aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-05-08 21:44:20 +0200
committerReinhard Tartler <siretart@tauware.de>2013-05-11 12:00:54 +0200
commit600bc1debaad1598fcc8aa5809de3de595d168eb (patch)
tree9ac1ede9a8a00b0c441b7e28d15cb4b6323ac27b
parent77a2f4cbcfc3ca29e128e830622fc8b6fc7676f6 (diff)
downloadffmpeg-600bc1debaad1598fcc8aa5809de3de595d168eb.tar.gz
af_asyncts: fix offset calculation
delta is in samples, not bytes. Also the sample format is not guaranteed to be planar. CC:libav-stable@libav.org (cherry picked from commit 16a4a18db089af8c432f1cdec62155000585b72c) Signed-off-by: Reinhard Tartler <siretart@tauware.de>
-rw-r--r--libavfilter/af_asyncts.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/libavfilter/af_asyncts.c b/libavfilter/af_asyncts.c
index 40680c8559..3ebe3b567e 100644
--- a/libavfilter/af_asyncts.c
+++ b/libavfilter/af_asyncts.c
@@ -237,18 +237,23 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *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);