videotestsrc: -I and +Q regions are wrong
@cap
Submitted by Julien Isorce Link to original bug (#787582)
Description
The pipeline gst-launch-1.0 videotestsrc ! ximagesink videotestsrc ! xvimagesink
does not output the same colors for some of the bottom left regions: Blue vs Purple. To be more precise the -I (in-phase) and +Q (quadrature) regions are wrong.
Same with:
gst-launch-1.0 videotestsrc ! "video/x-raw, format=BGRx" ! ximagesink videotestsrc ! "video/x-raw, format=NV12" ! videoconvert ! ximagesink
The issue comes from https://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/gst/videotestsrc/videotestsrc.c#n71 , the coeffs for yuv and rgb do not match for -I and +Q. I.e. on the +Q, YCbCr(16, 235, 198) is dark purple but RGB(0, 128, 255) is blue.
With git blame I found that -I and +Q regions in videotestsrc have been introduced by commit 768253dc (year 2002). The values for yuv and rgb mentioned above are like this since that commit.
Then the -I and +Q coeffs for bt601 have been copied from bt709 in commit b97e582c (year 2008).
According to http://avisynth.nl/index.php/ColorBars_theory, this should be:
--- a/gst/videotestsrc/videotestsrc.c
+++ b/gst/videotestsrc/videotestsrc.c
@@ -67,8 +67,8 @@ static const struct vts_color_struct vts_colors_bt709_ycbcr_100[] = {
{63, 102, 240, 255, 255, 0, 0, (64 << 8)},
{32, 240, 118, 255, 0, 0, 255, (32 << 8)},
{16, 128, 128, 255, 0, 0, 0, (16 << 8)},
- {16, 198, 21, 255, 0, 0, 128, (16 << 8)}, /* -I ? */
- {16, 235, 198, 255, 0, 128, 255, (16 << 8)}, /* +Q ? */
- {16, 157, 99, 255, 0, 54, 98, (16 << 8)}, /* -I ? */
- {16, 172, 146, 255, 75, 17, 126, (16 << 8)}, /* +Q ? */
{0, 128, 128, 255, 0, 0, 0, 0},
{32, 128, 128, 255, 19, 19, 19, (32 << 8)},
};
@@ -97,8 +97,8 @@ static const struct vts_color_struct vts_colors_bt601_ycbcr_100[] = {
{81, 90, 240, 255, 255, 0, 0, (64 << 8)},
{41, 240, 110, 255, 0, 0, 255, (32 << 8)},
{16, 128, 128, 255, 0, 0, 0, (16 << 8)},
- {16, 198, 21, 255, 0, 0, 128, (16 << 8)}, /* -I ? */
- {16, 235, 198, 255, 0, 128, 255, (16 << 8)}, /* +Q ? */
- {16, 158, 95, 255, 0, 58, 98, (16 << 8)}, /* -I ? */
- {16, 175, 148, 255, 75, 15, 126, (16 << 8)}, /* +Q ? */
{-0, 128, 128, 255, 0, 0, 0, 0},
{32, 128, 128, 255, 19, 19, 19, (32 << 8)},
};
but this does not make yuv and rgb outputs to look the same either.