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>
36 vlVdpVideoSurfaceCreate(VdpDevice device
,
37 VdpChromaType chroma_type
,
40 VdpVideoSurface
*surface
)
42 printf("[VDPAU] Creating a surface\n");
47 if (!(width
&& height
))
49 ret
= VDP_STATUS_INVALID_SIZE
;
54 if (!vlCreateHTAB()) {
55 ret
= VDP_STATUS_RESOURCES
;
59 p_surf
= CALLOC(1, sizeof(p_surf
));
61 ret
= VDP_STATUS_RESOURCES
;
65 vlVdpDevice
*dev
= vlGetDataHTAB(device
);
67 ret
= VDP_STATUS_INVALID_HANDLE
;
71 p_surf
->chroma_format
= FormatToPipe(chroma_type
);
74 *surface
= vlAddDataHTAB(p_surf
);
76 ret
= VDP_STATUS_ERROR
;
83 FREE(p_surf
->psurface
);
88 // vlDestroyHTAB(); XXX: Do not destroy this tab, I think.
95 vlVdpVideoSurfaceDestroy ( VdpVideoSurface surface
)
99 p_surf
= (vlVdpSurface
*)vlGetDataHTAB((vlHandle
)surface
);
101 return VDP_STATUS_INVALID_HANDLE
;
103 if (p_surf
->psurface
) {
104 if (p_surf
->psurface
->texture
) {
105 if (p_surf
->psurface
->texture
->screen
)
106 p_surf
->psurface
->texture
->screen
->tex_surface_destroy(p_surf
->psurface
);
110 return VDP_STATUS_OK
;
114 vlVdpVideoSurfaceGetParameters ( VdpVideoSurface surface
,
115 VdpChromaType
*chroma_type
,
120 if (!(width
&& height
&& chroma_type
))
121 return VDP_STATUS_INVALID_POINTER
;
124 vlVdpSurface
*p_surf
= vlGetDataHTAB(surface
);
126 return VDP_STATUS_INVALID_HANDLE
;
129 if (!(p_surf
->chroma_format
> 0 && p_surf
->chroma_format
< 3))
130 return VDP_STATUS_INVALID_CHROMA_TYPE
;
132 *width
= p_surf
->width
;
133 *height
= p_surf
->height
;
134 *chroma_type
= PipeToType(p_surf
->chroma_format
);
136 return VDP_STATUS_OK
;
140 vlVdpVideoSurfaceGetBitsYCbCr ( VdpVideoSurface surface
,
141 VdpYCbCrFormat destination_ycbcr_format
,
142 void *const *destination_data
,
143 uint32_t const *destination_pitches
147 return VDP_STATUS_RESOURCES
;
150 vlVdpSurface
*p_surf
= vlGetDataHTAB(surface
);
152 return VDP_STATUS_INVALID_HANDLE
;
154 if (!p_surf
->psurface
)
155 return VDP_STATUS_RESOURCES
;
158 return VDP_STATUS_OK
;
162 vlVdpVideoSurfacePutBitsYCbCr ( VdpVideoSurface surface
,
163 VdpYCbCrFormat source_ycbcr_format
,
164 void const *const *source_data
,
165 uint32_t const *source_pitches
168 uint32_t size_surface_bytes
;
169 const struct util_format_description
*format_desc
;
170 enum pipe_format pformat
= FormatToPipe(source_ycbcr_format
);
173 return VDP_STATUS_RESOURCES
;
176 vlVdpSurface
*p_surf
= vlGetDataHTAB(surface
);
178 return VDP_STATUS_INVALID_HANDLE
;
181 //size_surface_bytes = ( source_pitches[0] * p_surf->height util_format_get_blockheight(pformat) );
182 /*util_format_translate(enum pipe_format dst_format,
183 void *dst, unsigned dst_stride,
184 unsigned dst_x, unsigned dst_y,
185 enum pipe_format src_format,
186 const void *src, unsigned src_stride,
187 unsigned src_x, unsigned src_y,
188 unsigned width, unsigned height);*/
190 return VDP_STATUS_NO_IMPLEMENTATION
;