diff mbox series

[FFmpeg-devel,v2,1/2] lavc/qsvdec: add decode support for HEVC 4:2:2 8-bit and 10-bit

Message ID 1582706369-32704-1-git-send-email-linjie.fu@intel.com
State Accepted
Commit 9723d7d523b0871159e56f8144d59bd35a0390e2
Headers show
Series [FFmpeg-devel,v2,1/2] lavc/qsvdec: add decode support for HEVC 4:2:2 8-bit and 10-bit
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Fu, Linjie Feb. 26, 2020, 8:39 a.m. UTC
Enables HEVC Range Extension decoding support (Linux) for 4:2:2 8/10 bit
on ICL+ (gen11 +) platform.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
[v2]: restrict to support on Linux.

 libavcodec/qsv.c          | 16 ++++++++++++++++
 libavutil/hwcontext_qsv.c | 24 ++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

Comments

Fu, Linjie April 14, 2020, 3:10 p.m. UTC | #1
> From: Fu, Linjie <linjie.fu@intel.com>
> Sent: Wednesday, February 26, 2020 16:39
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie <linjie.fu@intel.com>
> Subject: [PATCH,v2 1/2] lavc/qsvdec: add decode support for HEVC 4:2:2 8-bit
> and 10-bit
> 
> Enables HEVC Range Extension decoding support (Linux) for 4:2:2 8/10 bit
> on ICL+ (gen11 +) platform.
> 
> Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> ---
> [v2]: restrict to support on Linux.
> 
>  libavcodec/qsv.c          | 16 ++++++++++++++++
>  libavutil/hwcontext_qsv.c | 24 ++++++++++++++++++++++++
>  2 files changed, 40 insertions(+)
> 
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> index db98c75..171a8d6 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -195,6 +195,12 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t
> fourcc)
>      case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
>      case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
>      case MFX_FOURCC_P8:   return AV_PIX_FMT_PAL8;
> +#if CONFIG_VAAPI
> +    case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
> +#if QSV_VERSION_ATLEAST(1, 27)
> +    case MFX_FOURCC_Y210: return AV_PIX_FMT_Y210;
> +#endif
> +#endif
>      }
>      return AV_PIX_FMT_NONE;
>  }
> @@ -211,6 +217,16 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format,
> uint32_t *fourcc)
>      case AV_PIX_FMT_P010:
>          *fourcc = MFX_FOURCC_P010;
>          return AV_PIX_FMT_P010;
> +#if CONFIG_VAAPI
> +    case AV_PIX_FMT_YUV422P:
> +        *fourcc = MFX_FOURCC_YUY2;
> +        return AV_PIX_FMT_YUYV422;
> +#if QSV_VERSION_ATLEAST(1, 27)
> +    case AV_PIX_FMT_YUV422P10:
> +        *fourcc = MFX_FOURCC_Y210;
> +        return AV_PIX_FMT_Y210;
> +#endif
> +#endif
>      default:
>          return AVERROR(ENOSYS);
>      }
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> index b1b6740..4306c6e3 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -44,6 +44,10 @@
>  #include "pixdesc.h"
>  #include "time.h"
> 
> +#define QSV_VERSION_ATLEAST(MAJOR, MINOR)   \
> +    (MFX_VERSION_MAJOR > (MAJOR) ||         \
> +     MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >=
> (MINOR))
> +
>  typedef struct QSVDevicePriv {
>      AVBufferRef *child_device_ctx;
>  } QSVDevicePriv;
> @@ -103,6 +107,14 @@ static const struct {
>      { AV_PIX_FMT_BGRA, MFX_FOURCC_RGB4 },
>      { AV_PIX_FMT_P010, MFX_FOURCC_P010 },
>      { AV_PIX_FMT_PAL8, MFX_FOURCC_P8   },
> +#if CONFIG_VAAPI
> +    { AV_PIX_FMT_YUYV422,
> +                       MFX_FOURCC_YUY2 },
> +#if QSV_VERSION_ATLEAST(1, 27)
> +    { AV_PIX_FMT_Y210,
> +                       MFX_FOURCC_Y210 },
> +#endif
> +#endif
>  };
> 
>  static uint32_t qsv_fourcc_from_pix_fmt(enum AVPixelFormat pix_fmt)
> @@ -773,7 +785,19 @@ static int map_frame_to_surface(const AVFrame
> *frame, mfxFrameSurface1 *surface)
>          surface->Data.R = frame->data[0] + 2;
>          surface->Data.A = frame->data[0] + 3;
>          break;
> +#if CONFIG_VAAPI
> +    case AV_PIX_FMT_YUYV422:
> +        surface->Data.Y = frame->data[0];
> +        surface->Data.U = frame->data[0] + 1;
> +        surface->Data.V = frame->data[0] + 3;
> +        break;
> 
> +    case AV_PIX_FMT_Y210:
> +        surface->Data.Y16 = (mfxU16 *)frame->data[0];
> +        surface->Data.U16 = (mfxU16 *)frame->data[0] + 1;
> +        surface->Data.V16 = (mfxU16 *)frame->data[0] + 3;
> +        break;
> +#endif
>      default:
>          return MFX_ERR_UNSUPPORTED;
>      }
> --
Ping for the patch set for 422 8/10 bit:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/1582706369-32704-1-git-send-email-linjie.fu@intel.com/
https://patchwork.ffmpeg.org/project/ffmpeg/patch/1582706402-439-1-git-send-email-linjie.fu@intel.com/
Zhong Li April 15, 2020, 1:58 a.m. UTC | #2
Linjie Fu <linjie.fu@intel.com> 于2020年2月26日周三 下午4:43写道:
>
> Enables HEVC Range Extension decoding support (Linux) for 4:2:2 8/10 bit
> on ICL+ (gen11 +) platform.
>
> Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> ---
> [v2]: restrict to support on Linux.
>
>  libavcodec/qsv.c          | 16 ++++++++++++++++
>  libavutil/hwcontext_qsv.c | 24 ++++++++++++++++++++++++
>  2 files changed, 40 insertions(+)
>
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> index db98c75..171a8d6 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -195,6 +195,12 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc)
>      case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
>      case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
>      case MFX_FOURCC_P8:   return AV_PIX_FMT_PAL8;
> +#if CONFIG_VAAPI
> +    case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;

There is no VAAPI structures here, so should not use CONFIG_VAAPI to
disable them.

> +#if QSV_VERSION_ATLEAST(1, 27)
> +    case MFX_FOURCC_Y210: return AV_PIX_FMT_Y210;
> +#endif
> +#endif
>      }
>      return AV_PIX_FMT_NONE;
>  }
> @@ -211,6 +217,16 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc)
>      case AV_PIX_FMT_P010:
>          *fourcc = MFX_FOURCC_P010;
>          return AV_PIX_FMT_P010;
> +#if CONFIG_VAAPI
> +    case AV_PIX_FMT_YUV422P:
> +        *fourcc = MFX_FOURCC_YUY2;
> +        return AV_PIX_FMT_YUYV422;
> +#if QSV_VERSION_ATLEAST(1, 27)
> +    case AV_PIX_FMT_YUV422P10:
> +        *fourcc = MFX_FOURCC_Y210;
> +        return AV_PIX_FMT_Y210;
> +#endif
> +#endif
>      default:
>          return AVERROR(ENOSYS);
>      }
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> index b1b6740..4306c6e3 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -44,6 +44,10 @@
>  #include "pixdesc.h"
>  #include "time.h"
>
> +#define QSV_VERSION_ATLEAST(MAJOR, MINOR)   \
> +    (MFX_VERSION_MAJOR > (MAJOR) ||         \
> +     MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
> +
>  typedef struct QSVDevicePriv {
>      AVBufferRef *child_device_ctx;
>  } QSVDevicePriv;
> @@ -103,6 +107,14 @@ static const struct {
>      { AV_PIX_FMT_BGRA, MFX_FOURCC_RGB4 },
>      { AV_PIX_FMT_P010, MFX_FOURCC_P010 },
>      { AV_PIX_FMT_PAL8, MFX_FOURCC_P8   },
> +#if CONFIG_VAAPI
> +    { AV_PIX_FMT_YUYV422,
> +                       MFX_FOURCC_YUY2 },
> +#if QSV_VERSION_ATLEAST(1, 27)
> +    { AV_PIX_FMT_Y210,
> +                       MFX_FOURCC_Y210 },
> +#endif
> +#endif
>  };
>
>  static uint32_t qsv_fourcc_from_pix_fmt(enum AVPixelFormat pix_fmt)
> @@ -773,7 +785,19 @@ static int map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface)
>          surface->Data.R = frame->data[0] + 2;
>          surface->Data.A = frame->data[0] + 3;
>          break;
> +#if CONFIG_VAAPI
> +    case AV_PIX_FMT_YUYV422:
> +        surface->Data.Y = frame->data[0];
> +        surface->Data.U = frame->data[0] + 1;
> +        surface->Data.V = frame->data[0] + 3;
> +        break;
>
> +    case AV_PIX_FMT_Y210:
> +        surface->Data.Y16 = (mfxU16 *)frame->data[0];
> +        surface->Data.U16 = (mfxU16 *)frame->data[0] + 1;
> +        surface->Data.V16 = (mfxU16 *)frame->data[0] + 3;
> +        break;
> +#endif
>      default:
>          return MFX_ERR_UNSUPPORTED;
>      }
> --
> 2.7.4
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Fu, Linjie April 15, 2020, 4:02 a.m. UTC | #3
> From: Zhong Li <lizhong1008@gmail.com>
> Sent: Wednesday, April 15, 2020 09:58
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Cc: Fu, Linjie <linjie.fu@intel.com>
> Subject: Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode
> support for HEVC 4:2:2 8-bit and 10-bit
> 
> Linjie Fu <linjie.fu@intel.com> 于2020年2月26日周三 下午4:43写道:
> >
> > Enables HEVC Range Extension decoding support (Linux) for 4:2:2 8/10 bit
> > on ICL+ (gen11 +) platform.
> >
> > Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> > ---
> > [v2]: restrict to support on Linux.
> >
> >  libavcodec/qsv.c          | 16 ++++++++++++++++
> >  libavutil/hwcontext_qsv.c | 24 ++++++++++++++++++++++++
> >  2 files changed, 40 insertions(+)
> >
> > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> > index db98c75..171a8d6 100644
> > --- a/libavcodec/qsv.c
> > +++ b/libavcodec/qsv.c
> > @@ -195,6 +195,12 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t
> fourcc)
> >      case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
> >      case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
> >      case MFX_FOURCC_P8:   return AV_PIX_FMT_PAL8;
> > +#if CONFIG_VAAPI
> > +    case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
> 
> There is no VAAPI structures here, so should not use CONFIG_VAAPI to
> disable them.
> 

This is pointed out in [1] that D3D code doesn't support YUYV format, and indeed
It leads to unexpected crash in windows.(instead of working or reporting unsupported
On ICL- platform)

Hence this patch restricted to add support on linux only.

And I admit the best solution should be get this fully supported on both linux and windows.
(I believe Max and Artem is helping on windows side)

Thanks for the review,
Linjie

[1] https://patchwork.ffmpeg.org/project/ffmpeg/patch/1582596080-1035-1-git-send-email-linjie.fu@intel.com/
Artem Galin April 27, 2020, 4:25 p.m. UTC | #4
On Wed, 15 Apr 2020 at 05:02, Fu, Linjie <linjie.fu@intel.com> wrote:

> > From: Zhong Li <lizhong1008@gmail.com>
> > Sent: Wednesday, April 15, 2020 09:58
> > To: FFmpeg development discussions and patches <ffmpeg-
> > devel@ffmpeg.org>
> > Cc: Fu, Linjie <linjie.fu@intel.com>
> > Subject: Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode
> > support for HEVC 4:2:2 8-bit and 10-bit
> >
> > Linjie Fu <linjie.fu@intel.com> 于2020年2月26日周三 下午4:43写道:
> > >
> > > Enables HEVC Range Extension decoding support (Linux) for 4:2:2 8/10
> bit
> > > on ICL+ (gen11 +) platform.
> > >
> > > Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> > > ---
> > > [v2]: restrict to support on Linux.
> > >
> > >  libavcodec/qsv.c          | 16 ++++++++++++++++
> > >  libavutil/hwcontext_qsv.c | 24 ++++++++++++++++++++++++
> > >  2 files changed, 40 insertions(+)
> > >
> > > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> > > index db98c75..171a8d6 100644
> > > --- a/libavcodec/qsv.c
> > > +++ b/libavcodec/qsv.c
> > > @@ -195,6 +195,12 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t
> > fourcc)
> > >      case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
> > >      case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
> > >      case MFX_FOURCC_P8:   return AV_PIX_FMT_PAL8;
> > > +#if CONFIG_VAAPI
>
LGTM. CONFIG_VAAPI is not needed here because crash does not related to
these changes.
Full support MFX_FOURCC_YUY2 is WIP for Windows.

> > > +    case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
> >
> > There is no VAAPI structures here, so should not use CONFIG_VAAPI to
> > disable them.
> >
>
> This is pointed out in [1] that D3D code doesn't support YUYV format, and
> indeed
> It leads to unexpected crash in windows.(instead of working or reporting
> unsupported
> On ICL- platform)
>
> Hence this patch restricted to add support on linux only.
>
> And I admit the best solution should be get this fully supported on both
> linux and windows.
> (I believe Max and Artem is helping on windows side)
>
> Thanks for the review,
> Linjie
>
> [1]
> https://patchwork.ffmpeg.org/project/ffmpeg/patch/1582596080-1035-1-git-send-email-linjie.fu@intel.com/
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Fu, Linjie May 15, 2020, 7:06 a.m. UTC | #5
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Artem Galin
> Sent: Tuesday, April 28, 2020 00:26
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Cc: Zhong Li <lizhong1008@gmail.com>
> Subject: Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode
> support for HEVC 4:2:2 8-bit and 10-bit
> 
> On Wed, 15 Apr 2020 at 05:02, Fu, Linjie <linjie.fu@intel.com> wrote:
> 
> > > From: Zhong Li <lizhong1008@gmail.com>
> > > Sent: Wednesday, April 15, 2020 09:58
> > > To: FFmpeg development discussions and patches <ffmpeg-
> > > devel@ffmpeg.org>
> > > Cc: Fu, Linjie <linjie.fu@intel.com>
> > > Subject: Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode
> > > support for HEVC 4:2:2 8-bit and 10-bit
> > >
> > > Linjie Fu <linjie.fu@intel.com> 于2020年2月26日周三 下午4:43写道:
> > > >
> > > > Enables HEVC Range Extension decoding support (Linux) for 4:2:2 8/10
> > bit
> > > > on ICL+ (gen11 +) platform.
> > > >
> > > > Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> > > > ---
> > > > [v2]: restrict to support on Linux.
> > > >
> > > >  libavcodec/qsv.c          | 16 ++++++++++++++++
> > > >  libavutil/hwcontext_qsv.c | 24 ++++++++++++++++++++++++
> > > >  2 files changed, 40 insertions(+)
> > > >
> > > > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> > > > index db98c75..171a8d6 100644
> > > > --- a/libavcodec/qsv.c
> > > > +++ b/libavcodec/qsv.c
> > > > @@ -195,6 +195,12 @@ enum AVPixelFormat
> ff_qsv_map_fourcc(uint32_t
> > > fourcc)
> > > >      case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
> > > >      case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
> > > >      case MFX_FOURCC_P8:   return AV_PIX_FMT_PAL8;
> > > > +#if CONFIG_VAAPI
> >
> LGTM. CONFIG_VAAPI is not needed here because crash does not related to
> these changes.
> Full support MFX_FOURCC_YUY2 is WIP for Windows.
> 
> > > > +    case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
> > >
> > > There is no VAAPI structures here, so should not use CONFIG_VAAPI to
> > > disable them.
> > >
> >
> > This is pointed out in [1] that D3D code doesn't support YUYV format, and
> > indeed
> > It leads to unexpected crash in windows.(instead of working or reporting
> > unsupported
> > On ICL- platform)
> >
> > Hence this patch restricted to add support on linux only.
> >
> > And I admit the best solution should be get this fully supported on both
> > linux and windows.
> > (I believe Max and Artem is helping on windows side)
> >
> > Thanks for the review,
> > Linjie
> >
> > [1]
> > https://patchwork.ffmpeg.org/project/ffmpeg/patch/1582596080-1035-1-
> git-send-email-linjie.fu@intel.com/

Synced with Zhong, will keep the restriction for now and apply this set soon. (if no objections)

- Linjie
Max Dmitrichenko May 15, 2020, 8:18 a.m. UTC | #6
On Fri, May 15, 2020 at 9:06 AM Fu, Linjie <linjie.fu@intel.com> wrote:

> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > Artem Galin
> > Sent: Tuesday, April 28, 2020 00:26
> > To: FFmpeg development discussions and patches <ffmpeg-
> > devel@ffmpeg.org>
> > Cc: Zhong Li <lizhong1008@gmail.com>
> > Subject: Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode
> > support for HEVC 4:2:2 8-bit and 10-bit
> >
> > On Wed, 15 Apr 2020 at 05:02, Fu, Linjie <linjie.fu@intel.com> wrote:
> >
> > > > From: Zhong Li <lizhong1008@gmail.com>
> > > > Sent: Wednesday, April 15, 2020 09:58
> > > > To: FFmpeg development discussions and patches <ffmpeg-
> > > > devel@ffmpeg.org>
> > > > Cc: Fu, Linjie <linjie.fu@intel.com>
> > > > Subject: Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode
> > > > support for HEVC 4:2:2 8-bit and 10-bit
> > > >
> > > > Linjie Fu <linjie.fu@intel.com> 于2020年2月26日周三 下午4:43写道:
> > > > >
> > > > > Enables HEVC Range Extension decoding support (Linux) for 4:2:2
> 8/10
> > > bit
> > > > > on ICL+ (gen11 +) platform.
> > > > >
> > > > > Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> > > > > ---
> > > > > [v2]: restrict to support on Linux.
> > > > >
> > > > >  libavcodec/qsv.c          | 16 ++++++++++++++++
> > > > >  libavutil/hwcontext_qsv.c | 24 ++++++++++++++++++++++++
> > > > >  2 files changed, 40 insertions(+)
> > > > >
> > > > > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> > > > > index db98c75..171a8d6 100644
> > > > > --- a/libavcodec/qsv.c
> > > > > +++ b/libavcodec/qsv.c
> > > > > @@ -195,6 +195,12 @@ enum AVPixelFormat
> > ff_qsv_map_fourcc(uint32_t
> > > > fourcc)
> > > > >      case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
> > > > >      case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
> > > > >      case MFX_FOURCC_P8:   return AV_PIX_FMT_PAL8;
> > > > > +#if CONFIG_VAAPI
> > >
> > LGTM. CONFIG_VAAPI is not needed here because crash does not related to
> > these changes.
> > Full support MFX_FOURCC_YUY2 is WIP for Windows.
> >
> > > > > +    case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
> > > >
> > > > There is no VAAPI structures here, so should not use CONFIG_VAAPI to
> > > > disable them.
> > > >
> > >
> > > This is pointed out in [1] that D3D code doesn't support YUYV format,
> and
> > > indeed
> > > It leads to unexpected crash in windows.(instead of working or
> reporting
> > > unsupported
> > > On ICL- platform)
> > >
> > > Hence this patch restricted to add support on linux only.
> > >
> > > And I admit the best solution should be get this fully supported on
> both
> > > linux and windows.
> > > (I believe Max and Artem is helping on windows side)
> > >
> > > Thanks for the review,
> > > Linjie
> > >
> > > [1]
> > > https://patchwork.ffmpeg.org/project/ffmpeg/patch/1582596080-1035-1-
> > git-send-email-linjie.fu@intel.com/
>
> Synced with Zhong, will keep the restriction for now and apply this set
> soon. (if no objections)
>
>
it make sense, as patch is clearly Linux focused



> - Linjie
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".



regards
Max
Fu, Linjie May 18, 2020, 5:53 a.m. UTC | #7
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Max Dmitrichenko
> Sent: Friday, May 15, 2020 16:19
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Cc: Zhong Li <lizhong1008@gmail.com>
> Subject: Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode
> support for HEVC 4:2:2 8-bit and 10-bit
> 
> On Fri, May 15, 2020 at 9:06 AM Fu, Linjie <linjie.fu@intel.com> wrote:
> 
> > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > > Artem Galin
> > > Sent: Tuesday, April 28, 2020 00:26
> > > To: FFmpeg development discussions and patches <ffmpeg-
> > > devel@ffmpeg.org>
> > > Cc: Zhong Li <lizhong1008@gmail.com>
> > > Subject: Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode
> > > support for HEVC 4:2:2 8-bit and 10-bit
> > >
> > > On Wed, 15 Apr 2020 at 05:02, Fu, Linjie <linjie.fu@intel.com> wrote:
> > >
> > > > > From: Zhong Li <lizhong1008@gmail.com>
> > > > > Sent: Wednesday, April 15, 2020 09:58
> > > > > To: FFmpeg development discussions and patches <ffmpeg-
> > > > > devel@ffmpeg.org>
> > > > > Cc: Fu, Linjie <linjie.fu@intel.com>
> > > > > Subject: Re: [FFmpeg-devel] [PATCH, v2 1/2] lavc/qsvdec: add decode
> > > > > support for HEVC 4:2:2 8-bit and 10-bit
> > > > >
> > > > > Linjie Fu <linjie.fu@intel.com> 于2020年2月26日周三 下午4:43
> 写道:
> > > > > >
> > > > > > Enables HEVC Range Extension decoding support (Linux) for 4:2:2
> > 8/10
> > > > bit
> > > > > > on ICL+ (gen11 +) platform.
> > > > > >
> > > > > > Signed-off-by: Linjie Fu <linjie.fu@intel.com>
> > > > > > ---
> > > > > > [v2]: restrict to support on Linux.
> > > > > >
> > > > > >  libavcodec/qsv.c          | 16 ++++++++++++++++
> > > > > >  libavutil/hwcontext_qsv.c | 24 ++++++++++++++++++++++++
> > > > > >  2 files changed, 40 insertions(+)
> > > > > >
> > > > > > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> > > > > > index db98c75..171a8d6 100644
> > > > > > --- a/libavcodec/qsv.c
> > > > > > +++ b/libavcodec/qsv.c
> > > > > > @@ -195,6 +195,12 @@ enum AVPixelFormat
> > > ff_qsv_map_fourcc(uint32_t
> > > > > fourcc)
> > > > > >      case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
> > > > > >      case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
> > > > > >      case MFX_FOURCC_P8:   return AV_PIX_FMT_PAL8;
> > > > > > +#if CONFIG_VAAPI
> > > >
> > > LGTM. CONFIG_VAAPI is not needed here because crash does not
> related to
> > > these changes.
> > > Full support MFX_FOURCC_YUY2 is WIP for Windows.
> > >
> > > > > > +    case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
> > > > >
> > > > > There is no VAAPI structures here, so should not use CONFIG_VAAPI
> to
> > > > > disable them.
> > > > >
> > > >
> > > > This is pointed out in [1] that D3D code doesn't support YUYV format,
> > and
> > > > indeed
> > > > It leads to unexpected crash in windows.(instead of working or
> > reporting
> > > > unsupported
> > > > On ICL- platform)
> > > >
> > > > Hence this patch restricted to add support on linux only.
> > > >
> > > > And I admit the best solution should be get this fully supported on
> > both
> > > > linux and windows.
> > > > (I believe Max and Artem is helping on windows side)
> > > >
> > > > Thanks for the review,
> > > > Linjie
> > > >
> > > > [1]
> > > > https://patchwork.ffmpeg.org/project/ffmpeg/patch/1582596080-
> 1035-1-
> > > git-send-email-linjie.fu@intel.com/
> >
> > Synced with Zhong, will keep the restriction for now and apply this set
> > soon. (if no objections)
> >
> >
> it make sense, as patch is clearly Linux focused
> 
Thanks, applied.

- Linjie
diff mbox series

Patch

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index db98c75..171a8d6 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -195,6 +195,12 @@  enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc)
     case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12;
     case MFX_FOURCC_P010: return AV_PIX_FMT_P010;
     case MFX_FOURCC_P8:   return AV_PIX_FMT_PAL8;
+#if CONFIG_VAAPI
+    case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
+#if QSV_VERSION_ATLEAST(1, 27)
+    case MFX_FOURCC_Y210: return AV_PIX_FMT_Y210;
+#endif
+#endif
     }
     return AV_PIX_FMT_NONE;
 }
@@ -211,6 +217,16 @@  int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc)
     case AV_PIX_FMT_P010:
         *fourcc = MFX_FOURCC_P010;
         return AV_PIX_FMT_P010;
+#if CONFIG_VAAPI
+    case AV_PIX_FMT_YUV422P:
+        *fourcc = MFX_FOURCC_YUY2;
+        return AV_PIX_FMT_YUYV422;
+#if QSV_VERSION_ATLEAST(1, 27)
+    case AV_PIX_FMT_YUV422P10:
+        *fourcc = MFX_FOURCC_Y210;
+        return AV_PIX_FMT_Y210;
+#endif
+#endif
     default:
         return AVERROR(ENOSYS);
     }
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index b1b6740..4306c6e3 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -44,6 +44,10 @@ 
 #include "pixdesc.h"
 #include "time.h"
 
+#define QSV_VERSION_ATLEAST(MAJOR, MINOR)   \
+    (MFX_VERSION_MAJOR > (MAJOR) ||         \
+     MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
+
 typedef struct QSVDevicePriv {
     AVBufferRef *child_device_ctx;
 } QSVDevicePriv;
@@ -103,6 +107,14 @@  static const struct {
     { AV_PIX_FMT_BGRA, MFX_FOURCC_RGB4 },
     { AV_PIX_FMT_P010, MFX_FOURCC_P010 },
     { AV_PIX_FMT_PAL8, MFX_FOURCC_P8   },
+#if CONFIG_VAAPI
+    { AV_PIX_FMT_YUYV422,
+                       MFX_FOURCC_YUY2 },
+#if QSV_VERSION_ATLEAST(1, 27)
+    { AV_PIX_FMT_Y210,
+                       MFX_FOURCC_Y210 },
+#endif
+#endif
 };
 
 static uint32_t qsv_fourcc_from_pix_fmt(enum AVPixelFormat pix_fmt)
@@ -773,7 +785,19 @@  static int map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface)
         surface->Data.R = frame->data[0] + 2;
         surface->Data.A = frame->data[0] + 3;
         break;
+#if CONFIG_VAAPI
+    case AV_PIX_FMT_YUYV422:
+        surface->Data.Y = frame->data[0];
+        surface->Data.U = frame->data[0] + 1;
+        surface->Data.V = frame->data[0] + 3;
+        break;
 
+    case AV_PIX_FMT_Y210:
+        surface->Data.Y16 = (mfxU16 *)frame->data[0];
+        surface->Data.U16 = (mfxU16 *)frame->data[0] + 1;
+        surface->Data.V16 = (mfxU16 *)frame->data[0] + 3;
+        break;
+#endif
     default:
         return MFX_ERR_UNSUPPORTED;
     }