summaryrefslogtreecommitdiffstats
path: root/ext/xvid
diff options
context:
space:
mode:
Diffstat (limited to 'ext/xvid')
-rw-r--r--ext/xvid/gstxvid.c46
-rw-r--r--ext/xvid/gstxviddec.c34
-rw-r--r--ext/xvid/gstxviddec.h3
-rw-r--r--ext/xvid/gstxvidenc.c18
-rw-r--r--ext/xvid/gstxvidenc.h3
5 files changed, 62 insertions, 42 deletions
diff --git a/ext/xvid/gstxvid.c b/ext/xvid/gstxvid.c
index 3683a0f6..e1a9700e 100644
--- a/ext/xvid/gstxvid.c
+++ b/ext/xvid/gstxvid.c
@@ -21,13 +21,59 @@
#include "config.h"
#endif
+#include <string.h>
+
#include "gstxviddec.h"
#include "gstxvidenc.h"
+gchar *
+gst_xvid_error (int errorcode)
+{
+ gchar *error;
+
+ switch (errorcode) {
+ case XVID_ERR_FAIL:
+ error = "Operation failed";
+ break;
+ case XVID_ERR_OK:
+ error = "No error";
+ break;
+ case XVID_ERR_MEMORY:
+ error = "Memory error";
+ break;
+ case XVID_ERR_FORMAT:
+ error = "Invalid format";
+ break;
+ default:
+ error = "Unknown error";
+ break;
+ }
+
+ return error;
+}
+
static gboolean
plugin_init (GModule *module,
GstPlugin *plugin)
{
+ 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("Faied 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 (gst_xviddec_plugin_init(module, plugin) &&
gst_xvidenc_plugin_init(module, plugin));
}
diff --git a/ext/xvid/gstxviddec.c b/ext/xvid/gstxviddec.c
index 4e5ab26f..acb424fe 100644
--- a/ext/xvid/gstxviddec.c
+++ b/ext/xvid/gstxviddec.c
@@ -120,18 +120,6 @@ static void
gst_xviddec_class_init (GstXvidDecClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
- XVID_INIT_PARAM xinit;
-
- /* set up xvid initially (function pointers, CPU flags) */
- memset(&xinit, 0, sizeof(xinit));
- xinit.cpu_flags = 0;
- xvid_init(NULL, 0, &xinit, NULL);
- if (xinit.api_version != API_VERSION) {
- g_error("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;
- }
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
@@ -187,21 +175,10 @@ gst_xviddec_setup (GstXvidDec *xviddec)
if ((ret = xvid_decore(NULL, XVID_DEC_CREATE,
&xdec, NULL)) != XVID_ERR_OK) {
- char *error;
- switch (ret) {
- case XVID_ERR_MEMORY:
- error = "Memory allocation error";
- break;
- case XVID_ERR_FORMAT:
- error = "Bad format";
- break;
- default:
- error = "Internal failure";
- break;
- }
- GST_DEBUG(GST_CAT_PLUGIN_INFO,
- "Setting parameters %dx%d@%d failed: %s",
- xviddec->width, xviddec->height, xviddec->csp, error);
+ gst_element_error(GST_ELEMENT(xviddec),
+ "Setting parameters %dx%d@%d failed: %s (%d)",
+ xviddec->width, xviddec->height, xviddec->csp,
+ gst_xvid_error(ret), ret);
return FALSE;
}
@@ -260,7 +237,8 @@ gst_xviddec_chain (GstPad *pad,
if ((ret = xvid_decore(xviddec->handle, XVID_DEC_DECODE,
&xframe, NULL))) {
gst_element_error(GST_ELEMENT(xviddec),
- "Error decoding xvid frame: %d\n", ret);
+ "Error decoding xvid frame: %s (%d)\n",
+ gst_xvid_error(ret), ret);
gst_buffer_unref(buf);
return;
}
diff --git a/ext/xvid/gstxviddec.h b/ext/xvid/gstxviddec.h
index 848ad261..cdee5540 100644
--- a/ext/xvid/gstxviddec.h
+++ b/ext/xvid/gstxviddec.h
@@ -65,6 +65,9 @@ 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 7efe42f9..5b97c69d 100644
--- a/ext/xvid/gstxvidenc.c
+++ b/ext/xvid/gstxvidenc.c
@@ -131,7 +131,6 @@ gst_xvidenc_get_type(void)
static void
gst_xvidenc_class_init (GstXvidEncClass *klass)
{
- XVID_INIT_PARAM xinit;
GstElementClass *gstelement_class;
GObjectClass *gobject_class;
@@ -140,17 +139,6 @@ gst_xvidenc_class_init (GstXvidEncClass *klass)
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
- /* set up xvid initially (function pointers, CPU flags) */
- memset(&xinit, 0, sizeof(xinit));
- xinit.cpu_flags = 0;
- xvid_init(NULL, 0, &xinit, NULL);
- if (xinit.api_version != API_VERSION) {
- g_error("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;
- }
-
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BITRATE,
g_param_spec_ulong("bitrate","Bitrate",
"Target video bitrate",
@@ -237,7 +225,8 @@ gst_xvidenc_setup (GstXvidEnc *xvidenc)
if ((ret = xvid_encore(NULL, XVID_ENC_CREATE,
&xenc, NULL)) != XVID_ERR_OK) {
gst_element_error(GST_ELEMENT(xvidenc),
- "Error setting up xvid encoder: %d\n", ret);
+ "Error setting up xvid encoder: %s (%d)",
+ gst_xvid_error(ret), ret);
return FALSE;
}
@@ -291,7 +280,8 @@ gst_xvidenc_chain (GstPad *pad,
if ((ret = xvid_encore(xvidenc->handle, XVID_ENC_ENCODE,
&xframe, NULL)) != XVID_ERR_OK) {
gst_element_error(GST_ELEMENT(xvidenc),
- "Error encoding xvid frame: %d\n", ret);
+ "Error encoding xvid frame: %s (%d)",
+ gst_xvid_error(ret), ret);
gst_buffer_unref(buf);
return;
}
diff --git a/ext/xvid/gstxvidenc.h b/ext/xvid/gstxvidenc.h
index 198cadf3..e14b4133 100644
--- a/ext/xvid/gstxvidenc.h
+++ b/ext/xvid/gstxvidenc.h
@@ -74,6 +74,9 @@ 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 */