[FFmpeg-cvslog] avcodec/alsdec: Avoid 1 layer of pointer dereferences in INTERLEAVE_OUTPUT()
Michael Niedermayer
git at videolan.org
Sun Dec 1 18:20:12 EET 2019
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sat Nov 9 21:52:26 2019 +0100| [fd3c34ff304aebbeba1e730957bef08280fc9e10] | committer: Michael Niedermayer
avcodec/alsdec: Avoid 1 layer of pointer dereferences in INTERLEAVE_OUTPUT()
This optimizes the code slightly (116 -> 80sec)
Testcase: 18668/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5710836719157248
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fd3c34ff304aebbeba1e730957bef08280fc9e10
---
libavcodec/alsdec.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 4bc0e2bd84..babe30bdc7 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1819,16 +1819,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
{ \
int##bps##_t *dest = (int##bps##_t*)frame->data[0]; \
int channels = avctx->channels; \
- int32_t **raw_samples = ctx->raw_samples; \
+ int32_t *raw_samples = ctx->raw_samples[0]; \
+ int raw_step = channels > 1 ? ctx->raw_samples[1] - raw_samples : 1; \
shift = bps - ctx->avctx->bits_per_raw_sample; \
if (!ctx->cs_switch) { \
for (sample = 0; sample < ctx->cur_frame_length; sample++) \
for (c = 0; c < channels; c++) \
- *dest++ = raw_samples[c][sample] * (1U << shift); \
+ *dest++ = raw_samples[c*raw_step + sample] * (1U << shift); \
} else { \
for (sample = 0; sample < ctx->cur_frame_length; sample++) \
for (c = 0; c < channels; c++) \
- *dest++ = raw_samples[sconf->chan_pos[c]][sample] * (1U << shift);\
+ *dest++ = raw_samples[sconf->chan_pos[c]*raw_step + sample] * (1U << shift);\
} \
}
More information about the ffmpeg-cvslog
mailing list