aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-05-26 16:17:47 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-05-26 17:56:33 +0200
commit982caeac3eb32e2a31724aaf7164b06c50264d94 (patch)
tree82f26f546987e10c4da8eb09a55afba568d7ff9b
parentd108d0804a7d9f9a76f59358323ff38196bf4fce (diff)
downloadffmpeg-982caeac3eb32e2a31724aaf7164b06c50264d94.tar.gz
af_aresample: fix pts, they where off by a packet in the -async >0 case.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit be97675e6cf686900ea4ff39251cec94cfe4109c) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavfilter/af_aresample.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
index aab118b778..8ead3147a9 100644
--- a/libavfilter/af_aresample.c
+++ b/libavfilter/af_aresample.c
@@ -174,31 +174,9 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref
AVFilterLink *const outlink = inlink->dst->outputs[0];
AVFilterBufferRef *outsamplesref = ff_get_audio_buffer(outlink, AV_PERM_WRITE, n_out);
- n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out,
- (void *)insamplesref->extended_data, n_in);
- if (n_out <= 0) {
- avfilter_unref_buffer(outsamplesref);
- avfilter_unref_buffer(insamplesref);
- return;
- }
avfilter_copy_buffer_ref_props(outsamplesref, insamplesref);
- outsamplesref->audio->sample_rate = outlink->sample_rate;
- outsamplesref->audio->nb_samples = n_out;
-
-#if 0
- if(insamplesref->pts != AV_NOPTS_VALUE) {
- aresample->next_pts =
- outsamplesref->pts = av_rescale_q(insamplesref->pts, inlink->time_base, outlink->time_base)
- - swr_get_delay(aresample->swr, outlink->time_base.den);
- av_assert0(outlink->time_base.num == 1);
- } else{
- outsamplesref->pts = AV_NOPTS_VALUE; //aresample->next_pts;
- }
- if(aresample->next_pts != AV_NOPTS_VALUE)
- aresample->next_pts += av_rescale_q(n_out, (AVRational){1 ,outlink->sample_rate}, outlink->time_base);
-#else
if(insamplesref->pts != AV_NOPTS_VALUE) {
int64_t inpts = av_rescale(insamplesref->pts, inlink->time_base.num * (int64_t)outlink->sample_rate * inlink->sample_rate, inlink->time_base.den);
int64_t outpts= swr_next_pts(aresample->swr, inpts);
@@ -207,7 +185,18 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref
} else {
outsamplesref->pts = AV_NOPTS_VALUE;
}
-#endif
+
+ n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out,
+ (void *)insamplesref->extended_data, n_in);
+ if (n_out <= 0) {
+ avfilter_unref_buffer(outsamplesref);
+ avfilter_unref_buffer(insamplesref);
+ return;
+ }
+
+ outsamplesref->audio->sample_rate = outlink->sample_rate;
+ outsamplesref->audio->nb_samples = n_out;
+
ff_filter_samples(outlink, outsamplesref);
aresample->req_fullfilled= 1;
avfilter_unref_buffer(insamplesref);