From patchwork Thu Oct 10 00:18:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Skakov Pavel X-Patchwork-Id: 15646 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 DED8444A313 for ; Thu, 10 Oct 2019 03:18:34 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B70D768812E; Thu, 10 Oct 2019 03:18:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E26F868025D for ; Thu, 10 Oct 2019 03:18:28 +0300 (EEST) Received: by mail-lj1-f182.google.com with SMTP id f5so4287764ljg.8 for ; Wed, 09 Oct 2019 17:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=bT+bstz35fqSUrkVVKDYXdA45ChPILSAEZwEThCOP7Q=; b=ety4MTGAiUlQfgnNsO2jMau0UoM/Z9+DXbG2NbYpupDV8fGZCdurBV48B5Qu4x2VJ/ yzyl09Pd6yP5YUIRhIdNTg70IE2DlO9zuTqpoYsy0mFt3kCS5DtqOZ6EnvFR04W+5vt/ byjjBJ5S5LML6zDcg7gfIgyXUlpAdT7oOCQ92naRefxv33DO5t8kFE8LpuGsFqJ3kFT1 7grHlM+k24KjZuC0NaXy5/YPxyeMrXR1zNr9bYkC5QeooQ4TvY+d3wp+JQX9nN3+b6nb LYuLIpte2jKC4tkfG05bI8SSDJnPZ3AfA9JVQWXUEK6OudZHkcBlMIeVrGV6sQpiUwg8 XZMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=bT+bstz35fqSUrkVVKDYXdA45ChPILSAEZwEThCOP7Q=; b=EFjw3Ei2FNj/ZzwFUl2ZANdc56lyhC9KhhLeLWNtWT5//wylqTrv7Kb8fNNKuRt/LX pFuTRTlSjXomdvGiCeFjti8dew6Dg2TjXASj/vfv8FSNlESdao//qPugSp7zBDxIwWTo u/7meHDG3hQnsxCEw7slhZ5DeCSDNJnxX1vc0BfdWtpi6dTgoNcDjN8ZC0YvVxX937wJ OM2sWIHcjWWGHH4RjcFZZv/bapjXe09BL2xOk2I6tD5dLufCqUU+eseKxPToH9PAVJqw juE4wqUHIRcq9RHf+UajqlCECEqhx8rrIjA5JOHZTKo4Bcrvy9CouShbapsn7hoq5Zr1 YeRA== X-Gm-Message-State: APjAAAUQ/dRulS2+2I9s/cHho9csHci2lAnBfPXjToxiTdYbqn5s8OVB fSGtledQwJQ8Q7OrFC01Bd3Cvfqb X-Google-Smtp-Source: APXvYqzvDKrII9aN9Gji9rTh2+ar8F5cGsx9xLWpncD7GMaZ6USkmagCKrio/XZ5U/IwKpOJLrJIMA== X-Received: by 2002:a2e:9848:: with SMTP id e8mr3988455ljj.148.1570666708067; Wed, 09 Oct 2019 17:18:28 -0700 (PDT) Received: from [10.1.0.176] ([5.18.248.33]) by smtp.gmail.com with ESMTPSA id h3sm825220ljf.12.2019.10.09.17.18.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Oct 2019 17:18:27 -0700 (PDT) From: Skakov Pavel To: FFmpeg development discussions and patches References: <5bb1e2e7-faf8-7244-b48b-9bc21842b010@gmail.com> Message-ID: <2cd1db88-c1f8-16a1-9670-b30df834f570@gmail.com> Date: Thu, 10 Oct 2019 03:18:26 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <5bb1e2e7-faf8-7244-b48b-9bc21842b010@gmail.com> Content-Language: en-US Subject: [FFmpeg-devel] [PATCH v2 4/4] avcodec/tiff: small compiling optimization 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" Made it easier for compiler to optimize array indexes when unpacking YUV. From 29b2437e04d6af1c5093efcaac6f8bc852525d78 Mon Sep 17 00:00:00 2001 From: Pavel Skakov Date: Thu, 10 Oct 2019 02:43:34 +0300 Subject: [PATCH 4/4] avcodec/tiff: small compiling optimization Signed-off-by: Pavel Skakov --- libavcodec/tiff.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index be46db961c..71584b1c86 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -358,11 +358,12 @@ static void unpack_gray(TiffContext *s, AVFrame *p, } } -static void unpack_yuv(TiffContext *s, AVFrame *p, +static void unpack_yuv(TiffContext *av_restrict s, AVFrame *av_restrict p, const uint8_t *src, int lnum) { - int i, j, k; - int w = (s->width - 1) / s->subsampling[0] + 1; + size_t i, j, k; + size_t w = (s->width - 1) / s->subsampling[0] + 1; + uint8_t *py = &p->data[0][lnum * p->linesize[0]]; uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]]; uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]]; if (s->width % s->subsampling[0] || s->height % s->subsampling[1]) { @@ -371,7 +372,7 @@ static void unpack_yuv(TiffContext *s, AVFrame *p, for (j = 0; j < s->subsampling[1]; j++) for (k = 0; k < s->subsampling[0]; k++) if (j < s->height - lnum && i * s->subsampling[0] + k < s->width) { - p->data[0][(lnum + j) * p->linesize[0] + i * s->subsampling[0] + k] = *src++; + py[j * p->linesize[0] + i * s->subsampling[0] + k] = *src++; } else { src++; } @@ -383,8 +384,8 @@ static void unpack_yuv(TiffContext *s, AVFrame *p, for (j = 0; j < s->subsampling[1]; j++) for (k = 0; k < s->subsampling[0]; k++) if (j < s->height - lnum && i * s->subsampling[0] + k < s->width) { - p->data[0][(lnum + j) * p->linesize[0] + (i * s->subsampling[0] + k)*2 ] = *src++; - p->data[0][(lnum + j) * p->linesize[0] + (i * s->subsampling[0] + k)*2 + 1] = *src++; + py[j * p->linesize[0] + (i * s->subsampling[0] + k)*2 ] = *src++; + py[j * p->linesize[0] + (i * s->subsampling[0] + k)*2 + 1] = *src++; } else { src += 2; } @@ -399,7 +400,7 @@ static void unpack_yuv(TiffContext *s, AVFrame *p, for (i = 0; i < w; i++) { for (j = 0; j < s->subsampling[1]; j++) for (k = 0; k < s->subsampling[0]; k++) - p->data[0][(lnum + j) * p->linesize[0] + i * s->subsampling[0] + k] = *src++; + py[j * p->linesize[0] + i * s->subsampling[0] + k] = *src++; *pu++ = *src++; *pv++ = *src++; } @@ -407,8 +408,8 @@ static void unpack_yuv(TiffContext *s, AVFrame *p, for (i = 0; i < w; i++) { for (j = 0; j < s->subsampling[1]; j++) for (k = 0; k < s->subsampling[0]; k++) { - p->data[0][(lnum + j) * p->linesize[0] + (i * s->subsampling[0] + k)*2 ] = *src++; - p->data[0][(lnum + j) * p->linesize[0] + (i * s->subsampling[0] + k)*2 + 1] = *src++; + py[j * p->linesize[0] + (i * s->subsampling[0] + k)*2 ] = *src++; + py[j * p->linesize[0] + (i * s->subsampling[0] + k)*2 + 1] = *src++; } *pu++ = *src++; *pu++ = *src++; -- 2.13.2.windows.1