Merge remote branch 'origin/master' into pipe-video
[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 #include <util/u_memory.h>
30 #include <util/u_debug.h>
31 #include "vdpau_private.h"
32
33 VdpStatus
34 vlVdpVideoMixerCreate(VdpDevice device,
35 uint32_t feature_count,
36 VdpVideoMixerFeature const *features,
37 uint32_t parameter_count,
38 VdpVideoMixerParameter const *parameters,
39 void const *const *parameter_values,
40 VdpVideoMixer *mixer)
41 {
42 VdpStatus ret;
43 vlVdpVideoMixer *vmixer = NULL;
44
45 debug_printf("[VDPAU] Creating VideoMixer\n");
46
47 vlVdpDevice *dev = vlGetDataHTAB(device);
48 if (!dev)
49 return VDP_STATUS_INVALID_HANDLE;
50
51 vmixer = CALLOC(1, sizeof(vlVdpVideoMixer));
52 if (!vmixer)
53 return VDP_STATUS_RESOURCES;
54
55 vmixer->device = dev;
56 /*
57 * TODO: Handle features and parameters
58 * */
59
60 *mixer = vlAddDataHTAB(vmixer);
61 if (*mixer == 0) {
62 ret = VDP_STATUS_ERROR;
63 goto no_handle;
64 }
65
66 return VDP_STATUS_OK;
67 no_handle:
68 return ret;
69 }
70
71 VdpStatus
72 vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
73 uint32_t feature_count,
74 VdpVideoMixerFeature const *features,
75 VdpBool const *feature_enables)
76 {
77 debug_printf("[VDPAU] Setting VideoMixer features\n");
78
79 if (!(features && feature_enables))
80 return VDP_STATUS_INVALID_POINTER;
81
82 vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer);
83 if (!vmixer)
84 return VDP_STATUS_INVALID_HANDLE;
85
86 /*
87 * TODO: Set features
88 * */
89
90 return VDP_STATUS_OK;
91 }
92
93 VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
94 VdpOutputSurface background_surface,
95 VdpRect const *background_source_rect,
96 VdpVideoMixerPictureStructure current_picture_structure,
97 uint32_t video_surface_past_count,
98 VdpVideoSurface const *video_surface_past,
99 VdpVideoSurface video_surface_current,
100 uint32_t video_surface_future_count,
101 VdpVideoSurface const *video_surface_future,
102 VdpRect const *video_source_rect,
103 VdpOutputSurface destination_surface,
104 VdpRect const *destination_rect,
105 VdpRect const *destination_video_rect,
106 uint32_t layer_count,
107 VdpLayer const *layers)
108 {
109 if (!(background_source_rect && video_surface_past && video_surface_future &&
110 video_source_rect && destination_rect && destination_video_rect && layers))
111 return VDP_STATUS_INVALID_POINTER;
112
113 return VDP_STATUS_NO_IMPLEMENTATION;
114 }
115
116 VdpStatus
117 vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
118 uint32_t attribute_count,
119 VdpVideoMixerAttribute const *attributes,
120 void const *const *attribute_values)
121 {
122 if (!(attributes && attribute_values))
123 return VDP_STATUS_INVALID_POINTER;
124
125 vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer);
126 if (!vmixer)
127 return VDP_STATUS_INVALID_HANDLE;
128
129 /*
130 * TODO: Implement the function
131 *
132 * */
133
134 return VDP_STATUS_OK;
135 }