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_private.h"
29 #include <pipe/p_screen.h>
30 #include <pipe/p_state.h>
31 #include <util/u_memory.h>
32 #include <util/u_format.h>
35 vlVdpVideoSurfaceCreate(VdpDevice device
,
36 VdpChromaType chroma_type
,
39 VdpVideoSurface
*surface
)
41 printf("[VDPAU] Creating a surface\n");
46 if (!(width
&& height
))
48 ret
= VDP_STATUS_INVALID_SIZE
;
53 if (!vlCreateHTAB()) {
54 ret
= VDP_STATUS_RESOURCES
;
58 p_surf
= CALLOC(1, sizeof(p_surf
));
60 ret
= VDP_STATUS_RESOURCES
;
64 vlVdpDevice
*dev
= vlGetDataHTAB(device
);
66 ret
= VDP_STATUS_INVALID_HANDLE
;
70 p_surf
->chroma_format
= TypeToPipe(chroma_type
);
72 p_surf
->width
= width
;
73 p_surf
->height
= height
;
75 *surface
= vlAddDataHTAB(p_surf
);
77 ret
= VDP_STATUS_ERROR
;
84 FREE(p_surf
->psurface
);
89 // vlDestroyHTAB(); XXX: Do not destroy this tab, I think.
96 vlVdpVideoSurfaceDestroy ( VdpVideoSurface surface
)
100 p_surf
= (vlVdpSurface
*)vlGetDataHTAB((vlHandle
)surface
);
102 return VDP_STATUS_INVALID_HANDLE
;
104 if (p_surf
->psurface
) {
105 if (p_surf
->psurface
->texture
) {
106 if (p_surf
->psurface
->texture
->screen
)
107 p_surf
->psurface
->texture
->screen
->tex_surface_destroy(p_surf
->psurface
);
111 return VDP_STATUS_OK
;
115 vlVdpVideoSurfaceGetParameters ( VdpVideoSurface surface
,
116 VdpChromaType
*chroma_type
,
121 if (!(width
&& height
&& chroma_type
))
122 return VDP_STATUS_INVALID_POINTER
;
125 vlVdpSurface
*p_surf
= vlGetDataHTAB(surface
);
127 return VDP_STATUS_INVALID_HANDLE
;
130 if (!(p_surf
->chroma_format
> 0 && p_surf
->chroma_format
< 3))
131 return VDP_STATUS_INVALID_CHROMA_TYPE
;
133 *width
= p_surf
->width
;
134 *height
= p_surf
->height
;
135 *chroma_type
= PipeToType(p_surf
->chroma_format
);
137 return VDP_STATUS_OK
;
141 vlVdpVideoSurfaceGetBitsYCbCr ( VdpVideoSurface surface
,
142 VdpYCbCrFormat destination_ycbcr_format
,
143 void *const *destination_data
,
144 uint32_t const *destination_pitches
148 return VDP_STATUS_RESOURCES
;
151 vlVdpSurface
*p_surf
= vlGetDataHTAB(surface
);
153 return VDP_STATUS_INVALID_HANDLE
;
155 if (!p_surf
->psurface
)
156 return VDP_STATUS_RESOURCES
;
159 return VDP_STATUS_OK
;
163 vlVdpVideoSurfacePutBitsYCbCr ( VdpVideoSurface surface
,
164 VdpYCbCrFormat source_ycbcr_format
,
165 void const *const *source_data
,
166 uint32_t const *source_pitches
169 uint32_t size_surface_bytes
;
170 const struct util_format_description
*format_desc
;
171 enum pipe_format pformat
= FormatToPipe(source_ycbcr_format
);
174 return VDP_STATUS_RESOURCES
;
177 vlVdpSurface
*p_surf
= vlGetDataHTAB(surface
);
179 return VDP_STATUS_INVALID_HANDLE
;
182 //size_surface_bytes = ( source_pitches[0] * p_surf->height util_format_get_blockheight(pformat) );
183 /*util_format_translate(enum pipe_format dst_format,
184 void *dst, unsigned dst_stride,
185 unsigned dst_x, unsigned dst_y,
186 enum pipe_format src_format,
187 const void *src, unsigned src_stride,
188 unsigned src_x, unsigned src_y,
189 unsigned width, unsigned height);*/
191 return VDP_STATUS_NO_IMPLEMENTATION
;