Re: [FFmpeg-devel] [PATCH v1 7/7] lavc/vaapi_dec: Add VVC decoder

2024-04-05 Thread Nuo Mi
>
> > > --- a/libavcodec/vaapi_decode.c
> > > +++ b/libavcodec/vaapi_decode.c
> > > @@ -455,6 +455,9 @@ static const struct {
> > >  MAP(AV1, AV1_MAIN,AV1Profile0),
> > >  MAP(AV1, AV1_HIGH,AV1Profile1),
> > >  #endif
> > > +#if VA_CHECK_VERSION(1, 22, 0)
> > > +MAP(H266,VVC_MAIN_10, VVCMain10),
> > > +#endif
> > >
> > >  #undef MAP
> > >  };
> > > @@ -627,6 +630,10 @@ static int
> > > vaapi_decode_make_config(AVCodecContext *avctx,
> > >  case AV_CODEC_ID_VP8:
> > >  frames->initial_pool_size += 3;
> > >  break;
> > > +case AV_CODEC_ID_H266:
> > > +// Add additional 16 for maximum 16 frames delay in
> > > vvc native decode.
> > > +frames->initial_pool_size += 32;
> >
> > One frame of 8k YUV444, 10 bits, is about 200MB. Thirty-two frames
> > amount to approximately 6GB.Can we dynamically allocate the buffer
> > pool?
>
> It's processing in other thread:
> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=11316
>
> >
> > The software decoder requires a delay of 16 frames to ensure full
> > utilization of CPUs. In the future, we may consider increasing this
> > to 32 or even 64 frames.
> > However, for hardware decoding, given that all processing occurs on
> > the GPU, we do not require any delay.
>
> The delay can avoid sync hardware task immediately once it is
> submitted, which can avoid hardware switch tasks frequently and drop
> performance. If the number will increase, I'd prefer to set it as an
> option and diff the default value for hardware with software.

Why does VVC require such a large frame pool while other hardware codecs do
not?
What makes VVC so special?"
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v1 7/7] lavc/vaapi_dec: Add VVC decoder

2024-04-02 Thread Wang, Fei W
On Tue, 2024-04-02 at 20:48 +0800, Nuo Mi wrote:
> 
> 
> On Thu, Mar 28, 2024 at 9:27 AM 
> wrote:
> > From: Fei Wang 
> > 
> > Signed-off-by: Fei Wang 
> > ---
> >  Changelog |   4 +
> >  configure |   3 +
> >  libavcodec/Makefile   |   1 +
> >  libavcodec/hwaccels.h |   1 +
> >  libavcodec/vaapi_decode.c |   7 +
> >  libavcodec/vaapi_vvc.c| 657
> > ++
> >  libavcodec/version.h  |   2 +-
> >  libavcodec/vvc/vvcdec.c   |  15 +-
> >  8 files changed, 688 insertions(+), 2 deletions(-)
> >  create mode 100644 libavcodec/vaapi_vvc.c
> > 
> > diff --git a/Changelog b/Changelog
> > index e83a00e35c..3108e65558 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -1,6 +1,10 @@
> >  Entries are sorted chronologically from oldest to youngest within
> > each release,
> >  releases are sorted from youngest to oldest.
> > 
> > +version :
> > +- VVC VAAPI decoder
> > +
> > +
> >  version 7.0:
> >  - DXV DXT1 encoder
> >  - LEAD MCMP decoder
> > diff --git a/configure b/configure
> > index 2a1d22310b..d902c9adc8 100755
> > --- a/configure
> > +++ b/configure
> > @@ -3258,6 +3258,8 @@ vp9_vdpau_hwaccel_deps="vdpau
> > VdpPictureInfoVP9"
> >  vp9_vdpau_hwaccel_select="vp9_decoder"
> >  vp9_videotoolbox_hwaccel_deps="videotoolbox"
> >  vp9_videotoolbox_hwaccel_select="vp9_decoder"
> > +vvc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVVC"
> > +vvc_vaapi_hwaccel_select="vvc_decoder"
> >  wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
> >  wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel"
> >  wmv3_d3d12va_hwaccel_select="vc1_d3d12va_hwaccel"
> > @@ -7250,6 +7252,7 @@ if enabled vaapi; then
> >  check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0,
> > 0)"
> > 
> >  check_type "va/va.h va/va_dec_hevc.h"
> > "VAPictureParameterBufferHEVC"
> > +check_type "va/va.h va/va_dec_vvc.h"
> > "VAPictureParameterBufferVVC"
> >  check_struct "va/va.h" "VADecPictureParameterBufferVP9"
> > bit_depth
> >  check_struct "va/va.h" "VADecPictureParameterBufferAV1"
> > bit_depth_idx
> >  check_type   "va/va.h va/va_vpp.h"
> > "VAProcFilterParameterBufferHDRToneMapping"
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index 9ce6d445c1..343b037636 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -1054,6 +1054,7 @@ OBJS-$(CONFIG_VP9_VAAPI_HWACCEL)  +=
> > vaapi_vp9.o
> >  OBJS-$(CONFIG_VP9_VDPAU_HWACCEL)  += vdpau_vp9.o
> >  OBJS-$(CONFIG_VP9_VIDEOTOOLBOX_HWACCEL)   += videotoolbox_vp9.o
> >  OBJS-$(CONFIG_VP8_QSV_HWACCEL)+= qsvdec.o
> > +OBJS-$(CONFIG_VVC_VAAPI_HWACCEL)  += vaapi_vvc.o
> > 
> >  # Objects duplicated from other libraries for shared builds
> >  SHLIBOBJS  += log2_tab.o reverse.o
> > diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
> > index 5171e4c7d7..88d6b9a9b5 100644
> > --- a/libavcodec/hwaccels.h
> > +++ b/libavcodec/hwaccels.h
> > @@ -82,6 +82,7 @@ extern const struct FFHWAccel
> > ff_vp9_nvdec_hwaccel;
> >  extern const struct FFHWAccel ff_vp9_vaapi_hwaccel;
> >  extern const struct FFHWAccel ff_vp9_vdpau_hwaccel;
> >  extern const struct FFHWAccel ff_vp9_videotoolbox_hwaccel;
> > +extern const struct FFHWAccel ff_vvc_vaapi_hwaccel;
> >  extern const struct FFHWAccel ff_wmv3_d3d11va_hwaccel;
> >  extern const struct FFHWAccel ff_wmv3_d3d11va2_hwaccel;
> >  extern const struct FFHWAccel ff_wmv3_d3d12va_hwaccel;
> > diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> > index 1b1972a2a9..ceeb1f1a12 100644
> > --- a/libavcodec/vaapi_decode.c
> > +++ b/libavcodec/vaapi_decode.c
> > @@ -455,6 +455,9 @@ static const struct {
> >  MAP(AV1, AV1_MAIN,AV1Profile0),
> >  MAP(AV1, AV1_HIGH,AV1Profile1),
> >  #endif
> > +#if VA_CHECK_VERSION(1, 22, 0)
> > +MAP(H266,VVC_MAIN_10, VVCMain10),
> > +#endif
> > 
> >  #undef MAP
> >  };
> > @@ -627,6 +630,10 @@ static int
> > vaapi_decode_make_config(AVCodecContext *avctx,
> >  case AV_CODEC_ID_VP8:
> >  frames->initial_pool_size += 3;
> >  break;
> > +case AV_CODEC_ID_H266:
> > +// Add additional 16 for maximum 16 frames delay in
> > vvc native decode.
> > +frames->initial_pool_size += 32;
> 
> One frame of 8k YUV444, 10 bits, is about 200MB. Thirty-two frames
> amount to approximately 6GB.Can we dynamically allocate the buffer
> pool? 

It's processing in other thread:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=11316

> 
> The software decoder requires a delay of 16 frames to ensure full
> utilization of CPUs. In the future, we may consider increasing this
> to 32 or even 64 frames.
> However, for hardware decoding, given that all processing occurs on
> the GPU, we do not require any delay.

The delay can avoid sync hardware task immediately once it is
submitted, which can avoid hardware switch tasks 

Re: [FFmpeg-devel] [PATCH v1 7/7] lavc/vaapi_dec: Add VVC decoder

2024-04-02 Thread Nuo Mi
On Thu, Mar 28, 2024 at 9:27 AM  wrote:

> From: Fei Wang 
>
> Signed-off-by: Fei Wang 
> ---
>  Changelog |   4 +
>  configure |   3 +
>  libavcodec/Makefile   |   1 +
>  libavcodec/hwaccels.h |   1 +
>  libavcodec/vaapi_decode.c |   7 +
>  libavcodec/vaapi_vvc.c| 657 ++
>  libavcodec/version.h  |   2 +-
>  libavcodec/vvc/vvcdec.c   |  15 +-
>  8 files changed, 688 insertions(+), 2 deletions(-)
>  create mode 100644 libavcodec/vaapi_vvc.c
>
> diff --git a/Changelog b/Changelog
> index e83a00e35c..3108e65558 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -1,6 +1,10 @@
>  Entries are sorted chronologically from oldest to youngest within each
> release,
>  releases are sorted from youngest to oldest.
>
> +version :
> +- VVC VAAPI decoder
> +
> +
>  version 7.0:
>  - DXV DXT1 encoder
>  - LEAD MCMP decoder
> diff --git a/configure b/configure
> index 2a1d22310b..d902c9adc8 100755
> --- a/configure
> +++ b/configure
> @@ -3258,6 +3258,8 @@ vp9_vdpau_hwaccel_deps="vdpau VdpPictureInfoVP9"
>  vp9_vdpau_hwaccel_select="vp9_decoder"
>  vp9_videotoolbox_hwaccel_deps="videotoolbox"
>  vp9_videotoolbox_hwaccel_select="vp9_decoder"
> +vvc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVVC"
> +vvc_vaapi_hwaccel_select="vvc_decoder"
>  wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
>  wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel"
>  wmv3_d3d12va_hwaccel_select="vc1_d3d12va_hwaccel"
> @@ -7250,6 +7252,7 @@ if enabled vaapi; then
>  check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0, 0)"
>
>  check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
> +check_type "va/va.h va/va_dec_vvc.h" "VAPictureParameterBufferVVC"
>  check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
>  check_struct "va/va.h" "VADecPictureParameterBufferAV1" bit_depth_idx
>  check_type   "va/va.h va/va_vpp.h"
> "VAProcFilterParameterBufferHDRToneMapping"
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 9ce6d445c1..343b037636 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1054,6 +1054,7 @@ OBJS-$(CONFIG_VP9_VAAPI_HWACCEL)  +=
> vaapi_vp9.o
>  OBJS-$(CONFIG_VP9_VDPAU_HWACCEL)  += vdpau_vp9.o
>  OBJS-$(CONFIG_VP9_VIDEOTOOLBOX_HWACCEL)   += videotoolbox_vp9.o
>  OBJS-$(CONFIG_VP8_QSV_HWACCEL)+= qsvdec.o
> +OBJS-$(CONFIG_VVC_VAAPI_HWACCEL)  += vaapi_vvc.o
>
>  # Objects duplicated from other libraries for shared builds
>  SHLIBOBJS  += log2_tab.o reverse.o
> diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
> index 5171e4c7d7..88d6b9a9b5 100644
> --- a/libavcodec/hwaccels.h
> +++ b/libavcodec/hwaccels.h
> @@ -82,6 +82,7 @@ extern const struct FFHWAccel ff_vp9_nvdec_hwaccel;
>  extern const struct FFHWAccel ff_vp9_vaapi_hwaccel;
>  extern const struct FFHWAccel ff_vp9_vdpau_hwaccel;
>  extern const struct FFHWAccel ff_vp9_videotoolbox_hwaccel;
> +extern const struct FFHWAccel ff_vvc_vaapi_hwaccel;
>  extern const struct FFHWAccel ff_wmv3_d3d11va_hwaccel;
>  extern const struct FFHWAccel ff_wmv3_d3d11va2_hwaccel;
>  extern const struct FFHWAccel ff_wmv3_d3d12va_hwaccel;
> diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> index 1b1972a2a9..ceeb1f1a12 100644
> --- a/libavcodec/vaapi_decode.c
> +++ b/libavcodec/vaapi_decode.c
> @@ -455,6 +455,9 @@ static const struct {
>  MAP(AV1, AV1_MAIN,AV1Profile0),
>  MAP(AV1, AV1_HIGH,AV1Profile1),
>  #endif
> +#if VA_CHECK_VERSION(1, 22, 0)
> +MAP(H266,VVC_MAIN_10, VVCMain10),
> +#endif
>
>  #undef MAP
>  };
> @@ -627,6 +630,10 @@ static int vaapi_decode_make_config(AVCodecContext
> *avctx,
>  case AV_CODEC_ID_VP8:
>  frames->initial_pool_size += 3;
>  break;
> +case AV_CODEC_ID_H266:
> +// Add additional 16 for maximum 16 frames delay in vvc
> native decode.
> +frames->initial_pool_size += 32;
>
One frame of 8k YUV444, 10 bits, is about 200MB. Thirty-two frames amount
to approximately 6GB.Can we dynamically allocate the buffer pool?

The software decoder requires a delay of 16 frames to ensure full
utilization of CPUs. In the future, we may consider increasing this to 32
or even 64 frames.
However, for hardware decoding, given that all processing occurs on the
GPU, we do not require any delay.

+break;
>  default:
>  frames->initial_pool_size += 2;
>  }
> diff --git a/libavcodec/vaapi_vvc.c b/libavcodec/vaapi_vvc.c
> new file mode 100644
> index 00..6141005688
> --- /dev/null
> +++ b/libavcodec/vaapi_vvc.c
> @@ -0,0 +1,657 @@
> +/*
> + * VVC HW decode acceleration through VA API
> + *
> + * Copyright (c) 2024 Intel Corporation
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the 

[FFmpeg-devel] [PATCH v1 7/7] lavc/vaapi_dec: Add VVC decoder

2024-03-27 Thread fei . w . wang-at-intel . com
From: Fei Wang 

Signed-off-by: Fei Wang 
---
 Changelog |   4 +
 configure |   3 +
 libavcodec/Makefile   |   1 +
 libavcodec/hwaccels.h |   1 +
 libavcodec/vaapi_decode.c |   7 +
 libavcodec/vaapi_vvc.c| 657 ++
 libavcodec/version.h  |   2 +-
 libavcodec/vvc/vvcdec.c   |  15 +-
 8 files changed, 688 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/vaapi_vvc.c

diff --git a/Changelog b/Changelog
index e83a00e35c..3108e65558 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,10 @@
 Entries are sorted chronologically from oldest to youngest within each release,
 releases are sorted from youngest to oldest.
 
+version :
+- VVC VAAPI decoder
+
+
 version 7.0:
 - DXV DXT1 encoder
 - LEAD MCMP decoder
diff --git a/configure b/configure
index 2a1d22310b..d902c9adc8 100755
--- a/configure
+++ b/configure
@@ -3258,6 +3258,8 @@ vp9_vdpau_hwaccel_deps="vdpau VdpPictureInfoVP9"
 vp9_vdpau_hwaccel_select="vp9_decoder"
 vp9_videotoolbox_hwaccel_deps="videotoolbox"
 vp9_videotoolbox_hwaccel_select="vp9_decoder"
+vvc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVVC"
+vvc_vaapi_hwaccel_select="vvc_decoder"
 wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
 wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel"
 wmv3_d3d12va_hwaccel_select="vc1_d3d12va_hwaccel"
@@ -7250,6 +7252,7 @@ if enabled vaapi; then
 check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0, 0)"
 
 check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
+check_type "va/va.h va/va_dec_vvc.h" "VAPictureParameterBufferVVC"
 check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
 check_struct "va/va.h" "VADecPictureParameterBufferAV1" bit_depth_idx
 check_type   "va/va.h va/va_vpp.h" 
"VAProcFilterParameterBufferHDRToneMapping"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 9ce6d445c1..343b037636 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1054,6 +1054,7 @@ OBJS-$(CONFIG_VP9_VAAPI_HWACCEL)  += vaapi_vp9.o
 OBJS-$(CONFIG_VP9_VDPAU_HWACCEL)  += vdpau_vp9.o
 OBJS-$(CONFIG_VP9_VIDEOTOOLBOX_HWACCEL)   += videotoolbox_vp9.o
 OBJS-$(CONFIG_VP8_QSV_HWACCEL)+= qsvdec.o
+OBJS-$(CONFIG_VVC_VAAPI_HWACCEL)  += vaapi_vvc.o
 
 # Objects duplicated from other libraries for shared builds
 SHLIBOBJS  += log2_tab.o reverse.o
diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
index 5171e4c7d7..88d6b9a9b5 100644
--- a/libavcodec/hwaccels.h
+++ b/libavcodec/hwaccels.h
@@ -82,6 +82,7 @@ extern const struct FFHWAccel ff_vp9_nvdec_hwaccel;
 extern const struct FFHWAccel ff_vp9_vaapi_hwaccel;
 extern const struct FFHWAccel ff_vp9_vdpau_hwaccel;
 extern const struct FFHWAccel ff_vp9_videotoolbox_hwaccel;
+extern const struct FFHWAccel ff_vvc_vaapi_hwaccel;
 extern const struct FFHWAccel ff_wmv3_d3d11va_hwaccel;
 extern const struct FFHWAccel ff_wmv3_d3d11va2_hwaccel;
 extern const struct FFHWAccel ff_wmv3_d3d12va_hwaccel;
diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 1b1972a2a9..ceeb1f1a12 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -455,6 +455,9 @@ static const struct {
 MAP(AV1, AV1_MAIN,AV1Profile0),
 MAP(AV1, AV1_HIGH,AV1Profile1),
 #endif
+#if VA_CHECK_VERSION(1, 22, 0)
+MAP(H266,VVC_MAIN_10, VVCMain10),
+#endif
 
 #undef MAP
 };
@@ -627,6 +630,10 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
 case AV_CODEC_ID_VP8:
 frames->initial_pool_size += 3;
 break;
+case AV_CODEC_ID_H266:
+// Add additional 16 for maximum 16 frames delay in vvc native 
decode.
+frames->initial_pool_size += 32;
+break;
 default:
 frames->initial_pool_size += 2;
 }
diff --git a/libavcodec/vaapi_vvc.c b/libavcodec/vaapi_vvc.c
new file mode 100644
index 00..6141005688
--- /dev/null
+++ b/libavcodec/vaapi_vvc.c
@@ -0,0 +1,657 @@
+/*
+ * VVC HW decode acceleration through VA API
+ *
+ * Copyright (c) 2024 Intel Corporation
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+