On 4/19/2025 4:07 PM, Mark Thompson wrote:
Typical checkasm result on Alder Lake:decode_transquant_8_c: 408.7 ( 1.00x) decode_transquant_8_avx2: 94.2 ( 4.34x) decode_transquant_10_c: 413.1 ( 1.00x) decode_transquant_10_avx2: 87.5 ( 4.72x) --- libavcodec/apv_dsp.c | 4 + libavcodec/apv_dsp.h | 2 + libavcodec/x86/Makefile | 2 + libavcodec/x86/apv_dsp.asm | 243 ++++++++++++++++++++++++++++++++++ libavcodec/x86/apv_dsp_init.c | 41 ++++++ tests/checkasm/Makefile | 1 + tests/checkasm/apv_dsp.c | 113 ++++++++++++++++ tests/checkasm/checkasm.c | 3 + tests/checkasm/checkasm.h | 1 + 9 files changed, 410 insertions(+) create mode 100644 libavcodec/x86/apv_dsp.asm create mode 100644 libavcodec/x86/apv_dsp_init.c create mode 100644 tests/checkasm/apv_dsp.c
[...]
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index d5c50e5599..193c1e4633 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -28,6 +28,7 @@ AVCODECOBJS-$(CONFIG_AAC_DECODER) += aacpsdsp.o \ sbrdsp.o AVCODECOBJS-$(CONFIG_AAC_ENCODER) += aacencdsp.o AVCODECOBJS-$(CONFIG_ALAC_DECODER) += alacdsp.o +AVCODECOBJS-$(CONFIG_APV_DECODER) += apv_dsp.o AVCODECOBJS-$(CONFIG_DCA_DECODER) += synth_filter.o AVCODECOBJS-$(CONFIG_DIRAC_DECODER) += diracdsp.o AVCODECOBJS-$(CONFIG_EXR_DECODER) += exrdsp.o diff --git a/tests/checkasm/apv_dsp.c b/tests/checkasm/apv_dsp.c new file mode 100644 index 0000000000..a0272d8edc --- /dev/null +++ b/tests/checkasm/apv_dsp.c @@ -0,0 +1,113 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdint.h> + +#include "checkasm.h" + +#include "libavutil/attributes.h" +#include "libavutil/mem_internal.h" +#include "libavcodec/apv_dsp.h" + + +static void check_decode_transquant_8(void) +{ + LOCAL_ALIGNED_16(int16_t, input, [64]); + LOCAL_ALIGNED_16(int16_t, qmatrix, [64]); + LOCAL_ALIGNED_16(uint8_t, new_output, [64]); + LOCAL_ALIGNED_16(uint8_t, ref_output, [64]); + + declare_func(void, + uint8_t *output, + ptrdiff_t pitch, + const int16_t *input, + const int16_t *qmatrix, + int64_t bit_depth, + int64_t qp_shift); + + for (int i = 0; i < 64; i++) { + // Any signed 12-bit integer. + input[i] = rnd() % 2048 - 1024; + + // qmatrix input is premultiplied by level_scale, so + // range is 1 to 255 * 71. Interesting values are all + // at the low end of that, though. + qmatrix[i] = rnd() % 16 + 16; + } + + call_ref(ref_output, 8, input, qmatrix, 8, 4); + call_new(new_output, 8, input, qmatrix, 8, 4); + + for (int i = 0; i < 64; i++) { + if (ref_output[i] != new_output[i])
memcmp?
+ fail(); + } + + bench_new(new_output, 8, input, qmatrix, 8, 4); +} + +static void check_decode_transquant_10(void) +{ + LOCAL_ALIGNED_16( int16_t, input, [64]); + LOCAL_ALIGNED_16( int16_t, qmatrix, [64]); + LOCAL_ALIGNED_16(uint16_t, new_output, [64]); + LOCAL_ALIGNED_16(uint16_t, ref_output, [64]); + + declare_func(void, + uint16_t *output, + ptrdiff_t pitch, + const int16_t *input, + const int16_t *qmatrix, + int64_t bit_depth, + int64_t qp_shift); + + for (int i = 0; i < 64; i++) { + // Any signed 14-bit integer. + input[i] = rnd() % 16384 - 8192; + + // qmatrix input is premultiplied by level_scale, so + // range is 1 to 255 * 71. Interesting values are all + // at the low end of that, though. + qmatrix[i] = 16; //rnd() % 16 + 16; + } + + call_ref(ref_output, 16, input, qmatrix, 10, 4); + call_new(new_output, 16, input, qmatrix, 10, 4); + + for (int i = 0; i < 64; i++) { + if (ref_output[i] != new_output[i]) + fail(); + } + + bench_new(new_output, 16, input, qmatrix, 10, 4); +} + +void checkasm_check_apv_dsp(void) +{ + APVDSPContext dsp; + + ff_apv_dsp_init(&dsp); + + if (check_func(dsp.decode_transquant, "decode_transquant_8")) + check_decode_transquant_8(); + + if (check_func(dsp.decode_transquant, "decode_transquant_10")) + check_decode_transquant_10(); + + report("apv_dsp"); +} diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 412b8b2cd1..3bb82ed0e5 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -129,6 +129,9 @@ static const struct { #if CONFIG_ALAC_DECODER { "alacdsp", checkasm_check_alacdsp }, #endif + #if CONFIG_APV_DECODER + { "apv_dsp", checkasm_check_apv_dsp }, + #endif #if CONFIG_AUDIODSP { "audiodsp", checkasm_check_audiodsp }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index ad239fb2a4..a6b5965e02 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -83,6 +83,7 @@ void checkasm_check_ac3dsp(void); void checkasm_check_aes(void); void checkasm_check_afir(void); void checkasm_check_alacdsp(void); +void checkasm_check_apv_dsp(void); void checkasm_check_audiodsp(void); void checkasm_check_av_tx(void); void checkasm_check_blend(void);
Also add an entry to tests/fate/checkasm.mak while at it.
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ 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".