Adding NV{12,21} and Y{U,V}12 pixel formats support.
PATCH v2 1/1 Adding NV{12,21} and Y{U,V}12 pixel formats support.
This is the second attempt at creating a patch doing that while respecting the pattern movements, crops, and other artifacts that can be added to the generated frames.
Hope it addresses Hans' comments on the first patch. It should create properly moving patterns, border, square and noise. SAV/EAV are left out for the new formats, but can be pulled in if deemed interesting/ necessary. New formats' descriptions are shorter. Needless to say, previous formats should work 100% the same as before.
Text is, still, printed as Y only. I think the goal of the text is not pixel-value-based comparisons, but human reading. Please let me know otherwise.
It needed quite some refactoring of the original tpg_fillbuffer() function:
- the internal code generating the video buffer line-by-line are factored out into a function tpg_fill_oneline(). const added wherever it made sense.
- this new tpg_fill_oneline() is used by both new functions tpg_fillbuffer_packed() and tpg_fillbuffer_planar().
- tpg_fillbuffer_packed() does the non-planar formats' buffer composition, so it does, or should do, pretty much the same as vivid did before this patch.
Tested via both guvcview and qv4l2, checking formats, patterns, pattern movements, box and frame checkboxes.
Hope I managed to get the patch correctly into the mail i.e. no spurious wraparounds, no whitespaces etc :)
--- drivers/media/platform/vivid/vivid-kthread-cap.c | 6 +- drivers/media/platform/vivid/vivid-tpg.c | 481 ++++++++++++++++------- drivers/media/platform/vivid/vivid-tpg.h | 24 +- drivers/media/platform/vivid/vivid-vid-common.c | 28 ++ 4 files changed, 383 insertions(+), 156 deletions(-)
drivers/media/platform/vivid/vivid-kthread-cap.c +2 -4
@@ -669,8 +669,7 @@ static void vivid_thread_vid_cap_tick(struct vivid_dev *dev, int dropped_bufs)if (vid_cap_buf) {/* Fill buffer */ vivid_fillbuff (dev, vid_cap_buf); -dprintk (dev,1 ,"filled buffer %d\n" , - vid_cap_buf->vb.v4l2_buf.index); +dprintk (dev,1 ,"filled buffer %d\n" , vid_cap_buf->vb.v4l2_buf.index);/* Handle overlay */ if (dev->overlay_cap_owner && dev->fb_cap.base &&
@@ -679,8 +678,7 @@ static void vivid_thread_vid_cap_tick(struct vivid_dev *dev, int dropped_bufs)vb2_buffer_done (&vid_cap_buf->vb, dev->dqbuf_error ?VB2_BUF_STATE_ERROR :VB2_BUF_STATE_DONE ); -dprintk (dev,2 ,"vid_cap buffer %d done\n" , - vid_cap_buf->vb.v4l2_buf.index); +dprintk (dev,2 ,"vid_cap buffer %d done\n" , vid_cap_buf->vb.v4l2_buf.index); }if (vbi_cap_buf) {
drivers/media/platform/vivid/vivid-tpg.c +338 -146
679 lines not on this page · raw message
drivers/media/platform/vivid/vivid-tpg.h +18 -6
@@ -141,6 +141,15 @@ struct tpg_data {/* size in bytes for two pixels in each plane */ unsigned twopixelsize[TPG_MAX_PLANES ];unsigned bytesperline[TPG_MAX_PLANES ]; +/* +* Vertical and horizontal downsample factors. Only applies to YUV formats, +* concretely Chroma components (not the Luma), and implies that the format +* is planar (2 or 3 planes). Only even numbers are allowed. Typical values +* include 0 for no downsampling and 2 (like in 4:2:0 formats, e.g. YUV420). +*/ +unsigned vertical_downsampling; +unsigned horizontal_downsampling; +u8 *scratchpad_line;/* Configuration */ enum tpg_pattern pattern;
@@ -165,7 +174,10 @@ struct tpg_data {bool recalc_lines;bool recalc_square_border; -/* Used to store TPG_MAX_PAT_LINES lines, each with up to two planes */ +/* +* Used to store TPG_MAX_PAT_LINES lines, each with up to TPG_MAX_PLANES +* planes +*/ unsigned max_line_width;u8 *lines[TPG_MAX_PAT_LINES ][TPG_MAX_PLANES ];u8 *random_line[TPG_MAX_PLANES ];
@@ -176,18 +188,18 @@ struct tpg_data {void tpg_init (struct tpg_data *tpg,unsigned w,unsigned h);int tpg_alloc (struct tpg_data *tpg,unsigned max_w);void tpg_free (struct tpg_data *tpg); +bool tpg_s_fourcc (struct tpg_data *tpg,u32 fourcc); +void tpg_s_crop_compose (struct tpg_data *tpg,const struct v4l2_rect *crop, +const struct v4l2_rect *compose);void tpg_reset_source (struct tpg_data *tpg,unsigned width,unsigned height,u32 field); -void tpg_set_font (const u8 *f);void tpg_gen_text (struct tpg_data *tpg,u8 *basep[TPG_MAX_PLANES ][2 ],int y,int x,char *text);void tpg_calc_text_basep (struct tpg_data *tpg,u8 *basep[TPG_MAX_PLANES ][2 ],unsigned p,u8 *vbuf); -void tpg_fillbuffer (struct tpg_data *tpg,v4l2_std_id std,unsigned p,u8 *vbuf); -bool tpg_s_fourcc (struct tpg_data *tpg,u32 fourcc); -void tpg_s_crop_compose (struct tpg_data *tpg,const struct v4l2_rect *crop, -const struct v4l2_rect *compose); +void tpg_fillbuffer (struct tpg_data *tpg,const v4l2_std_id std, +const unsigned p,u8 *vbuf);static inline void tpg_s_pattern (struct tpg_data *tpg,enum tpg_pattern pattern) {
drivers/media/platform/vivid/vivid-vid-common.c +28 -0
@@ -73,7 +73,34 @@ struct vivid_fmt vivid_formats[] = { .planes = 1, }, { + .name = "YUV 4:2:0 biplanar.", + .fourcc = V4L2_PIX_FMT_NV12, + .depth = 12, + .is_yuv = true, + .planes = 1, + }, + { + .name = "YVU 4:2:0 biplanar.", + .fourcc = V4L2_PIX_FMT_NV21, + .depth = 12, + .is_yuv = true, + .planes = 1, + }, + { + .name = "YUV 4:2:0 triplanar", + .fourcc = V4L2_PIX_FMT_YUV420, + .depth = 12, + .is_yuv = true, + .planes = 1, + }, + { + .name = "YVU 4:2:0 triplanar", + .fourcc = V4L2_PIX_FMT_YVU420, + .depth = 12, + .is_yuv = true, + .planes = 1, + }, + { .name = "RGB565 (LE)", .fourcc = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */ .depth = 16,
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Hi Miguel,
Thanks for the patch. However, after reviewing it and testing it I decided to implement my own version. Partially because several features were still failing (crop/compose/scale), partially because I didn't like the way the tpg was changed: too much change basically.
Yesterday I added YUV 420 support. It's still work in progress as I am not happy with some of the internal changes and because changing the compose height fails to work at the moment.
You can find my preliminary work here:
http://git.linuxtv.org/cgit.cgi/hverkuil/media_tree.git/log/?h=vivid-420
I plan to continue work on this on Friday and Monday, fixing any remaining bugs, adding support for the other planar formats and carefully reviewing if I handle the downsampling correctly. I also want to add output support for these formats.
Regards,
Hans
Quoted 39 lines · Miguel Casas-Sanchez
This is the second attempt at creating a patch doing that while respecting the pattern movements, crops, and other artifacts that can be added to the generated frames.
Hope it addresses Hans' comments on the first patch. It should create properly moving patterns, border, square and noise. SAV/EAV are left out for the new formats, but can be pulled in if deemed interesting/ necessary. New formats' descriptions are shorter. Needless to say, previous formats should work 100% the same as before.
Text is, still, printed as Y only. I think the goal of the text is not pixel-value-based comparisons, but human reading. Please let me know otherwise.
It needed quite some refactoring of the original
tpg_fillbuffer()function:
- the internal code generating the video buffer line-by-line are factored out into a functiontpg_fill_oneline(). const added wherever it made sense.
- this newtpg_fill_oneline()is used by both new functionstpg_fillbuffer_packed()andtpg_fillbuffer_planar().
-tpg_fillbuffer_packed()does the non-planar formats' buffer composition, so it does, or should do, pretty much the same as vivid did before this patch.Tested via both guvcview and qv4l2, checking formats, patterns, pattern movements, box and frame checkboxes.
Hope I managed to get the patch correctly into the mail i.e. no spurious wraparounds, no whitespaces etc :)
Signed-off-by Miguel Casas-Sanchez <[email protected]>
Hi Hans,
go for it if you feel it's the best approach. Are you planning to add multiplanar formats? Particularly, I'm interested in YUV420M and its twin evil brother YVU420M.
I would recommend adding support for a less-common format such as YUV410 (or variation thereof). Since this format is so different, it stresses the added code in revealing ways. I was planning to support it as a bonus, but I noticed is not recognised in lib4vl -- neither in qv4l2, therefore. Just saying, it'd be cool.
Cheers
M
Quoted 66 lines · Hans Verkuil
Hi Miguel,
Thanks for the patch. However, after reviewing it and testing it I decided to implement my own version. Partially because several features were still failing (crop/compose/scale), partially because I didn't like the way the tpg was changed: too much change basically.
Yesterday I added YUV 420 support. It's still work in progress as I am not happy with some of the internal changes and because changing the compose height fails to work at the moment.
You can find my preliminary work here:
http://git.linuxtv.org/cgit.cgi/hverkuil/media_tree.git/log/?h=vivid-420
I plan to continue work on this on Friday and Monday, fixing any remaining bugs, adding support for the other planar formats and carefully reviewing if I handle the downsampling correctly. I also want to add output support for these formats.
Regards,
Hans
Quoted 39 lines · Miguel Casas-Sanchez
This is the second attempt at creating a patch doing that while respecting the pattern movements, crops, and other artifacts that can be added to the generated frames.
Hope it addresses Hans' comments on the first patch. It should create properly moving patterns, border, square and noise. SAV/EAV are left out for the new formats, but can be pulled in if deemed interesting/ necessary. New formats' descriptions are shorter. Needless to say, previous formats should work 100% the same as before.
Text is, still, printed as Y only. I think the goal of the text is not pixel-value-based comparisons, but human reading. Please let me know otherwise.
It needed quite some refactoring of the original
tpg_fillbuffer()function:
- the internal code generating the video buffer line-by-line are factored out into a functiontpg_fill_oneline(). const added wherever it made sense.
- this newtpg_fill_oneline()is used by both new functionstpg_fillbuffer_packed()andtpg_fillbuffer_planar().
-tpg_fillbuffer_packed()does the non-planar formats' buffer composition, so it does, or should do, pretty much the same as vivid did before this patch.Tested via both guvcview and qv4l2, checking formats, patterns, pattern movements, box and frame checkboxes.
Hope I managed to get the patch correctly into the mail i.e. no spurious wraparounds, no whitespaces etc :)
Signed-off-by Miguel Casas-Sanchez <[email protected]>
Quoted 5 lines · Miguel Casas-Sanchez
Hi Hans,
go for it if you feel it's the best approach. Are you planning to add multiplanar formats? Particularly, I'm interested in YUV420M and its twin evil brother YVU420M.
Certainly. I'm planning to add all those YUV420 variants. Once you have one working, the others are trivial.
Quoted 5 lines
I would recommend adding support for a less-common format such as YUV410 (or variation thereof). Since this format is so different, it stresses the added code in revealing ways. I was planning to support it as a bonus, but I noticed is not recognised in lib4vl -- neither in qv4l2, therefore. Just saying, it'd be cool.
I'll look at it. Is it something you will need? It's a really rare format, and I don't know if I want to spend a lot of time on it.
Regards,
Hans
Quoted 71 lines
Cheers
MQuoted 66 lines · Hans Verkuil
Hi Miguel,
Thanks for the patch. However, after reviewing it and testing it I decided to implement my own version. Partially because several features were still failing (crop/compose/scale), partially because I didn't like the way the tpg was changed: too much change basically.
Yesterday I added YUV 420 support. It's still work in progress as I am not happy with some of the internal changes and because changing the compose height fails to work at the moment.
You can find my preliminary work here:
http://git.linuxtv.org/cgit.cgi/hverkuil/media_tree.git/log/?h=vivid-420
I plan to continue work on this on Friday and Monday, fixing any remaining bugs, adding support for the other planar formats and carefully reviewing if I handle the downsampling correctly. I also want to add output support for these formats.
Regards,
Hans
Quoted 39 lines · Miguel Casas-Sanchez
This is the second attempt at creating a patch doing that while respecting the pattern movements, crops, and other artifacts that can be added to the generated frames.
Hope it addresses Hans' comments on the first patch. It should create properly moving patterns, border, square and noise. SAV/EAV are left out for the new formats, but can be pulled in if deemed interesting/ necessary. New formats' descriptions are shorter. Needless to say, previous formats should work 100% the same as before.
Text is, still, printed as Y only. I think the goal of the text is not pixel-value-based comparisons, but human reading. Please let me know otherwise.
It needed quite some refactoring of the original
tpg_fillbuffer()function:
- the internal code generating the video buffer line-by-line are factored out into a functiontpg_fill_oneline(). const added wherever it made sense.
- this newtpg_fill_oneline()is used by both new functionstpg_fillbuffer_packed()andtpg_fillbuffer_planar().
-tpg_fillbuffer_packed()does the non-planar formats' buffer composition, so it does, or should do, pretty much the same as vivid did before this patch.Tested via both guvcview and qv4l2, checking formats, patterns, pattern movements, box and frame checkboxes.
Hope I managed to get the patch correctly into the mail i.e. no spurious wraparounds, no whitespaces etc :)
Signed-off-by Miguel Casas-Sanchez <[email protected]>
Quoted 9 lines · Hans Verkuil
Quoted 5 lines · Miguel Casas-Sanchez
Hi Hans,
go for it if you feel it's the best approach. Are you planning to add multiplanar formats? Particularly, I'm interested in YUV420M and its twin evil brother YVU420M.
Certainly. I'm planning to add all those YUV420 variants. Once you have one working, the others are trivial.
Hooray!
Quoted 10 lines
Quoted 6 lines
I would recommend adding support for a less-common format such as YUV410 (or variation thereof). Since this format is so different, it stresses the added code in revealing ways. I was planning to support it as a bonus, but I noticed is not recognised in lib4vl -- neither in qv4l2, therefore. Just saying, it'd be cool.
I'll look at it. Is it something you will need? It's a really rare format, and I don't know if I want to spend a lot of time on it.
Not particularly high need no; moreover the high downsampling makes it look visually awful. I just found it was good to stretch assumptions in the code such as missed hardcoded loop boundaries etc. It'd be a nice-to-have. Like I said, it also depends on adding support for it in libv4l (typo before).
Quoted 76 lines
Regards,
Hans
Quoted 71 lines
Cheers
MQuoted 66 lines · Hans Verkuil
Hi Miguel,
Thanks for the patch. However, after reviewing it and testing it I decided to implement my own version. Partially because several features were still failing (crop/compose/scale), partially because I didn't like the way the tpg was changed: too much change basically.
Yesterday I added YUV 420 support. It's still work in progress as I am not happy with some of the internal changes and because changing the compose height fails to work at the moment.
You can find my preliminary work here:
http://git.linuxtv.org/cgit.cgi/hverkuil/media_tree.git/log/?h=vivid-420
I plan to continue work on this on Friday and Monday, fixing any remaining bugs, adding support for the other planar formats and carefully reviewing if I handle the downsampling correctly. I also want to add output support for these formats.
Regards,
Hans
Quoted 39 lines · Miguel Casas-Sanchez
This is the second attempt at creating a patch doing that while respecting the pattern movements, crops, and other artifacts that can be added to the generated frames.
Hope it addresses Hans' comments on the first patch. It should create properly moving patterns, border, square and noise. SAV/EAV are left out for the new formats, but can be pulled in if deemed interesting/ necessary. New formats' descriptions are shorter. Needless to say, previous formats should work 100% the same as before.
Text is, still, printed as Y only. I think the goal of the text is not pixel-value-based comparisons, but human reading. Please let me know otherwise.
It needed quite some refactoring of the original
tpg_fillbuffer()function:
- the internal code generating the video buffer line-by-line are factored out into a functiontpg_fill_oneline(). const added wherever it made sense.
- this newtpg_fill_oneline()is used by both new functionstpg_fillbuffer_packed()andtpg_fillbuffer_planar().
-tpg_fillbuffer_packed()does the non-planar formats' buffer composition, so it does, or should do, pretty much the same as vivid did before this patch.Tested via both guvcview and qv4l2, checking formats, patterns, pattern movements, box and frame checkboxes.
Hope I managed to get the patch correctly into the mail i.e. no spurious wraparounds, no whitespaces etc :)
Signed-off-by Miguel Casas-Sanchez <[email protected]>