diff --git a/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c b/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c index df1e6a54bd..2d4683890b 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c +++ b/subprojects/gst-plugins-bad/gst/mpegtsdemux/tsdemux.c @@ -1873,24 +1873,56 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream, GST_WARNING_OBJECT (demux, "Invalid JPEG XS descriptor"); break; } - if (jpegxs.frat >> 30) { - GST_WARNING_OBJECT (demux, "Interlaced JPEG-XS not supported yet"); + + guint8 interlace_mode = (jpegxs.frat >> 30) & 0x3; + + if (interlace_mode == 3) { // Reserved + GST_WARNING_OBJECT (demux, "Unknown JPEG XS interlace mode 3"); break; } + + const gchar *field_order_str; + guint n_fields; + + switch (interlace_mode) { + case 1: + field_order_str = "top-field-first"; + n_fields = 2; + break; + case 2: + field_order_str = "bottom-field-first"; + n_fields = 2; + break; + default: + g_assert_not_reached (); + /* fall through */ + case 0: + field_order_str = NULL; + n_fields = 1; + break; + } + if ((jpegxs.schar >> 15) == 0) { GST_WARNING_OBJECT (demux, "JPEG-XS sampling properties are required"); break; } is_video = TRUE; - caps = - gst_caps_from_string - ("image/x-jxsc, alignment=(string)frame, interlace-mode=(string)progressive"); - + caps = gst_caps_from_string ("image/x-jxsc, alignment=(string)frame"); /* interlace-mode, sampling, depth, framerate */ gint depth = ((jpegxs.schar >> 4) & 0xf) + 1; gst_caps_set_simple (caps, "width", G_TYPE_INT, jpegxs.horizontal_size, - "height", G_TYPE_INT, jpegxs.vertical_size, + "height", G_TYPE_INT, jpegxs.vertical_size * n_fields, "depth", G_TYPE_INT, depth, NULL); + + if (field_order_str) { + gst_caps_set_simple (caps, + "interlace-mode", G_TYPE_STRING, "fields", + "field-order", G_TYPE_STRING, field_order_str, NULL); + } else { + gst_caps_set_simple (caps, + "interlace-mode", G_TYPE_STRING, "progressive", NULL); + } + if (jpegxs.frat != 0) { gint framerate_num = (jpegxs.frat & 0x0000FFFFU); gint framerate_den = ((jpegxs.frat >> 24) & 0x0000003FU);