line21dec: relax caps requirements
authorMathieu Duponchelle <mathieu@centricular.com>
Fri, 22 Jan 2021 22:54:50 +0000 (23:54 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sat, 3 Apr 2021 00:42:15 +0000 (00:42 +0000)
Instead of requiring interlaced video, simply skip CC detection
when the input is progressive.

This allows placing line21decoder unconditionally in pipelines,
without having to worry about whether the input stream will be
interlaced, or even worse interlacing just in case!

+ update doc cache

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1885>

docs/plugins/gst_plugins_cache.json
ext/closedcaption/gstline21dec.c

index 02da740..9a484b3 100644 (file)
                 "long-name": "Line 21 CC Decoder",
                 "pad-templates": {
                     "sink": {
-                        "caps": "video/x-raw:\n         format: { I420, YUY2, YVYU, UYVY, VYUY, v210 }\n interlace-mode: interleaved\n",
+                        "caps": "video/x-raw:\n         format: { I420, YUY2, YVYU, UYVY, VYUY, v210 }\n",
                         "direction": "sink",
                         "presence": "always"
                     },
                     "src": {
-                        "caps": "video/x-raw:\n         format: { I420, YUY2, YVYU, UYVY, VYUY, v210 }\n interlace-mode: interleaved\n",
+                        "caps": "video/x-raw:\n         format: { I420, YUY2, YVYU, UYVY, VYUY, v210 }\n",
                         "direction": "src",
                         "presence": "always"
                     }
                 },
-                "properties": {},
+                "properties": {
+                    "mode": {
+                        "blurb": "Control whether and how detected CC meta should be inserted in the list of existing CC meta on a frame (if any).",
+                        "conditionally-available": false,
+                        "construct": false,
+                        "construct-only": false,
+                        "controllable": false,
+                        "default": "add (0)",
+                        "mutable": "null",
+                        "readable": true,
+                        "type": "GstLine21DecoderMode",
+                        "writable": true
+                    },
+                    "ntsc-only": {
+                        "blurb": "Whether line 21 decoding should only be attempted when the input resolution matches NTSC",
+                        "conditionally-available": false,
+                        "construct": false,
+                        "construct-only": false,
+                        "controllable": false,
+                        "default": "false",
+                        "mutable": "null",
+                        "readable": true,
+                        "type": "gboolean",
+                        "writable": true
+                    }
+                },
                 "rank": "none"
             },
             "line21encoder": {
                         "value": "3"
                     }
                 ]
+            },
+            "GstLine21DecoderMode": {
+                "kind": "enum",
+                "values": [
+                    {
+                        "desc": "add new CC meta on top of other CC meta, if any",
+                        "name": "add",
+                        "value": "0"
+                    },
+                    {
+                        "desc": "ignore CC if a CC meta was already present",
+                        "name": "drop",
+                        "value": "1"
+                    },
+                    {
+                        "desc": "replace existing CC meta",
+                        "name": "replace",
+                        "value": "2"
+                    }
+                ]
             }
         },
         "package": "GStreamer Bad Plug-ins",
index 489bd00..4e5b770 100644 (file)
@@ -56,7 +56,7 @@ enum
 #define DEFAULT_NTSC_ONLY FALSE
 #define DEFAULT_MODE GST_LINE_21_DECODER_MODE_ADD
 
-#define CAPS "video/x-raw, format={ I420, YUY2, YVYU, UYVY, VYUY, v210 }, interlace-mode=interleaved"
+#define CAPS "video/x-raw, format={ I420, YUY2, YVYU, UYVY, VYUY, v210 }"
 
 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
@@ -216,6 +216,8 @@ gst_line_21_decoder_class_init (GstLine21DecoderClass * klass)
   GST_DEBUG_CATEGORY_INIT (gst_line_21_decoder_debug, "line21decoder",
       0, "Line 21 CC Decoder");
   vbi_initialize_gst_debug ();
+
+  gst_type_mark_as_plugin_api (GST_TYPE_LINE_21_DECODER_MODE, 0);
 }
 
 static void
@@ -288,6 +290,12 @@ gst_line_21_decoder_set_info (GstVideoFilter * filter,
   /* Scan the next frame from the first line */
   self->line21_offset = -1;
 
+  if (!GST_VIDEO_INFO_IS_INTERLACED (in_info)) {
+    GST_DEBUG_OBJECT (filter, "Only interlaced formats are supported");
+    self->compatible_format = FALSE;
+    return TRUE;
+  }
+
   if (GST_VIDEO_INFO_WIDTH (in_info) != 720) {
     GST_DEBUG_OBJECT (filter, "Only 720 pixel wide formats are supported");
     self->compatible_format = FALSE;