[FFmpeg-devel,4/5] lavc/qsvdec: add ChromaFormat support for YUV422/YUV444

Submitted by Linjie Fu on June 28, 2019, 2:29 a.m.

Details

Message ID 1561688941-972-1-git-send-email-linjie.fu@intel.com
State New
Headers show

Commit Message

Linjie Fu June 28, 2019, 2:29 a.m.
Currently, ChromaFormat passed to libmfx is set to YUV42O by default.

Modify to choose ChromaFormat according to fourCC.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libavcodec/qsvdec.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Comments

Carl Eugen Hoyos June 27, 2019, 6:43 p.m.
Am Do., 27. Juni 2019 um 16:31 Uhr schrieb Linjie Fu <linjie.fu@intel.com>:
>
> Currently, ChromaFormat passed to libmfx is set to YUV42O by default.
>
> Modify to choose ChromaFormat according to fourCC.

Sorry if I misunderstand:
Doesn't 3/5 depend on this patch?

Carl Eugen
Hendrik Leppkes June 28, 2019, 1:08 a.m.
On Thu, Jun 27, 2019 at 4:31 PM Linjie Fu <linjie.fu@intel.com> wrote:
>
> Currently, ChromaFormat passed to libmfx is set to YUV42O by default.
>
> Modify to choose ChromaFormat according to fourCC.
>
> Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> ---
>  libavcodec/qsvdec.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index 46aa2d6..7650325 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -40,6 +40,7 @@
>  #include "qsv.h"
>  #include "qsv_internal.h"
>  #include "qsvdec.h"
> +#include <va/va.h>
>
>  const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
>      &(const AVCodecHWConfigInternal) {
> @@ -211,7 +212,24 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
>      param.mfx.FrameInfo.FourCC         = q->fourcc;
>      param.mfx.FrameInfo.Width          = frame_width;
>      param.mfx.FrameInfo.Height         = frame_height;
> -    param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
> +
> +    switch (q->fourcc) {
> +    case VA_FOURCC_YUY2:
> +#ifdef VA_FOURCC_Y210
> +    case VA_FOURCC_Y210:
> +#endif
> +        param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV422;
> +        break;
> +    case VA_FOURCC_AYUV:
> +#ifdef VA_FOURCC_Y410
> +    case VA_FOURCC_Y410:
> +#endif
> +        param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV444;
> +        break;
> +    default:
> +        param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
> +        break;
> +    }
>
>      switch (avctx->field_order) {
>      case AV_FIELD_PROGRESSIVE:

VA_FOURCC_ sounds like VAAPI, that doesn't seem like it belongs in qsv
code which is supposed to work on multiple platforms.

- Hendrik
Linjie Fu June 28, 2019, 2:50 a.m.
> -----Original Message-----

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

> Of Carl Eugen Hoyos

> Sent: Friday, June 28, 2019 02:43

> To: FFmpeg development discussions and patches <ffmpeg-

> devel@ffmpeg.org>

> Subject: Re: [FFmpeg-devel] [PATCH 4/5] lavc/qsvdec: add ChromaFormat

> support for YUV422/YUV444

> 

> Am Do., 27. Juni 2019 um 16:31 Uhr schrieb Linjie Fu <linjie.fu@intel.com>:

> >

> > Currently, ChromaFormat passed to libmfx is set to YUV42O by default.

> >

> > Modify to choose ChromaFormat according to fourCC.

> 

> Sorry if I misunderstand:

> Doesn't 3/5 depend on this patch?


The whole patch set enables HEVC Rext decode in QSV, and yes 3/5 won't take
effect without 4/5 or 5/5.
It seems I'd better adjust the patch sequence in the patch set according to dependency.

Thanks.
Linjie Fu June 28, 2019, 3:48 a.m.
> -----Original Message-----

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

> Of Hendrik Leppkes

> Sent: Friday, June 28, 2019 09:09

> To: FFmpeg development discussions and patches <ffmpeg-

> devel@ffmpeg.org>

> Subject: Re: [FFmpeg-devel] [PATCH 4/5] lavc/qsvdec: add ChromaFormat

> support for YUV422/YUV444

> 

> On Thu, Jun 27, 2019 at 4:31 PM Linjie Fu <linjie.fu@intel.com> wrote:

> >

> > Currently, ChromaFormat passed to libmfx is set to YUV42O by default.

> >

> > Modify to choose ChromaFormat according to fourCC.

> >

> > Signed-off-by: Linjie Fu <linjie.fu@intel.com>

> > ---

> >  libavcodec/qsvdec.c | 20 +++++++++++++++++++-

> >  1 file changed, 19 insertions(+), 1 deletion(-)

> >

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

> > index 46aa2d6..7650325 100644

> > --- a/libavcodec/qsvdec.c

> > +++ b/libavcodec/qsvdec.c

> > @@ -40,6 +40,7 @@

> >  #include "qsv.h"

> >  #include "qsv_internal.h"

> >  #include "qsvdec.h"

> > +#include <va/va.h>

> >

> >  const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {

> >      &(const AVCodecHWConfigInternal) {

> > @@ -211,7 +212,24 @@ static int qsv_decode_init(AVCodecContext *avctx,

> QSVContext *q)

> >      param.mfx.FrameInfo.FourCC         = q->fourcc;

> >      param.mfx.FrameInfo.Width          = frame_width;

> >      param.mfx.FrameInfo.Height         = frame_height;

> > -    param.mfx.FrameInfo.ChromaFormat   =

> MFX_CHROMAFORMAT_YUV420;

> > +

> > +    switch (q->fourcc) {

> > +    case VA_FOURCC_YUY2:

> > +#ifdef VA_FOURCC_Y210

> > +    case VA_FOURCC_Y210:

> > +#endif

> > +        param.mfx.FrameInfo.ChromaFormat   =

> MFX_CHROMAFORMAT_YUV422;

> > +        break;

> > +    case VA_FOURCC_AYUV:

> > +#ifdef VA_FOURCC_Y410

> > +    case VA_FOURCC_Y410:

> > +#endif

> > +        param.mfx.FrameInfo.ChromaFormat   =

> MFX_CHROMAFORMAT_YUV444;

> > +        break;

> > +    default:

> > +        param.mfx.FrameInfo.ChromaFormat   =

> MFX_CHROMAFORMAT_YUV420;

> > +        break;

> > +    }

> >

> >      switch (avctx->field_order) {

> >      case AV_FIELD_PROGRESSIVE:

> 

> VA_FOURCC_ sounds like VAAPI, that doesn't seem like it belongs in qsv

> code which is supposed to work on multiple platforms.


Yes,  it should be MFX_FOURCC_.
Thanks.
Zhong Li June 28, 2019, 3:53 a.m.
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Hendrik Leppkes

> Sent: Friday, June 28, 2019 9:09 AM

> To: FFmpeg development discussions and patches

> <ffmpeg-devel@ffmpeg.org>

> Subject: Re: [FFmpeg-devel] [PATCH 4/5] lavc/qsvdec: add ChromaFormat

> support for YUV422/YUV444

> 

> On Thu, Jun 27, 2019 at 4:31 PM Linjie Fu <linjie.fu@intel.com> wrote:

> >

> > Currently, ChromaFormat passed to libmfx is set to YUV42O by default.

> >

> > Modify to choose ChromaFormat according to fourCC.

> >

> > Signed-off-by: Linjie Fu <linjie.fu@intel.com>

> > ---

> >  libavcodec/qsvdec.c | 20 +++++++++++++++++++-

> >  1 file changed, 19 insertions(+), 1 deletion(-)

> >

> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index

> > 46aa2d6..7650325 100644

> > --- a/libavcodec/qsvdec.c

> > +++ b/libavcodec/qsvdec.c

> > @@ -40,6 +40,7 @@

> >  #include "qsv.h"

> >  #include "qsv_internal.h"

> >  #include "qsvdec.h"

> > +#include <va/va.h>

> >

> >  const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {

> >      &(const AVCodecHWConfigInternal) { @@ -211,7 +212,24 @@

> static

> > int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)

> >      param.mfx.FrameInfo.FourCC         = q->fourcc;

> >      param.mfx.FrameInfo.Width          = frame_width;

> >      param.mfx.FrameInfo.Height         = frame_height;

> > -    param.mfx.FrameInfo.ChromaFormat   =

> MFX_CHROMAFORMAT_YUV420;

> > +

> > +    switch (q->fourcc) {

> > +    case VA_FOURCC_YUY2:

> > +#ifdef VA_FOURCC_Y210

> > +    case VA_FOURCC_Y210:

> > +#endif

> > +        param.mfx.FrameInfo.ChromaFormat   =

> MFX_CHROMAFORMAT_YUV422;

> > +        break;

> > +    case VA_FOURCC_AYUV:

> > +#ifdef VA_FOURCC_Y410

> > +    case VA_FOURCC_Y410:

> > +#endif

> > +        param.mfx.FrameInfo.ChromaFormat   =

> MFX_CHROMAFORMAT_YUV444;

> > +        break;

> > +    default:

> > +        param.mfx.FrameInfo.ChromaFormat   =

> MFX_CHROMAFORMAT_YUV420;

> > +        break;

> > +    }

> >

> >      switch (avctx->field_order) {

> >      case AV_FIELD_PROGRESSIVE:

> 

> VA_FOURCC_ sounds like VAAPI, that doesn't seem like it belongs in qsv code

> which is supposed to work on multiple platforms.

> 

> - Hendrik


Good point, shouldn't use any VAAPI definition if without checking Linux platform or CONFIG_VAAPI.

Patch hide | download patch | download mbox

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 46aa2d6..7650325 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -40,6 +40,7 @@ 
 #include "qsv.h"
 #include "qsv_internal.h"
 #include "qsvdec.h"
+#include <va/va.h>
 
 const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
     &(const AVCodecHWConfigInternal) {
@@ -211,7 +212,24 @@  static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
     param.mfx.FrameInfo.FourCC         = q->fourcc;
     param.mfx.FrameInfo.Width          = frame_width;
     param.mfx.FrameInfo.Height         = frame_height;
-    param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
+
+    switch (q->fourcc) {
+    case VA_FOURCC_YUY2:
+#ifdef VA_FOURCC_Y210
+    case VA_FOURCC_Y210:
+#endif
+        param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV422;
+        break;
+    case VA_FOURCC_AYUV:
+#ifdef VA_FOURCC_Y410
+    case VA_FOURCC_Y410:
+#endif
+        param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV444;
+        break;
+    default:
+        param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
+        break;
+    }
 
     switch (avctx->field_order) {
     case AV_FIELD_PROGRESSIVE: