diff mbox series

[FFmpeg-devel,1/7] avutil/tests/imgutils: factorize basic tests to new function

Message ID 20231203002726.29683-1-cus@passwd.hu
State New
Headers show
Series [FFmpeg-devel,1/7] avutil/tests/imgutils: factorize basic tests to new function | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Marton Balint Dec. 3, 2023, 12:27 a.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavutil/tests/imgutils.c | 68 ++++++++++++++++++++++----------------
 1 file changed, 39 insertions(+), 29 deletions(-)

Comments

Stefano Sabatini Dec. 3, 2023, 9:31 p.m. UTC | #1
On date Sunday 2023-12-03 01:27:20 +0100, Marton Balint wrote:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavutil/tests/imgutils.c | 68 ++++++++++++++++++++++----------------
>  1 file changed, 39 insertions(+), 29 deletions(-)
> 
> diff --git a/libavutil/tests/imgutils.c b/libavutil/tests/imgutils.c
> index 748bd6c9d2..f3a433ac4a 100644
> --- a/libavutil/tests/imgutils.c
> +++ b/libavutil/tests/imgutils.c
> @@ -19,6 +19,41 @@
>  #include "libavutil/imgutils.c"
>  
>  #undef printf

> +static int basic_tests(enum AVPixelFormat pix_fmt, int w, int h) {

better be descriptive and follow the usual VERB_OBJECT convention,
this might be:
static inst check_image_fill(...)

[...]

LGTM otherwise.
diff mbox series

Patch

diff --git a/libavutil/tests/imgutils.c b/libavutil/tests/imgutils.c
index 748bd6c9d2..f3a433ac4a 100644
--- a/libavutil/tests/imgutils.c
+++ b/libavutil/tests/imgutils.c
@@ -19,6 +19,41 @@ 
 #include "libavutil/imgutils.c"
 
 #undef printf
+static int basic_tests(enum AVPixelFormat pix_fmt, int w, int h) {
+    uint8_t *data[4];
+    size_t sizes[4];
+    ptrdiff_t linesizes1[4], offsets[3] = { 0 };
+    int i, total_size, linesizes[4];
+
+    if (av_image_fill_linesizes(linesizes, pix_fmt, w) < 0)
+        return -1;
+    for (i = 0; i < 4; i++)
+        linesizes1[i] = linesizes[i];
+    if (av_image_fill_plane_sizes(sizes, pix_fmt, h, linesizes1) < 0)
+        return -1;
+    total_size = av_image_fill_pointers(data, pix_fmt, h, (void *)1, linesizes);
+    if (total_size < 0)
+        return -1;
+    for (i = 0; i < 4 && data[i]; i++);
+    printf("planes: %d", i);
+    // Test the output of av_image_fill_linesizes()
+    printf(", linesizes:");
+    for (i = 0; i < 4; i++)
+        printf(" %3d", linesizes[i]);
+    // Test the output of av_image_fill_plane_sizes()
+    printf(", plane_sizes:");
+    for (i = 0; i < 4; i++)
+        printf(" %5"SIZE_SPECIFIER, sizes[i]);
+    // Test the output of av_image_fill_pointers()
+    for (i = 0; i < 3 && data[i + 1]; i++)
+        offsets[i] = data[i + 1] - data[i];
+    printf(", plane_offsets:");
+    for (i = 0; i < 3; i++)
+        printf(" %5"PTRDIFF_SPECIFIER, offsets[i]);
+    printf(", total_size: %d", total_size);
+
+    return 0;
+}
 
 int main(void)
 {
@@ -35,39 +70,14 @@  int main(void)
     printf("\n");
 
     while (desc = av_pix_fmt_desc_next(desc)) {
-        uint8_t *data[4];
-        size_t sizes[4];
-        ptrdiff_t linesizes1[4], offsets[3] = { 0 };
-        int i, total_size, w = 64, h = 48, linesizes[4];
+        int w = 64, h = 48;
         enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(desc);
 
-        if (av_image_fill_linesizes(linesizes, pix_fmt, w) < 0)
-            continue;
-        for (i = 0; i < 4; i++)
-            linesizes1[i] = linesizes[i];
-        if (av_image_fill_plane_sizes(sizes, pix_fmt, h, linesizes1) < 0)
-            continue;
-        total_size = av_image_fill_pointers(data, pix_fmt, h, (void *)1, linesizes);
-        if (total_size < 0)
+        if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
             continue;
         printf("%-16s", desc->name);
-        for (i = 0; i < 4 && data[i]; i++);
-        printf("planes: %d", i);
-        // Test the output of av_image_fill_linesizes()
-        printf(", linesizes:");
-        for (i = 0; i < 4; i++)
-            printf(" %3d", linesizes[i]);
-        // Test the output of av_image_fill_plane_sizes()
-        printf(", plane_sizes:");
-        for (i = 0; i < 4; i++)
-            printf(" %5"SIZE_SPECIFIER, sizes[i]);
-        // Test the output of av_image_fill_pointers()
-        for (i = 0; i < 3 && data[i + 1]; i++)
-            offsets[i] = data[i + 1] - data[i];
-        printf(", plane_offsets:");
-        for (i = 0; i < 3; i++)
-            printf(" %5"PTRDIFF_SPECIFIER, offsets[i]);
-        printf(", total_size: %d\n", total_size);
+        basic_tests(pix_fmt, w, h);
+        printf("\n");
     }
 
     return 0;