[FFmpeg-cvslog] libpostproc/tests: Factor ff_chksum() out
Michael Niedermayer
git at videolan.org
Mon May 5 20:15:42 EEST 2025
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun May 4 16:29:19 2025 +0200| [e5640e67d08c9b95632a88f3916edb4face4d265] | committer: Michael Niedermayer
libpostproc/tests: Factor ff_chksum() out
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e5640e67d08c9b95632a88f3916edb4face4d265
---
libpostproc/Makefile | 6 ++++++
libpostproc/tests/blocktest.c | 18 ++----------------
libpostproc/tests/stripetest.c | 18 ++----------------
libpostproc/tests/temptest.c | 18 ++----------------
libpostproc/tests/test_utils.c | 38 ++++++++++++++++++++++++++++++++++++++
libpostproc/tests/test_utils.h | 27 +++++++++++++++++++++++++++
6 files changed, 77 insertions(+), 48 deletions(-)
diff --git a/libpostproc/Makefile b/libpostproc/Makefile
index defd541e8b..d78fc0277f 100644
--- a/libpostproc/Makefile
+++ b/libpostproc/Makefile
@@ -9,9 +9,15 @@ HEADERS = postprocess.h \
OBJS = postprocess.o \
version.o \
+TESTOBJS = tests/test_utils.o \
+
# Windows resource file
SHLIBOBJS-$(HAVE_GNU_WINDRES) += postprocres.o
TESTPROGS = blocktest \
stripetest \
temptest \
+
+$(SUBDIR)tests/blocktest$(EXESUF): $(SUBDIR)tests/test_utils.o
+$(SUBDIR)tests/stripetest$(EXESUF): $(SUBDIR)tests/test_utils.o
+$(SUBDIR)tests/temptest$(EXESUF): $(SUBDIR)tests/test_utils.o
diff --git a/libpostproc/tests/blocktest.c b/libpostproc/tests/blocktest.c
index 5375d3c72b..e91fb0b569 100644
--- a/libpostproc/tests/blocktest.c
+++ b/libpostproc/tests/blocktest.c
@@ -21,6 +21,7 @@
#include "libavutil/frame.h"
#include "libavutil/adler32.h"
#include "libpostproc/postprocess.h"
+#include "test_utils.h"
typedef const uint8_t *cuint8;
@@ -39,21 +40,6 @@ static void blocks(AVFrame *frame, int blocksize, int mul)
}
}
-static int64_t chksum(AVFrame *f)
-{
- AVAdler a = 123;
-
- for(int y=0; y<f->height; y++) {
- a = av_adler32_update(a, &f->data[0][y*f->linesize[0]], f->width);
- }
- for(int y=0; y<(f->height+1)/2; y++) {
- a = av_adler32_update(a, &f->data[1][y*f->linesize[1]], (f->width+1)/2);
- a = av_adler32_update(a, &f->data[2][y*f->linesize[2]], (f->width+1)/2);
- }
-
- return a;
-}
-
static int64_t test(int width, int height, const char * filter_string, int blocksize, int flags, int pict_type, int quality) {
AVFrame *in = av_frame_alloc();
AVFrame *out = av_frame_alloc();
@@ -90,7 +76,7 @@ static int64_t test(int width, int height, const char * filter_string, int block
width, height, qp, QP_STRIDE,
mode, context, pict_type);
- ret = chksum(out);
+ ret = ff_chksum(out);
end:
av_frame_free(&in);
av_frame_free(&out);
diff --git a/libpostproc/tests/stripetest.c b/libpostproc/tests/stripetest.c
index be23934493..def7aa3756 100644
--- a/libpostproc/tests/stripetest.c
+++ b/libpostproc/tests/stripetest.c
@@ -21,6 +21,7 @@
#include "libavutil/frame.h"
#include "libavutil/adler32.h"
#include "libpostproc/postprocess.h"
+#include "test_utils.h"
typedef const uint8_t *cuint8;
@@ -48,21 +49,6 @@ static void strips(AVFrame *frame, int mul)
}
}
-static int64_t chksum(AVFrame *f)
-{
- AVAdler a = 123;
-
- for(int y=0; y<f->height; y++) {
- a = av_adler32_update(a, &f->data[0][y*f->linesize[0]], f->width);
- }
- for(int y=0; y<(f->height+1)/2; y++) {
- a = av_adler32_update(a, &f->data[1][y*f->linesize[1]], (f->width+1)/2);
- a = av_adler32_update(a, &f->data[2][y*f->linesize[2]], (f->width+1)/2);
- }
-
- return a;
-}
-
static int64_t test(int width, int height, const char *testname, int mul, int flags, int pict_type, int quality) {
AVFrame *in = av_frame_alloc();
AVFrame *out = av_frame_alloc();
@@ -94,7 +80,7 @@ static int64_t test(int width, int height, const char *testname, int mul, int fl
width, height, NULL, 0,
mode, context, pict_type);
- ret = chksum(out);
+ ret = ff_chksum(out);
end:
av_frame_free(&in);
av_frame_free(&out);
diff --git a/libpostproc/tests/temptest.c b/libpostproc/tests/temptest.c
index 5396b0da44..26414a1ce3 100644
--- a/libpostproc/tests/temptest.c
+++ b/libpostproc/tests/temptest.c
@@ -21,6 +21,7 @@
#include "libavutil/frame.h"
#include "libavutil/adler32.h"
#include "libpostproc/postprocess.h"
+#include "test_utils.h"
typedef const uint8_t *cuint8;
@@ -41,21 +42,6 @@ static void stuff(AVFrame *frame, unsigned *state, int mul)
}
}
-static int64_t chksum(AVFrame *f)
-{
- AVAdler a = 123;
-
- for(int y=0; y<f->height; y++) {
- a = av_adler32_update(a, &f->data[0][y*f->linesize[0]], f->width);
- }
- for(int y=0; y<(f->height+1)/2; y++) {
- a = av_adler32_update(a, &f->data[1][y*f->linesize[1]], (f->width+1)/2);
- a = av_adler32_update(a, &f->data[2][y*f->linesize[2]], (f->width+1)/2);
- }
-
- return a;
-}
-
static int64_t test(int width, int height, const char *testname, int mul, int flags, int pict_type, int quality) {
AVFrame *in = av_frame_alloc();
AVFrame *out = av_frame_alloc();
@@ -89,7 +75,7 @@ static int64_t test(int width, int height, const char *testname, int mul, int fl
width, height, NULL, 0,
mode, context, pict_type);
- ret += chksum(out);
+ ret += ff_chksum(out);
ret *= 1664525U;
}
end:
diff --git a/libpostproc/tests/test_utils.c b/libpostproc/tests/test_utils.c
new file mode 100644
index 0000000000..f1642c0c81
--- /dev/null
+++ b/libpostproc/tests/test_utils.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2025 Michael Niedermayer
+ *
+ * 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/frame.h"
+#include "libavutil/adler32.h"
+#include "test_utils.h"
+
+int64_t ff_chksum(AVFrame *f)
+{
+ AVAdler a = 123;
+
+ for(int y=0; y<f->height; y++) {
+ a = av_adler32_update(a, &f->data[0][y*f->linesize[0]], f->width);
+ }
+ for(int y=0; y<(f->height+1)/2; y++) {
+ a = av_adler32_update(a, &f->data[1][y*f->linesize[1]], (f->width+1)/2);
+ a = av_adler32_update(a, &f->data[2][y*f->linesize[2]], (f->width+1)/2);
+ }
+
+ return a;
+}
diff --git a/libpostproc/tests/test_utils.h b/libpostproc/tests/test_utils.h
new file mode 100644
index 0000000000..d73ea6cab8
--- /dev/null
+++ b/libpostproc/tests/test_utils.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Michael Niedermayer
+ *
+ * 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
+ */
+
+
+#ifndef POSTPROC_TESTS_TEST_UTILS_H
+#define POSTPROC_TESTS_TEST_UTILS_H
+
+int64_t ff_chksum(AVFrame *f);
+
+#endif /* POSTPROC_TESTS_TEST_UTILS_H */
More information about the ffmpeg-cvslog
mailing list