From: "Martin Storsjö" <martin@martin.st>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Nuo Mi <nuomi2021@gmail.com>, Shaun Loo <shaunloo10@gmail.com>
Subject: Re: [FFmpeg-devel] [PATCH 5/5] checkasm: add vvc_sao
Date: Fri, 2 May 2025 10:49:02 +0300 (EEST)
Message-ID: <f6d0f640-dc88-3362-1e60-66f93a7b371@martin.st> (raw)
In-Reply-To: <20250502074430.291561-5-nuomi2021@gmail.com>
On Fri, 2 May 2025, Nuo Mi wrote:
> From: Shaun Loo <shaunloo10@gmail.com>
>
> This is a part of Google Summer of Code 2023
>
> AVX2:
> - vvc_sao.sao_band [OK]
> - vvc_sao.sao_edge [OK]
>
> Co-authored-by: Nuo Mi <nuomi2021@gmail.com>
> ---
> tests/checkasm/Makefile | 2 +-
> tests/checkasm/checkasm.c | 1 +
> tests/checkasm/checkasm.h | 1 +
> tests/checkasm/vvc_sao.c | 161 ++++++++++++++++++++++++++++++++++++++
> 4 files changed, 164 insertions(+), 1 deletion(-)
> create mode 100644 tests/checkasm/vvc_sao.c
>
> diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
> index 193c1e4633..fabbf595b4 100644
> --- a/tests/checkasm/Makefile
> +++ b/tests/checkasm/Makefile
> @@ -47,7 +47,7 @@ AVCODECOBJS-$(CONFIG_V210_DECODER) += v210dec.o
> AVCODECOBJS-$(CONFIG_V210_ENCODER) += v210enc.o
> AVCODECOBJS-$(CONFIG_VORBIS_DECODER) += vorbisdsp.o
> AVCODECOBJS-$(CONFIG_VP9_DECODER) += vp9dsp.o
> -AVCODECOBJS-$(CONFIG_VVC_DECODER) += vvc_alf.o vvc_mc.o
> +AVCODECOBJS-$(CONFIG_VVC_DECODER) += vvc_alf.o vvc_mc.o vvc_sao.o
>
> CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes)
>
> diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
> index 3bb82ed0e5..0734cd26bf 100644
> --- a/tests/checkasm/checkasm.c
> +++ b/tests/checkasm/checkasm.c
> @@ -256,6 +256,7 @@ static const struct {
> #if CONFIG_VVC_DECODER
> { "vvc_alf", checkasm_check_vvc_alf },
> { "vvc_mc", checkasm_check_vvc_mc },
> + { "vvc_sao", checkasm_check_vvc_sao },
> #endif
> #endif
> #if CONFIG_AVFILTER
> diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
> index a6b5965e02..146bfdec35 100644
> --- a/tests/checkasm/checkasm.h
> +++ b/tests/checkasm/checkasm.h
> @@ -149,6 +149,7 @@ void checkasm_check_videodsp(void);
> void checkasm_check_vorbisdsp(void);
> void checkasm_check_vvc_alf(void);
> void checkasm_check_vvc_mc(void);
> +void checkasm_check_vvc_sao(void);
>
> struct CheckasmPerf;
>
> diff --git a/tests/checkasm/vvc_sao.c b/tests/checkasm/vvc_sao.c
> new file mode 100644
> index 0000000000..026078ff02
> --- /dev/null
> +++ b/tests/checkasm/vvc_sao.c
> @@ -0,0 +1,161 @@
> +/*
> + * Copyright (c) 2018 Yingming Fan <yingmingfan@gmail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 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 General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
> + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + */
> +
> +#include <string.h>
> +
> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/mem_internal.h"
> +
> +#include "libavcodec/vvc/dsp.h"
> +#include "libavcodec/vvc/ctu.h"
> +
> +#include "checkasm.h"
> +
> +static const uint32_t pixel_mask[3] = { 0xffffffff, 0x03ff03ff, 0x0fff0fff };
> +static const uint32_t sao_size[] = {8, 16, 32, 48, 64, 80, 96, 112, 128};
> +
> +#define SIZEOF_PIXEL ((bit_depth + 7) / 8)
> +#define PIXEL_STRIDE (2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) //same with sao_edge src_stride
> +#define BUF_SIZE (PIXEL_STRIDE * (MAX_PB_SIZE+2) * 2) //+2 for top and bottom row, *2 for high bit depth
> +#define OFFSET_THRESH (1 << (bit_depth - 5))
> +#define OFFSET_LENGTH 5
> +
> +#define randomize_buffers(buf0, buf1, size) \
> + do { \
> + uint32_t mask = pixel_mask[(bit_depth - 8) >> 1]; \
> + int k; \
> + for (k = 0; k < size; k += 4) { \
> + uint32_t r = rnd() & mask; \
> + AV_WN32A(buf0 + k, r); \
> + AV_WN32A(buf1 + k, r); \
> + } \
> + } while (0)
> +
> +#define randomize_buffers2(buf, size) \
> + do { \
> + uint32_t max_offset = OFFSET_THRESH; \
> + int k; \
> + if (bit_depth == 8) { \
> + for (k = 0; k < size; k++) { \
> + uint8_t r = rnd() % max_offset; \
> + buf[k] = r; \
> + } \
> + } else { \
> + for (k = 0; k < size; k++) { \
> + uint16_t r = rnd() % max_offset; \
> + buf[k] = r; \
> + } \
> + } \
> + } while (0)
> +
> +static void check_sao_band(VVCDSPContext *h, int bit_depth)
> +{
> + int i;
> + LOCAL_ALIGNED_32(uint8_t, dst0, [BUF_SIZE]);
> + LOCAL_ALIGNED_32(uint8_t, dst1, [BUF_SIZE]);
> + LOCAL_ALIGNED_32(uint8_t, src0, [BUF_SIZE]);
> + LOCAL_ALIGNED_32(uint8_t, src1, [BUF_SIZE]);
> + int16_t offset_val[OFFSET_LENGTH];
> + int left_class = rnd()%32;
> +
> + for (i = 0; i < FF_ARRAY_ELEMS(sao_size); i++) {
> + int block_size = sao_size[i];
> + int prev_size = i > 0 ? sao_size[i - 1] : 0;
> + ptrdiff_t stride = PIXEL_STRIDE*SIZEOF_PIXEL;
> + declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t dst_stride, ptrdiff_t src_stride,
> + const int16_t *sao_offset_val, int sao_left_class, int width, int height);
> +
> + if (check_func(h->sao.band_filter[i], "vvc_sao_band_%d_%d", block_size, bit_depth)) {
> +
> + for (int w = prev_size + 4; w <= block_size; w += 4) {
> + randomize_buffers(src0, src1, BUF_SIZE);
> + randomize_buffers2(offset_val, OFFSET_LENGTH);
> + memset(dst0, 0, BUF_SIZE);
> + memset(dst1, 0, BUF_SIZE);
> +
> + call_ref(dst0, src0, stride, stride, offset_val, left_class, w, block_size);
> + call_new(dst1, src1, stride, stride, offset_val, left_class, w, block_size);
> + for (int j = 0; j < block_size; j++) {
> + if (memcmp(dst0 + j*stride, dst1 + j*stride, w*SIZEOF_PIXEL))
> + fail();
> + }
> + }
For new checkasm tests, I would suggest trying to use the helpers for
doing bounds checks automatically; see the recent commits
4d4b301e4a269adfabceaeca1a20c653bde47554 and
c1a2da72cc27cf9b78a0cbea2f60265909d8b253 for how to use them. This will
make sure that any new SIMD implementation doesn't accidentally write
outside of the designated area, which previously could happen without
noticing.
// 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-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2025-05-02 7:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-02 7:44 [FFmpeg-devel] [PATCH 1/5] x86/vvcdec: misc, reordered functions in dsp_init for improved readability Nuo Mi
2025-05-02 7:44 ` [FFmpeg-devel] [PATCH 2/5] x86/hevcdec: sao, refact out h26x macros Nuo Mi
2025-05-02 7:44 ` [FFmpeg-devel] [PATCH 3/5] x86/hevcdec: refact, remove duplicate code in HEVC_SAO_{BAND, EDGE}_FILTER Nuo Mi
2025-05-02 7:44 ` [FFmpeg-devel] [PATCH 4/5] x86/vvcdec: sao, add avx2 support Nuo Mi
2025-05-02 7:44 ` [FFmpeg-devel] [PATCH 5/5] checkasm: add vvc_sao Nuo Mi
2025-05-02 7:49 ` Martin Storsjö [this message]
2025-05-02 14:48 ` Nuo Mi
2025-05-02 20:45 ` Martin Storsjö
2025-05-03 9:15 ` Nuo Mi
2025-05-06 21:26 ` Martin Storsjö
2025-05-10 12:45 ` Nuo Mi
2025-05-14 13:01 ` Nuo Mi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f6d0f640-dc88-3362-1e60-66f93a7b371@martin.st \
--to=martin@martin.st \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=nuomi2021@gmail.com \
--cc=shaunloo10@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git