public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Improve Y16 color setup
@ 2015-06-01  7:05 Hans Verkuil
  2015-06-01 21:11 ` Ricardo Ribalda Delgado
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Verkuil @ 2015-06-01  7:05 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Ricardo Ribalda Delgado

Currently the colors for the Y16 and Y16_BE pixelformats are in the range
0x0000-0xff00. So pure white (0xffff) is never created.

Improve this by using the same byte for both LSB and MSB so the full range
is achieved.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

diff --git a/drivers/media/platform/vivid/vivid-tpg.c b/drivers/media/platform/vivid/vivid-tpg.c
index b1147f2..e28f32b 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -896,16 +896,12 @@ static void gen_twopix(struct tpg_data *tpg,
 	b_v = tpg->colors[color][2]; /* B or precalculated V */
 
 	switch (tpg->fourcc) {
-	case V4L2_PIX_FMT_GREY:
-		buf[0][offset] = r_y;
-		break;
 	case V4L2_PIX_FMT_Y16:
-		buf[0][offset] = 0;
-		buf[0][offset+1] = r_y;
-		break;
 	case V4L2_PIX_FMT_Y16_BE:
+		buf[0][offset+1] = r_y;
+		/* fall through */
+	case V4L2_PIX_FMT_GREY:
 		buf[0][offset] = r_y;
-		buf[0][offset+1] = 0;
 		break;
 	case V4L2_PIX_FMT_YUV422P:
 	case V4L2_PIX_FMT_YUV420:

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Improve Y16 color setup
  2015-06-01  7:05 [PATCH] Improve Y16 color setup Hans Verkuil
@ 2015-06-01 21:11 ` Ricardo Ribalda Delgado
  0 siblings, 0 replies; 2+ messages in thread
From: Ricardo Ribalda Delgado @ 2015-06-01 21:11 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Linux Media Mailing List

Hello Hans


On Mon, Jun 1, 2015 at 9:05 AM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> Currently the colors for the Y16 and Y16_BE pixelformats are in the range
> 0x0000-0xff00. So pure white (0xffff) is never created.
>
> Improve this by using the same byte for both LSB and MSB so the full range
> is achieved.


If someone uses vivid as reference (I sometimes do), this could lead
to incorrect implementations. If the user don't implement the
endianess right he will never notice. I have carried out an endianness
bug for some months, until gstreamer was showing "funny" ;) images.

If the problem is that you want to reach saturation, I would rather
setting the lsb to 0xff all the time. (i.e. going from 0x00ff to
0xffff).

If we want saturation and zero, we could set the lsb to val?0xff:0;



Regards!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-01 21:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-01  7:05 [PATCH] Improve Y16 color setup Hans Verkuil
2015-06-01 21:11 ` Ricardo Ribalda Delgado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox