mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
videoconvert: fix 0_255 handling
We also need to apply an offset to the Cb and Cr samples in the 0-255 case.
This commit is contained in:
parent
8f88f015f0
commit
93c3a74755
1 changed files with 56 additions and 7 deletions
|
@ -221,18 +221,38 @@ videoconvert_convert_compute_matrix (VideoConvert * convert)
|
|||
else
|
||||
use_16 = FALSE;
|
||||
|
||||
|
||||
color_matrix_set_identity (&dst);
|
||||
|
||||
/* 1, bring color components to [0..1.0] range */
|
||||
switch (in_info->colorimetry.range) {
|
||||
case GST_VIDEO_COLOR_RANGE_0_255:
|
||||
if (use_16)
|
||||
color_matrix_scale_components (&dst, (1 / 65535.0), (1 / 65535.0),
|
||||
(1 / 65535.0));
|
||||
else
|
||||
color_matrix_scale_components (&dst, (1 / 255.0), (1 / 255.0),
|
||||
(1 / 255.0));
|
||||
switch (in_info->finfo->unpack_format) {
|
||||
case GST_VIDEO_FORMAT_AYUV:
|
||||
case GST_VIDEO_FORMAT_AYUV64:
|
||||
GST_DEBUG ("using 0-255 input range YUV");
|
||||
if (use_16) {
|
||||
color_matrix_offset_components (&dst, 0, -32768, -32768);
|
||||
color_matrix_scale_components (&dst, (1 / 65535.0), (1 / 65535.0),
|
||||
(1 / 65535.0));
|
||||
} else {
|
||||
color_matrix_offset_components (&dst, 0, -128, -128);
|
||||
color_matrix_scale_components (&dst, (1 / 255.0), (1 / 255.0),
|
||||
(1 / 255.0));
|
||||
}
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_ARGB:
|
||||
case GST_VIDEO_FORMAT_ARGB64:
|
||||
GST_DEBUG ("using 0-255 input range RGB");
|
||||
if (use_16)
|
||||
color_matrix_scale_components (&dst, (1 / 65535.0), (1 / 65535.0),
|
||||
(1 / 65535.0));
|
||||
else
|
||||
color_matrix_scale_components (&dst, (1 / 255.0), (1 / 255.0),
|
||||
(1 / 255.0));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case GST_VIDEO_COLOR_RANGE_16_235:
|
||||
|
@ -240,6 +260,7 @@ videoconvert_convert_compute_matrix (VideoConvert * convert)
|
|||
switch (in_info->finfo->unpack_format) {
|
||||
case GST_VIDEO_FORMAT_AYUV:
|
||||
case GST_VIDEO_FORMAT_AYUV64:
|
||||
GST_DEBUG ("using 16-235 input range YUV");
|
||||
if (use_16) {
|
||||
color_matrix_offset_components (&dst, -4096, -32768, -32768);
|
||||
color_matrix_scale_components (&dst, (1 / 56064.0), (1 / 57344.0),
|
||||
|
@ -252,6 +273,7 @@ videoconvert_convert_compute_matrix (VideoConvert * convert)
|
|||
break;
|
||||
case GST_VIDEO_FORMAT_ARGB:
|
||||
case GST_VIDEO_FORMAT_ARGB64:
|
||||
GST_DEBUG ("using 16-235 input range RGB");
|
||||
if (use_16) {
|
||||
color_matrix_offset_components (&dst, -4096, -4096, -4096);
|
||||
color_matrix_scale_components (&dst, (1 / 56064.0), (1 / 56064.0),
|
||||
|
@ -316,6 +338,31 @@ videoconvert_convert_compute_matrix (VideoConvert * convert)
|
|||
/* 8, bring color components to nominal range */
|
||||
switch (out_info->colorimetry.range) {
|
||||
case GST_VIDEO_COLOR_RANGE_0_255:
|
||||
switch (out_info->finfo->unpack_format) {
|
||||
case GST_VIDEO_FORMAT_AYUV:
|
||||
case GST_VIDEO_FORMAT_AYUV64:
|
||||
GST_DEBUG ("using 0-255 output range YUV");
|
||||
if (use_16) {
|
||||
color_matrix_scale_components (&dst, 65535.0, 65535.0, 65535.0);
|
||||
color_matrix_offset_components (&dst, 0, 32768, 32768);
|
||||
} else {
|
||||
color_matrix_scale_components (&dst, 255.0, 255.0, 255.0);
|
||||
color_matrix_offset_components (&dst, 0, 128, 128);
|
||||
}
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_ARGB:
|
||||
case GST_VIDEO_FORMAT_ARGB64:
|
||||
GST_DEBUG ("using 0-255 output range RGB");
|
||||
if (use_16)
|
||||
color_matrix_scale_components (&dst, 65535.0, 65535.0, 65535.0);
|
||||
else
|
||||
color_matrix_scale_components (&dst, 255.0, 255.0, 255.0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
GST_DEBUG ("using 0-255 output range");
|
||||
if (use_16)
|
||||
color_matrix_scale_components (&dst, 65535.0, 65535.0, 65535.0);
|
||||
else
|
||||
|
@ -326,6 +373,7 @@ videoconvert_convert_compute_matrix (VideoConvert * convert)
|
|||
switch (out_info->finfo->unpack_format) {
|
||||
case GST_VIDEO_FORMAT_AYUV:
|
||||
case GST_VIDEO_FORMAT_AYUV64:
|
||||
GST_DEBUG ("using 16-235 output range YUV");
|
||||
if (use_16) {
|
||||
color_matrix_scale_components (&dst, 56064.0, 57344.0, 57344.0);
|
||||
color_matrix_offset_components (&dst, 4096, 32768, 32768);
|
||||
|
@ -336,6 +384,7 @@ videoconvert_convert_compute_matrix (VideoConvert * convert)
|
|||
break;
|
||||
case GST_VIDEO_FORMAT_ARGB:
|
||||
case GST_VIDEO_FORMAT_ARGB64:
|
||||
GST_DEBUG ("using 16-235 output range RGB");
|
||||
if (use_16) {
|
||||
color_matrix_scale_components (&dst, 56064.0, 56064.0, 56064.0);
|
||||
color_matrix_offset_components (&dst, 4096, 4096, 4096);
|
||||
|
|
Loading…
Reference in a new issue