[FFmpeg-cvslog] avcodec/twinvq: remove FF_ALLOCZ_ARRAY_OR_GOTO and gotos label

Limin Wang git at videolan.org
Sat Jun 13 02:04:36 EEST 2020


ffmpeg | branch: master | Limin Wang <lance.lmwang at gmail.com> | Mon Jun  1 22:23:57 2020 +0800| [afaaf27fc4f3a5ff16d0f970603fb337ea9d8f8e] | committer: Limin Wang

avcodec/twinvq: remove FF_ALLOCZ_ARRAY_OR_GOTO and gotos label

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=afaaf27fc4f3a5ff16d0f970603fb337ea9d8f8e
---

 libavcodec/twinvq.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c
index 34ca1846b9..6dfaf06b14 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);
 }
 
 /**



More information about the ffmpeg-cvslog mailing list