diff mbox series

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

Message ID 1590728554-23471-4-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 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/h264dec.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index b3bd8c8a67..8a4c85018f 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -185,17 +185,17 @@  int ff_h264_alloc_tables(H264Context *h)
     const int st_size = 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)))      ||
-        !(h->slice_table_base       = av_mallocz_array(st_size, 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 * 16, sizeof(uint8_t)))      ||
-        !(h->mvd_table[1]           = av_mallocz_array(row_mb_num * 16, 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))))
+    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(st_size, sizeof(*h->slice_table_base)))          ||
+        !(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 * 16, sizeof(*h->mvd_table[0])))      ||
+        !(h->mvd_table[1]           = av_mallocz_array(row_mb_num * 16, 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];
@@ -253,10 +253,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(er_size, sizeof(uint8_t)))       ||
-            !(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(er_size, 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++)