diff mbox series

[FFmpeg-devel,3/8] lavc/qsvenc: Add hardware config metadata

Message ID 20200413153321.5956-3-sw@jkqxz.net
State Accepted
Commit 5a1ff449071fefa7913858fbe2d084f698443e57
Headers show
Series [FFmpeg-devel,1/8] lavc: Rename hwaccel.h to hwconfig.h | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Mark Thompson April 13, 2020, 3:33 p.m. UTC
All of these encoders can accept libmfx surfaces directly in a hardware
frames context, or they can accept software frames if a suitable device
is supplied to use.
---
 libavcodec/qsvenc.c       | 7 +++++++
 libavcodec/qsvenc.h       | 3 +++
 libavcodec/qsvenc_h264.c  | 1 +
 libavcodec/qsvenc_hevc.c  | 1 +
 libavcodec/qsvenc_jpeg.c  | 1 +
 libavcodec/qsvenc_mpeg2.c | 1 +
 libavcodec/qsvenc_vp9.c   | 1 +
 7 files changed, 15 insertions(+)

Comments

Zhong Li April 19, 2020, 2:21 p.m. UTC | #1
Mark Thompson <sw@jkqxz.net> 于2020年4月13日周一 下午11:34写道:
>
> All of these encoders can accept libmfx surfaces directly in a hardware
> frames context, or they can accept software frames if a suitable device
> is supplied to use.
> ---
>  libavcodec/qsvenc.c       | 7 +++++++
>  libavcodec/qsvenc.h       | 3 +++
>  libavcodec/qsvenc_h264.c  | 1 +
>  libavcodec/qsvenc_hevc.c  | 1 +
>  libavcodec/qsvenc_jpeg.c  | 1 +
>  libavcodec/qsvenc_mpeg2.c | 1 +
>  libavcodec/qsvenc_vp9.c   | 1 +
>  7 files changed, 15 insertions(+)
>
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index afab8fd715..9ec0636dde 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -1652,3 +1652,10 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q)
>
>      return 0;
>  }
> +
> +const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[] = {
> +    HW_CONFIG_ENCODER_FRAMES(QSV,  QSV),
> +    HW_CONFIG_ENCODER_DEVICE(NV12, QSV),
> +    HW_CONFIG_ENCODER_DEVICE(P010, QSV),
> +    NULL,
> +};
> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> index 6609171af3..4f579d1db1 100644
> --- a/libavcodec/qsvenc.h
> +++ b/libavcodec/qsvenc.h
> @@ -32,6 +32,7 @@
>  #include "libavutil/fifo.h"
>
>  #include "avcodec.h"
> +#include "hwconfig.h"
>  #include "qsv_internal.h"
>
>  #define QSV_HAVE_CO2 QSV_VERSION_ATLEAST(1, 6)
> @@ -97,6 +98,8 @@
>  { "forced_idr",     "Forcing I frames as IDR frames",         OFFSET(qsv.forced_idr),     AV_OPT_TYPE_BOOL,{ .i64 = 0  },  0,          1, VE },                         \
>  { "low_power", "enable low power mode(experimental: many limitations by mfx version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, VE},\
>
> +extern const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[];
> +
>  typedef int SetEncodeCtrlCB (AVCodecContext *avctx,
>                               const AVFrame *frame, mfxEncodeCtrl* enc_ctrl);
>  typedef struct QSVEncContext {
> diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
> index 27f36b9f7b..364975bea5 100644
> --- a/libavcodec/qsvenc_h264.c
> +++ b/libavcodec/qsvenc_h264.c
> @@ -197,4 +197,5 @@ AVCodec ff_h264_qsv_encoder = {
>      .defaults       = qsv_enc_defaults,
>      .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>      .wrapper_name   = "qsv",
> +    .hw_configs     = ff_qsv_enc_hw_configs,
>  };
> diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
> index 27e2232a9f..36e5ef6052 100644
> --- a/libavcodec/qsvenc_hevc.c
> +++ b/libavcodec/qsvenc_hevc.c
> @@ -288,4 +288,5 @@ AVCodec ff_hevc_qsv_encoder = {
>      .defaults       = qsv_enc_defaults,
>      .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>      .wrapper_name   = "qsv",
> +    .hw_configs     = ff_qsv_enc_hw_configs,
>  };
> diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c
> index 1619a335c7..f76af9486b 100644
> --- a/libavcodec/qsvenc_jpeg.c
> +++ b/libavcodec/qsvenc_jpeg.c
> @@ -95,4 +95,5 @@ AVCodec ff_mjpeg_qsv_encoder = {
>      .priv_class     = &class,
>      .defaults       = qsv_enc_defaults,
>      .wrapper_name   = "qsv",
> +    .hw_configs     = ff_qsv_enc_hw_configs,
>  };
> diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c
> index e4ade56d62..0e34bb75dc 100644
> --- a/libavcodec/qsvenc_mpeg2.c
> +++ b/libavcodec/qsvenc_mpeg2.c
> @@ -112,4 +112,5 @@ AVCodec ff_mpeg2_qsv_encoder = {
>      .defaults       = qsv_enc_defaults,
>      .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>      .wrapper_name   = "qsv",
> +    .hw_configs     = ff_qsv_enc_hw_configs,
>  };
> diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c
> index 9402f806b1..ce44c09397 100644
> --- a/libavcodec/qsvenc_vp9.c
> +++ b/libavcodec/qsvenc_vp9.c
> @@ -110,4 +110,5 @@ AVCodec ff_vp9_qsv_encoder = {
>      .defaults       = qsv_enc_defaults,
>      .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>      .wrapper_name   = "qsv",
> +    .hw_configs     = ff_qsv_enc_hw_configs,
>  };
> --
> 2.25.1

LGTM
diff mbox series

Patch

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index afab8fd715..9ec0636dde 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1652,3 +1652,10 @@  int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q)
 
     return 0;
 }
+
+const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[] = {
+    HW_CONFIG_ENCODER_FRAMES(QSV,  QSV),
+    HW_CONFIG_ENCODER_DEVICE(NV12, QSV),
+    HW_CONFIG_ENCODER_DEVICE(P010, QSV),
+    NULL,
+};
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 6609171af3..4f579d1db1 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -32,6 +32,7 @@ 
 #include "libavutil/fifo.h"
 
 #include "avcodec.h"
+#include "hwconfig.h"
 #include "qsv_internal.h"
 
 #define QSV_HAVE_CO2 QSV_VERSION_ATLEAST(1, 6)
@@ -97,6 +98,8 @@ 
 { "forced_idr",     "Forcing I frames as IDR frames",         OFFSET(qsv.forced_idr),     AV_OPT_TYPE_BOOL,{ .i64 = 0  },  0,          1, VE },                         \
 { "low_power", "enable low power mode(experimental: many limitations by mfx version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, VE},\
 
+extern const AVCodecHWConfigInternal *ff_qsv_enc_hw_configs[];
+
 typedef int SetEncodeCtrlCB (AVCodecContext *avctx,
                              const AVFrame *frame, mfxEncodeCtrl* enc_ctrl);
 typedef struct QSVEncContext {
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 27f36b9f7b..364975bea5 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -197,4 +197,5 @@  AVCodec ff_h264_qsv_encoder = {
     .defaults       = qsv_enc_defaults,
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .wrapper_name   = "qsv",
+    .hw_configs     = ff_qsv_enc_hw_configs,
 };
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 27e2232a9f..36e5ef6052 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -288,4 +288,5 @@  AVCodec ff_hevc_qsv_encoder = {
     .defaults       = qsv_enc_defaults,
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .wrapper_name   = "qsv",
+    .hw_configs     = ff_qsv_enc_hw_configs,
 };
diff --git a/libavcodec/qsvenc_jpeg.c b/libavcodec/qsvenc_jpeg.c
index 1619a335c7..f76af9486b 100644
--- a/libavcodec/qsvenc_jpeg.c
+++ b/libavcodec/qsvenc_jpeg.c
@@ -95,4 +95,5 @@  AVCodec ff_mjpeg_qsv_encoder = {
     .priv_class     = &class,
     .defaults       = qsv_enc_defaults,
     .wrapper_name   = "qsv",
+    .hw_configs     = ff_qsv_enc_hw_configs,
 };
diff --git a/libavcodec/qsvenc_mpeg2.c b/libavcodec/qsvenc_mpeg2.c
index e4ade56d62..0e34bb75dc 100644
--- a/libavcodec/qsvenc_mpeg2.c
+++ b/libavcodec/qsvenc_mpeg2.c
@@ -112,4 +112,5 @@  AVCodec ff_mpeg2_qsv_encoder = {
     .defaults       = qsv_enc_defaults,
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .wrapper_name   = "qsv",
+    .hw_configs     = ff_qsv_enc_hw_configs,
 };
diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c
index 9402f806b1..ce44c09397 100644
--- a/libavcodec/qsvenc_vp9.c
+++ b/libavcodec/qsvenc_vp9.c
@@ -110,4 +110,5 @@  AVCodec ff_vp9_qsv_encoder = {
     .defaults       = qsv_enc_defaults,
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
     .wrapper_name   = "qsv",
+    .hw_configs     = ff_qsv_enc_hw_configs,
 };