vdpau: rough try at implementing pushinf of YV12 buffers

This commit is contained in:
Carl-Anton Ingmarsson 2009-03-25 19:59:06 +01:00 committed by Jan Schmidt
parent 2363032b34
commit 62757ca5b4
3 changed files with 38 additions and 3 deletions

View file

@ -69,12 +69,36 @@ static void gst_vdpaudecoder_get_property (GObject * object, guint prop_id,
gboolean gboolean
gst_vdpaudecoder_push_video_surface (GstVdpauDecoder * dec, gst_vdpaudecoder_push_video_surface (GstVdpauDecoder * dec,
VdpVideoSurface * surface) VdpVideoSurface surface)
{ {
switch (dec->format) { switch (dec->format) {
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'): case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
/* YV12 specific code */ {
gint size;
GstFlowReturn result;
GstBuffer *buffer;
VdpStatus status;
guint8 *data[3];
size = dec->height * dec->width + dec->height * dec->width / 2;
result =
gst_pad_alloc_buffer_and_set_caps (dec->src, GST_BUFFER_OFFSET_NONE,
size, GST_PAD_CAPS (dec->src), &buffer);
if (G_UNLIKELY (result != GST_FLOW_OK))
return FALSE;
data[0] = GST_BUFFER_DATA (buffer);
data[1] = data[0] + dec->height * dec->width;
data[2] = data[1] + dec->height * dec->width / 4;
status =
vdp_video_surface_get_bits_ycbcr (surface, VDP_YCBCR_FORMAT_YV12,
(void *) data, NULL);
if (G_UNLIKELY (status != VDP_STATUS_OK))
return FALSE;
break; break;
}
default: default:
break; break;
} }
@ -223,6 +247,9 @@ gst_vdpaudecoder_init_vdpau (GstVdpauDecoder * dec)
(void **) &vdp_video_surface_query_ycbcr_capabilities); (void **) &vdp_video_surface_query_ycbcr_capabilities);
vdp_get_proc_address (dec->device, vdp_get_proc_address (dec->device,
VDP_FUNC_ID_DEVICE_DESTROY, (void **) &vdp_device_destroy); VDP_FUNC_ID_DEVICE_DESTROY, (void **) &vdp_device_destroy);
vdp_get_proc_address (dec->device,
VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR,
(void **) &vdp_video_surface_get_bits_ycbcr);
caps = gst_vdpaudecoder_get_vdpau_support (dec); caps = gst_vdpaudecoder_get_vdpau_support (dec);
if (!caps) { if (!caps) {
@ -293,6 +320,8 @@ gst_vdpaudecoder_sink_set_caps (GstPad * pad, GstCaps * caps)
if (!res) if (!res)
return FALSE; return FALSE;
dec->width = width;
dec->height = height;
dec->format = fourcc_format; dec->format = fourcc_format;
return TRUE; return TRUE;
@ -363,6 +392,10 @@ gst_vdpaudecoder_init (GstVdpauDecoder * dec, GstVdpauDecoderClass * klass)
dec->silent = FALSE; dec->silent = FALSE;
dec->src_caps = NULL; dec->src_caps = NULL;
dec->height = 0;
dec->width = 0;
dec->format = 0;
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_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);

View file

@ -54,6 +54,7 @@ struct _GstVdpauDecoder {
GstCaps *src_caps; GstCaps *src_caps;
gint width, height;
guint32 format; guint32 format;
gboolean silent; gboolean silent;
@ -65,7 +66,7 @@ struct _GstVdpauDecoderClass {
GType gst_vdpaudecoder_get_type (void); GType gst_vdpaudecoder_get_type (void);
gboolean gst_vdpaudecoder_push_video_surface (GstVdpauDecoder * dec, VdpVideoSurface * surface); gboolean gst_vdpaudecoder_push_video_surface (GstVdpauDecoder * dec, VdpVideoSurface surface);
G_END_DECLS G_END_DECLS

View file

@ -2,6 +2,7 @@
static VdpVideoSurfaceQueryCapabilities *vdp_video_surface_query_capabilities; static VdpVideoSurfaceQueryCapabilities *vdp_video_surface_query_capabilities;
static VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities *vdp_video_surface_query_ycbcr_capabilities; static VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities *vdp_video_surface_query_ycbcr_capabilities;
static VdpVideoSurfaceGetBitsYCbCr *vdp_video_surface_get_bits_ycbcr;
static VdpGetProcAddress *vdp_get_proc_address; static VdpGetProcAddress *vdp_get_proc_address;
static VdpDeviceDestroy *vdp_device_destroy; static VdpDeviceDestroy *vdp_device_destroy;