[FFmpeg-cvslog] af_asyncts: fix offset calculation

Anton Khirnov git at videolan.org
Fri May 10 23:04:07 CEST 2013


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed May  8 21:44:20 2013 +0200| [16a4a18db089af8c432f1cdec62155000585b72c] | committer: Anton Khirnov

af_asyncts: fix offset calculation

delta is in samples, not bytes. Also the sample format is not guaranteed
to be planar.

CC:libav-stable at libav.org

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

 libavfilter/af_asyncts.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavfilter/af_asyncts.c b/libavfilter/af_asyncts.c
index a76415b..0ddd8b6 100644
--- a/libavfilter/af_asyncts.c
+++ b/libavfilter/af_asyncts.c
@@ -237,18 +237,23 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
         }
 
         if (s->first_frame && delta > 0) {
+            int planar = av_sample_fmt_is_planar(buf_out->format);
+            int planes = planar ?  nb_channels : 1;
+            int block_size = av_get_bytes_per_sample(buf_out->format) *
+                             (planar ? 1 : nb_channels);
+
             int ch;
 
             av_samples_set_silence(buf_out->extended_data, 0, delta,
                                    nb_channels, buf->format);
 
-            for (ch = 0; ch < nb_channels; ch++)
-                buf_out->extended_data[ch] += delta;
+            for (ch = 0; ch < planes; ch++)
+                buf_out->extended_data[ch] += delta * block_size;
 
             avresample_read(s->avr, buf_out->extended_data, out_size);
 
-            for (ch = 0; ch < nb_channels; ch++)
-                buf_out->extended_data[ch] -= delta;
+            for (ch = 0; ch < planes; ch++)
+                buf_out->extended_data[ch] -= delta * block_size;
         } else {
             avresample_read(s->avr, buf_out->extended_data, out_size);
 



More information about the ffmpeg-cvslog mailing list