---
libavcodec/h263dec.c | 10 ++++++++++
libavcodec/h264dec.c | 19 +++++++++++++++++++
libavcodec/hevcdec.c | 19 +++++++++++++++++++
libavcodec/hwaccel.h | 27 +++++++++++++++++++++++++++
libavcodec/mmaldec.c | 7 +++++++
libavcodec/mpeg12dec.c | 24 +++++++++++++++++++++++-
libavcodec/mpeg4videodec.c | 10 ++++++++++
libavcodec/qsvdec.c | 11 +++++++++++
libavcodec/qsvdec.h | 2 ++
libavcodec/qsvdec_h2645.c | 2 ++
libavcodec/qsvdec_other.c | 3 +++
libavcodec/vc1dec.c | 19 +++++++++++++++++++
libavcodec/vp8.c | 7 +++++++
13 files changed, 159 insertions(+), 1 deletion(-)
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 921ff5fb9..58f31eb8d 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -31,6 +31,7 @@
#include "flv.h"
#include "h263.h"
#include "h263_parser.h"
+#include "hwaccel.h"
#include "internal.h"
#include "mpeg_er.h"
#include "mpeg4video.h"
@@ -677,4 +678,13 @@ AVCodec ff_h263_decoder = {
AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY,
.flush = ff_mpeg_flush,
.pix_fmts = ff_h263_hwaccel_pixfmt_list_420,
+ .hw_configs = (const AVCodecHWConfig*[]) {
+#if CONFIG_H263_VAAPI_HWACCEL
+ HWACCEL_VAAPI,
+#endif
+#if CONFIG_MPEG4_VDPAU_HWACCEL
+ HWACCEL_VDPAU,
+#endif
+ NULL
+ },
};
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 7a8293efa..28114549d 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -44,6 +44,7 @@
#include "h264chroma.h"
#include "h264_mvpred.h"
#include "h264_ps.h"
+#include "hwaccel.h"
#include "mathops.h"
#include "me_cmp.h"
#include "mpegutils.h"
@@ -786,6 +787,24 @@ AVCodec ff_h264_decoder = {
.capabilities = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/
AV_CODEC_CAP_DR1 |
AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
AV_CODEC_CAP_FRAME_THREADS,
+ .hw_configs = (const AVCodecHWConfig*[]) {
+#if CONFIG_H264_CUVID_HWACCEL
+ HWACCEL_CUVID,
+#endif
+#if CONFIG_H264_DXVA2_HWACCEL
+ HWACCEL_DXVA2,
+#endif
+#if CONFIG_H264_D3D11VA2_HWACCEL
+ HWACCEL_D3D11VA,
+#endif
+#if CONFIG_H264_VAAPI_HWACCEL
+ HWACCEL_VAAPI,
+#endif
+#if CONFIG_H264_VDPAU_HWACCEL
+ HWACCEL_VDPAU,
+#endif
+ NULL
+ },
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
FF_CODEC_CAP_EXPORTS_CROPPING,
.flush = flush_dpb,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index a1619cf4b..4b89ce87e 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -39,6 +39,7 @@
#include "hevc.h"
#include "hevc_data.h"
#include "hevcdec.h"
+#include "hwaccel.h"
#include "profiles.h"
const uint8_t ff_hevc_qpel_extra_before[4] = { 0, 3, 3, 3 };
@@ -3113,4 +3114,22 @@ AVCodec ff_hevc_decoder = {
AV_CODEC_CAP_FRAME_THREADS,
.profiles = NULL_IF_CONFIG_SMALL(ff_hevc_profiles),
.caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING |
FF_CODEC_CAP_INIT_THREADSAFE,
+ .hw_configs = (const AVCodecHWConfig*[]) {
+#if CONFIG_HEVC_CUVID_HWACCEL
+ HWACCEL_CUVID,
+#endif
+#if CONFIG_HEVC_DXVA2_HWACCEL
+ HWACCEL_DXVA2,
+#endif
+#if CONFIG_HEVC_D3D11VA2_HWACCEL
+ HWACCEL_D3D11VA,
+#endif
+#if CONFIG_HEVC_VAAPI_HWACCEL
+ HWACCEL_VAAPI,
+#endif
+#if CONFIG_HEVC_VDPAU_HWACCEL
+ HWACCEL_VDPAU,
+#endif
+ NULL
+ },
};
diff --git a/libavcodec/hwaccel.h b/libavcodec/hwaccel.h
index 60dbe81c8..aa9182cc3 100644
--- a/libavcodec/hwaccel.h
+++ b/libavcodec/hwaccel.h
@@ -21,4 +21,31 @@
#define HWACCEL_CAP_ASYNC_SAFE (1 << 0)
+
+// These are used to simplify AVCodecHWConfig definitions.
+
+#define HW_CONFIG_HWACCEL(format, device) \
+ &(const AVCodecHWConfig) { \
+ .pix_fmt = AV_PIX_FMT_ ## format, \
+ .methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX | \
+ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, \
+ .hwaccel = 1, \
+ .device_type = AV_HWDEVICE_TYPE_ ## device, \
+ }
+
+#define HW_CONFIG_INTERNAL(format) \
+ &(const AVCodecHWConfig) { \
+ .pix_fmt = AV_PIX_FMT_ ## format, \
+ .methods = AV_CODEC_HW_CONFIG_METHOD_INTERNAL, \
+ .hwaccel = 0, \
+ .device_type = AV_HWDEVICE_TYPE_NONE, \
+ }
+
+#define HWACCEL_CUVID HW_CONFIG_HWACCEL(CUDA, CUDA)
+#define HWACCEL_DXVA2 HW_CONFIG_HWACCEL(DXVA2_VLD, DXVA2)
+#define HWACCEL_D3D11VA HW_CONFIG_HWACCEL(D3D11, D3D11VA)
+#define HWACCEL_VAAPI HW_CONFIG_HWACCEL(VAAPI, VAAPI)
+#define HWACCEL_VDPAU HW_CONFIG_HWACCEL(VDPAU, VDPAU)
+
+
#endif /* AVCODEC_HWACCEL_H */
diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 023ebe80d..1b34e398b 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -34,6 +34,7 @@
#include <stdatomic.h>
#include "avcodec.h"
+#include "hwaccel.h"
#include "internal.h"
#include "libavutil/avassert.h"
#include "libavutil/buffer.h"
@@ -808,6 +809,11 @@ AVHWAccel ff_vc1_mmal_hwaccel = {
.pix_fmt = AV_PIX_FMT_MMAL,
};
+static const AVCodecHWConfig *mmal_hw_configs = {
+ HW_CONFIG_INTERNAL(MMAL),
+ NULL
+};
+
static const AVOption options[]={
{"extra_buffers", "extra buffers", offsetof(MMALDecodeContext,
extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0},
{"extra_decoder_buffers", "extra MMAL internal buffered frames",
offsetof(MMALDecodeContext, extra_decoder_buffers), AV_OPT_TYPE_INT, {.i64 =
10}, 0, 256, 0},
@@ -840,6 +846,7 @@ static const AVOption options[]={
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MMAL, \
AV_PIX_FMT_YUV420P, \
AV_PIX_FMT_NONE}, \
+ .hw_configs = mmal_hw_configs,
};
FFMMAL_DEC(h264, AV_CODEC_ID_H264)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 9a9a92701..d0a2ac816 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -34,6 +34,7 @@
#include "avcodec.h"
#include "bytestream.h"
#include "error_resilience.h"
+#include "hwaccel.h"
#include "idctdsp.h"
#include "internal.h"
#include "mpeg_er.h"
@@ -2594,7 +2595,13 @@ AVCodec ff_mpeg1video_decoder = {
AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
AV_CODEC_CAP_SLICE_THREADS,
.flush = flush,
- .update_thread_context =
ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context)
+ .update_thread_context =
ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context),
+ .hw_configs = (const AVCodecHWConfig*[]) {
+#if CONFIG_MPEG1_VDPAU_HWACCEL
+ HWACCEL_VDPAU,
+#endif
+ NULL
+ },
};
AVCodec ff_mpeg2video_decoder = {
@@ -2611,4 +2618,19 @@ AVCodec ff_mpeg2video_decoder = {
AV_CODEC_CAP_SLICE_THREADS,
.flush = flush,
.profiles = NULL_IF_CONFIG_SMALL(ff_mpeg2_video_profiles),
+ .hw_configs = (const AVCodecHWConfig*[]) {
+#if CONFIG_MPEG2_DXVA2_HWACCEL
+ HWACCEL_DXVA2,
+#endif
+#if CONFIG_MPEG2_D3D11VA2_HWACCEL
+ HWACCEL_D3D11VA,
+#endif
+#if CONFIG_MPEG2_VAAPI_HWACCEL
+ HWACCEL_VAAPI,
+#endif
+#if CONFIG_MPEG2_VDPAU_HWACCEL
+ HWACCEL_VDPAU,
+#endif
+ NULL
+ },
};
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index eb1b67273..0ccc96e5c 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -21,6 +21,7 @@
*/
#include "error_resilience.h"
+#include "hwaccel.h"
#include "idctdsp.h"
#include "internal.h"
#include "mpegutils.h"
@@ -2625,6 +2626,15 @@ AVCodec ff_mpeg4_decoder = {
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
AV_CODEC_CAP_FRAME_THREADS,
+ .hw_configs = (const AVCodecHWConfig*[]) {
+#if CONFIG_MPEG4_VAAPI_HWACCEL
+ HWACCEL_VAAPI,
+#endif
+#if CONFIG_MPEG4_VDPAU_HWACCEL
+ HWACCEL_VDPAU,
+#endif
+ NULL
+ },
.flush = ff_mpeg_flush,
.pix_fmts = ff_h263_hwaccel_pixfmt_list_420,
.profiles = NULL_IF_CONFIG_SMALL(ff_mpeg4_video_profiles),
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 2c90436a1..306ffdd25 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -41,6 +41,17 @@
#include "qsv_internal.h"
#include "qsvdec.h"
+const AVCodecHWConfig *ff_qsv_hw_configs[] = {
+ &(const AVCodecHWConfig) {
+ .pix_fmt = AV_PIX_FMT_QSV,
+ .methods = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
+ AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
+ .hwaccel = 0,
+ .device_type = AV_HWDEVICE_TYPE_QSV,
+ },
+ NULL
+};
+
static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession
session,
AVBufferRef *hw_frames_ref, AVBufferRef
*hw_device_ref)
{
diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h
index c6ec99af1..22d74d999 100644
--- a/libavcodec/qsvdec.h
+++ b/libavcodec/qsvdec.h
@@ -70,6 +70,8 @@ typedef struct QSVContext {
int nb_ext_buffers;
} QSVContext;
+extern const AVCodecHWConfig *ff_qsv_hw_configs[];
+
int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q,
AVFrame *frame, int *got_frame, AVPacket *pkt);
diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
index a2a6cc3c4..05c1db3d7 100644
--- a/libavcodec/qsvdec_h2645.c
+++ b/libavcodec/qsvdec_h2645.c
@@ -220,6 +220,7 @@ AVCodec ff_hevc_qsv_decoder = {
AV_PIX_FMT_P010,
AV_PIX_FMT_QSV,
AV_PIX_FMT_NONE },
+ .hw_configs = ff_qsv_hw_configs,
.bsfs = "hevc_mp4toannexb",
};
#endif
@@ -262,6 +263,7 @@ AVCodec ff_h264_qsv_decoder = {
AV_PIX_FMT_P010,
AV_PIX_FMT_QSV,
AV_PIX_FMT_NONE },
+ .hw_configs = ff_qsv_hw_configs,
.bsfs = "h264_mp4toannexb",
};
#endif
diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
index 3ea1859bf..0a506a154 100644
--- a/libavcodec/qsvdec_other.c
+++ b/libavcodec/qsvdec_other.c
@@ -190,6 +190,7 @@ AVCodec ff_mpeg2_qsv_decoder = {
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
AV_PIX_FMT_QSV,
AV_PIX_FMT_NONE },
+ .hw_configs = ff_qsv_hw_configs,
};
#endif
@@ -225,6 +226,7 @@ AVCodec ff_vc1_qsv_decoder = {
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
AV_PIX_FMT_QSV,
AV_PIX_FMT_NONE },
+ .hw_configs = ff_qsv_hw_configs,
};
#endif
@@ -260,5 +262,6 @@ AVCodec ff_vp8_qsv_decoder = {
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
AV_PIX_FMT_QSV,
AV_PIX_FMT_NONE },
+ .hw_configs = ff_qsv_hw_configs,
};
#endif
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 5e00a33e3..3e5c14ac5 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -29,6 +29,7 @@
#include "avcodec.h"
#include "blockdsp.h"
#include "get_bits.h"
+#include "hwaccel.h"
#include "internal.h"
#include "mpeg_er.h"
#include "mpegvideo.h"
@@ -974,6 +975,22 @@ static const enum AVPixelFormat
vc1_hwaccel_pixfmt_list_420[] = {
AV_PIX_FMT_NONE
};
+static const AVCodecHWConfig *vc1_hw_configs[] = {
+#if CONFIG_VC1_DXVA2_HWACCEL
+ HWACCEL_DXVA2,
+#endif
+#if CONFIG_VC1_D3D11VA2_HWACCEL
+ HWACCEL_D3D11VA,
+#endif
+#if CONFIG_VC1_VAAPI_HWACCEL
+ HWACCEL_VAAPI,
+#endif
+#if CONFIG_VC1_VDPAU_HWACCEL
+ HWACCEL_VDPAU,
+#endif
+ NULL
+};
+
AVCodec ff_vc1_decoder = {
.name = "vc1",
.long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"),
@@ -986,6 +1003,7 @@ AVCodec ff_vc1_decoder = {
.flush = ff_mpeg_flush,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
.pix_fmts = vc1_hwaccel_pixfmt_list_420,
+ .hw_configs = vc1_hw_configs,
.profiles = NULL_IF_CONFIG_SMALL(ff_vc1_profiles)
};
@@ -1002,6 +1020,7 @@ AVCodec ff_wmv3_decoder = {
.flush = ff_mpeg_flush,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
.pix_fmts = vc1_hwaccel_pixfmt_list_420,
+ .hw_configs = vc1_hw_configs,
.profiles = NULL_IF_CONFIG_SMALL(ff_vc1_profiles)
};
#endif
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 43580a3a8..08614a6a5 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -27,6 +27,7 @@
#include "libavutil/imgutils.h"
#include "avcodec.h"
+#include "hwaccel.h"
#include "internal.h"
#include "mathops.h"
#include "rectangle.h"
@@ -2851,6 +2852,12 @@ AVCodec ff_vp8_decoder = {
.decode = ff_vp8_decode_frame,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
AV_CODEC_CAP_SLICE_THREADS,
+ .hw_configs = (const AVCodecHWConfig*[]) {
+#if CONFIG_VP8_VAAPI_HWACCEL
+ HWACCEL_VAAPI,
+#endif
+ NULL
+ },
.flush = vp8_decode_flush,
.init_thread_copy =
ONLY_IF_THREADS_ENABLED(vp8_decode_init_thread_copy),
.update_thread_context =
ONLY_IF_THREADS_ENABLED(vp8_decode_update_thread_context),
--
2.11.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel