summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2019-03-06 11:23:32 +0100
committerMathieu Duponchelle <mathieu@centricular.com>2019-03-06 11:29:20 +0100
commit919cd44f4722b48d83728a501ea8949d71fdd555 (patch)
tree41b4a91600cbfa3d82b8f1324c74515705f3168d /ext
parent156865541fb18e93b445f759f940989bc66ccd7d (diff)
downloadgstreamer-plugins-bad-919cd44f4722b48d83728a501ea8949d71fdd555.tar.gz
line21dec: general cleanup
This ports over the review comments made on line21enc in !217
Diffstat (limited to 'ext')
-rw-r--r--ext/closedcaption/gstline21dec.c129
1 files changed, 32 insertions, 97 deletions
diff --git a/ext/closedcaption/gstline21dec.c b/ext/closedcaption/gstline21dec.c
index 53833860f..b3c93cbaf 100644
--- a/ext/closedcaption/gstline21dec.c
+++ b/ext/closedcaption/gstline21dec.c
@@ -37,33 +37,21 @@
GST_DEBUG_CATEGORY_STATIC (gst_line_21_decoder_debug);
#define GST_CAT_DEFAULT gst_line_21_decoder_debug
-enum
-{
- PROP_0,
-};
-
-#define SUPPORTED_FORMATS "{ I420, YUY2, YVYU, UYVY, VYUY, v210 }"
+#define CAPS "video/x-raw, format={ I420, YUY2, YVYU, UYVY, VYUY, v210 }, interlace-mode=interleaved"
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (SUPPORTED_FORMATS)));
+ GST_STATIC_CAPS (CAPS));
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (SUPPORTED_FORMATS)));
+ GST_STATIC_CAPS (CAPS));
G_DEFINE_TYPE (GstLine21Decoder, gst_line_21_decoder, GST_TYPE_VIDEO_FILTER);
#define parent_class gst_line_21_decoder_parent_class
-static void gst_line_21_decoder_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_line_21_decoder_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static GstStateChangeReturn gst_line_21_decoder_change_state (GstElement *
- element, GstStateChange transition);
static void gst_line_21_decoder_finalize (GObject * self);
static gboolean gst_line_21_decoder_set_info (GstVideoFilter * filter,
GstCaps * incaps, GstVideoInfo * in_info,
@@ -86,16 +74,11 @@ gst_line_21_decoder_class_init (GstLine21DecoderClass * klass)
transform_class = (GstBaseTransformClass *) klass;
filter_class = (GstVideoFilterClass *) klass;
- gobject_class->set_property = gst_line_21_decoder_set_property;
- gobject_class->get_property = gst_line_21_decoder_get_property;
gobject_class->finalize = gst_line_21_decoder_finalize;
- gstelement_class->change_state =
- GST_DEBUG_FUNCPTR (gst_line_21_decoder_change_state);
-
gst_element_class_set_static_metadata (gstelement_class,
"Line 21 CC Decoder",
- "Filter",
+ "Filter/Video/ClosedCaption",
"Extract line21 CC from SD video streams",
"Edward Hervey <edward@centricular.com>");
@@ -114,48 +97,12 @@ gst_line_21_decoder_class_init (GstLine21DecoderClass * klass)
}
static void
-gst_line_21_decoder_reset (GstLine21Decoder * self)
-{
- self->line21_offset = -1;
- self->max_line_probes = 40;
- if (self->info) {
- gst_video_info_free (self->info);
- self->info = NULL;
- }
- g_free (self->converted_lines);
- self->converted_lines = NULL;
-}
-
-static void
gst_line_21_decoder_init (GstLine21Decoder * filter)
{
- gst_line_21_decoder_reset (filter);
-}
-
-static void
-gst_line_21_decoder_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- /* GstLine21Decoder *filter = GST_LINE21DECODER (object); */
-
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_line_21_decoder_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- /* GstLine21Decoder *filter = GST_LINE21DECODER (object); */
+ GstLine21Decoder *self = (GstLine21Decoder *) filter;
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ self->line21_offset = -1;
+ self->max_line_probes = 40;
}
static vbi_pixfmt
@@ -181,7 +128,8 @@ vbi_pixfmt_from_gst_video_format (GstVideoFormat format,
return VBI_PIXFMT_YUV420;
/* All the other formats are not really bullet-proof. Force conversion */
default:
- return 0;
+ g_assert_not_reached ();
+ return (vbi_pixfmt) 0;
}
#undef NATIVE_VBI_FMT
}
@@ -204,6 +152,17 @@ gst_line_21_decoder_set_info (GstVideoFilter * filter,
GST_DEBUG_OBJECT (filter, "#planes : %d #components : %d",
GST_VIDEO_INFO_N_PLANES (in_info), GST_VIDEO_INFO_N_COMPONENTS (in_info));
+ if (self->info) {
+ gst_video_info_free (self->info);
+ self->info = NULL;
+ }
+
+ g_free (self->converted_lines);
+ self->converted_lines = NULL;
+
+ /* Scan the next frame from the first line */
+ self->line21_offset = -1;
+
if (GST_VIDEO_INFO_WIDTH (in_info) != 720) {
GST_DEBUG_OBJECT (filter, "Only 720 pixel wide formats are supported");
self->compatible_format = FALSE;
@@ -244,7 +203,10 @@ gst_line_21_decoder_set_info (GstVideoFilter * filter,
/* initialize the decoder */
vbi_raw_decoder_init (&self->zvbi_decoder);
- /* We either deal with PAL (625 lines) or NTSC (525 lines) */
+ /*
+ * Set up blank / black / white levels fit for NTSC, no actual relation
+ * with the height of the video
+ */
self->zvbi_decoder.scanning = 525;
/* The pixel format. Quite a few formats are handled by zvbi, but
* some are not and require conversion (or cheating) */
@@ -453,44 +415,17 @@ gst_line_21_decoder_transform_ip (GstVideoFilter * filter,
return GST_FLOW_OK;
}
-static GstStateChangeReturn
-gst_line_21_decoder_change_state (GstElement * element,
- GstStateChange transition)
+static void
+gst_line_21_decoder_finalize (GObject * object)
{
- GstStateChangeReturn ret;
- GstLine21Decoder *filter = GST_LINE21DECODER (element);
-
- switch (transition) {
- case GST_STATE_CHANGE_NULL_TO_READY:
- break;
- case GST_STATE_CHANGE_READY_TO_PAUSED:
- break;
- case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
- break;
- default:
- break;
- }
-
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
- if (ret != GST_STATE_CHANGE_SUCCESS)
- return ret;
+ GstLine21Decoder *self = (GstLine21Decoder *) object;
- switch (transition) {
- case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
- break;
- case GST_STATE_CHANGE_PAUSED_TO_READY:
- gst_line_21_decoder_reset (filter);
- break;
- case GST_STATE_CHANGE_READY_TO_NULL:
- default:
- break;
+ if (self->info) {
+ gst_video_info_free (self->info);
+ self->info = NULL;
}
+ g_free (self->converted_lines);
+ self->converted_lines = NULL;
- return ret;
-}
-
-static void
-gst_line_21_decoder_finalize (GObject * object)
-{
G_OBJECT_CLASS (parent_class)->finalize (object);
}