diff mbox series

[FFmpeg-devel,v2,6/7] avcodec/adpcmenc: remove FF_ALLOC_OR_GOTO macros for gotos will be removed

Message ID 1590728554-23471-6-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2,1/7] avcodec/h264dec: cosmetics
Related show

Checks

Context Check Description
andriy/default pending
andriy/make_warn warning New warnings during build
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Limin Wang May 29, 2020, 5:02 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/adpcmenc.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index d5fbc0b9a7..bcb6783c0c 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -89,14 +89,11 @@  static av_cold int adpcm_encode_init(AVCodecContext *avctx)
     if (avctx->trellis) {
         int frontier  = 1 << avctx->trellis;
         int max_paths =  frontier * FREEZE_INTERVAL;
-        FF_ALLOC_OR_GOTO(avctx, s->paths,
-                         max_paths * sizeof(*s->paths), error);
-        FF_ALLOC_OR_GOTO(avctx, s->node_buf,
-                         2 * frontier * sizeof(*s->node_buf),  error);
-        FF_ALLOC_OR_GOTO(avctx, s->nodep_buf,
-                         2 * frontier * sizeof(*s->nodep_buf), error);
-        FF_ALLOC_OR_GOTO(avctx, s->trellis_hash,
-                         65536 * sizeof(*s->trellis_hash), error);
+        if (!FF_ALLOC_TYPED_ARRAY(s->paths, max_paths)        ||
+            !FF_ALLOC_TYPED_ARRAY(s->node_buf, 2 * frontier)  ||
+            !FF_ALLOC_TYPED_ARRAY(s->nodep_buf, 2 * frontier) ||
+            !FF_ALLOC_TYPED_ARRAY(s->trellis_hash, 65536))
+            return AVERROR(ENOMEM);
     }
 
     avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);
@@ -523,7 +520,8 @@  static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
 
         /* stereo: 4 bytes (8 samples) for left, 4 bytes for right */
         if (avctx->trellis > 0) {
-            FF_ALLOC_ARRAY_OR_GOTO(avctx, buf, avctx->channels, blocks * 8, error);
+            if (!FF_ALLOC_TYPED_ARRAY(buf, avctx->channels * blocks * 8))
+                return AVERROR(ENOMEM);
             for (ch = 0; ch < avctx->channels; ch++) {
                 adpcm_compress_trellis(avctx, &samples_p[ch][1],
                                        buf + ch * blocks * 8, &c->status[ch],
@@ -618,7 +616,8 @@  static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
         }
 
         if (avctx->trellis > 0) {
-            FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error);
+            if (!(buf = av_malloc(2 * n)))
+                return AVERROR(ENOMEM);
             adpcm_compress_trellis(avctx, samples + avctx->channels, buf,
                                    &c->status[0], n, avctx->channels);
             if (avctx->channels == 2)
@@ -666,7 +665,8 @@  static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
 
         if (avctx->trellis > 0) {
             n = avctx->block_align - 7 * avctx->channels;
-            FF_ALLOC_OR_GOTO(avctx, buf, 2 * n, error);
+            if (!(buf = av_malloc(2 * n)))
+                return AVERROR(ENOMEM);
             if (avctx->channels == 1) {
                 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,
                                        avctx->channels);
@@ -693,7 +693,8 @@  static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     case AV_CODEC_ID_ADPCM_YAMAHA:
         n = frame->nb_samples / 2;
         if (avctx->trellis > 0) {
-            FF_ALLOC_OR_GOTO(avctx, buf, 2 * n * 2, error);
+            if (!(buf = av_malloc(2 * n * 2)))
+                return AVERROR(ENOMEM);
             n *= 2;
             if (avctx->channels == 1) {
                 adpcm_compress_trellis(avctx, samples, buf, &c->status[0], n,