From patchwork Sun Aug 5 20:29:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 9900 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp2539816jad; Sun, 5 Aug 2018 13:30:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpejxihL8EiVDWCRLvq8/yqeOozTD4p0sZS23B+cDYjFm0zpz/ssk9xj9U2S4PStiY2Y4PpR X-Received: by 2002:a1c:7301:: with SMTP id d1-v6mr9639455wmb.34.1533501021485; Sun, 05 Aug 2018 13:30:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533501021; cv=none; d=google.com; s=arc-20160816; b=0AUUdUXgFFUPHnbgr33B9M3DwzwGED6xdxeKtm4hxdU3FnftO0tDo+fplF4wib5yWT 46dAstHFCaAxwb5yM0bVIMTYd+2iztcpZgIXHkCOxppXk64dHh7NA+a4ZVJgD9Hj191C 6CxmEcVOLZf5o7RGBF9WYZLPByL9P6KdYtjHOiWxuoxV3qfpS7XK3Q7KuLLLF8THKYo1 M8oKeTiiRxLJNT1PiwfQc3tEjFsMO1Lnkp/T2fNsIx+Ob0HggVnf17CWM/P6iH3PN91Z Oe2yDYd0u7D3PZU7QyJodgtai/JJWCymd3qd9lWGewSkfRS/vamtJUztriHe9cN/kADD sD7Q== 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=eo0WH4iB7n63gJepDlIsXqodfhTMdmd428gPHjKwEPo=; b=p//FrbxLeWARi7cApEZ1y+C3ZIqGxPFQmVzLFTN4S+TlB+zmfEpeO+B8/0Fuz5+h81 miFQZ8cb++SBcA+Cck3G8ci2+BcRDpxykyOEoxrr3SzCt7bS6r7IrZTpQpIhwYGgzxuw 4RXtgVdUBVPdcC3KT2wGzu8HSCzsyy5fk1h3pn6v7pmLET89oWEuVA01oYGyAtgDg61W w7Y6y1VZUrPlmebHy+tIv0AGUDxIVD1U3FsAAyQAg6+vThGqBs2ntnKQfyyZn2cy0d6i V+cBK0Csj6hc5S3NstLLbJJcC8SNrzE4itfZqtOas5P19Y9cZC1GcFcw0IVhOk/Tp3DZ 1BKw== 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 r7-v6si4074560wma.141.2018.08.05.13.30.21; Sun, 05 Aug 2018 13:30:21 -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 C470368064F; Sun, 5 Aug 2018 23:29:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-2.mx.upcmail.net (vie01a-dmta-pe06-2.mx.upcmail.net [84.116.36.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6958468064F for ; Sun, 5 Aug 2018 23:29:53 +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 1fmPfJ-0005oA-0U for ffmpeg-devel@ffmpeg.org; Sun, 05 Aug 2018 22:30:13 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id KYWB1y0210S5wYM01YWCT4; Sun, 05 Aug 2018 22:30:12 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 5 Aug 2018 22:29:30 +0200 Message-Id: <20180805202937.7563-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180805202937.7563-1-michael@niedermayer.cc> References: <20180805202937.7563-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/9] avcodec/gdv: Replace divisions by shifts in rescale() 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" Divisions tend to be slower than shifts unless the compiler optimizes them out. And some of these are in inner loops. Signed-off-by: Michael Niedermayer --- libavcodec/gdv.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/gdv.c b/libavcodec/gdv.c index e52a637610..79ca157dde 100644 --- a/libavcodec/gdv.c +++ b/libavcodec/gdv.c @@ -85,14 +85,14 @@ static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, in int y = h - j - 1; for (i = 0; i < w; i++) { int x = w - i - 1; - dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + x/2 + (y/2) * (w/2)]; + dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + (x>>1) + (y>>1) * (w>>1)]; } } } else if (gdv->scale_h) { for (j = 0; j < h; j++) { int y = h - j - 1; for (x = 0; x < w; x++) { - dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + x + (y/2) * w]; + dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + x + (y>>1) * w]; } } } else if (gdv->scale_v) { @@ -100,26 +100,26 @@ static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, in int y = h - j - 1; for (i = 0; i < w; i++) { int x = w - i - 1; - dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + x/2 + y * (w/2)]; + dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + (x>>1) + y * (w>>1)]; } } } if (scale_h && scale_v) { - for (y = 0; y < h/2; y++) { - for (x = 0; x < w/2; x++) { - dst[PREAMBLE_SIZE + x + y * (w/2)] = dst[PREAMBLE_SIZE + x*2 + y*2 * w]; + for (y = 0; y < (h>>1); y++) { + for (x = 0; x < (w>>1); x++) { + dst[PREAMBLE_SIZE + x + y * (w>>1)] = dst[PREAMBLE_SIZE + x*2 + y*2 * w]; } } } else if (scale_h) { - for (y = 0; y < h/2; y++) { + for (y = 0; y < (h>>1); y++) { for (x = 0; x < w; x++) { dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + x + y*2 * w]; } } } else if (scale_v) { for (y = 0; y < h; y++) { - for (x = 0; x < w/2; x++) { + for (x = 0; x < (w>>1); x++) { dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + x*2 + y * w]; } }