]> git.sesse.net Git - ffmpeg/blob - libavcodec/hwaccel.h
avcodec/amfenc: move config.h include where it's needed
[ffmpeg] / libavcodec / hwaccel.h
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18
19 #ifndef AVCODEC_HWACCEL_H
20 #define AVCODEC_HWACCEL_H
21
22 #include "avcodec.h"
23 #include "hwaccels.h"
24
25
26 #define HWACCEL_CAP_ASYNC_SAFE      (1 << 0)
27
28
29 typedef struct AVCodecHWConfigInternal {
30     /**
31      * This is the structure which will be returned to the user by
32      * avcodec_get_hw_config().
33      */
34     AVCodecHWConfig public;
35     /**
36      * If this configuration uses a hwaccel, a pointer to it.
37      * If not, NULL.
38      */
39     const AVHWAccel *hwaccel;
40 } AVCodecHWConfigInternal;
41
42
43 // These macros are used to simplify AVCodecHWConfigInternal definitions.
44
45 #define HW_CONFIG_HWACCEL(format, device, name) \
46     &(const AVCodecHWConfigInternal) { \
47         .public          = { \
48             .pix_fmt     = AV_PIX_FMT_ ## format, \
49             .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX | \
50                            AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, \
51             .device_type = AV_HWDEVICE_TYPE_ ## device, \
52         }, \
53         .hwaccel         = &name, \
54     }
55
56 #define HW_CONFIG_INTERNAL(format) \
57     &(const AVCodecHWConfigInternal) { \
58         .public          = { \
59             .pix_fmt     = AV_PIX_FMT_ ## format, \
60             .methods     = AV_CODEC_HW_CONFIG_METHOD_INTERNAL, \
61             .device_type = AV_HWDEVICE_TYPE_NONE, \
62         }, \
63         .hwaccel         = NULL, \
64     }
65
66 #define HW_CONFIG_AD_HOC_HWACCEL(format, name) \
67     &(const AVCodecHWConfigInternal) { \
68         .public =      { \
69             .pix_fmt     = AV_PIX_FMT_ ## format, \
70             .methods     = AV_CODEC_HW_CONFIG_METHOD_AD_HOC, \
71             .device_type = AV_HWDEVICE_TYPE_NONE, \
72         }, \
73         .hwaccel = &name, \
74     }
75
76 #define HWACCEL_DXVA2(codec) \
77     HW_CONFIG_HWACCEL(DXVA2_VLD, DXVA2,   ff_ ## codec ## _dxva2_hwaccel)
78 #define HWACCEL_D3D11VA2(codec) \
79     HW_CONFIG_HWACCEL(D3D11,     D3D11VA, ff_ ## codec ## _d3d11va2_hwaccel)
80 #define HWACCEL_NVDEC(codec) \
81     HW_CONFIG_HWACCEL(CUDA,      CUDA,    ff_ ## codec ## _nvdec_hwaccel)
82 #define HWACCEL_VAAPI(codec) \
83     HW_CONFIG_HWACCEL(VAAPI,     VAAPI,   ff_ ## codec ## _vaapi_hwaccel)
84 #define HWACCEL_VDPAU(codec) \
85     HW_CONFIG_HWACCEL(VDPAU,     VDPAU,   ff_ ## codec ## _vdpau_hwaccel)
86 #define HWACCEL_VIDEOTOOLBOX(codec) \
87     HW_CONFIG_HWACCEL(VIDEOTOOLBOX, VIDEOTOOLBOX, ff_ ## codec ## _videotoolbox_hwaccel)
88
89 #define HWACCEL_D3D11VA(codec) \
90     HW_CONFIG_AD_HOC_HWACCEL(D3D11VA_VLD, ff_ ## codec ## _d3d11va_hwaccel)
91 #define HWACCEL_XVMC(codec) \
92     HW_CONFIG_AD_HOC_HWACCEL(XVMC,        ff_ ## codec ## _xvmc_hwaccel)
93
94 #endif /* AVCODEC_HWACCEL_H */