vdpau: add stups for the missing functions
[mesa.git] / src / gallium / state_trackers / vdpau / mixer.c
1 /**************************************************************************
2 *
3 * Copyright 2010 Thomas Balling Sørensen.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include <vdpau/vdpau.h>
29
30 #include <util/u_memory.h>
31 #include <util/u_debug.h>
32
33 #include <vl/vl_csc.h>
34
35 #include "vdpau_private.h"
36
37 VdpStatus
38 vlVdpVideoMixerCreate(VdpDevice device,
39 uint32_t feature_count,
40 VdpVideoMixerFeature const *features,
41 uint32_t parameter_count,
42 VdpVideoMixerParameter const *parameters,
43 void const *const *parameter_values,
44 VdpVideoMixer *mixer)
45 {
46 vlVdpVideoMixer *vmixer = NULL;
47 struct pipe_video_context *context;
48 VdpStatus ret;
49 float csc[16];
50
51 debug_printf("[VDPAU] Creating VideoMixer\n");
52
53 vlVdpDevice *dev = vlGetDataHTAB(device);
54 if (!dev)
55 return VDP_STATUS_INVALID_HANDLE;
56
57 context = dev->context->vpipe;
58
59 vmixer = CALLOC(1, sizeof(vlVdpVideoMixer));
60 if (!vmixer)
61 return VDP_STATUS_RESOURCES;
62
63 vmixer->device = dev;
64 vmixer->compositor = context->create_compositor(context);
65
66 vl_csc_get_matrix
67 (
68 debug_get_bool_option("G3DVL_NO_CSC", FALSE) ?
69 VL_CSC_COLOR_STANDARD_IDENTITY : VL_CSC_COLOR_STANDARD_BT_601,
70 NULL, true, csc
71 );
72 vmixer->compositor->set_csc_matrix(vmixer->compositor, csc);
73
74 /*
75 * TODO: Handle features and parameters
76 * */
77
78 *mixer = vlAddDataHTAB(vmixer);
79 if (*mixer == 0) {
80 ret = VDP_STATUS_ERROR;
81 goto no_handle;
82 }
83
84 return VDP_STATUS_OK;
85 no_handle:
86 return ret;
87 }
88
89 VdpStatus
90 vlVdpVideoMixerDestroy(VdpVideoMixer mixer)
91 {
92 return VDP_STATUS_NO_IMPLEMENTATION;
93 }
94
95 VdpStatus
96 vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
97 uint32_t feature_count,
98 VdpVideoMixerFeature const *features,
99 VdpBool const *feature_enables)
100 {
101 debug_printf("[VDPAU] Setting VideoMixer features\n");
102
103 if (!(features && feature_enables))
104 return VDP_STATUS_INVALID_POINTER;
105
106 vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer);
107 if (!vmixer)
108 return VDP_STATUS_INVALID_HANDLE;
109
110 /*
111 * TODO: Set features
112 * */
113
114 return VDP_STATUS_OK;
115 }
116
117 VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
118 VdpOutputSurface background_surface,
119 VdpRect const *background_source_rect,
120 VdpVideoMixerPictureStructure current_picture_structure,
121 uint32_t video_surface_past_count,
122 VdpVideoSurface const *video_surface_past,
123 VdpVideoSurface video_surface_current,
124 uint32_t video_surface_future_count,
125 VdpVideoSurface const *video_surface_future,
126 VdpRect const *video_source_rect,
127 VdpOutputSurface destination_surface,
128 VdpRect const *destination_rect,
129 VdpRect const *destination_video_rect,
130 uint32_t layer_count,
131 VdpLayer const *layers)
132 {
133 vlVdpVideoMixer *vmixer;
134 vlVdpSurface *surf;
135 vlVdpOutputSurface *dst;
136
137 vmixer = vlGetDataHTAB(mixer);
138 if (!vmixer)
139 return VDP_STATUS_INVALID_HANDLE;
140
141 surf = vlGetDataHTAB(video_surface_current);
142 if (!surf)
143 return VDP_STATUS_INVALID_HANDLE;
144
145 dst = vlGetDataHTAB(destination_surface);
146 if (!dst)
147 return VDP_STATUS_INVALID_HANDLE;
148
149 vmixer->compositor->clear_layers(vmixer->compositor);
150 vmixer->compositor->set_buffer_layer(vmixer->compositor, 0, surf->video_buffer, NULL, NULL);
151 vmixer->compositor->render_picture(vmixer->compositor, PIPE_MPEG12_PICTURE_TYPE_FRAME,
152 dst->surface, NULL, NULL);
153
154 return VDP_STATUS_OK;
155 }
156
157 VdpStatus
158 vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
159 uint32_t attribute_count,
160 VdpVideoMixerAttribute const *attributes,
161 void const *const *attribute_values)
162 {
163 if (!(attributes && attribute_values))
164 return VDP_STATUS_INVALID_POINTER;
165
166 vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer);
167 if (!vmixer)
168 return VDP_STATUS_INVALID_HANDLE;
169
170 /*
171 * TODO: Implement the function
172 *
173 * */
174
175 return VDP_STATUS_OK;
176 }
177
178 VdpStatus
179 vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer,
180 uint32_t feature_count,
181 VdpVideoMixerFeature const *features,
182 VdpBool *feature_supports)
183 {
184 return VDP_STATUS_NO_IMPLEMENTATION;
185 }
186
187 VdpStatus
188 vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer,
189 uint32_t feature_count,
190 VdpVideoMixerFeature const *features,
191 VdpBool *feature_enables)
192 {
193 return VDP_STATUS_NO_IMPLEMENTATION;
194 }
195
196 VdpStatus
197 vlVdpVideoMixerGetParameterValues(VdpVideoMixer mixer,
198 uint32_t parameter_count,
199 VdpVideoMixerParameter const *parameters,
200 void *const *parameter_values)
201 {
202 return VDP_STATUS_NO_IMPLEMENTATION;
203 }
204
205 VdpStatus
206 vlVdpVideoMixerGetAttributeValues(VdpVideoMixer mixer,
207 uint32_t attribute_count,
208 VdpVideoMixerAttribute const *attributes,
209 void *const *attribute_values)
210 {
211 return VDP_STATUS_NO_IMPLEMENTATION;
212 }