line21enc: add remove-caption-meta property

Similar to #GstCCExtractor:remove-caption-meta

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1554>
This commit is contained in:
Mathieu Duponchelle 2020-09-04 16:53:03 +02:00
parent c07e2a89ba
commit c58357fb66
4 changed files with 83 additions and 4 deletions

View file

@ -3436,7 +3436,20 @@
"presence": "always"
}
},
"properties": {},
"properties": {
"remove-caption-meta": {
"blurb": "Remove encoded caption meta from outgoing video buffers",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "false",
"mutable": "null",
"readable": true,
"type": "gboolean",
"writable": true
}
},
"rank": "none"
}
},

View file

@ -39,6 +39,12 @@
GST_DEBUG_CATEGORY_STATIC (gst_line_21_encoder_debug);
#define GST_CAT_DEFAULT gst_line_21_encoder_debug
enum
{
PROP_0,
PROP_REMOVE_CAPTION_META,
};
/* FIXME: add and test support for PAL resolutions */
#define CAPS "video/x-raw, format={ I420, YUY2, YVYU, UYVY, VYUY }, width=(int)720, height=(int){ 525, 486 }, interlace-mode=interleaved"
@ -60,16 +66,41 @@ static gboolean gst_line_21_encoder_set_info (GstVideoFilter * filter,
GstCaps * outcaps, GstVideoInfo * out_info);
static GstFlowReturn gst_line_21_encoder_transform_ip (GstVideoFilter * filter,
GstVideoFrame * frame);
static void gst_line_21_encoder_set_property (GObject * self, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_line_21_encoder_get_property (GObject * self, guint prop_id,
GValue * value, GParamSpec * pspec);
static void
gst_line_21_encoder_class_init (GstLine21EncoderClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstVideoFilterClass *filter_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
filter_class = (GstVideoFilterClass *) klass;
gobject_class->set_property = gst_line_21_encoder_set_property;
gobject_class->get_property = gst_line_21_encoder_get_property;
/**
* line21encoder:remove-caption-meta
*
* Selects whether the encoded #GstVideoCaptionMeta should be removed from
* the outgoing video buffers or whether it should be kept.
*
* Since: 1.20
*/
g_object_class_install_property (G_OBJECT_CLASS (klass),
PROP_REMOVE_CAPTION_META, g_param_spec_boolean ("remove-caption-meta",
"Remove Caption Meta",
"Remove encoded caption meta from outgoing video buffers", FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_set_static_metadata (gstelement_class,
"Line 21 CC Encoder",
"Filter/Video/ClosedCaption",
@ -92,6 +123,38 @@ gst_line_21_encoder_init (GstLine21Encoder * filter)
{
}
static void
gst_line_21_encoder_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstLine21Encoder *enc = GST_LINE21ENCODER (object);
switch (prop_id) {
case PROP_REMOVE_CAPTION_META:
enc->remove_caption_meta = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_line_21_encoder_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstLine21Encoder *enc = GST_LINE21ENCODER (object);
switch (prop_id) {
case PROP_REMOVE_CAPTION_META:
g_value_set_boolean (value, enc->remove_caption_meta);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static vbi_pixfmt
vbi_pixfmt_from_gst_video_format (GstVideoFormat format)
{
@ -445,8 +508,8 @@ gst_line_21_encoder_transform_ip (GstVideoFilter * filter,
}
}
/* We've encoded this meta, it can now be removed */
if (cc_meta)
/* We've encoded this meta, it can now be removed if required */
if (cc_meta && self->remove_caption_meta)
gst_buffer_remove_meta (frame->buffer, (GstMeta *) cc_meta);
/* When dealing with standard NTSC resolution, field 1 goes at line 21,

View file

@ -48,6 +48,8 @@ struct _GstLine21Encoder
vbi_sampling_par sp;
GstVideoInfo info;
gboolean remove_caption_meta;
};
struct _GstLine21EncoderClass

View file

@ -42,7 +42,8 @@ GST_START_TEST (basic)
"interlace-mode", G_TYPE_STRING, "interleaved",
NULL);
h = gst_harness_new_parse ("line21encoder ! line21decoder");
h = gst_harness_new_parse
("line21encoder remove-caption-meta=true ! line21decoder");
gst_harness_set_caps (h, gst_caps_ref (caps), gst_caps_ref (caps));
gst_video_info_from_caps (&info, caps);