From patchwork Thu May 28 13:57:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 19932 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D2B2644A156 for ; Thu, 28 May 2020 16:57:53 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B6B1068AE45; Thu, 28 May 2020 16:57:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 92D5968AEA8 for ; Thu, 28 May 2020 16:57:46 +0300 (EEST) Received: by mail-pg1-f196.google.com with SMTP id p21so13497607pgm.13 for ; Thu, 28 May 2020 06:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+QKH0Tuc7O7m/7WWIvf88PBum6ydtQxO3/4AqfOZrfg=; b=CauWNuVMS1n2aqVNo+5dJSOt54z7cYVhrCQhRZLhRMbsnR/wLKR/05/k6jjQyPS8hr PSVpplbbMXrxYXTh7Dkg7cXup7s4L9X+JewcxLK5UzDaXhGfDwkTBUzaRlQwmtqYESJh YFgv7osrJLHNfvSpuvGxb2t8it2jFMp6egdCyne00bYt1Y3LPxwmexMqqVnWGpncu9eM l0z5JNmFQyXZanjpqmwEkZAvqkwfZg+xfdZK9IKqQFli7V6nrJiPIvQwnK8ezgdA67Dv B2kPzTDKW1mAoxiMieHt0RvcmRGTce6/TU9CjHKMmXmwUscF+tgZF4Cxp/lLIN1FAMeH M8kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+QKH0Tuc7O7m/7WWIvf88PBum6ydtQxO3/4AqfOZrfg=; b=rT9LfJy9EX6L7ZJeetyWoJaDNOKKQX0n1hi0gxAMEsCMZWOtTc5y5eatDCY0VXrjRl pAIWJEKTn4P6Gio3Kid21lsc0iwZAYKTBCRzR7sKqzuqGdwkk7GnfnDNkzazekFavL1v Gk9jnzHNWrkYKK7GB1VHQX98guGOJrNkWEKhH0Gvq4Ff7X8pRmsxtSgicX0HDX+Q1hDN yxQ7KLFx9K4N7gg3VXs/5V3vdWjsXhVju+R+lEna4PedOTzuX5MUZLKPtTy/621YsgSw Ym2x9eYVAXS4/5H5p5Diyvr2ndCTufclnlBmlqt9GCDDQLnFgl6IPEQzcdISmfTx644O zKMA== X-Gm-Message-State: AOAM530lqETi0qqHg/m/5BrrSqpa4x/N2sk9B0IWTs7dx4llyR3FDXIJ cJ6SPQuOcDkhKrrL0AU4L3ObFqp7 X-Google-Smtp-Source: ABdhPJz7ivP9A93IrwDckG0Rc7mTvmZ/dkzbUJR+cjbqMmFM/cn42o0FItHrf9qEmiyvN6o/P4RUXg== X-Received: by 2002:a62:1957:: with SMTP id 84mr1563926pfz.54.1590674264129; Thu, 28 May 2020 06:57:44 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id x11sm1412118pfm.196.2020.05.28.06.57.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 May 2020 06:57:43 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 May 2020 21:57:28 +0800 Message-Id: <1590674250-32571-5-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1590674250-32571-1-git-send-email-lance.lmwang@gmail.com> References: <1590674250-32571-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 5/7] avcodec/h264dec: define and use FF_ALLOCZ_TYPED_ARRAY helper macro X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang The macro will help to short the long lines and avoid split them. Signed-off-by: Limin Wang --- libavcodec/h264dec.c | 30 +++++++++++++++--------------- libavutil/internal.h | 2 ++ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index d5b3df3..b797c79 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(*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(*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)))) + if (!FF_ALLOCZ_TYPED_ARRAY(h->intra4x4_pred_mode, row_mb_num * 8) || + !FF_ALLOCZ_TYPED_ARRAY(h->non_zero_count, big_mb_num * 48) || + !FF_ALLOCZ_TYPED_ARRAY(h->slice_table_base, slice_tsize) || + !FF_ALLOCZ_TYPED_ARRAY(h->cbp_table, big_mb_num) || + !FF_ALLOCZ_TYPED_ARRAY(h->chroma_pred_mode_table,big_mb_num) || + !FF_ALLOCZ_TYPED_ARRAY(h->mvd_table[0], row_mb_num * 8) || + !FF_ALLOCZ_TYPED_ARRAY(h->mvd_table[1], row_mb_num * 8) || + !FF_ALLOCZ_TYPED_ARRAY(h->direct_table, big_mb_num * 4) || + !FF_ALLOCZ_TYPED_ARRAY(h->list_counts, big_mb_num) || + !FF_ALLOCZ_TYPED_ARRAY(h->mb2b_xy, big_mb_num) || + !FF_ALLOCZ_TYPED_ARRAY(h->mb2br_xy, big_mb_num)) 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(*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)))) + if (!FF_ALLOCZ_TYPED_ARRAY(er->mb_index2xy, h->mb_num + 1) || + !FF_ALLOCZ_TYPED_ARRAY(er->error_status_table, mb_array_size) || + !FF_ALLOCZ_TYPED_ARRAY(er->er_temp_buffer, h->mb_height * h->mb_stride + 1) || + !FF_ALLOCZ_TYPED_ARRAY(sl->dc_val_base, yc_size)) return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for us for (y = 0; y < h->mb_height; y++) diff --git a/libavutil/internal.h b/libavutil/internal.h index 4acbcf5..9c4499e 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -137,6 +137,8 @@ # define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,)) #endif +#define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_mallocz_array(nelem, sizeof(*p))) + #define FF_ALLOC_OR_GOTO(ctx, p, size, label)\ {\ p = av_malloc(size);\