mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 14:06:23 +00:00
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
This commit is contained in:
parent
841a073154
commit
58a23c99e9
1 changed files with 11 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue