mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
ext/xvid/: xvid plugin to support more capabilities of XviD codec.
Original commit message from CVS: Patch by: Mark Nauwelaerts <manauw at skynet dot be> * ext/xvid/gstxvid.c: (gst_xvid_init), (gst_xvid_structure_to_csp), (gst_xvid_csp_to_caps), (gst_xvid_image_get_size), (gst_xvid_image_fill): * ext/xvid/gstxvid.h: * ext/xvid/gstxviddec.c: (gst_xviddec_class_init), (gst_xviddec_init), (gst_xviddec_reset), (gst_xviddec_unset), (gst_xviddec_handle_sink_event), (gst_xviddec_setup), (gst_xviddec_add_par), (gst_xviddec_negotiate), (gst_xviddec_decode), (gst_xviddec_chain), (gst_xviddec_flush_buffers), (gst_xviddec_src_getcaps), (gst_xviddec_src_link), (gst_xviddec_setcaps), (gst_xviddec_change_state): * ext/xvid/gstxviddec.h: * ext/xvid/gstxvidenc.c: (gst_xvidenc_profile_get_type), (gst_xvidenc_quant_type_get_type), (gst_xvidenc_pass_get_type), (gst_xvidenc_get_type), (gst_xvidenc_base_init), (gst_xvidenc_class_init), (gst_xvidenc_init), (gst_xvidenc_finalize), (gst_xvidenc_handle_sink_event), (gst_xvidenc_setup), (gst_xvidenc_setcaps), (gst_xvidenc_encode), (gst_xvidenc_chain), (gst_xvidenc_flush_buffers), (gst_xvidenc_set_property), (gst_xvidenc_get_property), (gst_xvidenc_change_state): * ext/xvid/gstxvidenc.h: xvid plugin to support more capabilities of XviD codec. Fixes #339462. Some more cleanups here and there.
This commit is contained in:
parent
d7195fba1e
commit
39f82f2f19
7 changed files with 1500 additions and 426 deletions
31
ChangeLog
31
ChangeLog
|
@ -1,3 +1,34 @@
|
|||
2006-05-12 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
|
||||
|
||||
* ext/xvid/gstxvid.c: (gst_xvid_init), (gst_xvid_structure_to_csp),
|
||||
(gst_xvid_csp_to_caps), (gst_xvid_image_get_size),
|
||||
(gst_xvid_image_fill):
|
||||
* ext/xvid/gstxvid.h:
|
||||
* ext/xvid/gstxviddec.c: (gst_xviddec_class_init),
|
||||
(gst_xviddec_init), (gst_xviddec_reset), (gst_xviddec_unset),
|
||||
(gst_xviddec_handle_sink_event), (gst_xviddec_setup),
|
||||
(gst_xviddec_add_par), (gst_xviddec_negotiate),
|
||||
(gst_xviddec_decode), (gst_xviddec_chain),
|
||||
(gst_xviddec_flush_buffers), (gst_xviddec_src_getcaps),
|
||||
(gst_xviddec_src_link), (gst_xviddec_setcaps),
|
||||
(gst_xviddec_change_state):
|
||||
* ext/xvid/gstxviddec.h:
|
||||
* ext/xvid/gstxvidenc.c: (gst_xvidenc_profile_get_type),
|
||||
(gst_xvidenc_quant_type_get_type), (gst_xvidenc_pass_get_type),
|
||||
(gst_xvidenc_get_type), (gst_xvidenc_base_init),
|
||||
(gst_xvidenc_class_init), (gst_xvidenc_init),
|
||||
(gst_xvidenc_finalize), (gst_xvidenc_handle_sink_event),
|
||||
(gst_xvidenc_setup), (gst_xvidenc_setcaps), (gst_xvidenc_encode),
|
||||
(gst_xvidenc_chain), (gst_xvidenc_flush_buffers),
|
||||
(gst_xvidenc_set_property), (gst_xvidenc_get_property),
|
||||
(gst_xvidenc_change_state):
|
||||
* ext/xvid/gstxvidenc.h:
|
||||
xvid plugin to support more capabilities of XviD codec.
|
||||
Fixes #339462.
|
||||
Some more cleanups here and there.
|
||||
|
||||
2006-05-11 Edgard Lima <edgard.lima@indt.org.br>
|
||||
|
||||
* sys/v4l2/Makefile.am:
|
||||
|
|
|
@ -42,6 +42,7 @@ gst_xvid_init (void)
|
|||
|
||||
/* set up xvid initially (function pointers, CPU flags) */
|
||||
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;
|
||||
|
@ -87,11 +88,10 @@ gst_xvid_error (int errorcode)
|
|||
}
|
||||
|
||||
gint
|
||||
gst_xvid_structure_to_csp (GstStructure * structure,
|
||||
gint w, gint * _stride, gint * _bpp)
|
||||
gst_xvid_structure_to_csp (GstStructure * structure)
|
||||
{
|
||||
const gchar *mime = gst_structure_get_name (structure);
|
||||
gint xvid_cs = -1, stride = -1, bpp = -1;
|
||||
gint xvid_cs = -1;
|
||||
|
||||
if (!strcmp (mime, "video/x-raw-yuv")) {
|
||||
guint32 fourcc;
|
||||
|
@ -100,32 +100,22 @@ gst_xvid_structure_to_csp (GstStructure * structure,
|
|||
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;
|
||||
gint depth, bpp, r_mask;
|
||||
|
||||
gst_structure_get_int (structure, "depth", &depth);
|
||||
gst_structure_get_int (structure, "bpp", &bpp);
|
||||
|
@ -164,20 +154,15 @@ gst_xvid_structure_to_csp (GstStructure * structure,
|
|||
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, gint fps_n, gint fps_d)
|
||||
gst_xvid_csp_to_caps (gint csp, gint w, gint h)
|
||||
{
|
||||
GstCaps *caps = NULL;
|
||||
GstStructure *structure = NULL;
|
||||
|
||||
switch (csp) {
|
||||
case XVID_CSP_RGB555:
|
||||
|
@ -253,7 +238,7 @@ gst_xvid_csp_to_caps (gint csp, gint w, gint h, gint fps_n, gint fps_d)
|
|||
break;
|
||||
}
|
||||
|
||||
caps = gst_caps_new_simple ("video/x-raw-rgb",
|
||||
structure = gst_structure_new ("video/x-raw-rgb",
|
||||
"width", G_TYPE_INT, w,
|
||||
"height", G_TYPE_INT, h,
|
||||
"depth", G_TYPE_INT, depth,
|
||||
|
@ -261,8 +246,7 @@ gst_xvid_csp_to_caps (gint csp, gint w, gint h, gint fps_n, gint fps_d)
|
|||
"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", GST_TYPE_FRACTION, fps_n, fps_d, NULL);
|
||||
"blue_mask", G_TYPE_INT, b_mask, NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -290,19 +274,87 @@ gst_xvid_csp_to_caps (gint csp, gint w, gint h, gint fps_n, gint fps_d)
|
|||
fourcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
|
||||
break;
|
||||
}
|
||||
caps = gst_caps_new_simple ("video/x-raw-yuv",
|
||||
|
||||
structure = gst_structure_new ("video/x-raw-yuv",
|
||||
"width", G_TYPE_INT, w,
|
||||
"height", G_TYPE_INT, h,
|
||||
"format", GST_TYPE_FOURCC, fourcc,
|
||||
"framerate", GST_TYPE_FRACTION, fps_n, fps_d, NULL);
|
||||
"height", G_TYPE_INT, h, "format", GST_TYPE_FOURCC, fourcc, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return caps;
|
||||
return gst_caps_new_full (structure, NULL);
|
||||
}
|
||||
|
||||
|
||||
gint
|
||||
gst_xvid_image_get_size (gint csp, gint width, gint height)
|
||||
{
|
||||
xvid_image_t dummy_im;
|
||||
|
||||
return gst_xvid_image_fill (&dummy_im, NULL, csp, width, height);
|
||||
}
|
||||
|
||||
gint
|
||||
gst_xvid_image_fill (xvid_image_t * im, void *ptr, gint csp,
|
||||
gint width, gint height)
|
||||
{
|
||||
gint stride, h2, size = 0;
|
||||
|
||||
im->csp = csp;
|
||||
|
||||
switch (csp) {
|
||||
case XVID_CSP_I420:
|
||||
case XVID_CSP_YV12:
|
||||
/* planar */
|
||||
/* luma */
|
||||
stride = GST_ROUND_UP_4 (width);
|
||||
h2 = GST_ROUND_UP_2 (height);
|
||||
im->stride[0] = stride;
|
||||
im->plane[0] = ptr;
|
||||
/* chroma */
|
||||
im->plane[1] = im->plane[0] + (stride * h2);
|
||||
size += stride * height;
|
||||
stride = GST_ROUND_UP_8 (width) / 2;
|
||||
h2 = GST_ROUND_UP_2 (height) / 2;
|
||||
im->stride[1] = stride;
|
||||
|
||||
im->plane[2] = im->plane[1] + (stride * h2);
|
||||
im->stride[2] = stride;
|
||||
size += 2 * (stride * height);
|
||||
break;
|
||||
case XVID_CSP_RGB555:
|
||||
case XVID_CSP_RGB565:
|
||||
case XVID_CSP_YUY2:
|
||||
case XVID_CSP_UYVY:
|
||||
case XVID_CSP_YVYU:
|
||||
/* packed */
|
||||
stride = GST_ROUND_UP_4 (width * 2);
|
||||
im->plane[0] = ptr;
|
||||
im->stride[0] = stride;
|
||||
size = stride * height;
|
||||
break;
|
||||
case XVID_CSP_BGR:
|
||||
stride = GST_ROUND_UP_4 (width * 3);
|
||||
im->plane[0] = ptr;
|
||||
im->stride[0] = stride;
|
||||
size = stride * height * 2;
|
||||
break;
|
||||
case XVID_CSP_ABGR:
|
||||
case XVID_CSP_BGRA:
|
||||
case XVID_CSP_RGBA:
|
||||
#ifdef XVID_CSP_ARGB
|
||||
case XVID_CSP_ARGB:
|
||||
#endif
|
||||
stride = width * 4;
|
||||
im->plane[0] = ptr;
|
||||
im->stride[0] = stride;
|
||||
size = stride * height;
|
||||
break;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ G_BEGIN_DECLS
|
|||
"video/x-raw-rgb, " \
|
||||
"width = (int) [ 0, MAX ], " \
|
||||
"height = (int) [ 0, MAX], " \
|
||||
"framerate = (double) [ 0.0, MAX], " \
|
||||
"framerate = (fraction) [ 0, MAX], " \
|
||||
"depth = (int) 24, " \
|
||||
"bpp = (int) " G_STRINGIFY (bpp) ", " \
|
||||
"endianness = (int) BIG_ENDIAN, " \
|
||||
|
@ -45,10 +45,12 @@ G_BEGIN_DECLS
|
|||
extern gchar * gst_xvid_error (int errorcode);
|
||||
extern gboolean gst_xvid_init (void);
|
||||
|
||||
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,
|
||||
gint fps_n, gint fps_d);
|
||||
extern gint gst_xvid_structure_to_csp (GstStructure *structure);
|
||||
extern GstCaps *gst_xvid_csp_to_caps (gint csp, gint w, gint h);
|
||||
extern gint gst_xvid_image_get_size (gint csp,
|
||||
gint width, gint height);
|
||||
extern gint gst_xvid_image_fill (xvid_image_t * im, void * ptr, gint csp,
|
||||
gint width, gint height);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* GStreamer xvid decoder plugin
|
||||
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
||||
* (C) 2006 Mark Nauwelaerts <manauw@skynet.be>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -17,6 +18,7 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
@ -39,7 +41,7 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
|||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/x-xvid, "
|
||||
"width = (int) [ 0, MAX ], "
|
||||
"height = (int) [ 0, MAX ], " "framerate = (fraction) [0/1, MAX]")
|
||||
"height = (int) [ 0, MAX ], " "framerate = (fraction) [ 0/1, MAX ]")
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
|
@ -68,19 +70,32 @@ enum
|
|||
/* FILL ME */
|
||||
};
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (xviddec_debug);
|
||||
#define GST_CAT_DEFAULT xviddec_debug
|
||||
|
||||
static void gst_xviddec_base_init (GstXvidDecClass * klass);
|
||||
static void gst_xviddec_class_init (GstXvidDecClass * klass);
|
||||
static void gst_xviddec_init (GstXvidDec * xviddec);
|
||||
static void gst_xviddec_reset (GstXvidDec * xviddec);
|
||||
static gboolean gst_xviddec_handle_sink_event (GstPad * pad, GstEvent * event);
|
||||
static GstFlowReturn gst_xviddec_chain (GstPad * pad, GstBuffer * buf);
|
||||
static gboolean gst_xviddec_setcaps (GstPad * pad, GstCaps * caps);
|
||||
static gboolean gst_xviddec_negotiate (GstXvidDec * xviddec);
|
||||
static void gst_xviddec_flush_buffers (GstXvidDec * xviddec, gboolean send);
|
||||
|
||||
#if 0
|
||||
static GstPadLinkReturn
|
||||
gst_xviddec_src_link (GstPad * pad, const GstCaps * vscapslist);
|
||||
*/static GstCaps *gst_xviddec_src_getcaps (GstPad * pad);
|
||||
#endif
|
||||
static GstStateChangeReturn gst_xviddec_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
/* static guint gst_xviddec_signals[LAST_SIGNAL] = { 0 }; */
|
||||
|
||||
|
||||
GType
|
||||
gst_xviddec_get_type (void)
|
||||
{
|
||||
|
@ -121,25 +136,31 @@ gst_xviddec_base_init (GstXvidDecClass * klass)
|
|||
static void
|
||||
gst_xviddec_class_init (GstXvidDecClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
||||
GstElementClass *gstelement_class = (GstElementClass *) klass;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
gstelement_class->change_state = gst_xviddec_change_state;
|
||||
GST_DEBUG_CATEGORY_INIT (xviddec_debug, "xviddec", 0, "XviD decoder");
|
||||
|
||||
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_xviddec_change_state);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gst_xviddec_init (GstXvidDec * xviddec)
|
||||
{
|
||||
gst_xvid_init ();
|
||||
|
||||
/* create the sink pad */
|
||||
xviddec->sinkpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
|
||||
"sink");
|
||||
gst_element_add_pad (GST_ELEMENT (xviddec), xviddec->sinkpad);
|
||||
gst_pad_set_chain_function (xviddec->sinkpad, gst_xviddec_chain);
|
||||
gst_pad_set_setcaps_function (xviddec->sinkpad, gst_xviddec_setcaps);
|
||||
|
||||
gst_pad_set_chain_function (xviddec->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_xviddec_chain));
|
||||
gst_pad_set_setcaps_function (xviddec->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_xviddec_setcaps));
|
||||
gst_pad_set_event_function (xviddec->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_xviddec_handle_sink_event));
|
||||
|
||||
/* create the src pad */
|
||||
xviddec->srcpad =
|
||||
|
@ -148,129 +169,380 @@ gst_xviddec_init (GstXvidDec * xviddec)
|
|||
gst_element_add_pad (GST_ELEMENT (xviddec), xviddec->srcpad);
|
||||
gst_pad_use_fixed_caps (xviddec->srcpad);
|
||||
|
||||
gst_xviddec_reset (xviddec);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gst_xviddec_reset (GstXvidDec * xviddec)
|
||||
{
|
||||
/* size, etc. */
|
||||
xviddec->width = xviddec->height = xviddec->csp = -1;
|
||||
xviddec->fps_n = xviddec->par_n = -1;
|
||||
xviddec->fps_d = xviddec->par_d = 1;
|
||||
xviddec->next_ts = xviddec->next_dur = GST_CLOCK_TIME_NONE;
|
||||
|
||||
/* set xvid handle to NULL */
|
||||
xviddec->handle = NULL;
|
||||
|
||||
/* no delayed timestamp to start with */
|
||||
xviddec->have_ts = FALSE;
|
||||
|
||||
/* need keyframe to get going */
|
||||
xviddec->waiting_for_key = TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gst_xviddec_unset (GstXvidDec * xviddec)
|
||||
{
|
||||
/* unref this instance */
|
||||
/* release XviD decoder */
|
||||
xvid_decore (xviddec->handle, XVID_DEC_DESTROY, NULL, NULL);
|
||||
xviddec->handle = NULL;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gst_xviddec_handle_sink_event (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
GstXvidDec *xviddec = GST_XVIDDEC (GST_PAD_PARENT (pad));
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_EOS:
|
||||
gst_xviddec_flush_buffers (xviddec, TRUE);
|
||||
break;
|
||||
case GST_EVENT_FLUSH_STOP:
|
||||
gst_xviddec_flush_buffers (xviddec, FALSE);
|
||||
break;
|
||||
case GST_EVENT_NEWSEGMENT:
|
||||
/* don't really mind about the actual segment info,
|
||||
* but we do need to recover from this possible jump */
|
||||
/* FIXME, NEWSEGMENT is not a discontinuity. A decoder
|
||||
* should clip the output to the segment boundaries.
|
||||
* Also the rate field of the segment can be used to
|
||||
* optimize the decoding, like skipping B frames when
|
||||
* playing at double speed.
|
||||
* The DISCONT flag on buffers should be used to detect
|
||||
* discontinuities.
|
||||
*/
|
||||
xviddec->waiting_for_key = TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return gst_pad_push_event (xviddec->srcpad, event);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gst_xviddec_setup (GstXvidDec * xviddec)
|
||||
{
|
||||
xvid_dec_create_t xdec;
|
||||
int ret;
|
||||
gint ret;
|
||||
|
||||
/* initialise parameters, see xvid documentation */
|
||||
gst_xvid_init_struct (xdec);
|
||||
xdec.width = xviddec->width;
|
||||
xdec.height = xviddec->height;
|
||||
/* let the decoder handle this, don't trust the container */
|
||||
xdec.width = 0;
|
||||
xdec.height = 0;
|
||||
xdec.handle = NULL;
|
||||
|
||||
if ((ret = xvid_decore (NULL, XVID_DEC_CREATE, &xdec, NULL)) < 0) {
|
||||
GST_ELEMENT_ERROR (xviddec, LIBRARY, SETTINGS, (NULL),
|
||||
("Setting parameters %dx%d@%d failed: %s (%d)",
|
||||
xviddec->width, xviddec->height, xviddec->csp,
|
||||
gst_xvid_error (ret), ret));
|
||||
GST_DEBUG_OBJECT (xviddec,
|
||||
"Initializing xvid decoder with parameters %dx%d@%d failed: %s (%d)",
|
||||
xviddec->width, xviddec->height, xviddec->csp,
|
||||
gst_xvid_error (ret), ret);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xviddec->handle = xdec.handle;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gst_xviddec_add_par (GstStructure * structure,
|
||||
gint mux_par_n, gint mux_par_d, gint dec_par_n, gint dec_par_d)
|
||||
{
|
||||
/* muxer wins if decoder has nothing interesting to offer */
|
||||
if (dec_par_n == dec_par_d) {
|
||||
gst_structure_set (structure, "pixel-aspect-ratio", GST_TYPE_FRACTION,
|
||||
mux_par_n, mux_par_d, NULL);
|
||||
} else {
|
||||
gst_structure_set (structure, "pixel-aspect-ratio", GST_TYPE_FRACTION,
|
||||
dec_par_n, dec_par_d, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* based on the decoder info, if provided, and xviddec info,
|
||||
construct a caps and send on to src pad */
|
||||
static gboolean
|
||||
gst_xviddec_negotiate (GstXvidDec * xviddec, xvid_dec_stats_t * xstats)
|
||||
{
|
||||
gint par_width, par_height;
|
||||
GstCaps *caps;
|
||||
|
||||
/* note: setcaps call with no xstats info,
|
||||
so definitely need to negotiate then */
|
||||
if (xstats && (xstats->type != XVID_TYPE_VOL
|
||||
|| (xstats->type == XVID_TYPE_VOL
|
||||
&& xviddec->width == xstats->data.vol.width
|
||||
&& xviddec->height == xstats->data.vol.height)))
|
||||
return TRUE;
|
||||
|
||||
switch (xstats ? xstats->data.vol.par : XVID_PAR_11_VGA) {
|
||||
case XVID_PAR_11_VGA:
|
||||
par_width = par_height = 1;
|
||||
break;
|
||||
case XVID_PAR_43_PAL:
|
||||
case XVID_PAR_43_NTSC:
|
||||
par_width = 4;
|
||||
par_height = 3;
|
||||
break;
|
||||
case XVID_PAR_169_PAL:
|
||||
case XVID_PAR_169_NTSC:
|
||||
par_width = 16;
|
||||
par_height = 9;
|
||||
break;
|
||||
case XVID_PAR_EXT:
|
||||
default:
|
||||
par_width = xstats->data.vol.par_width;
|
||||
par_height = xstats->data.vol.par_height;
|
||||
}
|
||||
|
||||
caps = gst_xvid_csp_to_caps (xviddec->csp, xviddec->width, xviddec->height);
|
||||
|
||||
/* can only provide framerate if we received one */
|
||||
if (xviddec->fps_n != -1) {
|
||||
gst_structure_set (gst_caps_get_structure (caps, 0), "framerate",
|
||||
GST_TYPE_FRACTION, xviddec->fps_n, xviddec->fps_d, NULL);
|
||||
}
|
||||
|
||||
gst_xviddec_add_par (gst_caps_get_structure (caps, 0),
|
||||
xviddec->par_n, xviddec->par_d, par_width, par_height);
|
||||
|
||||
return gst_pad_set_caps (xviddec->srcpad, caps);
|
||||
}
|
||||
|
||||
|
||||
/* decodes frame according to info in xframe;
|
||||
- outbuf must not be NULL
|
||||
- xstats can be NULL, if not, it has been init'ed
|
||||
- output placed in outbuf, which is also allocated if NULL,
|
||||
caller must unref when needed
|
||||
- xvid stats placed in xstats, if not NULL
|
||||
- xvid return code is returned, which is usually the size of the output frame
|
||||
*/
|
||||
static gint
|
||||
gst_xviddec_decode (GstXvidDec * xviddec, xvid_dec_frame_t xframe,
|
||||
GstBuffer ** outbuf, xvid_dec_stats_t * xstats)
|
||||
{
|
||||
|
||||
g_return_val_if_fail (outbuf, -1);
|
||||
|
||||
if (!*outbuf) {
|
||||
gint size = gst_xvid_image_get_size (xviddec->csp,
|
||||
xviddec->width, xviddec->height);
|
||||
|
||||
gst_pad_alloc_buffer (xviddec->srcpad, GST_BUFFER_OFFSET_NONE, size,
|
||||
GST_PAD_CAPS (xviddec->srcpad), outbuf);
|
||||
}
|
||||
|
||||
gst_xvid_image_fill (&xframe.output, GST_BUFFER_DATA (*outbuf),
|
||||
xviddec->csp, xviddec->width, xviddec->height);
|
||||
|
||||
GST_DEBUG_OBJECT (xviddec, "decoding into buffer %" GST_PTR_FORMAT
|
||||
", data %" GST_PTR_FORMAT ", %" GST_PTR_FORMAT, *outbuf,
|
||||
GST_BUFFER_MALLOCDATA (*outbuf), GST_BUFFER_DATA (*outbuf));
|
||||
|
||||
return xvid_decore (xviddec->handle, XVID_DEC_DECODE, &xframe, xstats);
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_xviddec_chain (GstPad * pad, GstBuffer * buf)
|
||||
{
|
||||
GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad));
|
||||
GstXvidDec *xviddec;
|
||||
GstBuffer *outbuf = NULL;
|
||||
xvid_dec_frame_t xframe;
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
guint bufsize;
|
||||
int error = 0;
|
||||
xvid_dec_stats_t xstats;
|
||||
gint ret;
|
||||
guint8 *data;
|
||||
guint size;
|
||||
GstFlowReturn fret;
|
||||
|
||||
if (xviddec->handle == NULL) {
|
||||
if (!gst_xviddec_negotiate (xviddec))
|
||||
goto not_negotiated;
|
||||
xviddec = GST_XVIDDEC (GST_OBJECT_PARENT (pad));
|
||||
|
||||
if (!xviddec->handle)
|
||||
goto not_negotiated;
|
||||
|
||||
fret = GST_FLOW_OK;
|
||||
|
||||
GST_DEBUG_OBJECT (xviddec,
|
||||
"Received buffer of time %" GST_TIME_FORMAT ", size %d",
|
||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_BUFFER_SIZE (buf));
|
||||
|
||||
data = GST_BUFFER_DATA (buf);
|
||||
size = GST_BUFFER_SIZE (buf);
|
||||
|
||||
do { /* loop needed because xvidcore may return vol information */
|
||||
/* decode and so ... */
|
||||
gst_xvid_init_struct (xframe);
|
||||
xframe.general = XVID_LOWDELAY;
|
||||
xframe.bitstream = (void *) data;
|
||||
xframe.length = size;
|
||||
|
||||
gst_xvid_init_struct (xstats);
|
||||
|
||||
if ((ret = gst_xviddec_decode (xviddec, xframe, &outbuf, &xstats)) < 0)
|
||||
goto decode_error;
|
||||
|
||||
GST_DEBUG_OBJECT (xviddec, "xvid produced output, type %d, consumed %d",
|
||||
xstats.type, ret);
|
||||
|
||||
if (xstats.type == XVID_TYPE_VOL)
|
||||
gst_xviddec_negotiate (xviddec, &xstats);
|
||||
|
||||
data += ret;
|
||||
size -= ret;
|
||||
} while (xstats.type <= 0 && size > 0);
|
||||
|
||||
if (size > 1) /* 1 byte is frequently left over */
|
||||
GST_WARNING_OBJECT (xviddec,
|
||||
"xvid decoder returned frame without consuming all input");
|
||||
|
||||
/* FIXME, reflow the multiple return exit points */
|
||||
if (xstats.type > 0) { /* some real output was produced */
|
||||
if (G_UNLIKELY (xviddec->waiting_for_key)) {
|
||||
if (xstats.type != XVID_TYPE_IVOP)
|
||||
goto dropping;
|
||||
|
||||
xviddec->waiting_for_key = FALSE;
|
||||
}
|
||||
/* bframes can cause a delay in frames being returned
|
||||
non keyframe timestamps can permute a bit between
|
||||
encode and display order, but should match for keyframes */
|
||||
if (xviddec->have_ts) {
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = xviddec->next_ts;
|
||||
GST_BUFFER_DURATION (outbuf) = xviddec->next_dur;
|
||||
xviddec->next_ts = GST_BUFFER_TIMESTAMP (buf);
|
||||
xviddec->next_dur = GST_BUFFER_DURATION (buf);
|
||||
} else {
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
|
||||
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
|
||||
}
|
||||
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (xviddec->srcpad));
|
||||
|
||||
fret = gst_pad_push (xviddec->srcpad, outbuf);
|
||||
|
||||
} else { /* no real output yet, delay in frames being returned */
|
||||
if (G_UNLIKELY (xviddec->have_ts)) {
|
||||
GST_WARNING_OBJECT (xviddec,
|
||||
"xvid decoder produced no output, but timestamp %" GST_TIME_FORMAT
|
||||
" already queued", GST_TIME_ARGS (xviddec->next_ts));
|
||||
} else {
|
||||
xviddec->have_ts = TRUE;
|
||||
xviddec->next_ts = GST_BUFFER_TIMESTAMP (buf);
|
||||
xviddec->next_dur = GST_BUFFER_TIMESTAMP (buf);
|
||||
}
|
||||
gst_buffer_unref (outbuf);
|
||||
}
|
||||
|
||||
bufsize = (xviddec->width * xviddec->height * xviddec->bpp / 8);
|
||||
done:
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
outbuf = gst_buffer_new_and_alloc (bufsize);
|
||||
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
|
||||
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
|
||||
GST_BUFFER_SIZE (outbuf) = bufsize;
|
||||
|
||||
/* decode and so ... */
|
||||
gst_xvid_init_struct (xframe);
|
||||
xframe.general = XVID_LOWDELAY;
|
||||
xframe.bitstream = (void *) GST_BUFFER_DATA (buf);
|
||||
xframe.length = GST_BUFFER_SIZE (buf);
|
||||
xframe.output.csp = xviddec->csp;
|
||||
if (xviddec->width == xviddec->stride) {
|
||||
xframe.output.plane[0] = GST_BUFFER_DATA (outbuf);
|
||||
xframe.output.plane[1] =
|
||||
xframe.output.plane[0] + (xviddec->width * xviddec->height);
|
||||
xframe.output.plane[2] =
|
||||
xframe.output.plane[1] + (xviddec->width * xviddec->height / 4);
|
||||
xframe.output.stride[0] = xviddec->width;
|
||||
xframe.output.stride[1] = xviddec->width / 2;
|
||||
xframe.output.stride[2] = xviddec->width / 2;
|
||||
} else {
|
||||
xframe.output.plane[0] = GST_BUFFER_DATA (outbuf);
|
||||
xframe.output.stride[0] = xviddec->stride;
|
||||
}
|
||||
|
||||
if ((error =
|
||||
xvid_decore (xviddec->handle, XVID_DEC_DECODE, &xframe, NULL)) < 0) {
|
||||
goto not_decoding;
|
||||
}
|
||||
|
||||
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (xviddec->srcpad));
|
||||
ret = gst_pad_push (xviddec->srcpad, outbuf);
|
||||
|
||||
goto cleanup;
|
||||
return fret;
|
||||
|
||||
/* ERRORS */
|
||||
not_negotiated:
|
||||
{
|
||||
GST_ELEMENT_ERROR (xviddec, CORE, NEGOTIATION, (NULL),
|
||||
("format wasn't negotiated before chain function"));
|
||||
ret = GST_FLOW_NOT_NEGOTIATED;
|
||||
goto cleanup;
|
||||
fret = GST_FLOW_NOT_NEGOTIATED;
|
||||
goto done;
|
||||
}
|
||||
|
||||
not_decoding:
|
||||
decode_error:
|
||||
{
|
||||
GST_ELEMENT_ERROR (xviddec, STREAM, DECODE, (NULL),
|
||||
("Error decoding xvid frame: %s (%d)\n", gst_xvid_error (error),
|
||||
error));
|
||||
gst_buffer_unref (outbuf);
|
||||
ret = GST_FLOW_ERROR;
|
||||
goto cleanup;
|
||||
GST_ELEMENT_WARNING (xviddec, STREAM, DECODE, (NULL),
|
||||
("Error decoding xvid frame: %s (%d)", gst_xvid_error (ret), ret));
|
||||
if (outbuf)
|
||||
gst_buffer_unref (outbuf);
|
||||
goto done;
|
||||
}
|
||||
dropping:
|
||||
{
|
||||
GST_WARNING_OBJECT (xviddec, "Dropping non-keyframe (seek/init)");
|
||||
if (outbuf)
|
||||
gst_buffer_unref (outbuf);
|
||||
goto done;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
||||
gst_buffer_unref (buf);
|
||||
gst_object_unref (xviddec);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_xviddec_negotiate (GstXvidDec * xviddec)
|
||||
|
||||
/* flush xvid encoder buffers caused by bframe usage;
|
||||
not well tested */
|
||||
static void
|
||||
gst_xviddec_flush_buffers (GstXvidDec * xviddec, gboolean send)
|
||||
{
|
||||
#if 0
|
||||
gint ret;
|
||||
GstBuffer *outbuf = NULL;
|
||||
xvid_dec_frame_t xframe;
|
||||
xvid_dec_stats_t xstats;
|
||||
#endif
|
||||
|
||||
GST_DEBUG_OBJECT (xviddec, "flushing buffers with send %d, have_ts %d",
|
||||
send, xviddec->have_ts);
|
||||
|
||||
/* no need to flush if there is no delayed time-stamp */
|
||||
if (!xviddec->have_ts)
|
||||
return;
|
||||
|
||||
/* flushing must reset the timestamp keeping */
|
||||
xviddec->have_ts = FALSE;
|
||||
|
||||
/* also no need to flush if no handle */
|
||||
if (!xviddec->handle)
|
||||
return;
|
||||
|
||||
/* unlike encoder, decoder does not seem to like flushing, disable for now */
|
||||
#if 0
|
||||
gst_xvid_init_struct (xframe);
|
||||
gst_xvid_init_struct (xstats);
|
||||
|
||||
/* init a fake frame to force flushing */
|
||||
xframe.bitstream = NULL;
|
||||
xframe.length = -1;
|
||||
|
||||
ret = gst_xviddec_decode (xviddec, xframe, &outbuf, &xstats);
|
||||
GST_DEBUG_OBJECT (xviddec, "received frame when flushing, type %d, size %d",
|
||||
xstats.type, ret);
|
||||
|
||||
if (ret > 0 && send) {
|
||||
/* we have some valid return frame, give it the delayed timestamp and send */
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = xviddec->next_ts;
|
||||
GST_BUFFER_DURATION (outbuf) = xviddec->next_dur;
|
||||
|
||||
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (xviddec->srcpad));
|
||||
gst_pad_push (xviddec->srcpad, outbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (outbuf)
|
||||
gst_buffer_unref (outbuf);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
static GstCaps *
|
||||
gst_xviddec_src_getcaps (GstPad * pad)
|
||||
{
|
||||
GstXvidDec *xviddec = GST_XVIDDEC (GST_PAD_PARENT (pad));
|
||||
GstCaps *caps;
|
||||
gint csp[] = {
|
||||
XVID_CSP_I420,
|
||||
XVID_CSP_YV12,
|
||||
|
@ -289,75 +561,125 @@ gst_xviddec_negotiate (GstXvidDec * xviddec)
|
|||
0
|
||||
}, i;
|
||||
|
||||
for (i = 0; csp[i] != 0; i++) {
|
||||
GstCaps *one = gst_xvid_csp_to_caps (csp[i], xviddec->width,
|
||||
xviddec->height, xviddec->fps_n, xviddec->fps_d);
|
||||
|
||||
if (one) {
|
||||
|
||||
if (gst_pad_set_caps (xviddec->srcpad, one)) {
|
||||
GstStructure *structure = gst_caps_get_structure (one, 0);
|
||||
|
||||
xviddec->csp = gst_xvid_structure_to_csp (structure, xviddec->width,
|
||||
&xviddec->stride, &xviddec->bpp);
|
||||
|
||||
if (xviddec->csp < 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
gst_caps_unref (one);
|
||||
|
||||
}
|
||||
if (!GST_PAD_CAPS (xviddec->sinkpad)) {
|
||||
GstPadTemplate *templ = gst_static_pad_template_get (&src_template);
|
||||
|
||||
return gst_caps_copy (gst_pad_template_get_caps (templ));
|
||||
}
|
||||
|
||||
gst_xviddec_setup (xviddec);
|
||||
return TRUE;
|
||||
caps = gst_caps_new_empty ();
|
||||
for (i = 0; csp[i] != 0; i++) {
|
||||
GstCaps *one = gst_xvid_csp_to_caps (csp[i], xviddec->width,
|
||||
xviddec->height, xviddec->fps, xviddec->par);
|
||||
|
||||
gst_caps_append (caps, one);
|
||||
}
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
|
||||
static GstPadLinkReturn
|
||||
gst_xviddec_src_link (GstPad * pad, const GstCaps * vscaps)
|
||||
{
|
||||
GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad));
|
||||
GstStructure *structure = gst_caps_get_structure (vscaps, 0);
|
||||
|
||||
if (!GST_PAD_CAPS (xviddec->sinkpad))
|
||||
return GST_PAD_LINK_DELAYED;
|
||||
|
||||
/* if there's something old around, remove it */
|
||||
if (xviddec->handle) {
|
||||
gst_xviddec_unset (xviddec);
|
||||
}
|
||||
xviddec->csp = gst_xvid_structure_to_csp (structure);
|
||||
|
||||
if (xviddec->csp < 0)
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
|
||||
if (!gst_xviddec_setup (xviddec))
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
|
||||
return GST_PAD_LINK_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
gst_xviddec_setcaps (GstPad * pad, GstCaps * caps)
|
||||
{
|
||||
GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad));
|
||||
GstXvidDec *xviddec = GST_XVIDDEC (GST_PAD_PARENT (pad));
|
||||
GstStructure *structure;
|
||||
const GValue *fps;
|
||||
gboolean ret = FALSE;
|
||||
const GValue *val;
|
||||
|
||||
GST_DEBUG ("setcaps called");
|
||||
|
||||
/* if there's something old around, remove it */
|
||||
if (xviddec->handle) {
|
||||
gst_xviddec_unset (xviddec);
|
||||
}
|
||||
|
||||
if (!gst_pad_set_caps (xviddec->srcpad, caps)) {
|
||||
ret = FALSE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* if we get here, we know the input is xvid. we
|
||||
* only need to bother with the output colorspace,
|
||||
* which the src_link function takes care of. */
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
gst_structure_get_int (structure, "width", &xviddec->width);
|
||||
gst_structure_get_int (structure, "height", &xviddec->height);
|
||||
|
||||
fps = gst_structure_get_value (structure, "framerate");
|
||||
if (fps != NULL) {
|
||||
xviddec->fps_n = gst_value_get_fraction_numerator (fps);
|
||||
xviddec->fps_d = gst_value_get_fraction_denominator (fps);
|
||||
/* perhaps some fps info */
|
||||
val = gst_structure_get_value (structure, "framerate");
|
||||
if ((val != NULL) && GST_VALUE_HOLDS_FRACTION (val)) {
|
||||
xviddec->fps_n = gst_value_get_fraction_numerator (val);
|
||||
xviddec->fps_d = gst_value_get_fraction_denominator (val);
|
||||
} else {
|
||||
xviddec->fps_n = -1;
|
||||
xviddec->fps_d = 1;
|
||||
}
|
||||
|
||||
ret = gst_xviddec_negotiate (xviddec);
|
||||
/* perhaps some par info */
|
||||
val = gst_structure_get_value (structure, "pixel-aspect-ratio");
|
||||
if ((val != NULL) && GST_VALUE_HOLDS_FRACTION (val)) {
|
||||
xviddec->par_n = gst_value_get_fraction_numerator (val);
|
||||
xviddec->par_d = gst_value_get_fraction_denominator (val);
|
||||
} else {
|
||||
xviddec->par_n = 1;
|
||||
xviddec->par_d = 1;
|
||||
}
|
||||
|
||||
done:
|
||||
gst_object_unref (xviddec);
|
||||
if (gst_xviddec_setup (xviddec)) {
|
||||
GstCaps *allowed_caps;
|
||||
|
||||
return ret;
|
||||
/* we try to find the preferred/accept csp */
|
||||
allowed_caps = gst_pad_get_allowed_caps (xviddec->srcpad);
|
||||
if (!allowed_caps) {
|
||||
GST_DEBUG_OBJECT (xviddec, "... but no peer, using template caps");
|
||||
/* need to copy because get_allowed_caps returns a ref,
|
||||
and get_pad_template_caps doesn't */
|
||||
allowed_caps =
|
||||
gst_caps_copy (gst_pad_get_pad_template_caps (xviddec->srcpad));
|
||||
}
|
||||
/* pick the first one ... */
|
||||
structure = gst_caps_get_structure (allowed_caps, 0);
|
||||
val = gst_structure_get_value (structure, "format");
|
||||
if (G_VALUE_TYPE (val) == GST_TYPE_LIST) {
|
||||
GValue temp = { 0 };
|
||||
gst_value_init_and_copy (&temp, gst_value_list_get_value (val, 0));
|
||||
gst_structure_set_value (structure, "format", &temp);
|
||||
g_value_unset (&temp);
|
||||
}
|
||||
|
||||
/* ... and use its info to get the csp */
|
||||
xviddec->csp = gst_xvid_structure_to_csp (structure);
|
||||
if (xviddec->csp == -1) {
|
||||
gchar *sstr = gst_structure_to_string (structure);
|
||||
|
||||
GST_INFO_OBJECT (xviddec,
|
||||
"failed to decide upon csp from caps %s, trying I420", sstr);
|
||||
g_free (sstr);
|
||||
xviddec->csp = XVID_CSP_I420;
|
||||
}
|
||||
gst_caps_unref (allowed_caps);
|
||||
|
||||
return gst_xviddec_negotiate (xviddec, NULL);
|
||||
|
||||
} else /* setup did not work out */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
|
@ -368,28 +690,29 @@ gst_xviddec_change_state (GstElement * element, GstStateChange transition)
|
|||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||
if (!gst_xvid_init ())
|
||||
return GST_STATE_CHANGE_FAILURE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ret = parent_class->change_state (element, transition);
|
||||
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||
if (ret == GST_STATE_CHANGE_FAILURE)
|
||||
goto done;
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
gst_xviddec_flush_buffers (xviddec, FALSE);
|
||||
if (xviddec->handle) {
|
||||
gst_xviddec_unset (xviddec);
|
||||
}
|
||||
break;
|
||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||
gst_xviddec_reset (xviddec);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -23,10 +23,7 @@
|
|||
#include <gst/gst.h>
|
||||
#include "gstxvid.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_XVIDDEC \
|
||||
(gst_xviddec_get_type())
|
||||
|
@ -52,9 +49,16 @@ struct _GstXvidDec {
|
|||
void *handle;
|
||||
|
||||
/* video (output) settings */
|
||||
gint csp, bpp, stride;
|
||||
gint csp;
|
||||
gint width, height;
|
||||
gint fps_n, fps_d;
|
||||
gint fps_n, fps_d, par_n, par_d;
|
||||
|
||||
/* whether in need for keyframe */
|
||||
gboolean waiting_for_key;
|
||||
|
||||
/* retain some info on delayed frame */
|
||||
gboolean have_ts;
|
||||
GstClockTime next_ts, next_dur;
|
||||
};
|
||||
|
||||
struct _GstXvidDecClass {
|
||||
|
@ -63,8 +67,6 @@ struct _GstXvidDecClass {
|
|||
|
||||
GType gst_xviddec_get_type(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_XVIDDEC_H__ */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,10 +23,7 @@
|
|||
#include <gst/gst.h>
|
||||
#include "gstxvid.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_XVIDENC \
|
||||
(gst_xvidenc_get_type())
|
||||
|
@ -48,24 +45,84 @@ struct _GstXvidEnc {
|
|||
/* pads */
|
||||
GstPad *sinkpad, *srcpad;
|
||||
|
||||
/* xvid handle */
|
||||
void *handle;
|
||||
|
||||
/* cache in place */
|
||||
xvid_enc_frame_t *xframe_cache;
|
||||
|
||||
/* caps information */
|
||||
gint csp;
|
||||
gint width, height;
|
||||
gint fbase;
|
||||
gint fincr;
|
||||
gint par_width;
|
||||
gint par_height;
|
||||
|
||||
/* delayed buffers if bframe usage */
|
||||
GQueue *delay;
|
||||
|
||||
/* encoding profile */
|
||||
gint profile;
|
||||
|
||||
/* quantizer type; h263, MPEG */
|
||||
gint quant_type;
|
||||
|
||||
/* encoding type; cbr, vbr, quant */
|
||||
gint pass;
|
||||
|
||||
/* quality of encoded image */
|
||||
gint bitrate;
|
||||
gint buffer_size;
|
||||
gint quant;
|
||||
|
||||
/* max number of B frames between I/P */
|
||||
gint max_b_frames;
|
||||
|
||||
/* max key interval */
|
||||
/* gop */
|
||||
gint max_key_interval;
|
||||
gboolean closed_gop;
|
||||
|
||||
/* xvid handle */
|
||||
void *handle;
|
||||
gint csp;
|
||||
gint width, height, stride;
|
||||
gint fps_n, fps_d;
|
||||
/* motion estimation */
|
||||
gint motion;
|
||||
gboolean me_chroma;
|
||||
gint me_vhq;
|
||||
gboolean me_quarterpel;
|
||||
|
||||
/* lumimasking */
|
||||
gboolean lumimasking;
|
||||
|
||||
/* b-frames */
|
||||
gint max_bframes;
|
||||
gint bquant_ratio;
|
||||
gint bquant_offset;
|
||||
gint bframe_threshold;
|
||||
|
||||
/* misc */
|
||||
gboolean gmc;
|
||||
gboolean trellis;
|
||||
gboolean interlaced;
|
||||
gboolean cartoon;
|
||||
gboolean greyscale;
|
||||
gboolean hqacpred;
|
||||
|
||||
/* quantizer ranges */
|
||||
gint max_iquant, min_iquant;
|
||||
gint max_pquant, min_pquant;
|
||||
gint max_bquant, min_bquant;
|
||||
|
||||
/* cbr (single pass) encoding */
|
||||
gint reaction_delay_factor;
|
||||
gint averaging_period;
|
||||
gint buffer;
|
||||
|
||||
/* vbr (2pass) encoding */
|
||||
gchar *filename;
|
||||
gint keyframe_boost;
|
||||
gint curve_compression_high;
|
||||
gint curve_compression_low;
|
||||
gint overflow_control_strength;
|
||||
gint max_overflow_improvement;
|
||||
gint max_overflow_degradation;
|
||||
gint kfreduction;
|
||||
gint kfthreshold;
|
||||
gint container_frame_overhead;
|
||||
};
|
||||
|
||||
struct _GstXvidEncClass {
|
||||
|
@ -77,8 +134,6 @@ struct _GstXvidEncClass {
|
|||
|
||||
GType gst_xvidenc_get_type(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_XVIDENC_H__ */
|
||||
|
|
Loading…
Reference in a new issue