diff options
author | Mathieu Duponchelle <mathieu@centricular.com> | 2021-08-05 23:11:26 +0200 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2021-08-30 15:49:11 +0100 |
commit | 689efff2a23b0075601d423d83ac7eeaf4ad0bf6 (patch) | |
tree | 8a112604508eb62ced7f2b04e9cd19186308f430 | |
parent | 36a09411b1dd54ff9c1550a4b0e515c1c31a4cbb (diff) | |
download | gstreamer-plugins-bad-689efff2a23b0075601d423d83ac7eeaf4ad0bf6.tar.gz |
mpeg2enc: fix interlace-mode detection
Previously, the code was always assuming progressive input,
fix this by looking at the caps.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2500>
-rw-r--r-- | ext/mpeg2enc/gstmpeg2encpicturereader.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/ext/mpeg2enc/gstmpeg2encpicturereader.cc b/ext/mpeg2enc/gstmpeg2encpicturereader.cc index 2bdd23d3d..3641b613a 100644 --- a/ext/mpeg2enc/gstmpeg2encpicturereader.cc +++ b/ext/mpeg2enc/gstmpeg2encpicturereader.cc @@ -61,6 +61,7 @@ GstMpeg2EncPictureReader::StreamPictureParams (MPEG2EncInVidParams & strm) const GValue *par_val; y4m_ratio_t fps; y4m_ratio_t par; + const gchar *interlace_mode; if (!gst_structure_get_int (structure, "width", &width)) width = -1; @@ -90,7 +91,24 @@ GstMpeg2EncPictureReader::StreamPictureParams (MPEG2EncInVidParams & strm) strm.horizontal_size = width; strm.vertical_size = height; - strm.interlacing_code = Y4M_ILACE_NONE; + interlace_mode = gst_structure_get_string (structure, "interlace-mode"); + + if (!g_strcmp0(interlace_mode, "interleaved")) { + const gchar *field_order = gst_structure_get_string(structure, "field-order"); + + if (!g_strcmp0(field_order, "bottom-field-first")) { + strm.interlacing_code = Y4M_ILACE_BOTTOM_FIRST; + } else if (!g_strcmp0(field_order, "top-field-first")) { + strm.interlacing_code = Y4M_ILACE_TOP_FIRST; + } else { + GST_WARNING ("No field-order in caps, assuming top field first"); + strm.interlacing_code = Y4M_ILACE_TOP_FIRST; + } + } else if (!g_strcmp0(interlace_mode, "mixed")) { + strm.interlacing_code = Y4M_ILACE_MIXED; + } else { + strm.interlacing_code = Y4M_ILACE_NONE; + } strm.aspect_ratio_code = mpeg_guess_mpeg_aspect_code (2, par, strm.horizontal_size, strm.vertical_size); |