[FFmpeg-cvslog] avcodec/mpegvideo_enc: remove FF_ALLOCZ_ARRAY_OR_GOTO and gotos lable

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


ffmpeg | branch: master | Limin Wang <lance.lmwang at gmail.com> | Tue Jun  2 23:59:15 2020 +0800| [67de2d6a8c9ae9ddacd36a2a05b8f96f3c9bad46] | committer: Limin Wang

avcodec/mpegvideo_enc: remove FF_ALLOCZ_ARRAY_OR_GOTO and gotos lable

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

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

 libavcodec/mpegvideo_enc.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index d1e2bd9975..c3ef40556a 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -925,27 +925,25 @@ FF_ENABLE_DEPRECATION_WARNINGS
     ff_qpeldsp_init(&s->qdsp);
 
     if (s->msmpeg4_version) {
-        FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats,
-                          2 * 2 * (MAX_LEVEL + 1) *
-                          (MAX_RUN + 1) * 2 * sizeof(int), fail);
+        int ac_stats_size = 2 * 2 * (MAX_LEVEL + 1) *  (MAX_RUN + 1) * 2 * sizeof(int);
+        if (!(s->ac_stats = av_mallocz(ac_stats_size)))
+            return AVERROR(ENOMEM);
     }
-    FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
-
-    FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix,   64 * 32 * sizeof(int), fail);
-    FF_ALLOCZ_OR_GOTO(s->avctx, s->q_chroma_intra_matrix, 64 * 32 * sizeof(int), fail);
-    FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix,   64 * 32 * sizeof(int), fail);
-    FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail);
-    FF_ALLOCZ_OR_GOTO(s->avctx, s->q_chroma_intra_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail);
-    FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail);
-    FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture,
-                      MAX_PICTURE_COUNT * sizeof(Picture *), fail);
-    FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture,
-                      MAX_PICTURE_COUNT * sizeof(Picture *), fail);
 
+    if (!(s->avctx->stats_out = av_mallocz(256))               ||
+        !FF_ALLOCZ_TYPED_ARRAY(s->q_intra_matrix,          32) ||
+        !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix,   32) ||
+        !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix,          32) ||
+        !FF_ALLOCZ_TYPED_ARRAY(s->q_intra_matrix16,        32) ||
+        !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32) ||
+        !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix16,        32) ||
+        !FF_ALLOCZ_TYPED_ARRAY(s->input_picture,           MAX_PICTURE_COUNT) ||
+        !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_PICTURE_COUNT))
+        return AVERROR(ENOMEM);
 
     if (s->noise_reduction) {
-        FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset,
-                          2 * 64 * sizeof(uint16_t), fail);
+        if (!FF_ALLOCZ_TYPED_ARRAY(s->dct_offset, 2))
+            return AVERROR(ENOMEM);
     }
 
     ff_dct_encode_init(s);
@@ -1060,8 +1058,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
     cpb_props->buffer_size = avctx->rc_buffer_size;
 
     return 0;
-fail:
-    return AVERROR_UNKNOWN;
 }
 
 av_cold int ff_mpv_encode_end(AVCodecContext *avctx)



More information about the ffmpeg-cvslog mailing list