Re: [FFmpeg-devel] [PATCH 02/13] lavc: Add hardware config metadata for decoders supporting hardware output

2017-11-20 Thread Philip Langdale

On 2017-11-18 10:47, Mark Thompson wrote:

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.
---
 libavcodec/cuviddec.c  | 15 ++
 libavcodec/h263dec.c   | 13 +
 libavcodec/h264dec.c   | 25 
 libavcodec/hevcdec.c   | 25 
 libavcodec/hwaccel.h   | 50 
 libavcodec/hwaccels.h  | 72 
++

 libavcodec/mediacodecdec.c | 18 
 libavcodec/mmaldec.c   |  7 +
 libavcodec/mpeg12dec.c | 42 ++-
 libavcodec/mpeg4videodec.c | 13 +
 libavcodec/qsvdec.c| 13 +
 libavcodec/qsvdec.h|  3 ++
 libavcodec/qsvdec_h2645.c  |  2 ++
 libavcodec/qsvdec_other.c  |  3 ++
 libavcodec/vc1dec.c| 43 +++
 libavcodec/vp9.c   | 19 
 16 files changed, 362 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/hwaccels.h

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 6370348639..0e5123304a 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -32,6 +32,7 @@

 #include "avcodec.h"
 #include "decode.h"
+#include "hwaccel.h"
 #include "internal.h"

 typedef struct CuvidContext
@@ -1094,6 +1095,19 @@ static const AVOption options[] = {
 { NULL }
 };

+static const AVCodecHWConfigInternal *cuvid_hw_configs[] = {
+&(const AVCodecHWConfigInternal) {
+.public = {
+.pix_fmt = AV_PIX_FMT_CUDA,
+.methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
+   AV_CODEC_HW_CONFIG_METHOD_INTERNAL,
+.device_type = AV_HWDEVICE_TYPE_CUDA
+},
+.hwaccel = NULL,
+},
+NULL
+};
+
 #define DEFINE_CUVID_CODEC(x, X) \
 static const AVClass x##_cuvid_class = { \
 .class_name = #x "_cuvid", \
@@ -1127,6 +1141,7 @@ static const AVOption options[] = {
 
AV_PIX_FMT_P010, \
 
AV_PIX_FMT_P016, \
 
AV_PIX_FMT_NONE }, \

+.hw_configs = cuvid_hw_configs, \
 };

 #if CONFIG_HEVC_CUVID_DECODER
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index c7cf4bc0c2..cf66e520b0 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -33,6 +33,7 @@
 #include "flv.h"
 #include "h263.h"
 #include "h263_parser.h"
+#include "hwaccel.h"
 #include "internal.h"
 #include "mpeg_er.h"
 #include "mpeg4video.h"
@@ -756,4 +757,16 @@ AVCodec ff_h263p_decoder = {
 .flush  = ff_mpeg_flush,
 .max_lowres = 3,
 .pix_fmts   = ff_h263_hwaccel_pixfmt_list_420,
+.hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_H263_VAAPI_HWACCEL
+HWACCEL_VAAPI(h263),
+#endif
+#if CONFIG_MPEG4_VDPAU_HWACCEL
+HWACCEL_VDPAU(mpeg4),
+#endif
+#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL
+HWACCEL_VIDEOTOOLBOX(h263),
+#endif
+NULL
+},
 };
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index be187eb5f4..b03024d4a3 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -47,6 +47,7 @@
 #include "h264_mvpred.h"
 #include "h264_ps.h"
 #include "golomb.h"
+#include "hwaccel.h"
 #include "mathops.h"
 #include "me_cmp.h"
 #include "mpegutils.h"
@@ -1059,6 +1060,30 @@ 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 AVCodecHWConfigInternal*[]) {
+#if CONFIG_H264_DXVA2_HWACCEL
+   HWACCEL_DXVA2(h264),
+#endif
+#if CONFIG_H264_D3D11VA_HWACCEL
+   HWACCEL_D3D11VA(h264),
+#endif
+#if CONFIG_H264_D3D11VA2_HWACCEL
+   HWACCEL_D3D11VA2(h264),
+#endif
+#if CONFIG_H264_NVDEC_HWACCEL
+   HWACCEL_NVDEC(h264),
+#endif
+#if CONFIG_H264_VAAPI_HWACCEL
+   HWACCEL_VAAPI(h264),
+#endif
+#if CONFIG_H264_VDPAU_HWACCEL
+   HWACCEL_VDPAU(h264),
+#endif
+#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL
+   HWACCEL_VIDEOTOOLBOX(h264),
+#endif
+   NULL
+   },
 .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
FF_CODEC_CAP_EXPORTS_CROPPING,
 .flush = flush_dpb,
 .init_thread_copy  = 

[FFmpeg-devel] [PATCH 02/13] lavc: Add hardware config metadata for decoders supporting hardware output

2017-11-18 Thread Mark Thompson
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.
---
 libavcodec/cuviddec.c  | 15 ++
 libavcodec/h263dec.c   | 13 +
 libavcodec/h264dec.c   | 25 
 libavcodec/hevcdec.c   | 25 
 libavcodec/hwaccel.h   | 50 
 libavcodec/hwaccels.h  | 72 ++
 libavcodec/mediacodecdec.c | 18 
 libavcodec/mmaldec.c   |  7 +
 libavcodec/mpeg12dec.c | 42 ++-
 libavcodec/mpeg4videodec.c | 13 +
 libavcodec/qsvdec.c| 13 +
 libavcodec/qsvdec.h|  3 ++
 libavcodec/qsvdec_h2645.c  |  2 ++
 libavcodec/qsvdec_other.c  |  3 ++
 libavcodec/vc1dec.c| 43 +++
 libavcodec/vp9.c   | 19 
 16 files changed, 362 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/hwaccels.h

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 6370348639..0e5123304a 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -32,6 +32,7 @@
 
 #include "avcodec.h"
 #include "decode.h"
+#include "hwaccel.h"
 #include "internal.h"
 
 typedef struct CuvidContext
@@ -1094,6 +1095,19 @@ static const AVOption options[] = {
 { NULL }
 };
 
+static const AVCodecHWConfigInternal *cuvid_hw_configs[] = {
+&(const AVCodecHWConfigInternal) {
+.public = {
+.pix_fmt = AV_PIX_FMT_CUDA,
+.methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
+   AV_CODEC_HW_CONFIG_METHOD_INTERNAL,
+.device_type = AV_HWDEVICE_TYPE_CUDA
+},
+.hwaccel = NULL,
+},
+NULL
+};
+
 #define DEFINE_CUVID_CODEC(x, X) \
 static const AVClass x##_cuvid_class = { \
 .class_name = #x "_cuvid", \
@@ -1127,6 +1141,7 @@ static const AVOption options[] = {
 AV_PIX_FMT_P010, \
 AV_PIX_FMT_P016, \
 AV_PIX_FMT_NONE }, \
+.hw_configs = cuvid_hw_configs, \
 };
 
 #if CONFIG_HEVC_CUVID_DECODER
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index c7cf4bc0c2..cf66e520b0 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -33,6 +33,7 @@
 #include "flv.h"
 #include "h263.h"
 #include "h263_parser.h"
+#include "hwaccel.h"
 #include "internal.h"
 #include "mpeg_er.h"
 #include "mpeg4video.h"
@@ -756,4 +757,16 @@ AVCodec ff_h263p_decoder = {
 .flush  = ff_mpeg_flush,
 .max_lowres = 3,
 .pix_fmts   = ff_h263_hwaccel_pixfmt_list_420,
+.hw_configs = (const AVCodecHWConfigInternal*[]) {
+#if CONFIG_H263_VAAPI_HWACCEL
+HWACCEL_VAAPI(h263),
+#endif
+#if CONFIG_MPEG4_VDPAU_HWACCEL
+HWACCEL_VDPAU(mpeg4),
+#endif
+#if CONFIG_H263_VIDEOTOOLBOX_HWACCEL
+HWACCEL_VIDEOTOOLBOX(h263),
+#endif
+NULL
+},
 };
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index be187eb5f4..b03024d4a3 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -47,6 +47,7 @@
 #include "h264_mvpred.h"
 #include "h264_ps.h"
 #include "golomb.h"
+#include "hwaccel.h"
 #include "mathops.h"
 #include "me_cmp.h"
 #include "mpegutils.h"
@@ -1059,6 +1060,30 @@ 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 AVCodecHWConfigInternal*[]) {
+#if CONFIG_H264_DXVA2_HWACCEL
+   HWACCEL_DXVA2(h264),
+#endif
+#if CONFIG_H264_D3D11VA_HWACCEL
+   HWACCEL_D3D11VA(h264),
+#endif
+#if CONFIG_H264_D3D11VA2_HWACCEL
+   HWACCEL_D3D11VA2(h264),
+#endif
+#if CONFIG_H264_NVDEC_HWACCEL
+   HWACCEL_NVDEC(h264),
+#endif
+#if CONFIG_H264_VAAPI_HWACCEL
+   HWACCEL_VAAPI(h264),
+#endif
+#if CONFIG_H264_VDPAU_HWACCEL
+   HWACCEL_VDPAU(h264),
+#endif
+#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL
+   HWACCEL_VIDEOTOOLBOX(h264),
+#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