~ubuntu-branches/ubuntu/precise/gst-plugins-bad0.10/precise-proposed

« back to all changes in this revision

Viewing changes to sys/vdpau/gstvdputils.c

Tags: upstream-0.10.17.2
Import upstream version 0.10.17.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include "gstvdputils.h"
24
24
 
 
25
static void
 
26
gst_vdp_video_remove_pixel_aspect_ratio (GstStructure * structure)
 
27
{
 
28
  gint par_n, par_d;
 
29
 
 
30
  if (gst_structure_get_fraction (structure, "pixel-aspect-ratio", &par_n,
 
31
          &par_d)) {
 
32
    gint width;
 
33
 
 
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);
 
37
 
 
38
    gst_structure_remove_field (structure, "pixel-aspect-ratio");
 
39
  }
 
40
}
 
41
 
25
42
GstCaps *
26
 
gst_vdp_video_to_yuv_caps (GstCaps * caps, GstVdpDevice * device)
 
43
gst_vdp_yuv_to_output_caps (GstCaps * caps)
27
44
{
28
 
  GstCaps *new_caps, *allowed_caps, *result;
 
45
  GstCaps *result;
29
46
  gint i;
30
 
  GstStructure *structure;
31
 
 
32
 
  new_caps = gst_caps_new_empty ();
33
 
 
 
47
 
 
48
  result = gst_caps_copy (caps);
34
49
  for (i = 0; i < gst_caps_get_size (caps); i++) {
35
 
    gint chroma_type;
36
 
    GSList *fourcc = NULL, *iter;
37
 
 
38
 
    structure = gst_caps_get_structure (caps, i);
39
 
 
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));
45
 
        }
46
 
      }
47
 
    } else {
48
 
      for (i = 0; i < G_N_ELEMENTS (formats); i++) {
49
 
        fourcc = g_slist_append (fourcc, GINT_TO_POINTER (formats[i].fourcc));
50
 
      }
51
 
    }
52
 
 
53
 
    for (iter = fourcc; iter; iter = iter->next) {
54
 
      GstStructure *new_struct = gst_structure_copy (structure);
55
 
 
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);
60
 
 
61
 
      gst_caps_append_structure (new_caps, new_struct);
62
 
    }
63
 
 
64
 
    g_slist_free (fourcc);
65
 
  }
66
 
  structure = gst_caps_get_structure (caps, 0);
67
 
 
68
 
  if (device) {
69
 
    allowed_caps = gst_vdp_video_buffer_get_allowed_yuv_caps (device);
70
 
    result = gst_caps_intersect (new_caps, allowed_caps);
71
 
 
72
 
    gst_caps_unref (new_caps);
73
 
    gst_caps_unref (allowed_caps);
74
 
  } else
75
 
    result = new_caps;
76
 
 
77
 
  return result;
78
 
}
79
 
 
80
 
GstCaps *
81
 
gst_vdp_yuv_to_video_caps (GstCaps * caps, GstVdpDevice * device)
82
 
{
83
 
  GstCaps *new_caps, *result;
84
 
  gint i;
85
 
 
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);
89
 
    guint32 fourcc;
90
 
 
91
 
    if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
92
 
      gint chroma_type = -1;
93
 
 
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;
98
 
          break;
99
 
        }
100
 
      }
101
 
      gst_structure_remove_field (structure, "format");
102
 
      gst_structure_set (structure, "chroma-type", G_TYPE_INT, chroma_type,
103
 
          NULL);
104
 
    } else
105
 
      gst_structure_set (structure, "chroma-type", GST_TYPE_INT_RANGE, 0, 2,
106
 
          NULL);
107
 
 
108
 
    gst_structure_set_name (structure, "video/x-vdpau-video");
109
 
  }
110
 
 
111
 
  if (device) {
112
 
    GstCaps *allowed_caps;
113
 
 
114
 
    allowed_caps = gst_vdp_video_buffer_get_allowed_video_caps (device);
115
 
    result = gst_caps_intersect (new_caps, allowed_caps);
116
 
 
117
 
    gst_caps_unref (new_caps);
118
 
    gst_caps_unref (allowed_caps);
119
 
  } else
120
 
    result = new_caps;
 
50
    GstStructure *structure, *rgb_structure;
 
51
 
 
52
    structure = gst_caps_get_structure (result, i);
 
53
    rgb_structure = gst_structure_copy (structure);
 
54
 
 
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);
 
58
 
 
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);
 
63
  }
121
64
 
122
65
  return result;
123
66
}
129
72
  gint i;
130
73
 
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);
134
 
    gint par_n, par_d;
 
75
  for (i = 0; i < gst_caps_get_size (caps); i++) {
 
76
 
 
77
    GstStructure *structure, *rgb_structure;
 
78
 
 
79
    structure = gst_caps_get_structure (result, i);
 
80
    rgb_structure = gst_structure_copy (structure);
135
81
 
136
82
    gst_structure_set_name (structure, "video/x-vdpau-output");
137
83
    gst_structure_remove_field (structure, "chroma-type");
138
 
 
139
 
    if (gst_structure_get_fraction (structure, "pixel-aspect-ratio", &par_n,
140
 
            &par_d)) {
141
 
      gint width;
142
 
 
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);
146
 
 
147
 
      gst_structure_remove_field (structure, "pixel-aspect-ratio");
148
 
    }
 
84
    gst_vdp_video_remove_pixel_aspect_ratio (structure);
 
85
 
 
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);
149
90
  }
150
91
 
151
92
  return result;