Re: [FFmpeg-devel] [PATCH 1/3] avcodec/vvc_parser: move avctx->has_b_frames initialization to dec

2024-07-25 Thread Nuo Mi
On Wed, Jul 24, 2024 at 2:56 AM  wrote:

> From: Wu Jianhua 
>
> From Jun Zhao :
> > Should we relocate this to the decoder? Other codecs typically set this
> > parameter in the decoder.
>
Thank you, Jianhua.
will apply next week.

>
> Signed-off-by: Wu Jianhua 
> ---
>  libavcodec/vvc/dec.c| 1 +
>  libavcodec/vvc_parser.c | 3 ---
>  2 files changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
> index d04f68e4cf..6e225d278a 100644
> --- a/libavcodec/vvc/dec.c
> +++ b/libavcodec/vvc/dec.c
> @@ -748,6 +748,7 @@ static void export_frame_params(VVCContext *s, const
> VVCFrameContext *fc)
>  c->coded_height = pps->height;
>  c->width= pps->width  - ((pps->r->pps_conf_win_left_offset +
> pps->r->pps_conf_win_right_offset) << sps->hshift[CHROMA]);
>  c->height   = pps->height - ((pps->r->pps_conf_win_top_offset +
> pps->r->pps_conf_win_bottom_offset) << sps->vshift[CHROMA]);
> +c->has_b_frames =
> sps->r->sps_dpb_params.dpb_max_num_reorder_pics[sps->r->sps_max_sublayers_minus1];
>  }
>
>  static int frame_setup(VVCFrameContext *fc, VVCContext *s)
> diff --git a/libavcodec/vvc_parser.c b/libavcodec/vvc_parser.c
> index 5373875aae..8d32d66573 100644
> --- a/libavcodec/vvc_parser.c
> +++ b/libavcodec/vvc_parser.c
> @@ -185,9 +185,6 @@ static void set_parser_ctx(AVCodecParserContext *s,
> AVCodecContext *avctx,
>  avctx->color_range =
>  sps->vui.vui_full_range_flag ? AVCOL_RANGE_JPEG :
> AVCOL_RANGE_MPEG;
>
> -avctx->has_b_frames =
> -
> sps->sps_dpb_params.dpb_max_num_reorder_pics[sps->sps_max_sublayers_minus1];
> -
>  if (sps->sps_ptl_dpb_hrd_params_present_flag &&
>  sps->sps_timing_hrd_params_present_flag) {
>  uint32_t num =
> sps->sps_general_timing_hrd_parameters.num_units_in_tick;
> --
> 2.44.0.windows.1
>
> ___
> 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".
>
___
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] [FFmpeg-cvslog] avcodec/vvc: Add aarch64 neon optimization for ALF

2024-07-23 Thread Nuo Mi
On Tue, Jul 23, 2024 at 7:24 PM Martin Storsjö  wrote:

> On Mon, 22 Jul 2024, Nuo Mi wrote:
>
> > On Mon, Jul 22, 2024 at 9:15 PM Martin Storsjö  wrote:
> >   On Mon, 22 Jul 2024, Zhao Zhili wrote:
> >
> >   > ffmpeg | branch: master | Zhao Zhili  |
> >   Tue Jul 16 00:19:15 2024 +0800|
> >   [2d4ef304c9e13f5e8abe37c20ddd0f17102c6393] | committer: Nuo Mi
> >   >
> >   > avcodec/vvc: Add aarch64 neon optimization for ALF
> >   >
> >   >>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2d4ef304c9e13f5e8
> >   abe37c20ddd0f17102c6393
> >   > ---
> >   >
> >   > libavcodec/aarch64/vvc/Makefile   |   5 +
> >   > libavcodec/aarch64/vvc/alf.S  | 293
> >   ++
> >   > libavcodec/aarch64/vvc/alf_template.c | 157 ++
> >   > libavcodec/aarch64/vvc/dsp_init.c |  57 +++
> >   > libavcodec/vvc/dsp.c  |   4 +-
> >   > libavcodec/vvc/dsp.h  |   1 +
> >   > 6 files changed, 516 insertions(+), 1 deletion(-)
> >
> >   I didn't review this patch yet.
> >
> >   I've been on vacation, and I was hoping to get to reviewing this
> >   (and
> >   other things) soon when I catch up.
> >
> >   The patch hasn't even been on the mailing list for one single
> >   week! For
> >   areas where earlier reviews have required multiple iterations to
> >   get
> >   patches right, I would hope that we could wait for an actual
> >   review.
> >
> > Hi Martin,
> > Sorry for this.I will wait more time next time.
> > Do you prefer to revert the patch temporarily?
>
> No, it doesn't seem to be necesssary - the patch seems mostly fine in
> practice; I only have a couple of minor suggestions. I'll send a patch to
> fix those bits.
>
Great! thank you for the patches

>
> // Martin
>
___
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] [FFmpeg-cvslog] avcodec/vvc: Add aarch64 neon optimization for ALF

2024-07-22 Thread Nuo Mi
On Mon, Jul 22, 2024 at 9:15 PM Martin Storsjö  wrote:

> On Mon, 22 Jul 2024, Zhao Zhili wrote:
>
> > ffmpeg | branch: master | Zhao Zhili  | Tue Jul
> 16 00:19:15 2024 +0800| [2d4ef304c9e13f5e8abe37c20ddd0f17102c6393] |
> committer: Nuo Mi
> >
> > avcodec/vvc: Add aarch64 neon optimization for ALF
> >
> >>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2d4ef304c9e13f5e8abe37c20ddd0f17102c6393
> > ---
> >
> > libavcodec/aarch64/vvc/Makefile   |   5 +
> > libavcodec/aarch64/vvc/alf.S  | 293
> ++
> > libavcodec/aarch64/vvc/alf_template.c | 157 ++
> > libavcodec/aarch64/vvc/dsp_init.c |  57 +++
> > libavcodec/vvc/dsp.c  |   4 +-
> > libavcodec/vvc/dsp.h  |   1 +
> > 6 files changed, 516 insertions(+), 1 deletion(-)
>
> I didn't review this patch yet.
>
> I've been on vacation, and I was hoping to get to reviewing this (and
> other things) soon when I catch up.
>
> The patch hasn't even been on the mailing list for one single week! For
> areas where earlier reviews have required multiple iterations to get
> patches right, I would hope that we could wait for an actual review.
>
Hi Martin,
Sorry for this.I will wait more time next time.
Do you prefer to revert the patch temporarily?

Thank you.

>
> // Martin
>
>
___
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] avcodec/vvc: Add aarch64 neon optimization for ALF

2024-07-22 Thread Nuo Mi
On Tue, Jul 16, 2024 at 8:39 PM Nuo Mi  wrote:

> Hi Zhili,
> Good job. Appreciate it.
> With this patch, we're very close to smooth 4K@30 playback on my M2.
>
Applied.
Thank you, Zhili, for our first Neon optimizations.


> On Tue, Jul 16, 2024 at 12:19 AM Zhao Zhili 
> wrote:
>
>> From: Zhao Zhili 
>>
>> vvc_alf_filter_chroma_4x4_8_c: 3.0
>> vvc_alf_filter_chroma_4x4_8_neon: 1.0
>> vvc_alf_filter_chroma_4x4_10_c: 2.7
>> vvc_alf_filter_chroma_4x4_10_neon: 1.0
>> vvc_alf_filter_chroma_4x4_12_c: 2.7
>> vvc_alf_filter_chroma_4x4_12_neon: 1.0
>> vvc_alf_filter_chroma_8x8_8_c: 10.2
>> vvc_alf_filter_chroma_8x8_8_neon: 3.0
>> vvc_alf_filter_chroma_8x8_10_c: 10.0
>> vvc_alf_filter_chroma_8x8_10_neon: 2.5
>> vvc_alf_filter_chroma_8x8_12_c: 10.0
>> vvc_alf_filter_chroma_8x8_12_neon: 2.5
>> vvc_alf_filter_chroma_16x16_8_c: 41.7
>> vvc_alf_filter_chroma_16x16_8_neon: 11.2
>> vvc_alf_filter_chroma_16x16_10_c: 39.0
>> vvc_alf_filter_chroma_16x16_10_neon: 10.0
>> vvc_alf_filter_chroma_16x16_12_c: 40.2
>> vvc_alf_filter_chroma_16x16_12_neon: 10.2
>> vvc_alf_filter_chroma_32x32_8_c: 162.0
>> vvc_alf_filter_chroma_32x32_8_neon: 45.0
>> vvc_alf_filter_chroma_32x32_10_c: 155.5
>> vvc_alf_filter_chroma_32x32_10_neon: 39.5
>> vvc_alf_filter_chroma_32x32_12_c: 155.5
>> vvc_alf_filter_chroma_32x32_12_neon: 40.0
>> vvc_alf_filter_chroma_64x64_8_c: 646.0
>> vvc_alf_filter_chroma_64x64_8_neon: 175.5
>> vvc_alf_filter_chroma_64x64_10_c: 708.2
>> vvc_alf_filter_chroma_64x64_10_neon: 166.7
>> vvc_alf_filter_chroma_64x64_12_c: 619.2
>> vvc_alf_filter_chroma_64x64_12_neon: 157.2
>> vvc_alf_filter_chroma_128x128_8_c: 2611.5
>> vvc_alf_filter_chroma_128x128_8_neon: 698.2
>> vvc_alf_filter_chroma_128x128_10_c: 2470.0
>> vvc_alf_filter_chroma_128x128_10_neon: 616.0
>> vvc_alf_filter_chroma_128x128_12_c: 2531.5
>> vvc_alf_filter_chroma_128x128_12_neon: 620.2
>> vvc_alf_filter_luma_8x8_8_c: 25.2
>> vvc_alf_filter_luma_8x8_8_neon: 4.2
>> vvc_alf_filter_luma_8x8_10_c: 18.5
>> vvc_alf_filter_luma_8x8_10_neon: 4.0
>> vvc_alf_filter_luma_8x8_12_c: 19.0
>> vvc_alf_filter_luma_8x8_12_neon: 4.0
>> vvc_alf_filter_luma_16x16_8_c: 106.5
>> vvc_alf_filter_luma_16x16_8_neon: 16.2
>> vvc_alf_filter_luma_16x16_10_c: 75.2
>> vvc_alf_filter_luma_16x16_10_neon: 14.7
>> vvc_alf_filter_luma_16x16_12_c: 79.7
>> vvc_alf_filter_luma_16x16_12_neon: 14.7
>> vvc_alf_filter_luma_32x32_8_c: 400.5
>> vvc_alf_filter_luma_32x32_8_neon: 63.2
>> vvc_alf_filter_luma_32x32_10_c: 299.2
>> vvc_alf_filter_luma_32x32_10_neon: 57.7
>> vvc_alf_filter_luma_32x32_12_c: 299.2
>> vvc_alf_filter_luma_32x32_12_neon: 57.7
>> vvc_alf_filter_luma_64x64_8_c: 1602.5
>> vvc_alf_filter_luma_64x64_8_neon: 251.7
>> vvc_alf_filter_luma_64x64_10_c: 1197.0
>> vvc_alf_filter_luma_64x64_10_neon: 235.5
>> vvc_alf_filter_luma_64x64_12_c: 1220.2
>> vvc_alf_filter_luma_64x64_12_neon: 235.7
>> vvc_alf_filter_luma_128x128_8_c: 6570.2
>> vvc_alf_filter_luma_128x128_8_neon: 1007.7
>> vvc_alf_filter_luma_128x128_10_c: 4822.7
>> vvc_alf_filter_luma_128x128_10_neon: 936.2
>> vvc_alf_filter_luma_128x128_12_c: 4791.2
>> vvc_alf_filter_luma_128x128_12_neon: 938.5
>>
>> Signed-off-by: Zhao Zhili 
>> ---
>>  libavcodec/aarch64/vvc/Makefile   |   5 +
>>  libavcodec/aarch64/vvc/alf.S  | 293 ++
>>  libavcodec/aarch64/vvc/alf_template.c | 157 ++
>>  libavcodec/aarch64/vvc/dsp_init.c |  57 +
>>  libavcodec/vvc/dsp.c  |   4 +-
>>  libavcodec/vvc/dsp.h  |   1 +
>>  6 files changed, 516 insertions(+), 1 deletion(-)
>>  create mode 100644 libavcodec/aarch64/vvc/Makefile
>>  create mode 100644 libavcodec/aarch64/vvc/alf.S
>>  create mode 100644 libavcodec/aarch64/vvc/alf_template.c
>>  create mode 100644 libavcodec/aarch64/vvc/dsp_init.c
>>
>> diff --git a/libavcodec/aarch64/vvc/Makefile
>> b/libavcodec/aarch64/vvc/Makefile
>> new file mode 100644
>> index 00..58398d6e3d
>> --- /dev/null
>> +++ b/libavcodec/aarch64/vvc/Makefile
>> @@ -0,0 +1,5 @@
>> +clean::
>> +   $(RM) $(CLEANSUFFIXES:%=libavcodec/aarch64/vvc/%)
>> +
>> +OBJS-$(CONFIG_VVC_DECODER) +=
>> aarch64/vvc/dsp_init.o
>> +NEON-OBJS-$(CONFIG_VVC_DECODER)+=
>> aarch64/vvc/alf.o
>> diff --git a/libavcodec/aarch64/vvc/alf.S b/libavcodec/aarch64/vvc/alf.S
>> new file mode 100644
>> index 00..beb36ac

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/vvc: Remove write-only assignments in alf_filter_chroma

2024-07-17 Thread Nuo Mi
On Tue, Jul 16, 2024 at 10:50 AM Zhao Zhili  wrote:

> From: Zhao Zhili 
>
merged.
Thank you

>
> ---
>  libavcodec/vvc/filter_template.c | 10 --
>  1 file changed, 10 deletions(-)
>
> diff --git a/libavcodec/vvc/filter_template.c
> b/libavcodec/vvc/filter_template.c
> index 32777452b7..6dd7310089 100644
> --- a/libavcodec/vvc/filter_template.c
> +++ b/libavcodec/vvc/filter_template.c
> @@ -153,8 +153,6 @@ static void FUNC(alf_filter_chroma)(uint8_t* _dst,
> ptrdiff_t dst_stride, const u
>  const pixel *s2 = s0 - src_stride;
>  const pixel *s3 = s1 + src_stride;
>  const pixel *s4 = s2 - src_stride;
> -const pixel *s5 = s3 + src_stride;
> -const pixel *s6 = s4 - src_stride;
>
>  for (int i = 0; i < ALF_BLOCK_SIZE; i++) {
>  pixel *dst = (pixel *)_dst + (y + i) * dst_stride + x;
> @@ -164,8 +162,6 @@ static void FUNC(alf_filter_chroma)(uint8_t* _dst,
> ptrdiff_t dst_stride, const u
>  const pixel *p2 = s2 + i * src_stride;
>  const pixel *p3 = s3 + i * src_stride;
>  const pixel *p4 = s4 + i * src_stride;
> -const pixel *p5 = s5 + i * src_stride;
> -const pixel *p6 = s6 + i * src_stride;
>
>  const int is_near_vb_above = (y + i <  vb_pos) && (y + i
> >= vb_pos - 1);
>  const int is_near_vb_below = (y + i >= vb_pos) && (y + i
> <= vb_pos);
> @@ -174,19 +170,15 @@ static void FUNC(alf_filter_chroma)(uint8_t* _dst,
> ptrdiff_t dst_stride, const u
>  if ((y + i < vb_pos) && ((y + i) >= vb_above)) {
>  p1 = (y + i == vb_pos - 1) ? p0 : p1;
>  p3 = (y + i >= vb_pos - 2) ? p1 : p3;
> -p5 = (y + i >= vb_pos - 3) ? p3 : p5;
>
>  p2 = (y + i == vb_pos - 1) ? p0 : p2;
>  p4 = (y + i >= vb_pos - 2) ? p2 : p4;
> -p6 = (y + i >= vb_pos - 3) ? p4 : p6;
>  } else if ((y + i >= vb_pos) && ((y + i) <= vb_below)) {
>  p2 = (y + i == vb_pos) ? p0 : p2;
>  p4 = (y + i <= vb_pos + 1) ? p2 : p4;
> -p6 = (y + i <= vb_pos + 2) ? p4 : p6;
>
>  p1 = (y + i == vb_pos) ? p0 : p1;
>  p3 = (y + i <= vb_pos + 1) ? p1 : p3;
> -p5 = (y + i <= vb_pos + 2) ? p3 : p5;
>  }
>
>  for (int j = 0; j < ALF_BLOCK_SIZE; j++) {
> @@ -212,8 +204,6 @@ static void FUNC(alf_filter_chroma)(uint8_t* _dst,
> ptrdiff_t dst_stride, const u
>  p2++;
>  p3++;
>  p4++;
> -p5++;
> -p6++;
>  }
>  }
>  }
> --
> 2.42.0
>
> ___
> 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".
>
___
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 1/2] avcodec/vvc: Remove NOP condition check in alf_filter_luma

2024-07-17 Thread Nuo Mi
On Wed, Jul 17, 2024 at 12:17 AM Zhao Zhili  wrote:

>
>
> > On Jul 17, 2024, at 00:07, Zhao Zhili  wrote:
> >
> >
> >
> >> On Jul 16, 2024, at 20:31, Nuo Mi  wrote:
> >>
> >> On Tue, Jul 16, 2024 at 10:50 AM Zhao Zhili  <mailto:quinkbl...@foxmail.com>> wrote:
> >>
> >>> From: Zhao Zhili mailto:zhiliz...@tencent.com
> >>
> >>>
> >>> If (y + i == vb_above) or (y + i == vb_below), the if body has no
> >>> operation.
> >>>
> >> , How did you find this? From a compiler warning or by reading the
> code?
> >
> > There is compiler warning. I found this issue when trying to simplify
> the logic
> > before rewrite in ARM assembly.
>
> Oops, I mean there is “no" compiler warning.
>
Good catch!
Applied.
Thank you


>
> >
> >>
> >>
> >>> ---
> >>> libavcodec/vvc/filter_template.c | 4 ++--
> >>> 1 file changed, 2 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/libavcodec/vvc/filter_template.c
> >>> b/libavcodec/vvc/filter_template.c
> >>> index 9b3a0e46f7..32777452b7 100644
> >>> --- a/libavcodec/vvc/filter_template.c
> >>> +++ b/libavcodec/vvc/filter_template.c
> >>> @@ -77,7 +77,7 @@ static void FUNC(alf_filter_luma)(uint8_t *_dst,
> >>> ptrdiff_t dst_stride, const uin
> >>>const int is_near_vb_below = (y + i >= vb_pos) && (y + i
> >>> <= vb_pos);
> >>>const int is_near_vb = is_near_vb_above ||
> >>> is_near_vb_below;
> >>>
> >>> -if ((y + i < vb_pos) && ((y + i) >= vb_above)) {
> >>> +if ((y + i < vb_pos) && ((y + i) > vb_above)) {
> >>>p1 = (y + i == vb_pos - 1) ? p0 : p1;
> >>>p3 = (y + i >= vb_pos - 2) ? p1 : p3;
> >>>p5 = (y + i >= vb_pos - 3) ? p3 : p5;
> >>> @@ -85,7 +85,7 @@ static void FUNC(alf_filter_luma)(uint8_t *_dst,
> >>> ptrdiff_t dst_stride, const uin
> >>>p2 = (y + i == vb_pos - 1) ? p0 : p2;
> >>>p4 = (y + i >= vb_pos - 2) ? p2 : p4;
> >>>p6 = (y + i >= vb_pos - 3) ? p4 : p6;
> >>> -} else if ((y + i >= vb_pos) && ((y + i) <=
> vb_below)) {
> >>> +} else if ((y + i >= vb_pos) && ((y + i) < vb_below))
> {
> >>>p2 = (y + i == vb_pos) ? p0 : p2;
> >>>p4 = (y + i <= vb_pos + 1) ? p2 : p4;
> >>>p6 = (y + i <= vb_pos + 2) ? p4 : p6;
> >>> --
> >>> 2.42.0
> >>>
> >>> ___
> >>> 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".
> >>>
> >> ___
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >> To unsubscribe, visit link above, or email
> >> ffmpeg-devel-requ...@ffmpeg.org <mailto:ffmpeg-devel-requ...@ffmpeg.org>
> with subject "unsubscribe".
> >
> > ___
> > 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".
>
> ___
> 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".
>
___
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] avcodec/vvc: Add aarch64 neon optimization for ALF

2024-07-16 Thread Nuo Mi
Hi Zhili,
Good job. Appreciate it.
With this patch, we're very close to smooth 4K@30 playback on my M2.

On Tue, Jul 16, 2024 at 12:19 AM Zhao Zhili  wrote:

> From: Zhao Zhili 
>
> vvc_alf_filter_chroma_4x4_8_c: 3.0
> vvc_alf_filter_chroma_4x4_8_neon: 1.0
> vvc_alf_filter_chroma_4x4_10_c: 2.7
> vvc_alf_filter_chroma_4x4_10_neon: 1.0
> vvc_alf_filter_chroma_4x4_12_c: 2.7
> vvc_alf_filter_chroma_4x4_12_neon: 1.0
> vvc_alf_filter_chroma_8x8_8_c: 10.2
> vvc_alf_filter_chroma_8x8_8_neon: 3.0
> vvc_alf_filter_chroma_8x8_10_c: 10.0
> vvc_alf_filter_chroma_8x8_10_neon: 2.5
> vvc_alf_filter_chroma_8x8_12_c: 10.0
> vvc_alf_filter_chroma_8x8_12_neon: 2.5
> vvc_alf_filter_chroma_16x16_8_c: 41.7
> vvc_alf_filter_chroma_16x16_8_neon: 11.2
> vvc_alf_filter_chroma_16x16_10_c: 39.0
> vvc_alf_filter_chroma_16x16_10_neon: 10.0
> vvc_alf_filter_chroma_16x16_12_c: 40.2
> vvc_alf_filter_chroma_16x16_12_neon: 10.2
> vvc_alf_filter_chroma_32x32_8_c: 162.0
> vvc_alf_filter_chroma_32x32_8_neon: 45.0
> vvc_alf_filter_chroma_32x32_10_c: 155.5
> vvc_alf_filter_chroma_32x32_10_neon: 39.5
> vvc_alf_filter_chroma_32x32_12_c: 155.5
> vvc_alf_filter_chroma_32x32_12_neon: 40.0
> vvc_alf_filter_chroma_64x64_8_c: 646.0
> vvc_alf_filter_chroma_64x64_8_neon: 175.5
> vvc_alf_filter_chroma_64x64_10_c: 708.2
> vvc_alf_filter_chroma_64x64_10_neon: 166.7
> vvc_alf_filter_chroma_64x64_12_c: 619.2
> vvc_alf_filter_chroma_64x64_12_neon: 157.2
> vvc_alf_filter_chroma_128x128_8_c: 2611.5
> vvc_alf_filter_chroma_128x128_8_neon: 698.2
> vvc_alf_filter_chroma_128x128_10_c: 2470.0
> vvc_alf_filter_chroma_128x128_10_neon: 616.0
> vvc_alf_filter_chroma_128x128_12_c: 2531.5
> vvc_alf_filter_chroma_128x128_12_neon: 620.2
> vvc_alf_filter_luma_8x8_8_c: 25.2
> vvc_alf_filter_luma_8x8_8_neon: 4.2
> vvc_alf_filter_luma_8x8_10_c: 18.5
> vvc_alf_filter_luma_8x8_10_neon: 4.0
> vvc_alf_filter_luma_8x8_12_c: 19.0
> vvc_alf_filter_luma_8x8_12_neon: 4.0
> vvc_alf_filter_luma_16x16_8_c: 106.5
> vvc_alf_filter_luma_16x16_8_neon: 16.2
> vvc_alf_filter_luma_16x16_10_c: 75.2
> vvc_alf_filter_luma_16x16_10_neon: 14.7
> vvc_alf_filter_luma_16x16_12_c: 79.7
> vvc_alf_filter_luma_16x16_12_neon: 14.7
> vvc_alf_filter_luma_32x32_8_c: 400.5
> vvc_alf_filter_luma_32x32_8_neon: 63.2
> vvc_alf_filter_luma_32x32_10_c: 299.2
> vvc_alf_filter_luma_32x32_10_neon: 57.7
> vvc_alf_filter_luma_32x32_12_c: 299.2
> vvc_alf_filter_luma_32x32_12_neon: 57.7
> vvc_alf_filter_luma_64x64_8_c: 1602.5
> vvc_alf_filter_luma_64x64_8_neon: 251.7
> vvc_alf_filter_luma_64x64_10_c: 1197.0
> vvc_alf_filter_luma_64x64_10_neon: 235.5
> vvc_alf_filter_luma_64x64_12_c: 1220.2
> vvc_alf_filter_luma_64x64_12_neon: 235.7
> vvc_alf_filter_luma_128x128_8_c: 6570.2
> vvc_alf_filter_luma_128x128_8_neon: 1007.7
> vvc_alf_filter_luma_128x128_10_c: 4822.7
> vvc_alf_filter_luma_128x128_10_neon: 936.2
> vvc_alf_filter_luma_128x128_12_c: 4791.2
> vvc_alf_filter_luma_128x128_12_neon: 938.5
>
> Signed-off-by: Zhao Zhili 
> ---
>  libavcodec/aarch64/vvc/Makefile   |   5 +
>  libavcodec/aarch64/vvc/alf.S  | 293 ++
>  libavcodec/aarch64/vvc/alf_template.c | 157 ++
>  libavcodec/aarch64/vvc/dsp_init.c |  57 +
>  libavcodec/vvc/dsp.c  |   4 +-
>  libavcodec/vvc/dsp.h  |   1 +
>  6 files changed, 516 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/aarch64/vvc/Makefile
>  create mode 100644 libavcodec/aarch64/vvc/alf.S
>  create mode 100644 libavcodec/aarch64/vvc/alf_template.c
>  create mode 100644 libavcodec/aarch64/vvc/dsp_init.c
>
> diff --git a/libavcodec/aarch64/vvc/Makefile
> b/libavcodec/aarch64/vvc/Makefile
> new file mode 100644
> index 00..58398d6e3d
> --- /dev/null
> +++ b/libavcodec/aarch64/vvc/Makefile
> @@ -0,0 +1,5 @@
> +clean::
> +   $(RM) $(CLEANSUFFIXES:%=libavcodec/aarch64/vvc/%)
> +
> +OBJS-$(CONFIG_VVC_DECODER) +=
> aarch64/vvc/dsp_init.o
> +NEON-OBJS-$(CONFIG_VVC_DECODER)+=
> aarch64/vvc/alf.o
> diff --git a/libavcodec/aarch64/vvc/alf.S b/libavcodec/aarch64/vvc/alf.S
> new file mode 100644
> index 00..beb36ac66b
> --- /dev/null
> +++ b/libavcodec/aarch64/vvc/alf.S
> @@ -0,0 +1,293 @@
> +/*
> + * Copyright (c) 2024 Zhao Zhili 
> + *
> + * 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
> + * 

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/vvc: Remove NOP condition check in alf_filter_luma

2024-07-16 Thread Nuo Mi
On Tue, Jul 16, 2024 at 10:50 AM Zhao Zhili  wrote:

> From: Zhao Zhili 
>
> If (y + i == vb_above) or (y + i == vb_below), the if body has no
> operation.
>
, How did you find this? From a compiler warning or by reading the code?


> ---
>  libavcodec/vvc/filter_template.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/vvc/filter_template.c
> b/libavcodec/vvc/filter_template.c
> index 9b3a0e46f7..32777452b7 100644
> --- a/libavcodec/vvc/filter_template.c
> +++ b/libavcodec/vvc/filter_template.c
> @@ -77,7 +77,7 @@ static void FUNC(alf_filter_luma)(uint8_t *_dst,
> ptrdiff_t dst_stride, const uin
>  const int is_near_vb_below = (y + i >= vb_pos) && (y + i
> <= vb_pos);
>  const int is_near_vb = is_near_vb_above ||
> is_near_vb_below;
>
> -if ((y + i < vb_pos) && ((y + i) >= vb_above)) {
> +if ((y + i < vb_pos) && ((y + i) > vb_above)) {
>  p1 = (y + i == vb_pos - 1) ? p0 : p1;
>  p3 = (y + i >= vb_pos - 2) ? p1 : p3;
>  p5 = (y + i >= vb_pos - 3) ? p3 : p5;
> @@ -85,7 +85,7 @@ static void FUNC(alf_filter_luma)(uint8_t *_dst,
> ptrdiff_t dst_stride, const uin
>  p2 = (y + i == vb_pos - 1) ? p0 : p2;
>  p4 = (y + i >= vb_pos - 2) ? p2 : p4;
>  p6 = (y + i >= vb_pos - 3) ? p4 : p6;
> -} else if ((y + i >= vb_pos) && ((y + i) <= vb_below)) {
> +} else if ((y + i >= vb_pos) && ((y + i) < vb_below)) {
>  p2 = (y + i == vb_pos) ? p0 : p2;
>  p4 = (y + i <= vb_pos + 1) ? p2 : p4;
>  p6 = (y + i <= vb_pos + 2) ? p4 : p6;
> --
> 2.42.0
>
> ___
> 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".
>
___
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 2/9] avcodec/vvc/ctu: Simplify code at the end of pred_mode_decode()

2024-07-12 Thread Nuo Mi
On Sun, May 19, 2024 at 10:49 AM Michael Niedermayer 
wrote:

> This simplification assumes that the code is correct
>
> Fixes: CID1560036 Logically dead code
>
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vvc/ctu.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/vvc/ctu.c b/libavcodec/vvc/ctu.c
> index 53f92ca10f7..7495ced0d5a 100644
> --- a/libavcodec/vvc/ctu.c
> +++ b/libavcodec/vvc/ctu.c
> @@ -1080,12 +1080,10 @@ static PredMode pred_mode_decode(VVCLocalContext
> *lc,
>  }
>  if (pred_mode_ibc_flag)
>  pred_mode = MODE_IBC;
> +return pred_mode;
>  } else {
> -pred_mode_flag = is_4x4 || mode_type == MODE_TYPE_INTRA ||
> -mode_type != MODE_TYPE_INTER || IS_I(rsh);
> -pred_mode = pred_mode_flag ? MODE_INTRA : MODE_INTER;
> +return MODE_INTRA;
>  }
> -return pred_mode;
>  }
>
LGTM.
We can also remove the else branch since the if branch returns.

>
>  static void sbt_info(VVCLocalContext *lc, const VVCSPS *sps)
> --
> 2.45.1
>
> ___
> 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".
>
___
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] avutil/executor: Fix missing check before using mutex

2024-07-11 Thread Nuo Mi
On Mon, Jul 1, 2024 at 10:13 PM Nuo Mi  wrote:

>
>
> On Mon, Jul 1, 2024 at 10:00 PM Zhao Zhili  wrote:
>
>>
>>
>> > On Jul 1, 2024, at 21:14, Nuo Mi  wrote:
>> >
>> > On Sun, Jun 30, 2024 at 6:45 PM Zhao Zhili 
>> wrote:
>> >
>> >> From: Zhao Zhili 
>> >>
>> >> ---
>> >> The code can be simplified by always creating mutex/cond. I'm not sure
>> >> it worth the overhead. Please note !HAVE_THREADS don't have the same
>> >> problem since it has mock implementation of ff_mutex_lock/unlock.
>> >>
>> > Hi Zhili,
>> > Thank you for the patch.
>> > Do we really need this? The lock/unlock/signal functions will return an
>> > error if the lock and condition variables are not initialized.
>>
>> We have strict check in libavutil/thread.h, e.g.,
>>
>> static inline int strict_pthread_mutex_lock(pthread_mutex_t *mutex)
>> {
>> ASSERT_PTHREAD(pthread_mutex_lock, mutex);
>> }
>>
>> The strict check is enabled when configure --assert-level=2.
>>
> LGTM.
> Thank you.
>
merged. thx.

>
>> >
>> >>
>> >> libavutil/executor.c | 9 ++---
>> >> 1 file changed, 6 insertions(+), 3 deletions(-)
>> >>
>> >> diff --git a/libavutil/executor.c b/libavutil/executor.c
>> >> index fb20104b58..89058fab2f 100644
>> >> --- a/libavutil/executor.c
>> >> +++ b/libavutil/executor.c
>> >> @@ -194,14 +194,17 @@ void av_executor_execute(AVExecutor *e, AVTask
>> *t)
>> >> AVTaskCallbacks *cb = >cb;
>> >> AVTask **prev;
>> >>
>> >> -ff_mutex_lock(>lock);
>> >> +if (e->thread_count)
>> >> +ff_mutex_lock(>lock);
>> >> if (t) {
>> >> for (prev = >tasks; *prev && cb->priority_higher(*prev, t);
>> >> prev = &(*prev)->next)
>> >> /* nothing */;
>> >> add_task(prev, t);
>> >> }
>> >> -ff_cond_signal(>cond);
>> >> -ff_mutex_unlock(>lock);
>> >> +if (e->thread_count) {
>> >> +ff_cond_signal(>cond);
>> >> +ff_mutex_unlock(>lock);
>> >> +}
>> >>
>> >> if (!e->thread_count || !HAVE_THREADS) {
>> >> // We are running in a single-threaded environment, so we must
>> >> handle all tasks ourselves
>> >> --
>> >> 2.42.0
>> >>
>> >> ___
>> >> 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".
>> >>
>> > ___
>> > 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".
>>
>> ___
>> 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".
>>
>
___
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 1/2] avcodec/vvc: Use static const for function table

2024-07-11 Thread Nuo Mi
applied, thx

On Mon, Jul 8, 2024 at 9:24 PM Nuo Mi  wrote:

> LGTM
> thank you, Zhili.
>
> On Mon, Jul 8, 2024 at 3:40 PM Zhao Zhili  wrote:
>
>> From: Zhao Zhili 
>>
>> ---
>>  libavcodec/vvc/thread.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c
>> index 0cacb1f51c..8dd9a36fd5 100644
>> --- a/libavcodec/vvc/thread.c
>> +++ b/libavcodec/vvc/thread.c
>> @@ -565,7 +565,7 @@ static void task_run_stage(VVCTask *t, VVCContext *s,
>> VVCLocalContext *lc)
>>  VVCFrameContext *fc  = t->fc;
>>  VVCFrameThread *ft   = fc->ft;
>>  const VVCTaskStage stage = t->stage;
>> -run_func run[] = {
>> +static const run_func run[] = {
>>  run_parse,
>>  run_inter,
>>  run_recon,
>> --
>> 2.42.0
>>
>> ___
>> 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".
>>
>
___
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 2/2] avutil/executor: Fix stack overflow due to recursive call

2024-07-11 Thread Nuo Mi
On Thu, Jul 11, 2024 at 8:21 PM Nuo Mi  wrote:

>
>
> On Wed, Jul 10, 2024 at 5:14 PM Anton Khirnov  wrote:
>
>> Quoting Nuo Mi (2024-07-09 13:36:09)
>> > On Tue, Jul 9, 2024 at 6:35 AM Timo Rothenpieler > >
>> > wrote:
>> >
>> > > On 08.07.2024 17:32, Zhao Zhili wrote:
>> > > >
>> > > >
>> > > >> On Jul 8, 2024, at 22:07, Timo Rothenpieler > >
>> > > wrote:
>> > > >>
>> > > >> On 08.07.2024 09:43, Zhao Zhili wrote:
>> > > >>> From: Zhao Zhili 
>> > > >>> av_executor_execute run the task directly when thread is disabled.
>> > > >>> The task can schedule a new task by call av_executor_execute. This
>> > > >>> forms an implicit recursive call. This patch removed the recursive
>> > > >>> call.
>> > > >>> ---
>> > > >>>   libavutil/executor.c | 5 +
>> > > >>>   1 file changed, 5 insertions(+)
>> > > >>> diff --git a/libavutil/executor.c b/libavutil/executor.c
>> > > >>> index 89058fab2f..c145c51be9 100644
>> > > >>> --- a/libavutil/executor.c
>> > > >>> +++ b/libavutil/executor.c
>> > > >>> @@ -58,6 +58,7 @@ struct AVExecutor {
>> > > >>>   int die;
>> > > >>> AVTask *tasks;
>> > > >>> +int stack_depth;
>> > > >>>   };
>> > > >>> static AVTask* remove_task(AVTask **prev, AVTask *t)
>> > > >>> @@ -207,8 +208,12 @@ void av_executor_execute(AVExecutor *e,
>> AVTask *t)
>> > > >>>   }
>> > > >>> if (!e->thread_count || !HAVE_THREADS) {
>> > > >>> +if (e->stack_depth > 0)
>> > > >>> +return;
>> > > >>> +e->stack_depth++;
>> > > >>>   // We are running in a single-threaded environment, so
>> we
>> > > must handle all tasks ourselves
>> > > >>>   while (run_one_task(e, e->local_contexts))
>> > > >>>   /* nothing */;
>> > > >>> +e->stack_depth--;
>> > > >>
>> > > >> Won't this put the above line into the "nothing" while-loop?
>> > > >> Is that intended? If so, the indentation should be adjusted
>> accordingly.
>> > > >> If not, the while-loop should gain empty {}.
>> > > >
>> > > > The comment specify it’s a while loop with empty body. Maybe it’s
>> not
>> > > obvious
>> > > > in the email client.
>> > >
>> > > Oh, there is a ; behind the comment.
>> > > Completely missed that. Can't say I like it, but yeah, that works.
>> > >
>> > Google suggests using "while (cond) continue;":
>> >
>> https://google.github.io/styleguide/cppguide.html#Formatting_Looping_Branching
>> > .
>> > However, it's not better than using /* nothing */.
>>
>> continue gets hilit by your editor.
>>
>> Also, I'd put it on a separate line for extra visibility.
>>
>> And bikesheds should be black with red stripes.
>>
> Editors will highlight the comment with green too, which will help protect
> our eyes.
>
Applied.
Thank you, for the patch and review.


>> --
>> Anton Khirnov
>> ___
>> 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".
>>
>
___
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 2/2] avutil/executor: Fix stack overflow due to recursive call

2024-07-11 Thread Nuo Mi
On Wed, Jul 10, 2024 at 5:14 PM Anton Khirnov  wrote:

> Quoting Nuo Mi (2024-07-09 13:36:09)
> > On Tue, Jul 9, 2024 at 6:35 AM Timo Rothenpieler 
> > wrote:
> >
> > > On 08.07.2024 17:32, Zhao Zhili wrote:
> > > >
> > > >
> > > >> On Jul 8, 2024, at 22:07, Timo Rothenpieler 
> > > wrote:
> > > >>
> > > >> On 08.07.2024 09:43, Zhao Zhili wrote:
> > > >>> From: Zhao Zhili 
> > > >>> av_executor_execute run the task directly when thread is disabled.
> > > >>> The task can schedule a new task by call av_executor_execute. This
> > > >>> forms an implicit recursive call. This patch removed the recursive
> > > >>> call.
> > > >>> ---
> > > >>>   libavutil/executor.c | 5 +
> > > >>>   1 file changed, 5 insertions(+)
> > > >>> diff --git a/libavutil/executor.c b/libavutil/executor.c
> > > >>> index 89058fab2f..c145c51be9 100644
> > > >>> --- a/libavutil/executor.c
> > > >>> +++ b/libavutil/executor.c
> > > >>> @@ -58,6 +58,7 @@ struct AVExecutor {
> > > >>>   int die;
> > > >>> AVTask *tasks;
> > > >>> +int stack_depth;
> > > >>>   };
> > > >>> static AVTask* remove_task(AVTask **prev, AVTask *t)
> > > >>> @@ -207,8 +208,12 @@ void av_executor_execute(AVExecutor *e,
> AVTask *t)
> > > >>>   }
> > > >>> if (!e->thread_count || !HAVE_THREADS) {
> > > >>> +if (e->stack_depth > 0)
> > > >>> +return;
> > > >>> +e->stack_depth++;
> > > >>>   // We are running in a single-threaded environment, so we
> > > must handle all tasks ourselves
> > > >>>   while (run_one_task(e, e->local_contexts))
> > > >>>   /* nothing */;
> > > >>> +e->stack_depth--;
> > > >>
> > > >> Won't this put the above line into the "nothing" while-loop?
> > > >> Is that intended? If so, the indentation should be adjusted
> accordingly.
> > > >> If not, the while-loop should gain empty {}.
> > > >
> > > > The comment specify it’s a while loop with empty body. Maybe it’s not
> > > obvious
> > > > in the email client.
> > >
> > > Oh, there is a ; behind the comment.
> > > Completely missed that. Can't say I like it, but yeah, that works.
> > >
> > Google suggests using "while (cond) continue;":
> >
> https://google.github.io/styleguide/cppguide.html#Formatting_Looping_Branching
> > .
> > However, it's not better than using /* nothing */.
>
> continue gets hilit by your editor.
>
> Also, I'd put it on a separate line for extra visibility.
>
> And bikesheds should be black with red stripes.
>
Editors will highlight the comment with green too, which will help protect
our eyes.

>
> --
> Anton Khirnov
> ___
> 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".
>
___
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 2/2] avutil/executor: Fix stack overflow due to recursive call

2024-07-09 Thread Nuo Mi
On Tue, Jul 9, 2024 at 6:35 AM Timo Rothenpieler 
wrote:

> On 08.07.2024 17:32, Zhao Zhili wrote:
> >
> >
> >> On Jul 8, 2024, at 22:07, Timo Rothenpieler 
> wrote:
> >>
> >> On 08.07.2024 09:43, Zhao Zhili wrote:
> >>> From: Zhao Zhili 
> >>> av_executor_execute run the task directly when thread is disabled.
> >>> The task can schedule a new task by call av_executor_execute. This
> >>> forms an implicit recursive call. This patch removed the recursive
> >>> call.
> >>> ---
> >>>   libavutil/executor.c | 5 +
> >>>   1 file changed, 5 insertions(+)
> >>> diff --git a/libavutil/executor.c b/libavutil/executor.c
> >>> index 89058fab2f..c145c51be9 100644
> >>> --- a/libavutil/executor.c
> >>> +++ b/libavutil/executor.c
> >>> @@ -58,6 +58,7 @@ struct AVExecutor {
> >>>   int die;
> >>> AVTask *tasks;
> >>> +int stack_depth;
> >>>   };
> >>> static AVTask* remove_task(AVTask **prev, AVTask *t)
> >>> @@ -207,8 +208,12 @@ void av_executor_execute(AVExecutor *e, AVTask *t)
> >>>   }
> >>> if (!e->thread_count || !HAVE_THREADS) {
> >>> +if (e->stack_depth > 0)
> >>> +return;
> >>> +e->stack_depth++;
> >>>   // We are running in a single-threaded environment, so we
> must handle all tasks ourselves
> >>>   while (run_one_task(e, e->local_contexts))
> >>>   /* nothing */;
> >>> +e->stack_depth--;
> >>
> >> Won't this put the above line into the "nothing" while-loop?
> >> Is that intended? If so, the indentation should be adjusted accordingly.
> >> If not, the while-loop should gain empty {}.
> >
> > The comment specify it’s a while loop with empty body. Maybe it’s not
> obvious
> > in the email client.
>
> Oh, there is a ; behind the comment.
> Completely missed that. Can't say I like it, but yeah, that works.
>
Google suggests using "while (cond) continue;":
https://google.github.io/styleguide/cppguide.html#Formatting_Looping_Branching
.
However, it's not better than using /* nothing */.

> ___
> 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".
>
___
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 3/6] avcodec/vvc/refs: Use unsigned mask

2024-07-08 Thread Nuo Mi
LGTM.
Thank you, Michael,


On Mon, Jul 8, 2024 at 2:48 AM Michael Niedermayer 
wrote:

> Not a bugfix, but might fix CID1604361 Overflowed constant
>
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vvc/refs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
> index 26a5b0b34cc..c1fc6132c2e 100644
> --- a/libavcodec/vvc/refs.c
> +++ b/libavcodec/vvc/refs.c
> @@ -310,7 +310,7 @@ void ff_vvc_bump_frame(VVCContext *s, VVCFrameContext
> *fc)
>
>  static VVCFrame *find_ref_idx(VVCContext *s, VVCFrameContext *fc, int
> poc, uint8_t use_msb)
>  {
> -const int mask = use_msb ? ~0 : fc->ps.sps->max_pic_order_cnt_lsb - 1;
> +const unsigned mask = use_msb ? ~0 :
> fc->ps.sps->max_pic_order_cnt_lsb - 1;
>
>  for (int i = 0; i < FF_ARRAY_ELEMS(fc->DPB); i++) {
>  VVCFrame *ref = >DPB[i];
> --
> 2.45.2
>
> ___
> 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".
>
___
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 1/2] avcodec/vvc: Use static const for function table

2024-07-08 Thread Nuo Mi
LGTM
thank you, Zhili.

On Mon, Jul 8, 2024 at 3:40 PM Zhao Zhili  wrote:

> From: Zhao Zhili 
>
> ---
>  libavcodec/vvc/thread.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c
> index 0cacb1f51c..8dd9a36fd5 100644
> --- a/libavcodec/vvc/thread.c
> +++ b/libavcodec/vvc/thread.c
> @@ -565,7 +565,7 @@ static void task_run_stage(VVCTask *t, VVCContext *s,
> VVCLocalContext *lc)
>  VVCFrameContext *fc  = t->fc;
>  VVCFrameThread *ft   = fc->ft;
>  const VVCTaskStage stage = t->stage;
> -run_func run[] = {
> +static const run_func run[] = {
>  run_parse,
>  run_inter,
>  run_recon,
> --
> 2.42.0
>
> ___
> 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".
>
___
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 v2 2/2] avutil/executor: Fix stack overflow due to recursive call

2024-07-08 Thread Nuo Mi
On Mon, Jul 8, 2024 at 8:14 PM Zhao Zhili  wrote:

> From: Zhao Zhili 
>
> av_executor_execute run the task directly when thread is disabled.
> The task can schedule a new task by call av_executor_execute. This
> forms an implicit recursive call. This patch removed the recursive
> call.
>
Thank you, Zhili.
LGTM
Using bool is a good idea.
We could also use bool for has_lock, has_cond, and die.


> ---
> v2: use bool type
>
>  libavutil/executor.c | 7 +++
>  1 file changed, 7 insertions(+)
>
> diff --git a/libavutil/executor.c b/libavutil/executor.c
> index 89058fab2f..bfce2ac444 100644
> --- a/libavutil/executor.c
> +++ b/libavutil/executor.c
> @@ -20,6 +20,8 @@
>
>  #include "config.h"
>
> +#include 
> +
>  #include "mem.h"
>  #include "thread.h"
>
> @@ -49,6 +51,7 @@ typedef struct ThreadInfo {
>  struct AVExecutor {
>  AVTaskCallbacks cb;
>  int thread_count;
> +bool recursive;
>
>  ThreadInfo *threads;
>  uint8_t *local_contexts;
> @@ -207,8 +210,12 @@ void av_executor_execute(AVExecutor *e, AVTask *t)
>  }
>
>  if (!e->thread_count || !HAVE_THREADS) {
> +if (e->recursive)
> +return;
> +e->recursive = true;
>  // We are running in a single-threaded environment, so we must
> handle all tasks ourselves
>  while (run_one_task(e, e->local_contexts))
>  /* nothing */;
> +e->recursive = false;
>  }
>  }
> --
> 2.42.0
>
> ___
> 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".
>
___
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 4/9] avcodec/vvc/ctu: Remove dead ret check

2024-07-03 Thread Nuo Mi
On Wed, Jul 3, 2024 at 2:44 AM Michael Niedermayer 
wrote:

> On Sun, May 19, 2024 at 04:49:10AM +0200, Michael Niedermayer wrote:
> > Fixes: CID1560040 Logically dead code
> >
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/vvc/ctu.c | 2 --
> >  1 file changed, 2 deletions(-)
>
> will apply
>
+1, thx

>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Breaking DRM is a little like attempting to break through a door even
> though the window is wide open and the only thing in the house is a bunch
> of things you dont want and which you would get tomorrow for free anyway
> ___
> 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".
>
___
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 5/9] avcodec/vvc/dec: Remove constant eos_at_start

2024-07-03 Thread Nuo Mi
On Wed, Jul 3, 2024 at 2:44 AM Michael Niedermayer 
wrote:

> On Sun, May 19, 2024 at 04:49:11AM +0200, Michael Niedermayer wrote:
> > Fixes: CID1560041 'Constant' variable guards dead code
> >
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/vvc/dec.c | 6 +-
> >  1 file changed, 1 insertion(+), 5 deletions(-)
>
> will apply
>
+1, thx

>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> It is what and why we do it that matters, not just one of them.
> ___
> 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".
>
___
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] avutil/executor: Fix missing check before using mutex

2024-07-01 Thread Nuo Mi
On Mon, Jul 1, 2024 at 10:00 PM Zhao Zhili  wrote:

>
>
> > On Jul 1, 2024, at 21:14, Nuo Mi  wrote:
> >
> > On Sun, Jun 30, 2024 at 6:45 PM Zhao Zhili 
> wrote:
> >
> >> From: Zhao Zhili 
> >>
> >> ---
> >> The code can be simplified by always creating mutex/cond. I'm not sure
> >> it worth the overhead. Please note !HAVE_THREADS don't have the same
> >> problem since it has mock implementation of ff_mutex_lock/unlock.
> >>
> > Hi Zhili,
> > Thank you for the patch.
> > Do we really need this? The lock/unlock/signal functions will return an
> > error if the lock and condition variables are not initialized.
>
> We have strict check in libavutil/thread.h, e.g.,
>
> static inline int strict_pthread_mutex_lock(pthread_mutex_t *mutex)
> {
> ASSERT_PTHREAD(pthread_mutex_lock, mutex);
> }
>
> The strict check is enabled when configure --assert-level=2.
>
LGTM.
Thank you.

>
> >
> >>
> >> libavutil/executor.c | 9 ++---
> >> 1 file changed, 6 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/libavutil/executor.c b/libavutil/executor.c
> >> index fb20104b58..89058fab2f 100644
> >> --- a/libavutil/executor.c
> >> +++ b/libavutil/executor.c
> >> @@ -194,14 +194,17 @@ void av_executor_execute(AVExecutor *e, AVTask *t)
> >> AVTaskCallbacks *cb = >cb;
> >> AVTask **prev;
> >>
> >> -ff_mutex_lock(>lock);
> >> +if (e->thread_count)
> >> +ff_mutex_lock(>lock);
> >> if (t) {
> >> for (prev = >tasks; *prev && cb->priority_higher(*prev, t);
> >> prev = &(*prev)->next)
> >> /* nothing */;
> >> add_task(prev, t);
> >> }
> >> -ff_cond_signal(>cond);
> >> -ff_mutex_unlock(>lock);
> >> +if (e->thread_count) {
> >> +ff_cond_signal(>cond);
> >> +ff_mutex_unlock(>lock);
> >> +}
> >>
> >> if (!e->thread_count || !HAVE_THREADS) {
> >> // We are running in a single-threaded environment, so we must
> >> handle all tasks ourselves
> >> --
> >> 2.42.0
> >>
> >> ___
> >> 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".
> >>
> > ___
> > 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".
>
> ___
> 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".
>
___
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] avutil/executor: Fix missing check before using mutex

2024-07-01 Thread Nuo Mi
On Sun, Jun 30, 2024 at 6:45 PM Zhao Zhili  wrote:

> From: Zhao Zhili 
>
> ---
> The code can be simplified by always creating mutex/cond. I'm not sure
> it worth the overhead. Please note !HAVE_THREADS don't have the same
> problem since it has mock implementation of ff_mutex_lock/unlock.
>
Hi Zhili,
Thank you for the patch.
Do we really need this? The lock/unlock/signal functions will return an
error if the lock and condition variables are not initialized.

>
>  libavutil/executor.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/libavutil/executor.c b/libavutil/executor.c
> index fb20104b58..89058fab2f 100644
> --- a/libavutil/executor.c
> +++ b/libavutil/executor.c
> @@ -194,14 +194,17 @@ void av_executor_execute(AVExecutor *e, AVTask *t)
>  AVTaskCallbacks *cb = >cb;
>  AVTask **prev;
>
> -ff_mutex_lock(>lock);
> +if (e->thread_count)
> +ff_mutex_lock(>lock);
>  if (t) {
>  for (prev = >tasks; *prev && cb->priority_higher(*prev, t);
> prev = &(*prev)->next)
>  /* nothing */;
>  add_task(prev, t);
>  }
> -ff_cond_signal(>cond);
> -ff_mutex_unlock(>lock);
> +if (e->thread_count) {
> +ff_cond_signal(>cond);
> +ff_mutex_unlock(>lock);
> +}
>
>  if (!e->thread_count || !HAVE_THREADS) {
>  // We are running in a single-threaded environment, so we must
> handle all tasks ourselves
> --
> 2.42.0
>
> ___
> 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".
>
___
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 02/11] avcodec/vvc/dec: Check ff_init_cabac_decoder() for failure

2024-07-01 Thread Nuo Mi
On Mon, Jul 1, 2024 at 7:13 AM Michael Niedermayer 
wrote:

> Fixes: signed integer overflow: 1107820800 + 1107820800 cannot be
> represented in type 'int'
> Fixes: left shift of 1091059712 by 6 places cannot be represented in type
> 'int'
> Fixes:
> 69910/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-5162839971528704
>
LGTM

>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by
> :
> Michael Niedermayer 
> ---
>  libavcodec/vvc/dec.c | 12 +---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
> index a6b601b778c..563f6fcf082 100644
> --- a/libavcodec/vvc/dec.c
> +++ b/libavcodec/vvc/dec.c
> @@ -476,13 +476,14 @@ static int slices_realloc(VVCFrameContext *fc)
>  return 0;
>  }
>
> -static void ep_init_cabac_decoder(SliceContext *sc, const int index,
> +static int ep_init_cabac_decoder(SliceContext *sc, const int index,
>  const H2645NAL *nal, GetBitContext *gb, const CodedBitstreamUnit
> *unit)
>  {
>  const H266RawSlice *slice = unit->content_ref;
>  const H266RawSliceHeader *rsh = sc->sh.r;
>  EntryPoint *ep= sc->eps + index;
>  int size;
> +int ret;
>
>  if (index < rsh->num_entry_points) {
>  int skipped = 0;
> @@ -501,8 +502,11 @@ static void ep_init_cabac_decoder(SliceContext *sc,
> const int index,
>  size = get_bits_left(gb) / 8;
>  }
>  av_assert0(gb->buffer + get_bits_count(gb) / 8 + size <=
> gb->buffer_end);
> -ff_init_cabac_decoder (>cc, gb->buffer + get_bits_count(gb) / 8,
> size);
> +ret = ff_init_cabac_decoder (>cc, gb->buffer + get_bits_count(gb)
> / 8, size);
> +if (ret < 0)
> +return ret;
>  skip_bits(gb, size * 8);
> +return 0;
>  }
>
>  static int slice_init_entry_points(SliceContext *sc,
> @@ -538,7 +542,9 @@ static int slice_init_entry_points(SliceContext *sc,
>  fc->tab.slice_idx[rs] = sc->slice_idx;
>  }
>
> -ep_init_cabac_decoder(sc, i, nal, , unit);
> +ret = ep_init_cabac_decoder(sc, i, nal, , unit);
> +if (ret < 0)
> +return ret;
>
>  if (i + 1 < sc->nb_eps)
>  ctu_addr = sh->entry_point_start_ctu[i];
> --
> 2.45.2
>
> ___
> 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".
>
___
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 v2] lavc/vvc: Always set flags for the current picture

2024-06-28 Thread Nuo Mi
Applied,
Thank you, Frank,

On Fri, Jun 28, 2024 at 1:53 AM Frank Plowman  wrote:

> ff_vvc_frame_rpl uses the flags to detect whether a frame is in use.
> Therefore, in the case of a CVSS AU (RASL/GDR with
> NoOutputBeforeRecoveryFlag) with ph_non_ref_pic_flag = 1, the frame
> would be freed before it is used.  Fix this by always marking the
> current frame with VVC_FRAME_FLAG_SHORT_REF, as is done by the HEVC
> decoder.
>
> Signed-off-by: Frank Plowman 
> ---
>  libavcodec/vvc/refs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
> index 8b7ba639a3..26a5b0b34c 100644
> --- a/libavcodec/vvc/refs.c
> +++ b/libavcodec/vvc/refs.c
> @@ -191,7 +191,7 @@ int ff_vvc_set_new_ref(VVCContext *s, VVCFrameContext
> *fc, AVFrame **frame)
>  fc->ref = ref;
>
>  if (s->no_output_before_recovery_flag && (IS_RASL(s) ||
> !GDR_IS_RECOVERED(s)))
> -ref->flags = 0;
> +ref->flags = VVC_FRAME_FLAG_SHORT_REF;
>  else if (ph->r->ph_pic_output_flag)
>  ref->flags = VVC_FRAME_FLAG_OUTPUT;
>
> --
> 2.45.1
>
> ___
> 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".
>
___
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 1/2] avutil/executor: Allowing thread_count be zero

2024-06-27 Thread Nuo Mi
On Tue, Jun 25, 2024 at 8:36 PM Nuo Mi  wrote:

>
>
> On Mon, Jun 24, 2024 at 12:48 PM Zhao Zhili 
> wrote:
>
>> From: Zhao Zhili 
>>
>> Before the patch, disable threads support at configure/build time
>> was the only method to force zero thread in executor. However,
>> it's common practice for libavcodec to run on caller's thread when
>> user specify thread number to one. And for WASM environment, whether
>> threads are supported needs to be detected at runtime. So executor
>> should support zero thread at runtime.
>>
>> A single thread executor can be useful, e.g., to handle network
>> protocol. So we can't take thread_count one as zero thread, which
>> disabled a valid usercase.
>>
>> Other libraries take -threads 0 to mean auto. Executor as a low
>> level utils doesn't do cpu detect. So take thread_count zero as
>> zero thread, literally.
>>
>> Signed-off-by: Zhao Zhili 
>>
> Hi Zhili,
> Thank you for the v2
> I will merge it in 3 days if there are no objections.
>
Applied

>
>
___
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] lavc/vvc: Always set flags for the current picture

2024-06-27 Thread Nuo Mi
On Mon, Jun 24, 2024 at 11:30 PM Frank Plowman 
wrote:

> ff_vvc_frame_rpl uses the flags to detect whether a frame is in use.
> Therefore, in the case of a CVSS AU (RASL/GDR with
> NoOutputBeforeRecoveryFlag) with ph_non_ref_pic_flag = 1, the frame
> would be freed before it is used.  Fix this by always marking the
> current frame with VVC_FRAME_FLAG_SHORT_REF, as is done by the HEVC
> decoder.
>
> Additionally, add an assert0 to mitigate the effects of a frame being
> freed before it is used.
>
> Signed-off-by: Frank Plowman 
> ---
>  libavcodec/vvc/refs.c   | 2 +-
>  libavcodec/vvc/thread.c | 2 ++
>  2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
> index 8b7ba639a3..26a5b0b34c 100644
> --- a/libavcodec/vvc/refs.c
> +++ b/libavcodec/vvc/refs.c
> @@ -191,7 +191,7 @@ int ff_vvc_set_new_ref(VVCContext *s, VVCFrameContext
> *fc, AVFrame **frame)
>  fc->ref = ref;
>
>  if (s->no_output_before_recovery_flag && (IS_RASL(s) ||
> !GDR_IS_RECOVERED(s)))
> -ref->flags = 0;
> +ref->flags = VVC_FRAME_FLAG_SHORT_REF;
>  else if (ph->r->ph_pic_output_flag)
>  ref->flags = VVC_FRAME_FLAG_OUTPUT;
>
> diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c
> index 5b01dd2d20..e87ed5b676 100644
> --- a/libavcodec/vvc/thread.c
> +++ b/libavcodec/vvc/thread.c
> @@ -801,6 +801,8 @@ int ff_vvc_frame_wait(VVCContext *s, VVCFrameContext
> *fc)
>  {
>  VVCFrameThread *ft = fc->ft;
>
> +av_assert0(fc->ref->progress);
> +
>
Hi Frank,
Thank you for the patch.

We have a mission to remove all assert0s in the decoder, right? :)
If it's only for debugging, maybe we don't need it.

>  ff_mutex_lock(>lock);
>
>  while (atomic_load(>nb_scheduled_tasks) ||
> atomic_load(>nb_scheduled_listeners))
> --
> 2.45.1
>
> ___
> 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".
>
___
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] lavc/vvc: Don't discard return codes

2024-06-27 Thread Nuo Mi
Merged.

On Wed, Jun 26, 2024 at 1:06 AM Frank Plowman  wrote:

> Signed-off-by: Frank Plowman 
> ---
>  libavcodec/vvc/thread.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c
> index c90c316661..118d56b67e 100644
> --- a/libavcodec/vvc/thread.c
> +++ b/libavcodec/vvc/thread.c
> @@ -443,8 +443,11 @@ static int run_inter(VVCContext *s, VVCLocalContext
> *lc, VVCTask *t)
>  {
>  VVCFrameContext *fc = lc->fc;
>  const CTU *ctu  = fc->tab.ctus + t->rs;
> +int ret;
>
> -ff_vvc_predict_inter(lc, t->rs);
> +ret = ff_vvc_predict_inter(lc, t->rs);
> +if (ret < 0)
> +return ret;
>
>  if (ctu->has_dmvr)
>  report_frame_progress(fc, t->ry, VVC_PROGRESS_MV);
> @@ -454,9 +457,7 @@ static int run_inter(VVCContext *s, VVCLocalContext
> *lc, VVCTask *t)
>
>  static int run_recon(VVCContext *s, VVCLocalContext *lc, VVCTask *t)
>  {
> -ff_vvc_reconstruct(lc, t->rs, t->rx, t->ry);
> -
> -return 0;
> +return ff_vvc_reconstruct(lc, t->rs, t->rx, t->ry);
>  }
>
>  static int run_lmcs(VVCContext *s, VVCLocalContext *lc, VVCTask *t)
> --
> 2.45.1
>
> ___
> 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".
>
___
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 v2] lavc/vvc: Validate IBC block vector

2024-06-27 Thread Nuo Mi
On Wed, Jun 26, 2024 at 1:04 AM Frank Plowman  wrote:

> From H.266 (V3) (09/2023) p. 321:
>
> It is a requirement of bitstream conformance that the luma block
> vector bvL shall obey the following constraints:
> - CtbSizeY is greater than or equal to
> ((yCb + (bvL[ 1 ] >> 4)) & (CtbSizeY − 1)) + cbHeight
>
> This patch checks this is true, which fixes crashes on fuzzed
> bitstreams.
>
Thank you, Frank,
Applied.

>
> Signed-off-by: Frank Plowman 
> ---
> Changes since v1:
> * Perform this check when the IBC block vectors are derived, rather than
>   when they are first used.
>
>  libavcodec/vvc/ctu.c | 19 +++
>  libavcodec/vvc/mvs.c | 21 +++--
>  libavcodec/vvc/mvs.h |  4 ++--
>  3 files changed, 36 insertions(+), 8 deletions(-)
>
> diff --git a/libavcodec/vvc/ctu.c b/libavcodec/vvc/ctu.c
> index 752a06e2f5..1a4ceafc25 100644
> --- a/libavcodec/vvc/ctu.c
> +++ b/libavcodec/vvc/ctu.c
> @@ -1444,20 +1444,25 @@ static void merge_data_block(VVCLocalContext *lc)
>  }
>  }
>
> -static void merge_data_ibc(VVCLocalContext *lc)
> +static int merge_data_ibc(VVCLocalContext *lc)
>  {
>  const VVCFrameContext* fc = lc->fc;
>  const VVCSPS* sps = fc->ps.sps;
>  MotionInfo *mi= >cu->pu.mi;
>  int merge_idx = 0;
> +int ret;
>
>  mi->pred_flag = PF_IBC;
>
>  if (sps->max_num_ibc_merge_cand > 1)
>  merge_idx = ff_vvc_merge_idx(lc);
>
> -ff_vvc_luma_mv_merge_ibc(lc, merge_idx, >mv[L0][0]);
> +ret = ff_vvc_luma_mv_merge_ibc(lc, merge_idx, >mv[L0][0]);
> +if (ret)
> +return ret;
>  ff_vvc_store_mv(lc, mi);
> +
> +return 0;
>  }
>
>  static int hls_merge_data(VVCLocalContext *lc)
> @@ -1466,11 +1471,14 @@ static int hls_merge_data(VVCLocalContext *lc)
>  const VVCPH  *ph= >ps.ph;
>  const CodingUnit *cu= lc->cu;
>  PredictionUnit *pu  = >cu->pu;
> +int ret;
>
>  pu->merge_gpm_flag = 0;
>  pu->mi.num_sb_x = pu->mi.num_sb_y = 1;
>  if (cu->pred_mode == MODE_IBC) {
> -merge_data_ibc(lc);
> +ret = merge_data_ibc(lc);
> +if (ret)
> +return ret;
>  } else {
>  if (ph->max_num_subblock_merge_cand > 0 && cu->cb_width >= 8 &&
> cu->cb_height >= 8)
>  pu->merge_subblock_flag = ff_vvc_merge_subblock_flag(lc);
> @@ -1596,6 +1604,7 @@ static int mvp_data_ibc(VVCLocalContext *lc)
>  int mvp_l0_flag   = 0;
>  int amvr_shift= 4;
>  Mv *mv= >mv[L0][0];
> +int ret;
>
>  mi->pred_flag = PF_IBC;
>  mi->num_sb_x  = 1;
> @@ -1607,7 +1616,9 @@ static int mvp_data_ibc(VVCLocalContext *lc)
>  if (sps->r->sps_amvr_enabled_flag && (mv->x || mv->y))
>  amvr_shift = ff_vvc_amvr_shift(lc, pu->inter_affine_flag,
> cu->pred_mode, 1);
>
> -ff_vvc_mvp_ibc(lc, mvp_l0_flag, amvr_shift, mv);
> +ret = ff_vvc_mvp_ibc(lc, mvp_l0_flag, amvr_shift, mv);
> +if (ret)
> +return ret;
>  ff_vvc_store_mv(lc, mi);
>
>  return 0;
> diff --git a/libavcodec/vvc/mvs.c b/libavcodec/vvc/mvs.c
> index 42564b3e6f..1788a7150b 100644
> --- a/libavcodec/vvc/mvs.c
> +++ b/libavcodec/vvc/mvs.c
> @@ -1695,17 +1695,34 @@ static void ibc_merge_candidates(VVCLocalContext
> *lc, const int merge_idx, Mv *m
>  memset(mv, 0, sizeof(*mv));
>  }
>
> -void ff_vvc_mvp_ibc(VVCLocalContext *lc, const int mvp_l0_flag, const int
> amvr_shift, Mv *mv)
> +static int ibc_check_mv(VVCLocalContext *lc, Mv *mv)
> +{
> +const VVCFrameContext *fc = lc->fc;
> +const VVCSPS *sps = lc->fc->ps.sps;
> +const CodingUnit *cu  = lc->cu;
> +const Mv *bv  = >pu.mi.mv[L0][0];
> +
> +if (sps->ctb_size_y < ((cu->y0 + (bv->y >> 4)) & (sps->ctb_size_y -
> 1)) + cu->cb_height) {
> +av_log(fc->log_ctx, AV_LOG_ERROR, "IBC region spans multiple
> CTBs.\n");
> +return AVERROR_INVALIDDATA;
> +}
> +
> +return 0;
> +}
> +
> +int ff_vvc_mvp_ibc(VVCLocalContext *lc, const int mvp_l0_flag, const int
> amvr_shift, Mv *mv)
>  {
>  LOCAL_ALIGNED_8(Mv, mvp, [1]);
>
>  ibc_merge_candidates(lc, mvp_l0_flag, mvp);
>  ibc_add_mvp(mv, mvp, amvr_shift);
> +return ibc_check_mv(lc, mv);
>  }
>
> -void ff_vvc_luma_mv_merge_ibc(VVCLocalContext *lc, const int merge_idx,
> Mv *mv)
> +int ff_vvc_luma_mv_merge_ibc(VVCLocalContext *lc, const int merge_idx, Mv
> *mv)
>  {
>  ibc_merge_candidates(lc, merge_idx, mv);
> +return ibc_check_mv(lc, mv);
>  }
>
>  static int affine_mvp_constructed_cp(NeighbourContext *ctx,
> diff --git a/libavcodec/vvc/mvs.h b/libavcodec/vvc/mvs.h
> index 3f0c8b08e9..b2242b2a4d 100644
> --- a/libavcodec/vvc/mvs.h
> +++ b/libavcodec/vvc/mvs.h
> @@ -30,9 +30,9 @@ void ff_vvc_clip_mv(Mv *mv);
>  void ff_vvc_mv_scale(Mv *dst, const Mv *src, int td, int tb);
>  void ff_vvc_luma_mv_merge_mode(VVCLocalContext *lc, int merge_idx, int
> ciip_flag, MvField *mv);
>  void 

Re: [FFmpeg-devel] [PATCH 18/18] avcodec/vvcdec: alf, support virtual boundaries

2024-06-25 Thread Nuo Mi
On Tue, Jun 25, 2024 at 8:48 PM James Almer  wrote:

> On 6/25/2024 8:53 AM, Nuo Mi wrote:
> > On Sat, Jun 22, 2024 at 2:24 PM Nuo Mi  wrote:
> >
> >> see https://ieeexplore.ieee.org/stamp/stamp.jsp?tp==9503377
> >>
> >> passed files:
> >>  GDR_A_ERICSSON_2.bit
> >>  GDR_B_NOKIA_2.bit
> >>  GDR_C_NOKIA_2.bit
> >>  VIRTUAL_A_MediaTek_3.bit
> >>  VIRTUAL_B_MediaTek_3.bit
> >>
> >
> > Applied.
> > thank you
>
> Can you add a test for this? Just one of those samples (the that covers
> the most decoder logic).
> And in general, try to add tests for at least one of the samples that
> exercise new feature support you add.
>
Hi James,
Thank you for the reminder.
Yes, we will do that. Once it is merged, it will trigger some gcov tests on
Frank's machine.
He will help select some clips to get the largest coverage and send a FATE
test like before.

BTW: We have a ci to cover conformance and fuzz test at
https://github.com/ffvvc/FFmpeg/actions/runs/9626631693/job/26559410841?pr=235#step:10:665

Thank you

___
> 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".
>
___
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] lavc/vvc: Validate IBC block vector

2024-06-25 Thread Nuo Mi
On Mon, Jun 24, 2024 at 9:31 PM Frank Plowman  wrote:

> From H.266 (V3) (09/2023) p. 321:
>
> It is a requirement of bitstream conformance that the luma block
> vector bvL shall obey the following constraints:
> - CtbSizeY is greater than or equal to
> ((yCb + (bvL[ 1 ] >> 4)) & (CtbSizeY − 1)) + cbHeight
>
> This patch checks this is true, which fixes crashes on fuzzed
> bitstreams.
>
> Signed-off-by: Frank Plowman 
> ---
>  libavcodec/vvc/intra.c  | 25 ++---
>  libavcodec/vvc/thread.c |  4 +---
>  2 files changed, 23 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/vvc/intra.c b/libavcodec/vvc/intra.c
> index f77a012f09..11371db797 100644
> --- a/libavcodec/vvc/intra.c
> +++ b/libavcodec/vvc/intra.c
> @@ -624,15 +624,26 @@ static void intra_block_copy(const VVCLocalContext
> *lc, const int c_idx)
>  }
>  }
>
> -static void vvc_predict_ibc(const VVCLocalContext *lc)
> +static int vvc_predict_ibc(const VVCLocalContext *lc)
>  {
> -const H266RawSPS *rsps = lc->fc->ps.sps->r;
> +const VVCFrameContext *fc = lc->fc;
> +const VVCSPS *sps = lc->fc->ps.sps;
> +const H266RawSPS *rsps= sps->r;
> +const CodingUnit *cu  = lc->cu;
> +const Mv *bv  = >pu.mi.mv[L0][0];
> +
> +if (sps->ctb_size_y < ((cu->y0 + (bv->y >> 4)) & (sps->ctb_size_y -
> 1)) + cu->cb_height) {
> +av_log(fc->log_ctx, AV_LOG_ERROR, "IBC region spans multiple
> CTBs.\n");
> +return AVERROR_INVALIDDATA;
> +}

Hi Frank,
Thank you for the patch.
Could we wrap it as a function and call it in ff_vvc_mvp_ibc and
ff_vvc_luma_mv_merge_ibc?
This will help us detect errors earlier.

>


>  intra_block_copy(lc, LUMA);
>  if (lc->cu->tree_type == SINGLE_TREE && rsps->sps_chroma_format_idc) {
>  intra_block_copy(lc, CB);
>  intra_block_copy(lc, CR);
>  }
> +
> +return 0;
>  }
>
>  static void ibc_fill_vir_buf(const VVCLocalContext *lc, const CodingUnit
> *cu)
> @@ -678,7 +689,10 @@ int ff_vvc_reconstruct(VVCLocalContext *lc, const int
> rs, const int rx, const in
>  if (cu->ciip_flag)
>  ff_vvc_predict_ciip(lc);
>  else if (cu->pred_mode == MODE_IBC)
> -vvc_predict_ibc(lc);
> +ret = vvc_predict_ibc(lc);
> +if (ret)
> +goto fail;
> +
>  if (cu->coded_flag) {
>  ret = reconstruct(lc);
>  } else {
> @@ -687,10 +701,15 @@ int ff_vvc_reconstruct(VVCLocalContext *lc, const
> int rs, const int rx, const in
>  if (sps->r->sps_chroma_format_idc && cu->tree_type !=
> DUAL_TREE_LUMA)
>  add_reconstructed_area(lc, CHROMA, cu->x0, cu->y0,
> cu->cb_width, cu->cb_height);
>  }
> +if (ret)
> +goto fail;
> +
>  if (sps->r->sps_ibc_enabled_flag)
>  ibc_fill_vir_buf(lc, cu);
>  cu = cu->next;
>  }
> +
> +fail:
>  ff_vvc_ctu_free_cus(ctu);
>  return ret;
>  }
> diff --git a/libavcodec/vvc/thread.c b/libavcodec/vvc/thread.c
> index 8777d380bf..5b01dd2d20 100644
> --- a/libavcodec/vvc/thread.c
> +++ b/libavcodec/vvc/thread.c
> @@ -454,9 +454,7 @@ static int run_inter(VVCContext *s, VVCLocalContext
> *lc, VVCTask *t)
>
>  static int run_recon(VVCContext *s, VVCLocalContext *lc, VVCTask *t)
>  {
> -ff_vvc_reconstruct(lc, t->rs, t->rx, t->ry);
> -
> -return 0;
> +return ff_vvc_reconstruct(lc, t->rs, t->rx, t->ry);
>  }
>
>  static int run_lmcs(VVCContext *s, VVCLocalContext *lc, VVCTask *t)
> --
> 2.45.1
>
> ___
> 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".
>
___
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 1/2] avutil/executor: Allowing thread_count be zero

2024-06-25 Thread Nuo Mi
On Mon, Jun 24, 2024 at 12:48 PM Zhao Zhili  wrote:

> From: Zhao Zhili 
>
> Before the patch, disable threads support at configure/build time
> was the only method to force zero thread in executor. However,
> it's common practice for libavcodec to run on caller's thread when
> user specify thread number to one. And for WASM environment, whether
> threads are supported needs to be detected at runtime. So executor
> should support zero thread at runtime.
>
> A single thread executor can be useful, e.g., to handle network
> protocol. So we can't take thread_count one as zero thread, which
> disabled a valid usercase.
>
> Other libraries take -threads 0 to mean auto. Executor as a low
> level utils doesn't do cpu detect. So take thread_count zero as
> zero thread, literally.
>
> Signed-off-by: Zhao Zhili 
>
Hi Zhili,
Thank you for the v2
I will merge it in 3 days if there are no objections.
___
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 4/4] checkasm/vvc_alf: ensure right and bottom boundaries are not overwritten by asm

2024-06-25 Thread Nuo Mi
Applied.
Thank you Ben for reviewing.

On Sat, Jun 22, 2024 at 12:21 PM Nuo Mi  wrote:

> ---
>  tests/checkasm/vvc_alf.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tests/checkasm/vvc_alf.c b/tests/checkasm/vvc_alf.c
> index be8b930810..15e79289cd 100644
> --- a/tests/checkasm/vvc_alf.c
> +++ b/tests/checkasm/vvc_alf.c
> @@ -108,8 +108,8 @@ static void check_alf_filter(VVCDSPContext *c, const
> int bit_depth)
>  memset(dst1, 0, DST_BUF_SIZE);
>  call_ref(dst0, dst_stride, src0 + offset, src_stride,
> w, h, filter, clip, vb_pos);
>  call_new(dst1, dst_stride, src1 + offset, src_stride,
> w, h, filter, clip, vb_pos);
> -for (int i = 0; i < h; i++) {
> -if (memcmp(dst0 + i * dst_stride, dst1 + i *
> dst_stride, w * SIZEOF_PIXEL))
> +for (int i = 0; i < (h + 1); i++) {
> +if (memcmp(dst0 + i * dst_stride, dst1 + i *
> dst_stride, (w + 1) * SIZEOF_PIXEL))
>  fail();
>  }
>  // Bench only square sizes, and ones with dimensions
> being a power of two.
> @@ -125,8 +125,8 @@ static void check_alf_filter(VVCDSPContext *c, const
> int bit_depth)
>  memset(dst1, 0, DST_BUF_SIZE);
>  call_ref(dst0, dst_stride, src0 + offset, src_stride,
> w, h, filter, clip, vb_pos);
>  call_new(dst1, dst_stride, src1 + offset, src_stride,
> w, h, filter, clip, vb_pos);
> -for (int i = 0; i < h; i++) {
> -if (memcmp(dst0 + i * dst_stride, dst1 + i *
> dst_stride, w * SIZEOF_PIXEL))
> +for (int i = 0; i < (h + 1); i++) {
> +if (memcmp(dst0 + i * dst_stride, dst1 + i *
> dst_stride, (w + 1) * SIZEOF_PIXEL))
>  fail();
>  }
>  if (w == h && (w & (w - 1)) == 0)
> --
> 2.34.1
>
>
___
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 18/18] avcodec/vvcdec: alf, support virtual boundaries

2024-06-25 Thread Nuo Mi
On Sat, Jun 22, 2024 at 2:24 PM Nuo Mi  wrote:

> see https://ieeexplore.ieee.org/stamp/stamp.jsp?tp==9503377
>
> passed files:
> GDR_A_ERICSSON_2.bit
> GDR_B_NOKIA_2.bit
> GDR_C_NOKIA_2.bit
> VIRTUAL_A_MediaTek_3.bit
> VIRTUAL_B_MediaTek_3.bit
>

Applied.
thank you

> --
> 2.34.1
>
>
___
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".


[FFmpeg-devel] [PATCH 18/18] avcodec/vvcdec: alf, support virtual boundaries

2024-06-22 Thread Nuo Mi
see https://ieeexplore.ieee.org/stamp/stamp.jsp?tp==9503377

passed files:
GDR_A_ERICSSON_2.bit
GDR_B_NOKIA_2.bit
GDR_C_NOKIA_2.bit
VIRTUAL_A_MediaTek_3.bit
VIRTUAL_B_MediaTek_3.bit
---
 libavcodec/vvc/ctu.h|   7 +++
 libavcodec/vvc/filter.c | 134 
 libavcodec/vvc/inter.c  |   7 ---
 3 files changed, 100 insertions(+), 48 deletions(-)

diff --git a/libavcodec/vvc/ctu.h b/libavcodec/vvc/ctu.h
index 432dbc5ade..d5c3e8d96f 100644
--- a/libavcodec/vvc/ctu.h
+++ b/libavcodec/vvc/ctu.h
@@ -463,6 +463,13 @@ typedef struct ALFParams {
 uint8_t ctb_cc_idc[2];  ///< alf_ctb_cc_cb_idc, 
alf_ctb_cc_cr_idc
 } ALFParams;
 
+typedef struct VVCRect {
+int l;  // left
+int t;  // top
+int r;  // right
+int b;  // bottom
+} VVCRect;
+
 /**
  * parse a CTU
  * @param lc local context for CTU
diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 44dd895d7d..19b69f078e 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -56,6 +56,9 @@ static const uint8_t betatable[64] = {
  58,  60,  62,  64,  66,  68,  70,  72,  74,  76,  78,  80,  82,  84,  86, 
 88,
 };
 
+// One vertical and one horizontal virtual boundary in a CTU at most. The CTU 
will be divided into 4 subblocks.
+#define MAX_VBBS 4
+
 static int get_virtual_boundary(const VVCFrameContext *fc, const int ctu_pos, 
const int vertical)
 {
 const VVCSPS *sps= fc->ps.sps;
@@ -1127,58 +1130,107 @@ static void alf_get_edges(const VVCLocalContext *lc, 
int edges[MAX_EDGES], const
 edges[RIGHT]  |= fc->ps.sps->r->sps_subpic_ctu_top_left_x[subpic_idx] 
+ fc->ps.sps->r->sps_subpic_width_minus1[subpic_idx] == rx;
 edges[BOTTOM] |= fc->ps.sps->r->sps_subpic_ctu_top_left_y[subpic_idx] 
+ fc->ps.sps->r->sps_subpic_height_minus1[subpic_idx] == ry;
 }
+
+if (sps->r->sps_virtual_boundaries_enabled_flag) {
+edges[LEFT]   |= is_virtual_boundary(fc, rx << sps->ctb_log2_size_y, 
1);
+edges[TOP]|= is_virtual_boundary(fc, ry << sps->ctb_log2_size_y, 
0);
+edges[RIGHT]  |= is_virtual_boundary(fc, (rx + 1) << 
sps->ctb_log2_size_y, 1);
+edges[BOTTOM] |= is_virtual_boundary(fc, (ry + 1) << 
sps->ctb_log2_size_y, 0);
+}
+}
+
+static void alf_init_subblock(VVCRect *sb, int sb_edges[MAX_EDGES], const 
VVCRect *b, const int edges[MAX_EDGES])
+{
+*sb = *b;
+memcpy(sb_edges, edges, sizeof(int) * MAX_EDGES);
+}
+
+static void alf_get_subblock(VVCRect *sb, int edges[MAX_EDGES], const int bx, 
const int by, const int vb_pos[2], const int has_vb[2])
+{
+int *pos[] = { >l, >t, >r, >b };
+
+for (int vertical = 0; vertical <= 1; vertical++) {
+if (has_vb[vertical]) {
+const int c = vertical ? (bx ? LEFT : RIGHT) : (by ? TOP : BOTTOM);
+*pos[c] = vb_pos[vertical];
+edges[c]  = 1;
+}
+}
+}
+
+static void alf_get_subblocks(const VVCLocalContext *lc, VVCRect 
sbs[MAX_VBBS], int sb_edges[MAX_VBBS][MAX_EDGES], int *nb_sbs,
+const int x0, const int y0, const int rx, const int ry)
+{
+VVCFrameContext *fc  = lc->fc;
+const VVCSPS *sps= fc->ps.sps;
+const VVCPPS *pps= fc->ps.pps;
+const int ctu_size_y = sps->ctb_size_y;
+const int vb_pos[]   = { get_virtual_boundary(fc, ry, 0),  
get_virtual_boundary(fc, rx, 1) };
+const int has_vb[]   = { vb_pos[0] > y0, vb_pos[1] > x0 };
+const VVCRect b  = { x0, y0, FFMIN(x0 + ctu_size_y, pps->width), 
FFMIN(y0 + ctu_size_y, pps->height) };
+int edges[MAX_EDGES] = { !rx, !ry, rx == pps->ctb_width - 1, ry == 
pps->ctb_height - 1 };
+int i= 0;
+
+alf_get_edges(lc, edges, rx, ry);
+
+for (int by = 0; by <= has_vb[0]; by++) {
+for (int bx = 0; bx <= has_vb[1]; bx++, i++) {
+alf_init_subblock(sbs + i, sb_edges[i], , edges);
+alf_get_subblock(sbs + i, sb_edges[i], bx, by, vb_pos, has_vb);
+}
+}
+*nb_sbs = i;
 }
 
 void ff_vvc_alf_filter(VVCLocalContext *lc, const int x0, const int y0)
 {
 VVCFrameContext *fc = lc->fc;
 const VVCSPS *sps   = fc->ps.sps;
-const VVCPPS *pps   = fc->ps.pps;
-const int rx= x0 >> fc->ps.sps->ctb_log2_size_y;
-const int ry= y0 >> fc->ps.sps->ctb_log2_size_y;
-const int ctb_size_y= fc->ps.sps->ctb_size_y;
-const int ps= fc->ps.sps->pixel_shift;
+const int rx= x0 >> sps->ctb_log2_size_y;
+const int ry= y0 >> sps->ctb_log2_size_y;
+const int ps= sps->pixel_shift;
 const int padded_stride = EDGE_EMU_BUFFER_STRIDE << ps;
 const int padded_offset = padded_stride * ALF_PADDING_SIZE + 
(ALF_PADDING_SIZE << ps);
 const int c_end = sps->r->sps_chroma_format_idc ? 
VVC_MAX_SAMPLE_ARRAYS : 1;
+const int ctu_end   = y0 + sps->ctb_size_y;
 const ALFParams *alf  

[FFmpeg-devel] [PATCH 16/18] avcodec/vvcdec: deblock, support virtual boundaries

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/filter.c | 34 ++
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index a5635c60df..69d67cb7f6 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -55,6 +55,29 @@ static const uint8_t betatable[64] = {
  58,  60,  62,  64,  66,  68,  70,  72,  74,  76,  78,  80,  82,  84,  86, 
 88,
 };
 
+static int get_virtual_boundary(const VVCFrameContext *fc, const int ctu_pos, 
const int vertical)
+{
+const VVCSPS *sps= fc->ps.sps;
+const VVCPH *ph  = >ps.ph;
+const uint16_t *vbs  = vertical ? ph->vb_pos_x: ph->vb_pos_y;
+const uint8_t nb_vbs = vertical ? ph->num_ver_vbs : ph->num_hor_vbs;
+const int pos= ctu_pos << sps->ctb_log2_size_y;
+
+if (sps->r->sps_virtual_boundaries_enabled_flag) {
+for (int i = 0; i < nb_vbs; i++) {
+const int o = vbs[i] - pos;
+if (o >= 0 && o < sps->ctb_size_y)
+return vbs[i];
+}
+}
+return 0;
+}
+
+static int is_virtual_boundary(const VVCFrameContext *fc, const int pos, const 
int vertical)
+{
+return get_virtual_boundary(fc, pos >> fc->ps.sps->ctb_log2_size_y, 
vertical) == pos;
+}
+
 static int get_qPc(const VVCFrameContext *fc, const int x0, const int y0, 
const int chroma)
 {
 const int x= x0 >> MIN_TU_LOG2;
@@ -429,6 +452,7 @@ static void vvc_deblock_subblock_bs(const VVCLocalContext 
*lc,
 
 // bs for TU internal vertical PU boundaries
 for (int i = 8 - ((x0 - cb) % 8); i < width; i += 8) {
+const int is_vb = is_virtual_boundary(fc, x0 + i, vertical);
 const int xp_pu = (x0 + i - 1) >> log2_min_pu_size;
 const int xq_pu = (x0 + i) >> log2_min_pu_size;
 
@@ -436,7 +460,7 @@ static void vvc_deblock_subblock_bs(const VVCLocalContext 
*lc,
 const int y_pu   = (y0 + j) >> log2_min_pu_size;
 const MvField *mvf_p = _mvf[y_pu * stridea + xp_pu * strideb];
 const MvField *mvf_q = _mvf[y_pu * stridea + xq_pu * strideb];
-const int bs = boundary_strength(lc, mvf_q, mvf_p, rpl);
+const int bs = is_vb ? 0 : boundary_strength(lc, mvf_q, 
mvf_p, rpl);
 int x= x0 + i;
 int y= y0 + j;
 uint8_t max_len_p = 0, max_len_q = 0;
@@ -557,6 +581,7 @@ static void vvc_deblock_bs_luma(const VVCLocalContext *lc,
 (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA;
 
 if (deblock_is_boundary(lc, pos > 0 && !(pos & mask), pos, rs, vertical)) {
+const int is_vb = is_virtual_boundary(fc, pos, vertical);
 const int size  = vertical ? height : width;
 const int off   = cb - pos;
 const int cb_size   = (vertical ? fc->tab.cb_width : 
fc->tab.cb_height)[LUMA][off_q];
@@ -569,7 +594,7 @@ static void vvc_deblock_bs_luma(const VVCLocalContext *lc,
 const int x = x0 + i * !vertical;
 const int y = y0 + i * vertical;
 uint8_t max_len_p, max_len_q;
-const int bs = deblock_bs(lc, x - vertical, y - !vertical, x, y, 
rpl_p, LUMA, off, has_sb);
+const int bs = is_vb ? 0 : deblock_bs(lc, x - vertical, y - 
!vertical, x, y, rpl_p, LUMA, off, has_sb);
 
 TAB_BS(fc->tab.bs[vertical][LUMA], x, y) = bs;
 
@@ -594,13 +619,14 @@ static void vvc_deblock_bs_chroma(const VVCLocalContext 
*lc,
 const int pos = vertical ? x0 : y0;
 
 if (deblock_is_boundary(lc, pos > 0 && !(pos & mask), pos, rs, vertical)) {
-const int size = vertical ? height : width;
+const int is_vb = is_virtual_boundary(fc, pos, vertical);
+const int size  = vertical ? height : width;
 
 for (int c_idx = CB; c_idx <= CR; c_idx++) {
 for (int i = 0; i < size; i += 2) {
 const int x  = x0 + i * !vertical;
 const int y  = y0 + i * vertical;
-const int bs = deblock_bs(lc, x - vertical, y - !vertical, x, 
y, NULL, c_idx, 0, 0);
+const int bs = is_vb ? 0 : deblock_bs(lc, x - vertical, y - 
!vertical, x, y, NULL, c_idx, 0, 0);
 
 TAB_BS(fc->tab.bs[vertical][c_idx], x, y) = bs;
 }
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 17/18] avcodec/vvcdec: sao, support virtual boundaries

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/filter.c | 46 +
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 69d67cb7f6..44dd895d7d 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include "libavutil/frame.h"
+#include "libavutil/imgutils.h"
 
 #include "ctu.h"
 #include "data.h"
@@ -198,7 +199,7 @@ static void sao_get_edges(uint8_t vert_edge[2], uint8_t 
horiz_edge[2], uint8_t d
 const uint8_t no_subpic_filter = rsps->sps_num_subpics_minus1 && 
!rsps->sps_loop_filter_across_subpic_enabled_flag[subpic_idx];
 uint8_t lf_edge[] = { 0, 0, 0, 0 };
 
-*restore = no_subpic_filter || no_tile_filter || !lfase;
+*restore = no_subpic_filter || no_tile_filter || !lfase || 
rsps->sps_virtual_boundaries_enabled_flag;
 
 if (!*restore)
 return;
@@ -206,21 +207,25 @@ static void sao_get_edges(uint8_t vert_edge[2], uint8_t 
horiz_edge[2], uint8_t d
 if (!edges[LEFT]) {
 lf_edge[LEFT]  = no_tile_filter && pps->ctb_to_col_bd[rx] == rx;
 lf_edge[LEFT] |= no_subpic_filter && 
rsps->sps_subpic_ctu_top_left_x[subpic_idx] == rx;
+lf_edge[LEFT] |= is_virtual_boundary(fc, rx << sps->ctb_log2_size_y, 
1);
 vert_edge[0]   = !sao_can_cross_slices(fc, rx, ry, -1, 0) || 
lf_edge[LEFT];
 }
 if (!edges[RIGHT]) {
 lf_edge[RIGHT]  = no_tile_filter && pps->ctb_to_col_bd[rx] != 
pps->ctb_to_col_bd[rx + 1];
 lf_edge[RIGHT] |= no_subpic_filter && 
rsps->sps_subpic_ctu_top_left_x[subpic_idx] + 
rsps->sps_subpic_width_minus1[subpic_idx] == rx;
+lf_edge[RIGHT] |= is_virtual_boundary(fc, (rx + 1) << 
sps->ctb_log2_size_y, 1);
 vert_edge[1]= !sao_can_cross_slices(fc, rx, ry, 1, 0) || 
lf_edge[RIGHT];
 }
 if (!edges[TOP]) {
 lf_edge[TOP]   = no_tile_filter && pps->ctb_to_row_bd[ry] == ry;
 lf_edge[TOP]  |= no_subpic_filter && 
rsps->sps_subpic_ctu_top_left_y[subpic_idx] == ry;
+lf_edge[TOP]  |= is_virtual_boundary(fc, ry << sps->ctb_log2_size_y, 
0);
 horiz_edge[0]  = !sao_can_cross_slices(fc, rx, ry, 0, -1) || 
lf_edge[TOP];
 }
 if (!edges[BOTTOM]) {
 lf_edge[BOTTOM]  = no_tile_filter && pps->ctb_to_row_bd[ry] != 
pps->ctb_to_row_bd[ry + 1];
 lf_edge[BOTTOM] |= no_subpic_filter && 
rsps->sps_subpic_ctu_top_left_y[subpic_idx] + 
rsps->sps_subpic_height_minus1[subpic_idx] == ry;
+lf_edge[BOTTOM] |= is_virtual_boundary(fc, (ry + 1) << 
sps->ctb_log2_size_y, 0);
 horiz_edge[1]= !sao_can_cross_slices(fc, rx, ry, 0, 1) || 
lf_edge[BOTTOM];
 }
 
@@ -285,6 +290,24 @@ static void sao_extends_edges(uint8_t *dst, const 
ptrdiff_t dst_stride,
 copy_ctb(dst, src, width << ps, height, dst_stride, src_stride);
 }
 
+static void sao_restore_vb(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t 
*src, ptrdiff_t src_stride,
+const int width, const int height, const int vb_pos, const int ps, const 
int vertical)
+{
+int w = 2;
+int h = (vertical ? height : width);
+int dx = vb_pos - 1;
+int dy = 0;
+
+if (!vertical) {
+FFSWAP(int, w, h);
+FFSWAP(int, dx, dy);
+}
+dst += dy * dst_stride +(dx << ps);
+src += dy * src_stride +(dx << ps);
+
+av_image_copy_plane(dst, dst_stride, src, src_stride, w << ps, h);
+}
+
 void ff_vvc_sao_filter(VVCLocalContext *lc, int x0, int y0)
 {
 VVCFrameContext *fc  = lc->fc;
@@ -297,7 +320,12 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x0, int y0)
 uint8_t vert_edge[]  = { 0, 0 };
 uint8_t horiz_edge[] = { 0, 0 };
 uint8_t diag_edge[]  = { 0, 0, 0, 0 };
-int restore;
+int restore, vb_x = 0, vb_y = 0;;
+
+if (sps->r->sps_virtual_boundaries_enabled_flag) {
+vb_x = get_virtual_boundary(fc, rx, 1);
+vb_y = get_virtual_boundary(fc, ry, 0);
+}
 
 sao_get_edges(vert_edge, horiz_edge, diag_edge, , lc, edges, rx, 
ry);
 
@@ -305,9 +333,13 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x0, int y0)
 static const uint8_t sao_tab[16] = { 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 
6, 7, 7, 8, 8 };
 const ptrdiff_t src_stride   = fc->frame->linesize[c_idx];
 uint8_t *src = POS(c_idx, x0, y0);
-const int width  = FFMIN(sps->ctb_size_y, 
fc->ps.pps->width - x0) >> sps->hshift[c_idx];
-const int height = FFMIN(sps->ctb_size_y, 
fc->ps.pps->height - y0) >> sps->vshift[c_idx];
+const int hs = sps->hshift[c_idx];
+const int vs = sps->vshift[c_idx];
+const int ps = sps->pixel_shift;
+const int width  = FFMIN(sps->ctb_size_y, 
fc->ps.pps->width  - x0) >> hs;
+const int height = FFMIN(sps->ctb_size_y, 
fc->ps.pps->height - y0) 

[FFmpeg-devel] [PATCH 14/18] cbs_h266: add VVC_MAX_VBS for max num of virtual boundaries

2024-06-22 Thread Nuo Mi
---
 libavcodec/cbs_h266.h | 8 
 libavcodec/cbs_h266_syntax_template.c | 8 
 libavcodec/vvc.h  | 3 +++
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/libavcodec/cbs_h266.h b/libavcodec/cbs_h266.h
index 21b9a4196c..5f12915b65 100644
--- a/libavcodec/cbs_h266.h
+++ b/libavcodec/cbs_h266.h
@@ -464,9 +464,9 @@ typedef struct H266RawSPS {
 uint8_t  sps_virtual_boundaries_enabled_flag;
 uint8_t  sps_virtual_boundaries_present_flag;
 uint8_t  sps_num_ver_virtual_boundaries;
-uint16_t sps_virtual_boundary_pos_x_minus1[3];
+uint16_t sps_virtual_boundary_pos_x_minus1[VVC_MAX_VBS];
 uint8_t  sps_num_hor_virtual_boundaries;
-uint16_t sps_virtual_boundary_pos_y_minus1[3];
+uint16_t sps_virtual_boundary_pos_y_minus1[VVC_MAX_VBS];
 
 uint8_t  sps_timing_hrd_params_present_flag;
 uint8_t  sps_sublayer_cpb_params_present_flag;
@@ -703,9 +703,9 @@ typedef struct  H266RawPictureHeader {
 
 uint8_t  ph_virtual_boundaries_present_flag;
 uint8_t  ph_num_ver_virtual_boundaries;
-uint16_t ph_virtual_boundary_pos_x_minus1[3];
+uint16_t ph_virtual_boundary_pos_x_minus1[VVC_MAX_VBS];
 uint8_t  ph_num_hor_virtual_boundaries;
-uint16_t ph_virtual_boundary_pos_y_minus1[3];
+uint16_t ph_virtual_boundary_pos_y_minus1[VVC_MAX_VBS];
 
 uint8_t  ph_pic_output_flag;
 H266RefPicLists ph_ref_pic_lists;
diff --git a/libavcodec/cbs_h266_syntax_template.c 
b/libavcodec/cbs_h266_syntax_template.c
index 53c4b60b0d..34b766c7af 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -1562,13 +1562,13 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, 
RWContext *rw,
 flag(sps_virtual_boundaries_present_flag);
 if (current->sps_virtual_boundaries_present_flag) {
 ue(sps_num_ver_virtual_boundaries,
-   0, current->sps_pic_width_max_in_luma_samples <= 8 ? 0 : 3);
+   0, current->sps_pic_width_max_in_luma_samples <= 8 ? 0 : 
VVC_MAX_VBS);
 for (i = 0; i < current->sps_num_ver_virtual_boundaries; i++)
 ues(sps_virtual_boundary_pos_x_minus1[i],
 0, (current->sps_pic_width_max_in_luma_samples + 7) / 8 - 
2,
 1, i);
 ue(sps_num_hor_virtual_boundaries,
-   0, current->sps_pic_height_max_in_luma_samples <= 8 ? 0 : 3);
+   0, current->sps_pic_height_max_in_luma_samples <= 8 ? 0 : 
VVC_MAX_VBS);
 for (i = 0; i < current->sps_num_hor_virtual_boundaries; i++)
 ues(sps_virtual_boundary_pos_y_minus1[i],
 0, (current->sps_pic_height_max_in_luma_samples + 7) /
@@ -2714,13 +2714,13 @@ static int FUNC(picture_header) (CodedBitstreamContext 
*ctx, RWContext *rw,
 flag(ph_virtual_boundaries_present_flag);
 if (current->ph_virtual_boundaries_present_flag) {
 ue(ph_num_ver_virtual_boundaries,
-   0, pps->pps_pic_width_in_luma_samples <= 8 ? 0 : 3);
+   0, pps->pps_pic_width_in_luma_samples <= 8 ? 0 : VVC_MAX_VBS);
 for (i = 0; i < current->ph_num_ver_virtual_boundaries; i++) {
 ues(ph_virtual_boundary_pos_x_minus1[i],
 0, (pps->pps_pic_width_in_luma_samples + 7) / 8 - 2, 1, i);
 }
 ue(ph_num_hor_virtual_boundaries,
-   0, pps->pps_pic_height_in_luma_samples <= 8 ? 0 : 3);
+   0, pps->pps_pic_height_in_luma_samples <= 8 ? 0 : VVC_MAX_VBS);
 for (i = 0; i < current->ph_num_hor_virtual_boundaries; i++) {
 ues(ph_virtual_boundary_pos_y_minus1[i],
 0, (pps->pps_pic_height_in_luma_samples + 7) / 8 - 2, 1, 
i);
diff --git a/libavcodec/vvc.h b/libavcodec/vvc.h
index c4cec1eb8f..92639779c1 100644
--- a/libavcodec/vvc.h
+++ b/libavcodec/vvc.h
@@ -151,6 +151,9 @@ enum {
 // get near that, though, so set a lower limit here with the maximum
 // possible value for 8K video (at most 135 32x32 Ctb rows).
 VVC_MAX_ENTRY_POINTS = VVC_MAX_TILE_COLUMNS * 135,
+
+// {sps, ph}_num_{ver, hor}_virtual_boundaries should in [0, 3]
+VVC_MAX_VBS = 3,
 };
 
 #endif /* AVCODEC_VVC_H */
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 13/18] avcodec/vvcdec: misc, constify ALFParams

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/filter.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 457e2b99c2..a5635c60df 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -926,7 +926,7 @@ static void alf_prepare_buffer(VVCFrameContext *fc, uint8_t 
*_dst, const uint8_t
 #define ALF_MAX_FILTER_SIZE (ALF_MAX_BLOCKS_IN_CTU * ALF_NUM_COEFF_LUMA)
 
 static void alf_get_coeff_and_clip(VVCLocalContext *lc, int16_t *coeff, 
int16_t *clip,
-const uint8_t *src, ptrdiff_t src_stride, int width, int height, int 
vb_pos, ALFParams *alf)
+const uint8_t *src, ptrdiff_t src_stride, int width, int height, int 
vb_pos, const ALFParams *alf)
 {
 const VVCFrameContext *fc = lc->fc;
 const H266RawSliceHeader *rsh = lc->sc->sh.r;
@@ -957,7 +957,7 @@ static void alf_get_coeff_and_clip(VVCLocalContext *lc, 
int16_t *coeff, int16_t
 
 static void alf_filter_luma(VVCLocalContext *lc, uint8_t *dst, const uint8_t 
*src,
 const ptrdiff_t dst_stride, const ptrdiff_t src_stride, const int x0, 
const int y0,
-const int width, const int height, const int _vb_pos, ALFParams *alf)
+const int width, const int height, const int _vb_pos, const ALFParams *alf)
 {
 const VVCFrameContext *fc = lc->fc;
 int vb_pos= _vb_pos - y0;
@@ -981,7 +981,7 @@ static int alf_clip_from_idx(const VVCFrameContext *fc, 
const int idx)
 
 static void alf_filter_chroma(VVCLocalContext *lc, uint8_t *dst, const uint8_t 
*src,
 const ptrdiff_t dst_stride, const ptrdiff_t src_stride, const int c_idx,
-const int width, const int height, const int vb_pos, ALFParams *alf)
+const int width, const int height, const int vb_pos, const ALFParams *alf)
 {
 VVCFrameContext *fc   = lc->fc;
 const H266RawSliceHeader *rsh = lc->sc->sh.r;
@@ -998,7 +998,7 @@ static void alf_filter_chroma(VVCLocalContext *lc, uint8_t 
*dst, const uint8_t *
 
 static void alf_filter_cc(VVCLocalContext *lc, uint8_t *dst, const uint8_t 
*luma,
 const ptrdiff_t dst_stride, const ptrdiff_t luma_stride, const int c_idx,
-const int width, const int height, const int hs, const int vs, const int 
vb_pos, ALFParams *alf)
+const int width, const int height, const int hs, const int vs, const int 
vb_pos, const ALFParams *alf)
 {
 const VVCFrameContext *fc = lc->fc;
 const H266RawSliceHeader *rsh = lc->sc->sh.r;
@@ -1077,7 +1077,7 @@ void ff_vvc_alf_filter(VVCLocalContext *lc, const int x0, 
const int y0)
 const int padded_stride = EDGE_EMU_BUFFER_STRIDE << ps;
 const int padded_offset = padded_stride * ALF_PADDING_SIZE + 
(ALF_PADDING_SIZE << ps);
 const int c_end = sps->r->sps_chroma_format_idc ? 
VVC_MAX_SAMPLE_ARRAYS : 1;
-ALFParams *alf  = (fc->tab.alf, rx, ry);
+const ALFParams *alf= (fc->tab.alf, rx, ry);
 int edges[MAX_EDGES]= { rx == 0, ry == 0, rx == pps->ctb_width - 1, ry 
== pps->ctb_height - 1 };
 
 alf_get_edges(lc, edges, rx, ry);
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 12/18] avcodec/vvcdec: misc, remove unused ALFParams.applied

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/ctu.h| 2 --
 libavcodec/vvc/filter.c | 2 --
 2 files changed, 4 deletions(-)

diff --git a/libavcodec/vvc/ctu.h b/libavcodec/vvc/ctu.h
index a987328d81..432dbc5ade 100644
--- a/libavcodec/vvc/ctu.h
+++ b/libavcodec/vvc/ctu.h
@@ -461,8 +461,6 @@ typedef struct ALFParams {
 uint8_t ctb_filt_set_idx_y; ///< AlfCtbFiltSetIdxY
 uint8_t alf_ctb_filter_alt_idx[2];  ///< alf_ctb_filter_alt_idx[]
 uint8_t ctb_cc_idc[2];  ///< alf_ctb_cc_cb_idc, 
alf_ctb_cc_cr_idc
-
-uint8_t applied[3];
 } ALFParams;
 
 /**
diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 671e599dab..457e2b99c2 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -1116,8 +1116,6 @@ void ff_vvc_alf_filter(VVCLocalContext *lc, const int x0, 
const int y0)
 alf_filter_cc(lc, src, padded, src_stride, padded_stride, c_idx,
 width, height, hs, vs, (ctb_size_v << vs) - 
ALF_VB_POS_ABOVE_LUMA, alf);
 }
-
-alf->applied[c_idx] = 1;
 }
 }
 
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 11/18] avcodec/vvcdec: refact out alf_get_edges

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/filter.c | 53 -
 1 file changed, 31 insertions(+), 22 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 3aa241ad90..671e599dab 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -1036,6 +1036,35 @@ void ff_vvc_alf_copy_ctu_to_hv(VVCLocalContext* lc, 
const int x0, const int y0)
 }
 }
 
+static void alf_get_edges(const VVCLocalContext *lc, int edges[MAX_EDGES], 
const int rx, const int ry)
+{
+VVCFrameContext *fc  = lc->fc;
+const VVCSPS *sps= fc->ps.sps;
+const VVCPPS *pps= fc->ps.pps;
+const int subpic_idx = lc->sc->sh.r->curr_subpic_idx;
+
+if (!pps->r->pps_loop_filter_across_tiles_enabled_flag) {
+edges[LEFT]   |= !!(lc->boundary_flags & BOUNDARY_LEFT_TILE);
+edges[TOP]|= !!(lc->boundary_flags & BOUNDARY_UPPER_TILE);
+edges[RIGHT]  |= pps->ctb_to_col_bd[rx] != pps->ctb_to_col_bd[rx + 1];
+edges[BOTTOM] |= pps->ctb_to_row_bd[ry] != pps->ctb_to_row_bd[ry + 1];
+}
+
+if (!pps->r->pps_loop_filter_across_slices_enabled_flag) {
+edges[LEFT]   |= !!(lc->boundary_flags & BOUNDARY_LEFT_SLICE);
+edges[TOP]|= !!(lc->boundary_flags & BOUNDARY_UPPER_SLICE);
+edges[RIGHT]  |= CTB(fc->tab.slice_idx, rx, ry) != 
CTB(fc->tab.slice_idx, rx + 1, ry);
+edges[BOTTOM] |= CTB(fc->tab.slice_idx, rx, ry) != 
CTB(fc->tab.slice_idx, rx, ry + 1);
+}
+
+if (!sps->r->sps_loop_filter_across_subpic_enabled_flag[subpic_idx]) {
+edges[LEFT]   |= !!(lc->boundary_flags & BOUNDARY_LEFT_SUBPIC);
+edges[TOP]|= !!(lc->boundary_flags & BOUNDARY_UPPER_SUBPIC);
+edges[RIGHT]  |= fc->ps.sps->r->sps_subpic_ctu_top_left_x[subpic_idx] 
+ fc->ps.sps->r->sps_subpic_width_minus1[subpic_idx] == rx;
+edges[BOTTOM] |= fc->ps.sps->r->sps_subpic_ctu_top_left_y[subpic_idx] 
+ fc->ps.sps->r->sps_subpic_height_minus1[subpic_idx] == ry;
+}
+}
+
 void ff_vvc_alf_filter(VVCLocalContext *lc, const int x0, const int y0)
 {
 VVCFrameContext *fc = lc->fc;
@@ -1047,31 +1076,11 @@ void ff_vvc_alf_filter(VVCLocalContext *lc, const int 
x0, const int y0)
 const int ps= fc->ps.sps->pixel_shift;
 const int padded_stride = EDGE_EMU_BUFFER_STRIDE << ps;
 const int padded_offset = padded_stride * ALF_PADDING_SIZE + 
(ALF_PADDING_SIZE << ps);
-const int c_end = fc->ps.sps->r->sps_chroma_format_idc ? 
VVC_MAX_SAMPLE_ARRAYS : 1;
-const int subpic_idx= lc->sc->sh.r->curr_subpic_idx;
+const int c_end = sps->r->sps_chroma_format_idc ? 
VVC_MAX_SAMPLE_ARRAYS : 1;
 ALFParams *alf  = (fc->tab.alf, rx, ry);
 int edges[MAX_EDGES]= { rx == 0, ry == 0, rx == pps->ctb_width - 1, ry 
== pps->ctb_height - 1 };
 
-if (!pps->r->pps_loop_filter_across_tiles_enabled_flag) {
-edges[LEFT]   = edges[LEFT] || (lc->boundary_flags & 
BOUNDARY_LEFT_TILE);
-edges[TOP]= edges[TOP] || (lc->boundary_flags & 
BOUNDARY_UPPER_TILE);
-edges[RIGHT]  = edges[RIGHT] || pps->ctb_to_col_bd[rx] != 
pps->ctb_to_col_bd[rx + 1];
-edges[BOTTOM] = edges[BOTTOM] || pps->ctb_to_row_bd[ry] != 
pps->ctb_to_row_bd[ry + 1];
-}
-
-if (!pps->r->pps_loop_filter_across_slices_enabled_flag) {
-edges[LEFT]   = edges[LEFT] || (lc->boundary_flags & 
BOUNDARY_LEFT_SLICE);
-edges[TOP]= edges[TOP] || (lc->boundary_flags & 
BOUNDARY_UPPER_SLICE);
-edges[RIGHT]  = edges[RIGHT] || CTB(fc->tab.slice_idx, rx, ry) != 
CTB(fc->tab.slice_idx, rx + 1, ry);
-edges[BOTTOM] = edges[BOTTOM] || CTB(fc->tab.slice_idx, rx, ry) != 
CTB(fc->tab.slice_idx, rx, ry + 1);
-}
-
-if (!sps->r->sps_loop_filter_across_subpic_enabled_flag[subpic_idx]) {
-edges[LEFT]   = edges[LEFT] || (lc->boundary_flags & 
BOUNDARY_LEFT_SUBPIC);
-edges[TOP]= edges[TOP] || (lc->boundary_flags & 
BOUNDARY_UPPER_SUBPIC);
-edges[RIGHT]  = edges[RIGHT] || 
fc->ps.sps->r->sps_subpic_ctu_top_left_x[subpic_idx] + 
fc->ps.sps->r->sps_subpic_width_minus1[subpic_idx] == rx;
-edges[BOTTOM] = edges[BOTTOM] || 
fc->ps.sps->r->sps_subpic_ctu_top_left_y[subpic_idx] + 
fc->ps.sps->r->sps_subpic_height_minus1[subpic_idx] == ry;
-}
+alf_get_edges(lc, edges, rx, ry);
 
 for (int c_idx = 0; c_idx < c_end; c_idx++) {
 const int hs = fc->ps.sps->hshift[c_idx];
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 10/18] avcodec/vvcdec: misc, reformat ff_vvc_sao_filter

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/filter.c | 52 -
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 10d11ce31f..3aa241ad90 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -266,44 +266,44 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x0, int 
y0)
 {
 VVCFrameContext *fc  = lc->fc;
 const VVCSPS *sps= fc->ps.sps;
-static const uint8_t sao_tab[16] = { 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 
7, 7, 8, 8 };
-int c_idx, restore;
 const int rx = x0 >> sps->ctb_log2_size_y;
 const int ry = y0 >> sps->ctb_log2_size_y;
-int edges[4] = { !rx, !ry, rx == fc->ps.pps->ctb_width - 1, ry == 
fc->ps.pps->ctb_height - 1 };
+const int edges[4]   = { !rx, !ry, rx == fc->ps.pps->ctb_width - 1, ry == 
fc->ps.pps->ctb_height - 1 };
 const SAOParams *sao = (fc->tab.sao, rx, ry);
 // flags indicating unfilterable edges
 uint8_t vert_edge[]  = { 0, 0 };
 uint8_t horiz_edge[] = { 0, 0 };
 uint8_t diag_edge[]  = { 0, 0, 0, 0 };
+int restore;
 
 sao_get_edges(vert_edge, horiz_edge, diag_edge, , lc, edges, rx, 
ry);
 
-for (c_idx = 0; c_idx < (sps->r->sps_chroma_format_idc ? 3 : 1); c_idx++) {
-ptrdiff_t src_stride = fc->frame->linesize[c_idx];
-const int width  = FFMIN(sps->ctb_size_y, fc->ps.pps->width - x0) >> 
sps->hshift[c_idx];
-const int height = FFMIN(sps->ctb_size_y, fc->ps.pps->height - y0) >> 
sps->vshift[c_idx];
-int tab  = sao_tab[(FFALIGN(width, 8) >> 3) - 1];
-uint8_t *src = POS(c_idx, x0, y0);
+for (int c_idx = 0; c_idx < (sps->r->sps_chroma_format_idc ? 3 : 1); 
c_idx++) {
+static const uint8_t sao_tab[16] = { 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 
6, 7, 7, 8, 8 };
+const ptrdiff_t src_stride   = fc->frame->linesize[c_idx];
+uint8_t *src = POS(c_idx, x0, y0);
+const int width  = FFMIN(sps->ctb_size_y, 
fc->ps.pps->width - x0) >> sps->hshift[c_idx];
+const int height = FFMIN(sps->ctb_size_y, 
fc->ps.pps->height - y0) >> sps->vshift[c_idx];
+const int tab= sao_tab[(FFALIGN(width, 8) >> 3) - 
1];
 
 switch (sao->type_idx[c_idx]) {
-case SAO_BAND:
-fc->vvcdsp.sao.band_filter[tab](src, src, src_stride, src_stride,
-sao->offset_val[c_idx], sao->band_position[c_idx], width, 
height);
-break;
-case SAO_EDGE:
-{
-const ptrdiff_t dst_stride = 2 * MAX_PB_SIZE + 
AV_INPUT_BUFFER_PADDING_SIZE;
-uint8_t *dst   = lc->sao_buffer + dst_stride + 
AV_INPUT_BUFFER_PADDING_SIZE;
-
-sao_extends_edges(dst, dst_stride, src, src_stride, width, height, 
fc, x0, y0, rx, ry, edges, c_idx);
-
-fc->vvcdsp.sao.edge_filter[tab](src, dst, src_stride, 
sao->offset_val[c_idx],
-sao->eo_class[c_idx], width, height);
-fc->vvcdsp.sao.edge_restore[restore](src, dst, src_stride, 
dst_stride,
-sao, edges, width, height, c_idx, vert_edge, horiz_edge, 
diag_edge);
-break;
-}
+case SAO_BAND:
+fc->vvcdsp.sao.band_filter[tab](src, src, src_stride, 
src_stride,
+sao->offset_val[c_idx], sao->band_position[c_idx], width, 
height);
+break;
+case SAO_EDGE:
+{
+const ptrdiff_t dst_stride = 2 * MAX_PB_SIZE + 
AV_INPUT_BUFFER_PADDING_SIZE;
+uint8_t *dst   = lc->sao_buffer + dst_stride + 
AV_INPUT_BUFFER_PADDING_SIZE;
+
+sao_extends_edges(dst, dst_stride, src, src_stride, width, 
height, fc, x0, y0, rx, ry, edges, c_idx);
+
+fc->vvcdsp.sao.edge_filter[tab](src, dst, src_stride, 
sao->offset_val[c_idx],
+sao->eo_class[c_idx], width, height);
+fc->vvcdsp.sao.edge_restore[restore](src, dst, src_stride, 
dst_stride,
+sao, edges, width, height, c_idx, vert_edge, horiz_edge, 
diag_edge);
+break;
+}
 }
 }
 }
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 08/18] avcodec/vvcdec: refact out sao_extends_edges

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/filter.c | 108 +++-
 1 file changed, 50 insertions(+), 58 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 1326d2c82e..534ba57205 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -214,6 +214,52 @@ static void sao_get_edges(uint8_t vert_edge[2], uint8_t 
horiz_edge[2], uint8_t d
 diag_edge[3] = !sao_can_cross_slices(fc, rx, ry, -1,  1) || 
lf_edge[LEFT] || lf_edge[BOTTOM];
 }
 
+static void sao_copy_hor(uint8_t *dst, const ptrdiff_t dst_stride,
+const uint8_t *src, const ptrdiff_t src_stride, const int width, const int 
edges[4], const int ps)
+{
+const int left  = 1 - edges[LEFT];
+const int right = 1 - edges[RIGHT];
+int pos = 0;
+
+src -= left << ps;
+dst -= left << ps;
+
+if (left) {
+copy_pixel(dst, src, ps);
+pos += (1 << ps);
+}
+memcpy(dst + pos, src + pos, width << ps);
+if (right) {
+pos += width << ps;
+copy_pixel(dst + pos, src + pos, ps);
+}
+}
+
+static void sao_extends_edges(uint8_t *dst, const ptrdiff_t dst_stride,
+const uint8_t *src, const ptrdiff_t src_stride, const int width, const int 
height,
+const VVCFrameContext *fc, const int x, const int y, const int rx, const 
int ry, const int edges[4], const int c_idx)
+{
+const uint8_t *sao_h = fc->tab.sao_pixel_buffer_h[c_idx];
+const uint8_t *sao_v = fc->tab.sao_pixel_buffer_v[c_idx];
+const int w  = fc->ps.pps->width >> fc->ps.sps->hshift[c_idx];
+const int h  = fc->ps.pps->height >> fc->ps.sps->vshift[c_idx];
+const int ps = fc->ps.sps->pixel_shift;
+
+if (!edges[TOP])
+sao_copy_hor(dst - dst_stride, dst_stride, sao_h + (((2 * ry - 1) * w 
+ x) << ps), src_stride, width, edges, ps);
+
+if (!edges[BOTTOM])
+sao_copy_hor(dst + height * dst_stride, dst_stride, sao_h + (((2 * ry 
+ 2) * w + x) << ps), src_stride, width, edges, ps);
+
+if (!edges[LEFT])
+copy_vert(dst - (1 << ps), sao_v + (((2 * rx - 1) * h + y) << ps), ps, 
height, dst_stride, 1 << ps);
+
+if (!edges[RIGHT])
+copy_vert(dst + (width << ps), sao_v + (((2 * rx + 2) * h + y) << ps), 
 ps, height, dst_stride, 1 << ps);
+
+copy_ctb(dst, src, width << ps, height, dst_stride, src_stride);
+}
+
 void ff_vvc_sao_filter(VVCLocalContext *lc, int x, int y)
 {
 VVCFrameContext *fc  = lc->fc;
@@ -241,8 +287,6 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x, int y)
 int height   = FFMIN(ctb_size_v, (fc->ps.pps->height >> 
fc->ps.sps->vshift[c_idx]) - y0);
 int tab  = sao_tab[(FFALIGN(width, 8) >> 3) - 1];
 uint8_t *src = POS(c_idx, x, y);
-ptrdiff_t dst_stride;
-uint8_t *dst;
 
 switch (sao->type_idx[c_idx]) {
 case SAO_BAND:
@@ -251,63 +295,11 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x, int y)
 break;
 case SAO_EDGE:
 {
-const int w = fc->ps.pps->width >> fc->ps.sps->hshift[c_idx];
-const int h = fc->ps.pps->height >> fc->ps.sps->vshift[c_idx];
-const int sh = fc->ps.sps->pixel_shift;
-
-dst_stride = 2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE;
-dst = lc->sao_buffer + dst_stride + AV_INPUT_BUFFER_PADDING_SIZE;
-
-if (!edges[TOP]) {
-const int left = 1 - edges[LEFT];
-const int right = 1 - edges[RIGHT];
-const uint8_t *src1;
-uint8_t *dst1;
-int pos = 0;
-
-dst1 = dst - dst_stride - (left << sh);
-src1 = fc->tab.sao_pixel_buffer_h[c_idx] + (((2 * ry - 1) * w 
+ x0 - left) << sh);
-if (left) {
-copy_pixel(dst1, src1, sh);
-pos += (1 << sh);
-}
-memcpy(dst1 + pos, src1 + pos, width << sh);
-if (right) {
-pos += width << sh;
-copy_pixel(dst1 + pos, src1 + pos, sh);
-}
-}
-if (!edges[BOTTOM]) {
-const int left = 1 - edges[LEFT];
-const int right = 1 - edges[RIGHT];
-const uint8_t *src1;
-uint8_t *dst1;
-int pos = 0;
-
-dst1 = dst + height * dst_stride - (left << sh);
-src1 = fc->tab.sao_pixel_buffer_h[c_idx] + (((2 * ry + 2) * w 
+ x0 - left) << sh);
-if (left) {
-copy_pixel(dst1, src1, sh);
-pos += (1 << sh);
-}
-memcpy(dst1 + pos, src1 + pos, width << sh);
-if (right) {
-pos += width << sh;
-copy_pixel(dst1 + pos, src1 + pos, sh);
-}
-}
-if (!edges[LEFT]) {
-copy_vert(dst - (1 << sh),
-

[FFmpeg-devel] [PATCH 09/18] avcodec/vvcdec: refact, fix naming convention of x0, y0 for sao

2024-06-22 Thread Nuo Mi
it's mismatched with the ff_vvc_sao_filter function declaration
---
 libavcodec/vvc/filter.c | 24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 534ba57205..10d11ce31f 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -237,10 +237,12 @@ static void sao_copy_hor(uint8_t *dst, const ptrdiff_t 
dst_stride,
 
 static void sao_extends_edges(uint8_t *dst, const ptrdiff_t dst_stride,
 const uint8_t *src, const ptrdiff_t src_stride, const int width, const int 
height,
-const VVCFrameContext *fc, const int x, const int y, const int rx, const 
int ry, const int edges[4], const int c_idx)
+const VVCFrameContext *fc, const int x0, const int y0, const int rx, const 
int ry, const int edges[4], const int c_idx)
 {
 const uint8_t *sao_h = fc->tab.sao_pixel_buffer_h[c_idx];
 const uint8_t *sao_v = fc->tab.sao_pixel_buffer_v[c_idx];
+const int x  = x0 >> fc->ps.sps->hshift[c_idx];
+const int y  = y0 >> fc->ps.sps->vshift[c_idx];
 const int w  = fc->ps.pps->width >> fc->ps.sps->hshift[c_idx];
 const int h  = fc->ps.pps->height >> fc->ps.sps->vshift[c_idx];
 const int ps = fc->ps.sps->pixel_shift;
@@ -260,14 +262,14 @@ static void sao_extends_edges(uint8_t *dst, const 
ptrdiff_t dst_stride,
 copy_ctb(dst, src, width << ps, height, dst_stride, src_stride);
 }
 
-void ff_vvc_sao_filter(VVCLocalContext *lc, int x, int y)
+void ff_vvc_sao_filter(VVCLocalContext *lc, int x0, int y0)
 {
 VVCFrameContext *fc  = lc->fc;
-const int ctb_size_y = fc->ps.sps->ctb_size_y;
+const VVCSPS *sps= fc->ps.sps;
 static const uint8_t sao_tab[16] = { 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 
7, 7, 8, 8 };
 int c_idx, restore;
-const int rx = x >> fc->ps.sps->ctb_log2_size_y;
-const int ry = y >> fc->ps.sps->ctb_log2_size_y;
+const int rx = x0 >> sps->ctb_log2_size_y;
+const int ry = y0 >> sps->ctb_log2_size_y;
 int edges[4] = { !rx, !ry, rx == fc->ps.pps->ctb_width - 1, ry == 
fc->ps.pps->ctb_height - 1 };
 const SAOParams *sao = (fc->tab.sao, rx, ry);
 // flags indicating unfilterable edges
@@ -277,16 +279,12 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x, int y)
 
 sao_get_edges(vert_edge, horiz_edge, diag_edge, , lc, edges, rx, 
ry);
 
-for (c_idx = 0; c_idx < (fc->ps.sps->r->sps_chroma_format_idc ? 3 : 1); 
c_idx++) {
-int x0   = x >> fc->ps.sps->hshift[c_idx];
-int y0   = y >> fc->ps.sps->vshift[c_idx];
+for (c_idx = 0; c_idx < (sps->r->sps_chroma_format_idc ? 3 : 1); c_idx++) {
 ptrdiff_t src_stride = fc->frame->linesize[c_idx];
-int ctb_size_h = ctb_size_y >> fc->ps.sps->hshift[c_idx];
-int ctb_size_v = ctb_size_y >> fc->ps.sps->vshift[c_idx];
-int width= FFMIN(ctb_size_h, (fc->ps.pps->width  >> 
fc->ps.sps->hshift[c_idx]) - x0);
-int height   = FFMIN(ctb_size_v, (fc->ps.pps->height >> 
fc->ps.sps->vshift[c_idx]) - y0);
+const int width  = FFMIN(sps->ctb_size_y, fc->ps.pps->width - x0) >> 
sps->hshift[c_idx];
+const int height = FFMIN(sps->ctb_size_y, fc->ps.pps->height - y0) >> 
sps->vshift[c_idx];
 int tab  = sao_tab[(FFALIGN(width, 8) >> 3) - 1];
-uint8_t *src = POS(c_idx, x, y);
+uint8_t *src = POS(c_idx, x0, y0);
 
 switch (sao->type_idx[c_idx]) {
 case SAO_BAND:
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 06/18] avcodec/vvcdec: refact, unify ff_vvc_deblock_{horizontal, vertical}

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/filter.c | 153 
 1 file changed, 44 insertions(+), 109 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 82a58a7ea8..89b794195e 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -712,144 +712,79 @@ static int get_qp(const VVCFrameContext *fc, const 
uint8_t *src, const int x, co
 return get_qp_c(fc, x, y, c_idx, vertical);
 }
 
-void ff_vvc_deblock_vertical(const VVCLocalContext *lc, const int x0, const 
int y0, const int rs)
+static void vvc_deblock(const VVCLocalContext *lc, int x0, int y0, const int 
rs, const int vertical)
 {
-VVCFrameContext *fc = lc->fc;
-const VVCSPS *sps   = fc->ps.sps;
-const int c_end = sps->r->sps_chroma_format_idc ? 
VVC_MAX_SAMPLE_ARRAYS : 1;
-uint8_t *src;
-int x, y, qp;
+VVCFrameContext *fc= lc->fc;
+const VVCSPS *sps  = fc->ps.sps;
+const int c_end= sps->r->sps_chroma_format_idc ? 
VVC_MAX_SAMPLE_ARRAYS : 1;
+const int ctb_size = fc->ps.sps->ctb_size_y;
+const DBParams *params = fc->tab.deblock + rs;
+int x_end  = FFMIN(x0 + ctb_size, fc->ps.pps->width);
+int y_end  = FFMIN(y0 + ctb_size, fc->ps.pps->height);
 
 //not use this yet, may needed by plt.
-const uint8_t no_p[4] = { 0 };
-const uint8_t no_q[4] = { 0 } ;
-
-const int ctb_log2_size_y = fc->ps.sps->ctb_log2_size_y;
-int x_end, y_end;
-const int ctb_size = 1 << ctb_log2_size_y;
-const DBParams *params = fc->tab.deblock + rs;
+const uint8_t no_p[4]  = { 0 };
+const uint8_t no_q[4]  = { 0 } ;
 
-vvc_deblock_bs(lc, x0, y0, rs, 1);
+vvc_deblock_bs(lc, x0, y0, rs, vertical);
 
-x_end = x0 + ctb_size;
-if (x_end > fc->ps.pps->width)
-x_end = fc->ps.pps->width;
-y_end = y0 + ctb_size;
-if (y_end > fc->ps.pps->height)
-y_end = fc->ps.pps->height;
+if (!vertical) {
+FFSWAP(int, x_end, y_end);
+FFSWAP(int, x0, y0);
+}
 
 for (int c_idx = 0; c_idx < c_end; c_idx++) {
-const int hs  = sps->hshift[c_idx];
-const int vs  = sps->vshift[c_idx];
+const int hs  = (vertical ? sps->hshift : sps->vshift)[c_idx];
+const int vs  = (vertical ? sps->vshift : sps->hshift)[c_idx];
 const int grid= c_idx ? (CHROMA_GRID << hs) : LUMA_GRID;
 const int tc_offset   = params->tc_offset[c_idx];
 const int beta_offset = params->beta_offset[c_idx];
+const int src_stride  = fc->frame->linesize[c_idx];
 
-for (y = y0; y < y_end; y += (DEBLOCK_STEP << vs)) {
-for (x = x0 ? x0 : grid; x < x_end; x += grid) {
-int32_t bs[4], beta[4], tc[4], all_zero_bs = 1;
+for (int y = y0; y < y_end; y += (DEBLOCK_STEP << vs)) {
+for (int x = x0 ? x0 : grid; x < x_end; x += grid) {
+const uint8_t horizontal_ctu_edge = !vertical && !(x % 
ctb_size);
+int32_t bs[4], beta[4], tc[4] = { }, all_zero_bs = 1;
 uint8_t max_len_p[4], max_len_q[4];
 
 for (int i = 0; i < DEBLOCK_STEP >> (2 - vs); i++) {
-const int dy = i << 2;
-bs[i] = (y + dy < y_end) ? TAB_BS(fc->tab.bs[1][c_idx], x, 
y + dy) : 0;
-if (bs[i]) {
-src = POS(c_idx, x, y + dy);
-qp = get_qp(fc, src, x, y + dy, c_idx, 1);
+int tx = x;
+int ty = y + (i << 2);
+const int end  = ty >= y_end;
 
-beta[i] = betatable[av_clip(qp + beta_offset, 0, 
MAX_QP)];
+if (!vertical)
+FFSWAP(int, tx, ty);
 
-max_filter_length(fc, x, y + dy, c_idx, 1, 0, bs[i], 
_len_p[i], _len_q[i]);
+bs[i] = end ? 0 : TAB_BS(fc->tab.bs[vertical][c_idx], tx, 
ty);
+if (bs[i]) {
+const int qp = get_qp(fc, POS(c_idx, tx, ty), tx, ty, 
c_idx, vertical);
+beta[i] = betatable[av_clip(qp + beta_offset, 0, 
MAX_QP)];
+tc[i] = TC_CALC(qp, bs[i]) ;
+max_filter_length(fc, tx, ty, c_idx, vertical, 
horizontal_ctu_edge, bs[i], _len_p[i], _len_q[i]);
 all_zero_bs = 0;
 }
-tc[i] = bs[i] ? TC_CALC(qp, bs[i]) : 0;
 }
 
 if (!all_zero_bs) {
-src = POS(c_idx, x, y);
-if (!c_idx) {
-fc->vvcdsp.lf.filter_luma[1](src, 
fc->frame->linesize[c_idx],
-beta, tc, no_p, no_q, max_len_p, max_len_q, 0);
-} else {
-fc->vvcdsp.lf.filter_chroma[1](src, 
fc->frame->linesize[c_idx],
-beta, tc, 

[FFmpeg-devel] [PATCH 07/18] avcodec/vvcdec: refact out sao_get_edges

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/filter.c | 119 ++--
 1 file changed, 65 insertions(+), 54 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 89b794195e..1326d2c82e 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -155,70 +155,81 @@ void ff_vvc_sao_copy_ctb_to_hv(VVCLocalContext *lc, const 
int rx, const int ry,
 sao_copy_ctb_to_hv(lc, rx, ry, 0);
 }
 
+static int sao_can_cross_slices(const VVCFrameContext *fc, const int rx, const 
int ry, const int dx, const int dy)
+{
+const uint8_t lfase = 
fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag;
+
+return lfase || CTB(fc->tab.slice_idx, rx, ry) == CTB(fc->tab.slice_idx, 
rx + dx, ry + dy);
+}
+
+static void sao_get_edges(uint8_t vert_edge[2], uint8_t horiz_edge[2], uint8_t 
diag_edge[4], int *restore,
+const VVCLocalContext *lc, const int edges[4], const int rx, const int ry)
+{
+const VVCFrameContext *fc  = lc->fc;
+const VVCSPS *sps  = fc->ps.sps;
+const H266RawSPS *rsps = sps->r;
+const VVCPPS *pps  = fc->ps.pps;
+const int subpic_idx   = lc->sc->sh.r->curr_subpic_idx;
+const uint8_t lfase= 
fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag;
+const uint8_t no_tile_filter   = pps->r->num_tiles_in_pic > 1 && 
!pps->r->pps_loop_filter_across_tiles_enabled_flag;
+const uint8_t no_subpic_filter = rsps->sps_num_subpics_minus1 && 
!rsps->sps_loop_filter_across_subpic_enabled_flag[subpic_idx];
+uint8_t lf_edge[] = { 0, 0, 0, 0 };
+
+*restore = no_subpic_filter || no_tile_filter || !lfase;
+
+if (!*restore)
+return;
+
+if (!edges[LEFT]) {
+lf_edge[LEFT]  = no_tile_filter && pps->ctb_to_col_bd[rx] == rx;
+lf_edge[LEFT] |= no_subpic_filter && 
rsps->sps_subpic_ctu_top_left_x[subpic_idx] == rx;
+vert_edge[0]   = !sao_can_cross_slices(fc, rx, ry, -1, 0) || 
lf_edge[LEFT];
+}
+if (!edges[RIGHT]) {
+lf_edge[RIGHT]  = no_tile_filter && pps->ctb_to_col_bd[rx] != 
pps->ctb_to_col_bd[rx + 1];
+lf_edge[RIGHT] |= no_subpic_filter && 
rsps->sps_subpic_ctu_top_left_x[subpic_idx] + 
rsps->sps_subpic_width_minus1[subpic_idx] == rx;
+vert_edge[1]= !sao_can_cross_slices(fc, rx, ry, 1, 0) || 
lf_edge[RIGHT];
+}
+if (!edges[TOP]) {
+lf_edge[TOP]   = no_tile_filter && pps->ctb_to_row_bd[ry] == ry;
+lf_edge[TOP]  |= no_subpic_filter && 
rsps->sps_subpic_ctu_top_left_y[subpic_idx] == ry;
+horiz_edge[0]  = !sao_can_cross_slices(fc, rx, ry, 0, -1) || 
lf_edge[TOP];
+}
+if (!edges[BOTTOM]) {
+lf_edge[BOTTOM]  = no_tile_filter && pps->ctb_to_row_bd[ry] != 
pps->ctb_to_row_bd[ry + 1];
+lf_edge[BOTTOM] |= no_subpic_filter && 
rsps->sps_subpic_ctu_top_left_y[subpic_idx] + 
rsps->sps_subpic_height_minus1[subpic_idx] == ry;
+horiz_edge[1]= !sao_can_cross_slices(fc, rx, ry, 0, 1) || 
lf_edge[BOTTOM];
+}
+
+if (!edges[LEFT] && !edges[TOP])
+diag_edge[0] = !sao_can_cross_slices(fc, rx, ry, -1, -1) || 
lf_edge[LEFT] || lf_edge[TOP];
+
+if (!edges[TOP] && !edges[RIGHT])
+diag_edge[1] = !sao_can_cross_slices(fc, rx, ry,  1, -1) || 
lf_edge[RIGHT] || lf_edge[TOP];
+
+if (!edges[RIGHT] && !edges[BOTTOM])
+diag_edge[2] = !sao_can_cross_slices(fc, rx, ry,  1,  1) || 
lf_edge[RIGHT] || lf_edge[BOTTOM];
+
+if (!edges[LEFT] && !edges[BOTTOM])
+diag_edge[3] = !sao_can_cross_slices(fc, rx, ry, -1,  1) || 
lf_edge[LEFT] || lf_edge[BOTTOM];
+}
+
 void ff_vvc_sao_filter(VVCLocalContext *lc, int x, int y)
 {
 VVCFrameContext *fc  = lc->fc;
 const int ctb_size_y = fc->ps.sps->ctb_size_y;
 static const uint8_t sao_tab[16] = { 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 
7, 7, 8, 8 };
-int c_idx;
+int c_idx, restore;
 const int rx = x >> fc->ps.sps->ctb_log2_size_y;
 const int ry = y >> fc->ps.sps->ctb_log2_size_y;
 int edges[4] = { !rx, !ry, rx == fc->ps.pps->ctb_width - 1, ry == 
fc->ps.pps->ctb_height - 1 };
 const SAOParams *sao = (fc->tab.sao, rx, ry);
 // flags indicating unfilterable edges
-uint8_t vert_edge[]  = { 0, 0 };
-uint8_t horiz_edge[] = { 0, 0 };
-uint8_t diag_edge[]  = { 0, 0, 0, 0 };
-uint8_t tile_edge[]  = { 0, 0, 0, 0 };
-uint8_t subpic_edge[]= { 0, 0, 0, 0 };
-const int subpic_idx = lc->sc->sh.r->curr_subpic_idx;
-const uint8_t lfase  = 
fc->ps.pps->r->pps_loop_filter_across_slices_enabled_flag;
-const uint8_t no_tile_filter = fc->ps.pps->r->num_tiles_in_pic > 1 &&
-   
!fc->ps.pps->r->pps_loop_filter_across_tiles_enabled_flag;
-const uint8_t no_subpic_filter = fc->ps.sps->r->sps_num_subpics_minus1 &&
-!fc->ps.sps->r->sps_loop_filter_across_subpic_enabled_flag[subpic_idx];
-const uint8_t restore= 

[FFmpeg-devel] [PATCH 05/18] avcodec/vvcdec: misc, use POS to simplify filter code

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/filter.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 7ae36b2344..82a58a7ea8 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -34,6 +34,10 @@
 
 #define DEFAULT_INTRA_TC_OFFSET 2
 
+#define POS(c_idx, x, y)   
 \
+>frame->data[c_idx][((y) >> fc->ps.sps->vshift[c_idx]) * 
fc->frame->linesize[c_idx] +   \
+(((x) >> fc->ps.sps->hshift[c_idx]) << fc->ps.sps->pixel_shift)]
+
 //Table 43 Derivation of threshold variables beta' and tc' from input Q
 static const uint16_t tctable[66] = {
   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 
  0,
@@ -135,7 +139,7 @@ static void sao_copy_ctb_to_hv(VVCLocalContext *lc, const 
int rx, const int ry,
 const int ctb_size_v   = ctb_size_y >> fc->ps.sps->vshift[c_idx];
 const int width= FFMIN(ctb_size_h, (fc->ps.pps->width  >> 
fc->ps.sps->hshift[c_idx]) - x);
 const int height   = FFMIN(ctb_size_v, (fc->ps.pps->height >> 
fc->ps.sps->vshift[c_idx]) - y);
-const uint8_t *src  = >frame->data[c_idx][y * src_stride + 
(x << fc->ps.sps->pixel_shift)];
+const uint8_t *src = POS(c_idx, x0, y0);
 copy_ctb_to_hv(fc, src, src_stride, x, y, width, height, c_idx, rx, 
ry, top);
 }
 }
@@ -225,7 +229,7 @@ void ff_vvc_sao_filter(VVCLocalContext *lc, int x, int y)
 int width= FFMIN(ctb_size_h, (fc->ps.pps->width  >> 
fc->ps.sps->hshift[c_idx]) - x0);
 int height   = FFMIN(ctb_size_v, (fc->ps.pps->height >> 
fc->ps.sps->vshift[c_idx]) - y0);
 int tab  = sao_tab[(FFALIGN(width, 8) >> 3) - 1];
-uint8_t *src = >frame->data[c_idx][y0 * src_stride + (x0 << 
fc->ps.sps->pixel_shift)];
+uint8_t *src = POS(c_idx, x, y);
 ptrdiff_t dst_stride;
 uint8_t *dst;
 
@@ -750,7 +754,7 @@ void ff_vvc_deblock_vertical(const VVCLocalContext *lc, 
const int x0, const int
 const int dy = i << 2;
 bs[i] = (y + dy < y_end) ? TAB_BS(fc->tab.bs[1][c_idx], x, 
y + dy) : 0;
 if (bs[i]) {
-src = >frame->data[c_idx][((y + dy) >> vs) * 
fc->frame->linesize[c_idx] + ((x >> hs) << fc->ps.sps->pixel_shift)];
+src = POS(c_idx, x, y + dy);
 qp = get_qp(fc, src, x, y + dy, c_idx, 1);
 
 beta[i] = betatable[av_clip(qp + beta_offset, 0, 
MAX_QP)];
@@ -762,7 +766,7 @@ void ff_vvc_deblock_vertical(const VVCLocalContext *lc, 
const int x0, const int
 }
 
 if (!all_zero_bs) {
-src = >frame->data[c_idx][(y >> vs) * 
fc->frame->linesize[c_idx] + ((x >> hs) << fc->ps.sps->pixel_shift)];
+src = POS(c_idx, x, y);
 if (!c_idx) {
 fc->vvcdsp.lf.filter_luma[1](src, 
fc->frame->linesize[c_idx],
 beta, tc, no_p, no_q, max_len_p, max_len_q, 0);
@@ -823,7 +827,7 @@ void ff_vvc_deblock_horizontal(const VVCLocalContext *lc, 
const int x0, const in
 
 bs[i] = (x + dx < x_end) ? TAB_BS(fc->tab.bs[0][c_idx], x 
+ dx, y) : 0;
 if (bs[i]) {
-src = >frame->data[c_idx][(y >> vs) * 
fc->frame->linesize[c_idx] + (((x + dx)>> hs) << fc->ps.sps->pixel_shift)];
+src = POS(c_idx, x + dx, y);
 qp = get_qp(fc, src, x + dx, y, c_idx, 0);
 
 beta[i] = betatable[av_clip(qp + beta_offset, 0, 
MAX_QP)];
@@ -834,7 +838,7 @@ void ff_vvc_deblock_horizontal(const VVCLocalContext *lc, 
const int x0, const in
 tc[i] = bs[i] ? TC_CALC(qp, bs[i]) : 0;
 }
 if (!all_zero_bs) {
-src = >frame->data[c_idx][(y >> vs) * 
fc->frame->linesize[c_idx] + ((x >> hs) << fc->ps.sps->pixel_shift)];
+src = POS(c_idx, x, y);
 if (!c_idx) {
 fc->vvcdsp.lf.filter_luma[0](src, 
fc->frame->linesize[c_idx],
 beta, tc, no_p, no_q, max_len_p, max_len_q, 
horizontal_ctu_edge);
@@ -1079,7 +1083,6 @@ void ff_vvc_alf_copy_ctu_to_hv(VVCLocalContext* lc, const 
int x0, const int y0)
 const int rx = x0 >> fc->ps.sps->ctb_log2_size_y;
 const int ry = y0 >> fc->ps.sps->ctb_log2_size_y;
 const int ctb_size_y = fc->ps.sps->ctb_size_y;
-const int ps = fc->ps.sps->pixel_shift;
 const int c_end  = fc->ps.sps->r->sps_chroma_format_idc ? 
VVC_MAX_SAMPLE_ARRAYS : 1;
 
 for (int c_idx = 0; c_idx < c_end; c_idx++) {
@@ -1091,7 +1094,7 @@ void ff_vvc_alf_copy_ctu_to_hv(VVCLocalContext* lc, const 
int x0, const int y0)
 const int height = FFMIN(fc->ps.pps->height - 

[FFmpeg-devel] [PATCH 04/18] avcodec/vvcdec: refact, unify {horizontal, vertical}_bs, {horizontal, vertical}_p, {horizontal, vertical}_q

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/dec.c| 14 +++---
 libavcodec/vvc/dec.h|  9 +++--
 libavcodec/vvc/filter.c | 32 +++-
 3 files changed, 21 insertions(+), 34 deletions(-)

diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
index f5603306f3..356ed58e37 100644
--- a/libavcodec/vvc/dec.c
+++ b/libavcodec/vvc/dec.c
@@ -191,14 +191,14 @@ static void bs_tl_init(TabList *l, VVCFrameContext *fc)
 
 tl_init(l, 1, changed);
 
-for (int i = 0; i < VVC_MAX_SAMPLE_ARRAYS; i++) {
-TL_ADD(horizontal_bs[i], bs_count);
-TL_ADD(vertical_bs[i],   bs_count);
+for (int i = 0; i < 2; i++) {
+for (int j = 0; j < VVC_MAX_SAMPLE_ARRAYS; j++) {
+TL_ADD(bs[i][j], bs_count);
+TL_ADD(bs[i][j],   bs_count);
+}
+TL_ADD(max_len_p[i], bs_count);
+TL_ADD(max_len_q[i], bs_count);
 }
-TL_ADD(horizontal_q, bs_count);
-TL_ADD(horizontal_p, bs_count);
-TL_ADD(vertical_p,   bs_count);
-TL_ADD(vertical_q,   bs_count);
 }
 
 static void pixel_buffer_nz_tl_init(TabList *l, VVCFrameContext *fc)
diff --git a/libavcodec/vvc/dec.h b/libavcodec/vvc/dec.h
index 1e0b76f283..a8492f1398 100644
--- a/libavcodec/vvc/dec.h
+++ b/libavcodec/vvc/dec.h
@@ -178,12 +178,9 @@ typedef struct VVCFrameContext {
 uint8_t *tb_height[2];
 uint8_t *pcmf[2];
 
-uint8_t *horizontal_bs[VVC_MAX_SAMPLE_ARRAYS];
-uint8_t *vertical_bs[VVC_MAX_SAMPLE_ARRAYS];
-uint8_t *horizontal_p;  ///< horizontal 
maxFilterLengthPs for luma
-uint8_t *horizontal_q;  ///< horizontal 
maxFilterLengthQs for luma
-uint8_t *vertical_p;///< vertical   
maxFilterLengthPs for luma
-uint8_t *vertical_q;///< vertical   
maxFilterLengthQs for luma
+uint8_t *bs[2][VVC_MAX_SAMPLE_ARRAYS];  ///< horizontal, 
vertical boundary filtering strength
+uint8_t *max_len_p[2];  ///< horizontal, 
vertical maxFilterLengthPs for luma
+uint8_t *max_len_q[2];  ///< horizontal, 
vertical maxFilterLengthQs for luma
 
 uint8_t *sao_pixel_buffer_h[VVC_MAX_SAMPLE_ARRAYS];
 uint8_t *sao_pixel_buffer_v[VVC_MAX_SAMPLE_ARRAYS];
diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 06e1717b13..7ae36b2344 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -414,9 +414,6 @@ static void vvc_deblock_subblock_bs(const VVCLocalContext 
*lc,
 const RefPicList *rpl  = lc->sc->rpl;
 int stridea= fc->ps.pps->min_pu_width;
 int strideb= 1;
-uint8_t *tab_bs= vertical ? fc->tab.vertical_bs[LUMA] : 
fc->tab.horizontal_bs[LUMA];
-uint8_t *tab_max_len_p = vertical ? fc->tab.vertical_p : 
fc->tab.horizontal_p;
-uint8_t *tab_max_len_q = vertical ? fc->tab.vertical_q : 
fc->tab.horizontal_q;
 const int log2_min_pu_size = MIN_PU_LOG2;
 
 if (!vertical) {
@@ -442,7 +439,7 @@ static void vvc_deblock_subblock_bs(const VVCLocalContext 
*lc,
 if (!vertical)
 FFSWAP(int, x, y);
 
-TAB_BS(tab_bs, x, y) = bs;
+TAB_BS(fc->tab.bs[vertical][LUMA], x, y) = bs;
 
 if (i == 4 || i == width - 4)
 max_len_p = max_len_q = 1;
@@ -451,8 +448,8 @@ static void vvc_deblock_subblock_bs(const VVCLocalContext 
*lc,
 else
 max_len_p = max_len_q = 3;
 
-TAB_MAX_LEN(tab_max_len_p, x, y) = max_len_p;
-TAB_MAX_LEN(tab_max_len_q, x, y) = max_len_q;
+TAB_MAX_LEN(fc->tab.max_len_p[vertical], x, y) = max_len_p;
+TAB_MAX_LEN(fc->tab.max_len_q[vertical], x, y) = max_len_q;
 }
 }
 }
@@ -562,9 +559,6 @@ static void vvc_deblock_bs_luma(const VVCLocalContext *lc,
 const int flag  = vertical ? BOUNDARY_LEFT_SLICE : 
BOUNDARY_UPPER_SLICE;
 const RefPicList *rpl_p =
 (lc->boundary_flags & flag) ? ff_vvc_get_ref_list(fc, fc->ref, x0 
- vertical, y0 - !vertical) : lc->sc->rpl;
-uint8_t *tab_bs = vertical ? fc->tab.vertical_bs[LUMA] : 
fc->tab.horizontal_bs[LUMA];
-uint8_t *tab_max_len_p  = vertical ? fc->tab.vertical_p : 
fc->tab.horizontal_p;
-uint8_t *tab_max_len_q  = vertical ? fc->tab.vertical_q : 
fc->tab.horizontal_q;
 
 for (int i = 0; i < size; i += 4) {
 const int x = x0 + i * !vertical;
@@ -572,11 +566,11 @@ static void vvc_deblock_bs_luma(const VVCLocalContext *lc,
 uint8_t max_len_p, max_len_q;
 const int bs = deblock_bs(lc, x - vertical, y - !vertical, x, y, 
rpl_p, LUMA, off, has_sb);
 
-TAB_BS(tab_bs, x, y) = bs;
+TAB_BS(fc->tab.bs[vertical][LUMA], x, y) = bs;
 
 derive_max_filter_length_luma(fc, x, y, is_intra, has_sb, 
vertical, _len_p, _len_q);
- 

[FFmpeg-devel] [PATCH 15/18] avcodec/vvcdec: ps, derive virtual boundaries

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/ps.c | 45 +
 libavcodec/vvc/ps.h |  6 ++
 2 files changed, 51 insertions(+)

diff --git a/libavcodec/vvc/ps.c b/libavcodec/vvc/ps.c
index 92368eafc2..58496c9fba 100644
--- a/libavcodec/vvc/ps.c
+++ b/libavcodec/vvc/ps.c
@@ -796,8 +796,49 @@ static int ph_max_num_subblock_merge_cand(const H266RawSPS 
*sps, const H266RawPi
 return sps->sps_sbtmvp_enabled_flag && ph->ph_temporal_mvp_enabled_flag;
 }
 
+static int ph_vb_pos(uint16_t *vbs, uint8_t *num_vbs, const uint16_t 
*pos_minus_1, const uint8_t num_pos, uint16_t max, const int ctb_size_y)
+{
+max = FF_CEIL_RSHIFT(max, 3) - 2;
+for (int i = 0; i < num_pos; i++) {
+if (pos_minus_1[i] > max)
+return AVERROR_INVALIDDATA;
+
+vbs[i] = (pos_minus_1[i] + 1) << 3;
+
+// The distance between any two vertical virtual boundaries shall be 
greater than or equal to CtbSizeY luma samples
+if (i && vbs[i] < vbs[i - 1] + ctb_size_y)
+return AVERROR_INVALIDDATA;
+}
+*num_vbs = num_pos;
+
+return 0;
+}
+
+#define VBF(f) (sps->sps_virtual_boundaries_present_flag ? sps->sps_##f : 
ph->r->ph_##f)
+#define VBFS(c, d) VBF(virtual_boundary_pos_##c##_minus1), 
VBF(num_##d##_virtual_boundaries)
+
+static int ph_vb(VVCPH *ph, const H266RawSPS *sps, const H266RawPPS *pps)
+{
+const int ctb_size_y = 1 << (sps->sps_log2_ctu_size_minus5 + 5);
+int ret;
+
+if (!sps->sps_virtual_boundaries_enabled_flag)
+return 0;
+
+ret = ph_vb_pos(ph->vb_pos_x, >num_ver_vbs, VBFS(x, ver), 
pps->pps_pic_width_in_luma_samples, ctb_size_y);
+if (ret < 0)
+return ret;
+
+ret = ph_vb_pos(ph->vb_pos_y, >num_hor_vbs, VBFS(y, hor), 
pps->pps_pic_height_in_luma_samples, ctb_size_y);
+if (ret < 0)
+return ret;
+
+return 0;
+}
+
 static int ph_derive(VVCPH *ph, const H266RawSPS *sps, const H266RawPPS *pps, 
const int poc_tid0, const int is_clvss)
 {
+int ret;
 ph->max_num_subblock_merge_cand = ph_max_num_subblock_merge_cand(sps, 
ph->r);
 
 ph->poc = ph_compute_poc(ph->r, sps, poc_tid0, is_clvss);
@@ -805,6 +846,10 @@ static int ph_derive(VVCPH *ph, const H266RawSPS *sps, 
const H266RawPPS *pps, co
 if (pps->pps_wp_info_in_ph_flag)
 pred_weight_table(>pwt, >r->ph_pred_weight_table);
 
+ret = ph_vb(ph, sps, pps);
+if (ret < 0)
+return ret;
+
 return 0;
 }
 
diff --git a/libavcodec/vvc/ps.h b/libavcodec/vvc/ps.h
index 6656a06320..9203e2c57f 100644
--- a/libavcodec/vvc/ps.h
+++ b/libavcodec/vvc/ps.h
@@ -151,6 +151,12 @@ typedef struct VVCPH {
 //derived values
 uint32_t max_num_subblock_merge_cand;   ///< 
MaxNumSubblockMergeCand
 int32_t  poc;   ///< PicOrderCntVal
+
+uint8_t  num_ver_vbs;   ///< 
NumVerVirtualBoundaries
+uint16_t vb_pos_x[VVC_MAX_VBS]; ///< VirtualBoundaryPosX
+uint8_t  num_hor_vbs;   ///< 
NumHorVirtualBoundaries
+uint16_t vb_pos_y[VVC_MAX_VBS]; ///< VirtualBoundaryPosY
+
 PredWeightTable pwt;
 } VVCPH;
 
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 02/18] avcodec/vvcdec: refact, unify vvc_deblock_bs_luma_{horizontal, vertical}

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/filter.c | 108 ++--
 1 file changed, 36 insertions(+), 72 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index d4c09b69f3..996e58dc3e 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -538,100 +538,64 @@ static int deblock_is_boundary(const VVCLocalContext 
*lc, const int boundary,
 return boundary;
 }
 
-static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc,
-const int x0, const int y0, const int width, const int height, const int 
rs)
+static void vvc_deblock_bs_luma(const VVCLocalContext *lc,
+const int x0, const int y0, const int width, const int height, const int 
rs, const int vertical)
 {
 const VVCFrameContext *fc  = lc->fc;
 const MvField *tab_mvf = fc->tab.mvf;
+const int mask = LUMA_GRID - 1;
 const int log2_min_pu_size = MIN_PU_LOG2;
 const int min_pu_width = fc->ps.pps->min_pu_width;
 const int min_cb_log2  = fc->ps.sps->min_cb_log2_size_y;
 const int min_cb_width = fc->ps.pps->min_cb_width;
-const int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * 
min_pu_width +
-(x0 >> log2_min_pu_size)].pred_flag == PF_INTRA;
-int boundary_left;
-int has_vertical_sb = 0;
-
+const int pos  = vertical ? x0 : y0;
 const int off_q= (y0 >> min_cb_log2) * min_cb_width + (x0 >> 
min_cb_log2);
-const int cb_x = fc->tab.cb_pos_x[LUMA][off_q];
-const int cb_width = fc->tab.cb_width[LUMA][off_q];
-const int off_x= cb_x - x0;
-
-if (!is_intra) {
-if (fc->tab.msf[off_q] || fc->tab.iaf[off_q])
-has_vertical_sb = cb_width  > 8;
-}
-
-// bs for vertical TU boundaries
-boundary_left = deblock_is_boundary(lc, x0 > 0 && !(x0 & 3), x0, rs, 1);
-
-if (boundary_left) {
-const RefPicList *rpl_left =
-(lc->boundary_flags & BOUNDARY_LEFT_SLICE) ? 
ff_vvc_get_ref_list(fc, fc->ref, x0 - 1, y0) : lc->sc->rpl;
-for (int i = 0; i < height; i += 4) {
+const int cb   = (vertical ? fc->tab.cb_pos_x : 
fc->tab.cb_pos_y )[LUMA][off_q];
+const int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * 
min_pu_width +
+(x0 >> log2_min_pu_size)].pred_flag == PF_INTRA;
+
+if (deblock_is_boundary(lc, pos > 0 && !(pos & mask), pos, rs, vertical)) {
+const int size  = vertical ? height : width;
+const int off   = cb - pos;
+const int cb_size   = (vertical ? fc->tab.cb_width : 
fc->tab.cb_height)[LUMA][off_q];
+const int has_sb= !is_intra && (fc->tab.msf[off_q] || 
fc->tab.iaf[off_q]) && cb_size > 8;
+const int flag  = vertical ? BOUNDARY_LEFT_SLICE : 
BOUNDARY_UPPER_SLICE;
+const RefPicList *rpl_p =
+(lc->boundary_flags & flag) ? ff_vvc_get_ref_list(fc, fc->ref, x0 
- vertical, y0 - !vertical) : lc->sc->rpl;
+uint8_t *tab_bs = vertical ? fc->tab.vertical_bs[LUMA] : 
fc->tab.horizontal_bs[LUMA];
+uint8_t *tab_max_len_p  = vertical ? fc->tab.vertical_p : 
fc->tab.horizontal_p;
+uint8_t *tab_max_len_q  = vertical ? fc->tab.vertical_q : 
fc->tab.horizontal_q;
+
+for (int i = 0; i < size; i += 4) {
+const int x = x0 + i * !vertical;
+const int y = y0 + i * vertical;
 uint8_t max_len_p, max_len_q;
-const int bs = deblock_bs(lc, x0 - 1, y0 + i, x0, y0 + i, 
rpl_left, 0, off_x, has_vertical_sb);
+const int bs = deblock_bs(lc, x - vertical, y - !vertical, x, y, 
rpl_p, LUMA, off, has_sb);
 
-TAB_BS(fc->tab.vertical_bs[LUMA], x0, (y0 + i)) = bs;
+TAB_BS(tab_bs, x, y) = bs;
 
-derive_max_filter_length_luma(fc, x0, y0 + i, is_intra, 
has_vertical_sb, 1, _len_p, _len_q);
-TAB_MAX_LEN(fc->tab.vertical_p, x0, y0 + i) = max_len_p;
-TAB_MAX_LEN(fc->tab.vertical_q, x0, y0 + i) = max_len_q;
+derive_max_filter_length_luma(fc, x, y, is_intra, has_sb, 
vertical, _len_p, _len_q);
+TAB_MAX_LEN(tab_max_len_p, x, y) = max_len_p;
+TAB_MAX_LEN(tab_max_len_q, x, y) = max_len_q;
 }
 }
 
 if (!is_intra) {
 if (fc->tab.msf[off_q] || fc->tab.iaf[off_q])
-vvc_deblock_subblock_bs(lc, cb_x, x0, y0, width, height, 1);
+vvc_deblock_subblock_bs(lc, cb, x0, y0, width, height, vertical);
 }
 }
 
-static void vvc_deblock_bs_luma_horizontal(const VVCLocalContext *lc,
+static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc,
 const int x0, const int y0, const int width, const int height, const int 
rs)
 {
-const VVCFrameContext *fc  = lc->fc;
-const MvField *tab_mvf = fc->tab.mvf;
-const int log2_min_pu_size = MIN_PU_LOG2;
-const int min_pu_width = fc->ps.pps->min_pu_width;
-const int min_cb_log2  = 

[FFmpeg-devel] [PATCH 03/18] avcodec/vvcdec: refact, unify vvc_deblock_bs_chroma_{horizontal, vertical}

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/filter.c | 62 +
 1 file changed, 19 insertions(+), 43 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 996e58dc3e..06e1717b13 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -586,56 +586,33 @@ static void vvc_deblock_bs_luma(const VVCLocalContext *lc,
 }
 }
 
-static void vvc_deblock_bs_luma_vertical(const VVCLocalContext *lc,
-const int x0, const int y0, const int width, const int height, const int 
rs)
-{
-vvc_deblock_bs_luma(lc, x0, y0, width, height, rs, 1);
-}
-
-static void vvc_deblock_bs_luma_horizontal(const VVCLocalContext *lc,
-const int x0, const int y0, const int width, const int height, const int 
rs)
-{
-vvc_deblock_bs_luma(lc, x0, y0, width, height, rs, 0);
-}
-
-static void vvc_deblock_bs_chroma_vertical(const VVCLocalContext *lc,
-const int x0, const int y0, const int width, const int height, const int 
rs)
+static void vvc_deblock_bs_chroma(const VVCLocalContext *lc,
+const int x0, const int y0, const int width, const int height, const int 
rs, const int vertical)
 {
 const VVCFrameContext *fc = lc->fc;
-const int boundary_left = deblock_is_boundary(lc,
- x0 > 0 && !(x0 & ((CHROMA_GRID << fc->ps.sps->hshift[CHROMA]) - 1)), 
x0, rs, 1);
-
-if (boundary_left) {
-for (int i = 0; i < height; i += 2) {
-for (int c_idx = CB; c_idx <= CR; c_idx++) {
-const int bs = deblock_bs(lc, x0 - 1, y0 + i, x0, y0 + i, 
NULL, c_idx, 0, 0);
+const int shift   = (vertical ? fc->ps.sps->hshift : 
fc->ps.sps->vshift)[CHROMA];
+const int mask= (CHROMA_GRID << shift) - 1;
+const int pos = vertical ? x0 : y0;
 
-TAB_BS(fc->tab.vertical_bs[c_idx], x0, (y0 + i)) = bs;
-}
-}
-}
-}
+if (deblock_is_boundary(lc, pos > 0 && !(pos & mask), pos, rs, vertical)) {
+const int size = vertical ? height : width;
 
-static void vvc_deblock_bs_chroma_horizontal(const VVCLocalContext *lc,
-const int x0, const int y0, const int width, const int height, const int 
rs)
-{
-const VVCFrameContext *fc = lc->fc;
-const int boundary_upper  = deblock_is_boundary(lc,
-y0 > 0 && !(y0 & ((CHROMA_GRID << fc->ps.sps->vshift[CHROMA]) - 1)), 
y0, rs, 0);
+for (int c_idx = CB; c_idx <= CR; c_idx++) {
+uint8_t *tab_bs = (vertical ? fc->tab.vertical_bs : 
fc->tab.horizontal_bs)[c_idx];
 
-if (boundary_upper) {
-for (int i = 0; i < width; i += 2) {
-for (int c_idx = CB; c_idx <= CR; c_idx++) {
-const int bs = deblock_bs(lc, x0 + i, y0 - 1, x0 + i, y0, 
NULL, c_idx, 0, 0);
+for (int i = 0; i < size; i += 2) {
+const int x  = x0 + i * !vertical;
+const int y  = y0 + i * vertical;
+const int bs = deblock_bs(lc, x - vertical, y - !vertical, x, 
y, NULL, c_idx, 0, 0);
 
-TAB_BS(fc->tab.horizontal_bs[c_idx], x0 + i, y0) = bs;
+TAB_BS(tab_bs, x, y) = bs;
 }
 }
 }
 }
 
 typedef void (*deblock_bs_fn)(const VVCLocalContext *lc, const int x0, const 
int y0,
-const int width, const int height, const int rs);
+const int width, const int height, const int rs, const int vertical);
 
 static void vvc_deblock_bs(const VVCLocalContext *lc, const int x0, const int 
y0, const int rs, const int vertical)
 {
@@ -645,9 +622,8 @@ static void vvc_deblock_bs(const VVCLocalContext *lc, const 
int x0, const int y0
 const int ctb_size = sps->ctb_size_y;
 const int x_end= FFMIN(x0 + ctb_size, pps->width) >> MIN_TU_LOG2;
 const int y_end= FFMIN(y0 + ctb_size, pps->height) >> MIN_TU_LOG2;
-deblock_bs_fn deblock_bs[2][2] = {
-{ vvc_deblock_bs_luma_horizontal, vvc_deblock_bs_chroma_horizontal },
-{ vvc_deblock_bs_luma_vertical,   vvc_deblock_bs_chroma_vertical   }
+deblock_bs_fn deblock_bs[] = {
+vvc_deblock_bs_luma, vvc_deblock_bs_chroma
 };
 
 for (int is_chroma = 0; is_chroma <= 1; is_chroma++) {
@@ -657,8 +633,8 @@ static void vvc_deblock_bs(const VVCLocalContext *lc, const 
int x0, const int y0
 for (int x = x0 >> MIN_TU_LOG2; x < x_end; x++) {
 const int off = y * fc->ps.pps->min_tu_width + x;
 if ((fc->tab.tb_pos_x0[is_chroma][off] >> MIN_TU_LOG2) == x && 
(fc->tab.tb_pos_y0[is_chroma][off] >> MIN_TU_LOG2) == y) {
-deblock_bs[vertical][is_chroma](lc, x << MIN_TU_LOG2, y << 
MIN_TU_LOG2,
-fc->tab.tb_width[is_chroma][off] << hs, 
fc->tab.tb_height[is_chroma][off] << vs, rs);
+deblock_bs[is_chroma](lc, x << MIN_TU_LOG2, y << 
MIN_TU_LOG2,
+fc->tab.tb_width[is_chroma][off] << hs, 
fc->tab.tb_height[is_chroma][off] << vs, rs, vertical);
 }
 }
 }
-- 
2.34.1


[FFmpeg-devel] [PATCH 01/18] avcodec/vvcdec: refact, unify vvc_deblock_subblock_bs_{horizontal, vertical}

2024-06-22 Thread Nuo Mi
---
 libavcodec/vvc/filter.c | 93 ++---
 1 file changed, 32 insertions(+), 61 deletions(-)

diff --git a/libavcodec/vvc/filter.c b/libavcodec/vvc/filter.c
index 7844d34eac..d4c09b69f3 100644
--- a/libavcodec/vvc/filter.c
+++ b/libavcodec/vvc/filter.c
@@ -406,30 +406,43 @@ static void derive_max_filter_length_luma(const 
VVCFrameContext *fc, const int q
 *max_len_p = FFMIN(5, *max_len_p);
 }
 
-static void vvc_deblock_subblock_bs_vertical(const VVCLocalContext *lc,
-const int cb_x, const int cb_y, const int x0, const int y0, const int 
width, const int height)
+static void vvc_deblock_subblock_bs(const VVCLocalContext *lc,
+const int cb, int x0, int y0, int width, int height, const int vertical)
 {
 const VVCFrameContext  *fc = lc->fc;
 const MvField *tab_mvf = fc->tab.mvf;
 const RefPicList *rpl  = lc->sc->rpl;
-const int min_pu_width = fc->ps.pps->min_pu_width;
+int stridea= fc->ps.pps->min_pu_width;
+int strideb= 1;
+uint8_t *tab_bs= vertical ? fc->tab.vertical_bs[LUMA] : 
fc->tab.horizontal_bs[LUMA];
+uint8_t *tab_max_len_p = vertical ? fc->tab.vertical_p : 
fc->tab.horizontal_p;
+uint8_t *tab_max_len_q = vertical ? fc->tab.vertical_q : 
fc->tab.horizontal_q;
 const int log2_min_pu_size = MIN_PU_LOG2;
 
+if (!vertical) {
+FFSWAP(int, x0, y0);
+FFSWAP(int, width, height);
+FFSWAP(int, stridea, strideb);
+}
+
 // bs for TU internal vertical PU boundaries
-for (int j = 0; j < height; j += 4) {
-const int y_pu = (y0 + j) >> log2_min_pu_size;
-
-for (int i = 8 - ((x0 - cb_x) % 8); i < width; i += 8) {
-const int xp_pu = (x0 + i - 1) >> log2_min_pu_size;
-const int xq_pu = (x0 + i) >> log2_min_pu_size;
-const MvField *left = _mvf[y_pu * min_pu_width + xp_pu];
-const MvField *curr = _mvf[y_pu * min_pu_width + xq_pu];
-const int x = x0 + i;
-const int y = y0 + j;
-const int bs = boundary_strength(lc, curr, left, rpl);
+for (int i = 8 - ((x0 - cb) % 8); i < width; i += 8) {
+const int xp_pu = (x0 + i - 1) >> log2_min_pu_size;
+const int xq_pu = (x0 + i) >> log2_min_pu_size;
+
+for (int j = 0; j < height; j += 4) {
+const int y_pu   = (y0 + j) >> log2_min_pu_size;
+const MvField *mvf_p = _mvf[y_pu * stridea + xp_pu * strideb];
+const MvField *mvf_q = _mvf[y_pu * stridea + xq_pu * strideb];
+const int bs = boundary_strength(lc, mvf_q, mvf_p, rpl);
+int x= x0 + i;
+int y= y0 + j;
 uint8_t max_len_p = 0, max_len_q = 0;
 
-TAB_BS(fc->tab.vertical_bs[LUMA], x, y) = bs;
+if (!vertical)
+FFSWAP(int, x, y);
+
+TAB_BS(tab_bs, x, y) = bs;
 
 if (i == 4 || i == width - 4)
 max_len_p = max_len_q = 1;
@@ -438,48 +451,8 @@ static void vvc_deblock_subblock_bs_vertical(const 
VVCLocalContext *lc,
 else
 max_len_p = max_len_q = 3;
 
-TAB_MAX_LEN(fc->tab.vertical_p, x, y) = max_len_p;
-TAB_MAX_LEN(fc->tab.vertical_q, x, y) = max_len_q;
-}
-}
-}
-
-static void vvc_deblock_subblock_bs_horizontal(const VVCLocalContext *lc,
-const int cb_x, const int cb_y, const int x0, const int y0, const int 
width, const int height)
-{
-const VVCFrameContext  *fc = lc->fc;
-const MvField* tab_mvf = fc->tab.mvf;
-const RefPicList* rpl  = lc->sc->rpl;
-const int min_pu_width = fc->ps.pps->min_pu_width;
-const int log2_min_pu_size = MIN_PU_LOG2;
-
-// bs for TU internal horizontal PU boundaries
-for (int j = 8 - ((y0 - cb_y) % 8); j < height; j += 8) {
-int yp_pu = (y0 + j - 1) >> log2_min_pu_size;
-int yq_pu = (y0 + j) >> log2_min_pu_size;
-
-for (int i = 0; i < width; i += 4) {
-const int x_pu = (x0 + i) >> log2_min_pu_size;
-const MvField *top  = _mvf[yp_pu * min_pu_width + x_pu];
-const MvField *curr = _mvf[yq_pu * min_pu_width + x_pu];
-const int x = x0 + i;
-const int y = y0 + j;
-const int bs = boundary_strength(lc, curr, top, rpl);
-uint8_t max_len_p = 0, max_len_q = 0;
-
-TAB_BS(fc->tab.horizontal_bs[LUMA], x, y) = bs;
-
-//fixme:
-//edgeTbFlags[ x − sbW ][ y ] is equal to 1
-//edgeTbFlags[ x + sbW ][ y ] is equal to 1
-if (j == 4 || j == height - 4)
-max_len_p = max_len_q = 1;
-else if (j == 8 || j == height - 8)
-max_len_p = max_len_q = 2;
-else
-max_len_p = max_len_q = 3;
-TAB_MAX_LEN(fc->tab.horizontal_p, x, y) = max_len_p;
-

[FFmpeg-devel] [PATCH 2/4] checkasm/vvc_alf: random select alf virtual boundaries position

2024-06-21 Thread Nuo Mi
A picture's virtual boundaries will split a CTU into 4 ALF blocks.
The ALF virtual boundary may cross or not cross a ALF block.
---
 tests/checkasm/vvc_alf.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tests/checkasm/vvc_alf.c b/tests/checkasm/vvc_alf.c
index 902757aff1..be8b930810 100644
--- a/tests/checkasm/vvc_alf.c
+++ b/tests/checkasm/vvc_alf.c
@@ -66,6 +66,14 @@ static const uint32_t pixel_mask[3] = { 0x, 
0x03ff03ff, 0x0fff0fff };
 }   \
 } while (0)
 
+static int get_alf_vb_pos(const int h, const int vb_pos_above)
+{
+if (h == MAX_CTU_SIZE)
+return MAX_CTU_SIZE - vb_pos_above;
+// If h < MAX_CTU_SIZE and picture virtual boundaries are involved, ALF 
virtual boundaries can either be within or outside this ALF block.
+return ((rnd() & 1) ? h : MAX_CTU_SIZE) - vb_pos_above;
+}
+
 static void check_alf_filter(VVCDSPContext *c, const int bit_depth)
 {
 LOCAL_ALIGNED_32(uint8_t, dst0, [DST_BUF_SIZE]);
@@ -92,11 +100,10 @@ static void check_alf_filter(VVCDSPContext *c, const int 
bit_depth)
 
 for (int h = 4; h <= MAX_CTU_SIZE; h += 4) {
 for (int w = 4; w <= MAX_CTU_SIZE; w += 4) {
-const int ctu_size = MAX_CTU_SIZE;
 //Both picture size and virtual boundaries are 8-aligned. For 
luma, we only need to check 8-aligned sizes.
 if (!(w % 8) && !(h % 8)) {
 if (check_func(c->alf.filter[LUMA], 
"vvc_alf_filter_luma_%dx%d_%d", w, h, bit_depth)) {
-const int vb_pos = ctu_size - ALF_VB_POS_ABOVE_LUMA;
+const int vb_pos = get_alf_vb_pos(h, 
ALF_VB_POS_ABOVE_LUMA);
 memset(dst0, 0, DST_BUF_SIZE);
 memset(dst1, 0, DST_BUF_SIZE);
 call_ref(dst0, dst_stride, src0 + offset, src_stride, w, 
h, filter, clip, vb_pos);
@@ -113,7 +120,7 @@ static void check_alf_filter(VVCDSPContext *c, const int 
bit_depth)
 //For chroma, once it exceeds 64, it's not a 4:2:0 format, so we 
only need to check 8-aligned sizes as well.
 if ((w <= 64 || !(w % 8)) && (h <= 64 || !(h % 8))) {
 if (check_func(c->alf.filter[CHROMA], 
"vvc_alf_filter_chroma_%dx%d_%d", w, h, bit_depth)) {
-const int vb_pos = ctu_size - ALF_VB_POS_ABOVE_CHROMA;
+const int vb_pos = get_alf_vb_pos(h, 
ALF_VB_POS_ABOVE_CHROMA);
 memset(dst0, 0, DST_BUF_SIZE);
 memset(dst1, 0, DST_BUF_SIZE);
 call_ref(dst0, dst_stride, src0 + offset, src_stride, w, 
h, filter, clip, vb_pos);
@@ -152,7 +159,7 @@ static void check_alf_classify(VVCDSPContext *c, const int 
bit_depth)
 for (int h = 8; h <= MAX_CTU_SIZE; h += 8) {
 for (int w = 8; w <= MAX_CTU_SIZE; w += 8) {
 const int id_size = w * h / ALF_BLOCK_SIZE / ALF_BLOCK_SIZE * 
sizeof(int);
-const int vb_pos  = MAX_CTU_SIZE - ALF_BLOCK_SIZE;
+const int vb_pos  = get_alf_vb_pos(h, ALF_VB_POS_ABOVE_LUMA);
 if (check_func(c->alf.classify, "vvc_alf_classify_%dx%d_%d", w, h, 
bit_depth)) {
 memset(class_idx0, 0, id_size);
 memset(class_idx1, 0, id_size);
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 1/4] checkasm/vvc_alf: only check the valid filter and classify sizes

2024-06-21 Thread Nuo Mi
---
 tests/checkasm/vvc_alf.c | 61 ++--
 1 file changed, 34 insertions(+), 27 deletions(-)

diff --git a/tests/checkasm/vvc_alf.c b/tests/checkasm/vvc_alf.c
index 84b0f9da15..902757aff1 100644
--- a/tests/checkasm/vvc_alf.c
+++ b/tests/checkasm/vvc_alf.c
@@ -90,35 +90,41 @@ static void check_alf_filter(VVCDSPContext *c, const int 
bit_depth)
 randomize_buffers2(filter, LUMA_PARAMS_SIZE, 1);
 randomize_buffers2(clip, LUMA_PARAMS_SIZE, 0);
 
-for (int h = 4; h <= MAX_CTU_SIZE; h += 8) {
-for (int w = 4; w <= MAX_CTU_SIZE; w += 8) {
+for (int h = 4; h <= MAX_CTU_SIZE; h += 4) {
+for (int w = 4; w <= MAX_CTU_SIZE; w += 4) {
 const int ctu_size = MAX_CTU_SIZE;
-if (check_func(c->alf.filter[LUMA], 
"vvc_alf_filter_luma_%dx%d_%d", w, h, bit_depth)) {
-const int vb_pos = ctu_size - ALF_VB_POS_ABOVE_LUMA;
-memset(dst0, 0, DST_BUF_SIZE);
-memset(dst1, 0, DST_BUF_SIZE);
-call_ref(dst0, dst_stride, src0 + offset, src_stride, w, h, 
filter, clip, vb_pos);
-call_new(dst1, dst_stride, src1 + offset, src_stride, w, h, 
filter, clip, vb_pos);
-for (int i = 0; i < h; i++) {
-if (memcmp(dst0 + i * dst_stride, dst1 + i * dst_stride, w 
* SIZEOF_PIXEL))
-fail();
+//Both picture size and virtual boundaries are 8-aligned. For 
luma, we only need to check 8-aligned sizes.
+if (!(w % 8) && !(h % 8)) {
+if (check_func(c->alf.filter[LUMA], 
"vvc_alf_filter_luma_%dx%d_%d", w, h, bit_depth)) {
+const int vb_pos = ctu_size - ALF_VB_POS_ABOVE_LUMA;
+memset(dst0, 0, DST_BUF_SIZE);
+memset(dst1, 0, DST_BUF_SIZE);
+call_ref(dst0, dst_stride, src0 + offset, src_stride, w, 
h, filter, clip, vb_pos);
+call_new(dst1, dst_stride, src1 + offset, src_stride, w, 
h, filter, clip, vb_pos);
+for (int i = 0; i < h; i++) {
+if (memcmp(dst0 + i * dst_stride, dst1 + i * 
dst_stride, w * SIZEOF_PIXEL))
+fail();
+}
+// Bench only square sizes, and ones with dimensions being 
a power of two.
+if (w == h && (w & (w - 1)) == 0)
+bench_new(dst1, dst_stride, src1 + offset, src_stride, 
w, h, filter, clip, vb_pos);
 }
-// Bench only square sizes, and ones with dimensions being a 
power of two.
-if (w == h && (w & (w - 1)) == 0)
-bench_new(dst1, dst_stride, src1 + offset, src_stride, w, 
h, filter, clip, vb_pos);
 }
-if (check_func(c->alf.filter[CHROMA], 
"vvc_alf_filter_chroma_%dx%d_%d", w, h, bit_depth)) {
-const int vb_pos = ctu_size - ALF_VB_POS_ABOVE_CHROMA;
-memset(dst0, 0, DST_BUF_SIZE);
-memset(dst1, 0, DST_BUF_SIZE);
-call_ref(dst0, dst_stride, src0 + offset, src_stride, w, h, 
filter, clip, vb_pos);
-call_new(dst1, dst_stride, src1 + offset, src_stride, w, h, 
filter, clip, vb_pos);
-for (int i = 0; i < h; i++) {
-if (memcmp(dst0 + i * dst_stride, dst1 + i * dst_stride, w 
* SIZEOF_PIXEL))
-fail();
+//For chroma, once it exceeds 64, it's not a 4:2:0 format, so we 
only need to check 8-aligned sizes as well.
+if ((w <= 64 || !(w % 8)) && (h <= 64 || !(h % 8))) {
+if (check_func(c->alf.filter[CHROMA], 
"vvc_alf_filter_chroma_%dx%d_%d", w, h, bit_depth)) {
+const int vb_pos = ctu_size - ALF_VB_POS_ABOVE_CHROMA;
+memset(dst0, 0, DST_BUF_SIZE);
+memset(dst1, 0, DST_BUF_SIZE);
+call_ref(dst0, dst_stride, src0 + offset, src_stride, w, 
h, filter, clip, vb_pos);
+call_new(dst1, dst_stride, src1 + offset, src_stride, w, 
h, filter, clip, vb_pos);
+for (int i = 0; i < h; i++) {
+if (memcmp(dst0 + i * dst_stride, dst1 + i * 
dst_stride, w * SIZEOF_PIXEL))
+fail();
+}
+if (w == h && (w & (w - 1)) == 0)
+bench_new(dst1, dst_stride, src1 + offset, src_stride, 
w, h, filter, clip, vb_pos);
 }
-if (w == h && (w & (w - 1)) == 0)
-bench_new(dst1, dst_stride, src1 + offset, src_stride, w, 
h, filter, clip, vb_pos);
 }
 }
 }
@@ -142,8 +148,9 @@ static void check_alf_classify(VVCDSPContext *c, const int 
bit_depth)
 
 randomize_buffers(src0, src1, SRC_BUF_SIZE);
 
-for (int h = 4; h <= MAX_CTU_SIZE; h += 8) {
-for (int w = 4; w <= MAX_CTU_SIZE; w += 8) {
+//Both 

[FFmpeg-devel] [PATCH 4/4] checkasm/vvc_alf: ensure right and bottom boundaries are not overwritten by asm

2024-06-21 Thread Nuo Mi
---
 tests/checkasm/vvc_alf.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/checkasm/vvc_alf.c b/tests/checkasm/vvc_alf.c
index be8b930810..15e79289cd 100644
--- a/tests/checkasm/vvc_alf.c
+++ b/tests/checkasm/vvc_alf.c
@@ -108,8 +108,8 @@ static void check_alf_filter(VVCDSPContext *c, const int 
bit_depth)
 memset(dst1, 0, DST_BUF_SIZE);
 call_ref(dst0, dst_stride, src0 + offset, src_stride, w, 
h, filter, clip, vb_pos);
 call_new(dst1, dst_stride, src1 + offset, src_stride, w, 
h, filter, clip, vb_pos);
-for (int i = 0; i < h; i++) {
-if (memcmp(dst0 + i * dst_stride, dst1 + i * 
dst_stride, w * SIZEOF_PIXEL))
+for (int i = 0; i < (h + 1); i++) {
+if (memcmp(dst0 + i * dst_stride, dst1 + i * 
dst_stride, (w + 1) * SIZEOF_PIXEL))
 fail();
 }
 // Bench only square sizes, and ones with dimensions being 
a power of two.
@@ -125,8 +125,8 @@ static void check_alf_filter(VVCDSPContext *c, const int 
bit_depth)
 memset(dst1, 0, DST_BUF_SIZE);
 call_ref(dst0, dst_stride, src0 + offset, src_stride, w, 
h, filter, clip, vb_pos);
 call_new(dst1, dst_stride, src1 + offset, src_stride, w, 
h, filter, clip, vb_pos);
-for (int i = 0; i < h; i++) {
-if (memcmp(dst0 + i * dst_stride, dst1 + i * 
dst_stride, w * SIZEOF_PIXEL))
+for (int i = 0; i < (h + 1); i++) {
+if (memcmp(dst0 + i * dst_stride, dst1 + i * 
dst_stride, (w + 1) * SIZEOF_PIXEL))
 fail();
 }
 if (w == h && (w & (w - 1)) == 0)
-- 
2.34.1

___
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".


[FFmpeg-devel] [PATCH 3/4] x86/vvc_alf: avoid overwriting for non-16 aligned widths

2024-06-21 Thread Nuo Mi
Previously, the code allowed overwriting on 16-aligned blocks, which was 
suitable when there were
no picture's virtual boundaries because both CTU sizes and strides were 
16-aligned. However, with
picture's virtual boundaries, each CTU is divided into four ALF blocks, leading 
to potential issues
with overwriting later CTUs.

In cases involving picture virtual boundaries, each ALF block is 8-pixel 
aligned.
For luma, we consistently ensure an 8-aligned width. For chroma in 4:2:0 format,
we need to account for a 4-aligned width.
---
 libavcodec/x86/vvc/vvc_alf.asm | 85 ++
 1 file changed, 75 insertions(+), 10 deletions(-)

diff --git a/libavcodec/x86/vvc/vvc_alf.asm b/libavcodec/x86/vvc/vvc_alf.asm
index b35dd9b0e9..f69a69f05f 100644
--- a/libavcodec/x86/vvc/vvc_alf.asm
+++ b/libavcodec/x86/vvc/vvc_alf.asm
@@ -324,18 +324,69 @@ SECTION .text
 %endif
 %endmacro
 
-; STORE_PIXELS(dst, src)
-%macro STORE_PIXELS 2
+; STORE_PIXELS_W16(dst, src)
+%macro STORE_PIXELS_W16 2
 %if ps == 2
-movu %1, m%2
+movu   [%1],  m%2
 %else
+movu   [%1], xm%2
+%endif
+%endmacro
+
+%macro STORE_PIXELS_W8 2
+%if ps == 2
+movu   [%1], xm%2
+%else
+movq   [%1], xm%2
+%endif
+%endmacro
+
+; STORE_PIXELS_W4(dst, src, offset)
+%macro STORE_PIXELS_W4 3
+%if ps == 2
+movq   [%1 + %3 * ps], xm%2
+%else
+movd[%1 + %3], xm%2
+%endif
+%endmacro
+
+%macro STORE_PIXELS_W8LE 3
+cmp %3, 8
+jl .w4
+STORE_PIXELS_W8 %1, %2
+cmp %3, 12
+%if ps == 2
+vpermq  m%2,  m%2, q0302
+%else
+vpermq  m%2,  m%2, q0101
+%endif
+jl .end
+STORE_PIXELS_W4 %1, %2, 8
+jmp .end
+.w4:
+STORE_PIXELS_W4 %1, %2, 0
+.end:
+%endmacro
+
+; STORE_PIXELS(dst, src, width)
+%macro STORE_PIXELS 3
+%if ps == 1
 packuswbm%2, m%2
 vpermq  m%2, m%2, 0x8
-movu %1, xm%2
+%endif
+
+%ifidn %3, 16
+STORE_PIXELS_W16  %1, %2
+%else
+%if LUMA
+STORE_PIXELS_W8   %1, %2
+%else
+STORE_PIXELS_W8LE %1, %2, %3
+%endif
 %endif
 %endmacro
 
-%macro FILTER_16x4 0
+%macro FILTER_16x4 1
 %if LUMA
 push clipq
 push strideq
@@ -362,7 +413,7 @@ SECTION .text
 ; clip to pixel
 CLIPW m0, m14, m15
 
-STORE_PIXELS  [dstq], 0
+STORE_PIXELSdstq, 0, %1
 
 lea srcq, [srcq + src_strideq]
 lea dstq, [dstq + dst_strideq]
@@ -399,7 +450,7 @@ SECTION .text
 ;  const uint8_t *src, ptrdiff_t src_stride, const ptrdiff_t width, cosnt 
ptr_diff_t height,
 ;  const int16_t *filter, const int16_t *clip, ptrdiff_t stride, ptrdiff_t 
vb_pos, ptrdiff_t pixel_max);
 ; **
-cglobal vvc_alf_filter_%2_%1bpc, 11, 15, 16, 0-0x28, dst, dst_stride, src, 
src_stride, width, height, filter, clip, stride, vb_pos, pixel_max, \
+cglobal vvc_alf_filter_%2_%1bpc, 11, 15, 16, 0-0x30, dst, dst_stride, src, 
src_stride, width, height, filter, clip, stride, vb_pos, pixel_max, \
 offset, x, s5, s6
 %define ps (%1 / 8) ; pixel size
 movdxm15, pixel_maxd
@@ -409,18 +460,32 @@ cglobal vvc_alf_filter_%2_%1bpc, 11, 15, 16, 0-0x28, dst, 
dst_stride, src, src_s
 .loop:
 pushsrcq
 pushdstq
+push  widthq
 xor   xq, xq
 
 .loop_w:
+cmp   widthq, 16
+jl   .loop_w_end
+
 LOAD_PARAMS
-FILTER_16x4
+FILTER_16x4   16
 
 add srcq, 16 * ps
 add dstq, 16 * ps
 add   xq, 16
-cmp   xq, widthq
-jl   .loop_w
+sub   widthq, 16
+jmp  .loop_w
+
+.loop_w_end:
+cmp   widthq, 0
+je.w_end
+
+LOAD_PARAMS
+FILTER_16x4  widthq
+
+.w_end:
 
+pop   widthq
 pop dstq
 pop srcq
 lea srcq, [srcq + 4 * src_strideq]
-- 
2.34.1

___
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] lavc/vvc: Invalidate PPSs which refer to a changed SPS

2024-06-20 Thread Nuo Mi
On Wed, Jun 19, 2024 at 4:53 PM Nuo Mi  wrote:

> Hi all,
> I will merge this tomorrow if there are no objections.
>
>>
>>> Applied.
Thank you, Frank, Christophe, Mark, and Anton, for a good discussion.
___
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 v2] fate/vvc: add vvc-conformance-RPR_A_4

2024-06-20 Thread Nuo Mi
Sorry for missing this.
Merged by James as
https://github.com/FFmpeg/FFmpeg/commit/0eacad6921c6835d0432f02b1aa5ec9b492a3572

Thank you, James and Frank


On Thu, Jun 20, 2024 at 6:13 PM Frank Plowman  wrote:

> On 10/06/2024 18:46, Frank Plowman wrote:
> >   BeforeAfter
> > -
> > make fate-vvc CPU Time (No ASM)  131.52s  134.83s
> > libavcodec/vvc/* Line Coverage 95.3%96.9%
> > inter_template.c Line Coverage 74.3%88.2%
> > inter.c Line Coverage  85.3%99.2%
> >
> > Signed-off-by: Frank Plowman 
> > ---
> >  tests/fate/vvc.mak | 1 +
> >  tests/ref/fate/vvc-conformance-RPR_A_4 | 9 +
> >  2 files changed, 10 insertions(+)
> >  create mode 100644 tests/ref/fate/vvc-conformance-RPR_A_4
> >
> > diff --git a/tests/fate/vvc.mak b/tests/fate/vvc.mak
> > index 0ff287eea6..3e762ec65e 100644
> > --- a/tests/fate/vvc.mak
> > +++ b/tests/fate/vvc.mak
> > @@ -14,6 +14,7 @@ VVC_SAMPLES_10BIT =   \
> >  POC_A_1   \
> >  PPS_B_1   \
> >  RAP_A_1   \
> > +RPR_A_4   \
> >  SAO_A_3   \
> >  SCALING_A_1   \
> >  SLICES_A_3\
> > diff --git a/tests/ref/fate/vvc-conformance-RPR_A_4
> b/tests/ref/fate/vvc-conformance-RPR_A_4
> > new file mode 100644
> > index 00..58ae0f3861
> > --- /dev/null
> > +++ b/tests/ref/fate/vvc-conformance-RPR_A_4
> > @@ -0,0 +1,9 @@
> > +#tb 0: 1/25
> > +#media_type 0: video
> > +#codec_id 0: rawvideo
> > +#dimensions 0: 832x480
> > +#sar 0: 0/1
> > +0,  0,  0,1,  1198080, 0x2c12c2be
> > +0,  1,  1,1,  1198080, 0x47275378
> > +0,  2,  2,1,  1198080, 0x5d7b0327
> > +0,  3,  3,1,  1198080, 0x0b15318a
>
> Ping
> ___
> 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".
>
___
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] lavc/vvc: Invalidate PPSs which refer to a changed SPS

2024-06-19 Thread Nuo Mi
Hi all,
I will merge this tomorrow if there are no objections.

Thank you.

On Mon, Jun 17, 2024 at 9:23 PM Nuo Mi  wrote:

>
>
> On Sun, Jun 16, 2024 at 11:26 PM Mark Thompson  wrote:
>
>> On 15/06/2024 17:37, Frank Plowman wrote:
>> > n 15/06/2024 13:24, Nuo Mi wrote:
>> >> On Sat, Jun 15, 2024 at 2:35 PM Christophe Gisquet <
>> >> christophe.gisq...@gmail.com> wrote:
>> >>
>> >>> Le ven. 14 juin 2024, 11:39, Frank Plowman  a
>> >>> écrit :
>> >>>
>> >>>> When the SPS associated with a particular SPS ID changes, invalidate
>> all
>> >>>> the PPSs which use that SPS ID.  Fixes crashes with illegal
>> bitstreams.
>> >>>> This is done in the CBS, rather than in libavcodec/vvc/ps.c like the
>> SPS
>> >>>> ID reuse validation, as parts of the CBS parsing process for PPSs
>> >>>> depend on the SPS being referred to.
>> >>>>
>> >>>
>> >>> I am uncertain about this. I have no definite knowledge nor proof,
>> but I
>> >>> would have thought these are persistent, IE it's legal to update some
>> of
>> >>> them, their validity depending on something else.
>> >>>
>> >>
>> >>> Wondering if the tested streams are thus conformant.
>> >>>
>> >>> But I don't know the actual rule. Maybe finding an EOB/EOS NUT?
>> Related to
>> >>> some particular shape of a clean random access point, that would
>> require
>> >>> retransmitting VPS/SPS/PPS/APS/... ?
>> >>>
>> >>> Asking Benjamin Bross might be a better option here.
>> >>>
>> >> Hi Chris,
>> >> spec said sps should not change in a CVS.  Frank has some patches to
>> fix a
>> >> similar issue.
>> >>
>> https://github.com/FFmpeg/FFmpeg/commit/2d79ae3f8a3306d24afe43ba505693a8dbefd21b
>> >>
>> >>
>> >> Hi Frank,
>> >> Did it crash before your error hand code in ps.c?
>> >> Could you send me the clip?
>> >>
>> >> Thank you
>> >>
>> >
>> > Hi both,
>> >
>> > Thank you for your reviews.
>> >
>> > An example of a crashing bitstream which is fixed by this patch is ID
>> > 295 available here: https://github.com/ffvvc/tests/pull/43.  The
>> > relevant part of the bitstream is a sequence of NAL units
>> >
>> > AU (decode_order=5)
>> > 18. SPS
>> > sps_seq_parameter_set_id = 0
>> > sps_ctb_log2_size_y = 5
>> > 19. PPS
>> > pps_pic_parameter_set_id = 0
>> > pps_seq_parameter_set_id = 0
>> > 20. IDR_N_LP
>> > ph_pic_order_cnt_lsb = 0
>> > NoOutputBeforeRecoveryFlag = 1
>> > ph_pic_parameter_set_id = 0
>> >
>> > AU (decode_order=6)
>> > 21. AUD
>> > 22. VPS
>> > 23. SPS
>> > sps_seq_parameter_set_id = 0
>> > sps_ctb_log2_size_y = 7
>> > 24. PREFIX_APS
>> > 25. IDR_N_LP
>> > ph_pic_order_cnt_lsb = 0
>> > NoOutputBeforeRecoveryFlag = 1
>> > ph_pic_parameter_set_id = 0
>> >
>> > The layout of SPSs alone is legal (not covered by the checks introduced
>> > in 2d79ae3f8a3306d24afe43ba505693a8dbefd21b) as the second AU is a CLVSS
>> > AU.  As a result, the bitstream crashes both before and after
>> > 2d79ae3f8a3306d24afe43ba505693a8dbefd21b.  What this patch does is
>> > produce an error when the VCL NAL unit in the second AU (25.) tries to
>> > use PPS ID 0, as the SPS NAL unit that PPS was defined with reference to
>> > (18.) is no longer available.
>> >
>> > Christophe, is my interpretation of your point correct when I say you
>> > are suggesting that the above sequence may be legal, so long as the PPS
>> > still satisfies the new bounds etc. derived from the second SPS?  I did
>> > consider this, and I think it may be possible to implement by delaying
>> > CBS element validation and inference until libavcodec/vvc/ps.c.
>> > However, there are no bitstreams in the conformance suite which contain
>> > such a structure and this is different to how the native HEVC decoder
>> > behaves (see libavcodec/hevc/ps.c:72).
>>
>> Is there some requirement in H.266 that in a single stream the PPS
>> precedes the SPS?
>>
> No, the spec only states that when decoding the picture header

Re: [FFmpeg-devel] [PATCH 1/2] avutil/executor: Allowing thread_count be zero

2024-06-19 Thread Nuo Mi
On Tue, Jun 18, 2024 at 10:24 PM Zhao Zhili  wrote:

>
>
> > On Jun 18, 2024, at 19:50, Nuo Mi  wrote:
> >
> > On Mon, Jun 17, 2024 at 5:28 PM Zhao Zhili 
> wrote:
> >
> >>
> >>
> >>> On Jun 17, 2024, at 16:45, Hendrik Leppkes 
> wrote:
> >>>
> >>> On Mon, Jun 17, 2024 at 10:03 AM Zhao Zhili 
> >> wrote:
> >>>>
> >>>>
> >>>>
> >>>>> On Jun 17, 2024, at 15:05, Anton Khirnov  wrote:
> >>>>>
> >>>>> Quoting Zhao Zhili (2024-06-17 07:19:26)
> >>>>>> From: Zhao Zhili 
> >>>>>>
> >>>>>> When thread_count be zero, it will be run on current thread like
> >>>>>> !HAVE_THREADS.
> >>>>>
> >>>>> Other APIs treat zero to mean "auto".
> >>>>
> >>>> executor don’t detect cpu cores by itself. It’s more low level than
> >> libavcodec.
> >>>>
> >>>> Zero thread is zero thread, literally. If we use thread_count one to
> >> mean
> >>>> run on current thread, how to create a single thread then?
> >>>
> >>> Whats the point of creating a single thread? Does the main thread ever
> >>> do something else in the meantime, or does it just wait for the job
> >>> anyway?
> >>
> >> Executor as a basic infrastructure should support such usage. The caller
> >> don’t need to wait for the job to finish.
> >>
> > Hi Zhili,
> > Thank you for the patch.
> > Could you explain more about its usage?
> > Why do we need to run everything in the main thread when we have pthread
> in
> > the system?
>
> In addition to match other decodes behavior, there are some usecases which
> require the decoder to not create a thread at runtime. For example, when
> build
> libavcodec with wasm and run in web browser, the runtime may or may not
> support threads, threads number should be decided at runtime, and can be
> zero.

Thank you for the details
Sounds reasonable if other code has the same behavior and we have real use
cases for this. Perhaps we can explain why we need this in the commit log.

Hi @Anton Khirnov   and @Paul B Mahol 
Do you prefer -1? We need to return an invalid parameter for 0 if we use -1
to indicate zero threads.

Thank you.

>
>
> >
> > Thank you.
> > ___
> > 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".
>
> ___
> 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".
>
___
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 1/2] avutil/executor: Allowing thread_count be zero

2024-06-19 Thread Nuo Mi
On Tue, Jun 18, 2024 at 8:06 PM Steven Liu  wrote:

> Nuo Mi  于2024年6月18日周二 19:51写道:
> >
> > On Mon, Jun 17, 2024 at 5:28 PM Zhao Zhili 
> wrote:
> >
> > >
> > >
> > > > On Jun 17, 2024, at 16:45, Hendrik Leppkes 
> wrote:
> > > >
> > > > On Mon, Jun 17, 2024 at 10:03 AM Zhao Zhili 
> > > wrote:
> > > >>
> > > >>
> > > >>
> > > >>> On Jun 17, 2024, at 15:05, Anton Khirnov 
> wrote:
> > > >>>
> > > >>> Quoting Zhao Zhili (2024-06-17 07:19:26)
> > > >>>> From: Zhao Zhili 
> > > >>>>
> > > >>>> When thread_count be zero, it will be run on current thread like
> > > >>>> !HAVE_THREADS.
> > > >>>
> > > >>> Other APIs treat zero to mean "auto".
> > > >>
> > > >> executor don’t detect cpu cores by itself. It’s more low level than
> > > libavcodec.
> > > >>
> > > >> Zero thread is zero thread, literally. If we use thread_count one to
> > > mean
> > > >> run on current thread, how to create a single thread then?
> > > >
> > > > Whats the point of creating a single thread? Does the main thread
> ever
> > > > do something else in the meantime, or does it just wait for the job
> > > > anyway?
> > >
> > > Executor as a basic infrastructure should support such usage. The
> caller
> > > don’t need to wait for the job to finish.
> > >
> > Hi Zhili,
> > Thank you for the patch.
> > Could you explain more about its usage?
> > Why do we need to run everything in the main thread when we have pthread
> in
> > the system?
> Just control CPU resource be used by decoder, perhaps the computer is
> running some other applications.
> There are running more application in one computer, and the ffmpeg
> decoder is need not realtime.
> For example running machine learning traning some model, and use
> ffmpeg transcoding vod videos,
> but transcode functions is borrow machine learning's team computers :D.
>
You can use "taskset" for CPU affinity. It will constrain the CPU resources
used by a process.

>
> >
> > Thank you.
> > ___
> > 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".
>
> Thanks
> Steven
> ___
> 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".
>
___
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 1/2] avutil/executor: Allowing thread_count be zero

2024-06-18 Thread Nuo Mi
On Mon, Jun 17, 2024 at 5:28 PM Zhao Zhili  wrote:

>
>
> > On Jun 17, 2024, at 16:45, Hendrik Leppkes  wrote:
> >
> > On Mon, Jun 17, 2024 at 10:03 AM Zhao Zhili 
> wrote:
> >>
> >>
> >>
> >>> On Jun 17, 2024, at 15:05, Anton Khirnov  wrote:
> >>>
> >>> Quoting Zhao Zhili (2024-06-17 07:19:26)
>  From: Zhao Zhili 
> 
>  When thread_count be zero, it will be run on current thread like
>  !HAVE_THREADS.
> >>>
> >>> Other APIs treat zero to mean "auto".
> >>
> >> executor don’t detect cpu cores by itself. It’s more low level than
> libavcodec.
> >>
> >> Zero thread is zero thread, literally. If we use thread_count one to
> mean
> >> run on current thread, how to create a single thread then?
> >
> > Whats the point of creating a single thread? Does the main thread ever
> > do something else in the meantime, or does it just wait for the job
> > anyway?
>
> Executor as a basic infrastructure should support such usage. The caller
> don’t need to wait for the job to finish.
>
Hi Zhili,
Thank you for the patch.
Could you explain more about its usage?
Why do we need to run everything in the main thread when we have pthread in
the system?

Thank you.
___
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] lavc/vvc: Invalidate PPSs which refer to a changed SPS

2024-06-17 Thread Nuo Mi
On Sun, Jun 16, 2024 at 11:26 PM Mark Thompson  wrote:

> On 15/06/2024 17:37, Frank Plowman wrote:
> > n 15/06/2024 13:24, Nuo Mi wrote:
> >> On Sat, Jun 15, 2024 at 2:35 PM Christophe Gisquet <
> >> christophe.gisq...@gmail.com> wrote:
> >>
> >>> Le ven. 14 juin 2024, 11:39, Frank Plowman  a
> >>> écrit :
> >>>
> >>>> When the SPS associated with a particular SPS ID changes, invalidate
> all
> >>>> the PPSs which use that SPS ID.  Fixes crashes with illegal
> bitstreams.
> >>>> This is done in the CBS, rather than in libavcodec/vvc/ps.c like the
> SPS
> >>>> ID reuse validation, as parts of the CBS parsing process for PPSs
> >>>> depend on the SPS being referred to.
> >>>>
> >>>
> >>> I am uncertain about this. I have no definite knowledge nor proof, but
> I
> >>> would have thought these are persistent, IE it's legal to update some
> of
> >>> them, their validity depending on something else.
> >>>
> >>
> >>> Wondering if the tested streams are thus conformant.
> >>>
> >>> But I don't know the actual rule. Maybe finding an EOB/EOS NUT?
> Related to
> >>> some particular shape of a clean random access point, that would
> require
> >>> retransmitting VPS/SPS/PPS/APS/... ?
> >>>
> >>> Asking Benjamin Bross might be a better option here.
> >>>
> >> Hi Chris,
> >> spec said sps should not change in a CVS.  Frank has some patches to
> fix a
> >> similar issue.
> >>
> https://github.com/FFmpeg/FFmpeg/commit/2d79ae3f8a3306d24afe43ba505693a8dbefd21b
> >>
> >>
> >> Hi Frank,
> >> Did it crash before your error hand code in ps.c?
> >> Could you send me the clip?
> >>
> >> Thank you
> >>
> >
> > Hi both,
> >
> > Thank you for your reviews.
> >
> > An example of a crashing bitstream which is fixed by this patch is ID
> > 295 available here: https://github.com/ffvvc/tests/pull/43.  The
> > relevant part of the bitstream is a sequence of NAL units
> >
> > AU (decode_order=5)
> > 18. SPS
> > sps_seq_parameter_set_id = 0
> > sps_ctb_log2_size_y = 5
> > 19. PPS
> > pps_pic_parameter_set_id = 0
> > pps_seq_parameter_set_id = 0
> > 20. IDR_N_LP
> > ph_pic_order_cnt_lsb = 0
> > NoOutputBeforeRecoveryFlag = 1
> > ph_pic_parameter_set_id = 0
> >
> > AU (decode_order=6)
> > 21. AUD
> > 22. VPS
> > 23. SPS
> > sps_seq_parameter_set_id = 0
> > sps_ctb_log2_size_y = 7
> > 24. PREFIX_APS
> > 25. IDR_N_LP
> > ph_pic_order_cnt_lsb = 0
> > NoOutputBeforeRecoveryFlag = 1
> > ph_pic_parameter_set_id = 0
> >
> > The layout of SPSs alone is legal (not covered by the checks introduced
> > in 2d79ae3f8a3306d24afe43ba505693a8dbefd21b) as the second AU is a CLVSS
> > AU.  As a result, the bitstream crashes both before and after
> > 2d79ae3f8a3306d24afe43ba505693a8dbefd21b.  What this patch does is
> > produce an error when the VCL NAL unit in the second AU (25.) tries to
> > use PPS ID 0, as the SPS NAL unit that PPS was defined with reference to
> > (18.) is no longer available.
> >
> > Christophe, is my interpretation of your point correct when I say you
> > are suggesting that the above sequence may be legal, so long as the PPS
> > still satisfies the new bounds etc. derived from the second SPS?  I did
> > consider this, and I think it may be possible to implement by delaying
> > CBS element validation and inference until libavcodec/vvc/ps.c.
> > However, there are no bitstreams in the conformance suite which contain
> > such a structure and this is different to how the native HEVC decoder
> > behaves (see libavcodec/hevc/ps.c:72).
>
> Is there some requirement in H.266 that in a single stream the PPS
> precedes the SPS?
>
No, the spec only states that when decoding the picture header, we need the
corresponding PPS and SPS.
If we strictly follow the spec, we should delay the PPS-derived process
when decoding the picture header, but it may be very complex.

7.4.3.4 Sequence parameter set RBSP semantics
An SPS RBSP shall be available to the decoding process, by inclusion in at
least one AU with TemporalId equal to 0 or
provided through external means, prior to it being referenced by either of
the following:
– a PH NAL unit having a ph_pic_parameter_set_id that refers to a PPS with
pps_seq_parameter_set_id equal to the
value of sps_

Re: [FFmpeg-devel] [PATCH] lavc/vvc: Invalidate PPSs which refer to a changed SPS

2024-06-16 Thread Nuo Mi
On Sun, Jun 16, 2024 at 12:38 AM Frank Plowman 
wrote:

> n 15/06/2024 13:24, Nuo Mi wrote:
> > On Sat, Jun 15, 2024 at 2:35 PM Christophe Gisquet <
> > christophe.gisq...@gmail.com> wrote:
> >
> >> Le ven. 14 juin 2024, 11:39, Frank Plowman  a
> >> écrit :
> >>
> >>> When the SPS associated with a particular SPS ID changes, invalidate
> all
> >>> the PPSs which use that SPS ID.  Fixes crashes with illegal bitstreams.
> >>> This is done in the CBS, rather than in libavcodec/vvc/ps.c like the
> SPS
> >>> ID reuse validation, as parts of the CBS parsing process for PPSs
> >>> depend on the SPS being referred to.
> >>>
> >>
> >> I am uncertain about this. I have no definite knowledge nor proof, but I
> >> would have thought these are persistent, IE it's legal to update some of
> >> them, their validity depending on something else.
> >>
> >
> >> Wondering if the tested streams are thus conformant.
> >>
> >> But I don't know the actual rule. Maybe finding an EOB/EOS NUT? Related
> to
> >> some particular shape of a clean random access point, that would require
> >> retransmitting VPS/SPS/PPS/APS/... ?
> >>
> >> Asking Benjamin Bross might be a better option here.
> >>
> > Hi Chris,
> > spec said sps should not change in a CVS.  Frank has some patches to fix
> a
> > similar issue.
> >
> https://github.com/FFmpeg/FFmpeg/commit/2d79ae3f8a3306d24afe43ba505693a8dbefd21b
> >
> >
> > Hi Frank,
> > Did it crash before your error hand code in ps.c?
> > Could you send me the clip?
> >
> > Thank you
> >
>
> Hi both,
>
> Thank you for your reviews.
>
> An example of a crashing bitstream which is fixed by this patch is ID
> 295 available here: https://github.com/ffvvc/tests/pull/43.  The
> relevant part of the bitstream is a sequence of NAL units
>
> AU (decode_order=5)
> 18. SPS
> sps_seq_parameter_set_id = 0
> sps_ctb_log2_size_y = 5
> 19. PPS
> pps_pic_parameter_set_id = 0
> pps_seq_parameter_set_id = 0
> 20. IDR_N_LP
> ph_pic_order_cnt_lsb = 0
> NoOutputBeforeRecoveryFlag = 1
> ph_pic_parameter_set_id = 0
>
> AU (decode_order=6)
> 21. AUD
> 22. VPS
> 23. SPS
> sps_seq_parameter_set_id = 0
> sps_ctb_log2_size_y = 7
> 24. PREFIX_APS
> 25. IDR_N_LP
> ph_pic_order_cnt_lsb = 0
> NoOutputBeforeRecoveryFlag = 1
> ph_pic_parameter_set_id = 0
>
> The layout of SPSs alone is legal (not covered by the checks introduced
> in 2d79ae3f8a3306d24afe43ba505693a8dbefd21b) as the second AU is a CLVSS
> AU.  As a result, the bitstream crashes both before and after
> 2d79ae3f8a3306d24afe43ba505693a8dbefd21b.  What this patch does is
> produce an error when the VCL NAL unit in the second AU (25.) tries to
> use PPS ID 0, as the SPS NAL unit that PPS was defined with reference to
> (18.) is no longer available.
>
> Christophe, is my interpretation of your point correct when I say you
> are suggesting that the above sequence may be legal, so long as the PPS
> still satisfies the new bounds etc. derived from the second SPS?  I did
> consider this, and I think it may be possible to implement by delaying
> CBS element validation and inference until libavcodec/vvc/ps.c.
> However, there are no bitstreams in the conformance suite which contain
> such a structure and this is different to how the native HEVC decoder
> behaves (see libavcodec/hevc/ps.c:72).
>
Pretty solid analysis, thank you, Frank

>
> All the best,
> --
> Frank
> ___
> 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".
>
___
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] rtp enc/dec update for vvc

2024-06-15 Thread Nuo Mi
On Sat, Jun 15, 2024 at 2:38 AM Frank Plowman  wrote:

> Hi,
>
> Thanks for the patch.  Unfortunately it looks to be corrupted and does
> not apply.  Also, it looks as though you submitted five near-identical
> patches.  I would suggest you try directing patches to your own mailbox
> and re-applying them while debugging the formatting issues, rather than
> sending lots of corrupted patches to the ML.
>
Hi ftaft,
Thank you for the patch. you can refer to
https://ffmpeg.org/developer.html#Introduction for the checklist.


> > \ No newline at end of file
> > diff --git a/configure b/configure
> > index 83284427df..d331688eb4 100755
> > --- a/configure
> > +++ b/configure
> > @@ -296,6 +296,7 @@ External library support:
> >--enable-libwebp enable WebP encoding via libwebp [no]
> >--enable-libx264 enable H.264 encoding via x264 [no]
> >--enable-libx265 enable HEVC encoding via x265 [no]
> > +  --enable-libvvencenable H.266/VVC encoding via vvenc [no]
>
> This looks like you had the VVenC patchset applied when you created this
> commit.  If your patch depends on the VVenC patchset, it will have to
> wait until that is applied (which could well be in the next day or two).
>
Hi ftaft,
I have pushed the libvvenc patch. You can rebase and send your patch again.


>
> >--enable-libxeve enable EVC encoding via libxeve [no]
> >--enable-libxevd enable EVC decoding via libxevd [no]
> >--enable-libxavs enable AVS encoding via xavs [no]
> > @@ -1867,6 +1868,7 @@ EXTERNAL_LIBRARY_GPL_LIST="
> >  libvidstab
> >  libx264
>
___
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 v5 1/1] avcodec: add external enc libvvenc for H266/VVC

2024-06-15 Thread Nuo Mi
On Wed, Jun 12, 2024 at 9:36 PM Nuo Mi  wrote:

> Hi all,
> If there are no objections, I will push it in 3 days.
>
> Thank you,  Christian
>
>
> On Thu, Jun 6, 2024 at 3:52 AM Christian Bartnik 
> wrote:
>
>> From: Thomas Siedel 
>>
>> Add external encoder VVenC for H266/VVC encoding.
>> Register new encoder libvvenc.
>> Add libvvenc to wrap the vvenc interface.
>> libvvenc implements encoder option: preset,qp,qpa,period,
>> passlogfile,stats,vvenc-params,level,tier.
>> Enable encoder by adding --enable-libvvenc in configure step.e
>
> Applied,
Thank you, Christian, Thomas, Andreas, Anton, and everyone who contributed
to this.


>
>
>> Co-authored-by: Christian Bartnik chris1031...@gmail.com
>> Signed-off-by: Thomas Siedel 
>> ---
>>  configure |   4 +
>>  doc/encoders.texi |  64 +
>>  fftools/ffmpeg_mux_init.c |   2 +-
>>  libavcodec/Makefile   |   1 +
>>  libavcodec/allcodecs.c|   1 +
>>  libavcodec/libvvenc.c | 492 ++
>>  6 files changed, 563 insertions(+), 1 deletion(-)
>>  create mode 100644 libavcodec/libvvenc.c
>>
>> diff --git a/configure b/configure
>> index 6c5b8aab9a..37ece23376 100755
>> --- a/configure
>> +++ b/configure
>> @@ -293,6 +293,7 @@ External library support:
>>--enable-libvorbis   enable Vorbis en/decoding via libvorbis,
>> native implementation exists [no]
>>--enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
>> +  --enable-libvvencenable H.266/VVC encoding via vvenc [no]
>>--enable-libwebp enable WebP encoding via libwebp [no]
>>--enable-libx264 enable H.264 encoding via x264 [no]
>>--enable-libx265 enable HEVC encoding via x265 [no]
>> @@ -1966,6 +1967,7 @@ EXTERNAL_LIBRARY_LIST="
>>  libvmaf
>>  libvorbis
>>  libvpx
>> +libvvenc
>>  libwebp
>>  libxevd
>>  libxeve
>> @@ -3560,6 +3562,7 @@ libvpx_vp8_decoder_deps="libvpx"
>>  libvpx_vp8_encoder_deps="libvpx"
>>  libvpx_vp9_decoder_deps="libvpx"
>>  libvpx_vp9_encoder_deps="libvpx"
>> +libvvenc_encoder_deps="libvvenc"
>>  libwebp_encoder_deps="libwebp"
>>  libwebp_anim_encoder_deps="libwebp"
>>  libx262_encoder_deps="libx262"
>> @@ -7030,6 +7033,7 @@ enabled libvpx&& {
>>  fi
>>  }
>>
>> +enabled libvvenc  && require_pkg_config libvvenc "libvvenc >=
>> 1.6.1" "vvenc/vvenc.h" vvenc_get_version
>>  enabled libwebp   && {
>>  enabled libwebp_encoder  && require_pkg_config libwebp "libwebp
>> >= 0.2.0" webp/encode.h WebPGetEncoderVersion
>>  enabled libwebp_anim_encoder && check_pkg_config
>> libwebp_anim_encoder "libwebpmux >= 0.4.0" webp/mux.h
>> WebPAnimEncoderOptionsInit; }
>> diff --git a/doc/encoders.texi b/doc/encoders.texi
>> index c82f316f94..496852faeb 100644
>> --- a/doc/encoders.texi
>> +++ b/doc/encoders.texi
>> @@ -2378,6 +2378,70 @@ Indicates frame duration
>>  For more information about libvpx see:
>>  @url{http://www.webmproject.org/}
>>
>> +@section libvvenc
>> +
>> +VVenC H.266/VVC encoder wrapper.
>> +
>> +This encoder requires the presence of the libvvenc headers and library
>> +during configuration. You need to explicitly configure the build with
>> +@option{--enable-libvvenc}.
>> +
>> +The VVenC project website is at
>> +@url{https://github.com/fraunhoferhhi/vvenc}.
>> +
>> +@subsection Supported Pixel Formats
>> +
>> +VVenC supports only 10-bit color spaces as input. But the internal
>> (encoded)
>> +bit depth can be set to 8-bit or 10-bit at runtime.
>> +
>> +@subsection Options
>> +
>> +@table @option
>> +@item b
>> +Sets target video bitrate.
>> +
>> +@item g
>> +Set the GOP size. Currently support for g=1 (Intra only) or default.
>> +
>> +@item preset
>> +Set the VVenC preset.
>> +
>> +@item levelidc
>> +Set level idc.
>> +
>> +@item tier
>> +Set vvc tier.
>> +
>> +@item qp
>> +Set constant quantization parameter.
>> +
>> +@item subopt @var{boolean}
>> +Set subjective (perceptually motivated) optimization. Default is 1 (on).
>> +
>> +@item bitdepth8 @var{boolean}
>> +Set 8bit coding mode ins

Re: [FFmpeg-devel] [PATCH] lavc/vvc: Invalidate PPSs which refer to a changed SPS

2024-06-15 Thread Nuo Mi
On Sat, Jun 15, 2024 at 2:35 PM Christophe Gisquet <
christophe.gisq...@gmail.com> wrote:

> Le ven. 14 juin 2024, 11:39, Frank Plowman  a
> écrit :
>
> > When the SPS associated with a particular SPS ID changes, invalidate all
> > the PPSs which use that SPS ID.  Fixes crashes with illegal bitstreams.
> > This is done in the CBS, rather than in libavcodec/vvc/ps.c like the SPS
> > ID reuse validation, as parts of the CBS parsing process for PPSs
> > depend on the SPS being referred to.
> >
>
> I am uncertain about this. I have no definite knowledge nor proof, but I
> would have thought these are persistent, IE it's legal to update some of
> them, their validity depending on something else.
>

> Wondering if the tested streams are thus conformant.
>
> But I don't know the actual rule. Maybe finding an EOB/EOS NUT? Related to
> some particular shape of a clean random access point, that would require
> retransmitting VPS/SPS/PPS/APS/... ?
>
> Asking Benjamin Bross might be a better option here.
>
Hi Chris,
spec said sps should not change in a CVS.  Frank has some patches to fix a
similar issue.
https://github.com/FFmpeg/FFmpeg/commit/2d79ae3f8a3306d24afe43ba505693a8dbefd21b


Hi Frank,
Did it crash before your error hand code in ps.c?
Could you send me the clip?

Thank you


> >
> ___
> 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".
>
___
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 v5 1/1] avcodec: add external enc libvvenc for H266/VVC

2024-06-12 Thread Nuo Mi
Hi all,
If there are no objections, I will push it in 3 days.

Thank you,  Christian


On Thu, Jun 6, 2024 at 3:52 AM Christian Bartnik 
wrote:

> From: Thomas Siedel 
>
> Add external encoder VVenC for H266/VVC encoding.
> Register new encoder libvvenc.
> Add libvvenc to wrap the vvenc interface.
> libvvenc implements encoder option: preset,qp,qpa,period,
> passlogfile,stats,vvenc-params,level,tier.
> Enable encoder by adding --enable-libvvenc in configure step.
>
> Co-authored-by: Christian Bartnik chris1031...@gmail.com
> Signed-off-by: Thomas Siedel 
> ---
>  configure |   4 +
>  doc/encoders.texi |  64 +
>  fftools/ffmpeg_mux_init.c |   2 +-
>  libavcodec/Makefile   |   1 +
>  libavcodec/allcodecs.c|   1 +
>  libavcodec/libvvenc.c | 492 ++
>  6 files changed, 563 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/libvvenc.c
>
> diff --git a/configure b/configure
> index 6c5b8aab9a..37ece23376 100755
> --- a/configure
> +++ b/configure
> @@ -293,6 +293,7 @@ External library support:
>--enable-libvorbis   enable Vorbis en/decoding via libvorbis,
> native implementation exists [no]
>--enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
> +  --enable-libvvencenable H.266/VVC encoding via vvenc [no]
>--enable-libwebp enable WebP encoding via libwebp [no]
>--enable-libx264 enable H.264 encoding via x264 [no]
>--enable-libx265 enable HEVC encoding via x265 [no]
> @@ -1966,6 +1967,7 @@ EXTERNAL_LIBRARY_LIST="
>  libvmaf
>  libvorbis
>  libvpx
> +libvvenc
>  libwebp
>  libxevd
>  libxeve
> @@ -3560,6 +3562,7 @@ libvpx_vp8_decoder_deps="libvpx"
>  libvpx_vp8_encoder_deps="libvpx"
>  libvpx_vp9_decoder_deps="libvpx"
>  libvpx_vp9_encoder_deps="libvpx"
> +libvvenc_encoder_deps="libvvenc"
>  libwebp_encoder_deps="libwebp"
>  libwebp_anim_encoder_deps="libwebp"
>  libx262_encoder_deps="libx262"
> @@ -7030,6 +7033,7 @@ enabled libvpx&& {
>  fi
>  }
>
> +enabled libvvenc  && require_pkg_config libvvenc "libvvenc >=
> 1.6.1" "vvenc/vvenc.h" vvenc_get_version
>  enabled libwebp   && {
>  enabled libwebp_encoder  && require_pkg_config libwebp "libwebp
> >= 0.2.0" webp/encode.h WebPGetEncoderVersion
>  enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder
> "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index c82f316f94..496852faeb 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -2378,6 +2378,70 @@ Indicates frame duration
>  For more information about libvpx see:
>  @url{http://www.webmproject.org/}
>
> +@section libvvenc
> +
> +VVenC H.266/VVC encoder wrapper.
> +
> +This encoder requires the presence of the libvvenc headers and library
> +during configuration. You need to explicitly configure the build with
> +@option{--enable-libvvenc}.
> +
> +The VVenC project website is at
> +@url{https://github.com/fraunhoferhhi/vvenc}.
> +
> +@subsection Supported Pixel Formats
> +
> +VVenC supports only 10-bit color spaces as input. But the internal
> (encoded)
> +bit depth can be set to 8-bit or 10-bit at runtime.
> +
> +@subsection Options
> +
> +@table @option
> +@item b
> +Sets target video bitrate.
> +
> +@item g
> +Set the GOP size. Currently support for g=1 (Intra only) or default.
> +
> +@item preset
> +Set the VVenC preset.
> +
> +@item levelidc
> +Set level idc.
> +
> +@item tier
> +Set vvc tier.
> +
> +@item qp
> +Set constant quantization parameter.
> +
> +@item subopt @var{boolean}
> +Set subjective (perceptually motivated) optimization. Default is 1 (on).
> +
> +@item bitdepth8 @var{boolean}
> +Set 8bit coding mode instead of using 10bit. Default is 0 (off).
> +
> +@item period
> +set (intra) refresh period in seconds.
> +
> +@item vvenc-params
> +Set vvenc options using a list of @var{key}=@var{value} couples separated
> +by ":". See @command{vvencapp --fullhelp} or @command{vvencFFapp
> --fullhelp} for a list of options.
> +
> +For example, the options might be provided as:
> +
> +@example
> +intraperiod=64:decodingrefreshtype=idr:poc0idr=1:internalbitdepth=8
> +@end example
> +
> +For example the encoding options might be provided with
> @option{-vvenc-params}:
> +
> +@example
> +ffmpeg -i input -c:v libvvenc -b 1M -vvenc-params
> intraperiod=64:decodingrefreshtype=idr:poc0idr=1:internalbitdepth=8
> output.mp4
> +@end example
> +
> +@end table
> +
>  @section libwebp
>
>  libwebp WebP Image encoder wrapper
> diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
> index 8797265145..ef2922854a 100644
> --- a/fftools/ffmpeg_mux_init.c
> +++ b/fftools/ffmpeg_mux_init.c
> @@ -739,7 +739,7 @@ static int new_stream_video(Muxer *mux, const
> OptionsContext *o,
>   ost->logfile_prefix ? ost->logfile_prefix :
>
> 

Re: [FFmpeg-devel] [PATCH v4] lavc/vvc: Prevent overflow in chroma QP derivation

2024-06-12 Thread Nuo Mi
On Sun, Jun 9, 2024 at 7:18 PM Frank Plowman  wrote:

> On the top of p. 112 in VVC (09/2023):
>
> It is a requirement of bitstream conformance that the values of
> qpInVal[ i ][ j ] and qpOutVal[ i ][ j ] shall be in the range
> of −QpBdOffset to 63, inclusive for i in the range of 0 to
> numQpTables − 1, inclusive, and j in the range of 0 to
> sps_num_points_in_qp_table_minus1[ i ] + 1, inclusive.
>
> Additionally, don't discard the return code from sps_chroma_qp_table.
>
> Applied.
Thank you, Frank
___
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] lavc/qsvdec: Add VVC decoder

2024-06-12 Thread Nuo Mi
Hi Fei,
Thank you for the patch.
Which hardware supports this? Could you provide the link?

On Wed, Jun 12, 2024 at 9:03 AM  wrote:

> From: Fei Wang 
>
> Signed-off-by: Fei Wang 
> ---
>  Changelog  | 1 +
>  configure  | 1 +
>  doc/decoders.texi  | 2 +-
>  libavcodec/allcodecs.c | 1 +
>  libavcodec/qsv.c   | 4 
>  libavcodec/qsvdec.c| 7 ++-
>  libavcodec/version.h   | 2 +-
>  7 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/Changelog b/Changelog
> index 03d6b29ad8..a238a1c1f3 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -12,6 +12,7 @@ version :
>  - qsv_params option added for QSV encoders
>  - VVC decoder compatible with DVB test content
>  - xHE-AAC decoder
> +- Intel QSV-accelerated VVC decoding
>
>
>  version 7.0:
> diff --git a/configure b/configure
> index 6c5b8aab9a..b4cf12658d 100755
> --- a/configure
> +++ b/configure
> @@ -3423,6 +3423,7 @@ av1_qsv_encoder_deps="libvpl"
>  av1_amf_encoder_deps="amf"
>  av1_vaapi_encoder_deps="VAEncPictureParameterBufferAV1"
>  av1_vaapi_encoder_select="cbs_av1 vaapi_encode"
> +vvc_qsv_decoder_select="qsvdec"
>
It's better to follow the alphabetical order.
You can send another patch to fix av1

>
>  # parsers
>  aac_parser_select="adts_header mpeg4audio"
> diff --git a/doc/decoders.texi b/doc/decoders.texi
> index 293c82c2ba..2fcc761d2f 100644
> --- a/doc/decoders.texi
> +++ b/doc/decoders.texi
> @@ -157,7 +157,7 @@ Force to use a specific number of threads
>  @section QSV Decoders
>
>  The family of Intel QuickSync Video decoders (VC1, MPEG-2, H.264, HEVC,
> -JPEG/MJPEG, VP8, VP9, AV1).
> +JPEG/MJPEG, VP8, VP9, AV1, VVC).
>
>  @subsection Common Options
>
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index b102a8069e..a73b4e1673 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -885,6 +885,7 @@ extern const FFCodec ff_vp9_mediacodec_encoder;
>  extern const FFCodec ff_vp9_qsv_decoder;
>  extern const FFCodec ff_vp9_vaapi_encoder;
>  extern const FFCodec ff_vp9_qsv_encoder;
> +extern const FFCodec ff_vvc_qsv_decoder;
>
>  // null codecs
>  extern const FFCodec ff_vnull_decoder;
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> index 0c6fbd0dc0..221c1b24e5 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -73,6 +73,10 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
>  case AV_CODEC_ID_AV1:
>  return MFX_CODEC_AV1;
>  #endif
> +#if QSV_VERSION_ATLEAST(2, 11)
> +case AV_CODEC_ID_VVC:
> +return MFX_CODEC_VVC;
> +#endif
>
>  default:
>  break;
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index f2cd6ae05c..9ad3439991 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -933,7 +933,8 @@ static int qsv_decode(AVCodecContext *avctx,
> QSVContext *q,
>  frame->pict_type =
> ff_qsv_map_pictype(aframe.frame->dec_info.FrameType);
>
>  if (avctx->codec_id == AV_CODEC_ID_H264 ||
> -avctx->codec_id == AV_CODEC_ID_HEVC) {
> +avctx->codec_id == AV_CODEC_ID_HEVC ||
> +avctx->codec_id == AV_CODEC_ID_VVC) {
>  if (aframe.frame->dec_info.FrameType & MFX_FRAMETYPE_IDR)
>  frame->flags |= AV_FRAME_FLAG_KEY;
>  else
> @@ -1300,3 +1301,7 @@ DEFINE_QSV_DECODER(vp9, VP9, NULL)
>  #if CONFIG_AV1_QSV_DECODER
>  DEFINE_QSV_DECODER(av1, AV1, NULL)
>  #endif
> +
> +#if CONFIG_VVC_QSV_DECODER
> +DEFINE_QSV_DECODER(vvc, VVC, NULL)
> +#endif
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index 7acb261bb3..37c4c39451 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -29,7 +29,7 @@
>
>  #include "version_major.h"
>
> -#define LIBAVCODEC_VERSION_MINOR   7
> +#define LIBAVCODEC_VERSION_MINOR   8
>  #define LIBAVCODEC_VERSION_MICRO 100
>
>  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
> --
> 2.25.1
>
> ___
> 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".
>
___
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] fate/vvc: add vvc-conformance-RPR_A_Alibaba_4

2024-06-10 Thread Nuo Mi
Hi Frank,
Thank you for the patch.
Could we follow the naming conventions used for other clips?

On Mon, Jun 10, 2024 at 2:45 AM Frank Plowman  wrote:

>   BeforeAfter
> -
> make fate-vvc CPU Time (No ASM)  131.52s  134.83s
> libavcodec/vvc/* Line Coverage 95.3%96.9%
> inter_template.c Line Coverage 74.3%88.2%
> inter.c Line Coverage  85.3%99.2%
>
> Signed-off-by: Frank Plowman 
> ---
>  tests/fate/vvc.mak | 1 +
>  tests/ref/fate/vvc-conformance-RPR_A_Alibaba_4 | 9 +
>  2 files changed, 10 insertions(+)
>  create mode 100644 tests/ref/fate/vvc-conformance-RPR_A_Alibaba_4
>
> diff --git a/tests/fate/vvc.mak b/tests/fate/vvc.mak
> index 0ff287eea6..93b86f15f0 100644
> --- a/tests/fate/vvc.mak
> +++ b/tests/fate/vvc.mak
> @@ -14,6 +14,7 @@ VVC_SAMPLES_10BIT =   \
>  POC_A_1   \
>  PPS_B_1   \
>  RAP_A_1   \
> +RPR_A_Alibaba_4   \
>  SAO_A_3   \
>  SCALING_A_1   \
>  SLICES_A_3\
> diff --git a/tests/ref/fate/vvc-conformance-RPR_A_Alibaba_4
> b/tests/ref/fate/vvc-conformance-RPR_A_Alibaba_4
> new file mode 100644
> index 00..58ae0f3861
> --- /dev/null
> +++ b/tests/ref/fate/vvc-conformance-RPR_A_Alibaba_4
> @@ -0,0 +1,9 @@
> +#tb 0: 1/25
> +#media_type 0: video
> +#codec_id 0: rawvideo
> +#dimensions 0: 832x480
> +#sar 0: 0/1
> +0,  0,  0,1,  1198080, 0x2c12c2be
> +0,  1,  1,1,  1198080, 0x47275378
> +0,  2,  2,1,  1198080, 0x5d7b0327
> +0,  3,  3,1,  1198080, 0x0b15318a
> --
> 2.45.1
>
> ___
> 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".
>
___
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] avcodec/vvc/inter: Don't return void

2024-06-10 Thread Nuo Mi
LGTM.
Thank you, Andreas

On Mon, Jun 10, 2024 at 1:37 PM Andreas Rheinhardt <
andreas.rheinha...@outlook.com> wrote:

> Returning a void is not allowed by the spec. Just return instead.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/vvc/inter.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
> index 98cb43322f..aaf3230c1e 100644
> --- a/libavcodec/vvc/inter.c
> +++ b/libavcodec/vvc/inter.c
> @@ -146,18 +146,21 @@ static void emulated_edge(const VVCLocalContext *lc,
> uint8_t *dst,
>  subpic_get_rect(, src_frame, subpic_idx, is_chroma);
>
>  if (!wrap_enabled || (dmvr_left >= 0 && dmvr_right <= pic_width)) {
> -return emulated_edge_no_wrap(lc, dst, src, src_stride,
> +emulated_edge_no_wrap(lc, dst, src, src_stride,
>  x_off, y_off, block_w, block_h, extra_before, extra_after,
> , , dmvr_clip);
> +return;
>  }
>  if (dmvr_right <= 0) {
>  sb_wrap(, wrap);
> -return emulated_edge_no_wrap(lc, dst, src, src_stride,
> +emulated_edge_no_wrap(lc, dst, src, src_stride,
>  x_off + wrap, y_off, block_w, block_h, extra_before,
> extra_after, , , dmvr_clip);
> +return;
>  }
>  if (dmvr_left >= pic_width) {
>  sb_wrap(, -wrap);
> -return emulated_edge_no_wrap(lc, dst, src, src_stride,
> +emulated_edge_no_wrap(lc, dst, src, src_stride,
>  x_off - wrap, y_off, block_w, block_h, extra_before,
> extra_after, , , dmvr_clip);
> +return;
>  }
>
>  block_w += extra;
> --
> 2.40.1
>
> ___
> 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".
>
___
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 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations

2024-06-08 Thread Nuo Mi
On Sun, Jun 9, 2024 at 5:14 AM Andreas Rheinhardt <
andreas.rheinha...@outlook.com> wrote:

> Nuo Mi:
> > On Wed, Jun 5, 2024 at 7:41 PM Andreas Rheinhardt <
> > andreas.rheinha...@outlook.com> wrote:
> >
> >> This is the VVC version of 8b5d15530127fea54e934043a64653859de07353.
> >>
> >> (Hint: This ensures that the order of NALU arrays is OPI-VPS-SPS-PPS-
> >> Prefix-SEI-Suffix-SEI, regardless of the order in the original
> >> extradata. I hope this is right.)
> >>
> >> Signed-off-by: Andreas Rheinhardt 
> >> ---
> >>  libavformat/vvc.c | 169 --
> >>  1 file changed, 73 insertions(+), 96 deletions(-)
> >>
> >> diff --git a/libavformat/vvc.c b/libavformat/vvc.c
> >> index 679bb07a4d..819ee02e2c 100644
> >> --- a/libavformat/vvc.c
> >> +++ b/libavformat/vvc.c
> >> @@ -32,6 +32,16 @@
> >>  #include "avio_internal.h"
> >>  #include "vvc.h"
> >>
> >> +enum {
> >> +OPI_INDEX,
> >> +VPS_INDEX,
> >> +SPS_INDEX,
> >> +PPS_INDEX,
> >> +SEI_PREFIX_INDEX,
> >> +SEI_SUFFIX_INDEX,
> >> +NB_ARRAYS
> >> +};
> >> +
> >>  typedef struct VVCCNALUnitArray {
> >>  uint8_t array_completeness;
> >>  uint8_t NAL_unit_type;
> >> @@ -67,7 +77,7 @@ typedef struct VVCDecoderConfigurationRecord {
> >>  uint16_t max_picture_height;
> >>  uint16_t avg_frame_rate;
> >>  uint8_t num_of_arrays;
> >> -VVCCNALUnitArray *array;
> >> +VVCCNALUnitArray arrays[NB_ARRAYS];
> >>  } VVCDecoderConfigurationRecord;
> >>
> >>  static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc,
> >> @@ -432,32 +442,11 @@ static void nal_unit_parse_header(GetBitContext
> *gb,
> >> uint8_t *nal_type)
> >>
> >>  static int vvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
> >> uint8_t nal_type, int
> >> ps_array_completeness,
> >> -   VVCDecoderConfigurationRecord *vvcc)
> >> +   VVCCNALUnitArray *array)
> >>  {
> >>  int ret;
> >> -uint8_t index;
> >>  uint16_t num_nalus;
> >> -VVCCNALUnitArray *array;
> >> -
> >> -for (index = 0; index < vvcc->num_of_arrays; index++)
> >> -if (vvcc->array[index].NAL_unit_type == nal_type)
> >> -break;
> >> -
> >> -if (index >= vvcc->num_of_arrays) {
> >> -uint8_t i;
> >> -
> >> -ret =
> >> -av_reallocp_array(>array, index + 1,
> >> -  sizeof(VVCCNALUnitArray));
> >> -if (ret < 0)
> >> -return ret;
> >> -
> >> -for (i = vvcc->num_of_arrays; i <= index; i++)
> >> -memset(>array[i], 0, sizeof(VVCCNALUnitArray));
> >> -vvcc->num_of_arrays = index + 1;
> >> -}
> >>
> >> -array = >array[index];
> >>  num_nalus = array->num_nalus;
> >>
> >>  ret = av_reallocp_array(>nal_unit, num_nalus + 1,
> >> sizeof(uint8_t *));
> >> @@ -504,7 +493,8 @@ static int vvcc_array_add_nal_unit(uint8_t *nal_buf,
> >> uint32_t nal_size,
> >>
> >>  static int vvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
> >>   int ps_array_completeness,
> >> - VVCDecoderConfigurationRecord *vvcc)
> >> + VVCDecoderConfigurationRecord *vvcc,
> >> + unsigned array_idx)
> >>  {
> >>  int ret = 0;
> >>  GetBitContext gbc;
> >> @@ -529,18 +519,15 @@ static int vvcc_add_nal_unit(uint8_t *nal_buf,
> >> uint32_t nal_size,
> >>   * vvcc. Perhaps the SEI playload type should be checked
> >>   * and non-declarative SEI messages discarded?
> >>   */
> >> -switch (nal_type) {
> >> -case VVC_OPI_NUT:
> >> -case VVC_VPS_NUT:
> >> -case VVC_SPS_NUT:
> >> -case VVC_PPS_NUT:
> >> -case VVC_PREFIX_SEI_NUT:
> >> -case VVC_SUFFIX_SEI_NUT:
> >> -ret = vvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
> >> -  

Re: [FFmpeg-devel] [PATCH v2 5/5] avcodec/vvcdec: support mv wraparound

2024-06-08 Thread Nuo Mi
On Tue, Jun 4, 2024 at 8:04 PM Nuo Mi  wrote:

> A 360 video specific tool
> see https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9503377
>
> passed files:
> DMVR_A_Huawei_3.bit
> WRAP_D_InterDigital_4.bit
> WRAP_A_InterDigital_4.bit
> WRAP_B_InterDigital_4.bit
> WRAP_C_InterDigital_4.bit
> ERP_A_MediaTek_3.bit
>
Applied.
___
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 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations

2024-06-06 Thread Nuo Mi
On Wed, Jun 5, 2024 at 7:41 PM Andreas Rheinhardt <
andreas.rheinha...@outlook.com> wrote:

> This is the VVC version of 8b5d15530127fea54e934043a64653859de07353.
>
> (Hint: This ensures that the order of NALU arrays is OPI-VPS-SPS-PPS-
> Prefix-SEI-Suffix-SEI, regardless of the order in the original
> extradata. I hope this is right.)
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/vvc.c | 169 --
>  1 file changed, 73 insertions(+), 96 deletions(-)
>
> diff --git a/libavformat/vvc.c b/libavformat/vvc.c
> index 679bb07a4d..819ee02e2c 100644
> --- a/libavformat/vvc.c
> +++ b/libavformat/vvc.c
> @@ -32,6 +32,16 @@
>  #include "avio_internal.h"
>  #include "vvc.h"
>
> +enum {
> +OPI_INDEX,
> +VPS_INDEX,
> +SPS_INDEX,
> +PPS_INDEX,
> +SEI_PREFIX_INDEX,
> +SEI_SUFFIX_INDEX,
> +NB_ARRAYS
> +};
> +
>  typedef struct VVCCNALUnitArray {
>  uint8_t array_completeness;
>  uint8_t NAL_unit_type;
> @@ -67,7 +77,7 @@ typedef struct VVCDecoderConfigurationRecord {
>  uint16_t max_picture_height;
>  uint16_t avg_frame_rate;
>  uint8_t num_of_arrays;
> -VVCCNALUnitArray *array;
> +VVCCNALUnitArray arrays[NB_ARRAYS];
>  } VVCDecoderConfigurationRecord;
>
>  static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc,
> @@ -432,32 +442,11 @@ static void nal_unit_parse_header(GetBitContext *gb,
> uint8_t *nal_type)
>
>  static int vvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
> uint8_t nal_type, int
> ps_array_completeness,
> -   VVCDecoderConfigurationRecord *vvcc)
> +   VVCCNALUnitArray *array)
>  {
>  int ret;
> -uint8_t index;
>  uint16_t num_nalus;
> -VVCCNALUnitArray *array;
> -
> -for (index = 0; index < vvcc->num_of_arrays; index++)
> -if (vvcc->array[index].NAL_unit_type == nal_type)
> -break;
> -
> -if (index >= vvcc->num_of_arrays) {
> -uint8_t i;
> -
> -ret =
> -av_reallocp_array(>array, index + 1,
> -  sizeof(VVCCNALUnitArray));
> -if (ret < 0)
> -return ret;
> -
> -for (i = vvcc->num_of_arrays; i <= index; i++)
> -memset(>array[i], 0, sizeof(VVCCNALUnitArray));
> -vvcc->num_of_arrays = index + 1;
> -}
>
> -array = >array[index];
>  num_nalus = array->num_nalus;
>
>  ret = av_reallocp_array(>nal_unit, num_nalus + 1,
> sizeof(uint8_t *));
> @@ -504,7 +493,8 @@ static int vvcc_array_add_nal_unit(uint8_t *nal_buf,
> uint32_t nal_size,
>
>  static int vvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
>   int ps_array_completeness,
> - VVCDecoderConfigurationRecord *vvcc)
> + VVCDecoderConfigurationRecord *vvcc,
> + unsigned array_idx)
>  {
>  int ret = 0;
>  GetBitContext gbc;
> @@ -529,18 +519,15 @@ static int vvcc_add_nal_unit(uint8_t *nal_buf,
> uint32_t nal_size,
>   * vvcc. Perhaps the SEI playload type should be checked
>   * and non-declarative SEI messages discarded?
>   */
> -switch (nal_type) {
> -case VVC_OPI_NUT:
> -case VVC_VPS_NUT:
> -case VVC_SPS_NUT:
> -case VVC_PPS_NUT:
> -case VVC_PREFIX_SEI_NUT:
> -case VVC_SUFFIX_SEI_NUT:
> -ret = vvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
> -  ps_array_completeness, vvcc);
> -if (ret < 0)
> -goto end;
> -else if (nal_type == VVC_VPS_NUT)
> +ret = vvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
> +  ps_array_completeness,
> +  >arrays[array_idx]);
> +if (ret < 0)
> +goto end;
> +if (vvcc->arrays[array_idx].num_nalus == 1)
> +vvcc->num_of_arrays++;
> +
> +if (nal_type == VVC_VPS_NUT)
>  ret = vvcc_parse_vps(, vvcc);
>  else if (nal_type == VVC_SPS_NUT)
>  ret = vvcc_parse_sps(, vvcc);
> @@ -551,11 +538,6 @@ static int vvcc_add_nal_unit(uint8_t *nal_buf,
> uint32_t nal_size,
>  }
>  if (ret < 0)
>  goto end;
> -break;
> -default:
> -ret = AVERROR_INVALIDDATA;
> -goto end;
> -}
>
>end:
>  av_free(rbsp_buf);
> @@ -572,22 +554,21 @@ static void vvcc_init(VVCDecoderConfigurationRecord
> *vvcc)
>
>  static void vvcc_close(VVCDecoderConfigurationRecord *vvcc)
>  {
> -uint8_t i;
> +for (unsigned i = 0; i < FF_ARRAY_ELEMS(vvcc->arrays); i++) {
> +VVCCNALUnitArray *const array = >arrays[i];
>
> -for (i = 0; i < vvcc->num_of_arrays; i++) {
> -vvcc->array[i].num_nalus = 0;
> -av_freep(>array[i].nal_unit);
> -av_freep(>array[i].nal_unit_length);
> +array->num_nalus = 0;
> +

Re: [FFmpeg-devel] [PATCH 4/7] avformat/vvc: Fix crash on allocation failure, avoid allocations

2024-06-06 Thread Nuo Mi
On Wed, Jun 5, 2024 at 7:53 PM Andreas Rheinhardt <
andreas.rheinha...@outlook.com> wrote:

> Andreas Rheinhardt:
> > This is the VVC version of 8b5d15530127fea54e934043a64653859de07353.
> >
> > (Hint: This ensures that the order of NALU arrays is OPI-VPS-SPS-PPS-
> > Prefix-SEI-Suffix-SEI, regardless of the order in the original
> > extradata. I hope this is right.)
> >
> > Signed-off-by: Andreas Rheinhardt 
> > ---
> >  libavformat/vvc.c | 169 --
> >  1 file changed, 73 insertions(+), 96 deletions(-)
> >
>
> Even after these patches, there are some strange things going in vvc.c:
> 1. There are at least 71 bits in general_constraint_info (if present),
> yet only 70 of these are written (the
> gci_no_chroma_qp_offset_constraint_flag is not).
>
Not sure why this happened, but 14496-15 said  this
see the comment:
/*
 * unsigned int (1) ptl_frame_only_constraint_flag
 * unsigned int (1) ptl_multilayer_enabled_flag
 * unsigned int (8*num_bytes_constraint_info -2)
general_constraint_info */
 8*9-2 = 70.
vvcc_parse_ptl parses the information from vps or sps.
vvcc_write writes VvcDecoderConfigurationRecord, it's not a bit-to-bit map.
I guess.

2. The code contains checks for VVC_DCI_NUT, yet these are dead, because
> these NALU type is filtered out before.
>
it's from the spec, see "if (NAL_unit_type != DCI_NUT  &&  NAL_unit_type !=
OPI_NUT)" in  https://cloud.tencent.com/developer/article/2227294
num_nalus is inferred as 1 if it does not exist. Maybe we can add a check

3. A comment claims to need at least one VPS and SPS, but it actually
> checks for SPS and PPS. Does someone know what was intended?
>
it's a typo. VPS is optional, SPS and PPS are mandatory.

>
> - Andreas
>
> ___
> 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".
>
___
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 v2 1/2] lavc/vvc: Use sps_chroma_qp_table return code

2024-06-05 Thread Nuo Mi
this code is simple, you can combine it with the next one

On Wed, Jun 5, 2024 at 5:24 PM Frank Plowman  wrote:

> Signed-off-by: Frank Plowman 
> ---
>  libavcodec/vvc/ps.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/vvc/ps.c b/libavcodec/vvc/ps.c
> index 1b23675c98..bfc3c121fd 100644
> --- a/libavcodec/vvc/ps.c
> +++ b/libavcodec/vvc/ps.c
> @@ -186,8 +186,11 @@ static int sps_derive(VVCSPS *sps, void *log_ctx)
>  sps_inter(sps);
>  sps_partition_constraints(sps);
>  sps_ladf(sps);
> -if (r->sps_chroma_format_idc != 0)
> -sps_chroma_qp_table(sps);
> +if (r->sps_chroma_format_idc != 0) {
> +ret = sps_chroma_qp_table(sps);
> +if (ret < 0)
> +return ret;
> +}
>
>  return 0;
>  }
> --
> 2.45.1
>
> ___
> 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".
>
___
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 v2 2/2] lavc/vvc: Prevent overflow in chroma QP derivation

2024-06-05 Thread Nuo Mi
Hi Frank,
Thank you for the patch

On Wed, Jun 5, 2024 at 5:24 PM Frank Plowman  wrote:

> On the top of p. 112 in VVC (09/2023):
>
> It is a requirement of bitstream conformance that the values of
> qpInVal[ i ][ j ] and qpOutVal[ i ][ j ] shall be in the range
> of −QpBdOffset to 63, inclusive for i in the range of 0 to
>
Then, why do we not check −QpBdOffset?

> numQpTables − 1, inclusive, and j in the range of 0 to
> sps_num_points_in_qp_table_minus1[ i ] + 1, inclusive.
>
> Signed-off-by: Frank Plowman 
> ---
>  libavcodec/vvc/ps.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/vvc/ps.c b/libavcodec/vvc/ps.c
> index bfc3c121fd..c4f64d5da7 100644
> --- a/libavcodec/vvc/ps.c
> +++ b/libavcodec/vvc/ps.c
> @@ -101,9 +101,14 @@ static int sps_chroma_qp_table(VVCSPS *sps)
>
>  qp_out[0] = qp_in[0] = r->sps_qp_table_start_minus26[i] + 26;
>  for (int j = 0; j < num_points_in_qp_table; j++ ) {
> +const uint8_t delta_qp_out =
> (r->sps_delta_qp_in_val_minus1[i][j] ^ r->sps_delta_qp_diff_val[i][j]);
>  delta_qp_in[j] = r->sps_delta_qp_in_val_minus1[i][j] + 1;
> +if (qp_in[j] + delta_qp_in[j] > 63)
> +return AVERROR(EINVAL);
>  qp_in[j+1] = qp_in[j] + delta_qp_in[j];
> -qp_out[j+1] = qp_out[j] +
> (r->sps_delta_qp_in_val_minus1[i][j] ^ r->sps_delta_qp_diff_val[i][j]);
> +if (qp_out[j] + delta_qp_out > 63)
> +return AVERROR(EINVAL);
> +qp_out[j+1] = qp_out[j] + delta_qp_out;
>
Instead of changing so many lines, we can  add 2 lines here
if (qp_in[j+1] < 63 ||  qp_out[j+1] < 63)
return AVERROR(EINVAL);

>  }
>  sps->chroma_qp_table[i][qp_in[0] + off] = qp_out[0];
>  for (int k = qp_in[0] - 1 + off; k >= 0; k--)
> --
> 2.45.1
>
> ___
> 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".
>
___
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] lavc/vvc: Reallocate pixel buffers if pixel shift changes

2024-06-04 Thread Nuo Mi
On Mon, Jun 3, 2024 at 9:06 PM Frank Plowman  wrote:

> Allocations in the following lines depend on the pixel shift, and so
> these buffers must be reallocated if the pixel shift changes.  Patch
> fixes segmentation faults in fuzzed bitstreams.
>
> Signed-off-by: Frank Plowman 
> ---
>  libavcodec/vvc/dec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c
> index e53ad4e607..f5603306f3 100644
> --- a/libavcodec/vvc/dec.c
> +++ b/libavcodec/vvc/dec.c
> @@ -214,7 +214,8 @@ static void pixel_buffer_nz_tl_init(TabList *l,
> VVCFrameContext *fc)
>  const int c_end  = chroma_idc ? VVC_MAX_SAMPLE_ARRAYS : 1;
>  const int changed= fc->tab.sz.chroma_format_idc != chroma_idc ||
>  fc->tab.sz.width != width || fc->tab.sz.height != height ||
> -fc->tab.sz.ctu_width != ctu_width || fc->tab.sz.ctu_height !=
> ctu_height;
> +fc->tab.sz.ctu_width != ctu_width || fc->tab.sz.ctu_height !=
> ctu_height ||
> +fc->tab.sz.pixel_shift != ps;
>
> Applied.

Thank you, Frank.

>  tl_init(l, 0, changed);
>
> --
> 2.45.1
>
> ___
> 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".
>
___
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 5/5] avcodec/vvcdec: support mv wraparound

2024-06-04 Thread Nuo Mi
On Tue, Jun 4, 2024 at 8:41 AM Michael Niedermayer 
wrote:

> On Mon, Jun 03, 2024 at 08:51:16PM +0800, Nuo Mi wrote:
> > A 360 video specific tool
> > see https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9503377
> >
> > passed files:
> > DMVR_A_Huawei_3.bit
> > WRAP_D_InterDigital_4.bit
> > WRAP_A_InterDigital_4.bit
> > WRAP_B_InterDigital_4.bit
> > WRAP_C_InterDigital_4.bit
> > ERP_A_MediaTek_3.bit
> > ---
> >  libavcodec/vvc/inter.c | 81 --
> >  1 file changed, 79 insertions(+), 2 deletions(-)
>
> seems to break fate-vvc-conformance-WRAP_A_4, maybe the fate checksums
> need to be updated ?
>
Hi Michael,
Sorry for missing the fate test
Yes, we need to update the reference. v2 will fix it

thank you.

>
> TESTvvc-conformance-WRAP_A_4
> --- ./tests/ref/fate/vvc-conformance-WRAP_A_4   2024-06-03
> 22:55:42.173081332 +0200
> +++ tests/data/fate/vvc-conformance-WRAP_A_42024-06-04
> 02:39:44.835650168 +0200
> @@ -4,11 +4,11 @@
>  #dimensions 0: 1680x832
>  #sar 0: 0/1
>  0,  0,  0,1,  4193280, 0xbd70f1b3
> -0,  1,  1,1,  4193280, 0x64e160d5
> -0,  2,  2,1,  4193280, 0xd20722ea
> -0,  3,  3,1,  4193280, 0xa1d00055
> -0,  4,  4,1,  4193280, 0xe3dcb9cd
> -0,  5,  5,1,  4193280, 0xcf97b6cf
> -0,  6,  6,1,  4193280, 0xd87b73d0
> -0,  7,  7,1,  4193280, 0x0f8ee2bc
> -0,  8,  8,1,  4193280, 0x76607ca4
> +0,  1,  1,1,  4193280, 0x491104c9
> +0,  2,  2,1,  4193280, 0xf600c2c1
> +0,  3,  3,1,  4193280, 0x1e3c8e2b
> +0,  4,  4,1,  4193280, 0xad275e45
> +0,  5,  5,1,  4193280, 0xcd6103d7
> +0,  6,  6,1,  4193280, 0x0ec8cfbd
> +0,  7,  7,1,  4193280, 0x2f664486
> +0,  8,  8,1,  4193280, 0x543eb3fc
> Test vvc-conformance-WRAP_A_4 failed. Look at
> tests/data/fate/vvc-conformance-WRAP_A_4.err for details.
> make: *** [tests/Makefile:311: fate-vvc-conformance-WRAP_A_4] Error 1
>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Some people wanted to paint the bikeshed green, some blue and some pink.
> People argued and fought, when they finally agreed, only rust was left.
> ___
> 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".
>
___
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".


[FFmpeg-devel] [PATCH v2 5/5] avcodec/vvcdec: support mv wraparound

2024-06-04 Thread Nuo Mi
A 360 video specific tool
see https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9503377

passed files:
DMVR_A_Huawei_3.bit
WRAP_D_InterDigital_4.bit
WRAP_A_InterDigital_4.bit
WRAP_B_InterDigital_4.bit
WRAP_C_InterDigital_4.bit
ERP_A_MediaTek_3.bit
---
 libavcodec/vvc/inter.c  | 81 -
 tests/ref/fate/vvc-conformance-WRAP_A_4 | 16 ++---
 2 files changed, 87 insertions(+), 10 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 09575eb2b4..98cb43322f 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -95,20 +95,97 @@ static void emulated_edge_no_wrap(const VVCLocalContext 
*lc, uint8_t *dst,
 }
 }
 
+static void emulated_half(const VVCLocalContext *lc, uint8_t *dst, const 
ptrdiff_t dst_stride,
+const uint8_t *src, const ptrdiff_t src_stride, const int ps,
+int x_off, int y_off, const int block_w, const int block_h,
+const VVCRect *subpic,const VVCRect *half_sb, const int dmvr_clip)
+{
+const VVCFrameContext *fc = lc->fc;
+int pic_width, pic_height;
+
+src += y_off * src_stride + x_off * (1 << ps);
+
+clip_to_subpic(_off, _off, _width, _height, subpic, half_sb, 
dmvr_clip);
+
+fc->vdsp.emulated_edge_mc(dst, src, dst_stride, src_stride,
+block_w, block_h, x_off, y_off, pic_width, pic_height);
+}
+
+static void sb_set_lr(VVCRect *sb, const int l, const int r)
+{
+sb->l = l;
+sb->r = r;
+}
+
+static void sb_wrap(VVCRect *sb, const int wrap)
+{
+sb_set_lr(sb, sb->l + wrap, sb->r + wrap);
+}
+
 static void emulated_edge(const VVCLocalContext *lc, uint8_t *dst,
 const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame,
 int x_sb, int y_sb, int x_off, int y_off, int block_w, int block_h, const 
int wrap_enabled,
 const int is_chroma, const int extra_before, const int extra_after)
 {
+const VVCSPS *sps  = src_frame->sps;
+const VVCPPS *pps  = src_frame->pps;
+const int ps   = sps->pixel_shift;
 const int subpic_idx   = lc->sc->sh.r->curr_subpic_idx;
+const int extra= extra_before + extra_after;
 const int dmvr_clip= x_sb != x_off || y_sb != y_off;
+const int dmvr_left= FFMAX(x_off, x_sb) - extra_before;
+const int dmvr_right   = FFMIN(x_off, x_sb) + block_w + extra_after;
+const int left = x_off - extra_before;
+const int top  = y_off - extra_before;
+const int pic_width= pps->width >> sps->hshift[is_chroma];
+const int wrap = pps->ref_wraparound_offset << 
(sps->min_cb_log2_size_y - sps->hshift[is_chroma]);
+const ptrdiff_t dst_stride = EDGE_EMU_BUFFER_STRIDE << ps;
 VVCRect sb = { x_sb - extra_before, y_sb - extra_before, 
x_sb + block_w + extra_after, y_sb + block_h + extra_after };
 VVCRect subpic;
 
 subpic_get_rect(, src_frame, subpic_idx, is_chroma);
 
-return emulated_edge_no_wrap(lc, dst, src, src_stride,
-x_off, y_off, block_w, block_h, extra_before, extra_after, , 
, dmvr_clip);
+if (!wrap_enabled || (dmvr_left >= 0 && dmvr_right <= pic_width)) {
+return emulated_edge_no_wrap(lc, dst, src, src_stride,
+x_off, y_off, block_w, block_h, extra_before, extra_after, 
, , dmvr_clip);
+}
+if (dmvr_right <= 0) {
+sb_wrap(, wrap);
+return emulated_edge_no_wrap(lc, dst, src, src_stride,
+x_off + wrap, y_off, block_w, block_h, extra_before, extra_after, 
, , dmvr_clip);
+}
+if (dmvr_left >= pic_width) {
+sb_wrap(, -wrap);
+return emulated_edge_no_wrap(lc, dst, src, src_stride,
+x_off - wrap, y_off, block_w, block_h, extra_before, extra_after, 
, , dmvr_clip);
+}
+
+block_w += extra;
+block_h += extra;
+
+// half block are wrapped
+if (dmvr_left < 0 ) {
+const int w = -left;
+VVCRect half_sb = { sb.l + wrap, sb.t, 0 + wrap, sb.b };
+emulated_half(lc, dst, dst_stride, *src, *src_stride, ps,
+left + wrap, top, w, block_h, , _sb, dmvr_clip);
+
+sb_set_lr(_sb, 0, sb.r);
+emulated_half(lc, dst +  (w << ps), dst_stride, *src, *src_stride, ps,
+0, top, block_w - w, block_h, , _sb, dmvr_clip);
+} else {
+const int w = pic_width - left;
+VVCRect half_sb = { sb.l, sb.t, pic_width, sb.b };
+emulated_half(lc, dst, dst_stride, *src, *src_stride, ps,
+left, top, w, block_h, , _sb, dmvr_clip);
+
+sb_set_lr(_sb, pic_width - wrap, sb.r - wrap);
+emulated_half(lc, dst +  (w << ps), dst_stride, *src, *src_stride, ps,
+pic_width - wrap , top, block_w - w, block_h, , _sb, 
dmvr_clip);
+}
+
+*src = dst + extra_before * dst_stride + (extra_before << ps);
+*src_stride = dst_stride;
 }
 
 #define MC_EMULATED_EDGE(dst, src, src_stride, x_off, y_off)   
 

[FFmpeg-devel] [PATCH v2 4/5] avcodec/vvcdec: misc, reindent inter.c

2024-06-04 Thread Nuo Mi
---
 libavcodec/vvc/inter.c | 278 -
 1 file changed, 139 insertions(+), 139 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index aacd5d8da0..09575eb2b4 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -127,14 +127,14 @@ static void emulated_edge(const VVCLocalContext *lc, 
uint8_t *dst,
 static int derive_weight_uni(int *denom, int *wx, int *ox,
 const VVCLocalContext *lc, const MvField *mvf, const int c_idx)
 {
-const VVCFrameContext *fc   = lc->fc;
-const VVCPPS *pps   = fc->ps.pps;
-const VVCSH *sh = >sc->sh;
-const int weight_flag   = (IS_P(sh->r) && 
pps->r->pps_weighted_pred_flag) ||
+const VVCFrameContext *fc = lc->fc;
+const VVCPPS *pps = fc->ps.pps;
+const VVCSH *sh   = >sc->sh;
+const int weight_flag = (IS_P(sh->r) && 
pps->r->pps_weighted_pred_flag) ||
   (IS_B(sh->r) && 
pps->r->pps_weighted_bipred_flag);
 if (weight_flag) {
-const int lx= mvf->pred_flag - PF_L0;
-const PredWeightTable *w= pps->r->pps_wp_info_in_ph_flag ? 
>ps.ph.pwt : >pwt;
+const int lx = mvf->pred_flag - PF_L0;
+const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? 
>ps.ph.pwt : >pwt;
 
 *denom = w->log2_denom[c_idx > 0];
 *wx = w->weight[lx][c_idx][mvf->ref_idx[lx]];
@@ -147,11 +147,11 @@ static int derive_weight_uni(int *denom, int *wx, int *ox,
 static int derive_weight(int *denom, int *w0, int *w1, int *o0, int *o1,
 const VVCLocalContext *lc, const MvField *mvf, const int c_idx, const int 
dmvr_flag)
 {
-const VVCFrameContext *fc   = lc->fc;
-const VVCPPS *pps   = fc->ps.pps;
-const VVCSH *sh = >sc->sh;
-const int bcw_idx   = mvf->bcw_idx;
-const int weight_flag   = (IS_P(sh->r) && 
pps->r->pps_weighted_pred_flag) ||
+const VVCFrameContext *fc = lc->fc;
+const VVCPPS *pps = fc->ps.pps;
+const VVCSH *sh   = >sc->sh;
+const int bcw_idx = mvf->bcw_idx;
+const int weight_flag = (IS_P(sh->r) && 
pps->r->pps_weighted_pred_flag) ||
   (IS_B(sh->r) && 
pps->r->pps_weighted_bipred_flag && !dmvr_flag);
 if ((!weight_flag && !bcw_idx) || (bcw_idx && lc->cu->ciip_flag))
 return 0;
@@ -162,7 +162,7 @@ static int derive_weight(int *denom, int *w0, int *w1, int 
*o0, int *o1,
 *w0 = 8 - *w1;
 *o0 = *o1 = 0;
 } else {
-const VVCPPS *pps = fc->ps.pps;
+const VVCPPS *pps= fc->ps.pps;
 const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? 
>ps.ph.pwt : >pwt;
 
 *denom = w->log2_denom[c_idx > 0];
@@ -179,20 +179,20 @@ static int derive_weight(int *denom, int *w0, int *w1, 
int *o0, int *o1,
 static void mc(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref, const 
Mv *mv,
 int x_off, int y_off, const int block_w, const int block_h, const int 
c_idx)
 {
-const VVCFrameContext *fc   = lc->fc;
-const PredictionUnit *pu= >cu->pu;
-const uint8_t *src  = ref->frame->data[c_idx];
-ptrdiff_t src_stride= ref->frame->linesize[c_idx];
-const int is_chroma = !!c_idx;
-const int hs= fc->ps.sps->hshift[c_idx];
-const int vs= fc->ps.sps->vshift[c_idx];
-const int idx   = av_log2(block_w) - 1;
-const intptr_t mx   = av_mod_uintp2(mv->x, 4 + hs) << (is_chroma - 
hs);
-const intptr_t my   = av_mod_uintp2(mv->y, 4 + vs) << (is_chroma - 
vs);
-const int hpel_if_idx   = (is_chroma || pu->merge_gpm_flag) ? 0 : 
pu->mi.hpel_if_idx;
-const int8_t *hf= INTER_FILTER(hpel_if_idx, mx);
-const int8_t *vf= INTER_FILTER(hpel_if_idx, my);
-const int wrap_enabled  = 
fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
+const VVCFrameContext *fc = lc->fc;
+const PredictionUnit *pu  = >cu->pu;
+const uint8_t *src= ref->frame->data[c_idx];
+ptrdiff_t src_stride  = ref->frame->linesize[c_idx];
+const int is_chroma   = !!c_idx;
+const int hs  = fc->ps.sps->hshift[c_idx];
+const int vs  = fc->ps.sps->vshift[c_idx];
+const int idx = av_log2(block_w) - 1;
+const intptr_t mx = av_mod_uintp2(mv->x, 4 + hs) << (is_chroma - 
hs);
+const intptr_t my = av_mod_uintp2(mv->y, 4 + vs) << (is_chroma - 
vs);
+const int hpel_if_idx = (is_chroma || pu->merge_gpm_flag) ? 0 : 
pu->mi.hpel_if_idx;
+const int8_t *hf  = INTER_FILTER(hpel_if_idx, mx);
+const int8_t *vf  = INTER_FILTER(hpel_if_idx, my);
+const int wrap_enabled= fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
 
 x_off += mv->x >> (4 + hs);
 y_off += mv->y >> (4 + vs);
@@ -205,22 +205,22 @@ static void 

[FFmpeg-devel] [PATCH v2 3/5] avcodec/vvcdec: refact out emulated_edge_no_wrap

2024-06-04 Thread Nuo Mi
prepare for refrence wraparound
---
 libavcodec/vvc/inter.c | 91 --
 1 file changed, 61 insertions(+), 30 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 07b55c4bac..aacd5d8da0 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -30,46 +30,53 @@
 #define PROF_TEMP_OFFSET (MAX_PB_SIZE + 32)
 static const int bcw_w_lut[] = {4, 5, 3, 10, -2};
 
-static void subpic_offset(int *x_off, int *y_off,
-const VVCSPS *sps, const VVCPPS *pps, const int subpic_idx, const int 
is_chroma)
+typedef struct VVCRect {
+int l;  // left
+int t;  // top
+int r;  // right
+int b;  // bottom
+} VVCRect;
+
+static void subpic_get_rect(VVCRect *r, const VVCFrame *src_frame, const int 
subpic_idx, const int is_chroma)
 {
-*x_off -= pps->subpic_x[subpic_idx] >> sps->hshift[is_chroma];
-*y_off -= pps->subpic_y[subpic_idx] >> sps->vshift[is_chroma];
+const VVCSPS *sps = src_frame->sps;
+const VVCPPS *pps = src_frame->pps;
+const int hs  = sps->hshift[is_chroma];
+const int vs  = sps->vshift[is_chroma];
+
+r->l = pps->subpic_x[subpic_idx] >> hs;
+r->t = pps->subpic_y[subpic_idx] >> vs;
+r->r = r->l + (pps->subpic_width[subpic_idx]  >> hs);
+r->b = r->t + (pps->subpic_height[subpic_idx] >> vs);
 }
 
-static void subpic_width_height(int *pic_width, int *pic_height,
-const VVCSPS *sps, const VVCPPS *pps, const int subpic_idx, const int 
is_chroma)
+// clip to subblock and subpicture process in 8.5.6.3.2 Luma sample 
interpolation filtering process
+static void clip_to_subpic(int *x_off, int *y_off, int *pic_width, int 
*pic_height, const VVCRect *subpic, const VVCRect *sb, const int dmvr_clip)
 {
-*pic_width  = pps->subpic_width[subpic_idx]  >> sps->hshift[is_chroma];
-*pic_height = pps->subpic_height[subpic_idx] >> sps->vshift[is_chroma];
+const int l = dmvr_clip ? FFMIN(FFMAX(subpic->l, sb->l), subpic->r - 1) : 
subpic->l;
+const int t = dmvr_clip ? FFMIN(FFMAX(subpic->t, sb->t), subpic->b - 1) : 
subpic->t;
+const int r = dmvr_clip ? FFMAX(FFMIN(subpic->r, sb->r), subpic->l + 1) : 
subpic->r;
+const int b = dmvr_clip ? FFMAX(FFMIN(subpic->b, sb->b), subpic->t + 1) : 
subpic->b;
+
+*x_off -= l;
+*y_off -= t;
+*pic_width  = r - l;
+*pic_height = b - t;
 }
 
-static void emulated_edge(const VVCLocalContext *lc, uint8_t *dst,
-const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame,
-int x_sb, int y_sb, int x_off, int y_off, const int block_w, const int 
block_h,
-const int is_chroma, const int extra_before, const int extra_after)
+static void emulated_edge_no_wrap(const VVCLocalContext *lc, uint8_t *dst,
+const uint8_t **src, ptrdiff_t *src_stride,
+int x_off, int y_off, const int block_w, const int block_h,
+const int extra_before, const int extra_after,
+const VVCRect *subpic, const VVCRect *sb, const int dmvr_clip)
 {
 const VVCFrameContext *fc = lc->fc;
-const VVCSPS *sps = src_frame->sps;
-const VVCPPS *pps = src_frame->pps;
-const int subpic_idx  = lc->sc->sh.r->curr_subpic_idx;
 const int extra   = extra_before + extra_after;
-const int dmvr_clip   = x_sb != x_off || y_sb != y_off;
 int pic_width, pic_height;
 
 *src  += y_off * *src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
 
-subpic_offset(_off, _off, sps, pps, subpic_idx, is_chroma);
-subpic_offset(_sb, _sb, sps, pps, subpic_idx, is_chroma);
-subpic_width_height(_width, _height, sps, pps, subpic_idx, 
is_chroma);
-if (dmvr_clip) {
-const int start_x = FFMIN(FFMAX(x_sb - extra_before, 0), pic_width  - 
1);
-const int start_y = FFMIN(FFMAX(y_sb - extra_before, 0), pic_height - 
1);
-pic_width  = FFMAX(FFMIN(pic_width, x_sb + block_w + extra_after) - 
start_x, 1);
-pic_height = FFMAX(FFMIN(pic_height, y_sb + block_h + extra_after) - 
start_y, 1);
-x_off -= start_x;
-y_off -= start_y;
-}
+clip_to_subpic(_off, _off, _width, _height, subpic, sb, 
dmvr_clip);
 
 if (dmvr_clip || x_off < extra_before || y_off < extra_before ||
 x_off >= pic_width - block_w - extra_after ||
@@ -88,16 +95,32 @@ static void emulated_edge(const VVCLocalContext *lc, 
uint8_t *dst,
 }
 }
 
+static void emulated_edge(const VVCLocalContext *lc, uint8_t *dst,
+const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame,
+int x_sb, int y_sb, int x_off, int y_off, int block_w, int block_h, const 
int wrap_enabled,
+const int is_chroma, const int extra_before, const int extra_after)
+{
+const int subpic_idx   = lc->sc->sh.r->curr_subpic_idx;
+const int dmvr_clip= x_sb != x_off || y_sb != y_off;
+VVCRect sb = { x_sb - extra_before, y_sb - extra_before, 
x_sb + block_w + extra_after, y_sb + block_h 

[FFmpeg-devel] [PATCH v2 2/5] avcodec/vvcdec: misc, move src offset inside emulated_edge

2024-06-04 Thread Nuo Mi
---
 libavcodec/vvc/inter.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 0843c99eb6..07b55c4bac 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -57,6 +57,8 @@ static void emulated_edge(const VVCLocalContext *lc, uint8_t 
*dst,
 const int dmvr_clip   = x_sb != x_off || y_sb != y_off;
 int pic_width, pic_height;
 
+*src  += y_off * *src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
+
 subpic_offset(_off, _off, sps, pps, subpic_idx, is_chroma);
 subpic_offset(_sb, _sb, sps, pps, subpic_idx, is_chroma);
 subpic_width_height(_width, _height, sps, pps, subpic_idx, 
is_chroma);
@@ -170,7 +172,6 @@ static void mc(VVCLocalContext *lc, int16_t *dst, const 
VVCFrame *ref, const Mv
 
 x_off += mv->x >> (4 + hs);
 y_off += mv->y >> (4 + vs);
-src  += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
 
 MC_EMULATED_EDGE(lc->edge_emu_buffer, , _stride, x_off, y_off);
 fc->vvcdsp.inter.put[is_chroma][idx][!!my][!!mx](dst, src, src_stride, 
block_h, hf, vf, block_w);
@@ -199,7 +200,6 @@ static void mc_uni(VVCLocalContext *lc, uint8_t *dst, const 
ptrdiff_t dst_stride
 
 x_off += mv->x >> (4 + hs);
 y_off += mv->y >> (4 + vs);
-src  += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
 
 MC_EMULATED_EDGE(lc->edge_emu_buffer, , _stride, x_off, y_off);
 if (derive_weight_uni(, , , lc, mvf, c_idx)) {
@@ -236,7 +236,7 @@ static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const 
ptrdiff_t dst_stride,
 const int oy= y_off + (mv->y >> (4 + vs));
 const VVCFrame *ref = refs[i];
 ptrdiff_t src_stride= ref->frame->linesize[c_idx];
-const uint8_t *src  = ref->frame->data[c_idx] + oy * src_stride + 
(ox * (1 << fc->ps.sps->pixel_shift));
+const uint8_t *src  = ref->frame->data[c_idx];
 const int8_t *hf= INTER_FILTER(hpel_if_idx, mx);
 const int8_t *vf= INTER_FILTER(hpel_if_idx, my);
 
@@ -306,7 +306,6 @@ static void scaled_ref_pos_and_step(const VVCLocalContext 
*lc, const VVCRefPic *
 static void emulated_edge_scaled(VVCLocalContext *lc, const uint8_t **src, 
ptrdiff_t *src_stride, int *src_height,
 const VVCFrame *ref, const int x, const int y, const int dx, const int dy, 
const int w, const int h, const int is_chroma)
 {
-const VVCFrameContext *fc = lc->fc;
 const int x_off   = SCALED_INT(x);
 const int y_off   = SCALED_INT(y);
 const int x_end   = SCALED_INT(x + w * dx);
@@ -316,8 +315,6 @@ static void emulated_edge_scaled(VVCLocalContext *lc, const 
uint8_t **src, ptrdi
 const int block_w = x_end - x_off + (x_end == x_last);
 const int block_h = *src_height = y_end - y_off + (y_end == 
y_last);
 
-*src  += y_off * *src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
-
 MC_EMULATED_EDGE(lc->edge_emu_buffer, src, src_stride, x_off, y_off);
 }
 
@@ -414,7 +411,6 @@ static void luma_prof_uni(VVCLocalContext *lc, uint8_t 
*dst, const ptrdiff_t dst
 
 x_off += mv->x >> 4;
 y_off += mv->y >> 4;
-src   += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
 
 MC_EMULATED_EDGE(lc->edge_emu_buffer, , _stride, x_off, y_off);
 if (cb_prof_flag) {
@@ -444,8 +440,8 @@ static void luma_prof(VVCLocalContext *lc, int16_t *dst, 
const VVCFrame *ref,
 const int idx = av_log2(block_w) - 1;
 const int is_chroma   = 0;
 uint16_t *prof_tmp= lc->tmp2 + PROF_TEMP_OFFSET;
-ptrdiff_t src_stride  = ref->frame->linesize[0];
-const uint8_t *src= ref->frame->data[0] + oy * src_stride + (ox * 
(1 << fc->ps.sps->pixel_shift));
+ptrdiff_t src_stride  = ref->frame->linesize[LUMA];
+const uint8_t *src= ref->frame->data[LUMA];
 const int8_t *hf  = 
ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
 const int8_t *vf  = 
ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
 
@@ -704,7 +700,7 @@ static void dmvr_mv_refine(VVCLocalContext *lc, MvField 
*mvf, MvField *orig_mv,
 const int oy= y_off + (mv->y >> 4) - sr_range;
 const VVCFrame *ref = refs[i];
 ptrdiff_t src_stride= ref->frame->linesize[LUMA];
-const uint8_t *src  = ref->frame->data[LUMA] + oy * src_stride + 
(ox * (1 << fc->ps.sps->pixel_shift));
+const uint8_t *src  = ref->frame->data[LUMA];
 MC_EMULATED_EDGE_BILINEAR(lc->edge_emu_buffer, , _stride, ox, 
oy);
 fc->vvcdsp.inter.dmvr[!!my][!!mx](tmp[i], src, src_stride, pred_h, mx, 
my, pred_w);
 }
-- 
2.34.1

___
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 

[FFmpeg-devel] [PATCH v2 1/5] avcodec/vvcdec: refact, remove emulated_edge_dmvr and emulated_edge_bilinear to simplify code

2024-06-04 Thread Nuo Mi
---
 libavcodec/vvc/inter.c | 146 +
 1 file changed, 46 insertions(+), 100 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index e1011b4fa1..0843c99eb6 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -44,112 +44,59 @@ static void subpic_width_height(int *pic_width, int 
*pic_height,
 *pic_height = pps->subpic_height[subpic_idx] >> sps->vshift[is_chroma];
 }
 
-static int emulated_edge(const VVCLocalContext *lc, uint8_t *dst, const 
uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame,
-int x_off, int y_off, const int block_w, const int block_h, const int 
is_chroma)
+static void emulated_edge(const VVCLocalContext *lc, uint8_t *dst,
+const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame,
+int x_sb, int y_sb, int x_off, int y_off, const int block_w, const int 
block_h,
+const int is_chroma, const int extra_before, const int extra_after)
 {
 const VVCFrameContext *fc = lc->fc;
 const VVCSPS *sps = src_frame->sps;
 const VVCPPS *pps = src_frame->pps;
 const int subpic_idx  = lc->sc->sh.r->curr_subpic_idx;
-const int extra_before= is_chroma ? CHROMA_EXTRA_BEFORE : 
LUMA_EXTRA_BEFORE;
-const int extra_after = is_chroma ? CHROMA_EXTRA_AFTER : 
LUMA_EXTRA_AFTER;
-const int extra   = is_chroma ? CHROMA_EXTRA : LUMA_EXTRA;
-int pic_width, pic_height;
-
-subpic_offset(_off, _off, sps, pps, subpic_idx, is_chroma);
-subpic_width_height(_width, _height, sps, pps, subpic_idx, 
is_chroma);
-
-if (x_off < extra_before || y_off < extra_before ||
-x_off >= pic_width - block_w - extra_after ||
-y_off >= pic_height - block_h - extra_after) {
-const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << 
fc->ps.sps->pixel_shift;
-int offset = extra_before * *src_stride  + (extra_before << 
fc->ps.sps->pixel_shift);
-int buf_offset = extra_before * edge_emu_stride + (extra_before << 
fc->ps.sps->pixel_shift);
-
-fc->vdsp.emulated_edge_mc(dst, *src - offset, edge_emu_stride, 
*src_stride,
-block_w + extra, block_h + extra, x_off - extra_before, y_off - 
extra_before,
-pic_width, pic_height);
-
-*src = dst + buf_offset;
-*src_stride = edge_emu_stride;
-return 1;
-}
-return 0;
-}
-
-static void emulated_edge_dmvr(const VVCLocalContext *lc, uint8_t *dst, const 
uint8_t **src, ptrdiff_t *src_stride,
-int x_sb, int y_sb, int x_off,  int y_off, const int block_w, const int 
block_h, const int is_chroma)
-{
-const VVCFrameContext *fc = lc->fc;
-const VVCSPS *sps = fc->ps.sps;
-const VVCPPS *pps = fc->ps.pps;
-const int subpic_idx  = lc->sc->sh.r->curr_subpic_idx;
-const int extra_before= is_chroma ? CHROMA_EXTRA_BEFORE : 
LUMA_EXTRA_BEFORE;
-const int extra_after = is_chroma ? CHROMA_EXTRA_AFTER : 
LUMA_EXTRA_AFTER;
-const int extra   = is_chroma ? CHROMA_EXTRA : LUMA_EXTRA;
+const int extra   = extra_before + extra_after;
+const int dmvr_clip   = x_sb != x_off || y_sb != y_off;
 int pic_width, pic_height;
 
 subpic_offset(_off, _off, sps, pps, subpic_idx, is_chroma);
 subpic_offset(_sb, _sb, sps, pps, subpic_idx, is_chroma);
 subpic_width_height(_width, _height, sps, pps, subpic_idx, 
is_chroma);
+if (dmvr_clip) {
+const int start_x = FFMIN(FFMAX(x_sb - extra_before, 0), pic_width  - 
1);
+const int start_y = FFMIN(FFMAX(y_sb - extra_before, 0), pic_height - 
1);
+pic_width  = FFMAX(FFMIN(pic_width, x_sb + block_w + extra_after) - 
start_x, 1);
+pic_height = FFMAX(FFMIN(pic_height, y_sb + block_h + extra_after) - 
start_y, 1);
+x_off -= start_x;
+y_off -= start_y;
+}
 
-if (x_off < extra_before || y_off < extra_before ||
+if (dmvr_clip || x_off < extra_before || y_off < extra_before ||
 x_off >= pic_width - block_w - extra_after ||
-y_off >= pic_height - block_h - extra_after||
-(x_off != x_sb || y_off !=  y_sb)) {
+y_off >= pic_height - block_h - extra_after) {
 const int ps= fc->ps.sps->pixel_shift;
 const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << ps;
-const int offset= extra_before * *src_stride + 
(extra_before << ps);
+const int offset= extra_before * *src_stride + 
(extra_before << ps);
 const int buf_offset= extra_before * edge_emu_stride + 
(extra_before << ps);
 
-const int start_x   = FFMIN(FFMAX(x_sb - extra_before, 0), 
pic_width  - 1);
-const int start_y   = FFMIN(FFMAX(y_sb - extra_before, 0), 
pic_height - 1);
-const int width = FFMAX(FFMIN(pic_width, x_sb + 
block_w + extra_after) - start_x, 1);
-const int height   

Re: [FFmpeg-devel] [PATCH v4 1/1] avcodec: add external enc libvvenc for H266/VVC

2024-06-03 Thread Nuo Mi
Hi all,

Tested with
./ffmpeg -f lavfi -i testsrc=duration=10:size=1280x720:rate=30 -c:v
libvvenc test.mp4 && ./ffplay -strict -2 -i test.mp4

I will merge in 3 days if there are no objections.
thank you

On Wed, May 29, 2024 at 12:27 AM Christian Bartnik 
wrote:

> From: Thomas Siedel 
>
> Add external encoder VVenC for H266/VVC encoding.
> Register new encoder libvvenc.
> Add libvvenc to wrap the vvenc interface.
> libvvenc implements encoder option: preset,qp,qpa,period,
> passlogfile,stats,vvenc-params,level,tier.
> Enable encoder by adding --enable-libvvenc in configure step.
>
> Co-authored-by: Christian Bartnik chris1031...@gmail.com
> Signed-off-by: Thomas Siedel 
> ---
>  configure |   4 +
>  doc/encoders.texi |  64 +
>  fftools/ffmpeg_mux_init.c |   2 +-
>  libavcodec/Makefile   |   1 +
>  libavcodec/allcodecs.c|   1 +
>  libavcodec/libvvenc.c | 507 ++
>  6 files changed, 578 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/libvvenc.c
>
> diff --git a/configure b/configure
> index 96b181fd21..082cbca7bb 100755
> --- a/configure
> +++ b/configure
> @@ -293,6 +293,7 @@ External library support:
>--enable-libvorbis   enable Vorbis en/decoding via libvorbis,
> native implementation exists [no]
>--enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
> +  --enable-libvvencenable H.266/VVC encoding via vvenc [no]
>--enable-libwebp enable WebP encoding via libwebp [no]
>--enable-libx264 enable H.264 encoding via x264 [no]
>--enable-libx265 enable HEVC encoding via x265 [no]
> @@ -1966,6 +1967,7 @@ EXTERNAL_LIBRARY_LIST="
>  libvmaf
>  libvorbis
>  libvpx
> +libvvenc
>  libwebp
>  libxevd
>  libxeve
> @@ -3560,6 +3562,7 @@ libvpx_vp8_decoder_deps="libvpx"
>  libvpx_vp8_encoder_deps="libvpx"
>  libvpx_vp9_decoder_deps="libvpx"
>  libvpx_vp9_encoder_deps="libvpx"
> +libvvenc_encoder_deps="libvvenc"
>  libwebp_encoder_deps="libwebp"
>  libwebp_anim_encoder_deps="libwebp"
>  libx262_encoder_deps="libx262"
> @@ -7030,6 +7033,7 @@ enabled libvpx&& {
>  fi
>  }
>
> +enabled libvvenc  && require_pkg_config libvvenc "libvvenc >=
> 1.6.1" "vvenc/vvenc.h" vvenc_get_version
>  enabled libwebp   && {
>  enabled libwebp_encoder  && require_pkg_config libwebp "libwebp
> >= 0.2.0" webp/encode.h WebPGetEncoderVersion
>  enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder
> "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; }
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index c82f316f94..496852faeb 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -2378,6 +2378,70 @@ Indicates frame duration
>  For more information about libvpx see:
>  @url{http://www.webmproject.org/}
>
> +@section libvvenc
> +
> +VVenC H.266/VVC encoder wrapper.
> +
> +This encoder requires the presence of the libvvenc headers and library
> +during configuration. You need to explicitly configure the build with
> +@option{--enable-libvvenc}.
> +
> +The VVenC project website is at
> +@url{https://github.com/fraunhoferhhi/vvenc}.
> +
> +@subsection Supported Pixel Formats
> +
> +VVenC supports only 10-bit color spaces as input. But the internal
> (encoded)
> +bit depth can be set to 8-bit or 10-bit at runtime.
> +
> +@subsection Options
> +
> +@table @option
> +@item b
> +Sets target video bitrate.
> +
> +@item g
> +Set the GOP size. Currently support for g=1 (Intra only) or default.
> +
> +@item preset
> +Set the VVenC preset.
> +
> +@item levelidc
> +Set level idc.
> +
> +@item tier
> +Set vvc tier.
> +
> +@item qp
> +Set constant quantization parameter.
> +
> +@item subopt @var{boolean}
> +Set subjective (perceptually motivated) optimization. Default is 1 (on).
> +
> +@item bitdepth8 @var{boolean}
> +Set 8bit coding mode instead of using 10bit. Default is 0 (off).
> +
> +@item period
> +set (intra) refresh period in seconds.
> +
> +@item vvenc-params
> +Set vvenc options using a list of @var{key}=@var{value} couples separated
> +by ":". See @command{vvencapp --fullhelp} or @command{vvencFFapp
> --fullhelp} for a list of options.
> +
> +For example, the options might be provided as:
> +
> +@example
> +intraperiod=64:decodingrefreshtype=idr:poc0idr=1:internalbitdepth=8
> +@end example
> +
> +For example the encoding options might be provided with
> @option{-vvenc-params}:
> +
> +@example
> +ffmpeg -i input -c:v libvvenc -b 1M -vvenc-params
> intraperiod=64:decodingrefreshtype=idr:poc0idr=1:internalbitdepth=8
> output.mp4
> +@end example
> +
> +@end table
> +
>  @section libwebp
>
>  libwebp WebP Image encoder wrapper
> diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
> index 8797265145..ef2922854a 100644
> --- a/fftools/ffmpeg_mux_init.c
> +++ b/fftools/ffmpeg_mux_init.c
> @@ -739,7 +739,7 @@ static int new_stream_video(Muxer 

[FFmpeg-devel] [PATCH 2/5] avcodec/vvcdec: misc, move src offset inside emulated_edge

2024-06-03 Thread Nuo Mi
---
 libavcodec/vvc/inter.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 0843c99eb6..07b55c4bac 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -57,6 +57,8 @@ static void emulated_edge(const VVCLocalContext *lc, uint8_t 
*dst,
 const int dmvr_clip   = x_sb != x_off || y_sb != y_off;
 int pic_width, pic_height;
 
+*src  += y_off * *src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
+
 subpic_offset(_off, _off, sps, pps, subpic_idx, is_chroma);
 subpic_offset(_sb, _sb, sps, pps, subpic_idx, is_chroma);
 subpic_width_height(_width, _height, sps, pps, subpic_idx, 
is_chroma);
@@ -170,7 +172,6 @@ static void mc(VVCLocalContext *lc, int16_t *dst, const 
VVCFrame *ref, const Mv
 
 x_off += mv->x >> (4 + hs);
 y_off += mv->y >> (4 + vs);
-src  += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
 
 MC_EMULATED_EDGE(lc->edge_emu_buffer, , _stride, x_off, y_off);
 fc->vvcdsp.inter.put[is_chroma][idx][!!my][!!mx](dst, src, src_stride, 
block_h, hf, vf, block_w);
@@ -199,7 +200,6 @@ static void mc_uni(VVCLocalContext *lc, uint8_t *dst, const 
ptrdiff_t dst_stride
 
 x_off += mv->x >> (4 + hs);
 y_off += mv->y >> (4 + vs);
-src  += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
 
 MC_EMULATED_EDGE(lc->edge_emu_buffer, , _stride, x_off, y_off);
 if (derive_weight_uni(, , , lc, mvf, c_idx)) {
@@ -236,7 +236,7 @@ static void mc_bi(VVCLocalContext *lc, uint8_t *dst, const 
ptrdiff_t dst_stride,
 const int oy= y_off + (mv->y >> (4 + vs));
 const VVCFrame *ref = refs[i];
 ptrdiff_t src_stride= ref->frame->linesize[c_idx];
-const uint8_t *src  = ref->frame->data[c_idx] + oy * src_stride + 
(ox * (1 << fc->ps.sps->pixel_shift));
+const uint8_t *src  = ref->frame->data[c_idx];
 const int8_t *hf= INTER_FILTER(hpel_if_idx, mx);
 const int8_t *vf= INTER_FILTER(hpel_if_idx, my);
 
@@ -306,7 +306,6 @@ static void scaled_ref_pos_and_step(const VVCLocalContext 
*lc, const VVCRefPic *
 static void emulated_edge_scaled(VVCLocalContext *lc, const uint8_t **src, 
ptrdiff_t *src_stride, int *src_height,
 const VVCFrame *ref, const int x, const int y, const int dx, const int dy, 
const int w, const int h, const int is_chroma)
 {
-const VVCFrameContext *fc = lc->fc;
 const int x_off   = SCALED_INT(x);
 const int y_off   = SCALED_INT(y);
 const int x_end   = SCALED_INT(x + w * dx);
@@ -316,8 +315,6 @@ static void emulated_edge_scaled(VVCLocalContext *lc, const 
uint8_t **src, ptrdi
 const int block_w = x_end - x_off + (x_end == x_last);
 const int block_h = *src_height = y_end - y_off + (y_end == 
y_last);
 
-*src  += y_off * *src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
-
 MC_EMULATED_EDGE(lc->edge_emu_buffer, src, src_stride, x_off, y_off);
 }
 
@@ -414,7 +411,6 @@ static void luma_prof_uni(VVCLocalContext *lc, uint8_t 
*dst, const ptrdiff_t dst
 
 x_off += mv->x >> 4;
 y_off += mv->y >> 4;
-src   += y_off * src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
 
 MC_EMULATED_EDGE(lc->edge_emu_buffer, , _stride, x_off, y_off);
 if (cb_prof_flag) {
@@ -444,8 +440,8 @@ static void luma_prof(VVCLocalContext *lc, int16_t *dst, 
const VVCFrame *ref,
 const int idx = av_log2(block_w) - 1;
 const int is_chroma   = 0;
 uint16_t *prof_tmp= lc->tmp2 + PROF_TEMP_OFFSET;
-ptrdiff_t src_stride  = ref->frame->linesize[0];
-const uint8_t *src= ref->frame->data[0] + oy * src_stride + (ox * 
(1 << fc->ps.sps->pixel_shift));
+ptrdiff_t src_stride  = ref->frame->linesize[LUMA];
+const uint8_t *src= ref->frame->data[LUMA];
 const int8_t *hf  = 
ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][mx];
 const int8_t *vf  = 
ff_vvc_inter_luma_filters[VVC_INTER_LUMA_FILTER_TYPE_AFFINE][my];
 
@@ -704,7 +700,7 @@ static void dmvr_mv_refine(VVCLocalContext *lc, MvField 
*mvf, MvField *orig_mv,
 const int oy= y_off + (mv->y >> 4) - sr_range;
 const VVCFrame *ref = refs[i];
 ptrdiff_t src_stride= ref->frame->linesize[LUMA];
-const uint8_t *src  = ref->frame->data[LUMA] + oy * src_stride + 
(ox * (1 << fc->ps.sps->pixel_shift));
+const uint8_t *src  = ref->frame->data[LUMA];
 MC_EMULATED_EDGE_BILINEAR(lc->edge_emu_buffer, , _stride, ox, 
oy);
 fc->vvcdsp.inter.dmvr[!!my][!!mx](tmp[i], src, src_stride, pred_h, mx, 
my, pred_w);
 }
-- 
2.34.1

___
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 

[FFmpeg-devel] [PATCH 1/5] avcodec/vvcdec: refact, remove emulated_edge_dmvr and emulated_edge_bilinear to simplify code

2024-06-03 Thread Nuo Mi
---
 libavcodec/vvc/inter.c | 146 +
 1 file changed, 46 insertions(+), 100 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index e1011b4fa1..0843c99eb6 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -44,112 +44,59 @@ static void subpic_width_height(int *pic_width, int 
*pic_height,
 *pic_height = pps->subpic_height[subpic_idx] >> sps->vshift[is_chroma];
 }
 
-static int emulated_edge(const VVCLocalContext *lc, uint8_t *dst, const 
uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame,
-int x_off, int y_off, const int block_w, const int block_h, const int 
is_chroma)
+static void emulated_edge(const VVCLocalContext *lc, uint8_t *dst,
+const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame,
+int x_sb, int y_sb, int x_off, int y_off, const int block_w, const int 
block_h,
+const int is_chroma, const int extra_before, const int extra_after)
 {
 const VVCFrameContext *fc = lc->fc;
 const VVCSPS *sps = src_frame->sps;
 const VVCPPS *pps = src_frame->pps;
 const int subpic_idx  = lc->sc->sh.r->curr_subpic_idx;
-const int extra_before= is_chroma ? CHROMA_EXTRA_BEFORE : 
LUMA_EXTRA_BEFORE;
-const int extra_after = is_chroma ? CHROMA_EXTRA_AFTER : 
LUMA_EXTRA_AFTER;
-const int extra   = is_chroma ? CHROMA_EXTRA : LUMA_EXTRA;
-int pic_width, pic_height;
-
-subpic_offset(_off, _off, sps, pps, subpic_idx, is_chroma);
-subpic_width_height(_width, _height, sps, pps, subpic_idx, 
is_chroma);
-
-if (x_off < extra_before || y_off < extra_before ||
-x_off >= pic_width - block_w - extra_after ||
-y_off >= pic_height - block_h - extra_after) {
-const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << 
fc->ps.sps->pixel_shift;
-int offset = extra_before * *src_stride  + (extra_before << 
fc->ps.sps->pixel_shift);
-int buf_offset = extra_before * edge_emu_stride + (extra_before << 
fc->ps.sps->pixel_shift);
-
-fc->vdsp.emulated_edge_mc(dst, *src - offset, edge_emu_stride, 
*src_stride,
-block_w + extra, block_h + extra, x_off - extra_before, y_off - 
extra_before,
-pic_width, pic_height);
-
-*src = dst + buf_offset;
-*src_stride = edge_emu_stride;
-return 1;
-}
-return 0;
-}
-
-static void emulated_edge_dmvr(const VVCLocalContext *lc, uint8_t *dst, const 
uint8_t **src, ptrdiff_t *src_stride,
-int x_sb, int y_sb, int x_off,  int y_off, const int block_w, const int 
block_h, const int is_chroma)
-{
-const VVCFrameContext *fc = lc->fc;
-const VVCSPS *sps = fc->ps.sps;
-const VVCPPS *pps = fc->ps.pps;
-const int subpic_idx  = lc->sc->sh.r->curr_subpic_idx;
-const int extra_before= is_chroma ? CHROMA_EXTRA_BEFORE : 
LUMA_EXTRA_BEFORE;
-const int extra_after = is_chroma ? CHROMA_EXTRA_AFTER : 
LUMA_EXTRA_AFTER;
-const int extra   = is_chroma ? CHROMA_EXTRA : LUMA_EXTRA;
+const int extra   = extra_before + extra_after;
+const int dmvr_clip   = x_sb != x_off || y_sb != y_off;
 int pic_width, pic_height;
 
 subpic_offset(_off, _off, sps, pps, subpic_idx, is_chroma);
 subpic_offset(_sb, _sb, sps, pps, subpic_idx, is_chroma);
 subpic_width_height(_width, _height, sps, pps, subpic_idx, 
is_chroma);
+if (dmvr_clip) {
+const int start_x = FFMIN(FFMAX(x_sb - extra_before, 0), pic_width  - 
1);
+const int start_y = FFMIN(FFMAX(y_sb - extra_before, 0), pic_height - 
1);
+pic_width  = FFMAX(FFMIN(pic_width, x_sb + block_w + extra_after) - 
start_x, 1);
+pic_height = FFMAX(FFMIN(pic_height, y_sb + block_h + extra_after) - 
start_y, 1);
+x_off -= start_x;
+y_off -= start_y;
+}
 
-if (x_off < extra_before || y_off < extra_before ||
+if (dmvr_clip || x_off < extra_before || y_off < extra_before ||
 x_off >= pic_width - block_w - extra_after ||
-y_off >= pic_height - block_h - extra_after||
-(x_off != x_sb || y_off !=  y_sb)) {
+y_off >= pic_height - block_h - extra_after) {
 const int ps= fc->ps.sps->pixel_shift;
 const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << ps;
-const int offset= extra_before * *src_stride + 
(extra_before << ps);
+const int offset= extra_before * *src_stride + 
(extra_before << ps);
 const int buf_offset= extra_before * edge_emu_stride + 
(extra_before << ps);
 
-const int start_x   = FFMIN(FFMAX(x_sb - extra_before, 0), 
pic_width  - 1);
-const int start_y   = FFMIN(FFMAX(y_sb - extra_before, 0), 
pic_height - 1);
-const int width = FFMAX(FFMIN(pic_width, x_sb + 
block_w + extra_after) - start_x, 1);
-const int height   

[FFmpeg-devel] [PATCH 5/5] avcodec/vvcdec: support mv wraparound

2024-06-03 Thread Nuo Mi
A 360 video specific tool
see https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9503377

passed files:
DMVR_A_Huawei_3.bit
WRAP_D_InterDigital_4.bit
WRAP_A_InterDigital_4.bit
WRAP_B_InterDigital_4.bit
WRAP_C_InterDigital_4.bit
ERP_A_MediaTek_3.bit
---
 libavcodec/vvc/inter.c | 81 --
 1 file changed, 79 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 09575eb2b4..98cb43322f 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -95,20 +95,97 @@ static void emulated_edge_no_wrap(const VVCLocalContext 
*lc, uint8_t *dst,
 }
 }
 
+static void emulated_half(const VVCLocalContext *lc, uint8_t *dst, const 
ptrdiff_t dst_stride,
+const uint8_t *src, const ptrdiff_t src_stride, const int ps,
+int x_off, int y_off, const int block_w, const int block_h,
+const VVCRect *subpic,const VVCRect *half_sb, const int dmvr_clip)
+{
+const VVCFrameContext *fc = lc->fc;
+int pic_width, pic_height;
+
+src += y_off * src_stride + x_off * (1 << ps);
+
+clip_to_subpic(_off, _off, _width, _height, subpic, half_sb, 
dmvr_clip);
+
+fc->vdsp.emulated_edge_mc(dst, src, dst_stride, src_stride,
+block_w, block_h, x_off, y_off, pic_width, pic_height);
+}
+
+static void sb_set_lr(VVCRect *sb, const int l, const int r)
+{
+sb->l = l;
+sb->r = r;
+}
+
+static void sb_wrap(VVCRect *sb, const int wrap)
+{
+sb_set_lr(sb, sb->l + wrap, sb->r + wrap);
+}
+
 static void emulated_edge(const VVCLocalContext *lc, uint8_t *dst,
 const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame,
 int x_sb, int y_sb, int x_off, int y_off, int block_w, int block_h, const 
int wrap_enabled,
 const int is_chroma, const int extra_before, const int extra_after)
 {
+const VVCSPS *sps  = src_frame->sps;
+const VVCPPS *pps  = src_frame->pps;
+const int ps   = sps->pixel_shift;
 const int subpic_idx   = lc->sc->sh.r->curr_subpic_idx;
+const int extra= extra_before + extra_after;
 const int dmvr_clip= x_sb != x_off || y_sb != y_off;
+const int dmvr_left= FFMAX(x_off, x_sb) - extra_before;
+const int dmvr_right   = FFMIN(x_off, x_sb) + block_w + extra_after;
+const int left = x_off - extra_before;
+const int top  = y_off - extra_before;
+const int pic_width= pps->width >> sps->hshift[is_chroma];
+const int wrap = pps->ref_wraparound_offset << 
(sps->min_cb_log2_size_y - sps->hshift[is_chroma]);
+const ptrdiff_t dst_stride = EDGE_EMU_BUFFER_STRIDE << ps;
 VVCRect sb = { x_sb - extra_before, y_sb - extra_before, 
x_sb + block_w + extra_after, y_sb + block_h + extra_after };
 VVCRect subpic;
 
 subpic_get_rect(, src_frame, subpic_idx, is_chroma);
 
-return emulated_edge_no_wrap(lc, dst, src, src_stride,
-x_off, y_off, block_w, block_h, extra_before, extra_after, , 
, dmvr_clip);
+if (!wrap_enabled || (dmvr_left >= 0 && dmvr_right <= pic_width)) {
+return emulated_edge_no_wrap(lc, dst, src, src_stride,
+x_off, y_off, block_w, block_h, extra_before, extra_after, 
, , dmvr_clip);
+}
+if (dmvr_right <= 0) {
+sb_wrap(, wrap);
+return emulated_edge_no_wrap(lc, dst, src, src_stride,
+x_off + wrap, y_off, block_w, block_h, extra_before, extra_after, 
, , dmvr_clip);
+}
+if (dmvr_left >= pic_width) {
+sb_wrap(, -wrap);
+return emulated_edge_no_wrap(lc, dst, src, src_stride,
+x_off - wrap, y_off, block_w, block_h, extra_before, extra_after, 
, , dmvr_clip);
+}
+
+block_w += extra;
+block_h += extra;
+
+// half block are wrapped
+if (dmvr_left < 0 ) {
+const int w = -left;
+VVCRect half_sb = { sb.l + wrap, sb.t, 0 + wrap, sb.b };
+emulated_half(lc, dst, dst_stride, *src, *src_stride, ps,
+left + wrap, top, w, block_h, , _sb, dmvr_clip);
+
+sb_set_lr(_sb, 0, sb.r);
+emulated_half(lc, dst +  (w << ps), dst_stride, *src, *src_stride, ps,
+0, top, block_w - w, block_h, , _sb, dmvr_clip);
+} else {
+const int w = pic_width - left;
+VVCRect half_sb = { sb.l, sb.t, pic_width, sb.b };
+emulated_half(lc, dst, dst_stride, *src, *src_stride, ps,
+left, top, w, block_h, , _sb, dmvr_clip);
+
+sb_set_lr(_sb, pic_width - wrap, sb.r - wrap);
+emulated_half(lc, dst +  (w << ps), dst_stride, *src, *src_stride, ps,
+pic_width - wrap , top, block_w - w, block_h, , _sb, 
dmvr_clip);
+}
+
+*src = dst + extra_before * dst_stride + (extra_before << ps);
+*src_stride = dst_stride;
 }
 
 #define MC_EMULATED_EDGE(dst, src, src_stride, x_off, y_off)   
 \
-- 
2.34.1


[FFmpeg-devel] [PATCH 4/5] avcodec/vvcdec: misc, reindent inter.c

2024-06-03 Thread Nuo Mi
---
 libavcodec/vvc/inter.c | 278 -
 1 file changed, 139 insertions(+), 139 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index aacd5d8da0..09575eb2b4 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -127,14 +127,14 @@ static void emulated_edge(const VVCLocalContext *lc, 
uint8_t *dst,
 static int derive_weight_uni(int *denom, int *wx, int *ox,
 const VVCLocalContext *lc, const MvField *mvf, const int c_idx)
 {
-const VVCFrameContext *fc   = lc->fc;
-const VVCPPS *pps   = fc->ps.pps;
-const VVCSH *sh = >sc->sh;
-const int weight_flag   = (IS_P(sh->r) && 
pps->r->pps_weighted_pred_flag) ||
+const VVCFrameContext *fc = lc->fc;
+const VVCPPS *pps = fc->ps.pps;
+const VVCSH *sh   = >sc->sh;
+const int weight_flag = (IS_P(sh->r) && 
pps->r->pps_weighted_pred_flag) ||
   (IS_B(sh->r) && 
pps->r->pps_weighted_bipred_flag);
 if (weight_flag) {
-const int lx= mvf->pred_flag - PF_L0;
-const PredWeightTable *w= pps->r->pps_wp_info_in_ph_flag ? 
>ps.ph.pwt : >pwt;
+const int lx = mvf->pred_flag - PF_L0;
+const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? 
>ps.ph.pwt : >pwt;
 
 *denom = w->log2_denom[c_idx > 0];
 *wx = w->weight[lx][c_idx][mvf->ref_idx[lx]];
@@ -147,11 +147,11 @@ static int derive_weight_uni(int *denom, int *wx, int *ox,
 static int derive_weight(int *denom, int *w0, int *w1, int *o0, int *o1,
 const VVCLocalContext *lc, const MvField *mvf, const int c_idx, const int 
dmvr_flag)
 {
-const VVCFrameContext *fc   = lc->fc;
-const VVCPPS *pps   = fc->ps.pps;
-const VVCSH *sh = >sc->sh;
-const int bcw_idx   = mvf->bcw_idx;
-const int weight_flag   = (IS_P(sh->r) && 
pps->r->pps_weighted_pred_flag) ||
+const VVCFrameContext *fc = lc->fc;
+const VVCPPS *pps = fc->ps.pps;
+const VVCSH *sh   = >sc->sh;
+const int bcw_idx = mvf->bcw_idx;
+const int weight_flag = (IS_P(sh->r) && 
pps->r->pps_weighted_pred_flag) ||
   (IS_B(sh->r) && 
pps->r->pps_weighted_bipred_flag && !dmvr_flag);
 if ((!weight_flag && !bcw_idx) || (bcw_idx && lc->cu->ciip_flag))
 return 0;
@@ -162,7 +162,7 @@ static int derive_weight(int *denom, int *w0, int *w1, int 
*o0, int *o1,
 *w0 = 8 - *w1;
 *o0 = *o1 = 0;
 } else {
-const VVCPPS *pps = fc->ps.pps;
+const VVCPPS *pps= fc->ps.pps;
 const PredWeightTable *w = pps->r->pps_wp_info_in_ph_flag ? 
>ps.ph.pwt : >pwt;
 
 *denom = w->log2_denom[c_idx > 0];
@@ -179,20 +179,20 @@ static int derive_weight(int *denom, int *w0, int *w1, 
int *o0, int *o1,
 static void mc(VVCLocalContext *lc, int16_t *dst, const VVCFrame *ref, const 
Mv *mv,
 int x_off, int y_off, const int block_w, const int block_h, const int 
c_idx)
 {
-const VVCFrameContext *fc   = lc->fc;
-const PredictionUnit *pu= >cu->pu;
-const uint8_t *src  = ref->frame->data[c_idx];
-ptrdiff_t src_stride= ref->frame->linesize[c_idx];
-const int is_chroma = !!c_idx;
-const int hs= fc->ps.sps->hshift[c_idx];
-const int vs= fc->ps.sps->vshift[c_idx];
-const int idx   = av_log2(block_w) - 1;
-const intptr_t mx   = av_mod_uintp2(mv->x, 4 + hs) << (is_chroma - 
hs);
-const intptr_t my   = av_mod_uintp2(mv->y, 4 + vs) << (is_chroma - 
vs);
-const int hpel_if_idx   = (is_chroma || pu->merge_gpm_flag) ? 0 : 
pu->mi.hpel_if_idx;
-const int8_t *hf= INTER_FILTER(hpel_if_idx, mx);
-const int8_t *vf= INTER_FILTER(hpel_if_idx, my);
-const int wrap_enabled  = 
fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
+const VVCFrameContext *fc = lc->fc;
+const PredictionUnit *pu  = >cu->pu;
+const uint8_t *src= ref->frame->data[c_idx];
+ptrdiff_t src_stride  = ref->frame->linesize[c_idx];
+const int is_chroma   = !!c_idx;
+const int hs  = fc->ps.sps->hshift[c_idx];
+const int vs  = fc->ps.sps->vshift[c_idx];
+const int idx = av_log2(block_w) - 1;
+const intptr_t mx = av_mod_uintp2(mv->x, 4 + hs) << (is_chroma - 
hs);
+const intptr_t my = av_mod_uintp2(mv->y, 4 + vs) << (is_chroma - 
vs);
+const int hpel_if_idx = (is_chroma || pu->merge_gpm_flag) ? 0 : 
pu->mi.hpel_if_idx;
+const int8_t *hf  = INTER_FILTER(hpel_if_idx, mx);
+const int8_t *vf  = INTER_FILTER(hpel_if_idx, my);
+const int wrap_enabled= fc->ps.pps->r->pps_ref_wraparound_enabled_flag;
 
 x_off += mv->x >> (4 + hs);
 y_off += mv->y >> (4 + vs);
@@ -205,22 +205,22 @@ static void 

[FFmpeg-devel] [PATCH 3/5] avcodec/vvcdec: refact out emulated_edge_no_wrap

2024-06-03 Thread Nuo Mi
prepare for refrence wraparound
---
 libavcodec/vvc/inter.c | 91 --
 1 file changed, 61 insertions(+), 30 deletions(-)

diff --git a/libavcodec/vvc/inter.c b/libavcodec/vvc/inter.c
index 07b55c4bac..aacd5d8da0 100644
--- a/libavcodec/vvc/inter.c
+++ b/libavcodec/vvc/inter.c
@@ -30,46 +30,53 @@
 #define PROF_TEMP_OFFSET (MAX_PB_SIZE + 32)
 static const int bcw_w_lut[] = {4, 5, 3, 10, -2};
 
-static void subpic_offset(int *x_off, int *y_off,
-const VVCSPS *sps, const VVCPPS *pps, const int subpic_idx, const int 
is_chroma)
+typedef struct VVCRect {
+int l;  // left
+int t;  // top
+int r;  // right
+int b;  // bottom
+} VVCRect;
+
+static void subpic_get_rect(VVCRect *r, const VVCFrame *src_frame, const int 
subpic_idx, const int is_chroma)
 {
-*x_off -= pps->subpic_x[subpic_idx] >> sps->hshift[is_chroma];
-*y_off -= pps->subpic_y[subpic_idx] >> sps->vshift[is_chroma];
+const VVCSPS *sps = src_frame->sps;
+const VVCPPS *pps = src_frame->pps;
+const int hs  = sps->hshift[is_chroma];
+const int vs  = sps->vshift[is_chroma];
+
+r->l = pps->subpic_x[subpic_idx] >> hs;
+r->t = pps->subpic_y[subpic_idx] >> vs;
+r->r = r->l + (pps->subpic_width[subpic_idx]  >> hs);
+r->b = r->t + (pps->subpic_height[subpic_idx] >> vs);
 }
 
-static void subpic_width_height(int *pic_width, int *pic_height,
-const VVCSPS *sps, const VVCPPS *pps, const int subpic_idx, const int 
is_chroma)
+// clip to subblock and subpicture process in 8.5.6.3.2 Luma sample 
interpolation filtering process
+static void clip_to_subpic(int *x_off, int *y_off, int *pic_width, int 
*pic_height, const VVCRect *subpic, const VVCRect *sb, const int dmvr_clip)
 {
-*pic_width  = pps->subpic_width[subpic_idx]  >> sps->hshift[is_chroma];
-*pic_height = pps->subpic_height[subpic_idx] >> sps->vshift[is_chroma];
+const int l = dmvr_clip ? FFMIN(FFMAX(subpic->l, sb->l), subpic->r - 1) : 
subpic->l;
+const int t = dmvr_clip ? FFMIN(FFMAX(subpic->t, sb->t), subpic->b - 1) : 
subpic->t;
+const int r = dmvr_clip ? FFMAX(FFMIN(subpic->r, sb->r), subpic->l + 1) : 
subpic->r;
+const int b = dmvr_clip ? FFMAX(FFMIN(subpic->b, sb->b), subpic->t + 1) : 
subpic->b;
+
+*x_off -= l;
+*y_off -= t;
+*pic_width  = r - l;
+*pic_height = b - t;
 }
 
-static void emulated_edge(const VVCLocalContext *lc, uint8_t *dst,
-const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame,
-int x_sb, int y_sb, int x_off, int y_off, const int block_w, const int 
block_h,
-const int is_chroma, const int extra_before, const int extra_after)
+static void emulated_edge_no_wrap(const VVCLocalContext *lc, uint8_t *dst,
+const uint8_t **src, ptrdiff_t *src_stride,
+int x_off, int y_off, const int block_w, const int block_h,
+const int extra_before, const int extra_after,
+const VVCRect *subpic, const VVCRect *sb, const int dmvr_clip)
 {
 const VVCFrameContext *fc = lc->fc;
-const VVCSPS *sps = src_frame->sps;
-const VVCPPS *pps = src_frame->pps;
-const int subpic_idx  = lc->sc->sh.r->curr_subpic_idx;
 const int extra   = extra_before + extra_after;
-const int dmvr_clip   = x_sb != x_off || y_sb != y_off;
 int pic_width, pic_height;
 
 *src  += y_off * *src_stride + (x_off * (1 << fc->ps.sps->pixel_shift));
 
-subpic_offset(_off, _off, sps, pps, subpic_idx, is_chroma);
-subpic_offset(_sb, _sb, sps, pps, subpic_idx, is_chroma);
-subpic_width_height(_width, _height, sps, pps, subpic_idx, 
is_chroma);
-if (dmvr_clip) {
-const int start_x = FFMIN(FFMAX(x_sb - extra_before, 0), pic_width  - 
1);
-const int start_y = FFMIN(FFMAX(y_sb - extra_before, 0), pic_height - 
1);
-pic_width  = FFMAX(FFMIN(pic_width, x_sb + block_w + extra_after) - 
start_x, 1);
-pic_height = FFMAX(FFMIN(pic_height, y_sb + block_h + extra_after) - 
start_y, 1);
-x_off -= start_x;
-y_off -= start_y;
-}
+clip_to_subpic(_off, _off, _width, _height, subpic, sb, 
dmvr_clip);
 
 if (dmvr_clip || x_off < extra_before || y_off < extra_before ||
 x_off >= pic_width - block_w - extra_after ||
@@ -88,16 +95,32 @@ static void emulated_edge(const VVCLocalContext *lc, 
uint8_t *dst,
 }
 }
 
+static void emulated_edge(const VVCLocalContext *lc, uint8_t *dst,
+const uint8_t **src, ptrdiff_t *src_stride, const VVCFrame *src_frame,
+int x_sb, int y_sb, int x_off, int y_off, int block_w, int block_h, const 
int wrap_enabled,
+const int is_chroma, const int extra_before, const int extra_after)
+{
+const int subpic_idx   = lc->sc->sh.r->curr_subpic_idx;
+const int dmvr_clip= x_sb != x_off || y_sb != y_off;
+VVCRect sb = { x_sb - extra_before, y_sb - extra_before, 
x_sb + block_w + extra_after, y_sb + block_h 

Re: [FFmpeg-devel] [PATCH 2/2] tests/checkasm/vvc_mc: don't zero the SAD buffers

2024-05-31 Thread Nuo Mi
On Wed, May 29, 2024 at 10:03 PM James Almer  wrote:

> They will be filled immediately after.
>
Pushed.
thank you, James

>
> Signed-off-by: James Almer 
> ---
>  tests/checkasm/vvc_mc.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c
> index 40be837d68..bc6b580f42 100644
> --- a/tests/checkasm/vvc_mc.c
> +++ b/tests/checkasm/vvc_mc.c
> @@ -333,9 +333,6 @@ static void check_vvc_sad(void)
>  declare_func(int, const int16_t *src0, const int16_t *src1, int dx,
> int dy, int block_w, int block_h);
>
>  ff_vvc_dsp_init(, bit_depth);
> -memset(src0, 0, MAX_CTU_SIZE * MAX_CTU_SIZE * 4 * sizeof(uint16_t));
> -memset(src1, 0, MAX_CTU_SIZE * MAX_CTU_SIZE * 4 * sizeof(uint16_t));
> -
>  randomize_pixels(src0, src1, MAX_CTU_SIZE * MAX_CTU_SIZE * 4);
>  for (int h = 8; h <= 16; h *= 2) {
>  for (int w = 8; w <= 16; w *= 2) {
> --
> 2.45.1
>
> ___
> 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".
>
___
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 v2 1/3] avcodec/x86/vvc/vvc_alf: fix integer overflow

2024-05-31 Thread Nuo Mi
On Fri, May 31, 2024 at 2:29 AM Ronald S. Bultje  wrote:

> Hi,
>
> On Thu, May 30, 2024 at 12:28 PM  wrote:
>
> > From: Wu Jianhua 
> >
> > Some tests fails with certain seeds
> >
> > tests/checkasm/checkasm 2325607578 --test=vvc_alf
> > checkasm: using random seed 2325607578
> > AVX2:
> > vvc_alf_filter_luma_120x20_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x24_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x28_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x32_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x36_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x40_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x44_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x48_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x52_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x56_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x60_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x64_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x68_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x72_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x76_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x80_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x84_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x88_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x92_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x96_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x100_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x104_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x108_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x112_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x116_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x120_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x124_12_avx2 (vvc_alf.c:104)
> > vvc_alf_filter_luma_120x128_12_avx2 (vvc_alf.c:104)
> >   - vvc_alf.alf_filter   [FAILED]
> >   - vvc_alf.alf_classify [OK]
> > checkasm: 28 of 9216 tests have failed
> >
> > Reported-by: James Almer 
> > Signed-off-by: Wu Jianhua 
> > ---
> >  libavcodec/x86/vvc/vvc_alf.asm | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/x86/vvc/vvc_alf.asm
> > b/libavcodec/x86/vvc/vvc_alf.asm
> > index 71e821c27b..f7b3e2a6cc 100644
> > --- a/libavcodec/x86/vvc/vvc_alf.asm
> > +++ b/libavcodec/x86/vvc/vvc_alf.asm
> > @@ -356,7 +356,8 @@ SECTION .text
> >
> >  FILTER_VB xq
> >
> > -paddw m0, m2
> > +; sum += curr
> > +paddsw m0, m2
> >
> >  ; clip to pixel
> >  CLIPW m0, m14, m15
> > --
> > 2.44.0.windows.1
> >
>
> LGTM.
>
Applied,
Thank you, Jianhua, Andreas, and Ronald.

>
> Ronald
> ___
> 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".
>
___
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 v2 1/3] avcodec/x86/vvc/vvc_alf: fix integer overflow

2024-05-31 Thread Nuo Mi
On Fri, May 31, 2024 at 4:49 AM Ronald S. Bultje  wrote:

> Hi Andreas,
>
> On Thu, May 30, 2024 at 2:33 PM Andreas Rheinhardt <
> andreas.rheinha...@outlook.com> wrote:
>
> > toq...@outlook.com:
> > > From: Wu Jianhua 
> > >
> > > Some tests fails with certain seeds
> > >
> > > tests/checkasm/checkasm 2325607578 --test=vvc_alf
> > > checkasm: using random seed 2325607578
> > > AVX2:
> > > vvc_alf_filter_luma_120x20_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x24_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x28_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x32_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x36_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x40_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x44_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x48_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x52_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x56_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x60_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x64_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x68_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x72_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x76_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x80_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x84_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x88_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x92_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x96_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x100_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x104_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x108_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x112_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x116_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x120_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x124_12_avx2 (vvc_alf.c:104)
> > > vvc_alf_filter_luma_120x128_12_avx2 (vvc_alf.c:104)
> > >   - vvc_alf.alf_filter   [FAILED]
> > >   - vvc_alf.alf_classify [OK]
> > > checkasm: 28 of 9216 tests have failed
> > >
> > > Reported-by: James Almer 
> > > Signed-off-by: Wu Jianhua 
> > > ---
> > >  libavcodec/x86/vvc/vvc_alf.asm | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/libavcodec/x86/vvc/vvc_alf.asm
> > b/libavcodec/x86/vvc/vvc_alf.asm
> > > index 71e821c27b..f7b3e2a6cc 100644
> > > --- a/libavcodec/x86/vvc/vvc_alf.asm
> > > +++ b/libavcodec/x86/vvc/vvc_alf.asm
> > > @@ -356,7 +356,8 @@ SECTION .text
> > >
> > >  FILTER_VB xq
> > >
> > > -paddw m0, m2
> > > +; sum += curr
> > > +paddsw m0, m2
> > >
> > >  ; clip to pixel
> > >  CLIPW m0, m14, m15
> >
> > And can I get an answer to the question of whether the issue is present
> > when used by the actual decoder and not only the checkasm test?
> >
>
> From my reading of the source code, this could happen in a crafted (e.g.
> fuzzed) stream.
>
Yes, the test case is valid. So even if the normal clips don't have this
issue, some clips might.

>
> Ronald
> ___
> 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".
>
___
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 2/2][GSoC 2024] tests/checkasm/vvc_mc: for SAD, only test valid subblock sizes

2024-05-29 Thread Nuo Mi
On Wed, May 29, 2024 at 3:10 AM Stone Chen  wrote:

> According to the VVC specification (section 8.5.1), the maximum
> width/height of a subblock passed for DMVR SAD is 16. This along with
> previous constraint requiring width * height >= 128 means that  8x16, 16x8,
> and 16x16 are the only allowed sizes

Applied.
Thank you, Stone.

>
>
This changes check_vvc_sad() to only test and benchmark those sizes.
> ---
>  tests/checkasm/vvc_mc.c | 12 +++-
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/tests/checkasm/vvc_mc.c b/tests/checkasm/vvc_mc.c
> index 1e889e2cff..09cac82edb 100644
> --- a/tests/checkasm/vvc_mc.c
> +++ b/tests/checkasm/vvc_mc.c
> @@ -337,11 +337,12 @@ static void check_vvc_sad(void)
>  memset(src1, 0, MAX_CTU_SIZE * MAX_CTU_SIZE * 4 * sizeof(uint16_t));
>
>  randomize_pixels(src0, src1, MAX_CTU_SIZE * MAX_CTU_SIZE * 4);
> - for (int h = 8; h <= MAX_CTU_SIZE; h *= 2) {
> -for (int w = 8; w <= MAX_CTU_SIZE; w *= 2) {
> +for (int h = 8; h <= 16; h *= 2) {
> +for (int w = 8; w <= 16; w *= 2) {
>
 for(int offy = 0; offy <= 4; offy++) {
>  for(int offx = 0; offx <= 4; offx++) {
> -if(check_func(c.inter.sad, "sad_%dx%d", w, h)) {
> +if(w * h >= 128) {
> +if(check_func(c.inter.sad, "sad_%dx%d", w, h)) {
>  int result0;
>  int result1;
>
> @@ -350,13 +351,14 @@ static void check_vvc_sad(void)
>
>  if (result1 != result0)
>  fail();
> -if(w == h && offx == 0 && offy == 0)
> +if(offx == 0 && offy == 0)
>  bench_new(src0 + PIXEL_STRIDE * 2 + 2, src1 +
> PIXEL_STRIDE * 2 + 2, offx, offy, w, h);
> +}
>  }
>  }
>  }
>  }
> - }
> +}
>
>  report("sad");
>  }
> --
> 2.45.0
>
> ___
> 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".
>
___
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] lavc/vvc: Validate temporal MVP references

2024-05-27 Thread Nuo Mi
On Sun, May 26, 2024 at 5:16 PM Frank Plowman  wrote:

> Per VVCv3 p. 157, the collocated reference picture used in temporal
> motion vector prediction must have RprConstraintsActiveFlag equal to
> zero and the same CTU size as the current picture.  Add these checks,
> fixing crashes decoding some fuzzed bitstreams.
>
> Additionally, only set up the collocated reference picture if it is
> actually going to be used (i.e. if ph_temporal_mvp_enabled_flag is 1),
> else legal RPR bitstreams will fail the new checks.
>
Applied, thank you, Frank.

>
> Co-authored-by: Nuo Mi 
> Signed-off-by: Frank Plowman 
> ---
>  libavcodec/vvc/refs.c | 11 ---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
> index fb42963034..8b7ba639a3 100644
> --- a/libavcodec/vvc/refs.c
> +++ b/libavcodec/vvc/refs.c
> @@ -506,9 +506,14 @@ int ff_vvc_slice_rpl(VVCContext *s, VVCFrameContext
> *fc, SliceContext *sc)
>  return ret;
>  }
>  }
> -if ((!rsh->sh_collocated_from_l0_flag) == lx &&
> -rsh->sh_collocated_ref_idx < rpl->nb_refs)
> -fc->ref->collocated_ref =
> rpl->refs[rsh->sh_collocated_ref_idx].ref;
> +if (ph->r->ph_temporal_mvp_enabled_flag &&
> +(!rsh->sh_collocated_from_l0_flag) == lx &&
> +rsh->sh_collocated_ref_idx < rpl->nb_refs) {
> +const VVCRefPic *refp = rpl->refs +
> rsh->sh_collocated_ref_idx;
> +if (refp->is_scaled || refp->ref->sps->ctb_log2_size_y !=
> sps->ctb_log2_size_y)
> +return AVERROR_INVALIDDATA;
> +fc->ref->collocated_ref = refp->ref;
> +}
>  }
>  return 0;
>  }
> --
> 2.44.0
>
>
___
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 v3 1/2] avcodec: add external enc libvvenc for H266/VVC

2024-05-24 Thread Nuo Mi
Hi @Andreas,
Thank you for the review.
Seems Christian still needs some guidance from you, see 1, 2, 3
On Thu, May 16, 2024 at 11:22 PM Christian  wrote:

>
>
> > On 14. May 2024, at 18:49, Andreas Rheinhardt <
> andreas.rheinha...@outlook.com> wrote:
> >
> > Christian Bartnik:
> >> From: Thomas Siedel 
> >>
> >> Add external encoder VVenC for H266/VVC encoding.
> >> Register new encoder libvvenc.
> >> Add libvvenc to wrap the vvenc interface.
> >> libvvenc implements encoder option: preset,qp,period,subjopt,
> >> vvenc-params,levelidc,tier.
> >> Enable encoder by adding --enable-libvvenc in configure step.
> >>
> >> Co-authored-by: Christian Bartnik chris1031...@gmail.com
> >> Signed-off-by: Christian Bartnik 
> >> ---
> >> configure  |   4 +
> >> doc/encoders.texi  |  65 +
> >> libavcodec/Makefile|   1 +
> >> libavcodec/allcodecs.c |   1 +
> >> libavcodec/libvvenc.c  | 566 +
> >> 5 files changed, 637 insertions(+)
> >> create mode 100644 libavcodec/libvvenc.c
> >>
> >> diff --git a/configure b/configure
> >> index a909b0689c..5d9a14821b 100755
> >> --- a/configure
> >> +++ b/configure
> >> @@ -293,6 +293,7 @@ External library support:
> >>   --enable-libvorbis   enable Vorbis en/decoding via libvorbis,
> >>native implementation exists [no]
> >>   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx
> [no]
> >> +  --enable-libvvencenable H.266/VVC encoding via vvenc [no]
> >>   --enable-libwebp enable WebP encoding via libwebp [no]
> >>   --enable-libx264 enable H.264 encoding via x264 [no]
> >>   --enable-libx265 enable HEVC encoding via x265 [no]
> >> @@ -1966,6 +1967,7 @@ EXTERNAL_LIBRARY_LIST="
> >> libvmaf
> >> libvorbis
> >> libvpx
> >> +libvvenc
> >> libwebp
> >> libxevd
> >> libxeve
> >> @@ -3558,6 +3560,7 @@ libvpx_vp8_decoder_deps="libvpx"
> >> libvpx_vp8_encoder_deps="libvpx"
> >> libvpx_vp9_decoder_deps="libvpx"
> >> libvpx_vp9_encoder_deps="libvpx"
> >> +libvvenc_encoder_deps="libvvenc"
> >> libwebp_encoder_deps="libwebp"
> >> libwebp_anim_encoder_deps="libwebp"
> >> libx262_encoder_deps="libx262"
> >> @@ -7025,6 +7028,7 @@ enabled libvpx&& {
> >> die "libvpx enabled but no supported decoders found"
> >> fi
> >> }
> >> +enabled libvvenc  && require_pkg_config libvvenc "libvvenc >=
> 1.6.1" "vvenc/vvenc.h" vvenc_get_version
> >>
> >> enabled libwebp   && {
> >> enabled libwebp_encoder  && require_pkg_config libwebp "libwebp
> >= 0.2.0" webp/encode.h WebPGetEncoderVersion
> >> diff --git a/doc/encoders.texi b/doc/encoders.texi
> >> index c82f316f94..92aab17c49 100644
> >> --- a/doc/encoders.texi
> >> +++ b/doc/encoders.texi
> >> @@ -2378,6 +2378,71 @@ Indicates frame duration
> >> For more information about libvpx see:
> >> @url{http://www.webmproject.org/}
> >>
> >> +@section libvvenc
> >> +
> >> +VVenC H.266/VVC encoder wrapper.
> >> +
> >> +This encoder requires the presence of the libvvenc headers and library
> >> +during configuration. You need to explicitly configure the build with
> >> +@option{--enable-libvvenc}.
> >> +
> >> +The VVenC project website is at
> >> +@url{https://github.com/fraunhoferhhi/vvenc}.
> >> +
> >> +@subsection Supported Pixel Formats
> >> +
> >> +VVenC supports only 10-bit color spaces as input. But the internal
> (encoded)
> >> +bit depth can be set to 8-bit or 10-bit at runtime.
> >> +
> >> +@subsection Options
> >> +
> >> +@table @option
> >> +@item b
> >> +Sets target video bitrate.
> >> +
> >> +@item g
> >> +Set the GOP size. Currently support for g=1 (Intra only) or default.
> >> +
> >> +@item preset
> >> +Set the VVenC preset.
> >> +
> >> +@item levelidc
> >> +Set level idc.
> >> +
> >> +@item tier
> >> +Set vvc tier.
> >> +
> >> +@item qp
> >> +Set constant quantization parameter.
> >> +
> >> +@item subopt @var{boolean}
> >> +Set subjective (perceptually motivated) optimization. Default is 1
> (on).
> >> +
> >> +@item bitdepth8 @var{boolean}
> >> +Set 8bit coding mode instead of using 10bit. Default is 0 (off).
> >> +
> >> +@item period
> >> +set (intra) refresh period in seconds.
> >> +
> >> +@item vvenc-params
> >> +Set vvenc options using a list of @var{key}=@var{value} couples
> separated
> >> +by ":". See @command{vvencapp --fullhelp} or @command{vvencFFapp
> --fullhelp} for a list of options.
> >> +
> >> +For example, the options might be provided as:
> >> +
> >> +@example
> >> +intraperiod=64:decodingrefreshtype=idr:poc0idr=1:internalbitdepth=8
> >> +@end example
> >> +
> >> +For example the encoding options for 2-pass encoding might be provided
> with @option{-vvenc-params}:
> >> +
> >> +@example
> >> +ffmpeg -i input -c:v libvvenc -b 1M -vvenc-params
> passes=2:pass=1:rcstatsfile=stats.json output.mp4
> >> +ffmpeg -i input -c:v libvvenc -b 1M -vvenc-params
> passes=2:pass=2:rcstatsfile=stats.json output.mp4
> >> +@end example
> >> +

Re: [FFmpeg-devel] [PATCH v5 1/2][GSoC 2024] libavcodec/x86/vvc: Add AVX2 DMVR SAD functions for VVC

2024-05-23 Thread Nuo Mi
On Thu, May 23, 2024 at 7:38 AM James Almer  wrote:

> On 5/21/2024 10:01 PM, Ronald S. Bultje wrote:
> > Hi,
> >
> > On Tue, May 21, 2024 at 8:01 PM Stone Chen 
> wrote:
> >
> >> Implements AVX2 DMVR (decoder-side motion vector refinement) SAD
> >> functions. DMVR SAD is only calculated if w >= 8, h >= 8, and w * h >
> 128.
> >> To reduce complexity, SAD is only calculated on even rows. This is
> >> calculated for all video bitdepths, but the values passed to the
> function
> >> are always 16bit (even if the original video bitdepth is 8). The AVX2
> >> implementation uses min/max/sub.
> >>
> >> Additionally this changes parameters dx and dy from int to intptr_t.
> This
> >> allows dx & dy to be used as pointer offsets without needing to use
> movsxd.
> >>
> >> Benchmarks ( AMD 7940HS )
> >> Before:
> >> BQTerrace_1920x1080_60_10_420_22_RA.vvc | 106.0 |
> >> Chimera_8bit_1080P_1000_frames.vvc | 204.3 |
> >> NovosobornayaSquare_1920x1080.bin | 197.3 |
> >> RitualDance_1920x1080_60_10_420_37_RA.266 | 174.0 |
> >>
> >> After:
> >> BQTerrace_1920x1080_60_10_420_22_RA.vvc | 109.3 |
> >> Chimera_8bit_1080P_1000_frames.vvc | 216.0 |
> >> NovosobornayaSquare_1920x1080.bin | 204.0|
> >> RitualDance_1920x1080_60_10_420_37_RA.266 | 181.7 |
> >> ---
> >>   libavcodec/vvc/dsp.c |   2 +-
> >>   libavcodec/vvc/dsp.h |   2 +-
> >>   libavcodec/x86/vvc/Makefile  |   3 +-
> >>   libavcodec/x86/vvc/vvc_sad.asm   | 130 +++
> >>   libavcodec/x86/vvc/vvcdsp_init.c |   6 ++
> >>   5 files changed, 140 insertions(+), 3 deletions(-)
> >>   create mode 100644 libavcodec/x86/vvc/vvc_sad.asm
> >>
> >
> > LGTM.
> >
> > Ronald
>
> Implemented my changes and applied.
>
Thank you, Ronald, Andreas, and James.

Hi Stone,
Congratulations on surviving your first crossfire!

___
> 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".
>
___
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] x86/vvc_alf: use the x86inc instruction macros

2024-05-22 Thread Nuo Mi
On Wed, May 22, 2024 at 12:29 AM Wu Jianhua  wrote:

> > 发件人: ffmpeg-devel  代表 James Almer <
> jamr...@gmail.com>
> > 发送时间: 2024年5月21日 6:52
> > 收件人: ffmpeg-devel@ffmpeg.org
> > 主题: [FFmpeg-devel] [PATCH] x86/vvc_alf: use the x86inc instruction macros
> >
> > Let its magic figure out the correct mnemonic based on target
> instruction set.
> >
> > Signed-off-by: James Almer 
> > ---
> >  libavcodec/x86/vvc/vvc_alf.asm | 202 -
> >  1 file changed, 101 insertions(+), 101 deletions(-)
>
> I tested this patch and LGTM. Thanks for updating them.
> 
> And would it be better to add avcodec to the path of the commit message?
>
Hi Jianhua,
vvc is clear in this case.

Applied,
thank you, Jianhua and James




> Thanks,
> Jianhua
> ___
> 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".
>
___
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] checkasm: vvc_alf: Limit benchmarking to a reasonable subset of functions

2024-05-21 Thread Nuo Mi
On Tue, May 21, 2024 at 6:16 PM Martin Storsjö  wrote:

> On Tue, 21 May 2024, Martin Storsjö wrote:
>
> > Don't benchmark every single combination of widths and heights;
> > only benchmark cases which are squares (like in vvc_mc.c).
> >
> > Contrary to vvc_mc, which increases sizes by doubling dimensions,
> > vvc_alf tests all sizes in increments of 4. Limit benchmarking to
> > the cases which are powers of two.
> >
> > This reduces the number of benchmarked cases from 3072 down to 18.
> > ---
> > tests/checkasm/vvc_alf.c | 11 ---
> > 1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/tests/checkasm/vvc_alf.c b/tests/checkasm/vvc_alf.c
> > index 9526260598..6dd89bfafc 100644
> > --- a/tests/checkasm/vvc_alf.c
> > +++ b/tests/checkasm/vvc_alf.c
> > @@ -103,7 +103,9 @@ static void check_alf_filter(VVCDSPContext *c, const
> int bit_depth)
> > if (memcmp(dst0 + i * dst_stride, dst1 + i *
> dst_stride, w * SIZEOF_PIXEL))
> > fail();
> > }
> > -bench_new(dst1, dst_stride, src1 + offset, src_stride,
> w, h, filter, clip, vb_pos);
> > +// Bench only square sizes, and ones with dimensions
> being a power of two.
> > +if (w == h && (w & (w - 1)) == 0)
> > +bench_new(dst1, dst_stride, src1 + offset,
> src_stride, w, h, filter, clip, vb_pos);
> > }
> > if (check_func(c->alf.filter[CHROMA],
> "vvc_alf_filter_chroma_%dx%d_%d", w, h, bit_depth)) {
> > const int vb_pos = ctu_size - ALF_VB_POS_ABOVE_CHROMA;
> > @@ -115,7 +117,8 @@ static void check_alf_filter(VVCDSPContext *c, const
> int bit_depth)
> > if (memcmp(dst0 + i * dst_stride, dst1 + i *
> dst_stride, w * SIZEOF_PIXEL))
> > fail();
> > }
> > -bench_new(dst1, dst_stride, src1 + offset, src_stride,
> w, h, filter, clip, vb_pos);
> > +if (w == h && (w & (w - 1)) == 0)
> > +bench_new(dst1, dst_stride, src1 + offset,
> src_stride, w, h, filter, clip, vb_pos);
> > }
> > }
> > }
> > @@ -156,7 +159,9 @@ static void check_alf_classify(VVCDSPContext *c,
> const int bit_depth)
> > fail();
> > if (memcmp(transpose_idx0, transpose_idx1, id_size))
> > fail();
> > -bench_new(class_idx1, transpose_idx1, src1 + offset,
> stride, w, h, vb_pos, alf_gradient_tmp);
> > +// Bench only square sizes, and ones with dimensions
> being a power of two.
> > +if (w == h && (w & (w - 1)) == 0)
> > +bench_new(class_idx1, transpose_idx1, src1 +
> offset, stride, w, h, vb_pos, alf_gradient_tmp);
>
> Note, these tests (all vvc tests) use check_func("name...%dx%d", w, h) -
> while it's common elsewhere to group them up into slightly bigger bundles,
> e.g. only including the width in the function name, assuming that this is
> the level of granularity of actual assembly implementations - e.g. I don't
> think there would be a different codepath implemented for each block
> height.
>
> And it's possible to convey more information about exactly what failed,
> without needing to encode it into the function name - see the
> checkasm_check functions/macro, and e.g. commit
> 8ff4a4a4f4f73c5e276fa0cbe6cd5a148ebdd4ae.
>
Hi Martin,
Thank you for the suggestion.
Tracked with https://github.com/ffvvc/FFmpeg/issues/226

>
> // Martin
> ___
> 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".
>
___
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 18/18] Changelog: add DVB compatible information for VVC decoder

2024-05-21 Thread Nuo Mi
On Sun, May 19, 2024 at 9:39 PM Nuo Mi  wrote:

> see
> https://dvb.org/specifications/verification-validation/vvc-test-content/
> ---
>  Changelog | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/Changelog b/Changelog
> index dd25715d6b..12770e4296 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -10,6 +10,7 @@ version :
>  - vf_scale supports secondary ref input and framesync options
>  - vf_scale2ref deprecated
>  - qsv_params option added for QSV encoders
> +- VVC decoder compatible with DVB test content
>
Applied.
Thank you.

>
>
>  version 7.0:
> --
> 2.34.1
>
>
___
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] checkasm: vvc_alf: Limit benchmarking to a reasonable subset of functions

2024-05-21 Thread Nuo Mi
On Tue, May 21, 2024 at 7:11 PM Rémi Denis-Courmont  wrote:

>
>
> Le 21 mai 2024 13:04:29 GMT+03:00, "Martin Storsjö"  a
> écrit :
> >Don't benchmark every single combination of widths and heights;
> >only benchmark cases which are squares (like in vvc_mc.c).
> >
> >Contrary to vvc_mc, which increases sizes by doubling dimensions,
> >vvc_alf tests all sizes in increments of 4. Limit benchmarking to
> >the cases which are powers of two.
> >
> >This reduces the number of benchmarked cases from 3072 down to 18.
> >---
> > tests/checkasm/vvc_alf.c | 11 ---
> > 1 file changed, 8 insertions(+), 3 deletions(-)
> >
> >diff --git a/tests/checkasm/vvc_alf.c b/tests/checkasm/vvc_alf.c
> >index 9526260598..6dd89bfafc 100644
> >--- a/tests/checkasm/vvc_alf.c
> >+++ b/tests/checkasm/vvc_alf.c
> >@@ -103,7 +103,9 @@ static void check_alf_filter(VVCDSPContext *c, const
> int bit_depth)
> > if (memcmp(dst0 + i * dst_stride, dst1 + i *
> dst_stride, w * SIZEOF_PIXEL))
> > fail();
> > }
> >-bench_new(dst1, dst_stride, src1 + offset, src_stride,
> w, h, filter, clip, vb_pos);
> >+// Bench only square sizes, and ones with dimensions
> being a power of two.
> >+if (w == h && (w & (w - 1)) == 0)
> >+bench_new(dst1, dst_stride, src1 + offset,
> src_stride, w, h, filter, clip, vb_pos);
> > }
> > if (check_func(c->alf.filter[CHROMA],
> "vvc_alf_filter_chroma_%dx%d_%d", w, h, bit_depth)) {
> > const int vb_pos = ctu_size - ALF_VB_POS_ABOVE_CHROMA;
> >@@ -115,7 +117,8 @@ static void check_alf_filter(VVCDSPContext *c, const
> int bit_depth)
> > if (memcmp(dst0 + i * dst_stride, dst1 + i *
> dst_stride, w * SIZEOF_PIXEL))
> > fail();
> > }
> >-bench_new(dst1, dst_stride, src1 + offset, src_stride,
> w, h, filter, clip, vb_pos);
> >+if (w == h && (w & (w - 1)) == 0)
> >+bench_new(dst1, dst_stride, src1 + offset,
> src_stride, w, h, filter, clip, vb_pos);
> > }
> > }
> > }
> >@@ -156,7 +159,9 @@ static void check_alf_classify(VVCDSPContext *c,
> const int bit_depth)
> > fail();
> > if (memcmp(transpose_idx0, transpose_idx1, id_size))
> > fail();
> >-bench_new(class_idx1, transpose_idx1, src1 + offset,
> stride, w, h, vb_pos, alf_gradient_tmp);
> >+// Bench only square sizes, and ones with dimensions
> being a power of two.
> >+if (w == h && (w & (w - 1)) == 0)
> >+bench_new(class_idx1, transpose_idx1, src1 + offset,
> stride, w, h, vb_pos, alf_gradient_tmp);
> > }
> > }
> > }
>
> LGTM.
>
Applied.
Thank you, Martin and Remi.

>
> By the way, does anybody know if we could skip benchmarking C functions
> for which zero optimisations are available ? We are not printing the
> benchmark results in that case, so that wouldn't be a loss.
> ___
> 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".
>
___
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".


  1   2   3   4   5   6   7   8   >