Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
ef28c7b3
Commit
ef28c7b3
authored
Jan 15, 2011
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi: use av_samples_alloc() in avfilter_default_get_audio_buffer()
parent
95a02426
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
34 deletions
+4
-34
defaults.c
libavfilter/defaults.c
+4
-34
No files found.
libavfilter/defaults.c
View file @
ef28c7b3
...
@@ -86,8 +86,7 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per
...
@@ -86,8 +86,7 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per
{
{
AVFilterBuffer
*
samples
=
av_mallocz
(
sizeof
(
AVFilterBuffer
));
AVFilterBuffer
*
samples
=
av_mallocz
(
sizeof
(
AVFilterBuffer
));
AVFilterBufferRef
*
ref
=
NULL
;
AVFilterBufferRef
*
ref
=
NULL
;
int
i
,
sample_size
,
chans_nb
,
bufsize
,
per_channel_size
,
step_size
=
0
;
int
nb_channels
=
av_get_channel_layout_nb_channels
(
channel_layout
);
char
*
buf
;
if
(
!
samples
||
!
(
ref
=
av_mallocz
(
sizeof
(
AVFilterBufferRef
))))
if
(
!
samples
||
!
(
ref
=
av_mallocz
(
sizeof
(
AVFilterBufferRef
))))
goto
fail
;
goto
fail
;
...
@@ -109,41 +108,12 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per
...
@@ -109,41 +108,12 @@ AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int per
samples
->
refcount
=
1
;
samples
->
refcount
=
1
;
samples
->
free
=
ff_avfilter_default_free_buffer
;
samples
->
free
=
ff_avfilter_default_free_buffer
;
sample_size
=
av_get_bits_per_sample_fmt
(
sample_fmt
)
>>
3
;
chans_nb
=
av_get_channel_layout_nb_channels
(
channel_layout
);
per_channel_size
=
nb_samples
*
sample_size
;
/* Set the number of bytes to traverse to reach next sample of a particular channel:
* For planar, this is simply the sample size.
* For packed, this is the number of samples * sample_size.
*/
for
(
i
=
0
;
i
<
chans_nb
;
i
++
)
samples
->
linesize
[
i
]
=
planar
>
0
?
per_channel_size
:
sample_size
;
memset
(
&
samples
->
linesize
[
chans_nb
],
0
,
(
8
-
chans_nb
)
*
sizeof
(
samples
->
linesize
[
0
]));
/* Calculate total buffer size, round to multiple of 16 to be SIMD friendly */
/* Calculate total buffer size, round to multiple of 16 to be SIMD friendly */
bufsize
=
(
nb_samples
*
chans_nb
*
sample_size
+
15
)
&~
15
;
if
(
av_samples_alloc
(
samples
->
data
,
samples
->
linesize
,
buf
=
av_malloc
(
bufsize
);
nb_channels
,
nb_samples
,
sample_fmt
,
if
(
!
buf
)
planar
,
16
)
<
0
)
goto
fail
;
goto
fail
;
/* For planar, set the start point of each channel's data within the buffer
* For packed, set the start point of the entire buffer only
*/
samples
->
data
[
0
]
=
buf
;
if
(
buf
&&
planar
)
{
for
(
i
=
1
;
i
<
chans_nb
;
i
++
)
{
step_size
+=
per_channel_size
;
samples
->
data
[
i
]
=
buf
+
step_size
;
}
}
else
{
for
(
i
=
1
;
i
<
chans_nb
;
i
++
)
samples
->
data
[
i
]
=
buf
;
}
memset
(
&
samples
->
data
[
chans_nb
],
0
,
(
8
-
chans_nb
)
*
sizeof
(
samples
->
data
[
0
]));
memcpy
(
ref
->
data
,
samples
->
data
,
sizeof
(
ref
->
data
));
memcpy
(
ref
->
data
,
samples
->
data
,
sizeof
(
ref
->
data
));
memcpy
(
ref
->
linesize
,
samples
->
linesize
,
sizeof
(
ref
->
linesize
));
memcpy
(
ref
->
linesize
,
samples
->
linesize
,
sizeof
(
ref
->
linesize
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment