summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sourceforge.net>2007-08-01 17:43:39 +0000
committerStefan Kost <ensonic@users.sourceforge.net>2007-08-01 17:43:39 +0000
commit907d7e40f5cde52bdff25e4501677165cdb4cd58 (patch)
treea4edf0cf9b3951b0a166ebc2ad1fca68e1c15e07
parent8e16a398368a11089ada00b7f560a7ae721ce758 (diff)
ext/ffmpeg/: Free strings atleast when finalizing elements.
Original commit message from CVS: * ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_finalize): * ext/ffmpeg/gstffmpegcfg.h: * ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_finalize), (ffmpegenc_setup_working_buf), (gst_ffmpegenc_chain_video), (gst_ffmpegenc_flush_buffers): Free strings atleast when finalizing elements. * tests/check/generic/libavcodec-locking.c: (GST_START_TEST), (simple_launch_lines_suite): Fix some leaks.
-rw-r--r--ChangeLog14
-rw-r--r--ext/ffmpeg/gstffmpegcfg.c39
-rw-r--r--ext/ffmpeg/gstffmpegcfg.h1
-rw-r--r--ext/ffmpeg/gstffmpegenc.c8
-rw-r--r--tests/check/generic/libavcodec-locking.c17
5 files changed, 65 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 44cbeca..e8a6f03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2007-08-01 Stefan Kost <ensonic@users.sf.net>
+ * ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_cfg_install_property),
+ (gst_ffmpeg_cfg_finalize):
+ * ext/ffmpeg/gstffmpegcfg.h:
+ * ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_finalize),
+ (ffmpegenc_setup_working_buf), (gst_ffmpegenc_chain_video),
+ (gst_ffmpegenc_flush_buffers):
+ Free strings atleast when finalizing elements.
+
+ * tests/check/generic/libavcodec-locking.c: (GST_START_TEST),
+ (simple_launch_lines_suite):
+ Fix some leaks.
+
+2007-08-01 Stefan Kost <ensonic@users.sf.net>
+
* configure.ac:
* ext/ffmpeg/Makefile.am:
Check for libm and link against it (ffmpeg is using sqrt).
diff --git a/ext/ffmpeg/gstffmpegcfg.c b/ext/ffmpeg/gstffmpegcfg.c
index 7501875..b42be81 100644
--- a/ext/ffmpeg/gstffmpegcfg.c
+++ b/ext/ffmpeg/gstffmpegcfg.c
@@ -760,7 +760,7 @@ gst_ffmpeg_cfg_install_property (GstFFMpegEncClass * klass, guint base)
GParamSpecString* pstring = G_PARAM_SPEC_STRING (pspec);
pspec = g_param_spec_string (name, nick, blurb,
lavc_default ? G_STRUCT_MEMBER (gchar*, ctx, ctx_offset)
- : pstring->default_value,
+ : pstring->default_value,
pspec->flags);
break;
}
@@ -813,13 +813,13 @@ gst_ffmpeg_cfg_install_property (GstFFMpegEncClass * klass, guint base)
GParamSpecEnum* penum = G_PARAM_SPEC_ENUM (pspec);
pspec = g_param_spec_enum (name, nick, blurb,
pspec->value_type,
- lavc_default ? G_STRUCT_MEMBER (gint, ctx, ctx_offset)
+ lavc_default ? G_STRUCT_MEMBER (gint, ctx, ctx_offset)
: penum->default_value, pspec->flags);
} else if (G_IS_PARAM_SPEC_FLAGS (pspec)) {
GParamSpecFlags* pflags = G_PARAM_SPEC_FLAGS (pspec);
pspec = g_param_spec_flags (name, nick, blurb,
pspec->value_type,
- lavc_default ? G_STRUCT_MEMBER (guint, ctx, ctx_offset)
+ lavc_default ? G_STRUCT_MEMBER (guint, ctx, ctx_offset)
: pflags->default_value, pspec->flags);
} else {
g_critical ("%s does not yet support type %s", GST_FUNCTION,
@@ -1026,3 +1026,36 @@ gst_ffmpeg_cfg_fill_context (GstFFMpegEnc * ffmpegenc, AVCodecContext * context)
list = list->next;
}
}
+
+void
+gst_ffmpeg_cfg_finalize (GstFFMpegEnc * ffmpegenc)
+{
+ GParamSpec **pspecs;
+ guint num_props, i;
+
+ pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (ffmpegenc),
+ &num_props);
+
+ for (i = 0; i < num_props; ++i) {
+ GParamSpec *pspec = pspecs[i];
+ GParamSpecData *qdata;
+
+ qdata = g_param_spec_get_qdata (pspec, quark);
+
+ /* our param specs should have such qdata */
+ if (!qdata)
+ continue;
+
+ switch (G_PARAM_SPEC_VALUE_TYPE (pspec)) {
+ case G_TYPE_STRING:
+ if(qdata->size == sizeof (gchar*)) {
+ g_free (G_STRUCT_MEMBER (gchar*, ffmpegenc, qdata->offset));
+ G_STRUCT_MEMBER (gchar*, ffmpegenc, qdata->offset) = NULL;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ g_free (pspecs);
+}
diff --git a/ext/ffmpeg/gstffmpegcfg.h b/ext/ffmpeg/gstffmpegcfg.h
index 1f442ba..8452359 100644
--- a/ext/ffmpeg/gstffmpegcfg.h
+++ b/ext/ffmpeg/gstffmpegcfg.h
@@ -35,6 +35,7 @@ gboolean gst_ffmpeg_cfg_get_property (GObject * object,
void gst_ffmpeg_cfg_fill_context (GstFFMpegEnc * ffmpegenc, AVCodecContext * context);
void gst_ffmpeg_cfg_set_defaults (GstFFMpegEnc * ffmpegenc);
+void gst_ffmpeg_cfg_finalize (GstFFMpegEnc * ffmpegenc);
G_END_DECLS
diff --git a/ext/ffmpeg/gstffmpegenc.c b/ext/ffmpeg/gstffmpegenc.c
index 05f34fe..028a2e7 100644
--- a/ext/ffmpeg/gstffmpegenc.c
+++ b/ext/ffmpeg/gstffmpegenc.c
@@ -259,6 +259,8 @@ gst_ffmpegenc_finalize (GObject * object)
{
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) object;
+ gst_ffmpeg_cfg_finalize (ffmpegenc);
+
/* close old session */
if (ffmpegenc->opened) {
gst_ffmpeg_avcodec_close (ffmpegenc->context);
@@ -570,7 +572,7 @@ gst_ffmpegenc_setcaps (GstPad * pad, GstCaps * caps)
static void
ffmpegenc_setup_working_buf (GstFFMpegEnc *ffmpegenc)
{
- if (ffmpegenc->working_buf == NULL ||
+ if (ffmpegenc->working_buf == NULL ||
ffmpegenc->working_buf_size != ffmpegenc->buffer_size) {
if (ffmpegenc->working_buf)
g_free (ffmpegenc->working_buf);
@@ -603,7 +605,7 @@ gst_ffmpegenc_chain_video (GstPad * pad, GstBuffer * inbuf)
ffmpegenc_setup_working_buf (ffmpegenc);
ret_size = avcodec_encode_video (ffmpegenc->context,
- ffmpegenc->working_buf, ffmpegenc->working_buf_size,
+ ffmpegenc->working_buf, ffmpegenc->working_buf_size,
ffmpegenc->picture);
if (ret_size < 0) {
@@ -754,7 +756,7 @@ gst_ffmpegenc_flush_buffers (GstFFMpegEnc * ffmpegenc, gboolean send)
while (!g_queue_is_empty (ffmpegenc->delay)) {
ffmpegenc_setup_working_buf (ffmpegenc);
-
+
ret_size = avcodec_encode_video (ffmpegenc->context,
ffmpegenc->working_buf, ffmpegenc->working_buf_size, NULL);
diff --git a/tests/check/generic/libavcodec-locking.c b/tests/check/generic/libavcodec-locking.c
index 88d321a..4e484f8 100644
--- a/tests/check/generic/libavcodec-locking.c
+++ b/tests/check/generic/libavcodec-locking.c
@@ -36,7 +36,7 @@ setup_pipeline (const gchar * pipe_descr)
return pipeline;
}
-/*
+/*
* run_pipeline:
* @pipe: the pipeline to run
* @desc: the description for use in messages
@@ -101,22 +101,21 @@ GST_START_TEST (test_libavcodec_locks)
for (i=0; i<NUM_SINKS; i++)
sink[i] = g_strdup_printf (" t.src%d ! queue ! ffenc_mpeg4 ! ffdec_mpeg4 ! fakesink sync=true", i);
-
+
sink [NUM_SINKS] = NULL;
-
+
sinks = g_strjoinv (" ", sink);
-
+
s = g_strdup_printf ("videotestsrc ! video/x-raw-yuv,format=(fourcc)I420,width=320,height=240,framerate=(fraction)10/1 ! tee name=t %s", sinks);
-
+
run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN);
-
g_free (s);
for (i=0; i<NUM_SINKS; i++)
g_free (sink[i]);
-
+ g_free (sinks);
}
GST_END_TEST Suite *
@@ -138,6 +137,7 @@ simple_launch_lines_suite (void)
suite_add_tcase (s, tc_chain);
+#ifndef GST_DISABLE_PARSE
/* only run this if we haven't been configured with --disable-encoders */
if (gst_default_registry_check_feature_version ("ffenc_mpeg4",
GST_VERSION_MAJOR, GST_VERSION_MINOR, 0)) {
@@ -145,7 +145,8 @@ simple_launch_lines_suite (void)
} else {
g_print ("******* Skipping libavcodec_locks test, no encoder available\n");
}
-
+#endif
+
return s;
}