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, LKML <linux-kernel@vger.kernel.org>,
	linux-media <linux-media@vger.kernel.org>
Subject: Re: [PATCH v4 09/12] [media] vivid: Local optimization
Date: Mon, 18 Jul 2016 16:16:08 +0200	[thread overview]
Message-ID: <1468851368.2994.54.camel@pengutronix.de> (raw)
In-Reply-To: <CAPybu_3MLxefeLDoU_HhSrS7ugc1idE7Qa7=h5a2F0x+4TizFg@mail.gmail.com>

Hi Ricardo,

Am Montag, den 18.07.2016, 15:21 +0200 schrieb Ricardo Ribalda Delgado:
> Hi Philipp
> 
> On Mon, Jul 18, 2016 at 3:13 PM, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> > 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.
> >
> 
> I dont think that I follow you completely here. The original code was

Sorry, I forgot to mention I compiled both versions for ARMv7-A, saw
that object size increased, had a look the diff between objdump -d
outputs and noticed an additional shift instruction. I have not checked
this for x86_64.

> if (a)
>    y= clamp(y, 16<<4, 235<<4)
> 
> y = clamp(y>>4, 1, 254)
>
> And now is
> 
> if (a)
>    y= clamp(y >>4, 16, 235)
> else
>     y = clamp(y, 1, 254)
     y = clamp(y >>4, 1, 254)

> On the previous case, when a was true there was 2 clamp operations.
> Now it is only one.

Yes. And now there's two shift operations (overall, still just one in
each conditional path).

It seems in my case the compiler was not clever enough to move all the
right shifts out of the conditional paths, so I ended up with one more
than before. You are right that in the limited range path the second
clamps are now avoided though. Basically, feel free to disregard my
comment.

I had the best looking result with this variant, btw:

	y >>= 4;
	cb >>= 4;
	cr >>= 4;
	if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) {
		y = clamp(y, 16, 235);
		cb = clamp(cb, 16, 240);
		cr = clamp(cr, 16, 240);
	} else {
		y = clamp(y, 1, 254);
		cb = clamp(cb, 1, 254);
		cr = clamp(cr, 1, 254);
	}

regards
Philipp

  reply	other threads:[~2016-07-18 14:16 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
2016-07-18 13:21     ` Ricardo Ribalda Delgado
2016-07-18 14:16       ` Philipp Zabel [this message]
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=1468851368.2994.54.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®