mixer.c revision 62373e8f9e948ac441d9fe355edfc0dca5f9df9c
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 90vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer, 91 uint32_t feature_count, 92 VdpVideoMixerFeature const *features, 93 VdpBool const *feature_enables) 94{ 95 debug_printf("[VDPAU] Setting VideoMixer features\n"); 96 97 if (!(features && feature_enables)) 98 return VDP_STATUS_INVALID_POINTER; 99 100 vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer); 101 if (!vmixer) 102 return VDP_STATUS_INVALID_HANDLE; 103 104 /* 105 * TODO: Set features 106 * */ 107 108 return VDP_STATUS_OK; 109} 110 111VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer, 112 VdpOutputSurface background_surface, 113 VdpRect const *background_source_rect, 114 VdpVideoMixerPictureStructure current_picture_structure, 115 uint32_t video_surface_past_count, 116 VdpVideoSurface const *video_surface_past, 117 VdpVideoSurface video_surface_current, 118 uint32_t video_surface_future_count, 119 VdpVideoSurface const *video_surface_future, 120 VdpRect const *video_source_rect, 121 VdpOutputSurface destination_surface, 122 VdpRect const *destination_rect, 123 VdpRect const *destination_video_rect, 124 uint32_t layer_count, 125 VdpLayer const *layers) 126{ 127 vlVdpVideoMixer *vmixer; 128 vlVdpSurface *surf; 129 vlVdpOutputSurface *dst; 130 131 vmixer = vlGetDataHTAB(mixer); 132 if (!vmixer) 133 return VDP_STATUS_INVALID_HANDLE; 134 135 surf = vlGetDataHTAB(video_surface_current); 136 if (!surf) 137 return VDP_STATUS_INVALID_HANDLE; 138 139 dst = vlGetDataHTAB(destination_surface); 140 if (!dst) 141 return VDP_STATUS_INVALID_HANDLE; 142 143 vmixer->compositor->clear_layers(vmixer->compositor); 144 vmixer->compositor->set_buffer_layer(vmixer->compositor, 0, surf->video_buffer, NULL, NULL); 145 vmixer->compositor->render_picture(vmixer->compositor, PIPE_MPEG12_PICTURE_TYPE_FRAME, 146 dst->surface, NULL, NULL); 147 148 return VDP_STATUS_OK; 149} 150 151VdpStatus 152vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer, 153 uint32_t attribute_count, 154 VdpVideoMixerAttribute const *attributes, 155 void const *const *attribute_values) 156{ 157 if (!(attributes && attribute_values)) 158 return VDP_STATUS_INVALID_POINTER; 159 160 vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer); 161 if (!vmixer) 162 return VDP_STATUS_INVALID_HANDLE; 163 164 /* 165 * TODO: Implement the function 166 * 167 * */ 168 169 return VDP_STATUS_OK; 170} 171