From: Nuo Mi <nuomi2021@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Nuo Mi <nuomi2021@gmail.com>, Shaun Loo <shaunloo10@gmail.com> Subject: [FFmpeg-devel] [PATCH 5/5] checkasm: add vvc_sao Date: Fri, 2 May 2025 15:44:30 +0800 Message-ID: <20250502074430.291561-5-nuomi2021@gmail.com> (raw) In-Reply-To: <20250502074430.291561-1-nuomi2021@gmail.com> 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] checkasm: all 54 tests passed vvc_sao_band_8_8_c: 157.4 ( 1.00x) vvc_sao_band_8_8_avx2: 30.7 ( 5.12x) vvc_sao_band_8_10_c: 119.4 ( 1.00x) vvc_sao_band_8_10_avx2: 29.2 ( 4.09x) vvc_sao_band_8_12_c: 144.6 ( 1.00x) vvc_sao_band_8_12_avx2: 30.0 ( 4.82x) vvc_sao_band_16_8_c: 446.5 ( 1.00x) vvc_sao_band_16_8_avx2: 103.3 ( 4.32x) vvc_sao_band_16_10_c: 399.2 ( 1.00x) vvc_sao_band_16_10_avx2: 64.3 ( 6.21x) vvc_sao_band_16_12_c: 472.9 ( 1.00x) vvc_sao_band_16_12_avx2: 56.5 ( 8.37x) vvc_sao_band_32_8_c: 2430.9 ( 1.00x) vvc_sao_band_32_8_avx2: 203.3 (11.96x) vvc_sao_band_32_10_c: 1405.7 ( 1.00x) vvc_sao_band_32_10_avx2: 208.5 ( 6.74x) vvc_sao_band_32_12_c: 2054.3 ( 1.00x) vvc_sao_band_32_12_avx2: 213.0 ( 9.64x) vvc_sao_band_48_8_c: 3835.4 ( 1.00x) vvc_sao_band_48_8_avx2: 604.2 ( 6.35x) vvc_sao_band_48_10_c: 3624.6 ( 1.00x) vvc_sao_band_48_10_avx2: 468.8 ( 7.73x) vvc_sao_band_48_12_c: 3752.4 ( 1.00x) vvc_sao_band_48_12_avx2: 477.5 ( 7.86x) vvc_sao_band_64_8_c: 6061.1 ( 1.00x) vvc_sao_band_64_8_avx2: 803.9 ( 7.54x) vvc_sao_band_64_10_c: 6142.5 ( 1.00x) vvc_sao_band_64_10_avx2: 827.3 ( 7.43x) vvc_sao_band_64_12_c: 6106.6 ( 1.00x) vvc_sao_band_64_12_avx2: 839.9 ( 7.27x) vvc_sao_band_80_8_c: 9478.0 ( 1.00x) vvc_sao_band_80_8_avx2: 1516.7 ( 6.25x) vvc_sao_band_80_10_c: 10300.5 ( 1.00x) vvc_sao_band_80_10_avx2: 1298.7 ( 7.93x) vvc_sao_band_80_12_c: 8941.1 ( 1.00x) vvc_sao_band_80_12_avx2: 1315.3 ( 6.80x) vvc_sao_band_96_8_c: 13351.5 ( 1.00x) vvc_sao_band_96_8_avx2: 1815.4 ( 7.35x) vvc_sao_band_96_10_c: 13197.5 ( 1.00x) vvc_sao_band_96_10_avx2: 1872.4 ( 7.05x) vvc_sao_band_96_12_c: 11969.0 ( 1.00x) vvc_sao_band_96_12_avx2: 1895.8 ( 6.31x) vvc_sao_band_112_8_c: 19936.9 ( 1.00x) vvc_sao_band_112_8_avx2: 2802.3 ( 7.11x) vvc_sao_band_112_10_c: 19534.9 ( 1.00x) vvc_sao_band_112_10_avx2: 2635.0 ( 7.41x) vvc_sao_band_112_12_c: 16520.6 ( 1.00x) vvc_sao_band_112_12_avx2: 2591.8 ( 6.37x) vvc_sao_band_128_8_c: 25967.5 ( 1.00x) vvc_sao_band_128_8_avx2: 3155.3 ( 8.23x) vvc_sao_band_128_10_c: 24002.6 ( 1.00x) vvc_sao_band_128_10_avx2: 3374.6 ( 7.11x) vvc_sao_band_128_12_c: 20829.4 ( 1.00x) vvc_sao_band_128_12_avx2: 3377.0 ( 6.17x) vvc_sao_edge_8_8_c: 174.6 ( 1.00x) vvc_sao_edge_8_8_avx2: 37.0 ( 4.72x) vvc_sao_edge_8_10_c: 174.4 ( 1.00x) vvc_sao_edge_8_10_avx2: 58.5 ( 2.98x) vvc_sao_edge_8_12_c: 171.1 ( 1.00x) vvc_sao_edge_8_12_avx2: 58.5 ( 2.93x) vvc_sao_edge_16_8_c: 677.7 ( 1.00x) vvc_sao_edge_16_8_avx2: 72.2 ( 9.39x) vvc_sao_edge_16_10_c: 724.8 ( 1.00x) vvc_sao_edge_16_10_avx2: 106.4 ( 6.81x) vvc_sao_edge_16_12_c: 647.0 ( 1.00x) vvc_sao_edge_16_12_avx2: 106.6 ( 6.07x) vvc_sao_edge_32_8_c: 3001.8 ( 1.00x) vvc_sao_edge_32_8_avx2: 157.6 (19.04x) vvc_sao_edge_32_10_c: 3071.1 ( 1.00x) vvc_sao_edge_32_10_avx2: 404.2 ( 7.60x) vvc_sao_edge_32_12_c: 2698.6 ( 1.00x) vvc_sao_edge_32_12_avx2: 398.8 ( 6.77x) vvc_sao_edge_48_8_c: 6557.7 ( 1.00x) vvc_sao_edge_48_8_avx2: 380.1 (17.25x) vvc_sao_edge_48_10_c: 6319.9 ( 1.00x) vvc_sao_edge_48_10_avx2: 896.3 ( 7.05x) vvc_sao_edge_48_12_c: 6306.4 ( 1.00x) vvc_sao_edge_48_12_avx2: 885.5 ( 7.12x) vvc_sao_edge_64_8_c: 11510.7 ( 1.00x) vvc_sao_edge_64_8_avx2: 504.1 (22.84x) vvc_sao_edge_64_10_c: 10917.4 ( 1.00x) vvc_sao_edge_64_10_avx2: 1608.3 ( 6.79x) vvc_sao_edge_64_12_c: 11499.8 ( 1.00x) vvc_sao_edge_64_12_avx2: 1586.4 ( 7.25x) vvc_sao_edge_80_8_c: 18193.2 ( 1.00x) vvc_sao_edge_80_8_avx2: 930.2 (19.56x) vvc_sao_edge_80_10_c: 17984.3 ( 1.00x) vvc_sao_edge_80_10_avx2: 2420.9 ( 7.43x) vvc_sao_edge_80_12_c: 18289.4 ( 1.00x) vvc_sao_edge_80_12_avx2: 2412.1 ( 7.58x) vvc_sao_edge_96_8_c: 26361.8 ( 1.00x) vvc_sao_edge_96_8_avx2: 1118.4 (23.57x) vvc_sao_edge_96_10_c: 26162.2 ( 1.00x) vvc_sao_edge_96_10_avx2: 3666.9 ( 7.13x) vvc_sao_edge_96_12_c: 25926.6 ( 1.00x) vvc_sao_edge_96_12_avx2: 3433.9 ( 7.55x) vvc_sao_edge_112_8_c: 36562.9 ( 1.00x) vvc_sao_edge_112_8_avx2: 1741.0 (21.00x) vvc_sao_edge_112_10_c: 38126.4 ( 1.00x) vvc_sao_edge_112_10_avx2: 5153.3 ( 7.40x) vvc_sao_edge_112_12_c: 36345.7 ( 1.00x) vvc_sao_edge_112_12_avx2: 4684.9 ( 7.76x) vvc_sao_edge_128_8_c: 46379.8 ( 1.00x) vvc_sao_edge_128_8_avx2: 2012.4 (23.05x) vvc_sao_edge_128_10_c: 47029.5 ( 1.00x) vvc_sao_edge_128_10_avx2: 6162.2 ( 7.63x) vvc_sao_edge_128_12_c: 49647.3 ( 1.00x) vvc_sao_edge_128_12_avx2: 6127.1 ( 8.10x) 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(); + } + } + bench_new(dst1, src1, stride, stride, offset_val, left_class, block_size, block_size); + } + } +} + +static void check_sao_edge(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 eo = rnd()%4; + + 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; + int offset = (AV_INPUT_BUFFER_PADDING_SIZE + PIXEL_STRIDE)*SIZEOF_PIXEL; + declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t stride_dst, + const int16_t *sao_offset_val, int eo, int width, int height); + + 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); + + if (check_func(h->sao.edge_filter[i], "vvc_sao_edge_%d_%d", block_size, bit_depth)) { + call_ref(dst0, src0 + offset, stride, offset_val, eo, w, block_size); + call_new(dst1, src1 + offset, stride, offset_val, eo, w, block_size); + for (int j = 0; j < block_size; j++) { + if (memcmp(dst0 + j*stride, dst1 + j*stride, w*SIZEOF_PIXEL)) + fail(); + } + bench_new(dst1, src1 + offset, stride, offset_val, eo, block_size, block_size); + } + } + } +} + +void checkasm_check_vvc_sao(void) +{ + int bit_depth; + + for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) { + VVCDSPContext h; + + ff_vvc_dsp_init(&h, bit_depth); + check_sao_band(&h, bit_depth); + } + report("sao_band"); + + for (bit_depth = 8; bit_depth <= 12; bit_depth += 2) { + VVCDSPContext h; + + ff_vvc_dsp_init(&h, bit_depth); + check_sao_edge(&h, bit_depth); + } + report("sao_edge"); +} -- 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-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2025-05-02 7:45 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 ` Nuo Mi [this message] 2025-05-02 7:49 ` [FFmpeg-devel] [PATCH 5/5] checkasm: add vvc_sao Martin Storsjö 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=20250502074430.291561-5-nuomi2021@gmail.com \ --to=nuomi2021@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --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