Add HSV format
Subsystems (2)
v2 cover Add HSV format
HSV formats are extremely useful for image segmentation. This set of patches makes v4l2 aware of this kind of formats.
Vivid changes have been divided in three to ease the reviewing process.
We are working on patches for Gstreamer and OpenCV that will make use of these formats.
Thanks!
Changelog
v2: Suggested by Mauro Carvalho Chehab <[email protected]>, -Rebase on top of docs-next (port documentation to .rst) @mchehab, You were right, there was no conflict after the rebase, Thanks!
Ricardo Ribalda Delgado (6):
[media] videodev2.h Add HSV formats
[media] Documentation: Add HSV format [media] Documentation: Add Ricardo Ribalda [media] vivid: code refactor for color representation [media] vivid: Add support for HSV formats [media] vivid: Rename variable
Documentation/media/uapi/v4l/hsv-formats.rst | 19 ++ Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst | 253 +++++++++++++++ Documentation/media/uapi/v4l/pixfmt.rst | 1 + Documentation/media/uapi/v4l/v4l2.rst | 9 + drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 341 ++++++++++++++------- drivers/media/platform/vivid/vivid-core.h | 2 +- drivers/media/platform/vivid/vivid-vid-common.c | 66 ++-- drivers/media/v4l2-core/v4l2-ioctl.c | 2 + include/media/v4l2-tpg.h | 8 +- include/uapi/linux/videodev2.h | 4 + 10 files changed, 558 insertions(+), 147 deletions(-) create mode 100644 Documentation/media/uapi/v4l/hsv-formats.rst create mode 100644 Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst
Signature · 1 line
2.8.1
PATCH v2 1/6 videodev2.h Add HSV formats
These formats store the color information of the image in a geometrical representation. The colors are mapped into a cylinder, where the angle is the HUE, the height is the VALUE and the distance to the center is the SATURATION. This is a very useful format for image segmentation algorithms.
--- drivers/media/v4l2-core/v4l2-ioctl.c | 2 ++ include/uapi/linux/videodev2.h | 4 ++++ 2 files changed, 6 insertions(+)
drivers/media/v4l2-core/v4l2-ioctl.c +2 -0
@@ -1238,6 +1238,8 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)case V4L2_PIX_FMT_TM6000 : descr ="A/V + VBI Mux Packet" ;break ;case V4L2_PIX_FMT_CIT_YYVYUY : descr ="GSPCA CIT YYVYUY" ;break ;case V4L2_PIX_FMT_KONICA420 : descr ="GSPCA KONICA420" ;break ; +case V4L2_PIX_FMT_HSV24 : descr ="24-bit HSV 8-8-8" ;break ; +case V4L2_PIX_FMT_HSV32 : descr ="32-bit XHSV 8-8-8-8" ;break ;case V4L2_SDR_FMT_CU8 : descr ="Complex U8" ;break ;case V4L2_SDR_FMT_CU16LE : descr ="Complex U16LE" ;break ;case V4L2_SDR_FMT_CS8 : descr ="Complex S8" ;break ;
include/uapi/linux/videodev2.h +4 -0
@@ -580,6 +580,10 @@ struct v4l2_pix_format {#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2')/* 12 RGRG.. GBGB.. */ #define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2')/* 16 BGBG.. GRGR.. */ +/* HSV formats */ +#define V4L2_PIX_FMT_HSV24 v4l2_fourcc('H', 'S', 'V', '3') +#define V4L2_PIX_FMT_HSV32 v4l2_fourcc('H', 'S', 'V', '4') +/* compressed formats */ #define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G')/* Motion-JPEG */ #define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G')/* JFIF JPEG */
Signature · 1 line
2.8.1
PATCH v2 2/6 Documentation: Add HSV format
In reply to Ricardo Ribalda DelgadoDescribe the HSV formats
--- Documentation/media/uapi/v4l/hsv-formats.rst | 19 ++ Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst | 253 +++++++++++++++++++++ Documentation/media/uapi/v4l/pixfmt.rst | 1 + Documentation/media/uapi/v4l/v4l2.rst | 5 + 4 files changed, 278 insertions(+) create mode 100644 Documentation/media/uapi/v4l/hsv-formats.rst create mode 100644 Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst
Documentation/media/uapi/v4l/hsv-formats.rst new file +19 -0
@@ -0,0 +1,19 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _hsv-formats: + +*********** +HSV Formats +*********** + +These formats store the color information of the image +in a geometrical representation. The colors are mapped into a +cylinder, where the angle is the HUE, the height is the VALUE +and the distance to the center is the SATURATION. This is a very +useful format for image segmentation algorithms. + + +.. toctree:: + :maxdepth: 1 + + pixfmt-packed-hsv
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +253 -0
253 lines not on this page · raw message
Documentation/media/uapi/v4l/pixfmt.rst +1 -0
@@ -29,6 +29,7 @@ see also :ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>`.) pixfmt-indexed pixfmt-rgb yuv-formats + hsv-formats depth-formats pixfmt-013 sdr-formats
Documentation/media/uapi/v4l/v4l2.rst +5 -0
@@ -85,6 +85,11 @@ part can be used and distributed without restrictions. Revision History **************** +:revision: 4.8 / 2016-07-15 (*rr*) + +Introduce HSV formats. + + :revision: 4.5 / 2015-10-29 (*rr*) Extend VIDIOC_G_EXT_CTRLS;. Replace ctrl_class with a new union with
Signature · 1 line
2.8.1
Re: [PATCH v2 2/6] [media] Documentation: Add HSV format
Hi Ricardo,
Thank you for the patch.
Quoted 50 lines · On Friday 15 Jul 2016 18:13:15 Ricardo Ribalda Delgado wrote:
Describe the HSV formats
Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- Documentation/media/uapi/v4l/hsv-formats.rst | 19 ++ Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst | 253 ++++++++++++++++++ Documentation/media/uapi/v4l/pixfmt.rst | 1 + Documentation/media/uapi/v4l/v4l2.rst | 5 + 4 files changed, 278 insertions(+) create mode 100644 Documentation/media/uapi/v4l/hsv-formats.rst create mode 100644 Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst(quoted diff) +0
-0
b/Documentation/media/uapi/v4l/hsv-formats.rstnew file mode 100644 index 000000000000..f0f2615eaa95Documentation/media/uapi/v4l/hsv-formats.rst new file +19
-0@@ -0,0 +1,19 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _hsv-formats: + +*********** +HSV Formats +*********** + +These formats store the color information of the image +in a geometrical representation. The colors are mapped into a +cylinder, where the angle is the HUE, the height is the VALUE +and the distance to the center is the SATURATION. This is a very +useful format for image segmentation algorithms. + + +.. toctree:: + :maxdepth: 1 + + pixfmt-packed-hsv(quoted diff) +0
-0
b/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rstnew file mode 100644 index 000000000000..b297aa4f7ba6Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +7
-0@@ -0,0 +1,253 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _packed-hsv: + +****************** +Packed HSV formats +******************
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst line 17
Quoted 10 lines
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +10
-0+ +*man Packed HSV formats(2)* + +Packed HSV formats + + +Description +=========== + +The HUE (h) is meassured in degrees, one LSB represents two degrees.
Is this common ? I have a device that can handle HSV data, I need to check how it maps the hue values to binary, but I'm pretty sure they cover the full 0-255 range. We would then have to support the two formats. Separate 4CCs are an option, but reporting the range separately (possibly through the colorspace API) might be better. Any thought on that ?
Quoted 11 lines
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +11
-0+The SATURATION (s) and the VALUE (v) are measured in percentage of the +cylinder: 0 being the smallest value and 255 the maximum. + + +The values are packed in 24 or 32 bit formats. + + +.. flat-table:: Packed HSV Image Formats + :header-rows: 2 + :stub-columns: 0 +
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst line 38
Quoted 10 lines
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +10
-0+ + - .. row 1 + + - Identifier + + - Code + + - + - :cspan:`7` Byte 0 in memory +
Do we really need all those blank lines ?
[snip]
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 2/6] [media] Documentation: Add HSV format
Quoted 63 lines · Laurent Pinchart
Hi Ricardo,
Thank you for the patch.
Quoted 58 lines · On Friday 15 Jul 2016 18:13:15 Ricardo Ribalda Delgado wrote:
Describe the HSV formats
Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- Documentation/media/uapi/v4l/hsv-formats.rst | 19 ++ Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst | 253 ++++++++++++++++++ Documentation/media/uapi/v4l/pixfmt.rst | 1 + Documentation/media/uapi/v4l/v4l2.rst | 5 + 4 files changed, 278 insertions(+) create mode 100644 Documentation/media/uapi/v4l/hsv-formats.rst create mode 100644 Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst(quoted diff) +0
-0
b/Documentation/media/uapi/v4l/hsv-formats.rstnew file mode 100644 index 000000000000..f0f2615eaa95Documentation/media/uapi/v4l/hsv-formats.rst new file +19
-0@@ -0,0 +1,19 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _hsv-formats: + +*********** +HSV Formats +*********** + +These formats store the color information of the image +in a geometrical representation. The colors are mapped into a +cylinder, where the angle is the HUE, the height is the VALUE +and the distance to the center is the SATURATION. This is a very +useful format for image segmentation algorithms. + + +.. toctree:: + :maxdepth: 1 + + pixfmt-packed-hsv(quoted diff) +0
-0
b/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rstnew file mode 100644 index 000000000000..b297aa4f7ba6Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +15
-0@@ -0,0 +1,253 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _packed-hsv: + +****************** +Packed HSV formats +****************** + +*man Packed HSV formats(2)* + +Packed HSV formats + + +Description +===========
Quoted 8 lines
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst line 17
Quoted 2 lines
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +2
-0+ +The HUE (h) is meassured in degrees, one LSB represents two degrees.Is this common ? I have a device that can handle HSV data, I need to check how it maps the hue values to binary, but I'm pretty sure they cover the full 0-255 range. We would then have to support the two formats. Separate 4CCs are an option, but reporting the range separately (possibly through the colorspace API) might be better. Any thought on that ?
It's either a separate 4cc or we do something with the ycbcr_enc field (reinterpreted as hsv_enc). I'm not sure, I would have to think some more about that.
Regards,
Hans
Re: [PATCH v2 2/6] [media] Documentation: Add HSV format
Hi Hans,
Quoted 70 lines · On Saturday 16 Jul 2016 10:19:29 Hans Verkuil wrote:
Quoted 60 lines · Laurent Pinchart
Quoted 59 lines · On Friday 15 Jul 2016 18:13:15 Ricardo Ribalda Delgado wrote:
Describe the HSV formats
Signed-off-by Ricardo Ribalda Delgado <[email protected]>---
Documentation/media/uapi/v4l/hsv-formats.rst | 19 ++ Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst | 253 +++++++++++++++ Documentation/media/uapi/v4l/pixfmt.rst | 1 + Documentation/media/uapi/v4l/v4l2.rst | 5 + 4 files changed, 278 insertions(+) create mode 100644 Documentation/media/uapi/v4l/hsv-formats.rst create mode 100644 Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst(quoted diff) +0
-0
b/Documentation/media/uapi/v4l/hsv-formats.rstnew file mode 100644 index 000000000000..f0f2615eaa95Documentation/media/uapi/v4l/hsv-formats.rst new file +19
-0@@ -0,0 +1,19 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _hsv-formats: + +*********** +HSV Formats +*********** + +These formats store the color information of the image +in a geometrical representation. The colors are mapped into a +cylinder, where the angle is the HUE, the height is the VALUE +and the distance to the center is the SATURATION. This is a very +useful format for image segmentation algorithms. + + +.. toctree:: + :maxdepth: 1 + + pixfmt-packed-hsv(quoted diff) +0
-0
b/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rstnew file mode 100644 index 000000000000..b297aa4f7ba6Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +15
-0@@ -0,0 +1,253 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _packed-hsv: + +****************** +Packed HSV formats +****************** + +*man Packed HSV formats(2)* + +Packed HSV formats + + +Description +===========Quoted 8 lines
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst line 17
Quoted 2 lines
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +2
-0+ +The HUE (h) is meassured in degrees, one LSB represents two degrees.Is this common ? I have a device that can handle HSV data, I need to check how it maps the hue values to binary, but I'm pretty sure they cover the full 0-255 range. We would then have to support the two formats. Separate 4CCs are an option, but reporting the range separately (possibly through the colorspace API) might be better. Any thought on that ?
Quoted 3 lines
It's either a separate 4cc or we do something with the
ycbcr_encfield (reinterpreted ashsv_enc). I'm not sure, I would have to think some more about that.
I'm inclined to use the ycbcr_enc field, especially given that a similar usage could be useful for RGB as well (don't ask me what it's supposed to be used for, but I have hardware that support limiting the RGB values range to 16-235).
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 2/6] [media] Documentation: Add HSV format
Quoted 73 lines · Laurent Pinchart
Hi Hans,
Quoted 70 lines · On Saturday 16 Jul 2016 10:19:29 Hans Verkuil wrote:
Quoted 68 lines · Laurent Pinchart
Quoted 51 lines · On Friday 15 Jul 2016 18:13:15 Ricardo Ribalda Delgado wrote:
Describe the HSV formats
Signed-off-by Ricardo Ribalda Delgado <[email protected]>---
Documentation/media/uapi/v4l/hsv-formats.rst | 19 ++ Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst | 253 +++++++++++++++ Documentation/media/uapi/v4l/pixfmt.rst | 1 + Documentation/media/uapi/v4l/v4l2.rst | 5 + 4 files changed, 278 insertions(+) create mode 100644 Documentation/media/uapi/v4l/hsv-formats.rst create mode 100644 Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst(quoted diff) +0
-0
b/Documentation/media/uapi/v4l/hsv-formats.rstnew file mode 100644 index 000000000000..f0f2615eaa95Documentation/media/uapi/v4l/hsv-formats.rst new file +19
-0@@ -0,0 +1,19 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _hsv-formats: + +*********** +HSV Formats +*********** + +These formats store the color information of the image +in a geometrical representation. The colors are mapped into a +cylinder, where the angle is the HUE, the height is the VALUE +and the distance to the center is the SATURATION. This is a very +useful format for image segmentation algorithms. + + +.. toctree:: + :maxdepth: 1 + + pixfmt-packed-hsv(quoted diff) +0
-0
b/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rstnew file mode 100644 index 000000000000..b297aa4f7ba6Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +7
-0@@ -0,0 +1,253 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _packed-hsv: + +****************** +Packed HSV formats +******************Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst line 17
Quoted 10 lines
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +10
-0+ +*man Packed HSV formats(2)* + +Packed HSV formats + + +Description +=========== + +The HUE (h) is meassured in degrees, one LSB represents two degrees.Is this common ? I have a device that can handle HSV data, I need to check how it maps the hue values to binary, but I'm pretty sure they cover the full 0-255 range. We would then have to support the two formats. Separate 4CCs are an option, but reporting the range separately (possibly through the colorspace API) might be better. Any thought on that ?
Quoted 8 lines
Quoted 3 lines
It's either a separate 4cc or we do something with the
ycbcr_encfield (reinterpreted ashsv_enc). I'm not sure, I would have to think some more about that.I'm inclined to use the
ycbcr_encfield, especially given that a similar usage could be useful for RGB as well (don't ask me what it's supposed to be used for, but I have hardware that support limiting the RGB values range to 16-235).
Limited vs full range quantization is handled by the quantization field. It's there already.
Limited range RGB is needed for HDMI due to a brain-dead spec when dealing with certain kinds of TVs and configurations. Don't ask, it's horrible.
Anyway, I am inclined to use ycbcr_enc as well.
Regards,
Hans
Re: [PATCH v2 2/6] [media] Documentation: Add HSV format
Hi Hans,
Quoted 79 lines · On Saturday 16 Jul 2016 15:59:08 Hans Verkuil wrote:
Quoted 78 lines · Laurent Pinchart
Quoted 76 lines · On Saturday 16 Jul 2016 10:19:29 Hans Verkuil wrote:
Quoted 63 lines · Laurent Pinchart
Quoted 62 lines · On Friday 15 Jul 2016 18:13:15 Ricardo Ribalda Delgado wrote:
Describe the HSV formats
Signed-off-by Ricardo Ribalda Delgado <[email protected]>---
Documentation/media/uapi/v4l/hsv-formats.rst | 19 ++ Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst | 253 +++++++++++++++ Documentation/media/uapi/v4l/pixfmt.rst | 1 + Documentation/media/uapi/v4l/v4l2.rst | 5 + 4 files changed, 278 insertions(+) create mode 100644 Documentation/media/uapi/v4l/hsv-formats.rst create mode 100644 Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst(quoted diff) +0
-0
b/Documentation/media/uapi/v4l/hsv-formats.rstnew file mode 100644 index 000000000000..f0f2615eaa95Documentation/media/uapi/v4l/hsv-formats.rst new file +19
-0@@ -0,0 +1,19 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _hsv-formats: + +*********** +HSV Formats +*********** + +These formats store the color information of the image +in a geometrical representation. The colors are mapped into a +cylinder, where the angle is the HUE, the height is the VALUE +and the distance to the center is the SATURATION. This is a very +useful format for image segmentation algorithms. + + +.. toctree:: + :maxdepth: 1 + + pixfmt-packed-hsv(quoted diff) +0
-0
b/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rstnew file mode 100644
index 000000000000..b297aa4f7ba6Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +16
-0@@ -0,0 +1,253 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _packed-hsv: + +****************** +Packed HSV formats +****************** + +*man Packed HSV formats(2)* + +Packed HSV formats + + +Description +=========== +Quoted 8 lines
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst line 17
Quoted 1 line
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +1
-0+The HUE (h) is meassured in degrees, one LSB represents two degrees.Is this common ? I have a device that can handle HSV data, I need to check how it maps the hue values to binary, but I'm pretty sure they cover the full 0-255 range. We would then have to support the two formats. Separate 4CCs are an option, but reporting the range separately (possibly through the colorspace API) might be better. Any thought on that ?
It's either a separate 4cc or we do something with the
ycbcr_encfield (reinterpreted ashsv_enc). I'm not sure, I would have to think some more about that.
Quoted 7 lines
Quoted 4 lines
I'm inclined to use the
ycbcr_encfield, especially given that a similar usage could be useful for RGB as well (don't ask me what it's supposed to be used for, but I have hardware that support limiting the RGB values range to 16-235).Limited vs full range quantization is handled by the quantization field. It's there already.
Right. I wonder how we'll deal with that when someone will come up with more than one limited range quantizations, have you thought about it ?
Quoted 2 lines
Limited range RGB is needed for HDMI due to a brain-dead spec when dealing with certain kinds of TVs and configurations. Don't ask, it's horrible.
I'd still like to know about it for my personal information :-)
Quoted 1 line
Anyway, I am inclined to use
ycbcr_encas well.
I'm glad we agree.
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2 2/6] [media] Documentation: Add HSV format
Hi
Quoted 1 line · Laurent Pinchart
I'd still like to know about it for my personal information :-)
Maybe it is just a very cheap gamma.
Quoted 5 lines
Quoted 2 lines
Anyway, I am inclined to use
ycbcr_encas well.I'm glad we agree.
Are you thinking about something like this:
include/uapi/linux/videodev2.h +10 -0
@@ -330,6 +330,16 @@ enum v4l2_ycbcr_encoding { V4L2_YCBCR_ENC_SMPTE240M = 8, }; +enum v4l2_hsv_encoding { +V4L2_HSV_ENC_180 =16 , +V4L2_HSV_ENC_256 =17 , +}; + +enum v4l2_rgb_encoding { +V4L2_RGB_ENC_FULL =32 , +V4L2_HSV_ENC_16_235 =33 , +}; +/* * Determine how YCBCR_ENC_DEFAULT should map to a proper Y'CbCr encoding. * This depends on the colorspace.
@@ -455,7 +465,11 @@ struct v4l2_pix_format {__u32 colorspace;/* enum v4l2_colorspace */ __u32 priv;/* private data,
depends on pixelformat */
__u32 flags; /* format flags
(V4L2_PIX_FMT_FLAG_*) */
- __u32 ycbcr_enc; /* enum v4l2_ycbcr_encoding */
+ union {
+ __u32 ycbcr_enc; /* enumv4l2_ycbcr_encoding */
+ __u32 hsv_enc; /* enumv4l2_hsv_encoding */
+ __u32 rgb_enc; /* enumv4l2_rgb_encoding */
+ };
__u32 quantization; /* enum v4l2_quantization */
__u32 xfer_func; /* enum v4l2_xfer_func */
};
@@ -1988,7 +2002,11 @@ struct v4l2_pix_format_mplane {
struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES];
__u8 num_planes;
__u8 flags;- __u8 ycbcr_enc;
+ union {
+ __u8 ycbcr_enc; /* enumv4l2_ycbcr_encoding */
+ __u8 hsv_enc; /* enumv4l2_hsv_encoding */
+ __u8 rgb_enc; /* enumv4l2_rgb_encoding */
+ };
__u8 quantization;
__u8 xfer_func;
__u8 reserved[7];Quoted 1 line
--
Best regards!
Signature · 1 line
Ricardo Ribalda
Re: [PATCH v2 2/6] [media] Documentation: Add HSV format
Quoted 23 lines · Ricardo Ribalda Delgado
Hi
Quoted 1 line · Laurent Pinchart
I'd still like to know about it for my personal information :-)
Maybe it is just a very cheap gamma.
Quoted 5 lines
Quoted 2 lines
Anyway, I am inclined to use
ycbcr_encas well.I'm glad we agree.
Are you thinking about something like this:
include/uapi/linux/videodev2.h +0
-0
include/uapi/linux/videodev2.h enum v4l2_ycbcr_encoding { · line 336
Quoted 7 lines
include/uapi/linux/videodev2.h +4
-0@@ -330,6 +330,16 @@ enum v4l2_ycbcr_encoding { V4L2_YCBCR_ENC_SMPTE240M = 8, }; +enum v4l2_hsv_encoding { +V4L2_HSV_ENC_180 =16 , +V4L2_HSV_ENC_256 =17 , +};
Yes.
include/uapi/linux/videodev2.h enum v4l2_ycbcr_encoding { · line 341
Quoted 5 lines
include/uapi/linux/videodev2.h +5
-0+ +enum v4l2_rgb_encoding { +V4L2_RGB_ENC_FULL =32 , +V4L2_HSV_ENC_16_235 =33 , +};
No.
The starting point is RGB, so there is nothing to encode. YCbCr and HSV are transformations from RGB (or R'G'B' to be precise).
The basic chain is:
XYZ -> colorspace conversion -> RGB -> transfer function -> R'G'B'
and after this there is an optional step that converts R'G'B' to Y'CbCr or HSV (ycbcr_enc or hsv_enc). The final step is the quantization step where you end up with the actual color component values.
There doesn't seem to be something like limited range HSV, so I'd say it's full range only.
Regards,
Hans
Quoted 44 lines
include/uapi/linux/videodev2.h +1
-0+/* * Determine how YCBCR_ENC_DEFAULT should map to a proper Y'CbCr encoding. * This depends on the colorspace. @@ -455,7 +465,11 @@ struct v4l2_pix_format {__u32 colorspace;/* enum v4l2_colorspace */ __u32 priv;/* private data, depends on pixelformat */
__u32flags; /* format flags
(V4L2_PIX_FMT_FLAG_*) */include/uapi/linux/videodev2.h +2
-1-__u32 ycbcr_enc;/* enum v4l2_ycbcr_encoding */ +union { +__u32 ycbcr_enc;/* enum
v4l2_ycbcr_encoding*/
+__u32hsv_enc; /* enumv4l2_hsv_encoding*/
+__u32rgb_enc; /* enumv4l2_rgb_encoding*/include/uapi/linux/videodev2.h +3
-1+ };__u32 quantization;/* enum v4l2_quantization */ __u32 xfer_func;/* enum v4l2_xfer_func */ };@@ -1988,7 +2002,11 @@ struct v4l2_pix_format_mplane {struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES ];__u8 num_planes;__u8 flags; -__u8 ycbcr_enc; +union { +__u8 ycbcr_enc;/* enum
v4l2_ycbcr_encoding*/
+__u8hsv_enc; /* enumv4l2_hsv_encoding*/
+__u8rgb_enc; /* enumv4l2_rgb_encoding*/+ }; __u8 quantization; __u8 xfer_func; __u8 reserved[7];Quoted 1 line
--
Best regards!
Re: [PATCH v2 2/6] [media] Documentation: Add HSV format
Hi Hans
Quoted 8 lines · Hans Verkuil
include/uapi/linux/videodev2.h enum v4l2_ycbcr_encoding { · line 341
Quoted 6 lines
include/uapi/linux/videodev2.h +5
-0+ +enum v4l2_rgb_encoding { +V4L2_RGB_ENC_FULL =32 , +V4L2_HSV_ENC_16_235 =33 , +};No.
I was trying to fit also Laurent special 16-235 RGB format. I will remove it on future versions.
Can I make this change as 2 new patches on my vivid-hsv patchset?
1) Add hsv_encoding
2) Add support for vivid hsv_encoding
?
Best Regards
Re: [PATCH v2 2/6] [media] Documentation: Add HSV format
Quoted 13 lines · Ricardo Ribalda Delgado
Hi Hans
Quoted 8 lines · Hans Verkuil
include/uapi/linux/videodev2.h enum v4l2_ycbcr_encoding { · line 341
Quoted 6 lines
include/uapi/linux/videodev2.h +5
-0+ +enum v4l2_rgb_encoding { +V4L2_RGB_ENC_FULL =32 , +V4L2_HSV_ENC_16_235 =33 , +};No.
Quoted 8 lines
I was trying to fit also Laurent special 16-235 RGB format. I will remove it on future versions.
Can I make this change as 2 new patches on my vivid-hsv patchset?
1) Add
hsv_encoding
2) Add support for vividhsv_encoding
Yes. I prefer them last in the series, since I am not quite 100% certain yet.
Regards,
Hans
Re: [PATCH v2 2/6] [media] Documentation: Add HSV format
In reply to Laurent PinchartQuoted 5 lines · Laurent Pinchart
Quoted 2 lines
Limited vs full range quantization is handled by the quantization field. It's there already.
Right. I wonder how we'll deal with that when someone will come up with more than one limited range quantizations, have you thought about it ?
There is just limited and full range. Limited range is basically a left-over from analog TV.
Quoted 4 lines
Quoted 2 lines
Limited range RGB is needed for HDMI due to a brain-dead spec when dealing with certain kinds of TVs and configurations. Don't ask, it's horrible.
I'd still like to know about it for my personal information :-)
RGB video over HDMI is limited range for CE timings (i.e. 720p, 1080p, 4k) unless signaled otherwise through the AVI InfoFrame. And you can only signal that if the sink supports it in the EDID (and doesn't lie about it).
Typically TVs follow CE timings, so hooking up a PC to a TV may very well cause problems (and often does).
Regards,
Hans
Re: [PATCH v2 2/6] [media] Documentation: Add HSV format
In reply to Laurent PinchartHi Laurent
It is actually a very good comment. :) In our case we have implemented the format ourselves in the FPGA and we support both 0-255 and 0-179 Hue ranges.
After some weeks of use, only the 0-179 range is used in userpace. The reasons for this is mainly that it is the format used by OpenCV
http://docs.opencv.org/3.1.0/de/d25/imgproc_color_conversions.html#color_convert_rgb_hsv&gsc.tab=0
, but also because it is very efficient to convert from 0-360 to 0-180 and the lose of color resolution (256/180) does not lead to (human) perceptible differences.
All that said, I would not mind to implement also the 0-255 range, but I do not know which API should be the best way to do it. quantization? it looks nice, but it is not really a quantization... a control? a bit messy.... fourcc? seems good...
I am open to anything :), but I am not the right guy for making the decision. Hans, could you help me?
Thanks!
Quoted 103 lines · Laurent Pinchart
Hi Ricardo,
Thank you for the patch.
Quoted 50 lines · On Friday 15 Jul 2016 18:13:15 Ricardo Ribalda Delgado wrote:
Describe the HSV formats
Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- Documentation/media/uapi/v4l/hsv-formats.rst | 19 ++ Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst | 253 ++++++++++++++++++ Documentation/media/uapi/v4l/pixfmt.rst | 1 + Documentation/media/uapi/v4l/v4l2.rst | 5 + 4 files changed, 278 insertions(+) create mode 100644 Documentation/media/uapi/v4l/hsv-formats.rst create mode 100644 Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst(quoted diff) +0
-0
b/Documentation/media/uapi/v4l/hsv-formats.rstnew file mode 100644 index 000000000000..f0f2615eaa95Documentation/media/uapi/v4l/hsv-formats.rst new file +19
-0@@ -0,0 +1,19 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _hsv-formats: + +*********** +HSV Formats +*********** + +These formats store the color information of the image +in a geometrical representation. The colors are mapped into a +cylinder, where the angle is the HUE, the height is the VALUE +and the distance to the center is the SATURATION. This is a very +useful format for image segmentation algorithms. + + +.. toctree:: + :maxdepth: 1 + + pixfmt-packed-hsv(quoted diff) +0
-0
b/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rstnew file mode 100644 index 000000000000..b297aa4f7ba6Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +7
-0@@ -0,0 +1,253 @@ +.. -*- coding: utf-8; mode: rst -*- + +.. _packed-hsv: + +****************** +Packed HSV formats +******************Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst line 17
Quoted 10 lines
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +10
-0+ +*man Packed HSV formats(2)* + +Packed HSV formats + + +Description +=========== + +The HUE (h) is meassured in degrees, one LSB represents two degrees.Is this common ? I have a device that can handle HSV data, I need to check how it maps the hue values to binary, but I'm pretty sure they cover the full 0-255 range. We would then have to support the two formats. Separate 4CCs are an option, but reporting the range separately (possibly through the colorspace API) might be better. Any thought on that ?
Quoted 11 lines
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +11
-0+The SATURATION (s) and the VALUE (v) are measured in percentage of the +cylinder: 0 being the smallest value and 255 the maximum. + + +The values are packed in 24 or 32 bit formats. + + +.. flat-table:: Packed HSV Image Formats + :header-rows: 2 + :stub-columns: 0 +Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst line 38
Quoted 10 lines
Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst new file +10
-0+ + - .. row 1 + + - Identifier + + - Code + + - + - :cspan:`7` Byte 0 in memory +Do we really need all those blank lines ?
[snip]
--
Regards,Laurent Pinchart
Signature · 1 line
Ricardo Ribalda
PATCH v2 3/6 Documentation: Add Ricardo Ribalda
In reply to Ricardo Ribalda DelgadoMy initials were on the Changelog, but there was no link to my name.
--- Documentation/media/uapi/v4l/v4l2.rst | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/media/uapi/v4l/v4l2.rst +4 -0
@@ -64,6 +64,10 @@ Authors, in alphabetical order: - SDR API. +- Ribalda, Ricardo + + - Introduce HSV formats and other minor changes. + - Rubli, Martin - Designed and documented the VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS ioctls.
Signature · 1 line
2.8.1
PATCH v2 4/6 vivid: code refactor for color representation
In reply to Ricardo Ribalda DelgadoReplace is_yuv with color_representation. Which can be used by HSV formats.
This change should ease the review of the following patches.
--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 44 ++++++++++++++------- drivers/media/platform/vivid/vivid-core.h | 2 +- drivers/media/platform/vivid/vivid-vid-common.c | 52 ++++++++++++------------- include/media/v4l2-tpg.h | 7 +++- 4 files changed, 63 insertions(+), 42 deletions(-)
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +30 -14
@@ -237,13 +237,13 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)case V4L2_PIX_FMT_GREY :case V4L2_PIX_FMT_Y16 :case V4L2_PIX_FMT_Y16_BE : - tpg->is_yuv = false; + tpg->color_representation =TGP_COLOR_REPRESENTATION_RGB ;break ;case V4L2_PIX_FMT_YUV444 :case V4L2_PIX_FMT_YUV555 :case V4L2_PIX_FMT_YUV565 :case V4L2_PIX_FMT_YUV32 : - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_YUV420M :case V4L2_PIX_FMT_YVU420M :
@@ -256,7 +256,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->hdownsampling[1 ] =2 ; tpg->hdownsampling[2 ] =2 ; tpg->planes =3 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_YUV422M :case V4L2_PIX_FMT_YVU422M :
@@ -268,7 +268,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->hdownsampling[1 ] =2 ; tpg->hdownsampling[2 ] =2 ; tpg->planes =3 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_NV16M :case V4L2_PIX_FMT_NV61M :
@@ -280,7 +280,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->hdownsampling[1 ] =1 ; tpg->hmask[1 ] = ~1 ; tpg->planes =2 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_NV12M :case V4L2_PIX_FMT_NV21M :
@@ -292,7 +292,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->hdownsampling[1 ] =1 ; tpg->hmask[1 ] = ~1 ; tpg->planes =2 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_YUV444M :case V4L2_PIX_FMT_YVU444M :
@@ -302,21 +302,21 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->vdownsampling[2 ] =1 ; tpg->hdownsampling[1 ] =1 ; tpg->hdownsampling[2 ] =1 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_NV24 :case V4L2_PIX_FMT_NV42 : tpg->vdownsampling[1 ] =1 ; tpg->hdownsampling[1 ] =1 ; tpg->planes =2 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_YUYV :case V4L2_PIX_FMT_UYVY :case V4L2_PIX_FMT_YVYU :case V4L2_PIX_FMT_VYUY : tpg->hmask[0 ] = ~1 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;default :return false;
@@ -820,7 +820,7 @@ static void precalculate_color(struct tpg_data *tpg, int k) cb = (128 <<4 ) + (tmp_cb * tpg->contrast * tpg->saturation) / (128 *128 ); cr = (128 <<4 ) + (tmp_cr * tpg->contrast * tpg->saturation) / (128 *128 ); -if (tpg->is_yuv) { +if (tpg->color_representation ==TGP_COLOR_REPRESENTATION_YUV ) { tpg->colors[k][0 ] =clamp (y >>4 ,1 ,254 ); tpg->colors[k][1 ] =clamp (cb >>4 ,1 ,254 ); tpg->colors[k][2 ] =clamp (cr >>4 ,1 ,254 );
@@ -829,7 +829,7 @@ static void precalculate_color(struct tpg_data *tpg, int k)ycbcr_to_color (tpg, y, cb, cr, &r, &g, &b); } -if (tpg->is_yuv) { +if (tpg->color_representation ==TGP_COLOR_REPRESENTATION_YUV ) {/* Convert to YCbCr */ int y, cb, cr;
@@ -1842,7 +1842,9 @@ static void tpg_recalc(struct tpg_data *tpg)if (tpg->quantization ==V4L2_QUANTIZATION_DEFAULT ) tpg->real_quantization = -V4L2_MAP_QUANTIZATION_DEFAULT (!tpg->is_yuv, +V4L2_MAP_QUANTIZATION_DEFAULT ( + tpg->color_representation == +TGP_COLOR_REPRESENTATION_RGB , tpg->colorspace, tpg->real_ycbcr_enc);tpg_precalculate_colors (tpg);
@@ -1889,11 +1891,25 @@ static int tpg_pattern_avg(const struct tpg_data *tpg,return -1 ; } +static const char *tpg_color_representation_str (enum tgp_color_representation + color_representation) +{ +switch (color_representation) { + +case TGP_COLOR_REPRESENTATION_YUV : +return "YCbCr" ; +case TGP_COLOR_REPRESENTATION_RGB : +default : +return "RGB" ; + + } +} +void tpg_log_status (struct tpg_data *tpg) {pr_info ("tpg source WxH: %ux%u (%s)\n" , - tpg->src_width, tpg->src_height, - tpg->is_yuv ?"YCbCr" :"RGB" ); + tpg->src_width, tpg->src_height, +tpg_color_representation_str (tpg->color_representation));pr_info ("tpg field: %u\n" , tpg->field);pr_info ("tpg crop: %ux%u@%dx%d\n" , tpg->crop.width, tpg->crop.height, tpg->crop.left, tpg->crop.top);
drivers/media/platform/vivid/vivid-core.h +1 -1
@@ -80,7 +80,7 @@ extern unsigned vivid_debug;struct vivid_fmt {u32 fourcc;/* v4l2 format id */ -bool is_yuv; +enum tgp_color_representation color_representation;bool can_do_overlay;u8 vdownsampling[TPG_MAX_PLANES ];u32 alpha_mask;
drivers/media/platform/vivid/vivid-vid-common.c +26 -26
208 lines not on this page · raw message
include/media/v4l2-tpg.h +6 -1
@@ -87,6 +87,11 @@ enum tpg_move_mode { TPG_MOVE_POS_FAST, }; +enum tgp_color_representation { +TGP_COLOR_REPRESENTATION_RGB , +TGP_COLOR_REPRESENTATION_YUV , +}; +extern const char *const tpg_aspect_strings[];#define TPG_MAX_PLANES 3
@@ -119,7 +124,7 @@ struct tpg_data {u8 saturation;s16 hue;u32 fourcc; -bool is_yuv; +enum tgp_color_representation color_representation;u32 colorspace;u32 xfer_func;u32 ycbcr_enc;
Signature · 1 line
2.8.1
Re: [PATCH v2 4/6] [media] vivid: code refactor for color representation
Quoted 4 lines · Ricardo Ribalda Delgado
Replace
is_yuvwithcolor_representation. Which can be used by HSV formats.This change should ease the review of the following patches.
It's a bit of a mouthful. How about calling this color_enc and TPG_COLOR_ENC_? (i.e. color encoding).
I would also like to have a TPG_COLOR_ENC_LUMA for the greyscale formats. This patch is a good opportunity to add that.
Regards,
Hans
Quoted 424 lines
Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 44 ++++++++++++++------- drivers/media/platform/vivid/vivid-core.h | 2 +- drivers/media/platform/vivid/vivid-vid-common.c | 52 ++++++++++++------------- include/media/v4l2-tpg.h | 7 +++- 4 files changed, 63 insertions(+), 42 deletions(-)drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +30
-14@@ -237,13 +237,13 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)case V4L2_PIX_FMT_GREY :case V4L2_PIX_FMT_Y16 :case V4L2_PIX_FMT_Y16_BE : - tpg->is_yuv = false; + tpg->color_representation =TGP_COLOR_REPRESENTATION_RGB ;break ;case V4L2_PIX_FMT_YUV444 :case V4L2_PIX_FMT_YUV555 :case V4L2_PIX_FMT_YUV565 :case V4L2_PIX_FMT_YUV32 : - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_YUV420M :case V4L2_PIX_FMT_YVU420M :@@ -256,7 +256,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->hdownsampling[1 ] =2 ; tpg->hdownsampling[2 ] =2 ; tpg->planes =3 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_YUV422M :case V4L2_PIX_FMT_YVU422M :@@ -268,7 +268,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->hdownsampling[1 ] =2 ; tpg->hdownsampling[2 ] =2 ; tpg->planes =3 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_NV16M :case V4L2_PIX_FMT_NV61M :@@ -280,7 +280,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->hdownsampling[1 ] =1 ; tpg->hmask[1 ] = ~1 ; tpg->planes =2 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_NV12M :case V4L2_PIX_FMT_NV21M :@@ -292,7 +292,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->hdownsampling[1 ] =1 ; tpg->hmask[1 ] = ~1 ; tpg->planes =2 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_YUV444M :case V4L2_PIX_FMT_YVU444M :@@ -302,21 +302,21 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->vdownsampling[2 ] =1 ; tpg->hdownsampling[1 ] =1 ; tpg->hdownsampling[2 ] =1 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_NV24 :case V4L2_PIX_FMT_NV42 : tpg->vdownsampling[1 ] =1 ; tpg->hdownsampling[1 ] =1 ; tpg->planes =2 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;case V4L2_PIX_FMT_YUYV :case V4L2_PIX_FMT_UYVY :case V4L2_PIX_FMT_YVYU :case V4L2_PIX_FMT_VYUY : tpg->hmask[0 ] = ~1 ; - tpg->is_yuv = true; + tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ;default :return false;@@ -820,7 +820,7 @@ static void precalculate_color(struct tpg_data *tpg, int k) cb = (128 <<4 ) + (tmp_cb * tpg->contrast * tpg->saturation) / (128 *128 ); cr = (128 <<4 ) + (tmp_cr * tpg->contrast * tpg->saturation) / (128 *128 ); -if (tpg->is_yuv) { +if (tpg->color_representation ==TGP_COLOR_REPRESENTATION_YUV ) { tpg->colors[k][0 ] =clamp (y >>4 ,1 ,254 ); tpg->colors[k][1 ] =clamp (cb >>4 ,1 ,254 ); tpg->colors[k][2 ] =clamp (cr >>4 ,1 ,254 );@@ -829,7 +829,7 @@ static void precalculate_color(struct tpg_data *tpg, int k)ycbcr_to_color (tpg, y, cb, cr, &r, &g, &b); } -if (tpg->is_yuv) { +if (tpg->color_representation ==TGP_COLOR_REPRESENTATION_YUV ) {/* Convert to YCbCr */ int y, cb, cr;@@ -1842,7 +1842,9 @@ static void tpg_recalc(struct tpg_data *tpg)if (tpg->quantization ==V4L2_QUANTIZATION_DEFAULT ) tpg->real_quantization = -V4L2_MAP_QUANTIZATION_DEFAULT (!tpg->is_yuv, +V4L2_MAP_QUANTIZATION_DEFAULT ( + tpg->color_representation == +TGP_COLOR_REPRESENTATION_RGB , tpg->colorspace, tpg->real_ycbcr_enc);tpg_precalculate_colors (tpg);@@ -1889,11 +1891,25 @@ static int tpg_pattern_avg(const struct tpg_data *tpg,return -1 ; } +static const char *tpg_color_representation_str (enum tgp_color_representation + color_representation) +{ +switch (color_representation) { + +case TGP_COLOR_REPRESENTATION_YUV : +return "YCbCr" ; +case TGP_COLOR_REPRESENTATION_RGB : +default : +return "RGB" ; + + } +} +void tpg_log_status (struct tpg_data *tpg) {pr_info ("tpg source WxH: %ux%u (%s)\n" , - tpg->src_width, tpg->src_height, - tpg->is_yuv ?"YCbCr" :"RGB" ); + tpg->src_width, tpg->src_height, +tpg_color_representation_str (tpg->color_representation));pr_info ("tpg field: %u\n" , tpg->field);pr_info ("tpg crop: %ux%u@%dx%d\n" , tpg->crop.width, tpg->crop.height, tpg->crop.left, tpg->crop.top);drivers/media/platform/vivid/vivid-core.h +1
-1@@ -80,7 +80,7 @@ extern unsigned vivid_debug;struct vivid_fmt {u32 fourcc;/* v4l2 format id */ -bool is_yuv; +enum tgp_color_representation color_representation;bool can_do_overlay;u8 vdownsampling[TPG_MAX_PLANES ];u32 alpha_mask;drivers/media/platform/vivid/vivid-vid-common.c +26
-26@@ -48,7 +48,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_YUYV, .vdownsampling = { 1 }, .bit_depth = { 16 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 1, .buffers = 1, .data_offset = { PLANE0_DATA_OFFSET },@@ -57,7 +57,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_UYVY, .vdownsampling = { 1 }, .bit_depth = { 16 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 1, .buffers = 1, },@@ -65,7 +65,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_YVYU, .vdownsampling = { 1 }, .bit_depth = { 16 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 1, .buffers = 1, },@@ -73,7 +73,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_VYUY, .vdownsampling = { 1 }, .bit_depth = { 16 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 1, .buffers = 1, },@@ -81,7 +81,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_YUV422P, .vdownsampling = { 1, 1, 1 }, .bit_depth = { 8, 4, 4 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 3, .buffers = 1, },@@ -89,7 +89,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_YUV420, .vdownsampling = { 1, 2, 2 }, .bit_depth = { 8, 4, 4 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 3, .buffers = 1, },@@ -97,7 +97,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_YVU420, .vdownsampling = { 1, 2, 2 }, .bit_depth = { 8, 4, 4 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 3, .buffers = 1, },@@ -105,7 +105,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_NV12, .vdownsampling = { 1, 2 }, .bit_depth = { 8, 8 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 2, .buffers = 1, },@@ -113,7 +113,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_NV21, .vdownsampling = { 1, 2 }, .bit_depth = { 8, 8 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 2, .buffers = 1, },@@ -121,7 +121,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_NV16, .vdownsampling = { 1, 1 }, .bit_depth = { 8, 8 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 2, .buffers = 1, },@@ -129,7 +129,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_NV61, .vdownsampling = { 1, 1 }, .bit_depth = { 8, 8 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 2, .buffers = 1, },@@ -137,7 +137,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_NV24, .vdownsampling = { 1, 1 }, .bit_depth = { 8, 16 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 2, .buffers = 1, },@@ -145,7 +145,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_NV42, .vdownsampling = { 1, 1 }, .bit_depth = { 8, 16 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 2, .buffers = 1, },@@ -184,7 +184,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_GREY, .vdownsampling = { 1 }, .bit_depth = { 8 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 1, .buffers = 1, },@@ -192,7 +192,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_Y16, .vdownsampling = { 1 }, .bit_depth = { 16 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 1, .buffers = 1, },@@ -200,7 +200,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_Y16_BE, .vdownsampling = { 1 }, .bit_depth = { 16 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 1, .buffers = 1, },@@ -452,7 +452,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_NV16M, .vdownsampling = { 1, 1 }, .bit_depth = { 8, 8 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 2, .buffers = 2, .data_offset = { PLANE0_DATA_OFFSET, 0 },@@ -461,7 +461,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_NV61M, .vdownsampling = { 1, 1 }, .bit_depth = { 8, 8 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 2, .buffers = 2, .data_offset = { 0, PLANE0_DATA_OFFSET },@@ -470,7 +470,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_YUV420M, .vdownsampling = { 1, 2, 2 }, .bit_depth = { 8, 4, 4 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 3, .buffers = 3, },@@ -478,7 +478,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_YVU420M, .vdownsampling = { 1, 2, 2 }, .bit_depth = { 8, 4, 4 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 3, .buffers = 3, },@@ -486,7 +486,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_NV12M, .vdownsampling = { 1, 2 }, .bit_depth = { 8, 8 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 2, .buffers = 2, },@@ -494,7 +494,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_NV21M, .vdownsampling = { 1, 2 }, .bit_depth = { 8, 8 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 2, .buffers = 2, },@@ -502,7 +502,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_YUV422M, .vdownsampling = { 1, 1, 1 }, .bit_depth = { 8, 4, 4 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 3, .buffers = 3, },@@ -510,7 +510,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_YVU422M, .vdownsampling = { 1, 1, 1 }, .bit_depth = { 8, 4, 4 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 3, .buffers = 3, },@@ -518,7 +518,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_YUV444M, .vdownsampling = { 1, 1, 1 }, .bit_depth = { 8, 8, 8 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 3, .buffers = 3, },@@ -526,7 +526,7 @@ struct vivid_fmt vivid_formats[] = { .fourcc = V4L2_PIX_FMT_YVU444M, .vdownsampling = { 1, 1, 1 }, .bit_depth = { 8, 8, 8 }, - .is_yuv = true, + .color_representation = TGP_COLOR_REPRESENTATION_YUV, .planes = 3, .buffers = 3, },include/media/v4l2-tpg.h +6
-1@@ -87,6 +87,11 @@ enum tpg_move_mode { TPG_MOVE_POS_FAST, }; +enum tgp_color_representation { +TGP_COLOR_REPRESENTATION_RGB , +TGP_COLOR_REPRESENTATION_YUV , +}; +extern const char *const tpg_aspect_strings[];#define TPG_MAX_PLANES 3@@ -119,7 +124,7 @@ struct tpg_data {u8 saturation;s16 hue;u32 fourcc; -bool is_yuv; +enum tgp_color_representation color_representation;u32 colorspace;u32 xfer_func;u32 ycbcr_enc;
Re: [PATCH v2 4/6] [media] vivid: code refactor for color representation
Quoted 11 lines · Hans Verkuil
Quoted 4 lines · Ricardo Ribalda Delgado
Replace
is_yuvwithcolor_representation. Which can be used by HSV formats.This change should ease the review of the following patches.
It's a bit of a mouthful. How about calling this
color_encandTPG_COLOR_ENC_? (i.e. color encoding).I would also like to have a
TPG_COLOR_ENC_LUMAfor the greyscale formats. This patch is a good opportunity to add that.
Also note that docs-next is older than the master branch w.r.t. the tpg. You're missing two is_yuv checks is docs-next that are present in the master.
Also:
Quoted 5 lines
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c static int tpg_pattern_avg(const struct tpg_data *tpg, · line 1898
Quoted 5 lines
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +5
-0+static const char *tpg_color_representation_str (enum tgp_color_representation + color_representation) +{ +switch (color_representation) { +
Drop empty line.
Quoted 8 lines
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c static int tpg_pattern_avg(const struct tpg_data *tpg, · line 1906
Quoted 8 lines
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +8
-0+case TGP_COLOR_REPRESENTATION_YUV : +return "YCbCr" ; +case TGP_COLOR_REPRESENTATION_RGB : +default : +return "RGB" ; + + } +}
Regards,
Hans
Re: [PATCH v2 4/6] [media] vivid: code refactor for color representation
In reply to Ricardo Ribalda DelgadoQuoted 18 lines · Ricardo Ribalda Delgado
Replace
is_yuvwithcolor_representation. Which can be used by HSV formats.This change should ease the review of the following patches.
Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 44 ++++++++++++++------- drivers/media/platform/vivid/vivid-core.h | 2 +- drivers/media/platform/vivid/vivid-vid-common.c | 52 ++++++++++++------------- include/media/v4l2-tpg.h | 7 +++- 4 files changed, 63 insertions(+), 42 deletions(-)drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +0
-0
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c static void tpg_recalc(struct tpg_data *tpg) · line 1847
Quoted 7 lines
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +3
-1@@ -1842,7 +1842,9 @@ static void tpg_recalc(struct tpg_data *tpg)if (tpg->quantization ==V4L2_QUANTIZATION_DEFAULT ) tpg->real_quantization = - V4L2_MAP_QUANTIZATION_DEFAULT(!tpg->is_yuv, + V4L2_MAP_QUANTIZATION_DEFAULT( + tpg->color_representation == + TGP_COLOR_REPRESENTATION_RGB,
This should be != TGP_COLOR_REPRESENTATION_YUV.
Otherwise HSV would map to limited range by default, which is probably wrong.
Regards,
Hans
Quoted 3 lines
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +0
-0tpg->colorspace, tpg->real_ycbcr_enc);tpg_precalculate_colors (tpg);
PATCH v2 5/6 vivid: Add support for HSV formats
In reply to Ricardo Ribalda DelgadoThis patch adds support for V4L2_PIX_FMT_HSV24 and V4L2_PIX_FMT_HSV32.
--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 94 +++++++++++++++++++++++-- drivers/media/platform/vivid/vivid-vid-common.c | 14 ++++ include/media/v4l2-tpg.h | 1 + 3 files changed, 105 insertions(+), 4 deletions(-)
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +90 -4
@@ -318,6 +318,10 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->hmask[0 ] = ~1 ; tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ; +case V4L2_PIX_FMT_HSV24 : +case V4L2_PIX_FMT_HSV32 : + tpg->color_representation =TGP_COLOR_REPRESENTATION_HSV ; +break ;default :return false; }
@@ -351,6 +355,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)break ;case V4L2_PIX_FMT_RGB24 :case V4L2_PIX_FMT_BGR24 : +case V4L2_PIX_FMT_HSV24 : tpg->twopixelsize[0 ] =2 *3 ;break ;case V4L2_PIX_FMT_BGR666 :
@@ -361,6 +366,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)case V4L2_PIX_FMT_ARGB32 :case V4L2_PIX_FMT_ABGR32 :case V4L2_PIX_FMT_YUV32 : +case V4L2_PIX_FMT_HSV32 : tpg->twopixelsize[0 ] =2 *4 ;break ;case V4L2_PIX_FMT_NV12 :
@@ -408,6 +414,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->twopixelsize[1 ] =4 ;break ; } +return true; }EXPORT_SYMBOL_GPL (tpg_s_fourcc);
@@ -490,6 +497,64 @@ static inline int linear_to_rec709(int v)return tpg_linear_to_rec709[v]; } +static void color_to_hsv (struct tpg_data *tpg,int r,int g,int b, +int *h,int *s,int *v) +{ +int max_rgb, min_rgb, diff_rgb; +int aux; +int third; + + r >>=4 ; + g >>=4 ; + b >>=4 ; + +/*V*/ + max_rgb =max3 (r, g, b); + *v = max_rgb; +if (!max_rgb) { + *h =0 ; + *s =0 ; +return ; + } + +/*S*/ + min_rgb =min3 (r, g, b); + diff_rgb = max_rgb - min_rgb; + aux =255 * diff_rgb; + aux += max_rgb /2 ; + aux /= max_rgb; + *s = aux; +if (!aux) { + *h =0 ; +return ; + } + +/*H*/ +if (max_rgb == r) { + aux = g - b; + third =0 ; + }else if (max_rgb == g) { + aux = b - r; + third =60 ; + }else { + aux = r - g; + third =120 ; + } + + aux *=30 ; + aux += diff_rgb /2 ; + aux /= diff_rgb; + aux += third; + +/*Clamp H*/ +if (aux <0 ) + aux +=180 ; +else if (aux >180 ) + aux -=180 ; + *h = aux; + +} +static void rgb2ycbcr (const int m[3 ][3 ],int r,int g,int b,int y_offset,int *y,int *cb,int *cr) {
@@ -829,7 +894,19 @@ static void precalculate_color(struct tpg_data *tpg, int k)ycbcr_to_color (tpg, y, cb, cr, &r, &g, &b); } -if (tpg->color_representation ==TGP_COLOR_REPRESENTATION_YUV ) { +switch (tpg->color_representation) { +case TGP_COLOR_REPRESENTATION_HSV : + { +int h, s, v; + +color_to_hsv (tpg, r, g, b, &h, &s, &v); + tpg->colors[k][0 ] = h; + tpg->colors[k][1 ] = s; + tpg->colors[k][2 ] = v; +break ; + } +case TGP_COLOR_REPRESENTATION_YUV : + {/* Convert to YCbCr */ int y, cb, cr;
@@ -863,7 +940,10 @@ static void precalculate_color(struct tpg_data *tpg, int k) tpg->colors[k][0 ] = y; tpg->colors[k][1 ] = cb; tpg->colors[k][2 ] = cr; - }else { +break ; + } +case TGP_COLOR_REPRESENTATION_RGB : + {if (tpg->real_quantization ==V4L2_QUANTIZATION_LIM_RANGE ) { r = (r *219 ) /255 + (16 <<4 ); g = (g *219 ) /255 + (16 <<4 );
@@ -913,6 +993,8 @@ static void precalculate_color(struct tpg_data *tpg, int k) tpg->colors[k][0 ] = r; tpg->colors[k][1 ] = g; tpg->colors[k][2 ] = b; +break ; + } } }
@@ -938,8 +1020,8 @@ static void gen_twopix(struct tpg_data *tpg, alpha =0 ;if (color ==TPG_COLOR_RANDOM )precalculate_color (tpg, color); - r_y = tpg->colors[color][0 ];/* R or precalculated Y */ - g_u = tpg->colors[color][1 ];/* G or precalculated U */ + r_y = tpg->colors[color][0 ];/* R or precalculated Y, H */ + g_u = tpg->colors[color][1 ];/* G or precalculated U, V */ b_v = tpg->colors[color][2 ];/* B or precalculated V */ switch (tpg->fourcc) {
@@ -1121,6 +1203,7 @@ static void gen_twopix(struct tpg_data *tpg, buf[0 ][offset +1 ] = (g_u <<5 ) | b_v;break ;case V4L2_PIX_FMT_RGB24 : +case V4L2_PIX_FMT_HSV24 : buf[0 ][offset] = r_y; buf[0 ][offset +1 ] = g_u; buf[0 ][offset +2 ] = b_v;
@@ -1138,6 +1221,7 @@ static void gen_twopix(struct tpg_data *tpg,break ;case V4L2_PIX_FMT_RGB32 :case V4L2_PIX_FMT_XRGB32 : +case V4L2_PIX_FMT_HSV32 : alpha =0 ;/* fall through */ case V4L2_PIX_FMT_YUV32 :
@@ -1896,6 +1980,8 @@ static const char *tpg_color_representation_str(enum tgp_color_representation {switch (color_representation) { +case TGP_COLOR_REPRESENTATION_HSV : +return "HSV" ;case TGP_COLOR_REPRESENTATION_YUV :return "YCbCr" ;case TGP_COLOR_REPRESENTATION_RGB :
drivers/media/platform/vivid/vivid-vid-common.c +14 -0
@@ -445,6 +445,20 @@ struct vivid_fmt vivid_formats[] = { .planes = 1, .buffers = 1, }, + { + .fourcc = V4L2_PIX_FMT_HSV24, /* HSV 24bits */ + .vdownsampling = { 1 }, + .bit_depth = { 24 }, + .planes = 1, + .buffers = 1, + }, + { + .fourcc = V4L2_PIX_FMT_HSV32, /* HSV 32bits */ + .vdownsampling = { 1 }, + .bit_depth = { 32 }, + .planes = 1, + .buffers = 1, + }, /* Multiplanar formats */
include/media/v4l2-tpg.h +1 -0
@@ -90,6 +90,7 @@ enum tpg_move_mode {enum tgp_color_representation {TGP_COLOR_REPRESENTATION_RGB ,TGP_COLOR_REPRESENTATION_YUV , +TGP_COLOR_REPRESENTATION_HSV , };extern const char *const tpg_aspect_strings[];
Signature · 1 line
2.8.1
Re: [PATCH v2 5/6] [media] vivid: Add support for HSV formats
Quoted 54 lines · Ricardo Ribalda Delgado
This patch adds support for
V4L2_PIX_FMT_HSV24andV4L2_PIX_FMT_HSV32.Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 94 +++++++++++++++++++++++-- drivers/media/platform/vivid/vivid-vid-common.c | 14 ++++ include/media/v4l2-tpg.h | 1 + 3 files changed, 105 insertions(+), 4 deletions(-)drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +9
-0@@ -318,6 +318,10 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->hmask[0 ] = ~1 ; tpg->color_representation =TGP_COLOR_REPRESENTATION_YUV ;break ; +case V4L2_PIX_FMT_HSV24 : +case V4L2_PIX_FMT_HSV32 : + tpg->color_representation =TGP_COLOR_REPRESENTATION_HSV ; +break ;default :return false; }@@ -351,6 +355,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)break ;case V4L2_PIX_FMT_RGB24 :case V4L2_PIX_FMT_BGR24 : +case V4L2_PIX_FMT_HSV24 : tpg->twopixelsize[0 ] =2 *3 ;break ;case V4L2_PIX_FMT_BGR666 :@@ -361,6 +366,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)case V4L2_PIX_FMT_ARGB32 :case V4L2_PIX_FMT_ABGR32 :case V4L2_PIX_FMT_YUV32 : +case V4L2_PIX_FMT_HSV32 : tpg->twopixelsize[0 ] =2 *4 ;break ;case V4L2_PIX_FMT_NV12 :@@ -408,6 +414,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) tpg->twopixelsize[1 ] =4 ;break ; } +return true; }EXPORT_SYMBOL_GPL (tpg_s_fourcc);@@ -490,6 +497,64 @@ static inline int linear_to_rec709(int v)return tpg_linear_to_rec709[v]; } +static void color_to_hsv (struct tpg_data *tpg,int r,int g,int b, +int *h,int *s,int *v)
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c static inline int linear_to_rec709(int v) · line 511
Quoted 10 lines
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +10
-0+{ +int max_rgb, min_rgb, diff_rgb; +int aux; +int third; + + r >>=4 ; + g >>=4 ; + b >>=4 ; + +/*V*/
Please add a space after /* and before */.
I also think it is better to write Value, Saturation, Hue instead of V, S, H.
Quoted 53 lines
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +46
-0+ max_rgb =max3 (r, g, b); + *v = max_rgb; +if (!max_rgb) { + *h =0 ; + *s =0 ; +return ; + } + +/*S*/ + min_rgb =min3 (r, g, b); + diff_rgb = max_rgb - min_rgb; + aux =255 * diff_rgb; + aux += max_rgb /2 ; + aux /= max_rgb; + *s = aux; +if (!aux) { + *h =0 ; +return ; + } + +/*H*/ +if (max_rgb == r) { + aux = g - b; + third =0 ; + }else if (max_rgb == g) { + aux = b - r; + third =60 ; + }else { + aux = r - g; + third =120 ; + } + + aux *=30 ; + aux += diff_rgb /2 ; + aux /= diff_rgb; + aux += third; + +/*Clamp H*/ +if (aux <0 ) + aux +=180 ; +else if (aux >180 ) + aux -=180 ; + *h = aux; + +} +static void rgb2ycbcr (const int m[3 ][3 ],int r,int g,int b,int y_offset,int *y,int *cb,int *cr) {@@ -829,7 +894,19 @@ static void precalculate_color(struct tpg_data *tpg, int k)ycbcr_to_color (tpg, y, cb, cr, &r, &g, &b); }
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c static void precalculate_color(struct tpg_data *tpg, int k) · line 905
Quoted 10 lines
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +9
-1-if (tpg->color_representation ==TGP_COLOR_REPRESENTATION_YUV ) { +switch (tpg->color_representation) { +case TGP_COLOR_REPRESENTATION_HSV : + { +int h, s, v; + +color_to_hsv (tpg, r, g, b, &h, &s, &v); + tpg->colors[k][0 ] = h; + tpg->colors[k][1 ] = s; + tpg->colors[k][2 ] = v;
Would quantization (limited/full range) be relevant here? I don't know if limited range would make sense (or what those limits would be).
Regards,
Hans
PATCH v2 6/6 vivid: Rename variable
In reply to Ricardo Ribalda Delgador_y and g_u now also contain the H and V components on the HSV formats. Rename the variables to reflect this.
--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 209 +++++++++++++------------- 1 file changed, 105 insertions(+), 104 deletions(-)
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +105 -104
@@ -1012,7 +1012,7 @@ static void gen_twopix(struct tpg_data *tpg, {unsigned offset = odd * tpg->twopixelsize[0 ] /2 ;u8 alpha = tpg->alpha_component; -u8 r_y, g_u, b_v; +u8 r_y_h, g_u_s, b_v; if (tpg->alpha_red_only && color != TPG_COLOR_CSC_RED && color != TPG_COLOR_100_RED &&
@@ -1020,161 +1020,161 @@ static void gen_twopix(struct tpg_data *tpg, alpha =0 ;if (color ==TPG_COLOR_RANDOM )precalculate_color (tpg, color); - r_y = tpg->colors[color][0 ];/* R or precalculated Y, H */ - g_u = tpg->colors[color][1 ];/* G or precalculated U, V */ + r_y_h = tpg->colors[color][0 ];/* R or precalculated Y, H */ + g_u_s = tpg->colors[color][1 ];/* G or precalculated U, V */ b_v = tpg->colors[color][2 ];/* B or precalculated V */ switch (tpg->fourcc) {case V4L2_PIX_FMT_GREY : - buf[0 ][offset] = r_y; + buf[0 ][offset] = r_y_h;break ;case V4L2_PIX_FMT_Y16 :/* -* Ideally both bytes should be set to r_y, but then you won't +* Ideally both bytes should be set to r_y_h, but then you won't * be able to detect endian problems. So keep it 0 except for -* the corner case where r_y is 0xff so white really will be +* the corner case where r_y_h is 0xff so white really will be * white (0xffff). */ - buf[0 ][offset] = r_y ==0xff ? r_y :0 ; - buf[0 ][offset+1 ] = r_y; + buf[0 ][offset] = r_y_h ==0xff ? r_y_h :0 ; + buf[0 ][offset+1 ] = r_y_h;break ;case V4L2_PIX_FMT_Y16_BE :/* See comment for V4L2_PIX_FMT_Y16 above */ - buf[0 ][offset] = r_y; - buf[0 ][offset+1 ] = r_y ==0xff ? r_y :0 ; + buf[0 ][offset] = r_y_h; + buf[0 ][offset+1 ] = r_y_h ==0xff ? r_y_h :0 ;break ;case V4L2_PIX_FMT_YUV422M :case V4L2_PIX_FMT_YUV422P :case V4L2_PIX_FMT_YUV420 :case V4L2_PIX_FMT_YUV420M : - buf[0 ][offset] = r_y; + buf[0 ][offset] = r_y_h;if (odd) { - buf[1 ][0 ] = (buf[1 ][0 ] + g_u) /2 ; + buf[1 ][0 ] = (buf[1 ][0 ] + g_u_s) /2 ; buf[2 ][0 ] = (buf[2 ][0 ] + b_v) /2 ; buf[1 ][1 ] = buf[1 ][0 ]; buf[2 ][1 ] = buf[2 ][0 ];break ; } - buf[1 ][0 ] = g_u; + buf[1 ][0 ] = g_u_s; buf[2 ][0 ] = b_v;break ;case V4L2_PIX_FMT_YVU422M :case V4L2_PIX_FMT_YVU420 :case V4L2_PIX_FMT_YVU420M : - buf[0 ][offset] = r_y; + buf[0 ][offset] = r_y_h;if (odd) { buf[1 ][0 ] = (buf[1 ][0 ] + b_v) /2 ; - buf[2 ][0 ] = (buf[2 ][0 ] + g_u) /2 ; + buf[2 ][0 ] = (buf[2 ][0 ] + g_u_s) /2 ; buf[1 ][1 ] = buf[1 ][0 ]; buf[2 ][1 ] = buf[2 ][0 ];break ; } buf[1 ][0 ] = b_v; - buf[2 ][0 ] = g_u; + buf[2 ][0 ] = g_u_s;break ;case V4L2_PIX_FMT_NV12 :case V4L2_PIX_FMT_NV12M :case V4L2_PIX_FMT_NV16 :case V4L2_PIX_FMT_NV16M : - buf[0 ][offset] = r_y; + buf[0 ][offset] = r_y_h;if (odd) { - buf[1 ][0 ] = (buf[1 ][0 ] + g_u) /2 ; + buf[1 ][0 ] = (buf[1 ][0 ] + g_u_s) /2 ; buf[1 ][1 ] = (buf[1 ][1 ] + b_v) /2 ;break ; } - buf[1 ][0 ] = g_u; + buf[1 ][0 ] = g_u_s; buf[1 ][1 ] = b_v;break ;case V4L2_PIX_FMT_NV21 :case V4L2_PIX_FMT_NV21M :case V4L2_PIX_FMT_NV61 :case V4L2_PIX_FMT_NV61M : - buf[0 ][offset] = r_y; + buf[0 ][offset] = r_y_h;if (odd) { buf[1 ][0 ] = (buf[1 ][0 ] + b_v) /2 ; - buf[1 ][1 ] = (buf[1 ][1 ] + g_u) /2 ; + buf[1 ][1 ] = (buf[1 ][1 ] + g_u_s) /2 ;break ; } buf[1 ][0 ] = b_v; - buf[1 ][1 ] = g_u; + buf[1 ][1 ] = g_u_s;break ;case V4L2_PIX_FMT_YUV444M : - buf[0 ][offset] = r_y; - buf[1 ][offset] = g_u; + buf[0 ][offset] = r_y_h; + buf[1 ][offset] = g_u_s; buf[2 ][offset] = b_v;break ;case V4L2_PIX_FMT_YVU444M : - buf[0 ][offset] = r_y; + buf[0 ][offset] = r_y_h; buf[1 ][offset] = b_v; - buf[2 ][offset] = g_u; + buf[2 ][offset] = g_u_s;break ;case V4L2_PIX_FMT_NV24 : - buf[0 ][offset] = r_y; - buf[1 ][2 * offset] = g_u; + buf[0 ][offset] = r_y_h; + buf[1 ][2 * offset] = g_u_s; buf[1 ][2 * offset +1 ] = b_v;break ;case V4L2_PIX_FMT_NV42 : - buf[0 ][offset] = r_y; + buf[0 ][offset] = r_y_h; buf[1 ][2 * offset] = b_v; - buf[1 ][2 * offset +1 ] = g_u; + buf[1 ][2 * offset +1 ] = g_u_s;break ;case V4L2_PIX_FMT_YUYV : - buf[0 ][offset] = r_y; + buf[0 ][offset] = r_y_h;if (odd) { - buf[0 ][1 ] = (buf[0 ][1 ] + g_u) /2 ; + buf[0 ][1 ] = (buf[0 ][1 ] + g_u_s) /2 ; buf[0 ][3 ] = (buf[0 ][3 ] + b_v) /2 ;break ; } - buf[0 ][1 ] = g_u; + buf[0 ][1 ] = g_u_s; buf[0 ][3 ] = b_v;break ;case V4L2_PIX_FMT_UYVY : - buf[0 ][offset +1 ] = r_y; + buf[0 ][offset +1 ] = r_y_h;if (odd) { - buf[0 ][0 ] = (buf[0 ][0 ] + g_u) /2 ; + buf[0 ][0 ] = (buf[0 ][0 ] + g_u_s) /2 ; buf[0 ][2 ] = (buf[0 ][2 ] + b_v) /2 ;break ; } - buf[0 ][0 ] = g_u; + buf[0 ][0 ] = g_u_s; buf[0 ][2 ] = b_v;break ;case V4L2_PIX_FMT_YVYU : - buf[0 ][offset] = r_y; + buf[0 ][offset] = r_y_h;if (odd) { buf[0 ][1 ] = (buf[0 ][1 ] + b_v) /2 ; - buf[0 ][3 ] = (buf[0 ][3 ] + g_u) /2 ; + buf[0 ][3 ] = (buf[0 ][3 ] + g_u_s) /2 ;break ; } buf[0 ][1 ] = b_v; - buf[0 ][3 ] = g_u; + buf[0 ][3 ] = g_u_s;break ;case V4L2_PIX_FMT_VYUY : - buf[0 ][offset +1 ] = r_y; + buf[0 ][offset +1 ] = r_y_h;if (odd) { buf[0 ][0 ] = (buf[0 ][0 ] + b_v) /2 ; - buf[0 ][2 ] = (buf[0 ][2 ] + g_u) /2 ; + buf[0 ][2 ] = (buf[0 ][2 ] + g_u_s) /2 ;break ; } buf[0 ][0 ] = b_v; - buf[0 ][2 ] = g_u; + buf[0 ][2 ] = g_u_s;break ;case V4L2_PIX_FMT_RGB332 : - buf[0 ][offset] = (r_y <<5 ) | (g_u <<2 ) | b_v; + buf[0 ][offset] = (r_y_h <<5 ) | (g_u_s <<2 ) | b_v;break ;case V4L2_PIX_FMT_YUV565 :case V4L2_PIX_FMT_RGB565 : - buf[0 ][offset] = (g_u <<5 ) | b_v; - buf[0 ][offset +1 ] = (r_y <<3 ) | (g_u >>3 ); + buf[0 ][offset] = (g_u_s <<5 ) | b_v; + buf[0 ][offset +1 ] = (r_y_h <<3 ) | (g_u_s >>3 );break ;case V4L2_PIX_FMT_RGB565X : - buf[0 ][offset] = (r_y <<3 ) | (g_u >>3 ); - buf[0 ][offset +1 ] = (g_u <<5 ) | b_v; + buf[0 ][offset] = (r_y_h <<3 ) | (g_u_s >>3 ); + buf[0 ][offset +1 ] = (g_u_s <<5 ) | b_v;break ;case V4L2_PIX_FMT_RGB444 :case V4L2_PIX_FMT_XRGB444 :
@@ -1182,8 +1182,8 @@ static void gen_twopix(struct tpg_data *tpg,/* fall through */ case V4L2_PIX_FMT_YUV444 :case V4L2_PIX_FMT_ARGB444 : - buf[0 ][offset] = (g_u <<4 ) | b_v; - buf[0 ][offset +1 ] = (alpha &0xf0 ) | r_y; + buf[0 ][offset] = (g_u_s <<4 ) | b_v; + buf[0 ][offset +1 ] = (alpha &0xf0 ) | r_y_h;break ;case V4L2_PIX_FMT_RGB555 :case V4L2_PIX_FMT_XRGB555 :
@@ -1191,32 +1191,33 @@ static void gen_twopix(struct tpg_data *tpg,/* fall through */ case V4L2_PIX_FMT_YUV555 :case V4L2_PIX_FMT_ARGB555 : - buf[0 ][offset] = (g_u <<5 ) | b_v; - buf[0 ][offset +1 ] = (alpha &0x80 ) | (r_y <<2 ) | (g_u >>3 ); + buf[0 ][offset] = (g_u_s <<5 ) | b_v; + buf[0 ][offset +1 ] = (alpha &0x80 ) | (r_y_h <<2 ) + | (g_u_s >>3 );break ;case V4L2_PIX_FMT_RGB555X :case V4L2_PIX_FMT_XRGB555X : alpha =0 ;/* fall through */ case V4L2_PIX_FMT_ARGB555X : - buf[0 ][offset] = (alpha &0x80 ) | (r_y <<2 ) | (g_u >>3 ); - buf[0 ][offset +1 ] = (g_u <<5 ) | b_v; + buf[0 ][offset] = (alpha &0x80 ) | (r_y_h <<2 ) | (g_u_s >>3 ); + buf[0 ][offset +1 ] = (g_u_s <<5 ) | b_v;break ;case V4L2_PIX_FMT_RGB24 :case V4L2_PIX_FMT_HSV24 : - buf[0 ][offset] = r_y; - buf[0 ][offset +1 ] = g_u; + buf[0 ][offset] = r_y_h; + buf[0 ][offset +1 ] = g_u_s; buf[0 ][offset +2 ] = b_v;break ;case V4L2_PIX_FMT_BGR24 : buf[0 ][offset] = b_v; - buf[0 ][offset +1 ] = g_u; - buf[0 ][offset +2 ] = r_y; + buf[0 ][offset +1 ] = g_u_s; + buf[0 ][offset +2 ] = r_y_h;break ;case V4L2_PIX_FMT_BGR666 : - buf[0 ][offset] = (b_v <<2 ) | (g_u >>4 ); - buf[0 ][offset +1 ] = (g_u <<4 ) | (r_y >>2 ); - buf[0 ][offset +2 ] = r_y <<6 ; + buf[0 ][offset] = (b_v <<2 ) | (g_u_s >>4 ); + buf[0 ][offset +1 ] = (g_u_s <<4 ) | (r_y_h >>2 ); + buf[0 ][offset +2 ] = r_y_h <<6 ; buf[0 ][offset +3 ] =0 ;break ;case V4L2_PIX_FMT_RGB32 :
@@ -1227,8 +1228,8 @@ static void gen_twopix(struct tpg_data *tpg,case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ARGB32 : buf[0 ][offset] = alpha; - buf[0 ][offset +1 ] = r_y; - buf[0 ][offset +2 ] = g_u; + buf[0 ][offset +1 ] = r_y_h; + buf[0 ][offset +2 ] = g_u_s; buf[0 ][offset +3 ] = b_v;break ;case V4L2_PIX_FMT_BGR32 :
@@ -1237,87 +1238,87 @@ static void gen_twopix(struct tpg_data *tpg,/* fall through */ case V4L2_PIX_FMT_ABGR32 : buf[0 ][offset] = b_v; - buf[0 ][offset +1 ] = g_u; - buf[0 ][offset +2 ] = r_y; + buf[0 ][offset +1 ] = g_u_s; + buf[0 ][offset +2 ] = r_y_h; buf[0 ][offset +3 ] = alpha;break ;case V4L2_PIX_FMT_SBGGR8 : - buf[0 ][offset] = odd ? g_u : b_v; - buf[1 ][offset] = odd ? r_y : g_u; + buf[0 ][offset] = odd ? g_u_s : b_v; + buf[1 ][offset] = odd ? r_y_h : g_u_s;break ;case V4L2_PIX_FMT_SGBRG8 : - buf[0 ][offset] = odd ? b_v : g_u; - buf[1 ][offset] = odd ? g_u : r_y; + buf[0 ][offset] = odd ? b_v : g_u_s; + buf[1 ][offset] = odd ? g_u_s : r_y_h;break ;case V4L2_PIX_FMT_SGRBG8 : - buf[0 ][offset] = odd ? r_y : g_u; - buf[1 ][offset] = odd ? g_u : b_v; + buf[0 ][offset] = odd ? r_y_h : g_u_s; + buf[1 ][offset] = odd ? g_u_s : b_v;break ;case V4L2_PIX_FMT_SRGGB8 : - buf[0 ][offset] = odd ? g_u : r_y; - buf[1 ][offset] = odd ? b_v : g_u; + buf[0 ][offset] = odd ? g_u_s : r_y_h; + buf[1 ][offset] = odd ? b_v : g_u_s;break ;case V4L2_PIX_FMT_SBGGR10 : - buf[0 ][offset] = odd ? g_u <<2 : b_v <<2 ; - buf[0 ][offset +1 ] = odd ? g_u >>6 : b_v >>6 ; - buf[1 ][offset] = odd ? r_y <<2 : g_u <<2 ; - buf[1 ][offset +1 ] = odd ? r_y >>6 : g_u >>6 ; + buf[0 ][offset] = odd ? g_u_s <<2 : b_v <<2 ; + buf[0 ][offset +1 ] = odd ? g_u_s >>6 : b_v >>6 ; + buf[1 ][offset] = odd ? r_y_h <<2 : g_u_s <<2 ; + buf[1 ][offset +1 ] = odd ? r_y_h >>6 : g_u_s >>6 ; buf[0 ][offset] |= (buf[0 ][offset] >>2 ) &3 ; buf[1 ][offset] |= (buf[1 ][offset] >>2 ) &3 ;break ;case V4L2_PIX_FMT_SGBRG10 : - buf[0 ][offset] = odd ? b_v <<2 : g_u <<2 ; - buf[0 ][offset +1 ] = odd ? b_v >>6 : g_u >>6 ; - buf[1 ][offset] = odd ? g_u <<2 : r_y <<2 ; - buf[1 ][offset +1 ] = odd ? g_u >>6 : r_y >>6 ; + buf[0 ][offset] = odd ? b_v <<2 : g_u_s <<2 ; + buf[0 ][offset +1 ] = odd ? b_v >>6 : g_u_s >>6 ; + buf[1 ][offset] = odd ? g_u_s <<2 : r_y_h <<2 ; + buf[1 ][offset +1 ] = odd ? g_u_s >>6 : r_y_h >>6 ; buf[0 ][offset] |= (buf[0 ][offset] >>2 ) &3 ; buf[1 ][offset] |= (buf[1 ][offset] >>2 ) &3 ;break ;case V4L2_PIX_FMT_SGRBG10 : - buf[0 ][offset] = odd ? r_y <<2 : g_u <<2 ; - buf[0 ][offset +1 ] = odd ? r_y >>6 : g_u >>6 ; - buf[1 ][offset] = odd ? g_u <<2 : b_v <<2 ; - buf[1 ][offset +1 ] = odd ? g_u >>6 : b_v >>6 ; + buf[0 ][offset] = odd ? r_y_h <<2 : g_u_s <<2 ; + buf[0 ][offset +1 ] = odd ? r_y_h >>6 : g_u_s >>6 ; + buf[1 ][offset] = odd ? g_u_s <<2 : b_v <<2 ; + buf[1 ][offset +1 ] = odd ? g_u_s >>6 : b_v >>6 ; buf[0 ][offset] |= (buf[0 ][offset] >>2 ) &3 ; buf[1 ][offset] |= (buf[1 ][offset] >>2 ) &3 ;break ;case V4L2_PIX_FMT_SRGGB10 : - buf[0 ][offset] = odd ? g_u <<2 : r_y <<2 ; - buf[0 ][offset +1 ] = odd ? g_u >>6 : r_y >>6 ; - buf[1 ][offset] = odd ? b_v <<2 : g_u <<2 ; - buf[1 ][offset +1 ] = odd ? b_v >>6 : g_u >>6 ; + buf[0 ][offset] = odd ? g_u_s <<2 : r_y_h <<2 ; + buf[0 ][offset +1 ] = odd ? g_u_s >>6 : r_y_h >>6 ; + buf[1 ][offset] = odd ? b_v <<2 : g_u_s <<2 ; + buf[1 ][offset +1 ] = odd ? b_v >>6 : g_u_s >>6 ; buf[0 ][offset] |= (buf[0 ][offset] >>2 ) &3 ; buf[1 ][offset] |= (buf[1 ][offset] >>2 ) &3 ;break ;case V4L2_PIX_FMT_SBGGR12 : - buf[0 ][offset] = odd ? g_u <<4 : b_v <<4 ; - buf[0 ][offset +1 ] = odd ? g_u >>4 : b_v >>4 ; - buf[1 ][offset] = odd ? r_y <<4 : g_u <<4 ; - buf[1 ][offset +1 ] = odd ? r_y >>4 : g_u >>4 ; + buf[0 ][offset] = odd ? g_u_s <<4 : b_v <<4 ; + buf[0 ][offset +1 ] = odd ? g_u_s >>4 : b_v >>4 ; + buf[1 ][offset] = odd ? r_y_h <<4 : g_u_s <<4 ; + buf[1 ][offset +1 ] = odd ? r_y_h >>4 : g_u_s >>4 ; buf[0 ][offset] |= (buf[0 ][offset] >>4 ) &0xf ; buf[1 ][offset] |= (buf[1 ][offset] >>4 ) &0xf ;break ;case V4L2_PIX_FMT_SGBRG12 : - buf[0 ][offset] = odd ? b_v <<4 : g_u <<4 ; - buf[0 ][offset +1 ] = odd ? b_v >>4 : g_u >>4 ; - buf[1 ][offset] = odd ? g_u <<4 : r_y <<4 ; - buf[1 ][offset +1 ] = odd ? g_u >>4 : r_y >>4 ; + buf[0 ][offset] = odd ? b_v <<4 : g_u_s <<4 ; + buf[0 ][offset +1 ] = odd ? b_v >>4 : g_u_s >>4 ; + buf[1 ][offset] = odd ? g_u_s <<4 : r_y_h <<4 ; + buf[1 ][offset +1 ] = odd ? g_u_s >>4 : r_y_h >>4 ; buf[0 ][offset] |= (buf[0 ][offset] >>4 ) &0xf ; buf[1 ][offset] |= (buf[1 ][offset] >>4 ) &0xf ;break ;case V4L2_PIX_FMT_SGRBG12 : - buf[0 ][offset] = odd ? r_y <<4 : g_u <<4 ; - buf[0 ][offset +1 ] = odd ? r_y >>4 : g_u >>4 ; - buf[1 ][offset] = odd ? g_u <<4 : b_v <<4 ; - buf[1 ][offset +1 ] = odd ? g_u >>4 : b_v >>4 ; + buf[0 ][offset] = odd ? r_y_h <<4 : g_u_s <<4 ; + buf[0 ][offset +1 ] = odd ? r_y_h >>4 : g_u_s >>4 ; + buf[1 ][offset] = odd ? g_u_s <<4 : b_v <<4 ; + buf[1 ][offset +1 ] = odd ? g_u_s >>4 : b_v >>4 ; buf[0 ][offset] |= (buf[0 ][offset] >>4 ) &0xf ; buf[1 ][offset] |= (buf[1 ][offset] >>4 ) &0xf ;break ;case V4L2_PIX_FMT_SRGGB12 : - buf[0 ][offset] = odd ? g_u <<4 : r_y <<4 ; - buf[0 ][offset +1 ] = odd ? g_u >>4 : r_y >>4 ; - buf[1 ][offset] = odd ? b_v <<4 : g_u <<4 ; - buf[1 ][offset +1 ] = odd ? b_v >>4 : g_u >>4 ; + buf[0 ][offset] = odd ? g_u_s <<4 : r_y_h <<4 ; + buf[0 ][offset +1 ] = odd ? g_u_s >>4 : r_y_h >>4 ; + buf[1 ][offset] = odd ? b_v <<4 : g_u_s <<4 ; + buf[1 ][offset +1 ] = odd ? b_v >>4 : g_u_s >>4 ; buf[0 ][offset] |= (buf[0 ][offset] >>4 ) &0xf ; buf[1 ][offset] |= (buf[1 ][offset] >>4 ) &0xf ;break ;
Signature · 1 line
2.8.1