mixer.c revision 13a50bd47deff3e52470a513695c1bdb86908d73
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 37VdpStatus 38vlVdpVideoMixerCreate(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; 85no_handle: 86 return ret; 87} 88 89VdpStatus 90vlVdpVideoMixerDestroy(VdpVideoMixer mixer) 91{ 92 vlVdpVideoMixer *vmixer; 93 94 debug_printf("[VDPAU] Destroying VideoMixer\n"); 95 96 vmixer = vlGetDataHTAB(mixer); 97 if (!vmixer) 98 return VDP_STATUS_INVALID_HANDLE; 99 100 vmixer->compositor->destroy(vmixer->compositor); 101 102 FREE(vmixer); 103 104 return VDP_STATUS_OK; 105} 106 107VdpStatus 108vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer, 109 uint32_t feature_count, 110 VdpVideoMixerFeature const *features, 111 VdpBool const *feature_enables) 112{ 113 debug_printf("[VDPAU] Setting VideoMixer features\n"); 114 115 if (!(features && feature_enables)) 116 return VDP_STATUS_INVALID_POINTER; 117 118 vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer); 119 if (!vmixer) 120 return VDP_STATUS_INVALID_HANDLE; 121 122 /* 123 * TODO: Set features 124 * */ 125 126 return VDP_STATUS_OK; 127} 128 129VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer, 130 VdpOutputSurface background_surface, 131 VdpRect const *background_source_rect, 132 VdpVideoMixerPictureStructure current_picture_structure, 133 uint32_t video_surface_past_count, 134 VdpVideoSurface const *video_surface_past, 135 VdpVideoSurface video_surface_current, 136 uint32_t video_surface_future_count, 137 VdpVideoSurface const *video_surface_future, 138 VdpRect const *video_source_rect, 139 VdpOutputSurface destination_surface, 140 VdpRect const *destination_rect, 141 VdpRect const *destination_video_rect, 142 uint32_t layer_count, 143 VdpLayer const *layers) 144{ 145 vlVdpVideoMixer *vmixer; 146 vlVdpSurface *surf; 147 vlVdpOutputSurface *dst; 148 149 vmixer = vlGetDataHTAB(mixer); 150 if (!vmixer) 151 return VDP_STATUS_INVALID_HANDLE; 152 153 surf = vlGetDataHTAB(video_surface_current); 154 if (!surf) 155 return VDP_STATUS_INVALID_HANDLE; 156 157 dst = vlGetDataHTAB(destination_surface); 158 if (!dst) 159 return VDP_STATUS_INVALID_HANDLE; 160 161 vmixer->compositor->clear_layers(vmixer->compositor); 162 vmixer->compositor->set_buffer_layer(vmixer->compositor, 0, surf->video_buffer, NULL, NULL); 163 vmixer->compositor->render_picture(vmixer->compositor, PIPE_MPEG12_PICTURE_TYPE_FRAME, 164 dst->surface, NULL, NULL); 165 166 return VDP_STATUS_OK; 167} 168 169VdpStatus 170vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer, 171 uint32_t attribute_count, 172 VdpVideoMixerAttribute const *attributes, 173 void const *const *attribute_values) 174{ 175 if (!(attributes && attribute_values)) 176 return VDP_STATUS_INVALID_POINTER; 177 178 vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer); 179 if (!vmixer) 180 return VDP_STATUS_INVALID_HANDLE; 181 182 /* 183 * TODO: Implement the function 184 * 185 * */ 186 187 return VDP_STATUS_OK; 188} 189 190VdpStatus 191vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer, 192 uint32_t feature_count, 193 VdpVideoMixerFeature const *features, 194 VdpBool *feature_supports) 195{ 196 return VDP_STATUS_NO_IMPLEMENTATION; 197} 198 199VdpStatus 200vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer, 201 uint32_t feature_count, 202 VdpVideoMixerFeature const *features, 203 VdpBool *feature_enables) 204{ 205 return VDP_STATUS_NO_IMPLEMENTATION; 206} 207 208VdpStatus 209vlVdpVideoMixerGetParameterValues(VdpVideoMixer mixer, 210 uint32_t parameter_count, 211 VdpVideoMixerParameter const *parameters, 212 void *const *parameter_values) 213{ 214 return VDP_STATUS_NO_IMPLEMENTATION; 215} 216 217VdpStatus 218vlVdpVideoMixerGetAttributeValues(VdpVideoMixer mixer, 219 uint32_t attribute_count, 220 VdpVideoMixerAttribute const *attributes, 221 void *const *attribute_values) 222{ 223 return VDP_STATUS_NO_IMPLEMENTATION; 224} 225