1 /*****************************************************************************
2 * va.h: Video Acceleration API for avcodec
3 *****************************************************************************
4 * Copyright (C) 2009 Laurent Aimar
5 * $Id: ec327f5a68a197e70c253438e7724ddf3b9980de $
6 *
7 * Authors: Laurent Aimar <fenrir_AT_ videolan _DOT_ org>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
23
24 #include "avcommon_compat.h"
25
26 #ifndef VLC_AVCODEC_VA_H
27 #define VLC_AVCODEC_VA_H 1
28
29 typedef struct vlc_va_t vlc_va_t;
30 typedef struct vlc_va_sys_t vlc_va_sys_t;
31
32 struct vlc_va_t {
33 VLC_COMMON_MEMBERS
34
35 vlc_va_sys_t *sys;
36 module_t *module;
37 const char *description;
38
39 int (*get)(vlc_va_t *, picture_t *pic, uint8_t **data);
40 };
41
42 /**
43 * Determines the VLC video chroma value for a pair of hardware acceleration
44 * PixelFormat and software PixelFormat.
45 * @param hwfmt the hardware acceleration pixel format
46 * @param swfmt the software pixel format
47 * @return a VLC chroma value, or 0 on error.
48 */
49 vlc_fourcc_t vlc_va_GetChroma(enum PixelFormat hwfmt, enum PixelFormat swfmt);
50
51 /**
52 * Creates an accelerated video decoding back-end for libavcodec.
53 * @param obj parent VLC object
54 * @param fmt VLC format of the content to decode
55 * @return a new VLC object on success, NULL on error.
56 */
57 vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *,
58 enum PixelFormat, const es_format_t *fmt,
59 picture_sys_t *p_sys);
60
61 /**
62 * Allocates a hardware video surface for a libavcodec frame.
63 * The surface will be used as output for the hardware decoder, and possibly
64 * also as a reference frame to decode other surfaces.
65 *
66 * @param pic pointer to VLC picture being allocated [IN/OUT]
67 * @param data pointer to the AVFrame data[0] and data[3] pointers [OUT]
68 *
69 * @note This function needs not be reentrant.
70 *
71 * @return VLC_SUCCESS on success, otherwise an error code.
72 */
vlc_va_Get(vlc_va_t * va,picture_t * pic,uint8_t ** data)73 static inline int vlc_va_Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
74 {
75 return va->get(va, pic, data);
76 }
77
78 /**
79 * Destroys a libavcodec hardware acceleration back-end.
80 * All allocated surfaces shall have been released beforehand.
81 */
82 void vlc_va_Delete(vlc_va_t *, void **);
83
84 #endif
85