diff --git a/subprojects/gst-plugins-good/gst/matroska/matroska-mux.c b/subprojects/gst-plugins-good/gst/matroska/matroska-mux.c index 465e0bce3b..3ce759c874 100644 --- a/subprojects/gst-plugins-good/gst/matroska/matroska-mux.c +++ b/subprojects/gst-plugins-good/gst/matroska/matroska-mux.c @@ -1157,6 +1157,9 @@ gst_matroska_mux_video_pad_setcaps (GstMatroskaMux * mux, videocontext->display_width = 0; videocontext->display_height = 0; } + if ((s = gst_structure_get_string (structure, "chroma-site"))) { + videocontext->chroma_site = gst_video_chroma_site_from_string (s); + } if ((s = gst_structure_get_string (structure, "colorimetry"))) { if (!gst_video_colorimetry_from_string (&videocontext->colorimetry, s)) { @@ -2687,6 +2690,9 @@ gst_matroska_mux_write_colour (GstMatroskaMux * mux, guint range_id = 0; guint transfer_id = 0; guint primaries_id = 0; + /* 0 = unknown, 1 = yes, 2 = no */ + guint chroma_site_horz = 0; + guint chroma_site_vert = 0; master = gst_ebml_write_master_start (ebml, GST_MATROSKA_ID_VIDEOCOLOUR); @@ -2707,6 +2713,15 @@ gst_matroska_mux_write_colour (GstMatroskaMux * mux, primaries_id = gst_video_color_primaries_to_iso (videocontext->colorimetry.primaries); + if (videocontext->chroma_site != GST_VIDEO_CHROMA_SITE_UNKNOWN) { + chroma_site_horz = 2; + chroma_site_vert = 2; + if (videocontext->chroma_site & GST_VIDEO_CHROMA_SITE_H_COSITED) + chroma_site_horz = 1; + if (videocontext->chroma_site & GST_VIDEO_CHROMA_SITE_V_COSITED) + chroma_site_vert = 1; + } + gst_ebml_write_uint (ebml, GST_MATROSKA_ID_VIDEORANGE, range_id); gst_ebml_write_uint (ebml, GST_MATROSKA_ID_VIDEOMATRIXCOEFFICIENTS, matrix_id); @@ -2720,6 +2735,12 @@ gst_matroska_mux_write_colour (GstMatroskaMux * mux, gst_ebml_write_uint (ebml, GST_MATROSKA_ID_MAXFALL, videocontext->content_light_level.max_frame_average_light_level); } + if (chroma_site_horz != 0 && chroma_site_vert != 0) { + gst_ebml_write_uint (ebml, GST_MATROSKA_ID_VIDEOCHROMASITINGHORZ, + chroma_site_horz); + gst_ebml_write_uint (ebml, GST_MATROSKA_ID_VIDEOCHROMASITINGVERT, + chroma_site_vert); + } gst_matroska_mux_write_mastering_metadata (mux, videocontext); gst_ebml_write_master_finish (ebml, master);