aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/alsdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-09-25 20:31:50 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-11-11 20:18:47 +0100
commit3a7fa0cebf60e2f3f367912043a623900195d6ae (patch)
tree04a4ef5ac55f46d22f27ef94fe2acecc3cac2a22 /libavcodec/alsdec.c
parentae4bfed934e3912bea994bb9c74019ac5c4e78d8 (diff)
downloadffmpeg-3a7fa0cebf60e2f3f367912043a623900195d6ae.tar.gz
avcodec/alsdec: Avoid dereferencing context pointer in inner interleave loop
This makes the decoder faster Improves/Fixes: Timeout (22sec -> 20sec) Testcase: 17619/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5078510820917248 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 581a895c5c8b464a7fc7ebbaa6d9f565c10bae62) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/alsdec.c')
-rw-r--r--libavcodec/alsdec.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index a53c170d18..56313d206c 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1815,15 +1815,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
#define INTERLEAVE_OUTPUT(bps) \
{ \
int##bps##_t *dest = (int##bps##_t*)frame->data[0]; \
+ int channels = avctx->channels; \
+ int32_t **raw_samples = ctx->raw_samples; \
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 < avctx->channels; c++) \
- *dest++ = ctx->raw_samples[c][sample] * (1U << shift); \
+ for (c = 0; c < channels; c++) \
+ *dest++ = raw_samples[c][sample] * (1U << shift); \
} else { \
for (sample = 0; sample < ctx->cur_frame_length; sample++) \
- for (c = 0; c < avctx->channels; c++) \
- *dest++ = ctx->raw_samples[sconf->chan_pos[c]][sample] * (1U << shift); \
+ for (c = 0; c < channels; c++) \
+ *dest++ = raw_samples[sconf->chan_pos[c]][sample] * (1U << shift);\
} \
}