1 /**************************************************************************
3 * Copyright 2010 Thomas Balling Sørensen.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #include <vdpau/vdpau.h>
30 #include "util/u_memory.h"
31 #include "util/u_debug.h"
33 #include "vl/vl_csc.h"
35 #include "vdpau_private.h"
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
,
46 vlVdpVideoMixer
*vmixer
= NULL
;
50 VDPAU_MSG(VDPAU_TRACE
, "[VDPAU] Creating VideoMixer\n");
52 vlVdpDevice
*dev
= vlGetDataHTAB(device
);
54 return VDP_STATUS_INVALID_HANDLE
;
56 vmixer
= CALLOC(1, sizeof(vlVdpVideoMixer
));
58 return VDP_STATUS_RESOURCES
;
61 vl_compositor_init(&vmixer
->compositor
, dev
->context
->pipe
);
65 debug_get_bool_option("G3DVL_NO_CSC", FALSE
) ?
66 VL_CSC_COLOR_STANDARD_IDENTITY
: VL_CSC_COLOR_STANDARD_BT_601
,
69 vl_compositor_set_csc_matrix(&vmixer
->compositor
, csc
);
72 * TODO: Handle features and parameters
75 *mixer
= vlAddDataHTAB(vmixer
);
77 ret
= VDP_STATUS_ERROR
;
88 vlVdpVideoMixerDestroy(VdpVideoMixer mixer
)
90 vlVdpVideoMixer
*vmixer
;
92 VDPAU_MSG(VDPAU_TRACE
, "[VDPAU] Destroying VideoMixer\n");
94 vmixer
= vlGetDataHTAB(mixer
);
96 return VDP_STATUS_INVALID_HANDLE
;
98 vl_compositor_cleanup(&vmixer
->compositor
);
102 return VDP_STATUS_OK
;
106 vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer
,
107 uint32_t feature_count
,
108 VdpVideoMixerFeature
const *features
,
109 VdpBool
const *feature_enables
)
111 VDPAU_MSG(VDPAU_TRACE
, "[VDPAU] Setting VideoMixer features\n");
113 if (!(features
&& feature_enables
))
114 return VDP_STATUS_INVALID_POINTER
;
116 vlVdpVideoMixer
*vmixer
= vlGetDataHTAB(mixer
);
118 return VDP_STATUS_INVALID_HANDLE
;
124 return VDP_STATUS_OK
;
127 VdpStatus
vlVdpVideoMixerRender(VdpVideoMixer mixer
,
128 VdpOutputSurface background_surface
,
129 VdpRect
const *background_source_rect
,
130 VdpVideoMixerPictureStructure current_picture_structure
,
131 uint32_t video_surface_past_count
,
132 VdpVideoSurface
const *video_surface_past
,
133 VdpVideoSurface video_surface_current
,
134 uint32_t video_surface_future_count
,
135 VdpVideoSurface
const *video_surface_future
,
136 VdpRect
const *video_source_rect
,
137 VdpOutputSurface destination_surface
,
138 VdpRect
const *destination_rect
,
139 VdpRect
const *destination_video_rect
,
140 uint32_t layer_count
,
141 VdpLayer
const *layers
)
143 struct pipe_video_rect src_rect
;
145 vlVdpVideoMixer
*vmixer
;
147 vlVdpOutputSurface
*dst
;
149 vmixer
= vlGetDataHTAB(mixer
);
151 return VDP_STATUS_INVALID_HANDLE
;
153 surf
= vlGetDataHTAB(video_surface_current
);
155 return VDP_STATUS_INVALID_HANDLE
;
157 dst
= vlGetDataHTAB(destination_surface
);
159 return VDP_STATUS_INVALID_HANDLE
;
161 vl_compositor_clear_layers(&vmixer
->compositor
);
162 vl_compositor_set_buffer_layer(&vmixer
->compositor
, 0, surf
->video_buffer
,
163 RectToPipe(video_source_rect
, &src_rect
), NULL
);
164 vl_compositor_render(&vmixer
->compositor
, dst
->surface
, NULL
, NULL
, false);
166 return VDP_STATUS_OK
;
170 vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer
,
171 uint32_t attribute_count
,
172 VdpVideoMixerAttribute
const *attributes
,
173 void const *const *attribute_values
)
175 if (!(attributes
&& attribute_values
))
176 return VDP_STATUS_INVALID_POINTER
;
178 vlVdpVideoMixer
*vmixer
= vlGetDataHTAB(mixer
);
180 return VDP_STATUS_INVALID_HANDLE
;
183 * TODO: Implement the function
186 return VDP_STATUS_OK
;
190 vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer
,
191 uint32_t feature_count
,
192 VdpVideoMixerFeature
const *features
,
193 VdpBool
*feature_supports
)
195 return VDP_STATUS_NO_IMPLEMENTATION
;
199 vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer
,
200 uint32_t feature_count
,
201 VdpVideoMixerFeature
const *features
,
202 VdpBool
*feature_enables
)
204 return VDP_STATUS_NO_IMPLEMENTATION
;
208 vlVdpVideoMixerGetParameterValues(VdpVideoMixer mixer
,
209 uint32_t parameter_count
,
210 VdpVideoMixerParameter
const *parameters
,
211 void *const *parameter_values
)
213 return VDP_STATUS_NO_IMPLEMENTATION
;
217 vlVdpVideoMixerGetAttributeValues(VdpVideoMixer mixer
,
218 uint32_t attribute_count
,
219 VdpVideoMixerAttribute
const *attributes
,
220 void *const *attribute_values
)
222 return VDP_STATUS_NO_IMPLEMENTATION
;
226 vlVdpGenerateCSCMatrix(VdpProcamp
*procamp
,
227 VdpColorStandard standard
,
228 VdpCSCMatrix
*csc_matrix
)
230 VDPAU_MSG(VDPAU_TRACE
, "[VDPAU] Generating CSCMatrix\n");
231 if (!(csc_matrix
&& procamp
))
232 return VDP_STATUS_INVALID_POINTER
;
234 return VDP_STATUS_OK
;