From 8a355f1a24fcb89e8ee35a5f0fc24c3e7db7e0fb Mon Sep 17 00:00:00 2001 From: Carl-Anton Ingmarsson Date: Thu, 29 Apr 2010 22:24:35 +0200 Subject: [PATCH] vdpau: small api cleanup merge gst_vdp_video_buffer_get_allowed_[video|yuv]_caps into gst_vdp_video_buffer_get_allowed_caps --- sys/vdpau/gstvdpsink.c | 4 +- sys/vdpau/gstvdpvideobuffer.c | 95 +++++++++++++------------------------- sys/vdpau/gstvdpvideobuffer.h | 3 +- sys/vdpau/gstvdpvideopostprocess.c | 6 +-- sys/vdpau/gstvdpvideosrcpad.c | 14 +++--- 5 files changed, 43 insertions(+), 79 deletions(-) diff --git a/sys/vdpau/gstvdpsink.c b/sys/vdpau/gstvdpsink.c index 3971c9c..bf79945 100644 --- a/sys/vdpau/gstvdpsink.c +++ b/sys/vdpau/gstvdpsink.c @@ -809,8 +809,8 @@ gst_vdp_sink_show_frame (GstBaseSink * bsink, GstBuffer * outbuf) g_mutex_lock (vdp_sink->x_lock); status = - device->vdp_presentation_queue_query_surface_status (vdp_sink->window-> - queue, surface, &queue_status, &pres_time); + device->vdp_presentation_queue_query_surface_status (vdp_sink-> + window->queue, surface, &queue_status, &pres_time); g_mutex_unlock (vdp_sink->x_lock); if (queue_status == VDP_PRESENTATION_QUEUE_STATUS_QUEUED) { diff --git a/sys/vdpau/gstvdpvideobuffer.c b/sys/vdpau/gstvdpvideobuffer.c index 16484f4..ff7fc5b 100644 --- a/sys/vdpau/gstvdpvideobuffer.c +++ b/sys/vdpau/gstvdpvideobuffer.c @@ -163,14 +163,16 @@ gst_vdp_video_buffer_get_caps (gboolean filter, VdpChromaType chroma_type) } GstCaps * -gst_vdp_video_buffer_get_allowed_yuv_caps (GstVdpDevice * device) +gst_vdp_video_buffer_get_allowed_caps (GstVdpDevice * device) { - GstCaps *caps; + GstCaps *video_caps, *yuv_caps; gint i; + VdpStatus status; + + video_caps = gst_caps_new_empty (); + yuv_caps = gst_caps_new_empty (); - caps = gst_caps_new_empty (); for (i = 0; i < G_N_ELEMENTS (chroma_types); i++) { - VdpStatus status; VdpBool is_supported; guint32 max_w, max_h; @@ -178,17 +180,19 @@ gst_vdp_video_buffer_get_allowed_yuv_caps (GstVdpDevice * device) device->vdp_video_surface_query_capabilities (device->device, chroma_types[i], &is_supported, &max_w, &max_h); - if (status != VDP_STATUS_OK && status != VDP_STATUS_INVALID_CHROMA_TYPE) { - GST_ERROR_OBJECT (device, - "Could not get query VDPAU video surface capabilites, " - "Error returned from vdpau was: %s", - device->vdp_get_error_string (status)); + if (status != VDP_STATUS_OK && status != VDP_STATUS_INVALID_CHROMA_TYPE) + goto surface_query_caps_error; - goto error; - } if (is_supported) { + GstCaps *format_caps; gint j; + format_caps = gst_caps_new_simple ("video/x-vdpau-video", + "chroma-type", G_TYPE_INT, chroma_types[i], + "width", GST_TYPE_INT_RANGE, 1, max_w, + "height", GST_TYPE_INT_RANGE, 1, max_h, NULL); + gst_caps_append (video_caps, format_caps); + for (j = 0; j < G_N_ELEMENTS (formats); j++) { if (formats[j].chroma_type != chroma_types[i]) continue; @@ -197,69 +201,36 @@ gst_vdp_video_buffer_get_allowed_yuv_caps (GstVdpDevice * device) device->vdp_video_surface_query_ycbcr_capabilities (device->device, formats[j].chroma_type, formats[j].format, &is_supported); if (status != VDP_STATUS_OK - && status != VDP_STATUS_INVALID_Y_CB_CR_FORMAT) { - GST_ERROR_OBJECT (device, "Could not query VDPAU YCbCr capabilites, " - "Error returned from vdpau was: %s", - device->vdp_get_error_string (status)); - - goto error; - } + && status != VDP_STATUS_INVALID_Y_CB_CR_FORMAT) + goto surface_query_ycbcr_error; 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, NULL); - gst_caps_append (caps, format_caps); + gst_caps_append (yuv_caps, format_caps); } } } } -error: - return caps; -} - -GstCaps * -gst_vdp_video_buffer_get_allowed_video_caps (GstVdpDevice * device) -{ - GstCaps *caps; - gint i; - - caps = gst_caps_new_empty (); - for (i = 0; i < G_N_ELEMENTS (chroma_types); i++) { - VdpStatus status; - VdpBool is_supported; - guint32 max_w, max_h; - - status = - device->vdp_video_surface_query_capabilities (device->device, - chroma_types[i], &is_supported, &max_w, &max_h); - - if (status != VDP_STATUS_OK && status != VDP_STATUS_INVALID_CHROMA_TYPE) { - GST_ERROR_OBJECT (device, - "Could not get query VDPAU video surface capabilites, " - "Error returned from vdpau was: %s", - device->vdp_get_error_string (status)); - - goto error; - } - - if (is_supported) { - GstCaps *format_caps; - - format_caps = gst_caps_new_simple ("video/x-vdpau-video", - "chroma-type", G_TYPE_INT, chroma_types[i], - "width", GST_TYPE_INT_RANGE, 1, max_w, - "height", GST_TYPE_INT_RANGE, 1, max_h, NULL); - gst_caps_append (caps, format_caps); - } - } +done: + gst_caps_append (video_caps, yuv_caps); + return video_caps; -error: - return caps; +surface_query_caps_error: + GST_ERROR_OBJECT (device, + "Could not get query VDPAU video surface capabilites, " + "Error returned from vdpau was: %s", + device->vdp_get_error_string (status)); + goto done; + +surface_query_ycbcr_error: + GST_ERROR_OBJECT (device, "Could not query VDPAU YCbCr capabilites, " + "Error returned from vdpau was: %s", + device->vdp_get_error_string (status)); + goto done; } gboolean diff --git a/sys/vdpau/gstvdpvideobuffer.h b/sys/vdpau/gstvdpvideobuffer.h index bef8642..4d14d8c 100644 --- a/sys/vdpau/gstvdpvideobuffer.h +++ b/sys/vdpau/gstvdpvideobuffer.h @@ -96,8 +96,7 @@ GstVdpVideoBuffer* gst_vdp_video_buffer_new (GstVdpDevice * device, VdpChromaTyp void gst_vdp_video_buffer_add_reference (GstVdpVideoBuffer *buffer, GstVdpVideoBuffer *buf); GstCaps *gst_vdp_video_buffer_get_caps (gboolean filter, VdpChromaType chroma_type); -GstCaps *gst_vdp_video_buffer_get_allowed_yuv_caps (GstVdpDevice * device); -GstCaps *gst_vdp_video_buffer_get_allowed_video_caps (GstVdpDevice * device); +GstCaps *gst_vdp_video_buffer_get_allowed_caps (GstVdpDevice * device); GstCaps *gst_vdp_video_buffer_parse_yuv_caps (GstCaps *yuv_caps); diff --git a/sys/vdpau/gstvdpvideopostprocess.c b/sys/vdpau/gstvdpvideopostprocess.c index ef1ebc5..304db48 100644 --- a/sys/vdpau/gstvdpvideopostprocess.c +++ b/sys/vdpau/gstvdpvideopostprocess.c @@ -844,11 +844,7 @@ gst_vdp_vpp_sink_getcaps (GstPad * pad) GstCaps *caps; if (vpp->device) { - GstCaps *video_caps, *yuv_caps; - video_caps = gst_vdp_video_buffer_get_allowed_video_caps (vpp->device); - yuv_caps = gst_vdp_video_buffer_get_allowed_yuv_caps (vpp->device); - gst_caps_append (video_caps, yuv_caps); - caps = video_caps; + caps = gst_vdp_video_buffer_get_allowed_caps (vpp->device); } else { GstElementClass *element_class = GST_ELEMENT_GET_CLASS (vpp); GstPadTemplate *sink_template; diff --git a/sys/vdpau/gstvdpvideosrcpad.c b/sys/vdpau/gstvdpvideosrcpad.c index 48c10f2..8b701a3 100644 --- a/sys/vdpau/gstvdpvideosrcpad.c +++ b/sys/vdpau/gstvdpvideosrcpad.c @@ -127,21 +127,19 @@ gst_vdp_video_src_pad_push (GstVdpVideoSrcPad * vdp_pad, static void gst_vdp_video_src_pad_update_caps (GstVdpVideoSrcPad * vdp_pad) { - GstCaps *yuv_caps, *video_caps; + GstCaps *caps; const GstCaps *templ_caps; - video_caps = gst_vdp_video_buffer_get_allowed_video_caps (vdp_pad->device); - yuv_caps = gst_vdp_video_buffer_get_allowed_yuv_caps (vdp_pad->device); - gst_caps_append (video_caps, yuv_caps); - if (vdp_pad->caps) gst_caps_unref (vdp_pad->caps); + caps = gst_vdp_video_buffer_get_allowed_caps (vdp_pad->device); + if ((templ_caps = gst_pad_get_pad_template_caps (GST_PAD (vdp_pad)))) { - vdp_pad->caps = gst_caps_intersect (video_caps, templ_caps); - gst_caps_unref (video_caps); + vdp_pad->caps = gst_caps_intersect (caps, templ_caps); + gst_caps_unref (caps); } else - vdp_pad->caps = video_caps; + vdp_pad->caps = caps; } GstFlowReturn -- 2.7.4