From patchwork Sun Aug 5 20:29:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 9902 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp2540051jad; Sun, 5 Aug 2018 13:30:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpel7T5Ijb3575LZ7olaMb09u5PRKA5nS91nyU6r6pSf27LcPax0Ih9/MLm3rDn/AKpJvcwS X-Received: by 2002:a1c:c1c8:: with SMTP id r191-v6mr9387774wmf.103.1533501037188; Sun, 05 Aug 2018 13:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533501037; cv=none; d=google.com; s=arc-20160816; b=SjBxvV/3kT8Lhow5BBDllx0mpQ5+C55IDBKGBeNiI8Uw6MM3OWZo1al/BBWYLJxUE9 1MnGoKgSch2MsoJsVkjCFEISjedXltrqOVlrObOKZENh3DwzoY7pwih1xlXo+ODi0C+A 0e8gHwh4S3GNQrlhCvXl9sP7da1LAX1uQVnVv0tanq1uJ8xwnSSQ3bfiINt4iAccr/Ka dFKsglcFne+VtHFPggw8rLd1VblBJdI82aR+KOPwKL/QsrxFcTwPnpB9Yr6ZnZH6VsBP XeakLUn03Y/C5U0D6mVApe3KyjFCPxWpW6tCzqxcqsLdTtB5Wh0UeICBi395F1xR4vlT jcRw== 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=0R1ZheQuwnolzSWdPmViPnXE/rx8EYICpmPUx0E3hxk=; b=On+ElJScktTvrmoXV5q6ohK9RyHM6iDGBSljO5kEPvjXFj5m1CqIqb2dfca8hXjgOd 99ukz4WMPXqrqY2oX+p1fmjTyVUkaBd3Iuui7addzKJ+vCYPauljHtgXsY5ueu+4wkOO 7ysaQ5+nPnYJhyDRjyJY+oSDtOziPdToauvdwdp2wMgXlkBqQMrUaQVcQRalgV/OAfI9 AwtU8ZTOXzFRd/aX05cwzP+OjLUzD3eFUtcttGCFnuektTZjWO7C9UHIYGaXN3PcqWka lnt4PUZ0OkMZfPkEnfOnsdUVWJf9e6zifAfVRLwYkfGS1A09mjjU732LNFOXpPjKGKL+ ld4w== 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 j17-v6si7834992wrp.323.2018.08.05.13.30.36; Sun, 05 Aug 2018 13:30:37 -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 6011A68A3E2; Sun, 5 Aug 2018 23:30:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe07-1.mx.upcmail.net (vie01a-dmta-pe07-1.mx.upcmail.net [84.116.36.17]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C200068A3C3 for ; Sun, 5 Aug 2018 23:29:58 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe07.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fmPfO-0005dp-7w for ffmpeg-devel@ffmpeg.org; Sun, 05 Aug 2018 22:30:18 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id KYWD1y00B0S5wYM01YWEU4; Sun, 05 Aug 2018 22:30:14 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 5 Aug 2018 22:29:31 +0200 Message-Id: <20180805202937.7563-3-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 3/9] avcodec/gdv: Factor terms out of inner loops 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" This also replaces some loops by memcpy() Signed-off-by: Michael Niedermayer --- libavcodec/gdv.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/libavcodec/gdv.c b/libavcodec/gdv.c index 79ca157dde..274552a7be 100644 --- a/libavcodec/gdv.c +++ b/libavcodec/gdv.c @@ -83,44 +83,51 @@ static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, in if (gdv->scale_h && gdv->scale_v) { for (j = 0; j < h; j++) { int y = h - j - 1; + uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w; + uint8_t *src1 = dst + PREAMBLE_SIZE + (y>>1) * (w>>1); for (i = 0; i < w; i++) { int x = w - i - 1; - dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + (x>>1) + (y>>1) * (w>>1)]; + dst1[x] = src1[(x>>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>>1) * w]; - } + uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w; + uint8_t *src1 = dst + PREAMBLE_SIZE + (y>>1) * w; + memcpy(dst1, src1, w); } } else if (gdv->scale_v) { for (j = 0; j < h; j++) { int y = h - j - 1; + uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w; + uint8_t *src1 = dst + PREAMBLE_SIZE + y * (w>>1); for (i = 0; i < w; i++) { int x = w - i - 1; - dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + (x>>1) + y * (w>>1)]; + dst1[x] = src1[(x>>1)]; } } } if (scale_h && scale_v) { for (y = 0; y < (h>>1); y++) { + uint8_t *dst1 = dst + PREAMBLE_SIZE + y * (w>>1); + uint8_t *src1 = dst + PREAMBLE_SIZE + y*2 * w; for (x = 0; x < (w>>1); x++) { - dst[PREAMBLE_SIZE + x + y * (w>>1)] = dst[PREAMBLE_SIZE + x*2 + y*2 * w]; + dst1[x] = src1[x*2]; } } } else if (scale_h) { 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]; - } + uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w; + uint8_t *src1 = dst + PREAMBLE_SIZE + y*2 * w; + memcpy(dst1, src1, w); } } else if (scale_v) { for (y = 0; y < h; y++) { + uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w; for (x = 0; x < (w>>1); x++) { - dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + x*2 + y * w]; + dst1[x] = dst1[x*2]; } } }