[FFmpeg-devel,v2,5/9] lavc/qsvdec: Add VP9 decoder support

Submitted by Mark Thompson on April 1, 2019, 11:39 p.m.

Details

Message ID 20190401233940.5941-5-sw@jkqxz.net
State New
Headers show

Commit Message

Mark Thompson April 1, 2019, 11:39 p.m.
From: Zhong Li <zhong.li@intel.com>

VP9 decoder is supported on Intel kabyLake+ platforms with MSDK Version 1.19+

Signed-off-by: Zhong Li <zhong.li@intel.com>
---
On 20/03/2019 14:41, Li, Zhong wrote:
> Yes, QSV is a marketing name which is no equal to libmfx/MSDK.
> But would be better to keep consistent with others, such as "Intel QSV-accelerated VP8 video decoding" in pervious changelog?

I don't think so?  VP9 decoding with the QSV hardware is already supported, this only adds the additional option of using libmfx to access the same thing as well.


 Changelog                 |  1 +
 configure                 |  6 ++++++
 libavcodec/allcodecs.c    |  1 +
 libavcodec/qsv.c          |  5 +++++
 libavcodec/qsvdec_other.c | 31 ++++++++++++++++++++++++++++++-
 5 files changed, 43 insertions(+), 1 deletion(-)

Comments

Zhong Li April 16, 2019, 2:31 a.m.
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Mark Thompson

> Sent: Tuesday, April 2, 2019 7:40 AM

> To: ffmpeg-devel@ffmpeg.org

> Subject: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder

> support

> 

> From: Zhong Li <zhong.li@intel.com>

> 

> VP9 decoder is supported on Intel kabyLake+ platforms with MSDK Version

> 1.19+

> 

> Signed-off-by: Zhong Li <zhong.li@intel.com>

> ---

> On 20/03/2019 14:41, Li, Zhong wrote:

> > Yes, QSV is a marketing name which is no equal to libmfx/MSDK.

> > But would be better to keep consistent with others, such as "Intel

> QSV-accelerated VP8 video decoding" in pervious changelog?

> 

> I don't think so?  VP9 decoding with the QSV hardware is already supported,

> this only adds the additional option of using libmfx to access the same thing

> as well.


Ok, here are just some words description of changelog. I will be happy to see this patch can be applied.
(As previous comment, the updated version of vp9 parser with pic_type of key frame issue fixing LGTM.)
Zhong Li June 26, 2019, 6 a.m.
> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Li, Zhong

> Sent: Tuesday, April 16, 2019 10:32 AM

> To: FFmpeg development discussions and patches

> <ffmpeg-devel@ffmpeg.org>

> Subject: Re: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder

> support

> 

> > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On

> Behalf

> > Of Mark Thompson

> > Sent: Tuesday, April 2, 2019 7:40 AM

> > To: ffmpeg-devel@ffmpeg.org

> > Subject: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder

> > support

> >

> > From: Zhong Li <zhong.li@intel.com>

> >

> > VP9 decoder is supported on Intel kabyLake+ platforms with MSDK

> > Version 1.19+

> >

> > Signed-off-by: Zhong Li <zhong.li@intel.com>

> > ---

> > On 20/03/2019 14:41, Li, Zhong wrote:

> > > Yes, QSV is a marketing name which is no equal to libmfx/MSDK.

> > > But would be better to keep consistent with others, such as "Intel

> > QSV-accelerated VP8 video decoding" in pervious changelog?

> >

> > I don't think so?  VP9 decoding with the QSV hardware is already

> > supported, this only adds the additional option of using libmfx to

> > access the same thing as well.

> 

> Ok, here are just some words description of changelog. I will be happy to see

> this patch can be applied.

> (As previous comment, the updated version of vp9 parser with pic_type of

> key frame issue fixing LGTM.)


Ping?

If nobody against, I will merge it with cbs vp9 parser patch during one week.
James Almer June 26, 2019, 2:18 p.m.
On 6/26/2019 3:00 AM, Li, Zhong wrote:
> 
> 
>> -----Original Message-----
>> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf
>> Of Li, Zhong
>> Sent: Tuesday, April 16, 2019 10:32 AM
>> To: FFmpeg development discussions and patches
>> <ffmpeg-devel@ffmpeg.org>
>> Subject: Re: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder
>> support
>>
>>> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On
>> Behalf
>>> Of Mark Thompson
>>> Sent: Tuesday, April 2, 2019 7:40 AM
>>> To: ffmpeg-devel@ffmpeg.org
>>> Subject: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder
>>> support
>>>
>>> From: Zhong Li <zhong.li@intel.com>
>>>
>>> VP9 decoder is supported on Intel kabyLake+ platforms with MSDK
>>> Version 1.19+
>>>
>>> Signed-off-by: Zhong Li <zhong.li@intel.com>
>>> ---
>>> On 20/03/2019 14:41, Li, Zhong wrote:
>>>> Yes, QSV is a marketing name which is no equal to libmfx/MSDK.
>>>> But would be better to keep consistent with others, such as "Intel
>>> QSV-accelerated VP8 video decoding" in pervious changelog?
>>>
>>> I don't think so?  VP9 decoding with the QSV hardware is already
>>> supported, this only adds the additional option of using libmfx to
>>> access the same thing as well.
>>
>> Ok, here are just some words description of changelog. I will be happy to see
>> this patch can be applied.
>> (As previous comment, the updated version of vp9 parser with pic_type of
>> key frame issue fixing LGTM.)
> 
> Ping?
> 
> If nobody against, I will merge it with cbs vp9 parser patch during one week.

Please, don't push a patchset written by Mark without his approval. I
reviewed a few other patches from this set and he will most likely
submit a new version for all of them.
Zhong Li June 27, 2019, 1:47 a.m.
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of James Almer

> Sent: Wednesday, June 26, 2019 10:19 PM

> To: ffmpeg-devel@ffmpeg.org

> Subject: Re: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder

> support

> 

> On 6/26/2019 3:00 AM, Li, Zhong wrote:

> >

> >

> >> -----Original Message-----

> >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On

> Behalf

> >> Of Li, Zhong

> >> Sent: Tuesday, April 16, 2019 10:32 AM

> >> To: FFmpeg development discussions and patches

> >> <ffmpeg-devel@ffmpeg.org>

> >> Subject: Re: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9

> >> decoder support

> >>

> >>> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On

> >> Behalf

> >>> Of Mark Thompson

> >>> Sent: Tuesday, April 2, 2019 7:40 AM

> >>> To: ffmpeg-devel@ffmpeg.org

> >>> Subject: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder

> >>> support

> >>>

> >>> From: Zhong Li <zhong.li@intel.com>

> >>>

> >>> VP9 decoder is supported on Intel kabyLake+ platforms with MSDK

> >>> Version 1.19+

> >>>

> >>> Signed-off-by: Zhong Li <zhong.li@intel.com>

> >>> ---

> >>> On 20/03/2019 14:41, Li, Zhong wrote:

> >>>> Yes, QSV is a marketing name which is no equal to libmfx/MSDK.

> >>>> But would be better to keep consistent with others, such as "Intel

> >>> QSV-accelerated VP8 video decoding" in pervious changelog?

> >>>

> >>> I don't think so?  VP9 decoding with the QSV hardware is already

> >>> supported, this only adds the additional option of using libmfx to

> >>> access the same thing as well.

> >>

> >> Ok, here are just some words description of changelog. I will be

> >> happy to see this patch can be applied.

> >> (As previous comment, the updated version of vp9 parser with pic_type

> >> of key frame issue fixing LGTM.)

> >

> > Ping?

> >

> > If nobody against, I will merge it with cbs vp9 parser patch during one

> week.

> 

> Please, don't push a patchset written by Mark without his approval. I

> reviewed a few other patches from this set and he will most likely submit a

> new version for all of them.


Thanks for your remind, James. Yes I saw your comment for av1, I thought the others should be ok but pending for a while. 
Anyway, will hold on and waiting for Mark's response.

Patch hide | download patch | download mbox

diff --git a/Changelog b/Changelog
index cd4ed54f2c..d838873dd4 100644
--- a/Changelog
+++ b/Changelog
@@ -21,6 +21,7 @@  version <next>:
 - Support decoding of HEVC 4:4:4 content in nvdec and cuviddec
 - removed libndi-newtek
 - agm decoder
+- Intel libmfx VP9 decoding
 
 
 version 4.1:
diff --git a/configure b/configure
index f6123f53e5..60cbbaf39e 100755
--- a/configure
+++ b/configure
@@ -3058,6 +3058,8 @@  vp8_v4l2m2m_decoder_deps="v4l2_m2m vp8_v4l2_m2m"
 vp8_v4l2m2m_encoder_deps="v4l2_m2m vp8_v4l2_m2m"
 vp9_cuvid_decoder_deps="cuvid"
 vp9_mediacodec_decoder_deps="mediacodec"
+vp9_qsv_decoder_deps="MFX_CODEC_VP9"
+vp9_qsv_decoder_select="qsvdec"
 vp9_rkmpp_decoder_deps="rkmpp"
 vp9_vaapi_encoder_deps="VAEncPictureParameterBufferVP9"
 vp9_vaapi_encoder_select="vaapi_encode"
@@ -6157,6 +6159,10 @@  enabled liblensfun        && require_pkg_config liblensfun lensfun lensfun.h lf_
 # can find the libraries and headers through other means.
 enabled libmfx            && { check_pkg_config libmfx libmfx "mfx/mfxvideo.h" MFXInit ||
                                { require libmfx "mfx/mfxvideo.h" MFXInit "-llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } }
+if enabled libmfx; then
+   check_cc MFX_CODEC_VP9 "mfx/mfxvp9.h mfx/mfxstructures.h" "MFX_CODEC_VP9"
+fi
+
 enabled libmodplug        && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load
 enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame $libm_extralibs
 enabled libmysofa         && { check_pkg_config libmysofa libmysofa mysofa.h mysofa_load ||
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 71fd74a07e..1f0233d971 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -776,6 +776,7 @@  extern AVCodec ff_vp8_v4l2m2m_encoder;
 extern AVCodec ff_vp8_vaapi_encoder;
 extern AVCodec ff_vp9_cuvid_decoder;
 extern AVCodec ff_vp9_mediacodec_decoder;
+extern AVCodec ff_vp9_qsv_decoder;
 extern AVCodec ff_vp9_vaapi_encoder;
 
 // The iterate API is not usable with ossfuzz due to the excessive size of binaries created
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index bb0d79588c..389fdcff41 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -60,6 +60,11 @@  int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
 #endif
     case AV_CODEC_ID_MJPEG:
         return MFX_CODEC_JPEG;
+#if QSV_VERSION_ATLEAST(1, 19)
+    case AV_CODEC_ID_VP9:
+        return MFX_CODEC_VP9;
+#endif
+
     default:
         break;
     }
diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
index 03251d2c85..d7a6d79f63 100644
--- a/libavcodec/qsvdec_other.c
+++ b/libavcodec/qsvdec_other.c
@@ -1,5 +1,5 @@ 
 /*
- * Intel MediaSDK QSV based MPEG-2, VC-1 and VP8 decoders
+ * Intel MediaSDK QSV based MPEG-2, VC-1, VP8 and VP9 decoders
  *
  * copyright (c) 2015 Anton Khirnov
  *
@@ -255,3 +255,32 @@  AVCodec ff_vp8_qsv_decoder = {
     .wrapper_name   = "qsv",
 };
 #endif
+
+#if CONFIG_VP9_QSV_DECODER
+static const AVClass vp9_qsv_class = {
+    .class_name = "vp9_qsv",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_vp9_qsv_decoder = {
+    .name           = "vp9_qsv",
+    .long_name      = NULL_IF_CONFIG_SMALL("VP9 video (Intel Quick Sync Video acceleration)"),
+    .priv_data_size = sizeof(QSVOtherContext),
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_VP9,
+    .init           = qsv_decode_init,
+    .decode         = qsv_decode_frame,
+    .flush          = qsv_decode_flush,
+    .close          = qsv_decode_close,
+    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
+    .priv_class     = &vp9_qsv_class,
+    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+                                                    AV_PIX_FMT_P010,
+                                                    AV_PIX_FMT_QSV,
+                                                    AV_PIX_FMT_NONE },
+    .hw_configs     = ff_qsv_hw_configs,
+    .wrapper_name   = "qsv",
+};
+#endif