summaryrefslogtreecommitdiff
path: root/libavfilter/framequeue.c
diff options
context:
space:
mode:
authorMuhammad Faiz <mfcc64@gmail.com>2017-05-18 20:10:47 +0700
committerMuhammad Faiz <mfcc64@gmail.com>2017-05-20 23:19:46 +0700
commitfc3a03fcf9cd7eafe7342e2508e6128888efa0bb (patch)
tree8d3214ab5511957d354ffeeda7b86f6994db8a1f /libavfilter/framequeue.c
parentf20161d8994399ba86f28e683126ea3b2ea0709b (diff)
downloadffmpeg-fc3a03fcf9cd7eafe7342e2508e6128888efa0bb.tar.gz
avfilter: take_samples: do not directly return frame when samples are skipped
Modifying data pointer when skipping samples may make it unaligned. Workaround for Ticket6349. This should fix the crash of ticket's testcase and a crash/regression with avxsynth (reported by Michael Niedermayer). Also change frame->nb_samples < max to frame->nb_samples <= max. This improves performance. Benchmark: ./ffmpeg -filter_complex "aevalsrc=0:n=1166,firequalizer=fixed=on" -f null null old: 25767 decicycles in take_samples, 1023 runs, 1 skips 25422 decicycles in take_samples, 2047 runs, 1 skips 25181 decicycles in take_samples, 4095 runs, 1 skips 24904 decicycles in take_samples, 8191 runs, 1 skips new: 550 decicycles in take_samples, 1024 runs, 0 skips 548 decicycles in take_samples, 2048 runs, 0 skips 545 decicycles in take_samples, 4096 runs, 0 skips 544 decicycles in take_samples, 8192 runs, 0 skips Reviewed-by: Nicolas George <george@nsup.org> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
Diffstat (limited to 'libavfilter/framequeue.c')
-rw-r--r--libavfilter/framequeue.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libavfilter/framequeue.c b/libavfilter/framequeue.c
index 26bfa49967..fed1118975 100644
--- a/libavfilter/framequeue.c
+++ b/libavfilter/framequeue.c
@@ -107,6 +107,7 @@ AVFrame *ff_framequeue_take(FFFrameQueue *fq)
fq->tail &= fq->allocated - 1;
fq->total_frames_tail++;
fq->total_samples_tail += b->frame->nb_samples;
+ fq->samples_skipped = 0;
check_consistency(fq);
return b->frame;
}
@@ -146,5 +147,6 @@ void ff_framequeue_skip_samples(FFFrameQueue *fq, size_t samples, AVRational tim
for (i = 0; i < planes && i < AV_NUM_DATA_POINTERS; i++)
b->frame->data[i] = b->frame->extended_data[i];
fq->total_samples_tail += samples;
+ fq->samples_skipped = 1;
ff_framequeue_update_peeked(fq, 0);
}