Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
97da6817
Commit
97da6817
authored
Nov 04, 2014
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_aresample: split flushing code out
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
e4f8a973
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
19 deletions
+33
-19
af_aresample.c
libavfilter/af_aresample.c
+33
-19
No files found.
libavfilter/af_aresample.c
View file @
97da6817
...
...
@@ -223,6 +223,37 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
return
ret
;
}
static
int
flush_frame
(
AVFilterLink
*
outlink
,
int
final
,
AVFrame
**
outsamplesref_ret
)
{
AVFilterContext
*
ctx
=
outlink
->
src
;
AResampleContext
*
aresample
=
ctx
->
priv
;
AVFilterLink
*
const
inlink
=
outlink
->
src
->
inputs
[
0
];
AVFrame
*
outsamplesref
;
int
n_out
=
4096
;
int64_t
pts
;
outsamplesref
=
ff_get_audio_buffer
(
outlink
,
n_out
);
*
outsamplesref_ret
=
outsamplesref
;
if
(
!
outsamplesref
)
return
AVERROR
(
ENOMEM
);
pts
=
swr_next_pts
(
aresample
->
swr
,
INT64_MIN
);
pts
=
ROUNDED_DIV
(
pts
,
inlink
->
sample_rate
);
n_out
=
swr_convert
(
aresample
->
swr
,
outsamplesref
->
extended_data
,
n_out
,
final
?
NULL
:
(
void
*
)
outsamplesref
->
extended_data
,
0
);
if
(
n_out
<=
0
)
{
av_frame_free
(
&
outsamplesref
);
return
(
n_out
==
0
)
?
AVERROR_EOF
:
n_out
;
}
outsamplesref
->
sample_rate
=
outlink
->
sample_rate
;
outsamplesref
->
nb_samples
=
n_out
;
outsamplesref
->
pts
=
pts
;
return
0
;
}
static
int
request_frame
(
AVFilterLink
*
outlink
)
{
AVFilterContext
*
ctx
=
outlink
->
src
;
...
...
@@ -237,26 +268,9 @@ static int request_frame(AVFilterLink *outlink)
if
(
ret
==
AVERROR_EOF
)
{
AVFrame
*
outsamplesref
;
int
n_out
=
4096
;
int64_t
pts
;
outsamplesref
=
ff_get_audio_buffer
(
outlink
,
n_out
);
if
(
!
outsamplesref
)
return
AVERROR
(
ENOMEM
);
pts
=
swr_next_pts
(
aresample
->
swr
,
INT64_MIN
);
pts
=
ROUNDED_DIV
(
pts
,
inlink
->
sample_rate
);
n_out
=
swr_convert
(
aresample
->
swr
,
outsamplesref
->
extended_data
,
n_out
,
0
,
0
);
if
(
n_out
<=
0
)
{
av_frame_free
(
&
outsamplesref
);
return
(
n_out
==
0
)
?
AVERROR_EOF
:
n_out
;
}
outsamplesref
->
sample_rate
=
outlink
->
sample_rate
;
outsamplesref
->
nb_samples
=
n_out
;
outsamplesref
->
pts
=
pts
;
if
((
ret
=
flush_frame
(
outlink
,
1
,
&
outsamplesref
))
<
0
)
return
ret
;
return
ff_filter_frame
(
outlink
,
outsamplesref
);
}
...
...
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