indentation test

Original commit message from CVS:
indentation test
This commit is contained in:
Thomas Vander Stichele 2004-03-14 20:47:18 +00:00
parent bcddae04d6
commit a19db4bbdc
2 changed files with 377 additions and 409 deletions

View file

@ -33,55 +33,49 @@ GstElementDetails gst_divxdec_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>" "Ronald Bultje <rbultje@ronald.bitfreak.net>"
}; };
static GstStaticPadTemplate sink_template = static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_PAD_TEMPLATE ( GST_PAD_SINK,
"sink", GST_PAD_ALWAYS,
GST_PAD_SINK, GST_STATIC_CAPS ("video/x-divx, "
GST_PAD_ALWAYS, "divxversion = (int) [ 3, 5 ], "
GST_STATIC_CAPS ( "width = (int) [ 16, 4096 ], "
"video/x-divx, " "height = (int) [ 16, 4096 ], " "framerate = (double) [ 0, MAX ]")
"divxversion = (int) [ 3, 5 ], " );
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ], "
"framerate = (double) [ 0, MAX ]"
)
);
static GstStaticPadTemplate src_template = static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_PAD_TEMPLATE ( GST_PAD_SRC,
"src", GST_PAD_ALWAYS,
GST_PAD_SRC, GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, UYVY }")
GST_PAD_ALWAYS, /* FIXME: 15/16/24/32bpp RGB */
GST_STATIC_CAPS ( )
GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, UYVY }") );
/* FIXME: 15/16/24/32bpp RGB */
)
);
/* DivxDec signals and args */ /* DivxDec signals and args */
enum { enum
{
/* FILL ME */ /* FILL ME */
LAST_SIGNAL LAST_SIGNAL
}; };
enum { enum
{
ARG_0 ARG_0
/* FILL ME */ /* FILL ME */
}; };
static void gst_divxdec_base_init (GstDivxDecClass *klass); static void gst_divxdec_base_init (GstDivxDecClass * klass);
static void gst_divxdec_class_init (GstDivxDecClass *klass); static void gst_divxdec_class_init (GstDivxDecClass * klass);
static void gst_divxdec_init (GstDivxDec *divxdec); static void gst_divxdec_init (GstDivxDec * divxdec);
static void gst_divxdec_dispose (GObject *object); static void gst_divxdec_dispose (GObject * object);
static void gst_divxdec_chain (GstPad *pad, static void gst_divxdec_chain (GstPad * pad, GstData * data);
GstData *data); static GstPadLinkReturn gst_divxdec_connect (GstPad * pad,
static GstPadLinkReturn gst_divxdec_connect (GstPad *pad, const GstCaps * vscapslist);
const GstCaps *vscapslist); static GstPadLinkReturn gst_divxdec_negotiate (GstDivxDec * divxdec);
static GstPadLinkReturn gst_divxdec_negotiate (GstDivxDec *divxdec);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
/* static guint gst_divxdec_signals[LAST_SIGNAL] = { 0 }; */ /* static guint gst_divxdec_signals[LAST_SIGNAL] = { 0 }; */
@ -115,72 +109,70 @@ gst_divxdec_error (int errorcode)
} }
GType GType
gst_divxdec_get_type(void) gst_divxdec_get_type (void)
{ {
static GType divxdec_type = 0; static GType divxdec_type = 0;
if (!divxdec_type) if (!divxdec_type) {
{
static const GTypeInfo divxdec_info = { static const GTypeInfo divxdec_info = {
sizeof(GstDivxDecClass), sizeof (GstDivxDecClass),
(GBaseInitFunc) gst_divxdec_base_init, (GBaseInitFunc) gst_divxdec_base_init,
NULL, NULL,
(GClassInitFunc) gst_divxdec_class_init, (GClassInitFunc) gst_divxdec_class_init,
NULL, NULL,
NULL, NULL,
sizeof(GstDivxDec), sizeof (GstDivxDec),
0, 0,
(GInstanceInitFunc) gst_divxdec_init, (GInstanceInitFunc) gst_divxdec_init,
}; };
divxdec_type = g_type_register_static(GST_TYPE_ELEMENT, divxdec_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstDivxDec", "GstDivxDec", &divxdec_info, 0);
&divxdec_info, 0);
} }
return divxdec_type; return divxdec_type;
} }
static void static void
gst_divxdec_base_init (GstDivxDecClass *klass) gst_divxdec_base_init (GstDivxDecClass * klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template)); gst_static_pad_template_get (&sink_template));
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_template)); gst_static_pad_template_get (&src_template));
gst_element_class_set_details (element_class, &gst_divxdec_details); gst_element_class_set_details (element_class, &gst_divxdec_details);
} }
static void static void
gst_divxdec_class_init (GstDivxDecClass *klass) gst_divxdec_class_init (GstDivxDecClass * klass)
{ {
GObjectClass *gobject_class = (GObjectClass *) klass; GObjectClass *gobject_class = (GObjectClass *) klass;
parent_class = g_type_class_ref(GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->dispose = gst_divxdec_dispose; gobject_class->dispose = gst_divxdec_dispose;
} }
static void static void
gst_divxdec_init (GstDivxDec *divxdec) gst_divxdec_init (GstDivxDec * divxdec)
{ {
/* create the sink pad */ /* create the sink pad */
divxdec->sinkpad = gst_pad_new_from_template( divxdec->sinkpad =
gst_static_pad_template_get (&sink_template), gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
"sink"); "sink");
gst_element_add_pad(GST_ELEMENT(divxdec), divxdec->sinkpad); gst_element_add_pad (GST_ELEMENT (divxdec), divxdec->sinkpad);
gst_pad_set_chain_function(divxdec->sinkpad, gst_divxdec_chain); gst_pad_set_chain_function (divxdec->sinkpad, gst_divxdec_chain);
gst_pad_set_link_function(divxdec->sinkpad, gst_divxdec_connect); gst_pad_set_link_function (divxdec->sinkpad, gst_divxdec_connect);
/* create the src pad */ /* create the src pad */
divxdec->srcpad = gst_pad_new_from_template( divxdec->srcpad =
gst_static_pad_template_get (&src_template), gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
"src"); "src");
gst_element_add_pad(GST_ELEMENT(divxdec), divxdec->srcpad); gst_element_add_pad (GST_ELEMENT (divxdec), divxdec->srcpad);
gst_pad_use_explicit_caps (divxdec->srcpad); gst_pad_use_explicit_caps (divxdec->srcpad);
/* bitrate, etc. */ /* bitrate, etc. */
@ -193,18 +185,18 @@ gst_divxdec_init (GstDivxDec *divxdec)
static void static void
gst_divxdec_unset (GstDivxDec *divxdec) gst_divxdec_unset (GstDivxDec * divxdec)
{ {
if (divxdec->handle) { if (divxdec->handle) {
/* unref this instance */ /* unref this instance */
decore(divxdec->handle, DEC_OPT_RELEASE, NULL, NULL); decore (divxdec->handle, DEC_OPT_RELEASE, NULL, NULL);
divxdec->handle = NULL; divxdec->handle = NULL;
} }
} }
static gboolean static gboolean
gst_divxdec_setup (GstDivxDec *divxdec) gst_divxdec_setup (GstDivxDec * divxdec)
{ {
void *handle; void *handle;
DEC_INIT xinit; DEC_INIT xinit;
@ -212,7 +204,7 @@ gst_divxdec_setup (GstDivxDec *divxdec)
int ret; int ret;
/* initialize the handle */ /* initialize the handle */
memset(&xinit, 0, sizeof(DEC_INIT)); memset (&xinit, 0, sizeof (DEC_INIT));
xinit.smooth_playback = 0; xinit.smooth_playback = 0;
switch (divxdec->version) { switch (divxdec->version) {
case 3: case 3:
@ -228,9 +220,9 @@ gst_divxdec_setup (GstDivxDec *divxdec)
xinit.codec_version = 0; xinit.codec_version = 0;
break; break;
} }
if ((ret = decore(&handle, DEC_OPT_INIT, &xinit, NULL)) != 0) { if ((ret = decore (&handle, DEC_OPT_INIT, &xinit, NULL)) != 0) {
GST_ELEMENT_ERROR (divxdec, LIBRARY, INIT, (NULL), GST_ELEMENT_ERROR (divxdec, LIBRARY, INIT, (NULL),
("divx library error: %s (%d)", gst_divxdec_error (ret), ret)); ("divx library error: %s (%d)", gst_divxdec_error (ret), ret));
return FALSE; return FALSE;
} }
@ -238,19 +230,17 @@ gst_divxdec_setup (GstDivxDec *divxdec)
divxdec->handle = handle; divxdec->handle = handle;
/* initialise parameters, see divx documentation */ /* initialise parameters, see divx documentation */
memset(&output, 0, sizeof(DivXBitmapInfoHeader)); memset (&output, 0, sizeof (DivXBitmapInfoHeader));
output.biSize = sizeof(DivXBitmapInfoHeader); output.biSize = sizeof (DivXBitmapInfoHeader);
output.biWidth = divxdec->width; output.biWidth = divxdec->width;
output.biHeight = divxdec->height; output.biHeight = divxdec->height;
output.biBitCount = divxdec->bitcnt; output.biBitCount = divxdec->bitcnt;
output.biCompression = divxdec->csp; output.biCompression = divxdec->csp;
if ((ret = decore(divxdec->handle, DEC_OPT_SETOUT, if ((ret = decore (divxdec->handle, DEC_OPT_SETOUT, &output, NULL)) != 0) {
&output, NULL)) != 0) {
GST_ELEMENT_ERROR (divxdec, LIBRARY, SETTINGS, (NULL), GST_ELEMENT_ERROR (divxdec, LIBRARY, SETTINGS, (NULL),
("error setting output: %s (%d)", ("error setting output: %s (%d)", gst_divxdec_error (ret), ret));
gst_divxdec_error (ret), ret)); gst_divxdec_unset (divxdec);
gst_divxdec_unset(divxdec);
return FALSE; return FALSE;
} }
@ -259,17 +249,16 @@ gst_divxdec_setup (GstDivxDec *divxdec)
static void static void
gst_divxdec_dispose (GObject *object) gst_divxdec_dispose (GObject * object)
{ {
GstDivxDec *divxdec = GST_DIVXDEC(object); GstDivxDec *divxdec = GST_DIVXDEC (object);
gst_divxdec_unset(divxdec); gst_divxdec_unset (divxdec);
} }
static void static void
gst_divxdec_chain (GstPad *pad, gst_divxdec_chain (GstPad * pad, GstData * _data)
GstData *_data)
{ {
GstBuffer *buf = GST_BUFFER (_data); GstBuffer *buf = GST_BUFFER (_data);
GstDivxDec *divxdec; GstDivxDec *divxdec;
@ -277,146 +266,162 @@ gst_divxdec_chain (GstPad *pad,
DEC_FRAME xframe; DEC_FRAME xframe;
int ret; int ret;
g_return_if_fail(pad != NULL); g_return_if_fail (pad != NULL);
g_return_if_fail(GST_IS_PAD(pad)); g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail(buf != NULL); g_return_if_fail (buf != NULL);
divxdec = GST_DIVXDEC(GST_OBJECT_PARENT(pad)); divxdec = GST_DIVXDEC (GST_OBJECT_PARENT (pad));
if (!divxdec->handle) { if (!divxdec->handle) {
if (gst_divxdec_negotiate(divxdec) <= 0) { if (gst_divxdec_negotiate (divxdec) <= 0) {
GST_ELEMENT_ERROR (divxdec, CORE, TOO_LAZY, (NULL), GST_ELEMENT_ERROR (divxdec, CORE, TOO_LAZY, (NULL),
("No format set - aborting")); ("No format set - aborting"));
gst_buffer_unref(buf); gst_buffer_unref (buf);
return; return;
} }
} }
outbuf = gst_buffer_new_and_alloc(divxdec->width * outbuf = gst_buffer_new_and_alloc (divxdec->width *
divxdec->height * divxdec->height * divxdec->bpp / 8);
divxdec->bpp / 8); GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf); GST_BUFFER_SIZE (outbuf) = divxdec->width *
GST_BUFFER_SIZE(outbuf) = divxdec->width * divxdec->height * divxdec->bpp / 8;
divxdec->height *
divxdec->bpp / 8;
/* encode and so ... */ /* encode and so ... */
xframe.bitstream = (void *) GST_BUFFER_DATA(buf); xframe.bitstream = (void *) GST_BUFFER_DATA (buf);
xframe.bmp = (void *) GST_BUFFER_DATA(outbuf); xframe.bmp = (void *) GST_BUFFER_DATA (outbuf);
xframe.length = GST_BUFFER_SIZE(buf); xframe.length = GST_BUFFER_SIZE (buf);
xframe.stride = 0; xframe.stride = 0;
xframe.render_flag = 1; xframe.render_flag = 1;
if ((ret = decore(divxdec->handle, DEC_OPT_FRAME, if ((ret = decore (divxdec->handle, DEC_OPT_FRAME, &xframe, NULL))) {
&xframe, NULL))) {
GST_ELEMENT_ERROR (divxdec, STREAM, DECODE, (NULL), GST_ELEMENT_ERROR (divxdec, STREAM, DECODE, (NULL),
("Error decoding divx frame: %s (%d)", ("Error decoding divx frame: %s (%d)", gst_divxdec_error (ret), ret));
gst_divxdec_error(ret), ret)); gst_buffer_unref (buf);
gst_buffer_unref(buf);
return; return;
} }
gst_pad_push(divxdec->srcpad, GST_DATA (outbuf)); gst_pad_push (divxdec->srcpad, GST_DATA (outbuf));
gst_buffer_unref(buf); gst_buffer_unref (buf);
} }
/* FIXME: moved all the bits out here that are broken so the syntax
* stays clear */
/*
{
GST_MAKE_FOURCC ('R', 'G', 'B', ' '), 32, 32,
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
GST_MAKE_FOURCC ('A', 'B', 'G', 'R'), 32}
,
#else
0, 32}
,
#endif
{
GST_MAKE_FOURCC ('R', 'G', 'B', ' '), 24, 24,
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
GST_MAKE_FOURCC ('A', 'B', 'G', 'R'), 24}
,
#else
0, 24}
,
#endif
{
GST_MAKE_FOURCC ('R', 'G', 'B', ' '), 16, 16, 3, 16}
, {
GST_MAKE_FOURCC ('R', 'G', 'B', ' '), 15, 16, 0, 16}
,
#endif
if (fmt_list[i].fourcc == GST_MAKE_FOURCC ('R', 'G', 'B', ' ')) {
guint32 r_mask = 0, b_mask = 0, g_mask = 0;
gint endianness = 0;
switch (fmt_list[i].depth) {
case 15:
endianness = G_BYTE_ORDER;
r_mask = 0xf800;
g_mask = 0x07c0;
b_mask = 0x003e;
break;
case 16:
endianness = G_BYTE_ORDER;
r_mask = 0xf800;
g_mask = 0x07e0;
b_mask = 0x001f;
break;
case 24:
endianness = G_BIG_ENDIAN;
r_mask = GST_VIDEO_BYTE1_MASK_24_INT;
g_mask = GST_VIDEO_BYTE2_MASK_24_INT;
b_mask = GST_VIDEO_BYTE3_MASK_24_INT break;
case 32:
endianness = G_BIG_ENDIAN;
r_mask = GST_VIDEO_BYTE1_MASK_32_INT;
g_mask = GST_VIDEO_BYTE2_MASK_32_INT;
b_mask = GST_VIDEO_BYTE3_MASK_32_INT break;
}
caps = GST_CAPS_NEW ("divxdec_src_pad_rgb",
"video/x-raw-rgb",
"width", GST_PROPS_INT (divxdec->width),
"height", GST_PROPS_INT (divxdec->height),
"framerate", GST_PROPS_FLOAT (divxdec->fps),
"depth", GST_PROPS_INT (fmt_list[i].depth),
"bpp", GST_PROPS_INT (fmt_list[i].bpp),
"endianness", GST_PROPS_INT (endianness),
"red_mask", GST_PROPS_INT (r_mask),
"green_mask", GST_PROPS_INT (g_mask),
"blue_mask", GST_PROPS_INT (b_mask));
} else {
#endif
#endif
*/
static GstPadLinkReturn static GstPadLinkReturn
gst_divxdec_negotiate (GstDivxDec *divxdec) gst_divxdec_negotiate (GstDivxDec * divxdec)
{ {
GstCaps *caps; GstCaps *caps;
struct { struct
{
guint32 fourcc; guint32 fourcc;
gint depth, bpp; gint depth, bpp;
guint32 csp; guint32 csp;
gint bitcnt; gint bitcnt;
} fmt_list[] = { } fmt_list[] = {
{ GST_MAKE_FOURCC('Y','U','Y','2'), 16, 16, {
GST_MAKE_FOURCC('Y','U','Y','2'), 0 }, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'), 16, 16,
{ GST_MAKE_FOURCC('U','Y','V','Y'), 16, 16, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'), 0}, {
GST_MAKE_FOURCC('U','Y','V','Y'), 0 }, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'), 16, 16,
{ GST_MAKE_FOURCC('I','4','2','0'), 12, 12, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'), 0}, {
GST_MAKE_FOURCC('I','4','2','0'), 0 }, GST_MAKE_FOURCC ('I', '4', '2', '0'), 12, 12,
{ GST_MAKE_FOURCC('Y','V','1','2'), 12, 12, GST_MAKE_FOURCC ('I', '4', '2', '0'), 0}, {
GST_MAKE_FOURCC('Y','V','1','2'), 0 }, GST_MAKE_FOURCC ('Y', 'V', '1', '2'), 12, 12,
#if 0 GST_MAKE_FOURCC ('Y', 'V', '1', '2'), 0}, {
/* FIXME: someone fix RGB here please */ 0, 0, 0, 0, 0}
{ GST_MAKE_FOURCC('R','G','B',' '), 32, 32,
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
GST_MAKE_FOURCC('A','B','G','R'), 32 },
#else
0, 32 },
#endif
{ GST_MAKE_FOURCC('R','G','B',' '), 24, 24,
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
GST_MAKE_FOURCC('A','B','G','R'), 24 },
#else
0, 24 },
#endif
{ GST_MAKE_FOURCC('R','G','B',' '), 16, 16,
3, 16 },
{ GST_MAKE_FOURCC('R','G','B',' '), 15, 16,
0, 16 },
#endif
{ 0, 0, 0, 0, 0 }
}; };
gint i; gint i;
for (i = 0; fmt_list[i].fourcc != 0; i++) { for (i = 0; fmt_list[i].fourcc != 0; i++) {
divxdec->csp = fmt_list[i].csp; divxdec->csp = fmt_list[i].csp;
#if 0 caps = gst_caps_new_simple ("video/x-raw-yuv",
/* try making a caps to set on the other side */ "width", G_TYPE_INT, divxdec->width,
if (fmt_list[i].fourcc == GST_MAKE_FOURCC('R','G','B',' ')) { "height", G_TYPE_INT, divxdec->height,
guint32 r_mask = 0, b_mask = 0, g_mask = 0; "framerate", G_TYPE_DOUBLE, divxdec->fps,
gint endianness = 0; "format", GST_TYPE_FOURCC, fmt_list[i].fourcc, NULL);
switch (fmt_list[i].depth) {
case 15:
endianness = G_BYTE_ORDER;
r_mask = 0xf800; g_mask = 0x07c0; b_mask = 0x003e;
break;
case 16:
endianness = G_BYTE_ORDER;
r_mask = 0xf800; g_mask = 0x07e0; b_mask = 0x001f;
break;
case 24:
endianness = G_BIG_ENDIAN;
r_mask = GST_VIDEO_BYTE1_MASK_24_INT;
g_mask = GST_VIDEO_BYTE2_MASK_24_INT;
b_mask = GST_VIDEO_BYTE3_MASK_24_INT
break;
case 32:
endianness = G_BIG_ENDIAN;
r_mask = GST_VIDEO_BYTE1_MASK_32_INT;
g_mask = GST_VIDEO_BYTE2_MASK_32_INT;
b_mask = GST_VIDEO_BYTE3_MASK_32_INT
break;
}
caps = GST_CAPS_NEW("divxdec_src_pad_rgb",
"video/x-raw-rgb",
"width", GST_PROPS_INT(divxdec->width),
"height", GST_PROPS_INT(divxdec->height),
"framerate", GST_PROPS_FLOAT(divxdec->fps),
"depth", GST_PROPS_INT(fmt_list[i].depth),
"bpp", GST_PROPS_INT(fmt_list[i].bpp),
"endianness", GST_PROPS_INT(endianness),
"red_mask", GST_PROPS_INT(r_mask),
"green_mask", GST_PROPS_INT(g_mask),
"blue_mask", GST_PROPS_INT(b_mask));
} else {
#endif
caps = gst_caps_new_simple ("video/x-raw-yuv",
"width", G_TYPE_INT, divxdec->width,
"height", G_TYPE_INT, divxdec->height,
"framerate", G_TYPE_DOUBLE, divxdec->fps,
"format", GST_TYPE_FOURCC, fmt_list[i].fourcc,
NULL);
/*}*/
if (gst_divxdec_setup(divxdec) && if (gst_divxdec_setup (divxdec) &&
gst_pad_set_explicit_caps(divxdec->srcpad, caps)) { gst_pad_set_explicit_caps (divxdec->srcpad, caps)) {
divxdec->csp = fmt_list[i].csp; divxdec->csp = fmt_list[i].csp;
divxdec->bpp = fmt_list[i].bpp; divxdec->bpp = fmt_list[i].bpp;
divxdec->bitcnt = fmt_list[i].bitcnt; divxdec->bitcnt = fmt_list[i].bitcnt;
return GST_PAD_LINK_OK; return GST_PAD_LINK_OK;
} }
@ -428,61 +433,55 @@ gst_divxdec_negotiate (GstDivxDec *divxdec)
static GstPadLinkReturn static GstPadLinkReturn
gst_divxdec_connect (GstPad *pad, gst_divxdec_connect (GstPad * pad, const GstCaps * caps)
const GstCaps *caps)
{ {
GstDivxDec *divxdec; GstDivxDec *divxdec;
GstStructure *structure = gst_caps_get_structure (caps, 0); GstStructure *structure = gst_caps_get_structure (caps, 0);
divxdec = GST_DIVXDEC(gst_pad_get_parent (pad)); divxdec = GST_DIVXDEC (gst_pad_get_parent (pad));
/* if there's something old around, remove it */ /* if there's something old around, remove it */
if (divxdec->handle) { if (divxdec->handle) {
gst_divxdec_unset(divxdec); gst_divxdec_unset (divxdec);
} }
/* we are not going to act on variable caps */ /* we are not going to act on variable caps */
if (!gst_caps_is_fixed(caps)) if (!gst_caps_is_fixed (caps))
return GST_PAD_LINK_DELAYED; return GST_PAD_LINK_DELAYED;
/* if we get here, we know the input is divx. we /* if we get here, we know the input is divx. we
* only need to bother with the output colorspace */ * only need to bother with the output colorspace */
gst_structure_get_int(structure, "width", &divxdec->width); gst_structure_get_int (structure, "width", &divxdec->width);
gst_structure_get_int(structure, "height", &divxdec->height); gst_structure_get_int (structure, "height", &divxdec->height);
gst_structure_get_double(structure, "framerate", &divxdec->fps); gst_structure_get_double (structure, "framerate", &divxdec->fps);
gst_structure_get_int(structure, "divxversion", &divxdec->version); gst_structure_get_int (structure, "divxversion", &divxdec->version);
return gst_divxdec_negotiate(divxdec); return gst_divxdec_negotiate (divxdec);
} }
static gboolean static gboolean
plugin_init (GstPlugin *plugin) plugin_init (GstPlugin * plugin)
{ {
int lib_version; int lib_version;
lib_version = decore(NULL, DEC_OPT_VERSION, 0, 0); lib_version = decore (NULL, DEC_OPT_VERSION, 0, 0);
if (lib_version != DECORE_VERSION) { if (lib_version != DECORE_VERSION) {
g_warning("Version mismatch! This plugin was compiled for " g_warning ("Version mismatch! This plugin was compiled for "
"DivX version %d, while your library has version %d!", "DivX version %d, while your library has version %d!",
DECORE_VERSION, lib_version); DECORE_VERSION, lib_version);
return FALSE; return FALSE;
} }
/* create an elementfactory for the v4lmjpegsrcparse element */ /* create an elementfactory for the v4lmjpegsrcparse element */
return gst_element_register(plugin, "divxdec", return gst_element_register (plugin, "divxdec",
GST_RANK_SECONDARY, GST_TYPE_DIVXDEC); GST_RANK_SECONDARY, GST_TYPE_DIVXDEC);
} }
GST_PLUGIN_DEFINE ( GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MAJOR, GST_VERSION_MINOR,
GST_VERSION_MINOR, "divxdec",
"divxdec", "DivX decoder",
"DivX decoder", plugin_init,
plugin_init, "5.03", GST_LICENSE_UNKNOWN, "divx4linux", "http://www.divx.com/");
"5.03",
GST_LICENSE_UNKNOWN,
"divx4linux",
"http://www.divx.com/"
)

View file

@ -34,39 +34,33 @@ GstElementDetails gst_divxenc_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>" "Ronald Bultje <rbultje@ronald.bitfreak.net>"
}; };
static GstStaticPadTemplate sink_template = static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_PAD_TEMPLATE ( GST_PAD_SINK,
"sink", GST_PAD_ALWAYS,
GST_PAD_SINK, GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }")
GST_PAD_ALWAYS, /* FIXME: 15/16/24/32bpp RGB */
GST_STATIC_CAPS ( )
GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }") );
/* FIXME: 15/16/24/32bpp RGB */
)
);
static GstStaticPadTemplate src_template = static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_PAD_TEMPLATE ( GST_PAD_SRC,
"src", GST_PAD_ALWAYS,
GST_PAD_SRC, GST_STATIC_CAPS ("video/x-divx, "
GST_PAD_ALWAYS, "divxversion = (int) 5, "
GST_STATIC_CAPS ( "width = (int) [ 16, 4096 ], "
"video/x-divx, " "height = (int) [ 16, 4096 ], " "framerate = (double) [ 0, MAX ]")
"divxversion = (int) 5, " );
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ], "
"framerate = (double) [ 0, MAX ]"
)
);
/* DivxEnc signals and args */ /* DivxEnc signals and args */
enum { enum
{
FRAME_ENCODED, FRAME_ENCODED,
LAST_SIGNAL LAST_SIGNAL
}; };
enum { enum
{
ARG_0, ARG_0,
ARG_BITRATE, ARG_BITRATE,
ARG_MAXKEYINTERVAL, ARG_MAXKEYINTERVAL,
@ -75,24 +69,19 @@ enum {
}; };
static void gst_divxenc_class_init (GstDivxEncClass *klass); static void gst_divxenc_class_init (GstDivxEncClass * klass);
static void gst_divxenc_base_init (GstDivxEncClass *klass); static void gst_divxenc_base_init (GstDivxEncClass * klass);
static void gst_divxenc_init (GstDivxEnc *divxenc); static void gst_divxenc_init (GstDivxEnc * divxenc);
static void gst_divxenc_dispose (GObject *object); static void gst_divxenc_dispose (GObject * object);
static void gst_divxenc_chain (GstPad *pad, static void gst_divxenc_chain (GstPad * pad, GstData * data);
GstData *data); static GstPadLinkReturn gst_divxenc_connect (GstPad * pad,
static GstPadLinkReturn gst_divxenc_connect (GstPad *pad, const GstCaps * vscapslist);
const GstCaps *vscapslist);
/* properties */ /* properties */
static void gst_divxenc_set_property (GObject *object, static void gst_divxenc_set_property (GObject * object,
guint prop_id, guint prop_id, const GValue * value, GParamSpec * pspec);
const GValue *value, static void gst_divxenc_get_property (GObject * object,
GParamSpec *pspec); guint prop_id, GValue * value, GParamSpec * pspec);
static void gst_divxenc_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
static guint gst_divxenc_signals[LAST_SIGNAL] = { 0 }; static guint gst_divxenc_signals[LAST_SIGNAL] = { 0 };
@ -132,47 +121,45 @@ gst_divxenc_error (int errorcode)
GType GType
gst_divxenc_get_type(void) gst_divxenc_get_type (void)
{ {
static GType divxenc_type = 0; static GType divxenc_type = 0;
if (!divxenc_type) if (!divxenc_type) {
{
static const GTypeInfo divxenc_info = { static const GTypeInfo divxenc_info = {
sizeof(GstDivxEncClass), sizeof (GstDivxEncClass),
(GBaseInitFunc) gst_divxenc_base_init, (GBaseInitFunc) gst_divxenc_base_init,
NULL, NULL,
(GClassInitFunc) gst_divxenc_class_init, (GClassInitFunc) gst_divxenc_class_init,
NULL, NULL,
NULL, NULL,
sizeof(GstDivxEnc), sizeof (GstDivxEnc),
0, 0,
(GInstanceInitFunc) gst_divxenc_init, (GInstanceInitFunc) gst_divxenc_init,
}; };
divxenc_type = g_type_register_static(GST_TYPE_ELEMENT, divxenc_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstDivxEnc", "GstDivxEnc", &divxenc_info, 0);
&divxenc_info, 0);
} }
return divxenc_type; return divxenc_type;
} }
static void static void
gst_divxenc_base_init (GstDivxEncClass *klass) gst_divxenc_base_init (GstDivxEncClass * klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template)); gst_static_pad_template_get (&sink_template));
gst_element_class_add_pad_template (element_class, gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_template)); gst_static_pad_template_get (&src_template));
gst_element_class_set_details (element_class, &gst_divxenc_details); gst_element_class_set_details (element_class, &gst_divxenc_details);
} }
static void static void
gst_divxenc_class_init (GstDivxEncClass *klass) gst_divxenc_class_init (GstDivxEncClass * klass)
{ {
GstElementClass *gstelement_class; GstElementClass *gstelement_class;
GObjectClass *gobject_class; GObjectClass *gobject_class;
@ -180,27 +167,24 @@ gst_divxenc_class_init (GstDivxEncClass *klass)
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass; gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref(GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BITRATE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
g_param_spec_ulong("bitrate","Bitrate", g_param_spec_ulong ("bitrate", "Bitrate",
"Target video bitrate", "Target video bitrate", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
0,G_MAXULONG,0,G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MAXKEYINTERVAL, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAXKEYINTERVAL,
g_param_spec_int("max_key_interval","Max. Key Interval", g_param_spec_int ("max_key_interval", "Max. Key Interval",
"Maximum number of frames between two keyframes", "Maximum number of frames between two keyframes",
0,G_MAXINT,0,G_PARAM_READWRITE)); 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BUFSIZE, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFSIZE,
g_param_spec_ulong("buffer_size", "Buffer Size", g_param_spec_ulong ("buffer_size", "Buffer Size",
"Size of the video buffers", "Size of the video buffers", 0, G_MAXULONG, 0, G_PARAM_READABLE));
0,G_MAXULONG,0,G_PARAM_READABLE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_QUALITY, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY,
g_param_spec_int("quality", "Quality", g_param_spec_int ("quality", "Quality",
"Amount of Motion Estimation", "Amount of Motion Estimation", 1, 5, 3, G_PARAM_READWRITE));
1,5,3,G_PARAM_READWRITE));
gobject_class->set_property = gst_divxenc_set_property; gobject_class->set_property = gst_divxenc_set_property;
gobject_class->get_property = gst_divxenc_get_property; gobject_class->get_property = gst_divxenc_get_property;
@ -208,37 +192,36 @@ gst_divxenc_class_init (GstDivxEncClass *klass)
gobject_class->dispose = gst_divxenc_dispose; gobject_class->dispose = gst_divxenc_dispose;
gst_divxenc_signals[FRAME_ENCODED] = gst_divxenc_signals[FRAME_ENCODED] =
g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS(klass), g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstDivxEncClass, frame_encoded), G_STRUCT_OFFSET (GstDivxEncClass, frame_encoded),
NULL, NULL, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
} }
static void static void
gst_divxenc_init (GstDivxEnc *divxenc) gst_divxenc_init (GstDivxEnc * divxenc)
{ {
/* create the sink pad */ /* create the sink pad */
divxenc->sinkpad = gst_pad_new_from_template( divxenc->sinkpad =
gst_static_pad_template_get (&sink_template), gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
"sink"); "sink");
gst_element_add_pad(GST_ELEMENT(divxenc), divxenc->sinkpad); gst_element_add_pad (GST_ELEMENT (divxenc), divxenc->sinkpad);
gst_pad_set_chain_function(divxenc->sinkpad, gst_divxenc_chain); gst_pad_set_chain_function (divxenc->sinkpad, gst_divxenc_chain);
gst_pad_set_link_function(divxenc->sinkpad, gst_divxenc_connect); gst_pad_set_link_function (divxenc->sinkpad, gst_divxenc_connect);
/* create the src pad */ /* create the src pad */
divxenc->srcpad = gst_pad_new_from_template( divxenc->srcpad =
gst_static_pad_template_get (&src_template), gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
"src"); "src");
gst_pad_use_explicit_caps (divxenc->srcpad); gst_pad_use_explicit_caps (divxenc->srcpad);
gst_element_add_pad(GST_ELEMENT(divxenc), divxenc->srcpad); gst_element_add_pad (GST_ELEMENT (divxenc), divxenc->srcpad);
/* bitrate, etc. */ /* bitrate, etc. */
divxenc->width = divxenc->height = divxenc->csp = divxenc->bitcnt = -1; divxenc->width = divxenc->height = divxenc->csp = divxenc->bitcnt = -1;
divxenc->bitrate = 512 * 1024; divxenc->bitrate = 512 * 1024;
divxenc->max_key_interval = -1; /* default - 2*fps */ divxenc->max_key_interval = -1; /* default - 2*fps */
divxenc->buffer_size = 512 * 1024; divxenc->buffer_size = 512 * 1024;
divxenc->quality = 3; divxenc->quality = 3;
@ -248,7 +231,7 @@ gst_divxenc_init (GstDivxEnc *divxenc)
static gboolean static gboolean
gst_divxenc_setup (GstDivxEnc *divxenc) gst_divxenc_setup (GstDivxEnc * divxenc)
{ {
void *handle = NULL; void *handle = NULL;
SETTINGS output; SETTINGS output;
@ -256,14 +239,14 @@ gst_divxenc_setup (GstDivxEnc *divxenc)
int ret; int ret;
/* set it up */ /* set it up */
memset(&input, 0, sizeof(DivXBitmapInfoHeader)); memset (&input, 0, sizeof (DivXBitmapInfoHeader));
input.biSize = sizeof(DivXBitmapInfoHeader); input.biSize = sizeof (DivXBitmapInfoHeader);
input.biWidth = divxenc->width; input.biWidth = divxenc->width;
input.biHeight = divxenc->height; input.biHeight = divxenc->height;
input.biBitCount = divxenc->bitcnt; input.biBitCount = divxenc->bitcnt;
input.biCompression = divxenc->csp; input.biCompression = divxenc->csp;
memset(&output, 0, sizeof(SETTINGS)); memset (&output, 0, sizeof (SETTINGS));
output.vbr_mode = RCMODE_VBV_1PASS; output.vbr_mode = RCMODE_VBV_1PASS;
output.bitrate = divxenc->bitrate; output.bitrate = divxenc->bitrate;
output.quantizer = 0; output.quantizer = 0;
@ -272,7 +255,7 @@ gst_divxenc_setup (GstDivxEnc *divxenc)
output.input_frame_period = 1000000; output.input_frame_period = 1000000;
output.internal_timescale = divxenc->fps * 1000000; output.internal_timescale = divxenc->fps * 1000000;
output.max_key_interval = (divxenc->max_key_interval == -1) ? output.max_key_interval = (divxenc->max_key_interval == -1) ?
150 : divxenc->max_key_interval; 150 : divxenc->max_key_interval;
output.key_frame_threshold = 50; output.key_frame_threshold = 50;
output.vbv_bitrate = 0; output.vbv_bitrate = 0;
output.vbv_size = 0; output.vbv_size = 0;
@ -282,7 +265,7 @@ gst_divxenc_setup (GstDivxEnc *divxenc)
output.quality = divxenc->quality; output.quality = divxenc->quality;
output.data_partitioning = 0; output.data_partitioning = 0;
output.quarter_pel = 1; output.quarter_pel = 1;
output.use_gmc = 1; output.use_gmc = 1;
output.psychovisual = 0; output.psychovisual = 0;
output.pv_strength_frame = 0; output.pv_strength_frame = 0;
output.pv_strength_MB = 0; output.pv_strength_MB = 0;
@ -294,10 +277,10 @@ gst_divxenc_setup (GstDivxEnc *divxenc)
output.spatial_level = 1.0; output.spatial_level = 1.0;
output.temporal_level = 1.0; output.temporal_level = 1.0;
if ((ret = encore(&handle, ENC_OPT_INIT, &input, &output))) { if ((ret = encore (&handle, ENC_OPT_INIT, &input, &output))) {
GST_ELEMENT_ERROR (divxenc, LIBRARY, SETTINGS, (NULL), GST_ELEMENT_ERROR (divxenc, LIBRARY, SETTINGS, (NULL),
("Error setting up divx encoder: %s (%d)", ("Error setting up divx encoder: %s (%d)",
gst_divxenc_error(ret), ret)); gst_divxenc_error (ret), ret));
return FALSE; return FALSE;
} }
@ -311,27 +294,26 @@ gst_divxenc_setup (GstDivxEnc *divxenc)
static void static void
gst_divxenc_unset (GstDivxEnc *divxenc) gst_divxenc_unset (GstDivxEnc * divxenc)
{ {
if (divxenc->handle) { if (divxenc->handle) {
encore(divxenc->handle, ENC_OPT_RELEASE, NULL, NULL); encore (divxenc->handle, ENC_OPT_RELEASE, NULL, NULL);
divxenc->handle = NULL; divxenc->handle = NULL;
} }
} }
static void static void
gst_divxenc_dispose (GObject *object) gst_divxenc_dispose (GObject * object)
{ {
GstDivxEnc *divxenc = GST_DIVXENC(object); GstDivxEnc *divxenc = GST_DIVXENC (object);
gst_divxenc_unset(divxenc); gst_divxenc_unset (divxenc);
} }
static void static void
gst_divxenc_chain (GstPad *pad, gst_divxenc_chain (GstPad * pad, GstData * _data)
GstData *_data)
{ {
GstBuffer *buf = GST_BUFFER (_data); GstBuffer *buf = GST_BUFFER (_data);
GstDivxEnc *divxenc; GstDivxEnc *divxenc;
@ -340,97 +322,95 @@ gst_divxenc_chain (GstPad *pad,
ENC_RESULT xres; ENC_RESULT xres;
int ret; int ret;
g_return_if_fail(pad != NULL); g_return_if_fail (pad != NULL);
g_return_if_fail(GST_IS_PAD(pad)); g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail(buf != NULL); g_return_if_fail (buf != NULL);
divxenc = GST_DIVXENC(GST_OBJECT_PARENT(pad)); divxenc = GST_DIVXENC (GST_OBJECT_PARENT (pad));
outbuf = gst_buffer_new_and_alloc(divxenc->buffer_size); outbuf = gst_buffer_new_and_alloc (divxenc->buffer_size);
GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf); GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
/* encode and so ... */ /* encode and so ... */
xframe.image = GST_BUFFER_DATA(buf); xframe.image = GST_BUFFER_DATA (buf);
xframe.bitstream = (void *) GST_BUFFER_DATA(outbuf); xframe.bitstream = (void *) GST_BUFFER_DATA (outbuf);
xframe.length = GST_BUFFER_MAXSIZE(outbuf); xframe.length = GST_BUFFER_MAXSIZE (outbuf);
xframe.produce_empty_frame = 0; xframe.produce_empty_frame = 0;
if ((ret = encore(divxenc->handle, ENC_OPT_ENCODE, if ((ret = encore (divxenc->handle, ENC_OPT_ENCODE, &xframe, &xres))) {
&xframe, &xres))) {
GST_ELEMENT_ERROR (divxenc, LIBRARY, ENCODE, (NULL), GST_ELEMENT_ERROR (divxenc, LIBRARY, ENCODE, (NULL),
("Error encoding divx frame: %s (%d)", ("Error encoding divx frame: %s (%d)", gst_divxenc_error (ret), ret));
gst_divxenc_error(ret), ret)); gst_buffer_unref (buf);
gst_buffer_unref(buf);
return; return;
} }
GST_BUFFER_SIZE(outbuf) = xframe.length; GST_BUFFER_SIZE (outbuf) = xframe.length;
if (xres.cType == 'I') if (xres.cType == 'I')
GST_BUFFER_FLAG_SET(outbuf, GST_BUFFER_KEY_UNIT); GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_KEY_UNIT);
/* go out, multiply! */ /* go out, multiply! */
gst_pad_push(divxenc->srcpad, GST_DATA (outbuf)); gst_pad_push (divxenc->srcpad, GST_DATA (outbuf));
/* proclaim destiny */ /* proclaim destiny */
g_signal_emit(G_OBJECT(divxenc),gst_divxenc_signals[FRAME_ENCODED], 0); g_signal_emit (G_OBJECT (divxenc), gst_divxenc_signals[FRAME_ENCODED], 0);
/* until the final judgement */ /* until the final judgement */
gst_buffer_unref(buf); gst_buffer_unref (buf);
} }
/* FIXME: moving broken bits here for others to fix */
/* someone fix RGB please */
/*
case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
gst_caps_get_int (caps, "depth", &d);
switch (d) {
case 24:
divx_cs = 0;
bitcnt = 24;
break;
case 32:
divx_cs = 0;
bitcnt = 32;
break;
*/
static GstPadLinkReturn static GstPadLinkReturn
gst_divxenc_connect (GstPad *pad, gst_divxenc_connect (GstPad * pad, const GstCaps * caps)
const GstCaps *caps)
{ {
GstDivxEnc *divxenc; GstDivxEnc *divxenc;
GstStructure *structure = gst_caps_get_structure (caps, 0); GstStructure *structure = gst_caps_get_structure (caps, 0);
gint w,h; gint w, h;
gdouble fps; gdouble fps;
guint32 fourcc; guint32 fourcc;
guint32 divx_cs; guint32 divx_cs;
gint bitcnt = 0; gint bitcnt = 0;
divxenc = GST_DIVXENC(gst_pad_get_parent (pad)); divxenc = GST_DIVXENC (gst_pad_get_parent (pad));
/* if there's something old around, remove it */ /* if there's something old around, remove it */
gst_divxenc_unset(divxenc); gst_divxenc_unset (divxenc);
gst_structure_get_int(structure, "width", &w); gst_structure_get_int (structure, "width", &w);
gst_structure_get_int(structure, "height", &h); gst_structure_get_int (structure, "height", &h);
gst_structure_get_double(structure, "framerate", &fps); gst_structure_get_double (structure, "framerate", &fps);
gst_structure_get_fourcc(structure, "format", &fourcc); gst_structure_get_fourcc (structure, "format", &fourcc);
switch (fourcc) { switch (fourcc) {
case GST_MAKE_FOURCC('I','4','2','0'): case GST_MAKE_FOURCC ('I', '4', '2', '0'):
divx_cs = GST_MAKE_FOURCC('I','4','2','0'); divx_cs = GST_MAKE_FOURCC ('I', '4', '2', '0');
break; break;
case GST_MAKE_FOURCC('Y','U','Y','2'): case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
divx_cs = GST_MAKE_FOURCC('Y','U','Y','2'); divx_cs = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
break; break;
case GST_MAKE_FOURCC('Y','V','1','2'): case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
divx_cs = GST_MAKE_FOURCC('Y','V','1','2'); divx_cs = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
break; break;
case GST_MAKE_FOURCC('Y','V','Y','U'): case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
divx_cs = GST_MAKE_FOURCC('Y','V','Y','U'); divx_cs = GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U');
break; break;
case GST_MAKE_FOURCC('U','Y','V','Y'): case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
divx_cs = GST_MAKE_FOURCC('U','Y','V','Y'); divx_cs = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
break; break;
#if 0
/* someone fix RGB please */
case GST_MAKE_FOURCC('R','G','B',' '):
gst_caps_get_int(caps, "depth", &d);
switch (d) {
case 24:
divx_cs = 0;
bitcnt = 24;
break;
case 32:
divx_cs = 0;
bitcnt = 32;
break;
#endif
default: default:
return GST_PAD_LINK_REFUSED; return GST_PAD_LINK_REFUSED;
} }
@ -442,20 +422,18 @@ gst_divxenc_connect (GstPad *pad,
divxenc->fps = fps; divxenc->fps = fps;
/* try it */ /* try it */
if (gst_divxenc_setup(divxenc)) { if (gst_divxenc_setup (divxenc)) {
GstPadLinkReturn ret; GstPadLinkReturn ret;
GstCaps *new_caps; GstCaps *new_caps;
new_caps = gst_caps_new_simple ("video/x-divx", new_caps = gst_caps_new_simple ("video/x-divx",
"divxversion", G_TYPE_INT, 5, "divxversion", G_TYPE_INT, 5,
"width", G_TYPE_INT, w, "width", G_TYPE_INT, w,
"height", G_TYPE_INT, h, "height", G_TYPE_INT, h, "framerate", G_TYPE_DOUBLE, fps, NULL);
"framerate", G_TYPE_DOUBLE, fps,
NULL);
ret = gst_pad_set_explicit_caps (divxenc->srcpad, new_caps); ret = gst_pad_set_explicit_caps (divxenc->srcpad, new_caps);
if (ret <= 0) { if (ret <= 0) {
gst_divxenc_unset(divxenc); gst_divxenc_unset (divxenc);
} }
return ret; return ret;
@ -467,26 +445,24 @@ gst_divxenc_connect (GstPad *pad,
static void static void
gst_divxenc_set_property (GObject *object, gst_divxenc_set_property (GObject * object,
guint prop_id, guint prop_id, const GValue * value, GParamSpec * pspec)
const GValue *value,
GParamSpec *pspec)
{ {
GstDivxEnc *divxenc; GstDivxEnc *divxenc;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_DIVXENC (object)); g_return_if_fail (GST_IS_DIVXENC (object));
divxenc = GST_DIVXENC(object); divxenc = GST_DIVXENC (object);
switch (prop_id) { switch (prop_id) {
case ARG_BITRATE: case ARG_BITRATE:
divxenc->bitrate = g_value_get_ulong(value); divxenc->bitrate = g_value_get_ulong (value);
break; break;
case ARG_MAXKEYINTERVAL: case ARG_MAXKEYINTERVAL:
divxenc->max_key_interval = g_value_get_int(value); divxenc->max_key_interval = g_value_get_int (value);
break; break;
case ARG_QUALITY: case ARG_QUALITY:
divxenc->quality = g_value_get_int(value); divxenc->quality = g_value_get_int (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -496,29 +472,27 @@ gst_divxenc_set_property (GObject *object,
static void static void
gst_divxenc_get_property (GObject *object, gst_divxenc_get_property (GObject * object,
guint prop_id, guint prop_id, GValue * value, GParamSpec * pspec)
GValue *value,
GParamSpec *pspec)
{ {
GstDivxEnc *divxenc; GstDivxEnc *divxenc;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_DIVXENC (object)); g_return_if_fail (GST_IS_DIVXENC (object));
divxenc = GST_DIVXENC(object); divxenc = GST_DIVXENC (object);
switch (prop_id) { switch (prop_id) {
case ARG_BITRATE: case ARG_BITRATE:
g_value_set_ulong(value, divxenc->bitrate); g_value_set_ulong (value, divxenc->bitrate);
break; break;
case ARG_BUFSIZE: case ARG_BUFSIZE:
g_value_set_ulong(value, divxenc->buffer_size); g_value_set_ulong (value, divxenc->buffer_size);
break; break;
case ARG_MAXKEYINTERVAL: case ARG_MAXKEYINTERVAL:
g_value_set_int(value, divxenc->max_key_interval); g_value_set_int (value, divxenc->max_key_interval);
break; break;
case ARG_QUALITY: case ARG_QUALITY:
g_value_set_int(value, divxenc->quality); g_value_set_int (value, divxenc->quality);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -528,32 +502,27 @@ gst_divxenc_get_property (GObject *object,
static gboolean static gboolean
plugin_init (GstPlugin *plugin) plugin_init (GstPlugin * plugin)
{ {
int lib_version; int lib_version;
lib_version = encore(NULL, ENC_OPT_VERSION, 0, 0); lib_version = encore (NULL, ENC_OPT_VERSION, 0, 0);
if (lib_version != ENCORE_VERSION) { if (lib_version != ENCORE_VERSION) {
g_warning("Version mismatch! This plugin was compiled for " g_warning ("Version mismatch! This plugin was compiled for "
"DivX version %d, while your library has version %d!", "DivX version %d, while your library has version %d!",
ENCORE_VERSION, lib_version); ENCORE_VERSION, lib_version);
return FALSE; return FALSE;
} }
/* create an elementfactory for the v4lmjpegsrcparse element */ /* create an elementfactory for the v4lmjpegsrcparse element */
return gst_element_register(plugin, "divxenc", return gst_element_register (plugin, "divxenc",
GST_RANK_PRIMARY, GST_TYPE_DIVXENC); GST_RANK_PRIMARY, GST_TYPE_DIVXENC);
} }
GST_PLUGIN_DEFINE ( GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MAJOR, GST_VERSION_MINOR,
GST_VERSION_MINOR, "divxenc",
"divxenc", "DivX encoder",
"DivX encoder", plugin_init,
plugin_init, "5.03", GST_LICENSE_UNKNOWN, "divx4linux", "http://www.divx.com/");
"5.03",
GST_LICENSE_UNKNOWN,
"divx4linux",
"http://www.divx.com/"
)