mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Markus Heiser <markus.heiser@darmarIT.de>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Helen Mae Koike Fornazier <helen.koike@collabora.co.uk>,
	Antti Palosaari <crope@iki.fi>,
	Shuah Khan <shuahkh@osg.samsung.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-media@vger.kernel.org
Subject: Re: [PATCH v4 09/12] [media] vivid: Local optimization
Date: Mon, 18 Jul 2016 15:13:31 +0200	[thread overview]
Message-ID: <1468847611.2994.22.camel@pengutronix.de> (raw)
In-Reply-To: <1468845736-19651-10-git-send-email-ricardo.ribalda@gmail.com>

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@gmail.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

  reply	other threads:[~2016-07-18 13:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18 12:42 [PATCH v4 00/12] Add HSV format Ricardo Ribalda Delgado
2016-07-18 12:42 ` [PATCH v4 01/12] [media] videodev2.h Add HSV formats Ricardo Ribalda Delgado
2016-07-18 12:42 ` [PATCH v4 02/12] [media] Documentation: Add HSV format Ricardo Ribalda Delgado
2016-07-18 12:42 ` [PATCH v4 03/12] [media] Documentation: Add Ricardo Ribalda Ricardo Ribalda Delgado
2016-07-18 12:42 ` [PATCH v4 04/12] [media] vivid: Code refactor for color encoding Ricardo Ribalda Delgado
2016-07-18 12:42 ` [PATCH v4 05/12] [media] vivid: Add support for HSV formats Ricardo Ribalda Delgado
2016-07-18 12:42 ` [PATCH v4 06/12] [media] vivid: Rename variable Ricardo Ribalda Delgado
2016-07-18 12:42 ` [PATCH v4 07/12] [media] vivid: Introduce TPG_COLOR_ENC_LUMA Ricardo Ribalda Delgado
2016-07-18 12:42 ` [PATCH v4 08/12] [media] vivid: Fix YUV555 and YUV565 handling Ricardo Ribalda Delgado
2016-07-18 12:42 ` [PATCH v4 09/12] [media] vivid: Local optimization Ricardo Ribalda Delgado
2016-07-18 13:13   ` Philipp Zabel [this message]
2016-07-18 13:21     ` Ricardo Ribalda Delgado
2016-07-18 14:16       ` Philipp Zabel
2016-07-18 19:41         ` Ricardo Ribalda Delgado
2016-07-18 12:42 ` [PATCH v4 10/12] [media] videodev2.h Add HSV encoding Ricardo Ribalda Delgado
2016-08-12 13:56   ` Hans Verkuil
2016-07-18 12:42 ` [PATCH v4 11/12] [media] Documentation: Add HSV encodings Ricardo Ribalda Delgado
2016-08-12 13:51   ` Hans Verkuil
2016-07-18 12:42 ` [PATCH v4 12/12] [media] vivid: Add support for HSV encoding Ricardo Ribalda Delgado

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468847611.2994.22.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=corbet@lwn.net \
    --cc=crope@iki.fi \
    --cc=helen.koike@collabora.co.uk \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=markus.heiser@darmarIT.de \
    --cc=mchehab@kernel.org \
    --cc=ricardo.ribalda@gmail.com \
    --cc=shuahkh@osg.samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®