[FFmpeg-devel,4/5] lavc/qsvdec: Add mjpeg decoder support

Submitted by Zhong Li on Jan. 21, 2019, 12:41 p.m.

Details

Message ID 1548074517-6578-5-git-send-email-zhong.li@intel.com
State New
Headers show

Commit Message

Zhong Li Jan. 21, 2019, 12:41 p.m.
Signed-off-by: Zhong Li <zhong.li@intel.com>
---
 Changelog                 |  1 +
 configure                 |  1 +
 libavcodec/Makefile       |  1 +
 libavcodec/allcodecs.c    |  1 +
 libavcodec/qsvdec_other.c | 28 +++++++++++++++++++++++++++-
 5 files changed, 31 insertions(+), 1 deletion(-)

Comments

Rogozhkin, Dmitry V Jan. 24, 2019, 9:46 p.m.
On Mon, 2019-01-21 at 20:41 +0800, Zhong Li wrote:
> Signed-off-by: Zhong Li <zhong.li@intel.com>

> ---

>  Changelog                 |  1 +

>  configure                 |  1 +

>  libavcodec/Makefile       |  1 +

>  libavcodec/allcodecs.c    |  1 +

>  libavcodec/qsvdec_other.c | 28 +++++++++++++++++++++++++++-

>  5 files changed, 31 insertions(+), 1 deletion(-)

> 

> diff --git a/Changelog b/Changelog

> index 422d84e..bf76613 100644

> --- a/Changelog

> +++ b/Changelog

> @@ -14,6 +14,7 @@ version <next>:

>  - vividas demuxer

>  - hymt decoder

>  - anlmdn filter

> +- Intel QSV-accelerated MJPEG decoding

>  

>  

>  version 4.1:

> diff --git a/configure b/configure

> index 946f534..ac71ecf 100755

> --- a/configure

> +++ b/configure

> @@ -2981,6 +2981,7 @@ hevc_v4l2m2m_decoder_deps="v4l2_m2m

> hevc_v4l2_m2m"

>  hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf"

>  hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"

>  mjpeg_cuvid_decoder_deps="cuvid"

> +mjpeg_qsv_decoder_select="qsvdec"

>  mjpeg_qsv_encoder_deps="libmfx"

>  mjpeg_qsv_encoder_select="qsvenc"

>  mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"

> diff --git a/libavcodec/Makefile b/libavcodec/Makefile

> index 99799ce..df5912c 100644

> --- a/libavcodec/Makefile

> +++ b/libavcodec/Makefile

> @@ -421,6 +421,7 @@ OBJS-$(CONFIG_METASOUND_DECODER)       +=

> metasound.o metasound_data.o \

>  OBJS-$(CONFIG_MICRODVD_DECODER)        += microdvddec.o ass.o

>  OBJS-$(CONFIG_MIMIC_DECODER)           += mimic.o

>  OBJS-$(CONFIG_MJPEG_DECODER)           += mjpegdec.o

> +OBJS-$(CONFIG_MJPEG_QSV_DECODER)       += qsvdec_other.o

>  OBJS-$(CONFIG_MJPEG_ENCODER)           += mjpegenc.o

> mjpegenc_common.o \

>                                            mjpegenc_huffman.o

>  OBJS-$(CONFIG_MJPEGB_DECODER)          += mjpegbdec.o

> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c

> index 4755af7..32cca0c 100644

> --- a/libavcodec/allcodecs.c

> +++ b/libavcodec/allcodecs.c

> @@ -756,6 +756,7 @@ extern AVCodec ff_hevc_videotoolbox_encoder;

>  extern AVCodec ff_libkvazaar_encoder;

>  extern AVCodec ff_mjpeg_cuvid_decoder;

>  extern AVCodec ff_mjpeg_qsv_encoder;

> +extern AVCodec ff_mjpeg_qsv_decoder;

>  extern AVCodec ff_mjpeg_vaapi_encoder;

>  extern AVCodec ff_mpeg1_cuvid_decoder;

>  extern AVCodec ff_mpeg2_cuvid_decoder;

> diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c

> index 03251d2..ba490d4 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 MJPEG decoders

>   *

>   * copyright (c) 2015 Anton Khirnov

>   *

> @@ -255,3 +255,29 @@ AVCodec ff_vp8_qsv_decoder = {

>      .wrapper_name   = "qsv",

>  };

>  #endif

> +

> +#if CONFIG_MJPEG_QSV_DECODER

> +static const AVClass mjpeg_qsv_class = {

> +    .class_name = "mjpeg_qsv",

> +    .item_name  = av_default_item_name,

> +    .option     = options,

> +    .version    = LIBAVUTIL_VERSION_INT,

> +};

> +

> +AVCodec ff_mjpeg_qsv_decoder = {

> +    .name           = "mjpeg_qsv",

> +    .long_name      = NULL_IF_CONFIG_SMALL("MJPEG video (Intel Quick

> Sync Video acceleration)"),

> +    .priv_data_size = sizeof(QSVOtherContext),

> +    .type           = AVMEDIA_TYPE_VIDEO,

> +    .id             = AV_CODEC_ID_MJPEG,

> +    .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     = &mjpeg_qsv_class,

> +    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,

I believe that mediasdk jpeg decoder can also support RGB32 and YUY2 on
the output. Do you plan to add support later on?
> +                                                    AV_PIX_FMT_QSV,

> +                                                    AV_PIX_FMT_NONE

> },

> +};

> +#endif
Zhong Li Jan. 25, 2019, 10:17 a.m.
> From: Rogozhkin, Dmitry V

> Sent: Friday, January 25, 2019 5:47 AM

> To: ffmpeg-devel@ffmpeg.org

> Cc: Li, Zhong <zhong.li@intel.com>

> Subject: Re: [FFmpeg-devel] [PATCH 4/5] lavc/qsvdec: Add mjpeg decoder

> support

> 

> On Mon, 2019-01-21 at 20:41 +0800, Zhong Li wrote:

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

> > ---

> >  Changelog                 |  1 +

> >  configure                 |  1 +

> >  libavcodec/Makefile       |  1 +

> >  libavcodec/allcodecs.c    |  1 +

> >  libavcodec/qsvdec_other.c | 28 +++++++++++++++++++++++++++-

> >  5 files changed, 31 insertions(+), 1 deletion(-)

> >

> > diff --git a/Changelog b/Changelog

> > index 422d84e..bf76613 100644

> > --- a/Changelog

> > +++ b/Changelog

> > @@ -14,6 +14,7 @@ version <next>:

> >  - vividas demuxer

> >  - hymt decoder

> >  - anlmdn filter

> > +- Intel QSV-accelerated MJPEG decoding

> >

> >

> >  version 4.1:

> > diff --git a/configure b/configure

> > index 946f534..ac71ecf 100755

> > --- a/configure

> > +++ b/configure

> > @@ -2981,6 +2981,7 @@ hevc_v4l2m2m_decoder_deps="v4l2_m2m

> > hevc_v4l2_m2m"

> >  hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf"

> >  hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"

> >  mjpeg_cuvid_decoder_deps="cuvid"

> > +mjpeg_qsv_decoder_select="qsvdec"

> >  mjpeg_qsv_encoder_deps="libmfx"

> >  mjpeg_qsv_encoder_select="qsvenc"

> >  mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"

> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile index

> > 99799ce..df5912c 100644

> > --- a/libavcodec/Makefile

> > +++ b/libavcodec/Makefile

> > @@ -421,6 +421,7 @@

> OBJS-$(CONFIG_METASOUND_DECODER)       +=

> > metasound.o metasound_data.o \

> >  OBJS-$(CONFIG_MICRODVD_DECODER)        += microdvddec.o

> ass.o

> >  OBJS-$(CONFIG_MIMIC_DECODER)           += mimic.o

> >  OBJS-$(CONFIG_MJPEG_DECODER)           += mjpegdec.o

> > +OBJS-$(CONFIG_MJPEG_QSV_DECODER)       += qsvdec_other.o

> >  OBJS-$(CONFIG_MJPEG_ENCODER)           += mjpegenc.o

> > mjpegenc_common.o \

> >                                            mjpegen

> c_huffman.o

> >  OBJS-$(CONFIG_MJPEGB_DECODER)          += mjpegbdec.o diff

> --git

> > a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index

> > 4755af7..32cca0c 100644

> > --- a/libavcodec/allcodecs.c

> > +++ b/libavcodec/allcodecs.c

> > @@ -756,6 +756,7 @@ extern AVCodec ff_hevc_videotoolbox_encoder;

> >  extern AVCodec ff_libkvazaar_encoder;

> >  extern AVCodec ff_mjpeg_cuvid_decoder;

> >  extern AVCodec ff_mjpeg_qsv_encoder;

> > +extern AVCodec ff_mjpeg_qsv_decoder;

> >  extern AVCodec ff_mjpeg_vaapi_encoder;

> >  extern AVCodec ff_mpeg1_cuvid_decoder;

> >  extern AVCodec ff_mpeg2_cuvid_decoder; diff --git

> > a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c index

> > 03251d2..ba490d4 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 MJPEG decoders

> >   *

> >   * copyright (c) 2015 Anton Khirnov

> >   *

> > @@ -255,3 +255,29 @@ AVCodec ff_vp8_qsv_decoder = {

> >      .wrapper_name   = "qsv",

> >  };

> >  #endif

> > +

> > +#if CONFIG_MJPEG_QSV_DECODER

> > +static const AVClass mjpeg_qsv_class = {

> > +    .class_name = "mjpeg_qsv",

> > +    .item_name  = av_default_item_name,

> > +    .option     = options,

> > +    .version    = LIBAVUTIL_VERSION_INT, };

> > +

> > +AVCodec ff_mjpeg_qsv_decoder = {

> > +    .name           = "mjpeg_qsv",

> > +    .long_name      = NULL_IF_CONFIG_SMALL("MJPEG video

> (Intel Quick

> > Sync Video acceleration)"),

> > +    .priv_data_size = sizeof(QSVOtherContext),

> > +    .type           = AVMEDIA_TYPE_VIDEO,

> > +    .id             = AV_CODEC_ID_MJPEG,

> > +    .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     = &mjpeg_qsv_class,

> > +    .pix_fmts       = (const enum

> AVPixelFormat[]){ AV_PIX_FMT_NV12,

> I believe that mediasdk jpeg decoder can also support RGB32 and YUY2 on

> the output. Do you plan to add support later on?


Good question. Current qsv pipeline can support RGB32/YUV2 (at least YUV2) well, so adding the support here is not enough and not suitable.
And yes, it is planned and should be worked as a separated patch with additional validation clips.
Zhong Li Jan. 25, 2019, 10:47 a.m.
> Good question. Current qsv pipeline can support RGB32/YUV2 (at least YUV2)

Sorry for the typo, can -> can't.
> well, so adding the support here is not enough and not suitable.

> And yes, it is planned and should be worked as a separated patch with

> additional validation clips.

Patch hide | download patch | download mbox

diff --git a/Changelog b/Changelog
index 422d84e..bf76613 100644
--- a/Changelog
+++ b/Changelog
@@ -14,6 +14,7 @@  version <next>:
 - vividas demuxer
 - hymt decoder
 - anlmdn filter
+- Intel QSV-accelerated MJPEG decoding
 
 
 version 4.1:
diff --git a/configure b/configure
index 946f534..ac71ecf 100755
--- a/configure
+++ b/configure
@@ -2981,6 +2981,7 @@  hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
 hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf"
 hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"
 mjpeg_cuvid_decoder_deps="cuvid"
+mjpeg_qsv_decoder_select="qsvdec"
 mjpeg_qsv_encoder_deps="libmfx"
 mjpeg_qsv_encoder_select="qsvenc"
 mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 99799ce..df5912c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -421,6 +421,7 @@  OBJS-$(CONFIG_METASOUND_DECODER)       += metasound.o metasound_data.o \
 OBJS-$(CONFIG_MICRODVD_DECODER)        += microdvddec.o ass.o
 OBJS-$(CONFIG_MIMIC_DECODER)           += mimic.o
 OBJS-$(CONFIG_MJPEG_DECODER)           += mjpegdec.o
+OBJS-$(CONFIG_MJPEG_QSV_DECODER)       += qsvdec_other.o
 OBJS-$(CONFIG_MJPEG_ENCODER)           += mjpegenc.o mjpegenc_common.o \
                                           mjpegenc_huffman.o
 OBJS-$(CONFIG_MJPEGB_DECODER)          += mjpegbdec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 4755af7..32cca0c 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -756,6 +756,7 @@  extern AVCodec ff_hevc_videotoolbox_encoder;
 extern AVCodec ff_libkvazaar_encoder;
 extern AVCodec ff_mjpeg_cuvid_decoder;
 extern AVCodec ff_mjpeg_qsv_encoder;
+extern AVCodec ff_mjpeg_qsv_decoder;
 extern AVCodec ff_mjpeg_vaapi_encoder;
 extern AVCodec ff_mpeg1_cuvid_decoder;
 extern AVCodec ff_mpeg2_cuvid_decoder;
diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
index 03251d2..ba490d4 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 MJPEG decoders
  *
  * copyright (c) 2015 Anton Khirnov
  *
@@ -255,3 +255,29 @@  AVCodec ff_vp8_qsv_decoder = {
     .wrapper_name   = "qsv",
 };
 #endif
+
+#if CONFIG_MJPEG_QSV_DECODER
+static const AVClass mjpeg_qsv_class = {
+    .class_name = "mjpeg_qsv",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_mjpeg_qsv_decoder = {
+    .name           = "mjpeg_qsv",
+    .long_name      = NULL_IF_CONFIG_SMALL("MJPEG video (Intel Quick Sync Video acceleration)"),
+    .priv_data_size = sizeof(QSVOtherContext),
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = AV_CODEC_ID_MJPEG,
+    .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     = &mjpeg_qsv_class,
+    .pix_fmts       = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
+                                                    AV_PIX_FMT_QSV,
+                                                    AV_PIX_FMT_NONE },
+};
+#endif