diff mbox series

[FFmpeg-devel,1/2] tests/checkasm/sw_scale.c

Message ID 20210219100057.70945-1-alankelly@google.com
State New
Headers show
Series [FFmpeg-devel,1/2] tests/checkasm/sw_scale.c | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Alan Kelly Feb. 19, 2021, 10 a.m. UTC
Initialises each item in src and filter arrays to fix valgrind
uninitialised value warning.
---
 tests/checkasm/sw_scale.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

James Almer Feb. 19, 2021, 1:05 p.m. UTC | #1
On 2/19/2021 7:00 AM, Alan Kelly wrote:
> Initialises each item in src and filter arrays to fix valgrind
> uninitialised value warning.
> ---
>   tests/checkasm/sw_scale.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c
> index 7504f8b45f..a4866723d7 100644
> --- a/tests/checkasm/sw_scale.c
> +++ b/tests/checkasm/sw_scale.c
> @@ -86,8 +86,10 @@ static void check_yuv2yuvX(void)
>           uint16_t coeff[8];
>       } *vFilterData;
>       uint8_t d_val = rnd();
> -    randomize_buffers(filter_coeff, LARGEST_FILTER);
> -    randomize_buffers(src_pixels, LARGEST_FILTER * LARGEST_INPUT_SIZE);
> +    for(i = 0; i < LARGEST_FILTER * LARGEST_INPUT_SIZE; ++i)
> +      src_pixels[i] = rnd();
> +    for(i = 0; i < LARGEST_FILTER; ++i)
> +      filter_coeff[i] = rnd();

This is slow and wasteful (each random value is 32 bits, and you throw 
away 24 bits).
Just cast the two pointers to uint8_t* and multiply the buffer size by 
sizeof(uint16_t). That way the loop in randomize_buffers() will cover 
the whole buffer.
diff mbox series

Patch

diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c
index 7504f8b45f..a4866723d7 100644
--- a/tests/checkasm/sw_scale.c
+++ b/tests/checkasm/sw_scale.c
@@ -86,8 +86,10 @@  static void check_yuv2yuvX(void)
         uint16_t coeff[8];
     } *vFilterData;
     uint8_t d_val = rnd();
-    randomize_buffers(filter_coeff, LARGEST_FILTER);
-    randomize_buffers(src_pixels, LARGEST_FILTER * LARGEST_INPUT_SIZE);
+    for(i = 0; i < LARGEST_FILTER * LARGEST_INPUT_SIZE; ++i)
+      src_pixels[i] = rnd();
+    for(i = 0; i < LARGEST_FILTER; ++i)
+      filter_coeff[i] = rnd();
     ctx = sws_alloc_context();
     if (sws_init_context(ctx, NULL, NULL) < 0)
         fail();