Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] libpostproc/tests: Factor ff_chksum() out
@ 2025-05-04 15:39 Michael Niedermayer
  2025-05-05 12:50 ` Andreas Rheinhardt
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Niedermayer @ 2025-05-04 15:39 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libpostproc/Makefile           |  6 ++++++
 libpostproc/test_utils.c       | 38 ++++++++++++++++++++++++++++++++++
 libpostproc/test_utils.h       | 27 ++++++++++++++++++++++++
 libpostproc/tests/blocktest.c  | 18 ++--------------
 libpostproc/tests/stripetest.c | 18 ++--------------
 libpostproc/tests/temptest.c   | 18 ++--------------
 6 files changed, 77 insertions(+), 48 deletions(-)
 create mode 100644 libpostproc/test_utils.c
 create mode 100644 libpostproc/test_utils.h

diff --git a/libpostproc/Makefile b/libpostproc/Makefile
index defd541e8bc..f75c9537944 100644
--- a/libpostproc/Makefile
+++ b/libpostproc/Makefile
@@ -9,9 +9,15 @@ HEADERS = postprocess.h        \
 OBJS = postprocess.o           \
        version.o               \
 
+TESTOBJS = test_utils.o        \
+
 # Windows resource file
 SHLIBOBJS-$(HAVE_GNU_WINDRES) += postprocres.o
 
 TESTPROGS = blocktest          \
             stripetest         \
             temptest	       \
+
+$(SUBDIR)tests/blocktest$(EXESUF):  $(SUBDIR)test_utils.o
+$(SUBDIR)tests/stripetest$(EXESUF): $(SUBDIR)test_utils.o
+$(SUBDIR)tests/temptest$(EXESUF):  $(SUBDIR)test_utils.o
diff --git a/libpostproc/test_utils.c b/libpostproc/test_utils.c
new file mode 100644
index 00000000000..bce0a112cce
--- /dev/null
+++ b/libpostproc/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 "libpostproc/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/test_utils.h b/libpostproc/test_utils.h
new file mode 100644
index 00000000000..f79ec997a74
--- /dev/null
+++ b/libpostproc/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_TEST_UTILS_H
+#define POSTPROC_TEST_UTILS_H
+
+int64_t ff_chksum(AVFrame *f);
+
+#endif /* POSTPROC_TEST_UTILS_H */
diff --git a/libpostproc/tests/blocktest.c b/libpostproc/tests/blocktest.c
index 5375d3c72b6..baba610c284 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 "libpostproc/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 be23934493f..ef92b22427a 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 "libpostproc/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 5396b0da44e..2ebd8fb1528 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 "libpostproc/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:
-- 
2.49.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] libpostproc/tests: Factor ff_chksum() out
  2025-05-04 15:39 [FFmpeg-devel] [PATCH] libpostproc/tests: Factor ff_chksum() out Michael Niedermayer
@ 2025-05-05 12:50 ` Andreas Rheinhardt
  2025-05-05 17:07   ` Michael Niedermayer
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Rheinhardt @ 2025-05-05 12:50 UTC (permalink / raw)
  To: ffmpeg-devel

Michael Niedermayer:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libpostproc/Makefile           |  6 ++++++
>  libpostproc/test_utils.c       | 38 ++++++++++++++++++++++++++++++++++
>  libpostproc/test_utils.h       | 27 ++++++++++++++++++++++++
>  libpostproc/tests/blocktest.c  | 18 ++--------------
>  libpostproc/tests/stripetest.c | 18 ++--------------
>  libpostproc/tests/temptest.c   | 18 ++--------------
>  6 files changed, 77 insertions(+), 48 deletions(-)
>  create mode 100644 libpostproc/test_utils.c
>  create mode 100644 libpostproc/test_utils.h
> 
> diff --git a/libpostproc/Makefile b/libpostproc/Makefile
> index defd541e8bc..f75c9537944 100644
> --- a/libpostproc/Makefile
> +++ b/libpostproc/Makefile
> @@ -9,9 +9,15 @@ HEADERS = postprocess.h        \
>  OBJS = postprocess.o           \
>         version.o               \
>  
> +TESTOBJS = test_utils.o        \
> +
>  # Windows resource file
>  SHLIBOBJS-$(HAVE_GNU_WINDRES) += postprocres.o
>  
>  TESTPROGS = blocktest          \
>              stripetest         \
>              temptest	       \
> +
> +$(SUBDIR)tests/blocktest$(EXESUF):  $(SUBDIR)test_utils.o
> +$(SUBDIR)tests/stripetest$(EXESUF): $(SUBDIR)test_utils.o
> +$(SUBDIR)tests/temptest$(EXESUF):  $(SUBDIR)test_utils.o
> diff --git a/libpostproc/test_utils.c b/libpostproc/test_utils.c
> new file mode 100644
> index 00000000000..bce0a112cce
> --- /dev/null
> +++ b/libpostproc/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 "libpostproc/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/test_utils.h b/libpostproc/test_utils.h
> new file mode 100644
> index 00000000000..f79ec997a74
> --- /dev/null
> +++ b/libpostproc/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_TEST_UTILS_H
> +#define POSTPROC_TEST_UTILS_H
> +
> +int64_t ff_chksum(AVFrame *f);
> +
> +#endif /* POSTPROC_TEST_UTILS_H */
> diff --git a/libpostproc/tests/blocktest.c b/libpostproc/tests/blocktest.c
> index 5375d3c72b6..baba610c284 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 "libpostproc/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 be23934493f..ef92b22427a 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 "libpostproc/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 5396b0da44e..2ebd8fb1528 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 "libpostproc/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:

Why is this not in the tests subfolder?

- Andreas

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] libpostproc/tests: Factor ff_chksum() out
  2025-05-05 12:50 ` Andreas Rheinhardt
@ 2025-05-05 17:07   ` Michael Niedermayer
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Niedermayer @ 2025-05-05 17:07 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 9650 bytes --]

On Mon, May 05, 2025 at 02:50:35PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libpostproc/Makefile           |  6 ++++++
> >  libpostproc/test_utils.c       | 38 ++++++++++++++++++++++++++++++++++
> >  libpostproc/test_utils.h       | 27 ++++++++++++++++++++++++
> >  libpostproc/tests/blocktest.c  | 18 ++--------------
> >  libpostproc/tests/stripetest.c | 18 ++--------------
> >  libpostproc/tests/temptest.c   | 18 ++--------------
> >  6 files changed, 77 insertions(+), 48 deletions(-)
> >  create mode 100644 libpostproc/test_utils.c
> >  create mode 100644 libpostproc/test_utils.h
> > 
> > diff --git a/libpostproc/Makefile b/libpostproc/Makefile
> > index defd541e8bc..f75c9537944 100644
> > --- a/libpostproc/Makefile
> > +++ b/libpostproc/Makefile
> > @@ -9,9 +9,15 @@ HEADERS = postprocess.h        \
> >  OBJS = postprocess.o           \
> >         version.o               \
> >  
> > +TESTOBJS = test_utils.o        \
> > +
> >  # Windows resource file
> >  SHLIBOBJS-$(HAVE_GNU_WINDRES) += postprocres.o
> >  
> >  TESTPROGS = blocktest          \
> >              stripetest         \
> >              temptest	       \
> > +
> > +$(SUBDIR)tests/blocktest$(EXESUF):  $(SUBDIR)test_utils.o
> > +$(SUBDIR)tests/stripetest$(EXESUF): $(SUBDIR)test_utils.o
> > +$(SUBDIR)tests/temptest$(EXESUF):  $(SUBDIR)test_utils.o
> > diff --git a/libpostproc/test_utils.c b/libpostproc/test_utils.c
> > new file mode 100644
> > index 00000000000..bce0a112cce
> > --- /dev/null
> > +++ b/libpostproc/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 "libpostproc/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/test_utils.h b/libpostproc/test_utils.h
> > new file mode 100644
> > index 00000000000..f79ec997a74
> > --- /dev/null
> > +++ b/libpostproc/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_TEST_UTILS_H
> > +#define POSTPROC_TEST_UTILS_H
> > +
> > +int64_t ff_chksum(AVFrame *f);
> > +
> > +#endif /* POSTPROC_TEST_UTILS_H */
> > diff --git a/libpostproc/tests/blocktest.c b/libpostproc/tests/blocktest.c
> > index 5375d3c72b6..baba610c284 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 "libpostproc/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 be23934493f..ef92b22427a 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 "libpostproc/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 5396b0da44e..2ebd8fb1528 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 "libpostproc/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:
> 
> Why is this not in the tests subfolder?

will apply with it moved to tests subfolder

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Homeopathy is like voting while filling the ballot out with transparent ink.
Sometimes the outcome one wanted occurs. Rarely its worse than filling out
a ballot properly.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-05 17:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-04 15:39 [FFmpeg-devel] [PATCH] libpostproc/tests: Factor ff_chksum() out Michael Niedermayer
2025-05-05 12:50 ` Andreas Rheinhardt
2025-05-05 17:07   ` Michael Niedermayer

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