lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1468847611.2994.22.camel@pengutronix.de>
Date:	Mon, 18 Jul 2016 15:13:31 +0200
From:	Philipp Zabel <p.zabel@...gutronix.de>
To:	Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
Cc:	Jonathan Corbet <corbet@....net>,
	Mauro Carvalho Chehab <mchehab@...nel.org>,
	Hans Verkuil <hverkuil@...all.nl>,
	Markus Heiser <markus.heiser@...marIT.de>,
	Laurent Pinchart <laurent.pinchart@...asonboard.com>,
	Helen Mae Koike Fornazier <helen.koike@...labora.co.uk>,
	Antti Palosaari <crope@....fi>,
	Shuah Khan <shuahkh@....samsung.com>,
	linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-media@...r.kernel.org
Subject: Re: [PATCH v4 09/12] [media] vivid: Local optimization

Hi Ricardo,

Am Montag, den 18.07.2016, 14:42 +0200 schrieb Ricardo Ribalda Delgado:
> Avoid duplicated data shifts when possible.
> 
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
> ---
>  drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
> index a26172575e56..7f284c591f25 100644
> --- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
> +++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
> @@ -919,13 +919,14 @@ static void precalculate_color(struct tpg_data *tpg, int k)
>  			color_to_ycbcr(tpg, r, g, b, &y, &cb, &cr);
>  
>  		if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) {
> -			y = clamp(y, 16 << 4, 235 << 4);
> -			cb = clamp(cb, 16 << 4, 240 << 4);
> -			cr = clamp(cr, 16 << 4, 240 << 4);
> +			y = clamp(y >> 4, 16, 235);
> +			cb = clamp(cb >> 4, 16, 240);
> +			cr = clamp(cr >> 4, 16, 240);

Since the constant expressions are evaluated at compile time, you are
not actually removing shifts. The code generated for precalculate_color
by gcc 5.4 even grows by one asr instruction with this patch.

> +		} else {
> +			y = clamp(y >> 4, 1, 254);
> +			cb = clamp(cb >> 4, 1, 254);
> +			cr = clamp(cr >> 4, 1, 254);
>  		}
> -		y = clamp(y >> 4, 1, 254);
> -		cb = clamp(cb >> 4, 1, 254);
> -		cr = clamp(cr >> 4, 1, 254);
>  		switch (tpg->fourcc) {
>  		case V4L2_PIX_FMT_YUV444:
>  			y >>= 4;

regards
Philipp

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ