Commit 47d4010a authored by Ronald S. Bultje's avatar Ronald S. Bultje

Update xvid plugin to latest xvid (1.0.0-beta3) API.

Original commit message from CVS:
2004-01-03  Ronald Bultje  <rbultje@ronald.bitfreak.net>

reviewed by: <delete if not using a buddy>

* configure.ac:
* ext/xvid/gstxvid.c: (gst_xvid_init), (gst_xvid_error),
(gst_xvid_structure_to_csp), (gst_xvid_csp_to_caps):
* ext/xvid/gstxvid.h:
* ext/xvid/gstxviddec.c: (gst_xviddec_class_init),
(gst_xviddec_init), (gst_xviddec_setup), (gst_xviddec_chain),
(gst_xviddec_src_link), (gst_xviddec_sink_link),
(gst_xviddec_change_state):
* ext/xvid/gstxviddec.h:
* ext/xvid/gstxvidenc.c: (gst_xvidenc_profile_get_type),
(gst_xvidenc_base_init), (gst_xvidenc_class_init),
(gst_xvidenc_init), (gst_xvidenc_setup), (gst_xvidenc_chain),
(gst_xvidenc_link), (gst_xvidenc_set_property),
(gst_xvidenc_get_property), (gst_xvidenc_change_state):
* ext/xvid/gstxvidenc.h:
Update xvid plugin to latest xvid (1.0.0-beta3) API.
parent b52042f6
......@@ -1289,21 +1289,30 @@ GST_CHECK_FEATURE(VORBIS, [vorbis plug-in], vorbisenc vorbisdec, [
dnl *** XVID ***
translit(dnm, m, l) AM_CONDITIONAL(USE_XVID, true)
GST_CHECK_FEATURE(XVID, [xvid plugins], xvid, [
HAVE_XVID=yes
AC_CHECK_HEADER(xvid.h, ,
[ AC_MSG_WARN([Xvid headers not found]) &&
HAVE_XVID=no ] )
LIBS="-lm"
AC_CHECK_LIB(xvidcore, xvid_encore, ,
[ AC_MSG_WARN([Xvid encore libs not found]) &&
HAVE_XVID=no ] )
AC_CHECK_LIB(xvidcore, xvid_decore, ,
[ AC_MSG_WARN([Xvid decore libs not found]) &&
HAVE_XVID=no ] )
if test x$HAVE_XVID = xyes; then
XVID_LIBS="-lxvidcore -lm"
AC_SUBST(XVID_LIBS)
fi
HAVE_XVID=no
AC_CHECK_HEADER(xvid.h, [
OLD_LIBS="$LIBS"
LIBS="-lm"
AC_CHECK_LIB(xvidcore, xvid_encore, [
AC_CHECK_LIB(xvidcore, xvid_decore, [
AC_CHECK_LIB(xvidcore, xvid_global, [
AC_MSG_CHECKING([for uptodate XviD API version])
AC_TRY_RUN([
#include <xvid.h>
#if XVID_API != XVID_MAKE_API(4,0)
#error "Incompatible XviD API version"
#endif
int main () { return 0; }
],[ AC_MSG_RESULT(yes)
XVID_LIBS="-lxvidcore -lm"
AC_SUBST(XVID_LIBS)
HAVE_XVID=yes
], AC_MSG_RESULT(no) )
], )
], )
], )
LIBS="$OLD_LIBS"
], )
])
......
/* GStreamer xvid decoder plugin
/* GStreamer xvid encoder/decoder plugin
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
......@@ -22,14 +22,16 @@
#endif
#include <string.h>
#include <xvid.h>
#include <gst/video/video.h>
#include "gstxviddec.h"
#include "gstxvidenc.h"
gboolean
gst_xvid_init (void)
{
XVID_INIT_PARAM xinit;
xvid_gbl_init_t xinit;
gint ret;
static gboolean is_init = FALSE;
......@@ -39,20 +41,18 @@ gst_xvid_init (void)
}
/* 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) {
gst_xvid_init_struct (xinit);
if ((ret = xvid_global(NULL, XVID_GBL_INIT, &xinit, NULL)) < 0) {
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;
}
GST_LOG ("Initted XviD version %d.%d.%d (API %d.%d)",
XVID_VERSION_MAJOR (XVID_VERSION),
XVID_VERSION_MINOR (XVID_VERSION),
XVID_VERSION_PATCH (XVID_VERSION),
XVID_API_MAJOR (XVID_API), XVID_API_MINOR (XVID_API));
is_init = TRUE;
return TRUE;
......@@ -67,14 +67,17 @@ gst_xvid_error (int errorcode)
case XVID_ERR_FAIL:
error = "Operation failed";
break;
case XVID_ERR_OK:
case 0:
error = "No error";
break;
case XVID_ERR_MEMORY:
error = "Memory error";
error = "Memory allocation error";
break;
case XVID_ERR_FORMAT:
error = "Invalid format";
error = "File format not supported";
break;
case XVID_ERR_VERSION:
error = "Structure version not supported";
break;
default:
error = "Unknown error";
......@@ -84,6 +87,193 @@ gst_xvid_error (int errorcode)
return error;
}
gint
gst_xvid_structure_to_csp (GstStructure *structure,
gint w, gint *_stride, gint *_bpp)
{
const gchar *mime = gst_structure_get_name (structure);
gint xvid_cs = -1, stride = -1, bpp = -1;
if (!strcmp (mime, "video/x-raw-yuv")) {
guint32 fourcc;
gst_structure_get_fourcc (structure, "format", &fourcc);
switch (fourcc) {
case GST_MAKE_FOURCC('I','4','2','0'):
xvid_cs = XVID_CSP_I420;
stride = w;
bpp = 12;
break;
case GST_MAKE_FOURCC('Y','U','Y','2'):
xvid_cs = XVID_CSP_YUY2;
stride = w * 2;
bpp = 16;
break;
case GST_MAKE_FOURCC('Y','V','1','2'):
xvid_cs = XVID_CSP_YV12;
stride = w;
bpp = 12;
break;
case GST_MAKE_FOURCC('U','Y','V','Y'):
xvid_cs = XVID_CSP_UYVY;
stride = w * 2;
bpp = 16;
break;
case GST_MAKE_FOURCC('Y','V','Y','U'):
xvid_cs = XVID_CSP_YVYU;
stride = w * 2;
bpp = 16;
break;
}
} else {
gint depth, r_mask;
gst_structure_get_int(structure, "depth", &depth);
gst_structure_get_int(structure, "bpp", &bpp);
gst_structure_get_int(structure, "red_mask", &r_mask);
switch (depth) {
case 15:
xvid_cs = XVID_CSP_RGB555;
break;
case 16:
xvid_cs = XVID_CSP_RGB565;
break;
case 24:
if (bpp == 24) {
xvid_cs = XVID_CSP_BGR;
} else {
switch (r_mask) {
case 0xff000000:
xvid_cs = XVID_CSP_RGBA;
break;
case 0x00ff0000:
xvid_cs = XVID_CSP_ARGB;
break;
case 0x0000ff00:
xvid_cs = XVID_CSP_BGRA;
break;
case 0x000000ff:
xvid_cs = XVID_CSP_ABGR;
break;
}
}
break;
default:
break;
}
stride = w * bpp / 8;
}
if (_stride)
*_stride = stride;
if (_bpp)
*_bpp = bpp;
return xvid_cs;
}
GstCaps *
gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps)
{
GstCaps *caps = NULL;
switch (csp) {
case XVID_CSP_RGB555:
case XVID_CSP_RGB565:
case XVID_CSP_BGR:
case XVID_CSP_ABGR:
case XVID_CSP_BGRA:
case XVID_CSP_ARGB:
case XVID_CSP_RGBA: {
gint r_mask = 0, b_mask = 0, g_mask = 0,
endianness = 0, bpp = 0, depth = 0;
switch (csp) {
case XVID_CSP_RGB555:
r_mask = R_MASK_15_INT; g_mask = G_MASK_15_INT; b_mask = B_MASK_15_INT;
endianness = G_BYTE_ORDER; depth = 15; bpp = 16;
break;
case XVID_CSP_RGB565:
r_mask = R_MASK_16_INT; g_mask = G_MASK_16_INT; b_mask = B_MASK_16_INT;
endianness = G_BYTE_ORDER; depth = 16; bpp = 16;
break;
case XVID_CSP_BGR:
r_mask = 0x0000ff; g_mask = 0x00ff00; b_mask = 0xff0000;
endianness = G_BIG_ENDIAN; depth = 24; bpp = 24;
break;
case XVID_CSP_ABGR:
r_mask = 0x000000ff; g_mask = 0x0000ff00; b_mask = 0x00ff0000;
endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
break;
case XVID_CSP_BGRA:
r_mask = 0x0000ff00; g_mask = 0x00ff0000; b_mask = 0xff000000;
endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
break;
case XVID_CSP_ARGB:
r_mask = 0x00ff0000; g_mask = 0x0000ff00; b_mask = 0x000000ff;
endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
break;
case XVID_CSP_RGBA:
r_mask = 0xff000000; g_mask = 0x00ff0000; b_mask = 0x0000ff00;
endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
break;
}
caps = gst_caps_new_simple ("video/x-raw-rgb",
"width", G_TYPE_INT, w,
"height", G_TYPE_INT, h,
"depth", G_TYPE_INT, depth,
"bpp", G_TYPE_INT, bpp,
"endianness", G_TYPE_INT, endianness,
"red_mask", G_TYPE_INT, r_mask,
"green_mask", G_TYPE_INT, g_mask,
"blue_mask", G_TYPE_INT, b_mask,
"framerate", G_TYPE_DOUBLE, fps,
NULL);
break;
}
case XVID_CSP_YUY2:
case XVID_CSP_YVYU:
case XVID_CSP_UYVY:
case XVID_CSP_I420:
case XVID_CSP_YV12: {
guint32 fourcc = 0;
switch (csp) {
case XVID_CSP_YUY2:
fourcc = GST_MAKE_FOURCC ('Y','U','Y','2');
break;
case XVID_CSP_YVYU:
fourcc = GST_MAKE_FOURCC ('Y','V','Y','U');
break;
case XVID_CSP_UYVY:
fourcc = GST_MAKE_FOURCC ('U','Y','V','Y');
break;
case XVID_CSP_I420:
fourcc = GST_MAKE_FOURCC ('I','4','2','0');
break;
case XVID_CSP_YV12:
fourcc = GST_MAKE_FOURCC ('Y','V','1','2');
break;
}
caps = gst_caps_new_simple ("video/x-raw-yuv",
"width", G_TYPE_INT, w,
"height", G_TYPE_INT, h,
"format", GST_TYPE_FOURCC, fourcc,
"framerate", G_TYPE_DOUBLE, fps,
NULL);
break;
}
}
return caps;
}
static gboolean
plugin_init (GstPlugin *plugin)
{
......@@ -97,9 +287,10 @@ GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"xvid",
"XVid plugin library",
"XviD plugin library",
plugin_init,
VERSION,
"GPL",
GST_PACKAGE,
GST_ORIGIN)
GST_ORIGIN
)
/* GStreamer xvid decoder plugin
/* GStreamer xvid encoder/decoder plugin
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* This library is free software; you can redistribute it and/or
......@@ -22,15 +22,33 @@
#include <gst/gst.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
G_BEGIN_DECLS
#define gst_xvid_init_struct(s) \
do { \
memset (&s, 0, sizeof(s)); \
s.version = XVID_VERSION; \
} while (0);
#define RGB_24_32_STATIC_CAPS(bpp, r_mask,g_mask,b_mask) \
"video/x-raw-rgb, " \
"width = (int) [ 0, MAX ], " \
"height = (int) [ 0, MAX], " \
"framerate = (double) [ 0.0, MAX], " \
"depth = (int) 24, " \
"bpp = (int) " G_STRINGIFY (bpp) ", " \
"endianness = (int) BIG_ENDIAN, " \
"red_mask = (int) " G_STRINGIFY (r_mask) ", " \
"green_mask = (int) " G_STRINGIFY (g_mask) ", " \
"blue_mask = (int) " G_STRINGIFY (b_mask)
extern gchar * gst_xvid_error (int errorcode);
extern gboolean gst_xvid_init (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
extern gint gst_xvid_structure_to_csp (GstStructure *structure,
gint w, gint *stride, gint *bpp);
extern GstCaps *gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps);
G_END_DECLS
#endif /* __GST_XVID_H__ */
This diff is collapsed.
......@@ -21,7 +21,6 @@
#define __GST_XVIDDEC_H__
#include <gst/gst.h>
#include <xvid.h>
#include "gstxvid.h"
#ifdef __cplusplus
......@@ -53,7 +52,7 @@ struct _GstXvidDec {
void *handle;
/* video (output) settings */
gint csp, bpp;
gint csp, bpp, stride;
gint width, height;
double fps;
};
......
This diff is collapsed.
......@@ -48,11 +48,15 @@ struct _GstXvidEnc {
/* pads */
GstPad *sinkpad, *srcpad;
/* quality of encoded JPEG image */
gulong bitrate;
/* encoding profile */
gint profile;
/* size of the JPEG buffers */
gulong buffer_size;
/* quality of encoded image */
gint bitrate;
gint buffer_size;
/* max number of B frames between I/P */
gint max_b_frames;
/* max key interval */
gint max_key_interval;
......@@ -60,8 +64,8 @@ struct _GstXvidEnc {
/* xvid handle */
void *handle;
gint csp;
gint width, height;
double fps;
gint width, height, stride;
gdouble fps;
};
struct _GstXvidEncClass {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment