[FFmpeg-devel] [PATCH 4/7] avcodec/h264dec: prefer to use variable instead of type for sizeof

lance.lmwang at gmail.com lance.lmwang at gmail.com
Thu May 28 16:57:27 EEST 2020


From: Limin Wang <lance.lmwang at gmail.com>

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
 libavcodec/h264dec.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 974d324..d5b3df3 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -185,17 +185,17 @@ int ff_h264_alloc_tables(H264Context *h)
     const int slice_tsize = big_mb_num + h->mb_stride;
     int x, y;
 
-    if (!(h->intra4x4_pred_mode     = av_mallocz_array(row_mb_num * 8, sizeof(uint8_t)))                ||
-        !(h->non_zero_count         = av_mallocz_array(big_mb_num * 48, sizeof(uint8_t)))               ||
+    if (!(h->intra4x4_pred_mode     = av_mallocz_array(row_mb_num * 8, sizeof(*h->intra4x4_pred_mode))) ||
+        !(h->non_zero_count         = av_mallocz_array(big_mb_num * 48, sizeof(*h->non_zero_count)))    ||
         !(h->slice_table_base       = av_mallocz_array(slice_tsize, sizeof(*h->slice_table_base)))      ||
-        !(h->cbp_table              = av_mallocz_array(big_mb_num, sizeof(uint16_t)))                   ||
-        !(h->chroma_pred_mode_table = av_mallocz_array(big_mb_num, sizeof(uint8_t)))                    ||
-        !(h->mvd_table[0]           = av_mallocz_array(row_mb_num * 8, sizeof(uint8_t)))                ||
-        !(h->mvd_table[1]           = av_mallocz_array(row_mb_num * 8, sizeof(uint8_t)))                ||
-        !(h->direct_table           = av_mallocz_array(big_mb_num * 4, sizeof(uint8_t)))                ||
-        !(h->list_counts            = av_mallocz_array(big_mb_num, sizeof(uint8_t)))                    ||
-        !(h->mb2b_xy                = av_mallocz_array(big_mb_num, sizeof(uint32_t)))                   ||
-        !(h->mb2br_xy               = av_mallocz_array(big_mb_num, sizeof(uint32_t))))
+        !(h->cbp_table              = av_mallocz_array(big_mb_num, sizeof(*h->cbp_table)))              ||
+        !(h->chroma_pred_mode_table = av_mallocz_array(big_mb_num, sizeof(*h->chroma_pred_mode_table))) ||
+        !(h->mvd_table[0]           = av_mallocz_array(row_mb_num * 8, sizeof(*h->mvd_table[0])))       ||
+        !(h->mvd_table[1]           = av_mallocz_array(row_mb_num * 8, sizeof(*h->mvd_table[1])))       ||
+        !(h->direct_table           = av_mallocz_array(big_mb_num * 4, sizeof(*h->direct_table)))       ||
+        !(h->list_counts            = av_mallocz_array(big_mb_num, sizeof(*h->list_counts)))            ||
+        !(h->mb2b_xy                = av_mallocz_array(big_mb_num, sizeof(*h->mb2b_xy)))                ||
+        !(h->mb2br_xy               = av_mallocz_array(big_mb_num, sizeof(*h->mb2br_xy))))
         return AVERROR(ENOMEM);
     h->slice_ctx[0].intra4x4_pred_mode = h->intra4x4_pred_mode;
     h->slice_ctx[0].mvd_table[0] = h->mvd_table[0];
@@ -252,10 +252,10 @@ int ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl)
         er->b8_stride   = h->mb_width * 2 + 1;
 
         // error resilience code looks cleaner with this
-        if (!(er->mb_index2xy        = av_mallocz_array(h->mb_num + 1, sizeof(int)))                   ||
-            !(er->error_status_table = av_mallocz_array(mb_array_size, sizeof(uint8_t)))               ||
-            !(er->er_temp_buffer     = av_mallocz_array(h->mb_height * h->mb_stride + 1, sizeof(int))) ||
-            !(sl->dc_val_base        = av_mallocz_array(yc_size, sizeof(int16_t))))
+        if (!(er->mb_index2xy        = av_mallocz_array(h->mb_num + 1, sizeof(*er->mb_index2xy)))                      ||
+            !(er->error_status_table = av_mallocz_array(mb_array_size, sizeof(*er->error_status_table)))               ||
+            !(er->er_temp_buffer     = av_mallocz_array(h->mb_height * h->mb_stride + 1, sizeof(*er->er_temp_buffer))) ||
+            !(sl->dc_val_base        = av_mallocz_array(yc_size, sizeof(*sl->dc_val_base))))
             return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for us
 
         for (y = 0; y < h->mb_height; y++)
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list