From patchwork Sat Sep 22 16:13:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 10443 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:1286:0:0:0:0:0 with SMTP id 6-v6csp717866jap; Sat, 22 Sep 2018 09:15:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV60VFdfx0KRiW1NqTYusPVpB+kxUx5vgOllvvH71kme30q6ETZIWALsoyC3pfHMjWScWG9Bg X-Received: by 2002:a5d:50cf:: with SMTP id f15-v6mr2518506wrt.128.1537632929285; Sat, 22 Sep 2018 09:15:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537632929; cv=none; d=google.com; s=arc-20160816; b=i73MtLt2KGHN/ZcBqhagK8wW/B5Ob4Ds4YCO9uCWurTl0NHw3RkKAdEoALEzys6b2M YHXWMhMOtA+NnHcFRXpjhkNdC3hmZsZ3cdsX5xfV+kyu0vzFCkZv+G9P2r98lMHelrwe is3CW8b+WXZ/TwWMny0KpeFVezvcLbOCKh3xZtGRfuSRoXA4QCUCyiLWIo5bRh0k5rfk hyCi7YS3H9paL5wxdAOVyE5XTG5hUqr3Eg/6aaZVzn8clY+wLCAX7Wv7r2ZXyiCQlCGC Q4nhKTqmSLTZnjAlGK7meHrgnXLI8nlrfgsPgI+zyzUrVx/GFhVc3+xwk90lREd8t+gW z4cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=7fd0k2OmLmN6urF/RSMgC6+Gdl5LKwY6DSMoyjmP+ls=; b=0oWcMSKOQwclSRPx4Of36MYsj1p0DLLhTdW6OrKgM2lTfW9hJXufK0X7ToahiehghN g0FufdB83tscd7p6B0U7SxyTs77wxVce4evsbqbD/C3AcvStZNxmUHj81yU/DA4AUkTb o98UW1/P7PES+e3oJSUUxrg/LSnzXvBX5iKeKrhAQPe1I9sLLbDCB5rIlCPAkIz37r67 JP0zHpUKpH/tz2JWw7nd3fXoA2WlPvCQ0SaUsp3u0miXM7suobe/28aKPCLsqc22T32q uojGjDKZBM9LAPgPmzeStSwXoTRHj5lwKGXDtw6BUafYaMe/UIQeu6Wgu8EJg9Rjk4+l 8Qjg== 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 b7-v6si756234wrt.307.2018.09.22.09.15.28; Sat, 22 Sep 2018 09:15:29 -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 A27D968A57D; Sat, 22 Sep 2018 19:14:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-1.mx.upcmail.net (vie01a-dmta-pe06-1.mx.upcmail.net [84.116.36.14]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A050968A4B7 for ; Sat, 22 Sep 2018 19:14:48 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1g3kYh-0007Gj-1W for ffmpeg-devel@ffmpeg.org; Sat, 22 Sep 2018 18:15:03 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id egEw1y0180S5wYM01gExfo; Sat, 22 Sep 2018 18:14:57 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 22 Sep 2018 18:13:59 +0200 Message-Id: <20180922161408.22052-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180922161408.22052-1-michael@niedermayer.cc> References: <20180922161408.22052-1-michael@niedermayer.cc> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/11] avcodec/prosumer: Factorize the 2 loops in fill_elements() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Michael Niedermayer --- libavcodec/prosumer.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c index cf2a4afbf6..46031aa0c0 100644 --- a/libavcodec/prosumer.c +++ b/libavcodec/prosumer.c @@ -282,29 +282,24 @@ static void fill_elements(uint32_t idx, uint32_t shift, int size, uint32_t *e0, { uint32_t b, h = idx << (32 - shift); - for (int i = 0; i < size; i++) { - b = 4 * (table[2 * i + 1] & 0xF); - if (shift >= b && (h & (0xFFF00000u << (12 - b))) == (table[2 * i + 1] & 0xFFFF0000u)) { - if (table[2 * i] >> 8 == 0x80u) { - return; - } else { - *e1 = table[2 * i]; - *e0 = (*e0 & 0xFFFFFFu) | (((12 + b - shift) & 0xFFFFFFFCu | 0x40u) << 22); - shift -= b; - h <<= b; - break; - } - } - } - for (int i = 0; i < size; i++) { - b = 4 * (table[2 * i + 1] & 0xF); - if (shift >= b && (h & (0xFFF00000u << (12 - b))) == (table[2 * i + 1] & 0xFFFF0000u)) { - if (table[2 * i] >> 8 == 0x80u) { - return; - } else { - *e1 |= table[2 * i] << 16; - *e0 = (*e0 & 0xFFFFFFu) | (((12 + b - shift) & 0xFFFFFFFCu | 0x80u) << 22); - break; + for (int j = 0; j < 2; j++) { + for (int i = 0; i < size; i++) { + b = 4 * (table[2 * i + 1] & 0xF); + if (shift >= b && (h & (0xFFF00000u << (12 - b))) == (table[2 * i + 1] & 0xFFFF0000u)) { + if (table[2 * i] >> 8 == 0x80u) { + return; + } else { + if (j == 0) { + *e1 = table[2 * i]; + *e0 = (*e0 & 0xFFFFFFu) | (((12 + b - shift) & 0xFFFFFFFCu | 0x40u) << 22); + shift -= b; + h <<= b; + } else { + *e1 |= table[2 * i] << 16; + *e0 = (*e0 & 0xFFFFFFu) | (((12 + b - shift) & 0xFFFFFFFCu | 0x80u) << 22); + } + break; + } } } }