[FFmpeg-cvslog] af_aresample: fix pts, they where off by a packet in the -async >0 case.

Michael Niedermayer git at videolan.org
Sun May 27 00:57:15 CEST 2012


ffmpeg | branch: release/0.11 | Michael Niedermayer <michaelni at gmx.at> | Sat May 26 16:17:47 2012 +0200| [982caeac3eb32e2a31724aaf7164b06c50264d94] | committer: Michael Niedermayer

af_aresample: fix pts, they where off by a packet in the -async >0 case.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit be97675e6cf686900ea4ff39251cec94cfe4109c)

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=982caeac3eb32e2a31724aaf7164b06c50264d94
---

 libavfilter/af_aresample.c |   35 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 23 deletions(-)

diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
index aab118b..8ead314 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);



More information about the ffmpeg-cvslog mailing list