matroskademux: Handle chroma site color information
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5534>
This commit is contained in:
parent
03c129d4d3
commit
8e6ec1fc34
@ -581,6 +581,8 @@ gst_matroska_demux_parse_colour (GstMatroskaDemux * demux, GstEbmlRead * ebml,
|
||||
{
|
||||
GstFlowReturn ret;
|
||||
GstVideoColorimetry colorimetry;
|
||||
guint64 chroma_site_horz;
|
||||
guint64 chroma_site_vert;
|
||||
guint32 id;
|
||||
guint64 num;
|
||||
|
||||
@ -588,6 +590,9 @@ gst_matroska_demux_parse_colour (GstMatroskaDemux * demux, GstEbmlRead * ebml,
|
||||
colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_UNKNOWN;
|
||||
colorimetry.transfer = GST_VIDEO_TRANSFER_UNKNOWN;
|
||||
colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_UNKNOWN;
|
||||
/* 0 = unknown, 1 = yes, 2 = no */
|
||||
chroma_site_horz = 0;
|
||||
chroma_site_vert = 0;
|
||||
|
||||
DEBUG_ELEMENT_START (demux, ebml, "TrackVideoColour");
|
||||
|
||||
@ -680,6 +685,22 @@ gst_matroska_demux_parse_colour (GstMatroskaDemux * demux, GstEbmlRead * ebml,
|
||||
break;
|
||||
}
|
||||
|
||||
case GST_MATROSKA_ID_VIDEOCHROMASITINGHORZ:{
|
||||
if ((ret =
|
||||
gst_ebml_read_uint (ebml, &id,
|
||||
&chroma_site_horz)) != GST_FLOW_OK)
|
||||
goto beach;
|
||||
break;
|
||||
}
|
||||
|
||||
case GST_MATROSKA_ID_VIDEOCHROMASITINGVERT:{
|
||||
if ((ret =
|
||||
gst_ebml_read_uint (ebml, &id,
|
||||
&chroma_site_vert)) != GST_FLOW_OK)
|
||||
goto beach;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
GST_FIXME_OBJECT (demux, "Unsupported subelement 0x%x in Colour", id);
|
||||
ret = gst_ebml_read_skip (ebml);
|
||||
@ -690,6 +711,15 @@ gst_matroska_demux_parse_colour (GstMatroskaDemux * demux, GstEbmlRead * ebml,
|
||||
memcpy (&video_context->colorimetry, &colorimetry,
|
||||
sizeof (GstVideoColorimetry));
|
||||
|
||||
if (chroma_site_horz == 1 && chroma_site_vert == 1)
|
||||
video_context->chroma_site = GST_VIDEO_CHROMA_SITE_COSITED;
|
||||
else if (chroma_site_horz == 1 && chroma_site_vert == 2)
|
||||
video_context->chroma_site = GST_VIDEO_CHROMA_SITE_H_COSITED;
|
||||
else if (chroma_site_horz == 2 && chroma_site_vert == 1)
|
||||
video_context->chroma_site = GST_VIDEO_CHROMA_SITE_V_COSITED;
|
||||
else if (chroma_site_horz == 2 && chroma_site_vert == 2)
|
||||
video_context->chroma_site = GST_VIDEO_CHROMA_SITE_NONE;
|
||||
|
||||
beach:
|
||||
DEBUG_ELEMENT_STOP (demux, ebml, "TrackVideoColour", ret);
|
||||
return ret;
|
||||
@ -7115,6 +7145,14 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
|
||||
}
|
||||
}
|
||||
|
||||
if (videocontext->chroma_site != GST_VIDEO_CHROMA_SITE_UNKNOWN) {
|
||||
gchar *chroma =
|
||||
gst_video_chroma_site_to_string (videocontext->chroma_site);
|
||||
gst_caps_set_simple (caps, "chroma-site", G_TYPE_STRING, chroma, NULL);
|
||||
GST_DEBUG ("setting chroma site to %s", chroma);
|
||||
g_free (chroma);
|
||||
}
|
||||
|
||||
caps = gst_caps_simplify (caps);
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,7 @@ gst_matroska_track_init_video_context (GstMatroskaTrackContext ** p_context)
|
||||
video_context->colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_UNKNOWN;
|
||||
video_context->colorimetry.transfer = GST_VIDEO_TRANSFER_UNKNOWN;
|
||||
video_context->colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_UNKNOWN;
|
||||
video_context->chroma_site = GST_VIDEO_CHROMA_SITE_UNKNOWN;
|
||||
gst_video_mastering_display_info_init
|
||||
(&video_context->mastering_display_info);
|
||||
video_context->mastering_display_info_present = FALSE;
|
||||
|
@ -144,6 +144,8 @@
|
||||
#define GST_MATROSKA_ID_VIDEOCOLOUR 0x55B0
|
||||
/* IDs in the Colour master*/
|
||||
#define GST_MATROSKA_ID_VIDEOMATRIXCOEFFICIENTS 0x55B1
|
||||
#define GST_MATROSKA_ID_VIDEOCHROMASITINGHORZ 0x55B7
|
||||
#define GST_MATROSKA_ID_VIDEOCHROMASITINGVERT 0x55B8
|
||||
#define GST_MATROSKA_ID_VIDEORANGE 0x55B9
|
||||
#define GST_MATROSKA_ID_VIDEOTRANSFERCHARACTERISTICS 0x55BA
|
||||
#define GST_MATROSKA_ID_VIDEOPRIMARIES 0x55BB
|
||||
@ -656,6 +658,7 @@ typedef struct _GstMatroskaTrackVideoContext {
|
||||
|
||||
GstBuffer *dirac_unit;
|
||||
GstVideoColorimetry colorimetry;
|
||||
GstVideoChromaSite chroma_site;
|
||||
|
||||
GstVideoMasteringDisplayInfo mastering_display_info;
|
||||
gboolean mastering_display_info_present;
|
||||
|
Loading…
x
Reference in New Issue
Block a user