diff mbox series

[FFmpeg-devel,v4,11/24] avcodec/twinvq: remove FF_ALLOCZ_ARRAY_OR_GOTO and gotos label

Message ID 1591111618-15778-11-git-send-email-lance.lmwang@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,v4,01/24] avcodec/h264dec: cosmetics
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Limin Wang June 2, 2020, 3:26 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/twinvq.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c
index 34ca184..6dfaf06 100644
--- a/libavcodec/twinvq.c
+++ b/libavcodec/twinvq.c
@@ -538,6 +538,7 @@  static av_cold int init_mdct_win(TwinVQContext *tctx)
     int size_m = mtab->size / mtab->fmode[TWINVQ_FT_MEDIUM].sub;
     int channels = tctx->avctx->channels;
     float norm = channels == 1 ? 2.0 : 1.0;
+    int table_size = 2 * mtab->size * channels;
 
     for (i = 0; i < 3; i++) {
         int bsize = tctx->mtab->size / tctx->mtab->fmode[i].sub;
@@ -546,25 +547,17 @@  static av_cold int init_mdct_win(TwinVQContext *tctx)
             return ret;
     }
 
-    FF_ALLOC_ARRAY_OR_GOTO(tctx->avctx, tctx->tmp_buf,
-                     mtab->size, sizeof(*tctx->tmp_buf), alloc_fail);
-
-    FF_ALLOC_ARRAY_OR_GOTO(tctx->avctx, tctx->spectrum,
-                     2 * mtab->size, channels * sizeof(*tctx->spectrum),
-                     alloc_fail);
-    FF_ALLOC_ARRAY_OR_GOTO(tctx->avctx, tctx->curr_frame,
-                     2 * mtab->size, channels * sizeof(*tctx->curr_frame),
-                     alloc_fail);
-    FF_ALLOC_ARRAY_OR_GOTO(tctx->avctx, tctx->prev_frame,
-                     2 * mtab->size, channels * sizeof(*tctx->prev_frame),
-                     alloc_fail);
+    if (!FF_ALLOC_TYPED_ARRAY(tctx->tmp_buf,    mtab->size) ||
+        !FF_ALLOC_TYPED_ARRAY(tctx->spectrum,   table_size) ||
+        !FF_ALLOC_TYPED_ARRAY(tctx->curr_frame, table_size) ||
+        !FF_ALLOC_TYPED_ARRAY(tctx->prev_frame, table_size))
+        return AVERROR(ENOMEM);
 
     for (i = 0; i < 3; i++) {
         int m       = 4 * mtab->size / mtab->fmode[i].sub;
         double freq = 2 * M_PI / m;
-        FF_ALLOC_ARRAY_OR_GOTO(tctx->avctx, tctx->cos_tabs[i],
-                         (m / 4), sizeof(*tctx->cos_tabs[i]), alloc_fail);
-
+        if (!FF_ALLOC_TYPED_ARRAY(tctx->cos_tabs[i], m / 4))
+            return AVERROR(ENOMEM);
         for (j = 0; j <= m / 8; j++)
             tctx->cos_tabs[i][j] = cos((2 * j + 1) * freq);
         for (j = 1; j < m / 8; j++)
@@ -576,9 +569,6 @@  static av_cold int init_mdct_win(TwinVQContext *tctx)
     ff_init_ff_sine_windows(av_log2(mtab->size));
 
     return 0;
-
-alloc_fail:
-    return AVERROR(ENOMEM);
 }
 
 /**