[FFmpeg-devel] [PATCH v2 4/4] avcodec/h264dec: use FF_ALLOCZ_TYPED_ARRAY_OR_GOTO instead
lance.lmwang at gmail.com
lance.lmwang at gmail.com
Mon May 11 18:52:23 EEST 2020
From: Limin Wang <lance.lmwang at gmail.com>
Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
libavcodec/h264dec.c | 48 ++++++++++++++++++++++--------------------------
1 file changed, 22 insertions(+), 26 deletions(-)
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 4c355fe..4e223c1 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -186,34 +186,32 @@ int ff_h264_alloc_tables(H264Context *h)
row_mb_num, 8 * sizeof(uint8_t), fail)
h->slice_ctx[0].intra4x4_pred_mode = h->intra4x4_pred_mode;
- FF_ALLOCZ_OR_GOTO(h->avctx, h->non_zero_count,
- big_mb_num * 48 * sizeof(uint8_t), fail)
- FF_ALLOCZ_OR_GOTO(h->avctx, h->slice_table_base,
- (big_mb_num + h->mb_stride) * sizeof(*h->slice_table_base), fail)
- FF_ALLOCZ_OR_GOTO(h->avctx, h->cbp_table,
- big_mb_num * sizeof(uint16_t), fail)
- FF_ALLOCZ_OR_GOTO(h->avctx, h->chroma_pred_mode_table,
- big_mb_num * sizeof(uint8_t), fail)
- FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->mvd_table[0],
- row_mb_num, 16 * sizeof(uint8_t), fail);
- FF_ALLOCZ_ARRAY_OR_GOTO(h->avctx, h->mvd_table[1],
- row_mb_num, 16 * sizeof(uint8_t), fail);
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->non_zero_count,
+ big_mb_num * 48, fail)
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->slice_table_base,
+ big_mb_num + h->mb_stride, fail)
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->cbp_table,
+ big_mb_num, fail)
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->chroma_pred_mode_table,
+ big_mb_num, fail)
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->mvd_table[0],
+ row_mb_num * 16, fail);
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->mvd_table[1],
+ row_mb_num * 16, fail);
h->slice_ctx[0].mvd_table[0] = h->mvd_table[0];
h->slice_ctx[0].mvd_table[1] = h->mvd_table[1];
- FF_ALLOCZ_OR_GOTO(h->avctx, h->direct_table,
- 4 * big_mb_num * sizeof(uint8_t), fail);
- FF_ALLOCZ_OR_GOTO(h->avctx, h->list_counts,
- big_mb_num * sizeof(uint8_t), fail)
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->direct_table,
+ 4 * big_mb_num, fail);
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->list_counts,
+ big_mb_num, fail)
memset(h->slice_table_base, -1,
(big_mb_num + h->mb_stride) * sizeof(*h->slice_table_base));
h->slice_table = h->slice_table_base + h->mb_stride * 2 + 1;
- FF_ALLOCZ_OR_GOTO(h->avctx, h->mb2b_xy,
- big_mb_num * sizeof(uint32_t), fail);
- FF_ALLOCZ_OR_GOTO(h->avctx, h->mb2br_xy,
- big_mb_num * sizeof(uint32_t), fail);
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->mb2b_xy, big_mb_num, fail);
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, h->mb2br_xy, big_mb_num, fail);
for (y = 0; y < h->mb_height; y++)
for (x = 0; x < h->mb_width; x++) {
const int mb_xy = x + y * h->mb_stride;
@@ -268,8 +266,7 @@ 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
- FF_ALLOCZ_OR_GOTO(h->avctx, er->mb_index2xy,
- (h->mb_num + 1) * sizeof(int), fail);
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, er->mb_index2xy, h->mb_num + 1, fail);
for (y = 0; y < h->mb_height; y++)
for (x = 0; x < h->mb_width; x++)
@@ -278,14 +275,13 @@ int ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl)
er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) *
h->mb_stride + h->mb_width;
- FF_ALLOCZ_OR_GOTO(h->avctx, er->error_status_table,
- mb_array_size * sizeof(uint8_t), fail);
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, er->error_status_table,
+ mb_array_size, fail);
FF_ALLOC_OR_GOTO(h->avctx, er->er_temp_buffer,
h->mb_height * h->mb_stride * (4*sizeof(int) + 1), fail);
- FF_ALLOCZ_OR_GOTO(h->avctx, sl->dc_val_base,
- yc_size * sizeof(int16_t), fail);
+ FF_ALLOCZ_TYPED_ARRAY_OR_GOTO(h->avctx, sl->dc_val_base, yc_size, fail);
er->dc_val[0] = sl->dc_val_base + h->mb_width * 2 + 2;
er->dc_val[1] = sl->dc_val_base + y_size + h->mb_stride + 1;
er->dc_val[2] = er->dc_val[1] + c_size;
--
1.8.3.1
More information about the ffmpeg-devel
mailing list