aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/hwaccel.h
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-10-26 00:18:40 +0100
committerMark Thompson <sw@jkqxz.net>2017-11-26 21:35:53 +0000
commit758fbc54fef2f31957b5c5f22e05e5fd9b04f631 (patch)
tree45b66ac7797cec7968add561498acf75cc4871c2 /libavcodec/hwaccel.h
parent24cc0a53e99e281b0ff502e82e7cf857111eca3f (diff)
downloadffmpeg-758fbc54fef2f31957b5c5f22e05e5fd9b04f631.tar.gz
lavc: Add hardware config metadata for decoders supporting hardware output
This includes a pointer to the associated hwaccel for decoders using hwaccels - these will be used later to implement the hwaccel setup without needing a global list. Also added is a new file listing all hwaccels as external declarations - this will be used later to generate the hwaccel list at configure time.
Diffstat (limited to 'libavcodec/hwaccel.h')
-rw-r--r--libavcodec/hwaccel.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/libavcodec/hwaccel.h b/libavcodec/hwaccel.h
index 0198c7f858..ae55527c2f 100644
--- a/libavcodec/hwaccel.h
+++ b/libavcodec/hwaccel.h
@@ -20,6 +20,7 @@
#define AVCODEC_HWACCEL_H
#include "avcodec.h"
+#include "hwaccels.h"
#define HWACCEL_CAP_ASYNC_SAFE (1 << 0)
@@ -39,4 +40,55 @@ typedef struct AVCodecHWConfigInternal {
} AVCodecHWConfigInternal;
+// These macros are used to simplify AVCodecHWConfigInternal definitions.
+
+#define HW_CONFIG_HWACCEL(format, device, name) \
+ &(const AVCodecHWConfigInternal) { \
+ .public = { \
+ .pix_fmt = AV_PIX_FMT_ ## format, \
+ .methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX | \
+ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, \
+ .device_type = AV_HWDEVICE_TYPE_ ## device, \
+ }, \
+ .hwaccel = &name, \
+ }
+
+#define HW_CONFIG_INTERNAL(format) \
+ &(const AVCodecHWConfigInternal) { \
+ .public = { \
+ .pix_fmt = AV_PIX_FMT_ ## format, \
+ .methods = AV_CODEC_HW_CONFIG_METHOD_INTERNAL, \
+ .device_type = AV_HWDEVICE_TYPE_NONE, \
+ }, \
+ .hwaccel = NULL, \
+ }
+
+#define HW_CONFIG_AD_HOC_HWACCEL(format, name) \
+ &(const AVCodecHWConfigInternal) { \
+ .public = { \
+ .pix_fmt = AV_PIX_FMT_ ## format, \
+ .methods = AV_CODEC_HW_CONFIG_METHOD_AD_HOC, \
+ .device_type = AV_HWDEVICE_TYPE_NONE, \
+ }, \
+ .hwaccel = &name, \
+ }
+
+#define HWACCEL_DXVA2(codec) \
+ HW_CONFIG_HWACCEL(DXVA2_VLD, DXVA2, ff_ ## codec ## _dxva2_hwaccel)
+#define HWACCEL_D3D11VA2(codec) \
+ HW_CONFIG_HWACCEL(D3D11, D3D11VA, ff_ ## codec ## _d3d11va2_hwaccel)
+#define HWACCEL_NVDEC(codec) \
+ HW_CONFIG_HWACCEL(CUDA, CUDA, ff_ ## codec ## _nvdec_hwaccel)
+#define HWACCEL_VAAPI(codec) \
+ HW_CONFIG_HWACCEL(VAAPI, VAAPI, ff_ ## codec ## _vaapi_hwaccel)
+#define HWACCEL_VDPAU(codec) \
+ HW_CONFIG_HWACCEL(VDPAU, VDPAU, ff_ ## codec ## _vdpau_hwaccel)
+#define HWACCEL_VIDEOTOOLBOX(codec) \
+ HW_CONFIG_HWACCEL(VIDEOTOOLBOX, VIDEOTOOLBOX, ff_ ## codec ## _videotoolbox_hwaccel)
+
+#define HWACCEL_D3D11VA(codec) \
+ HW_CONFIG_AD_HOC_HWACCEL(D3D11VA_VLD, ff_ ## codec ## _d3d11va_hwaccel)
+#define HWACCEL_XVMC(codec) \
+ HW_CONFIG_AD_HOC_HWACCEL(XVMC, ff_ ## codec ## _xvmc_hwaccel)
+
#endif /* AVCODEC_HWACCEL_H */