From patchwork Mon Oct 2 02:18:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 5367 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.61.8 with SMTP id n8csp1028003jan; Sun, 1 Oct 2017 19:18:56 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCycePAH1gPdS7Ct9BuFI0f5Tl6nqynr/Om5HflqANG7YKYFnMTy0QOk/AqAvBc+N5Ibd0e X-Received: by 10.223.146.101 with SMTP id 92mr5304230wrj.21.1506910736568; Sun, 01 Oct 2017 19:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506910736; cv=none; d=google.com; s=arc-20160816; b=xfti5MkiPda1T2DsXi/GcpwCU3ShYk8g3NYoEvsZ4HDvpmkz/wBIyDBDWUWk+HuV5K WdYoqaaZIq0wmIzSyZ/YhCJN3rnT387ii2noL+HUb7cSi1glvszXeuFs9r69ZZFYBdN/ riwd3oKuezTP/4ps8APmygNt5Jg+OEF56rojT4+7hlWJrRFl2weFPZBIMo9m2PY14dpO d7rM9dXukiWD7uVWR7ltASKf16LQtd4U4c0xaRTqpoP24hzTYh3cGhwLHqWNmpyfFyZv ojTh6WDzyCuzGXjUn3FNEasYEN9aR3eGNT5OWqxc/xDEaSy0PzyizcChsv6CQtj9a9Hz jJdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=5mpSavGWeLfT5a5RL8uaH0rs8Dt8Q8sU4xaktGkc7DQ=; b=BI5HEq3cZ29Tleovxotrtu47t3efV0QI7Y3DrHaWUuxHOv8NVPx3AiNEFgaqxlQCRp csbdvKgL/6iYarCUe6ECrGAjdt3rmegIoleSi4taCHbbQtohlAqZOH07kanZ5ehWGH1n OsXSH8IleLKFqktVBf8ubEKIm/ML2F0mo3S7Jua5h8t8qLbHXULsRQpSkAc2aUTfbW91 y55thyJVpyTS5dmvYc0uWmtiYbw7E0JTsufA3t3bml2zRbcmNmCA1nfHeT8WBzjxi5Et dJ7xMNu1pckDm5dv8tlHgXuQqQ84mecADstEsedXSfffTJGqswRFXVQzLSWpbyLaaWZ9 xY4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b7si7902408wrd.163.2017.10.01.19.18.56; Sun, 01 Oct 2017 19:18:56 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B6B2E689DF9; Mon, 2 Oct 2017 05:18:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-1.mx.upcmail.net (vie01a-dmta-pe05-1.mx.upcmail.net [84.116.36.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C0BA8689DDC for ; Mon, 2 Oct 2017 05:18:22 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dyqJY-0005Yf-LA for ffmpeg-devel@ffmpeg.org; Mon, 02 Oct 2017 04:18:36 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id GSJS1w01G0S5wYM01SJTZS; Mon, 02 Oct 2017 04:18:27 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 2 Oct 2017 04:18:23 +0200 Message-Id: <20171002021823.31638-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171002021823.31638-1-michael@niedermayer.cc> References: <20171002021823.31638-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/proresdec2: Use LAST_SKIP_BITS where possible 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Michael Niedermayer --- libavcodec/proresdec2.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index 22dc70eeb4..9647aa7ebc 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -250,7 +250,7 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons return pic_data_size; } -#define DECODE_CODEWORD(val, codebook) \ +#define DECODE_CODEWORD(val, codebook, SKIP_BITSf) \ do { \ unsigned int rice_order, exp_order, switch_bits; \ unsigned int q, buf, bits; \ @@ -271,14 +271,14 @@ static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, cons return AVERROR_INVALIDDATA; \ val = SHOW_UBITS(re, gb, bits) - (1 << exp_order) + \ ((switch_bits + 1) << rice_order); \ - SKIP_BITS(re, gb, bits); \ + SKIP_BITSf(re, gb, bits); \ } else if (rice_order) { \ SKIP_BITS(re, gb, q+1); \ val = (q << rice_order) + SHOW_UBITS(re, gb, rice_order); \ - SKIP_BITS(re, gb, rice_order); \ + SKIP_BITSf(re, gb, rice_order); \ } else { \ val = q; \ - SKIP_BITS(re, gb, q+1); \ + SKIP_BITSf(re, gb, q+1); \ } \ } while (0) @@ -296,7 +296,7 @@ static av_always_inline int decode_dc_coeffs(GetBitContext *gb, int16_t *out, OPEN_READER(re, gb); - DECODE_CODEWORD(code, FIRST_DC_CB); + DECODE_CODEWORD(code, FIRST_DC_CB, LAST_SKIP_BITS); prev_dc = TOSIGNED(code); out[0] = prev_dc; @@ -305,7 +305,7 @@ static av_always_inline int decode_dc_coeffs(GetBitContext *gb, int16_t *out, code = 5; sign = 0; for (i = 1; i < blocks_per_slice; i++, out += 64) { - DECODE_CODEWORD(code, dc_codebook[FFMIN(code, 6U)]); + DECODE_CODEWORD(code, dc_codebook[FFMIN(code, 6U)], LAST_SKIP_BITS); if(code) sign ^= -(code & 1); else sign = 0; prev_dc += (((code + 1) >> 1) ^ sign) - sign; @@ -341,14 +341,14 @@ static av_always_inline int decode_ac_coeffs(AVCodecContext *avctx, GetBitContex if (!bits_left || (bits_left < 32 && !SHOW_UBITS(re, gb, bits_left))) break; - DECODE_CODEWORD(run, run_to_cb[FFMIN(run, 15)]); + DECODE_CODEWORD(run, run_to_cb[FFMIN(run, 15)], LAST_SKIP_BITS); pos += run + 1; if (pos >= max_coeffs) { av_log(avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", pos, max_coeffs); return AVERROR_INVALIDDATA; } - DECODE_CODEWORD(level, lev_to_cb[FFMIN(level, 9)]); + DECODE_CODEWORD(level, lev_to_cb[FFMIN(level, 9)], SKIP_BITS); level += 1; i = pos >> log2_block_count;