From: Ronald S. Bultje Date: Tue, 29 Jul 2003 11:59:09 +0000 (+0000) Subject: call xvid_init() only once, and move duplicated code into one place X-Git-Tag: 1.19.3~507^2~24246 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=833a8b579b03c478de72f1d5e8aafb9b369380bd;p=platform%2Fupstream%2Fgstreamer.git 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 --- diff --git a/common b/common index d6e219f..8b323f4 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit d6e219fd076d8f182bd1ee84228b1b85cdb807a6 +Subproject commit 8b323f41bfaccb8f30bddfc6ff8bd6a4be04a3e1 diff --git a/ext/xvid/gstxvid.c b/ext/xvid/gstxvid.c index fb7d06f..8496a9d 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 0000000..6e444f5 --- /dev/null +++ b/ext/xvid/gstxvid.h @@ -0,0 +1,36 @@ +/* GStreamer xvid decoder plugin + * Copyright (C) 2003 Ronald Bultje + * + * 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 + +#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 a5888da..50e72a3 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 6a08b2b..d174334 100644 --- a/ext/xvid/gstxviddec.h +++ b/ext/xvid/gstxviddec.h @@ -22,6 +22,7 @@ #include #include +#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 eb27b8f..b217b65 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 224487d..02028d8 100644 --- a/ext/xvid/gstxvidenc.h +++ b/ext/xvid/gstxvidenc.h @@ -21,6 +21,7 @@ #define __GST_XVIDENC_H__ #include +#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 */