From patchwork Mon Apr 30 23:26:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 8707 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp4005083jad; Mon, 30 Apr 2018 16:33:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrx+Q1lUpoVksINENTaYJlIPrT1UfifLgoYWTur+i5x5ek/Mpk2+ESBSDApLnAZtxNl5sFu X-Received: by 10.28.136.149 with SMTP id k143mr5079837wmd.17.1525131199736; Mon, 30 Apr 2018 16:33:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525131199; cv=none; d=google.com; s=arc-20160816; b=wRuklXLY6sSxEEB2QFvszA10bUcXnQJYTFe56BPazgRkIRpivPXqAfX3pXKa4wuG8H 9VpEbCWRJZW+nWenyntYl2itkSJtxcf7rfQWDCTi4PbgNzv7vRGtpPg7FFV8im1cPNd4 6Lnt3Q3BlKTTs2JhNyJoRz9i70Qpia2a9FCGlpX4MIlbBgrUQkKcWRK9kIyTZ3xMmn9q pJTUrypf2R8M98LYgymInQG4yoyeBigwpr22Ros2mc1cOEPB2qWvIPIjgtSEIldjJU3A ERTKeO2LMrEnoJziB+LcNfOtC7ircnhcRWXt4/+NNdUbQuupk2pmjyBSo87wlICiwXbu 2SNg== 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:dkim-signature:delivered-to:arc-authentication-results; bh=RsDt6c4K18sj3lKsxymrYn4waYLr70LVYjiv9Z7Mq1o=; b=IzDT0LUeE+CAiicCK3qbeTSnftS7ay8OkqJ2JtqDYrIxHgSlsjgPvYPWj6Vwf3u9yY bdULCMZvvoFNJ9/LOtbsCm6Y3RxhwSbik/Z8fQqKitDErP2E8U31EkfgkDug+Rf/J8hM ENqj3Ec9frc14XjcmIdiyM4E/ZkyltLKTAthyb3VFpNV/d44iVsz4yMENnbJ1wYg0n4l CuG8j/PCIy/K6F8zjZTZsWD1QBn2Hkuvsm/KdhDwC2/AApKSPP/QFhwQ5BI7AAxSk+Aq 3obLlr4oR9zpbeZSYEARHHmu+hZfxVhbC4vnYdLnKSmBkhYchlkjNgSgAsCM6N9lkljn udFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.com header.s=20150623 header.b=OokmCnuO; 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 h25si6253844wmi.24.2018.04.30.16.33.19; Mon, 30 Apr 2018 16:33:19 -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; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.com header.s=20150623 header.b=OokmCnuO; 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 465B568A391; Tue, 1 May 2018 02:32:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DE87E68A154 for ; Tue, 1 May 2018 02:32:39 +0300 (EEST) Received: by mail-wm0-f68.google.com with SMTP id n10so16743780wmc.1 for ; Mon, 30 Apr 2018 16:33:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=IkeWHSozTT4mbDKZ1m7VmWdG97yxhDONMr5GYXZZj1g=; b=OokmCnuOgodaxUDf4VjrJBOnOKI9GkIu1VCIjhm/YfrDlpQgPmtxPg4dH//8Mi2kti TUMgzJaQNdTwUsfpojYnNW5lYpRJPanc75poqgatGGckKVD/lFefPMQBkUWH1K5ROc4q 6s8LW6Nkd0DnuRoCHP4zrYTi5fH/87O44t8LsSpf0EWDfBuKrtYWf35uWrJ2f2Ms9Mwl 9ohGLVZW9idOYGBl1s9S8Fn/+66024wiIzlH5jEGBbs3M6qs7mI5+jLSpzMRaKFA40V4 MwQVVpRprWkApuXQ4PrBieMo1lOQYZZqWxKbpTahUrWOOnx7rR6dr/zbva75xw7PEick wX9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=IkeWHSozTT4mbDKZ1m7VmWdG97yxhDONMr5GYXZZj1g=; b=EDo9eUVMBiPskv46jRQaw9C3osTHmOvnAO3lCTQL5urLCNpDN/loPhJmzx61mE6VGj 0Z/2Fh60o3gB9ouXn2yscH21oFcz7sLOkBP0rfmQ38n6bRc5qwjRp68MIcyWKzmnmtwA jfEmb5l7Jcp4F9pChUk2fHBiKWc0F9Eghi15H3NJ23Z9+ZH1sZHr/ulGI72oy8kQHqS3 zB9UdCCwXP4Ud5sestouOdpLiE5AOzOUUaqIfvLKcDcoFTm6/AeNKjsCqlYkYyepDgHc I3d74RB458X8SzfqURIWAdDo15e2L8KOTx6w0kkodHfP5UEIuKa0N1DTkQxIt1LZzX3W 8IoQ== X-Gm-Message-State: ALQs6tDY1Zx6QVKZRo4PXagnRwmvRpZSAeQJExCm5iNBRZFrSWGwW+Mm Yxqw+Zr6ld7nDRPvXnyUtBuJysPI X-Received: by 10.28.4.4 with SMTP id 4mr7814915wme.23.1525130771079; Mon, 30 Apr 2018 16:26:11 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id f5-v6sm8777229wrh.35.2018.04.30.16.26.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Apr 2018 16:26:10 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 May 2018 00:26:01 +0100 Message-Id: <20180430232605.4846-2-sw@jkqxz.net> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180430232605.4846-1-sw@jkqxz.net> References: <20180430232605.4846-1-sw@jkqxz.net> Subject: [FFmpeg-devel] [PATCH 2/6] cbs_h2645: Simplify representation of fixed values 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" --- Mainly to avoid messing with them in the following patch. libavcodec/cbs_h2645.c | 5 +++++ libavcodec/cbs_h264_syntax_template.c | 30 ++++++++++++--------------- libavcodec/cbs_h265_syntax_template.c | 38 +++++++++++++++-------------------- 3 files changed, 34 insertions(+), 39 deletions(-) diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 5585831cf6..c243dc7da4 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -239,6 +239,11 @@ static int cbs_write_se_golomb(CodedBitstreamContext *ctx, PutBitContext *pbc, #define FUNC_H264(rw, name) FUNC_NAME(rw, h264, name) #define FUNC_H265(rw, name) FUNC_NAME(rw, h265, name) +#define fixed(width, name, value) do { \ + av_unused uint32_t fixed_value = value; \ + xu(width, name, fixed_value, value, value); \ + } while (0) + #define READ #define READWRITE read diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index b5cd0b2310..7c507b9a13 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -19,10 +19,10 @@ static int FUNC(rbsp_trailing_bits)(CodedBitstreamContext *ctx, RWContext *rw) { int err; - av_unused int one = 1, zero = 0; - xu(1, rbsp_stop_one_bit, one, 1, 1); + + fixed(1, rbsp_stop_one_bit, 1); while (byte_alignment(rw) != 0) - xu(1, rbsp_alignment_zero_bit, zero, 0, 0); + fixed(1, rbsp_alignment_zero_bit, 0); return 0; } @@ -740,9 +740,8 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, break; case H264_SEI_TYPE_FILLER_PAYLOAD: { - av_unused int ff_byte = 0xff; for (i = 0; i < current->payload_size; i++) - xu(8, ff_byte, ff_byte, 0xff, 0xff); + fixed(8, ff_byte, 0xff); } break; case H264_SEI_TYPE_USER_DATA_REGISTERED: @@ -770,10 +769,9 @@ static int FUNC(sei_payload)(CodedBitstreamContext *ctx, RWContext *rw, } if (byte_alignment(rw)) { - av_unused int one = 1, zero = 0; - xu(1, bit_equal_to_one, one, 1, 1); + fixed(1, bit_equal_to_one, 1); while (byte_alignment(rw)) - xu(1, bit_equal_to_zero, zero, 0, 0); + fixed(1, bit_equal_to_zero, 0); } #ifdef READ @@ -810,14 +808,14 @@ static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw, uint32_t tmp; while (show_bits(rw, 8) == 0xff) { - xu(8, ff_byte, tmp, 0xff, 0xff); + fixed(8, ff_byte, 0xff); payload_type += 255; } xu(8, last_payload_type_byte, tmp, 0, 254); payload_type += tmp; while (show_bits(rw, 8) == 0xff) { - xu(8, ff_byte, tmp, 0xff, 0xff); + fixed(8, ff_byte, 0xff); payload_size += 255; } xu(8, last_payload_size_byte, tmp, 0, 254); @@ -853,14 +851,14 @@ static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw, tmp = current->payload[k].payload_type; while (tmp >= 255) { - xu(8, ff_byte, 0xff, 0xff, 0xff); + fixed(8, ff_byte, 0xff); tmp -= 255; } xu(8, last_payload_type_byte, tmp, 0, 254); tmp = current->payload[k].payload_size; while (tmp >= 255) { - xu(8, ff_byte, 0xff, 0xff, 0xff); + fixed(8, ff_byte, 0xff); tmp -= 255; } xu(8, last_payload_size_byte, tmp, 0, 254); @@ -1240,9 +1238,8 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw, } if (pps->entropy_coding_mode_flag) { - av_unused int one = 1; while (byte_alignment(rw)) - xu(1, cabac_alignment_one_bit, one, 1, 1); + fixed(1, cabac_alignment_one_bit, 1); } return 0; @@ -1251,7 +1248,6 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw, static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw, H264RawFiller *current) { - av_unused int ff_byte = 0xff; int err; HEADER("Filler Data"); @@ -1261,14 +1257,14 @@ static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw, #ifdef READ while (show_bits(rw, 8) == 0xff) { - xu(8, ff_byte, ff_byte, 0xff, 0xff); + fixed(8, ff_byte, 0xff); ++current->filler_size; } #else { uint32_t i; for (i = 0; i < current->filler_size; i++) - xu(8, ff_byte, ff_byte, 0xff, 0xff); + fixed(8, ff_byte, 0xff); } #endif diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index 140c827c9d..58a79f3014 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -19,10 +19,10 @@ static int FUNC(rbsp_trailing_bits)(CodedBitstreamContext *ctx, RWContext *rw) { int err; - av_unused int one = 1, zero = 0; - xu(1, rbsp_stop_one_bit, one, 1, 1); + + fixed(1, rbsp_stop_one_bit, 1); while (byte_alignment(rw) != 0) - xu(1, rbsp_alignment_zero_bit, zero, 0, 0); + fixed(1, rbsp_alignment_zero_bit, 0); return 0; } @@ -50,10 +50,10 @@ static int FUNC(nal_unit_header)(CodedBitstreamContext *ctx, RWContext *rw, static int FUNC(byte_alignment)(CodedBitstreamContext *ctx, RWContext *rw) { int err; - av_unused int one = 1, zero = 0; - xu(1, alignment_bit_equal_to_one, one, 1, 1); + + fixed(1, alignment_bit_equal_to_one, 1); while (byte_alignment(rw) != 0) - xu(1, alignment_bit_equal_to_zero, zero, 0, 0); + fixed(1, alignment_bit_equal_to_zero, 0); return 0; } @@ -90,7 +90,6 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw, int profile_present_flag, int max_num_sub_layers_minus1) { - av_unused unsigned int zero = 0; int err, i, j; if (profile_present_flag) { @@ -125,15 +124,15 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw, if (profile_compatible(5) || profile_compatible(9) || profile_compatible(10)) { flag(general_max_14bit_constraint_flag); - xu(24, general_reserved_zero_33bits, zero, 0, 0); - xu(9, general_reserved_zero_33bits, zero, 0, 0); + fixed(24, general_reserved_zero_33bits, 0); + fixed( 9, general_reserved_zero_33bits, 0); } else { - xu(24, general_reserved_zero_34bits, zero, 0, 0); - xu(10, general_reserved_zero_34bits, zero, 0, 0); + fixed(24, general_reserved_zero_34bits, 0); + fixed(10, general_reserved_zero_34bits, 0); } } else { - xu(24, general_reserved_zero_43bits, zero, 0, 0); - xu(19, general_reserved_zero_43bits, zero, 0, 0); + fixed(24, general_reserved_zero_43bits, 0); + fixed(19, general_reserved_zero_43bits, 0); } if (profile_compatible(1) || profile_compatible(2) || @@ -141,7 +140,7 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw, profile_compatible(5) || profile_compatible(9)) { flag(general_inbld_flag); } else { - xu(1, general_reserved_zero_bit, zero, 0, 0); + fixed(1, general_reserved_zero_bit, 0); } #undef profile_compatible } @@ -154,10 +153,8 @@ static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw, } if (max_num_sub_layers_minus1 > 0) { - for (i = max_num_sub_layers_minus1; i < 8; i++) { - av_unused int zero = 0; - xu(2, reserved_zero_2bits, zero, 0, 0); - } + for (i = max_num_sub_layers_minus1; i < 8; i++) + fixed(2, reserved_zero_2bits, 0); } for (i = 0; i < max_num_sub_layers_minus1; i++) { @@ -386,10 +383,7 @@ static int FUNC(vps)(CodedBitstreamContext *ctx, RWContext *rw, return AVERROR_INVALIDDATA; } - { - av_unused uint16_t ffff = 0xffff; - xu(16, vps_reserved_0xffff_16bits, ffff, 0xffff, 0xffff); - } + fixed(16, vps_reserved_0xffff_16bits, 0xffff); CHECK(FUNC(profile_tier_level)(ctx, rw, ¤t->profile_tier_level, 1, current->vps_max_sub_layers_minus1));