mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
vdpau: implement downstream caps negotiation
This commit is contained in:
parent
05908cd130
commit
f2eea7d0ed
6 changed files with 577 additions and 82 deletions
|
@ -1,7 +1,8 @@
|
||||||
plugin_LTLIBRARIES = libgstvdpau.la
|
plugin_LTLIBRARIES = libgstvdpau.la
|
||||||
|
|
||||||
libgstvdpau_la_SOURCES = \
|
libgstvdpau_la_SOURCES = \
|
||||||
gstvdpaudecoder.c
|
gstvdpaudecoder.c\
|
||||||
|
gstvdpauh264decoder.c
|
||||||
|
|
||||||
libgstvdpau_la_CFLAGS = $(GST_CFLAGS) $(X11_CFLAGS) -Ivdpau
|
libgstvdpau_la_CFLAGS = $(GST_CFLAGS) $(X11_CFLAGS) -Ivdpau
|
||||||
libgstvdpau_la_LIBADD = $(GST_LIBS) $(X11_LIBS) -lvdpau
|
libgstvdpau_la_LIBADD = $(GST_LIBS) $(X11_LIBS) -lvdpau
|
||||||
|
@ -9,6 +10,8 @@ libgstvdpau_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||||
libgstvdpau_la_LIBTOOLFLAGS = --tag=disable-static
|
libgstvdpau_la_LIBTOOLFLAGS = --tag=disable-static
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
gstvdpaudecoder.h
|
gstvdpaudecoder.h\
|
||||||
|
vdpauvariables.h \
|
||||||
|
gstvdpauh264decoder.h
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <vdpau/vdpau_x11.h>
|
#include <vdpau/vdpau_x11.h>
|
||||||
|
|
||||||
|
#include "vdpauvariables.h"
|
||||||
#include "gstvdpaudecoder.h"
|
#include "gstvdpaudecoder.h"
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_vdpaudecoder_debug);
|
GST_DEBUG_CATEGORY_STATIC (gst_vdpaudecoder_debug);
|
||||||
|
@ -61,7 +63,7 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
#define DEBUG_INIT(bla) \
|
#define DEBUG_INIT(bla) \
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_vdpaudecoder_debug, "vdpaudecoder", 0, "vdpaudecoder base class");
|
GST_DEBUG_CATEGORY_INIT (gst_vdpaudecoder_debug, "vdpaudecoder", 0, "vdpaudecoder base class");
|
||||||
|
|
||||||
GST_BOILERPLATE_FULL (GstVDPAUDecoder, gst_vdpaudecoder, GstElement,
|
GST_BOILERPLATE_FULL (GstVdpauDecoder, gst_vdpaudecoder, GstElement,
|
||||||
GST_TYPE_ELEMENT, DEBUG_INIT);
|
GST_TYPE_ELEMENT, DEBUG_INIT);
|
||||||
|
|
||||||
static void gst_vdpaudecoder_set_property (GObject * object, guint prop_id,
|
static void gst_vdpaudecoder_set_property (GObject * object, guint prop_id,
|
||||||
|
@ -69,8 +71,213 @@ static void gst_vdpaudecoder_set_property (GObject * object, guint prop_id,
|
||||||
static void gst_vdpaudecoder_get_property (GObject * object, guint prop_id,
|
static void gst_vdpaudecoder_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static GstStateChangeReturn gst_vdpaudecoder_change_state (GstElement * element,
|
typedef struct
|
||||||
GstStateChange transition);
|
{
|
||||||
|
VdpChromaType chroma_type;
|
||||||
|
VdpYCbCrFormat format;
|
||||||
|
guint32 fourcc;
|
||||||
|
} VdpauFormats;
|
||||||
|
|
||||||
|
static VdpChromaType chroma_types[3] =
|
||||||
|
{ VDP_CHROMA_TYPE_420, VDP_CHROMA_TYPE_422, VDP_CHROMA_TYPE_444 };
|
||||||
|
static VdpauFormats formats[6] = {
|
||||||
|
{
|
||||||
|
VDP_CHROMA_TYPE_420,
|
||||||
|
VDP_YCBCR_FORMAT_NV12,
|
||||||
|
GST_MAKE_FOURCC ('N', 'V', '1', '2')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
VDP_CHROMA_TYPE_422,
|
||||||
|
VDP_YCBCR_FORMAT_UYVY,
|
||||||
|
GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
VDP_CHROMA_TYPE_444,
|
||||||
|
VDP_YCBCR_FORMAT_V8U8Y8A8,
|
||||||
|
GST_MAKE_FOURCC ('A', 'Y', 'U', 'V')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
VDP_CHROMA_TYPE_444,
|
||||||
|
VDP_YCBCR_FORMAT_Y8U8V8A8,
|
||||||
|
GST_MAKE_FOURCC ('A', 'V', 'U', 'Y')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
VDP_CHROMA_TYPE_422,
|
||||||
|
VDP_YCBCR_FORMAT_YUYV,
|
||||||
|
GST_MAKE_FOURCC ('Y', 'U', 'Y', 'V')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
VDP_CHROMA_TYPE_420,
|
||||||
|
VDP_YCBCR_FORMAT_YV12,
|
||||||
|
GST_MAKE_FOURCC ('Y', 'V', '1', '2')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static GstCaps *
|
||||||
|
gst_vdpaudecoder_get_vdpau_support (GstVdpauDecoder * dec)
|
||||||
|
{
|
||||||
|
GstCaps *caps;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
caps = gst_caps_new_empty ();
|
||||||
|
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
VdpStatus status;
|
||||||
|
VdpBool is_supported;
|
||||||
|
guint32 max_w, max_h;
|
||||||
|
|
||||||
|
status = vdp_video_surface_query_capabilities (dec->device, chroma_types[i],
|
||||||
|
&is_supported, &max_w, &max_h);
|
||||||
|
|
||||||
|
if (status != VDP_STATUS_OK && status != VDP_STATUS_INVALID_CHROMA_TYPE) {
|
||||||
|
GST_ELEMENT_ERROR (dec, RESOURCE, READ,
|
||||||
|
("Could not get VDPAU capabilites"),
|
||||||
|
("Could not query video surface capabilities"));
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (is_supported) {
|
||||||
|
gint j;
|
||||||
|
|
||||||
|
for (j = 0; j < 6; j++) {
|
||||||
|
if (formats[j].chroma_type != chroma_types[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
status =
|
||||||
|
vdp_video_surface_query_ycbcr_capabilities (dec->device,
|
||||||
|
formats[j].chroma_type, formats[j].format, &is_supported);
|
||||||
|
if (status != VDP_STATUS_OK
|
||||||
|
&& status != VDP_STATUS_INVALID_Y_CB_CR_FORMAT) {
|
||||||
|
GST_ELEMENT_ERROR (dec, RESOURCE, READ,
|
||||||
|
("Could not get VDPAU capabilites"),
|
||||||
|
("Could not query video surface ycbcr capabilities"));
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (is_supported) {
|
||||||
|
GstCaps *format_caps;
|
||||||
|
|
||||||
|
format_caps = gst_caps_new_simple ("video/x-raw-yuv",
|
||||||
|
"format", GST_TYPE_FOURCC, formats[j].fourcc,
|
||||||
|
"width", GST_TYPE_INT_RANGE, 1, max_w,
|
||||||
|
"height", GST_TYPE_INT_RANGE, 1, max_h,
|
||||||
|
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
|
||||||
|
gst_caps_append (caps, format_caps);
|
||||||
|
GST_DEBUG ("fourcc: %" GST_FOURCC_FORMAT "\n",
|
||||||
|
GST_FOURCC_ARGS (formats[j].fourcc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gst_caps_is_empty (caps)) {
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return caps;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_vdpaudecoder_init_vdpau (GstVdpauDecoder * dec)
|
||||||
|
{
|
||||||
|
Display *display;
|
||||||
|
int screen;
|
||||||
|
VdpStatus status;
|
||||||
|
GstCaps *caps;
|
||||||
|
|
||||||
|
/* FIXME: We probably want to use the same VdpDevice for every VDPAU element */
|
||||||
|
display = XOpenDisplay (dec->display);
|
||||||
|
if (!display) {
|
||||||
|
GST_ELEMENT_ERROR (dec, RESOURCE, READ, ("Could not initialise VDPAU"),
|
||||||
|
("Could not open display"));
|
||||||
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
screen = DefaultScreen (display);
|
||||||
|
status =
|
||||||
|
vdp_device_create_x11 (display, screen, &dec->device,
|
||||||
|
&vdp_get_proc_address);
|
||||||
|
if (status != VDP_STATUS_OK) {
|
||||||
|
GST_ELEMENT_ERROR (dec, RESOURCE, READ, ("Could not initialise VDPAU"),
|
||||||
|
("Could not create VDPAU device"));
|
||||||
|
XCloseDisplay (display);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
XCloseDisplay (display);
|
||||||
|
|
||||||
|
vdp_get_proc_address (dec->device,
|
||||||
|
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES,
|
||||||
|
(void **) &vdp_video_surface_query_capabilities);
|
||||||
|
vdp_get_proc_address (dec->device,
|
||||||
|
VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES,
|
||||||
|
(void **) &vdp_video_surface_query_ycbcr_capabilities);
|
||||||
|
|
||||||
|
caps = gst_vdpaudecoder_get_vdpau_support (dec);
|
||||||
|
if (!caps)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
dec->src_caps = caps;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_vdpaudecoder_sink_set_caps (GstPad * pad, GstCaps * caps)
|
||||||
|
{
|
||||||
|
GstVdpauDecoder *dec = GST_VDPAU_DECODER (GST_OBJECT_PARENT (pad));
|
||||||
|
|
||||||
|
GstCaps *src_caps, *new_caps;
|
||||||
|
GstStructure *structure;
|
||||||
|
gint width, height;
|
||||||
|
gint framerate_numerator, framerate_denominator;
|
||||||
|
gboolean res;
|
||||||
|
|
||||||
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
|
gst_structure_get_int (structure, "width", &width);
|
||||||
|
gst_structure_get_int (structure, "height", &height);
|
||||||
|
gst_structure_get_fraction (structure, "framerate",
|
||||||
|
&framerate_numerator, &framerate_denominator);
|
||||||
|
|
||||||
|
src_caps = gst_pad_get_allowed_caps (dec->src);
|
||||||
|
GST_DEBUG ("caps: %s\n\n", gst_caps_to_string (src_caps));
|
||||||
|
|
||||||
|
structure = gst_caps_get_structure (src_caps, 0);
|
||||||
|
gst_structure_set (structure,
|
||||||
|
"width", G_TYPE_INT, width,
|
||||||
|
"height", G_TYPE_INT, height,
|
||||||
|
"framerate", GST_TYPE_FRACTION, framerate_numerator,
|
||||||
|
framerate_denominator, NULL);
|
||||||
|
|
||||||
|
new_caps = gst_caps_copy_nth (src_caps, 0);
|
||||||
|
gst_caps_unref (src_caps);
|
||||||
|
gst_pad_fixate_caps (dec->src, new_caps);
|
||||||
|
res = gst_pad_set_caps (dec->src, new_caps);
|
||||||
|
|
||||||
|
gst_caps_unref (new_caps);
|
||||||
|
GST_DEBUG ("caps: %s\n\n", gst_caps_to_string (gst_pad_get_caps (dec->src)));
|
||||||
|
|
||||||
|
if (!res)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstCaps *
|
||||||
|
gst_vdpaudecoder_src_getcaps (GstPad * pad)
|
||||||
|
{
|
||||||
|
GstVdpauDecoder *dec;
|
||||||
|
|
||||||
|
dec = GST_VDPAU_DECODER (GST_OBJECT_PARENT (pad));
|
||||||
|
|
||||||
|
if (GST_PAD_CAPS (dec->src))
|
||||||
|
return gst_caps_ref (GST_PAD_CAPS (dec->src));
|
||||||
|
|
||||||
|
if (dec->src_caps)
|
||||||
|
return gst_caps_ref (dec->src_caps);
|
||||||
|
|
||||||
|
return gst_caps_copy (gst_pad_get_pad_template_caps (dec->src));
|
||||||
|
}
|
||||||
|
|
||||||
/* GObject vmethod implementations */
|
/* GObject vmethod implementations */
|
||||||
|
|
||||||
|
@ -80,7 +287,7 @@ gst_vdpaudecoder_base_init (gpointer klass)
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||||
|
|
||||||
gst_element_class_set_details_simple (element_class,
|
gst_element_class_set_details_simple (element_class,
|
||||||
"VDPAUDecoder",
|
"VdpauDecoder",
|
||||||
"Generic/Filter",
|
"Generic/Filter",
|
||||||
"VDPAU decoder base class",
|
"VDPAU decoder base class",
|
||||||
"Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>");
|
"Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>");
|
||||||
|
@ -91,7 +298,7 @@ gst_vdpaudecoder_base_init (gpointer klass)
|
||||||
|
|
||||||
/* initialize the vdpaudecoder's class */
|
/* initialize the vdpaudecoder's class */
|
||||||
static void
|
static void
|
||||||
gst_vdpaudecoder_class_init (GstVDPAUDecoderClass * klass)
|
gst_vdpaudecoder_class_init (GstVdpauDecoderClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstElementClass *gstelement_class;
|
GstElementClass *gstelement_class;
|
||||||
|
@ -109,73 +316,33 @@ gst_vdpaudecoder_class_init (GstVDPAUDecoderClass * klass)
|
||||||
g_object_class_install_property (gobject_class, PROP_SILENT,
|
g_object_class_install_property (gobject_class, PROP_SILENT,
|
||||||
g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
|
g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
|
||||||
FALSE, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
|
FALSE, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
|
||||||
|
|
||||||
gstelement_class->change_state =
|
|
||||||
GST_DEBUG_FUNCPTR (gst_vdpaudecoder_change_state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vdpaudecoder_init (GstVDPAUDecoder * dec, GstVDPAUDecoderClass * klass)
|
gst_vdpaudecoder_init (GstVdpauDecoder * dec, GstVdpauDecoderClass * klass)
|
||||||
{
|
{
|
||||||
dec->display = NULL;
|
dec->display = NULL;
|
||||||
dec->device = 0;
|
dec->device = 0;
|
||||||
dec->silent = FALSE;
|
dec->silent = FALSE;
|
||||||
|
dec->src_caps = NULL;
|
||||||
|
|
||||||
dec->src = gst_pad_new_from_static_template (&src_template, "src");
|
dec->src = gst_pad_new_from_static_template (&src_template, "src");
|
||||||
|
gst_pad_set_getcaps_function (dec->src, gst_vdpaudecoder_src_getcaps);
|
||||||
gst_element_add_pad (GST_ELEMENT (dec), dec->src);
|
gst_element_add_pad (GST_ELEMENT (dec), dec->src);
|
||||||
|
|
||||||
dec->sink = gst_pad_new_from_template (gst_element_class_get_pad_template
|
dec->sink = gst_pad_new_from_template (gst_element_class_get_pad_template
|
||||||
(GST_ELEMENT_CLASS (klass), "sink"), "sink");
|
(GST_ELEMENT_CLASS (klass), "sink"), "sink");
|
||||||
|
gst_pad_set_setcaps_function (dec->sink, gst_vdpaudecoder_sink_set_caps);
|
||||||
gst_element_add_pad (GST_ELEMENT (dec), dec->sink);
|
gst_element_add_pad (GST_ELEMENT (dec), dec->sink);
|
||||||
}
|
|
||||||
|
|
||||||
static GstStateChangeReturn
|
gst_vdpaudecoder_init_vdpau (dec);
|
||||||
gst_vdpaudecoder_change_state (GstElement * element, GstStateChange transition)
|
|
||||||
{
|
|
||||||
GstVDPAUDecoder *dec;
|
|
||||||
|
|
||||||
dec = GST_VDPAUDECODER (element);
|
|
||||||
|
|
||||||
switch (transition) {
|
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
|
||||||
{
|
|
||||||
Display *display;
|
|
||||||
int screen;
|
|
||||||
VdpStatus status;
|
|
||||||
|
|
||||||
/* FIXME: We probably want to use the same VdpDevice for every VDPAU element */
|
|
||||||
display = XOpenDisplay (dec->display);
|
|
||||||
if (!display) {
|
|
||||||
GST_ELEMENT_ERROR (dec, RESOURCE, WRITE, ("Could not initialise VDPAU"),
|
|
||||||
("Could not open display"));
|
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
screen = DefaultScreen (display);
|
|
||||||
status = vdp_device_create_x11 (display, screen, &dec->device, NULL);
|
|
||||||
if (status != VDP_STATUS_OK) {
|
|
||||||
GST_ELEMENT_ERROR (dec, RESOURCE, WRITE, ("Could not initialise VDPAU"),
|
|
||||||
("Could not create VDPAU device"));
|
|
||||||
XCloseDisplay (display);
|
|
||||||
|
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
|
||||||
}
|
|
||||||
XCloseDisplay (display);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GST_STATE_CHANGE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vdpaudecoder_set_property (GObject * object, guint prop_id,
|
gst_vdpaudecoder_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstVDPAUDecoder *dec = GST_VDPAUDECODER (object);
|
GstVdpauDecoder *dec = GST_VDPAU_DECODER (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_DISPLAY:
|
case PROP_DISPLAY:
|
||||||
|
@ -195,7 +362,7 @@ static void
|
||||||
gst_vdpaudecoder_get_property (GObject * object, guint prop_id,
|
gst_vdpaudecoder_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec)
|
GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
GstVDPAUDecoder *dec = GST_VDPAUDECODER (object);
|
GstVdpauDecoder *dec = GST_VDPAU_DECODER (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_DISPLAY:
|
case PROP_DISPLAY:
|
||||||
|
@ -209,15 +376,3 @@ gst_vdpaudecoder_get_property (GObject * object, guint prop_id,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
plugin_init (GstPlugin * plugin)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
||||||
GST_VERSION_MINOR,
|
|
||||||
"vdpau",
|
|
||||||
"vdpau elements",
|
|
||||||
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __GST_VDPAUDECODER_H__
|
#ifndef __GST_VDPAU_DECODER_H__
|
||||||
#define __GST_VDPAUDECODER_H__
|
#define __GST_VDPAU_DECODER_H__
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstbasetransform.h>
|
#include <gst/base/gstbasetransform.h>
|
||||||
|
@ -29,21 +29,21 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_TYPE_VDPAUDECODER \
|
#define GST_TYPE_VDPAU_DECODER \
|
||||||
(gst_vdpaudecoder_get_type())
|
(gst_vdpaudecoder_get_type())
|
||||||
#define GST_VDPAUDECODER(obj) \
|
#define GST_VDPAU_DECODER(obj) \
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VDPAUDECODER,GstVDPAUDecoder))
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VDPAU_DECODER,GstVdpauDecoder))
|
||||||
#define GST_VDPAUDECODER_CLASS(klass) \
|
#define GST_VDPAU_DECODER_CLASS(klass) \
|
||||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VDPAUDECODER,GstVDPAUDecoderClass))
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VDPAU_DECODER,GstVdpauDecoderClass))
|
||||||
#define GST_IS_VDPAUDECODER(obj) \
|
#define GST_IS_VDPAU_DECODER(obj) \
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VDPAUDECODER))
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VDPAU_DECODER))
|
||||||
#define GST_IS_VDPAUDECODER_CLASS(klass) \
|
#define GST_IS_VDPAU_DECODER_CLASS(klass) \
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VDPAUDECODER))
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VDPAU_DECODER))
|
||||||
|
|
||||||
typedef struct _GstVDPAUDecoder GstVDPAUDecoder;
|
typedef struct _GstVdpauDecoder GstVdpauDecoder;
|
||||||
typedef struct _GstVDPAUDecoderClass GstVDPAUDecoderClass;
|
typedef struct _GstVdpauDecoderClass GstVdpauDecoderClass;
|
||||||
|
|
||||||
struct _GstVDPAUDecoder {
|
struct _GstVdpauDecoder {
|
||||||
GstElement element;
|
GstElement element;
|
||||||
|
|
||||||
gchar *display;
|
gchar *display;
|
||||||
|
@ -52,10 +52,12 @@ struct _GstVDPAUDecoder {
|
||||||
GstPad *src;
|
GstPad *src;
|
||||||
GstPad *sink;
|
GstPad *sink;
|
||||||
|
|
||||||
|
GstCaps *src_caps;
|
||||||
|
|
||||||
gboolean silent;
|
gboolean silent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstVDPAUDecoderClass {
|
struct _GstVdpauDecoderClass {
|
||||||
GstBaseTransformClass parent_class;
|
GstBaseTransformClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,4 +65,4 @@ GType gst_vdpaudecoder_get_type (void);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_VDPAUDECODER_H__ */
|
#endif /* __GST_VDPAU_DECODER_H__ */
|
||||||
|
|
202
sys/vdpau/gstvdpauh264decoder.c
Normal file
202
sys/vdpau/gstvdpauh264decoder.c
Normal file
|
@ -0,0 +1,202 @@
|
||||||
|
/*
|
||||||
|
* GStreamer
|
||||||
|
* Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
|
||||||
|
* Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||||
|
* Copyright (C) 2009 Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the
|
||||||
|
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
|
||||||
|
* which case the following provisions apply instead of the ones
|
||||||
|
* mentioned above:
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:element-vdpauh264decoder
|
||||||
|
*
|
||||||
|
* FIXME:Describe vdpauh264decoder here.
|
||||||
|
*
|
||||||
|
* <refsect2>
|
||||||
|
* <title>Example launch line</title>
|
||||||
|
* |[
|
||||||
|
* gst-launch -v -m fakesrc ! vdpauh264decoder ! fakesink silent=TRUE
|
||||||
|
* ]|
|
||||||
|
* </refsect2>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#include "gstvdpauh264decoder.h"
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_STATIC (gst_vdpau_h264decoder_debug);
|
||||||
|
#define GST_CAT_DEFAULT gst_vdpau_h264decoder_debug
|
||||||
|
|
||||||
|
/* Filter signals and args */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/* FILL ME */
|
||||||
|
LAST_SIGNAL
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_SILENT
|
||||||
|
};
|
||||||
|
|
||||||
|
/* the capabilities of the inputs and outputs.
|
||||||
|
*
|
||||||
|
* describe the real formats here.
|
||||||
|
*/
|
||||||
|
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
|
GST_PAD_SINK,
|
||||||
|
GST_PAD_ALWAYS,
|
||||||
|
GST_STATIC_CAPS ("video/x-h264")
|
||||||
|
);
|
||||||
|
|
||||||
|
GST_BOILERPLATE (GstVdpauH264Decoder, gst_vdpau_h264decoder, GstVdpauDecoder,
|
||||||
|
GST_TYPE_VDPAU_DECODER);
|
||||||
|
|
||||||
|
static void gst_vdpau_h264decoder_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
static void gst_vdpau_h264decoder_get_property (GObject * object, guint prop_id,
|
||||||
|
GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
|
/* GObject vmethod implementations */
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vdpau_h264decoder_base_init (gpointer gclass)
|
||||||
|
{
|
||||||
|
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
|
||||||
|
|
||||||
|
gst_element_class_set_details_simple (element_class,
|
||||||
|
"VdpauH264Decoder",
|
||||||
|
"FIXME:Generic",
|
||||||
|
"FIXME:Generic Template Element",
|
||||||
|
"Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>");
|
||||||
|
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&sink_factory));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialize the vdpauh264decoder's class */
|
||||||
|
static void
|
||||||
|
gst_vdpau_h264decoder_class_init (GstVdpauH264DecoderClass * klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class;
|
||||||
|
GstElementClass *gstelement_class;
|
||||||
|
|
||||||
|
gobject_class = (GObjectClass *) klass;
|
||||||
|
gstelement_class = (GstElementClass *) klass;
|
||||||
|
|
||||||
|
gobject_class->set_property = gst_vdpau_h264decoder_set_property;
|
||||||
|
gobject_class->get_property = gst_vdpau_h264decoder_get_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_SILENT,
|
||||||
|
g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
|
||||||
|
FALSE, G_PARAM_READWRITE));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vdpau_h264decoder_init (GstVdpauH264Decoder * filter,
|
||||||
|
GstVdpauH264DecoderClass * gclass)
|
||||||
|
{
|
||||||
|
filter->silent = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vdpau_h264decoder_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
GstVdpauH264Decoder *filter = GST_VDPAU_H264_DECODER (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_SILENT:
|
||||||
|
filter->silent = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vdpau_h264decoder_get_property (GObject * object, guint prop_id,
|
||||||
|
GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
GstVdpauH264Decoder *filter = GST_VDPAU_H264_DECODER (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_SILENT:
|
||||||
|
g_value_set_boolean (value, filter->silent);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* entry point to initialize the plug-in
|
||||||
|
* initialize the plug-in itself
|
||||||
|
* register the element factories and other features
|
||||||
|
*/
|
||||||
|
static gboolean
|
||||||
|
vdpauh264decoder_init (GstPlugin * vdpauh264decoder)
|
||||||
|
{
|
||||||
|
/* debug category for fltering log messages
|
||||||
|
*
|
||||||
|
* exchange the string 'Template vdpauh264decoder' with your description
|
||||||
|
*/
|
||||||
|
GST_DEBUG_CATEGORY_INIT (gst_vdpau_h264decoder_debug, "vdpauh264decoder",
|
||||||
|
0, "Template vdpauh264decoder");
|
||||||
|
|
||||||
|
return gst_element_register (vdpauh264decoder, "vdpauh264decoder",
|
||||||
|
GST_RANK_NONE, GST_TYPE_VDPAU_H264_DECODER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* gstreamer looks for this structure to register vdpauh264decoders
|
||||||
|
*
|
||||||
|
* exchange the string 'Template vdpauh264decoder' with your vdpauh264decoder description
|
||||||
|
*/
|
||||||
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||||
|
GST_VERSION_MINOR,
|
||||||
|
"vdpauh264decoder",
|
||||||
|
"Template vdpauh264decoder",
|
||||||
|
vdpauh264decoder_init,
|
||||||
|
VERSION, "LGPL", "GStreamer", "http://gstreamer.net/")
|
88
sys/vdpau/gstvdpauh264decoder.h
Normal file
88
sys/vdpau/gstvdpauh264decoder.h
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* GStreamer
|
||||||
|
* Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
|
||||||
|
* Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||||
|
* Copyright (C) 2009 Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the
|
||||||
|
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
|
||||||
|
* which case the following provisions apply instead of the ones
|
||||||
|
* mentioned above:
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GST_VDPAU_H264_DECODER_H__
|
||||||
|
#define __GST_VDPAU_H264_DECODER_H__
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#include "gstvdpaudecoder.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/* #defines don't like whitespacey bits */
|
||||||
|
#define GST_TYPE_VDPAU_H264_DECODER \
|
||||||
|
(gst_vdpau_h264decoder_get_type())
|
||||||
|
#define GST_VDPAU_H264_DECODER(obj) \
|
||||||
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VDPAU_H264_DECODER,GstVdpauH264Decoder))
|
||||||
|
#define GST_VDPAU_H264_DECODER_CLASS(klass) \
|
||||||
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VDPAU_H264_DECODER,GstVdpauH264DecoderClass))
|
||||||
|
#define GST_IS_VDPAU_H264_DECODER(obj) \
|
||||||
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VDPAU_H264_DECODER))
|
||||||
|
#define GST_IS_VDPAU_H264_DECODER_CLASS(klass) \
|
||||||
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VDPAU_H264_DECODER))
|
||||||
|
|
||||||
|
typedef struct _GstVdpauH264Decoder GstVdpauH264Decoder;
|
||||||
|
typedef struct _GstVdpauH264DecoderClass GstVdpauH264DecoderClass;
|
||||||
|
|
||||||
|
struct _GstVdpauH264Decoder
|
||||||
|
{
|
||||||
|
GstVdpauDecoder dec;
|
||||||
|
|
||||||
|
GstPad *sinkpad, *srcpad;
|
||||||
|
|
||||||
|
gboolean silent;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstVdpauH264DecoderClass
|
||||||
|
{
|
||||||
|
GstVdpauDecoderClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gst_vdpau_h264decoder_get_type (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GST_VDPAU_H264_DECODER_H__ */
|
45
sys/vdpau/vdpauvariables.h
Normal file
45
sys/vdpau/vdpauvariables.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#include <vdpau/vdpau.h>
|
||||||
|
|
||||||
|
static VdpVideoSurfaceQueryCapabilities *vdp_video_surface_query_capabilities;
|
||||||
|
static VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities *vdp_video_surface_query_ycbcr_capabilities;
|
||||||
|
|
||||||
|
static VdpGetProcAddress *vdp_get_proc_address;
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
static VdpDeviceDestroy *vdp_device_destroy;
|
||||||
|
static VdpVideoSurfaceCreate *vdp_video_surface_create;
|
||||||
|
static VdpVideoSurfaceDestroy *vdp_video_surface_destroy;
|
||||||
|
|
||||||
|
static VdpGetErrorString *vdp_get_error_string;
|
||||||
|
|
||||||
|
static VdpVideoSurfacePutBitsYCbCr *vdp_video_surface_put_bits_y_cb_cr;
|
||||||
|
static VdpOutputSurfacePutBitsNative *vdp_output_surface_put_bits_native;
|
||||||
|
|
||||||
|
static VdpOutputSurfaceCreate *vdp_output_surface_create;
|
||||||
|
static VdpOutputSurfaceDestroy *vdp_output_surface_destroy;
|
||||||
|
|
||||||
|
static VdpVideoMixerCreate *vdp_video_mixer_create;
|
||||||
|
static VdpVideoMixerDestroy *vdp_video_mixer_destroy;
|
||||||
|
static VdpVideoMixerRender *vdp_video_mixer_render;
|
||||||
|
static VdpVideoMixerSetFeatureEnables *vdp_video_mixer_set_feature_enables;
|
||||||
|
static VdpVideoMixerSetAttributeValues *vdp_video_mixer_set_attribute_values;
|
||||||
|
|
||||||
|
static VdpPresentationQueueTargetDestroy *vdp_presentation_queue_target_destroy;
|
||||||
|
static VdpPresentationQueueCreate *vdp_presentation_queue_create;
|
||||||
|
static VdpPresentationQueueDestroy *vdp_presentation_queue_destroy;
|
||||||
|
static VdpPresentationQueueDisplay *vdp_presentation_queue_display;
|
||||||
|
static VdpPresentationQueueBlockUntilSurfaceIdle *vdp_presentation_queue_block_until_surface_idle;
|
||||||
|
static VdpPresentationQueueTargetCreateX11 *vdp_presentation_queue_target_create_x11;
|
||||||
|
|
||||||
|
static VdpOutputSurfaceRenderOutputSurface *vdp_output_surface_render_output_surface;
|
||||||
|
static VdpOutputSurfacePutBitsIndexed *vdp_output_surface_put_bits_indexed;
|
||||||
|
static VdpOutputSurfaceRenderBitmapSurface *vdp_output_surface_render_bitmap_surface;
|
||||||
|
|
||||||
|
static VdpBitmapSurfaceCreate *vdp_bitmap_surface_create;
|
||||||
|
static VdpBitmapSurfaceDestroy *vdp_bitmap_surface_destroy;
|
||||||
|
static VdpBitmapSurfacePutBitsNative *vdp_bitmap_surface_putbits_native;
|
||||||
|
|
||||||
|
static VdpDecoderCreate *vdp_decoder_create;
|
||||||
|
static VdpDecoderDestroy *vdp_decoder_destroy;
|
||||||
|
static VdpDecoderRender *vdp_decoder_render;
|
||||||
|
#endif
|
Loading…
Reference in a new issue