From patchwork Sun Mar 5 23:36:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 40590 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d046:b0:cd:afd7:272c with SMTP id hv6csp2478245pzb; Sun, 5 Mar 2023 15:37:26 -0800 (PST) X-Google-Smtp-Source: AK7set8kNeUrOxEnGfragFp8s0xtdxL0ckbXQMj1bJ6D6Kz5gktR7S4On7iJVUvW5IoRFG4GwlOv X-Received: by 2002:a17:906:9bdd:b0:88a:b6ca:7d3d with SMTP id de29-20020a1709069bdd00b0088ab6ca7d3dmr8984477ejc.8.1678059446505; Sun, 05 Mar 2023 15:37:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678059446; cv=none; d=google.com; s=arc-20160816; b=PEI9s9ubWrxjHWp2iAvyYEUJOuGZ3/wwFnW6MQfY5vYz9JPlab/TLDD/3vFAaL27sF V7Gn6fsujfKVjKb4vib3lXjLiOU5C9BKAUrLh2chgeQT+b/PHe/eun5XPA63dh3LoIOa Uh1aM+bXPtLaZHFbh0VEDLsZzGbAQt3ZT9X/wNX3W0Z2i4uYE1vBp8ehrICNnMXHYj0C HCgK57gsSAEh0yGUHHXl44ppM5szYUKgsuns0rGTr/97HdSRh1eCcz6Z/kHpAK+vU6K0 bLN+Sji2SwnvbzrGgD/qg8Y1s+u0IlJZoK1TeeB34AUVY1yR1kzxpnCqGz7SxUyNHdyk OtUA== 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; bh=5km0PnmM3Muy6DCJcvNKWqS9OD+rieqfWdQXTKbKQ08=; b=L9z+J/RbsDMGasktDIGEE9ysGtBPi//JpXvrYublTnLujRSOKsum3PjObfx7bCiTu2 Db9a069HEFvDYISzdCyZUxwCWDfPr6r6eVYWKMK0VLouPmmRiOh/lkDCzW81s8E/mB0Z 5uijXSqANmCAithGGrMDFq3Xj9q3WONHkksOnLUXqn2fjIpkvjiq+l5U5lmIXzJlJQbl 2pNGy+im/R7wbylNBxq6P5KZwV1rXRuX4hcadCgRfO5XWKT1qjGfTY3iyr4nrshnG3X4 6e5DCzaWi0kYlZhWSw57Yjo+iAnvyJN/TeGMH/CTq2tI77U9vLEJt+H0Upue/zHPctnI 2jCA== 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 s3-20020aa7c543000000b004af6e957024si8814643edr.580.2023.03.05.15.37.26; Sun, 05 Mar 2023 15:37:26 -0800 (PST) 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 7443668BB64; Mon, 6 Mar 2023 01:37:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3F06668BA07 for ; Mon, 6 Mar 2023 01:36:58 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 830CE40003 for ; Sun, 5 Mar 2023 23:36:57 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 6 Mar 2023 00:36:54 +0100 Message-Id: <20230305233654.13895-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230305233654.13895-1-michael@niedermayer.cc> References: <20230305233654.13895-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/escape124: Simplify unpack_codebook() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: lOgOrNiCu4ZB Signed-off-by: Michael Niedermayer --- libavcodec/escape124.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c index 064a4e6bf5..e8a8395f4b 100644 --- a/libavcodec/escape124.c +++ b/libavcodec/escape124.c @@ -97,15 +97,12 @@ static CodeBook unpack_codebook(GetBitContext* gb, unsigned depth, cb.size = size; for (i = 0; i < size; i++) { unsigned mask_bits = get_bits(gb, 4); - unsigned color0 = get_bits(gb, 15); - unsigned color1 = get_bits(gb, 15); - - for (j = 0; j < 4; j++) { - if (mask_bits & (1 << j)) - cb.blocks[i].pixels[j] = color1; - else - cb.blocks[i].pixels[j] = color0; - } + unsigned color[2]; + color[0] = get_bits(gb, 15); + color[1] = get_bits(gb, 15); + + for (j = 0; j < 4; j++) + cb.blocks[i].pixels[j] = color[(mask_bits>>j) & 1]; } return cb; }