summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>2003-07-29 11:59:09 +0000
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>2003-07-29 11:59:09 +0000
commit833a8b579b03c478de72f1d5e8aafb9b369380bd (patch)
tree27b9c58ca9173b3f8af52260cd2c96dbcbaf3f75
parent0e115bc63918feb9973b10fd5066bae101a3113b (diff)
downloadgstreamer-plugins-bad-833a8b579b03c478de72f1d5e8aafb9b369380bd.tar.gz
call xvid_init() only once, and move duplicated code into one place
Original commit message from CVS: call xvid_init() only once, and move duplicated code into one place
m---------common0
-rw-r--r--ext/xvid/gstxvid.c32
-rw-r--r--ext/xvid/gstxvid.h36
-rw-r--r--ext/xvid/gstxviddec.c19
-rw-r--r--ext/xvid/gstxviddec.h4
-rw-r--r--ext/xvid/gstxvidenc.c19
-rw-r--r--ext/xvid/gstxvidenc.h4
7 files changed, 74 insertions, 40 deletions
diff --git a/common b/common
-Subproject d6e219fd076d8f182bd1ee84228b1b85cdb807a
+Subproject 8b323f41bfaccb8f30bddfc6ff8bd6a4be04a3e
diff --git a/ext/xvid/gstxvid.c b/ext/xvid/gstxvid.c
index fb7d06f4e..8496a9d4d 100644
--- a/ext/xvid/gstxvid.c
+++ b/ext/xvid/gstxvid.c
@@ -26,6 +26,38 @@
#include "gstxviddec.h"
#include "gstxvidenc.h"
+gboolean
+gst_xvid_init (void)
+{
+ XVID_INIT_PARAM xinit;
+ gint ret;
+ static gboolean is_init = FALSE;
+
+ /* only init once */
+ if (is_init == TRUE) {
+ return TRUE;
+ }
+
+ /* set up xvid initially (function pointers, CPU flags) */
+ memset(&xinit, 0, sizeof(XVID_INIT_PARAM));
+ xinit.cpu_flags = 0;
+ if ((ret = xvid_init(NULL, 0, &xinit, NULL)) != XVID_ERR_OK) {
+ g_warning("Failed to initialize XviD: %s (%d)",
+ gst_xvid_error(ret), ret);
+ return FALSE;
+ }
+
+ if (xinit.api_version != API_VERSION) {
+ g_warning("Xvid API version mismatch! %d.%d (that's us) != %d.%d (lib)",
+ (API_VERSION >> 8) & 0xff, API_VERSION & 0xff,
+ (xinit.api_version >> 8) & 0xff, xinit.api_version & 0xff);
+ return FALSE;
+ }
+
+ is_init = TRUE;
+ return TRUE;
+}
+
gchar *
gst_xvid_error (int errorcode)
{
diff --git a/ext/xvid/gstxvid.h b/ext/xvid/gstxvid.h
new file mode 100644
index 000000000..6e444f5f0
--- /dev/null
+++ b/ext/xvid/gstxvid.h
@@ -0,0 +1,36 @@
+/* GStreamer xvid decoder plugin
+ * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_XVID_H__
+#define __GST_XVID_H__
+
+#include <gst/gst.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+extern gchar * gst_xvid_error (int errorcode);
+extern gboolean gst_xvid_init (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __GST_XVID_H__ */
diff --git a/ext/xvid/gstxviddec.c b/ext/xvid/gstxviddec.c
index a5888da8f..50e72a3c7 100644
--- a/ext/xvid/gstxviddec.c
+++ b/ext/xvid/gstxviddec.c
@@ -135,23 +135,8 @@ static void
gst_xviddec_class_init (GstXvidDecClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
- XVID_INIT_PARAM xinit;
- gint ret;
-
- /* set up xvid initially (function pointers, CPU flags) */
- memset(&xinit, 0, sizeof(XVID_INIT_PARAM));
- xinit.cpu_flags = 0;
- if ((ret = xvid_init(NULL, 0, &xinit, NULL)) != XVID_ERR_OK) {
- g_warning("Failed to initialize XviD: %s (%d)",
- gst_xvid_error(ret), ret);
- return;
- }
-
- if (xinit.api_version != API_VERSION) {
- g_warning("Xvid API version mismatch! %d.%d (that's us) != %d.%d (lib)",
- (API_VERSION >> 8) & 0xff, API_VERSION & 0xff,
- (xinit.api_version >> 8) & 0xff, xinit.api_version & 0xff);
- }
+
+ gst_xvid_init();
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
diff --git a/ext/xvid/gstxviddec.h b/ext/xvid/gstxviddec.h
index 6a08b2be9..d17433429 100644
--- a/ext/xvid/gstxviddec.h
+++ b/ext/xvid/gstxviddec.h
@@ -22,6 +22,7 @@
#include <gst/gst.h>
#include <xvid.h>
+#include "gstxvid.h"
#ifdef __cplusplus
extern "C" {
@@ -66,9 +67,6 @@ GType gst_xviddec_get_type(void);
gboolean gst_xviddec_plugin_init (GModule *module,
GstPlugin *plugin);
-/* in gstxvid.c */
-extern gchar * gst_xvid_error (int errorcode);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/ext/xvid/gstxvidenc.c b/ext/xvid/gstxvidenc.c
index eb27b8ff7..b217b652d 100644
--- a/ext/xvid/gstxvidenc.c
+++ b/ext/xvid/gstxvidenc.c
@@ -147,23 +147,8 @@ gst_xvidenc_class_init (GstXvidEncClass *klass)
{
GstElementClass *gstelement_class;
GObjectClass *gobject_class;
- XVID_INIT_PARAM xinit;
- gint ret;
-
- /* set up xvid initially (function pointers, CPU flags) */
- memset(&xinit, 0, sizeof(XVID_INIT_PARAM));
- xinit.cpu_flags = 0;
- if ((ret = xvid_init(NULL, 0, &xinit, NULL)) != XVID_ERR_OK) {
- g_warning("Failed to initialize XviD: %s (%d)",
- gst_xvid_error(ret), ret);
- return;
- }
-
- if (xinit.api_version != API_VERSION) {
- g_warning("Xvid API version mismatch! %d.%d (that's us) != %d.%d (lib)",
- (API_VERSION >> 8) & 0xff, API_VERSION & 0xff,
- (xinit.api_version >> 8) & 0xff, xinit.api_version & 0xff);
- }
+
+ gst_xvid_init();
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
diff --git a/ext/xvid/gstxvidenc.h b/ext/xvid/gstxvidenc.h
index 224487dc4..02028d83a 100644
--- a/ext/xvid/gstxvidenc.h
+++ b/ext/xvid/gstxvidenc.h
@@ -21,6 +21,7 @@
#define __GST_XVIDENC_H__
#include <gst/gst.h>
+#include "gstxvid.h"
#ifdef __cplusplus
extern "C" {
@@ -75,9 +76,6 @@ GType gst_xvidenc_get_type(void);
gboolean gst_xvidenc_plugin_init (GModule *module,
GstPlugin *plugin);
-/* in gstxvid.c */
-extern gchar * gst_xvid_error (int errorcode);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */