From patchwork Sat Aug 3 16:57:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 14213 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 34325446D45 for ; Sat, 3 Aug 2019 19:57:47 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 11410680AE5; Sat, 3 Aug 2019 19:57:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 19114680268 for ; Sat, 3 Aug 2019 19:57:41 +0300 (EEST) X-Originating-IP: 213.47.41.20 Received: from localhost (213-47-41-20.cable.dynamic.surfer.at [213.47.41.20]) (Authenticated sender: michael@niedermayer.cc) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 69B97C0005 for ; Sat, 3 Aug 2019 16:57:40 +0000 (UTC) Date: Sat, 3 Aug 2019 18:57:39 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20190803165739.GY3219@michaelspb> References: <20190802234957.11098-1-michael@niedermayer.cc> <20190802234957.11098-4-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Subject: Re: [FFmpeg-devel] [PATCH 4/6] avcodec/hnm4video: Optimize postprocess_current_frame() 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" On Sat, Aug 03, 2019 at 04:07:22PM +0200, Tomas Härdin wrote: > lör 2019-08-03 klockan 01:49 +0200 skrev Michael Niedermayer: > > - uint32_t x, y, src_x, src_y; > > + uint32_t x, y, src_y; > > + int width = hnm->width; > > > > for (y = 0; y < hnm->height; y++) { > > + uint8_t *dst = hnm->processed + y * width; > > + const uint8_t *src = hnm->current; > > src_y = y - (y % 2); > > - src_x = src_y * hnm->width + (y % 2); > > - for (x = 0; x < hnm->width; x++) { > > - hnm->processed[(y * hnm->width) + x] = hnm- > > >current[src_x]; > > - src_x += 2; > > + src += src_y * width + (y % 2); > > + for (x = 0; x < width; x++) { > > + dst[x] = *src; > > + src += 2; > > Looks OK. Maybe telling the compiler that src and dst don't alias would > be worthwhile? i can add restrict keywords if you want: ? [...] diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c index 68d0baef6d..1c2501afab 100644 --- a/libavcodec/hnm4video.c +++ b/libavcodec/hnm4video.c @@ -121,8 +121,8 @@ static void postprocess_current_frame(AVCodecContext *avctx) int width = hnm->width; for (y = 0; y < hnm->height; y++) { - uint8_t *dst = hnm->processed + y * width; - const uint8_t *src = hnm->current; + uint8_t * restrict dst = hnm->processed + y * width; + const uint8_t * restrict src = hnm->current; src_y = y - (y % 2); src += src_y * width + (y % 2); for (x = 0; x < width; x++) {