[FFmpeg-devel] [PATCH 1/2] checkasm/mpegvideoencdsp: add pix_sum and pix_norm1
Ramiro Polla
ramiro.polla at gmail.com
Fri Aug 9 14:27:26 EEST 2024
---
tests/checkasm/Makefile | 1 +
tests/checkasm/checkasm.c | 3 ++
tests/checkasm/checkasm.h | 1 +
tests/checkasm/mpegvideoencdsp.c | 77 ++++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+)
create mode 100644 tests/checkasm/mpegvideoencdsp.c
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 3a7670e24b..7da58c14c4 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -18,6 +18,7 @@ AVCODECOBJS-$(CONFIG_LLVIDDSP) += llviddsp.o
AVCODECOBJS-$(CONFIG_LLVIDENCDSP) += llviddspenc.o
AVCODECOBJS-$(CONFIG_LPC) += lpc.o
AVCODECOBJS-$(CONFIG_ME_CMP) += motion.o
+AVCODECOBJS-$(CONFIG_MPEGVIDEOENC) += mpegvideoencdsp.o
AVCODECOBJS-$(CONFIG_VC1DSP) += vc1dsp.o
AVCODECOBJS-$(CONFIG_VP8DSP) += vp8dsp.o
AVCODECOBJS-$(CONFIG_VIDEODSP) += videodsp.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 58597d3888..0bba4fb295 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -170,6 +170,9 @@ static const struct {
#if CONFIG_ME_CMP
{ "motion", checkasm_check_motion },
#endif
+ #if CONFIG_MPEGVIDEOENC
+ { "mpegvideoencdsp", checkasm_check_mpegvideoencdsp },
+ #endif
#if CONFIG_OPUS_DECODER
{ "opusdsp", checkasm_check_opusdsp },
#endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 4d5f3e387e..ba7e8c1ea0 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -110,6 +110,7 @@ void checkasm_check_llviddsp(void);
void checkasm_check_llviddspenc(void);
void checkasm_check_lpc(void);
void checkasm_check_motion(void);
+void checkasm_check_mpegvideoencdsp(void);
void checkasm_check_nlmeans(void);
void checkasm_check_opusdsp(void);
void checkasm_check_pixblockdsp(void);
diff --git a/tests/checkasm/mpegvideoencdsp.c b/tests/checkasm/mpegvideoencdsp.c
new file mode 100644
index 0000000000..00d21ba0ba
--- /dev/null
+++ b/tests/checkasm/mpegvideoencdsp.c
@@ -0,0 +1,77 @@
+/*
+ * 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 "libavutil/mem.h"
+#include "libavutil/mem_internal.h"
+
+#include "libavcodec/mpegvideoencdsp.h"
+
+#include "checkasm.h"
+
+static void check_pix_sum(MpegvideoEncDSPContext *c)
+{
+ LOCAL_ALIGNED_16(uint8_t, src, [16 * 16]);
+
+ declare_func(int, const uint8_t *pix, int line_size);
+
+ for (int i = 0; i < 16 * 16; i++)
+ src[i] = rnd();
+
+ if (check_func(c->pix_sum, "pix_sum")) {
+ int sum0, sum1;
+ sum0 = call_ref(src, 16);
+ sum1 = call_new(src, 16);
+ if (sum0 != sum1)
+ fail();
+ bench_new(src, 16);
+ }
+}
+
+static void check_pix_norm1(MpegvideoEncDSPContext *c)
+{
+ LOCAL_ALIGNED_16(uint8_t, src, [16 * 16]);
+
+ declare_func(int, const uint8_t *pix, int line_size);
+
+ for (int i = 0; i < 16 * 16; i++)
+ src[i] = rnd();
+
+ if (check_func(c->pix_norm1, "pix_norm1")) {
+ int sum0, sum1;
+ sum0 = call_ref(src, 16);
+ sum1 = call_new(src, 16);
+ if (sum0 != sum1)
+ fail();
+ bench_new(src, 16);
+ }
+}
+
+void checkasm_check_mpegvideoencdsp(void)
+{
+ AVCodecContext avctx = {
+ .bits_per_raw_sample = 8,
+ };
+ MpegvideoEncDSPContext c = { 0 };
+
+ ff_mpegvideoencdsp_init(&c, &avctx);
+
+ check_pix_sum(&c);
+ report("pix_sum");
+ check_pix_norm1(&c);
+ report("pix_norm1");
+}
--
2.30.2
More information about the ffmpeg-devel
mailing list