diff mbox series

[FFmpeg-devel,08/17] avcodec/alsdec: Improve code locality

Message ID AM7PR03MB666068EEC0A902B7FE4DB2638F319@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit e925d5453b476017ef7aff60b66e98fb74168b2f
Headers show
Series [FFmpeg-devel,01/17] avcodec/svq3: Mark decoder as init-threadsafe | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 12, 2022, 6:41 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/alsdec.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index f8609e61fd..c09401d257 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -2094,12 +2094,6 @@  static av_cold int decode_init(AVCodecContext *avctx)
         ctx->reverted_channels = NULL;
     }
 
-    channel_size      = sconf->frame_length + sconf->max_order;
-
-    ctx->prev_raw_samples = av_malloc_array(sconf->max_order, sizeof(*ctx->prev_raw_samples));
-    ctx->raw_buffer       = av_calloc(avctx->channels * channel_size, sizeof(*ctx->raw_buffer));
-    ctx->raw_samples      = av_malloc_array(avctx->channels, sizeof(*ctx->raw_samples));
-
     if (sconf->floating) {
         ctx->acf               = av_malloc_array(avctx->channels, sizeof(*ctx->acf));
         ctx->shift_value       = av_malloc_array(avctx->channels, sizeof(*ctx->shift_value));
@@ -2125,7 +2119,12 @@  static av_cold int decode_init(AVCodecContext *avctx)
         }
     }
 
+    channel_size      = sconf->frame_length + sconf->max_order;
+
     // allocate previous raw sample buffer
+    ctx->prev_raw_samples = av_malloc_array(sconf->max_order, sizeof(*ctx->prev_raw_samples));
+    ctx->raw_buffer       = av_calloc(avctx->channels * channel_size, sizeof(*ctx->raw_buffer));
+    ctx->raw_samples      = av_malloc_array(avctx->channels, sizeof(*ctx->raw_samples));
     if (!ctx->prev_raw_samples || !ctx->raw_buffer|| !ctx->raw_samples) {
         av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
         return AVERROR(ENOMEM);