summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2017-07-15 14:59:42 +0100
committerTim-Philipp Müller <tim@centricular.com>2017-07-15 14:59:42 +0100
commit58a23c99e932eb4a221673a118d1675fdabd58e2 (patch)
tree70cd40187ae03e7fe3c33430e98da4b44f3e2c4b /ext
parent841a073154d9ab512b2abba997552b2ae354bc92 (diff)
x264enc: fix caps leak
Move creation of supported sink pads into class_init function which is also the only place where they're used. Unref the caps when no longer needed, the pad template will take its own ref. https://bugzilla.gnome.org/show_bug.cgi?id=784982
Diffstat (limited to 'ext')
-rw-r--r--ext/x264/gstx264enc.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c
index 6ce73d0d..57ecc68d 100644
--- a/ext/x264/gstx264enc.c
+++ b/ext/x264/gstx264enc.c
@@ -140,7 +140,6 @@ struct _GstX264EncVTable
static GstX264EncVTable default_vtable;
static GstX264EncVTable *vtable_8bit = NULL, *vtable_10bit = NULL;
-static GstCaps *supported_sinkcaps = NULL;
#define LOAD_SYMBOL(name) G_STMT_START { \
if (!g_module_symbol (module, #name, (gpointer *) &vtable->name)) { \
@@ -324,14 +323,6 @@ load_x264_libraries (void)
if (!vtable_8bit && !vtable_10bit)
return FALSE;
- supported_sinkcaps = gst_caps_new_simple ("video/x-raw",
- "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
- "width", GST_TYPE_INT_RANGE, 16, G_MAXINT,
- "height", GST_TYPE_INT_RANGE, 16, G_MAXINT, NULL);
-
- gst_x264_enc_add_x264_chroma_format (gst_caps_get_structure
- (supported_sinkcaps, 0), TRUE, TRUE, TRUE);
-
return TRUE;
}
@@ -874,6 +865,7 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
GstVideoEncoderClass *gstencoder_class;
const gchar *partitions = NULL;
GstPadTemplate *sink_templ;
+ GstCaps *supported_sinkcaps;
x264enc_defaults = g_string_new ("");
@@ -1134,9 +1126,19 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
"Josef Zlomek <josef.zlomek@itonis.tv>, "
"Mark Nauwelaerts <mnauw@users.sf.net>");
+ supported_sinkcaps = gst_caps_new_simple ("video/x-raw",
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
+ "width", GST_TYPE_INT_RANGE, 16, G_MAXINT,
+ "height", GST_TYPE_INT_RANGE, 16, G_MAXINT, NULL);
+
+ gst_x264_enc_add_x264_chroma_format (gst_caps_get_structure
+ (supported_sinkcaps, 0), TRUE, TRUE, TRUE);
+
sink_templ = gst_pad_template_new ("sink",
GST_PAD_SINK, GST_PAD_ALWAYS, supported_sinkcaps);
+ gst_caps_unref (supported_sinkcaps);
+
gst_element_class_add_pad_template (element_class, sink_templ);
gst_element_class_add_static_pad_template (element_class, &src_factory);
}