-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Video: addition of more Bayer / RGB / YUV PIX formats #88817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For convenience, links to the Linux doc for these formats:
- https://docs.kernel.org/userspace-api/media/v4l/pixfmt-srggb10.html
- https://docs.kernel.org/userspace-api/media/v4l/pixfmt-srggb12.html
- https://docs.kernel.org/userspace-api/media/v4l/pixfmt-srggb14.html
- https://docs.kernel.org/userspace-api/media/v4l/pixfmt-srggb16.html
- https://docs.kernel.org/userspace-api/media/v4l/pixfmt-rgb.html#bits-per-component
- https://docs.kernel.org/userspace-api/media/v4l/yuv-formats.html
I have some doubts regarding the bit packing, but all the FOURCC match AFAICT.
FourCC's have so many exception everywhere ("BYR2"?, "BA12"?)!
I hope this notation format is not a burden to maintain... It seems useful support to disambiguate subtle nuances.
Thank you for this documentation effort, much more correct than my own PR. :)
include/zephyr/drivers/video.h
Outdated
* | Bbbbbbbb | bb000000 | Gggggggg | gg000000 | Bbbbbbbb | bb000000 | ... | ||
* | Gggggggg | gg000000 | Rrrrrrrr | rr000000 | Gggggggg | gg000000 | ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not important, but if wanting to give stronger visual cue of where the pixels channels start and end, it is possible to write it like that:
* | Bbbbbbbb | bb000000 | Gggggggg | gg000000 | Bbbbbbbb | bb000000 | ... | |
* | Gggggggg | gg000000 | Rrrrrrrr | rr000000 | Gggggggg | gg000000 | ... | |
* | Bbbbbbbb bb000000 | Gggggggg gg000000 | Bbbbbbbb bb000000 | ... | |
* | Gggggggg gg000000 | Rrrrrrrr rr000000 | Gggggggg gg000000 | ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a doubt about this matching the Linux side:
Each sample is stored in a 16-bit word, with 6 unused high bits filled with zeros
Following this, maybe this would be like this?
* | Bbbbbbbb | bb000000 | Gggggggg | gg000000 | Bbbbbbbb | bb000000 | ... | |
* | Gggggggg | gg000000 | Rrrrrrrr | rr000000 | Gggggggg | gg000000 | ... | |
* | gggggggg 000000Gg | bbbbbbbb 000000Bb | gggggggg 000000Gg | ... | |
* | rrrrrrrr 000000Rr | gggggggg 000000Gg | rrrrrrrr 000000Rr | ... |
This would make the values go in the range [0 ~ UINT10_MAX]
instead of [0 ~ UINT16_MAX]
, and packed in little-endian.
I like the format you described though as then 10/12/14/16-bits have the same range and all data processing is the same for every bit depth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor, non-blocking nit: There is an opportunity to describe all bayer formats as "how do you pack 2 rows of 4 pixels each" (like the packed ones). This makes comparing the packed and non-packed formats easier:
* | Bbbbbbbb | bb000000 | Gggggggg | gg000000 | Bbbbbbbb | bb000000 | ... | |
* | Gggggggg | gg000000 | Rrrrrrrr | rr000000 | Gggggggg | gg000000 | ... | |
* | gggggggg 000000Gg | bbbbbbbb 000000Bb | gggggggg 000000Gg | bbbbbbbb 000000Bb | ... | |
* | rrrrrrrr 000000Rr | gggggggg 000000Gg | rrrrrrrr 000000Rr | gggggggg 000000Gg | ... |
This still fits in Zephyr's 100 character per line.
* @endcode | ||
*/ | ||
#define VIDEO_PIX_FMT_RGGB16 VIDEO_FOURCC('R', 'G', '1', '6') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a converted version applying all the suggestions above, in hope this helps.
/**
* @code{.unparsed}
* | bbbbbbbb 000000Bb | gggggggg 000000Gg | bbbbbbbb 000000Bb | gggggggg 000000Gg | ...
* | gggggggg 000000Gg | rrrrrrrr 000000Rr | gggggggg 000000Gg | rrrrrrrr 000000Rr | ...
* @endcode
*/
#define VIDEO_PIX_FMT_BGGR10 VIDEO_FOURCC('B', 'G', '1', '0')
/**
* @code{.unparsed}
* | gggggggg 000000Gg | bbbbbbbb 000000Bb | gggggggg 000000Gg | bbbbbbbb 000000Bb | ...
* | rrrrrrrr 000000Rr | gggggggg 000000Gg | rrrrrrrr 000000Rr | gggggggg 000000Gg | ...
* @endcode
*/
#define VIDEO_PIX_FMT_GBRG10 VIDEO_FOURCC('G', 'B', '1', '0')
/**
* @code{.unparsed}
* | gggggggg 000000Gg | rrrrrrrr 000000Rr | gggggggg 000000Gg | rrrrrrrr 000000Rr | ...
* | bbbbbbbb 000000Bb | gggggggg 000000Gg | bbbbbbbb 000000Bb | gggggggg 000000Gg | ...
* @endcode
*/
#define VIDEO_PIX_FMT_GRBG10 VIDEO_FOURCC('B', 'A', '1', '0')
/**
* @code{.unparsed}
* | rrrrrrrr 000000Rr | gggggggg 000000Gg | rrrrrrrr 000000Rr | gggggggg 000000Gg | ...
* | gggggggg 000000Gg | bbbbbbbb 000000Bb | gggggggg 000000Gg | bbbbbbbb 000000Bb | ...
* @endcode
*/
#define VIDEO_PIX_FMT_RGGB10 VIDEO_FOURCC('R', 'G', '1', '0')
/**
* @code{.unparsed}
* | bbbbbbbb 0000Bbbb | gggggggg 0000Gggg | bbbbbbbb 0000Bbbb | gggggggg 0000Gggg | ...
* | gggggggg 0000Gggg | rrrrrrrr 0000Rrrr | gggggggg 0000Gggg | rrrrrrrr 0000Rrrr | ...
* @endcode
*/
#define VIDEO_PIX_FMT_BGGR12 VIDEO_FOURCC('B', 'G', '1', '2')
/**
* @code{.unparsed}
* | gggggggg 0000Gggg | bbbbbbbb 0000Bbbb | gggggggg 0000Gggg | bbbbbbbb 0000Bbbb | ...
* | rrrrrrrr 0000Rrrr | gggggggg 0000Gggg | rrrrrrrr 0000Rrrr | gggggggg 0000Gggg | ...
* @endcode
*/
#define VIDEO_PIX_FMT_GBRG12 VIDEO_FOURCC('G', 'B', '1', '2')
/**
* @code{.unparsed}
* | gggggggg 0000Gggg | rrrrrrrr 0000Rrrr | gggggggg 0000Gggg | rrrrrrrr 0000Rrrr | ...
* | bbbbbbbb 0000Bbbb | gggggggg 0000Gggg | bbbbbbbb 0000Bbbb | gggggggg 0000Gggg | ...
* @endcode
*/
#define VIDEO_PIX_FMT_GRBG12 VIDEO_FOURCC('B', 'A', '1', '2')
/**
* @code{.unparsed}
* | rrrrrrrr 0000Rrrr | gggggggg 0000Gggg | rrrrrrrr 0000Rrrr | gggggggg 0000Gggg | ...
* | gggggggg 0000Gggg | bbbbbbbb 0000Bbbb | gggggggg 0000Gggg | bbbbbbbb 0000Bbbb | ...
* @endcode
*/
#define VIDEO_PIX_FMT_RGGB12 VIDEO_FOURCC('R', 'G', '1', '2')
/**
* @code{.unparsed}
* | bbbbbbbb 00Bbbbbb | gggggggg 00Gggggg | bbbbbbbb 00Bbbbbb | gggggggg 00Gggggg | ...
* | gggggggg 00Gggggg | rrrrrrrr 00Rrrrrr | gggggggg 00Gggggg | rrrrrrrr 00Rrrrrr | ...
* @endcode
*/
#define VIDEO_PIX_FMT_BGGR14 VIDEO_FOURCC('B', 'G', '1', '4')
/**
* @code{.unparsed}
* | gggggggg 00Gggggg | bbbbbbbb 00Bbbbbb | gggggggg 00Gggggg | bbbbbbbb 00Bbbbbb | ...
* | rrrrrrrr 00Rrrrrr | gggggggg 00Gggggg | rrrrrrrr 00Rrrrrr | gggggggg 00Gggggg | ...
* @endcode
*/
#define VIDEO_PIX_FMT_GBRG14 VIDEO_FOURCC('G', 'B', '1', '4')
/**
* @code{.unparsed}
* | gggggggg 00Gggggg | rrrrrrrr 00Rrrrrr | gggggggg 00Gggggg | rrrrrrrr 00Rrrrrr | ...
* | bbbbbbbb 00Bbbbbb | gggggggg 00Gggggg | bbbbbbbb 00Bbbbbb | gggggggg 00Gggggg | ...
* @endcode
*/
#define VIDEO_PIX_FMT_GRBG14 VIDEO_FOURCC('G', 'R', '1', '4')
/**
* @code{.unparsed}
* | rrrrrrrr 00Rrrrrr | gggggggg 00Gggggg | rrrrrrrr 00Rrrrrr | gggggggg 00Gggggg | ...
* | gggggggg 00Gggggg | bbbbbbbb 00Bbbbbb | gggggggg 00Gggggg | bbbbbbbb 00Bbbbbb | ...
* @endcode
*/
#define VIDEO_PIX_FMT_RGGB14 VIDEO_FOURCC('R', 'G', '1', '4')
/**
* @code{.unparsed}
* | bbbbbbbb Bbbbbbbb | gggggggg Gggggggg | bbbbbbbb Bbbbbbbb | gggggggg Gggggggg | ...
* | gggggggg Gggggggg | rrrrrrrr Rrrrrrrr | gggggggg Gggggggg | rrrrrrrr Rrrrrrrr | ...
* @endcode
*/
#define VIDEO_PIX_FMT_BGGR16 VIDEO_FOURCC('B', 'Y', 'R', '2')
/**
* @code{.unparsed}
* | gggggggg Gggggggg | bbbbbbbb Bbbbbbbb | gggggggg Gggggggg | bbbbbbbb Bbbbbbbb | ...
* | rrrrrrrr Rrrrrrrr | gggggggg Gggggggg | rrrrrrrr Rrrrrrrr | gggggggg Gggggggg | ...
* @endcode
*/
#define VIDEO_PIX_FMT_GBRG16 VIDEO_FOURCC('G', 'B', '1', '6')
/**
* @code{.unparsed}
* | gggggggg Gggggggg | rrrrrrrr Rrrrrrrr | gggggggg Gggggggg | rrrrrrrr Rrrrrrrr | ...
* | bbbbbbbb Bbbbbbbb | gggggggg Gggggggg | bbbbbbbb Bbbbbbbb | gggggggg Gggggggg | ...
* @endcode
*/
#define VIDEO_PIX_FMT_GRBG16 VIDEO_FOURCC('G', 'R', '1', '6')
/**
* @code{.unparsed}
* | rrrrrrrr Rrrrrrrr | gggggggg Gggggggg | rrrrrrrr Rrrrrrrr | gggggggg Gggggggg | ...
* | gggggggg Gggggggg | bbbbbbbb Bbbbbbbb | gggggggg Gggggggg | bbbbbbbb Bbbbbbbb | ...
* @endcode
*/
#define VIDEO_PIX_FMT_RGGB16 VIDEO_FOURCC('R', 'G', '1', '6')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for the update. I agree. I noticed an issue in the original commit, I wrote the format in FMT_RGGBXX while it should have been FMT_SRGGBxx (I forgot the leading S). I will add it in the update, in addition with the description you propose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Add all 4 variants of 10 / 12 / 14 and 16 bits unpacked bayer formats Signed-off-by: Alain Volmat <[email protected]>
Add several more RGB formats: (RGB24/BGR24,ARGB32,ABGR32,RGBA32,BGRA32) as well as more YUV formats: YVYU, VYVU, UYVY Signed-off-by: Alain Volmat <[email protected]>
9a804f4
to
5be89f6
Compare
In preparation of the DCMIPP pull-request, add some more formats that can be output such as unpacked bayer formats or RGB24 / 32 formats as well as more 16bit YUV variants.