mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 20:59:44 +00:00
vdpau: rename gst_vdp_video_buffer_parse_yuv_caps and move it to gstvdputils.h
This commit is contained in:
parent
726290de21
commit
472cdc4c61
5 changed files with 82 additions and 71 deletions
|
@ -40,17 +40,22 @@ gst_vdp_video_remove_pixel_aspect_ratio (GstStructure * structure)
|
||||||
}
|
}
|
||||||
|
|
||||||
GstCaps *
|
GstCaps *
|
||||||
gst_vdp_video_to_output_caps (GstCaps * caps)
|
gst_vdp_video_to_output_caps (GstCaps * video_caps)
|
||||||
{
|
{
|
||||||
GstCaps *result;
|
GstCaps *output_caps;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
result = gst_caps_copy (caps);
|
g_return_val_if_fail (GST_IS_CAPS (video_caps), NULL);
|
||||||
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
|
||||||
|
output_caps = gst_caps_copy (video_caps);
|
||||||
|
for (i = 0; i < gst_caps_get_size (video_caps); i++) {
|
||||||
|
|
||||||
GstStructure *structure, *rgb_structure;
|
GstStructure *structure, *rgb_structure;
|
||||||
|
|
||||||
structure = gst_caps_get_structure (result, i);
|
structure = gst_caps_get_structure (output_caps, i);
|
||||||
|
if (!gst_structure_has_name (structure, "video/x-vdpau-video"))
|
||||||
|
goto not_video_error;
|
||||||
|
|
||||||
rgb_structure = gst_structure_copy (structure);
|
rgb_structure = gst_structure_copy (structure);
|
||||||
|
|
||||||
gst_structure_set_name (structure, "video/x-vdpau-output");
|
gst_structure_set_name (structure, "video/x-vdpau-output");
|
||||||
|
@ -60,8 +65,74 @@ gst_vdp_video_to_output_caps (GstCaps * caps)
|
||||||
gst_structure_set_name (rgb_structure, "video/x-raw-rgb");
|
gst_structure_set_name (rgb_structure, "video/x-raw-rgb");
|
||||||
gst_structure_remove_field (rgb_structure, "chroma-type");
|
gst_structure_remove_field (rgb_structure, "chroma-type");
|
||||||
gst_vdp_video_remove_pixel_aspect_ratio (rgb_structure);
|
gst_vdp_video_remove_pixel_aspect_ratio (rgb_structure);
|
||||||
gst_caps_append_structure (result, rgb_structure);
|
gst_caps_append_structure (output_caps, rgb_structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return output_caps;
|
||||||
|
|
||||||
|
error:
|
||||||
|
gst_caps_unref (output_caps);
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
not_video_error:
|
||||||
|
GST_WARNING ("The caps weren't of type \"video/x-vdpau-video\"");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
GstCaps *
|
||||||
|
gst_vdp_yuv_to_video_caps (GstCaps * yuv_caps)
|
||||||
|
{
|
||||||
|
GstCaps *video_caps;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_CAPS (yuv_caps), NULL);
|
||||||
|
|
||||||
|
video_caps = gst_caps_copy (yuv_caps);
|
||||||
|
for (i = 0; i < gst_caps_get_size (video_caps); i++) {
|
||||||
|
GstStructure *structure;
|
||||||
|
guint32 fourcc;
|
||||||
|
VdpChromaType chroma_type;
|
||||||
|
|
||||||
|
structure = gst_caps_get_structure (video_caps, i);
|
||||||
|
if (!gst_structure_has_name (structure, "video/x-raw-yuv"))
|
||||||
|
goto not_yuv_error;
|
||||||
|
|
||||||
|
if (!gst_structure_get_fourcc (structure, "format", &fourcc))
|
||||||
|
goto no_format_error;
|
||||||
|
|
||||||
|
chroma_type = -1;
|
||||||
|
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
|
||||||
|
if (formats[i].fourcc == fourcc) {
|
||||||
|
chroma_type = formats[i].chroma_type;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chroma_type == -1)
|
||||||
|
goto no_chroma_error;
|
||||||
|
|
||||||
|
/* now we transform the caps */
|
||||||
|
gst_structure_set_name (structure, "video/x-vdpau-video");
|
||||||
|
gst_structure_remove_field (structure, "format");
|
||||||
|
gst_structure_set (structure, "chroma-type", G_TYPE_INT, chroma_type, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return video_caps;
|
||||||
|
|
||||||
|
error:
|
||||||
|
gst_caps_unref (video_caps);
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
not_yuv_error:
|
||||||
|
GST_WARNING ("The caps weren't of type \"video/x-raw-yuv\"");
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
no_format_error:
|
||||||
|
GST_WARNING ("The caps didn't have a \"fourcc\" field");
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
no_chroma_error:
|
||||||
|
GST_WARNING ("The caps had an invalid \"fourcc\" field");
|
||||||
|
goto error;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include "gstvdpdevice.h"
|
#include "gstvdpdevice.h"
|
||||||
|
|
||||||
GstCaps *gst_vdp_video_to_output_caps (GstCaps *caps);
|
GstCaps *gst_vdp_video_to_output_caps (GstCaps *video_caps);
|
||||||
|
GstCaps *gst_vdp_yuv_to_video_caps (GstCaps * yuv_caps);
|
||||||
|
|
||||||
#endif /* _GST_VDP_UTILS_H_ */
|
#endif /* _GST_VDP_UTILS_H_ */
|
||||||
|
|
|
@ -279,65 +279,6 @@ gst_vdp_video_buffer_calculate_size (guint32 fourcc, gint width, gint height,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GstCaps *
|
|
||||||
gst_vdp_video_buffer_parse_yuv_caps (GstCaps * yuv_caps)
|
|
||||||
{
|
|
||||||
|
|
||||||
GstCaps *video_caps;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_CAPS (yuv_caps), NULL);
|
|
||||||
|
|
||||||
video_caps = gst_caps_copy (yuv_caps);
|
|
||||||
for (i = 0; i < gst_caps_get_size (video_caps); i++) {
|
|
||||||
GstStructure *structure;
|
|
||||||
guint32 fourcc;
|
|
||||||
VdpChromaType chroma_type;
|
|
||||||
|
|
||||||
structure = gst_caps_get_structure (video_caps, i);
|
|
||||||
if (!gst_structure_has_name (structure, "video/x-raw-yuv"))
|
|
||||||
goto not_yuv_error;
|
|
||||||
|
|
||||||
if (!gst_structure_get_fourcc (structure, "format", &fourcc))
|
|
||||||
goto no_format_error;
|
|
||||||
|
|
||||||
chroma_type = -1;
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
|
|
||||||
if (formats[i].fourcc == fourcc) {
|
|
||||||
chroma_type = formats[i].chroma_type;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chroma_type == -1)
|
|
||||||
goto no_chroma_error;
|
|
||||||
|
|
||||||
/* now we transform the caps */
|
|
||||||
gst_structure_set_name (structure, "video/x-vdpau-video");
|
|
||||||
gst_structure_remove_field (structure, "format");
|
|
||||||
gst_structure_set (structure, "chroma-type", G_TYPE_INT, chroma_type, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return video_caps;
|
|
||||||
|
|
||||||
error:
|
|
||||||
gst_caps_unref (video_caps);
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
not_yuv_error:
|
|
||||||
GST_WARNING ("The caps weren't of type \"video/x-raw-yuv\"");
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
no_format_error:
|
|
||||||
GST_WARNING ("The caps didn't have a \"fourcc\" field");
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
no_chroma_error:
|
|
||||||
GST_WARNING ("The caps had an invalid \"fourcc\" field");
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_vdp_video_buffer_download (GstVdpVideoBuffer * video_buf,
|
gst_vdp_video_buffer_download (GstVdpVideoBuffer * video_buf,
|
||||||
GstBuffer * outbuf, guint32 fourcc, gint width, gint height)
|
GstBuffer * outbuf, guint32 fourcc, gint width, gint height)
|
||||||
|
|
|
@ -96,8 +96,6 @@ GstVdpVideoBuffer *gst_vdp_video_buffer_new (GstVdpDevice * device, VdpChromaTyp
|
||||||
GstCaps *gst_vdp_video_buffer_get_caps (gboolean filter, VdpChromaType chroma_type);
|
GstCaps *gst_vdp_video_buffer_get_caps (gboolean filter, VdpChromaType chroma_type);
|
||||||
GstCaps *gst_vdp_video_buffer_get_allowed_caps (GstVdpDevice * device);
|
GstCaps *gst_vdp_video_buffer_get_allowed_caps (GstVdpDevice * device);
|
||||||
|
|
||||||
GstCaps *gst_vdp_video_buffer_parse_yuv_caps (GstCaps *yuv_caps);
|
|
||||||
|
|
||||||
gboolean gst_vdp_video_buffer_calculate_size (guint32 fourcc, gint width, gint height, guint *size);
|
gboolean gst_vdp_video_buffer_calculate_size (guint32 fourcc, gint width, gint height, guint *size);
|
||||||
gboolean gst_vdp_video_buffer_download (GstVdpVideoBuffer *inbuf, GstBuffer *outbuf, guint32 fourcc, gint width, gint height);
|
gboolean gst_vdp_video_buffer_download (GstVdpVideoBuffer *inbuf, GstBuffer *outbuf, guint32 fourcc, gint width, gint height);
|
||||||
gboolean gst_vdp_video_buffer_upload (GstVdpVideoBuffer *video_buf, GstBuffer *src_buf, guint fourcc, gint width, gint height);
|
gboolean gst_vdp_video_buffer_upload (GstVdpVideoBuffer *video_buf, GstBuffer *src_buf, guint fourcc, gint width, gint height);
|
||||||
|
|
|
@ -482,7 +482,7 @@ gst_vdp_vpp_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
if (!gst_structure_get_fourcc (structure, "format", &vpp->fourcc))
|
if (!gst_structure_get_fourcc (structure, "format", &vpp->fourcc))
|
||||||
goto done;
|
goto done;
|
||||||
vpp->native_input = FALSE;
|
vpp->native_input = FALSE;
|
||||||
video_caps = gst_vdp_video_buffer_parse_yuv_caps (caps);
|
video_caps = gst_vdp_yuv_to_video_caps (caps);
|
||||||
if (!video_caps)
|
if (!video_caps)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ gst_vdp_vpp_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
vpp->native_input = TRUE;
|
vpp->native_input = TRUE;
|
||||||
video_caps = gst_caps_copy (caps);
|
video_caps = gst_caps_ref (caps);
|
||||||
|
|
||||||
if (vpp->vpool) {
|
if (vpp->vpool) {
|
||||||
g_object_unref (vpp->vpool);
|
g_object_unref (vpp->vpool);
|
||||||
|
|
Loading…
Reference in a new issue