23
23
#include "gstvdputils.h"
26
gst_vdp_video_remove_pixel_aspect_ratio (GstStructure * structure)
30
if (gst_structure_get_fraction (structure, "pixel-aspect-ratio", &par_n,
34
gst_structure_get_int (structure, "width", &width);
35
width = gst_util_uint64_scale_int (width, par_n, par_d);
36
gst_structure_set (structure, "width", G_TYPE_INT, width, NULL);
38
gst_structure_remove_field (structure, "pixel-aspect-ratio");
26
gst_vdp_video_to_yuv_caps (GstCaps * caps, GstVdpDevice * device)
43
gst_vdp_yuv_to_output_caps (GstCaps * caps)
28
GstCaps *new_caps, *allowed_caps, *result;
30
GstStructure *structure;
32
new_caps = gst_caps_new_empty ();
48
result = gst_caps_copy (caps);
34
49
for (i = 0; i < gst_caps_get_size (caps); i++) {
36
GSList *fourcc = NULL, *iter;
38
structure = gst_caps_get_structure (caps, i);
40
if (gst_structure_get_int (structure, "chroma-type", &chroma_type)) {
41
/* calculate fourcc from chroma_type */
42
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
43
if (formats[i].chroma_type == chroma_type) {
44
fourcc = g_slist_append (fourcc, GINT_TO_POINTER (formats[i].fourcc));
48
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
49
fourcc = g_slist_append (fourcc, GINT_TO_POINTER (formats[i].fourcc));
53
for (iter = fourcc; iter; iter = iter->next) {
54
GstStructure *new_struct = gst_structure_copy (structure);
56
gst_structure_set_name (new_struct, "video/x-raw-yuv");
57
gst_structure_remove_field (new_struct, "chroma-type");
58
gst_structure_set (new_struct, "format", GST_TYPE_FOURCC,
59
GPOINTER_TO_INT (iter->data), NULL);
61
gst_caps_append_structure (new_caps, new_struct);
64
g_slist_free (fourcc);
66
structure = gst_caps_get_structure (caps, 0);
69
allowed_caps = gst_vdp_video_buffer_get_allowed_yuv_caps (device);
70
result = gst_caps_intersect (new_caps, allowed_caps);
72
gst_caps_unref (new_caps);
73
gst_caps_unref (allowed_caps);
81
gst_vdp_yuv_to_video_caps (GstCaps * caps, GstVdpDevice * device)
83
GstCaps *new_caps, *result;
86
new_caps = gst_caps_copy (caps);
87
for (i = 0; i < gst_caps_get_size (new_caps); i++) {
88
GstStructure *structure = gst_caps_get_structure (new_caps, i);
91
if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
92
gint chroma_type = -1;
94
/* calculate chroma type from fourcc */
95
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
96
if (formats[i].fourcc == fourcc) {
97
chroma_type = formats[i].chroma_type;
101
gst_structure_remove_field (structure, "format");
102
gst_structure_set (structure, "chroma-type", G_TYPE_INT, chroma_type,
105
gst_structure_set (structure, "chroma-type", GST_TYPE_INT_RANGE, 0, 2,
108
gst_structure_set_name (structure, "video/x-vdpau-video");
112
GstCaps *allowed_caps;
114
allowed_caps = gst_vdp_video_buffer_get_allowed_video_caps (device);
115
result = gst_caps_intersect (new_caps, allowed_caps);
117
gst_caps_unref (new_caps);
118
gst_caps_unref (allowed_caps);
50
GstStructure *structure, *rgb_structure;
52
structure = gst_caps_get_structure (result, i);
53
rgb_structure = gst_structure_copy (structure);
55
gst_structure_set_name (structure, "video/x-vdpau-output");
56
gst_structure_remove_field (structure, "format");
57
gst_vdp_video_remove_pixel_aspect_ratio (structure);
59
gst_structure_set_name (rgb_structure, "video/x-raw-rgb");
60
gst_structure_remove_field (rgb_structure, "format");
61
gst_vdp_video_remove_pixel_aspect_ratio (rgb_structure);
62
gst_caps_append_structure (result, rgb_structure);
131
74
result = gst_caps_copy (caps);
132
for (i = 0; i < gst_caps_get_size (result); i++) {
133
GstStructure *structure = gst_caps_get_structure (result, i);
75
for (i = 0; i < gst_caps_get_size (caps); i++) {
77
GstStructure *structure, *rgb_structure;
79
structure = gst_caps_get_structure (result, i);
80
rgb_structure = gst_structure_copy (structure);
136
82
gst_structure_set_name (structure, "video/x-vdpau-output");
137
83
gst_structure_remove_field (structure, "chroma-type");
139
if (gst_structure_get_fraction (structure, "pixel-aspect-ratio", &par_n,
143
gst_structure_get_int (structure, "width", &width);
144
width = gst_util_uint64_scale_int (width, par_n, par_d);
145
gst_structure_set (structure, "width", G_TYPE_INT, width, NULL);
147
gst_structure_remove_field (structure, "pixel-aspect-ratio");
84
gst_vdp_video_remove_pixel_aspect_ratio (structure);
86
gst_structure_set_name (rgb_structure, "video/x-raw-rgb");
87
gst_structure_remove_field (structure, "chroma-type");
88
gst_vdp_video_remove_pixel_aspect_ratio (rgb_structure);
89
gst_caps_append_structure (result, rgb_structure);