From 833a8b579b03c478de72f1d5e8aafb9b369380bd Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 29 Jul 2003 11:59:09 +0000 Subject: 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 --- ext/xvid/gstxvid.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'ext/xvid/gstxvid.c') diff --git a/ext/xvid/gstxvid.c b/ext/xvid/gstxvid.c index fb7d06f4..8496a9d4 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) { -- cgit v1.2.1