video: Add gst_video_decoder_set_interlaced_output_state()
authorZeeshan Ali <zeenix@collabora.co.uk>
Fri, 6 Jul 2018 13:48:35 +0000 (15:48 +0200)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 29 Aug 2018 16:14:38 +0000 (12:14 -0400)
Add a variant of gst_video_decoder_set_output_state() that allows the user
to pass an interlacing mode as well. This is needed to ensure that
gst_video_info_set_interlaced_format() is used instead so that
GstVideoInfo.size is correctly initialized.

https://bugzilla.gnome.org/show_bug.cgi?id=796106

gst-libs/gst/video/gstvideodecoder.c
gst-libs/gst/video/gstvideodecoder.h

index 888737f5ab74d3631e6db5421e91f41f4df30321..ce7100f10be4ed8ca05dbb04cf43eea649c894b8 100644 (file)
@@ -619,15 +619,16 @@ parse_fail:
 }
 
 static GstVideoCodecState *
-_new_output_state (GstVideoFormat fmt, guint width, guint height,
-    GstVideoCodecState * reference)
+_new_output_state (GstVideoFormat fmt, GstVideoInterlaceMode mode, guint width,
+    guint height, GstVideoCodecState * reference)
 {
   GstVideoCodecState *state;
 
   state = g_slice_new0 (GstVideoCodecState);
   state->ref_count = 1;
   gst_video_info_init (&state->info);
-  if (!gst_video_info_set_format (&state->info, fmt, width, height)) {
+  if (!gst_video_info_set_interlaced_format (&state->info, fmt, mode, width,
+          height)) {
     g_slice_free (GstVideoCodecState, state);
     return NULL;
   }
@@ -3485,6 +3486,31 @@ GstVideoCodecState *
 gst_video_decoder_set_output_state (GstVideoDecoder * decoder,
     GstVideoFormat fmt, guint width, guint height,
     GstVideoCodecState * reference)
+{
+  return gst_video_decoder_set_interlaced_output_state (decoder, fmt,
+      GST_VIDEO_INTERLACE_MODE_PROGRESSIVE, width, height, reference);
+}
+
+/**
+ * gst_video_decoder_set_interlaced_output_state:
+ * @decoder: a #GstVideoDecoder
+ * @fmt: a #GstVideoFormat
+ * @width: The width in pixels
+ * @height: The height in pixels
+ * @mode: A #GstVideoInterlaceMode
+ * @reference: (allow-none) (transfer none): An optional reference #GstVideoCodecState
+ *
+ * Same as #gst_video_decoder_set_output_state() but also allows you to also set
+ * the interlacing mode.
+ *
+ * Returns: (transfer full): the newly configured output state.
+ *
+ * Since: 1.16.
+ */
+GstVideoCodecState *
+gst_video_decoder_set_interlaced_output_state (GstVideoDecoder * decoder,
+    GstVideoFormat fmt, GstVideoInterlaceMode mode, guint width, guint height,
+    GstVideoCodecState * reference)
 {
   GstVideoDecoderPrivate *priv = decoder->priv;
   GstVideoCodecState *state;
@@ -3493,7 +3519,7 @@ gst_video_decoder_set_output_state (GstVideoDecoder * decoder,
       fmt, width, height, reference);
 
   /* Create the new output state */
-  state = _new_output_state (fmt, width, height, reference);
+  state = _new_output_state (fmt, mode, width, height, reference);
   if (!state)
     return NULL;
 
index a3abab2831e6a1ae7464fdda67e7aa51a67d6ecc..17048cfc8e4f46112cec0e9282f02e0a61fc0fcc 100644 (file)
@@ -433,6 +433,11 @@ GstVideoCodecState *gst_video_decoder_set_output_state (GstVideoDecoder *decoder
                                                        GstVideoFormat fmt, guint width, guint height,
                                                        GstVideoCodecState *reference);
 
+GST_VIDEO_API
+GstVideoCodecState *gst_video_decoder_set_interlaced_output_state (GstVideoDecoder *decoder,
+                                                                   GstVideoFormat fmt, GstVideoInterlaceMode mode,
+                                                                   guint width, guint height, GstVideoCodecState *reference);
+
 GST_VIDEO_API
 GstVideoCodecState *gst_video_decoder_get_output_state (GstVideoDecoder *decoder);