From a8ef1fac0dfa9d64ba47fd6c4a307e2d4acb218f Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Wed, 18 Sep 2024 16:29:14 +0200 Subject: [PATCH] checkasm: use FF_ARRAY_ELEMS instead of hardcoding size of arrays --- tests/checkasm/sw_gbrp.c | 15 ++++----------- tests/checkasm/sw_range_convert.c | 8 ++------ tests/checkasm/sw_scale.c | 11 ++++------- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/tests/checkasm/sw_gbrp.c b/tests/checkasm/sw_gbrp.c index 039be8006b..23ac1dfb56 100644 --- a/tests/checkasm/sw_gbrp.c +++ b/tests/checkasm/sw_gbrp.c @@ -72,7 +72,6 @@ static void check_output_yuv2gbrp(void) #define FILTER_SIZES 4 static const int filter_sizes[] = {1, 4, 8, 16}; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; uint8_t *dst0[4]; uint8_t *dst1[4]; @@ -140,7 +139,7 @@ static void check_output_yuv2gbrp(void) for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { for (fsi = 0; fsi < FILTER_SIZES; fsi++) { - for (isi = 0; isi < INPUT_SIZES; isi++ ) { + for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); c->dstFormat = planar_fmts[fmi]; @@ -187,7 +186,6 @@ static void check_output_yuv2gbrp(void) } #undef LARGEST_INPUT_SIZE -#undef INPUT_SIZES static void check_input_planar_rgb_to_y(void) { @@ -197,7 +195,6 @@ static void check_input_planar_rgb_to_y(void) int fmi, isi; int dstW, byte_size; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; const uint8_t *src[4]; int32_t rgb2yuv[9] = {0}; @@ -230,7 +227,7 @@ static void check_input_planar_rgb_to_y(void) c = sws_internal(sws); for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { - for (isi = 0; isi < INPUT_SIZES; isi++ ) { + for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); c->srcFormat = planar_fmts[fmi]; c->dstFormat = AV_PIX_FMT_YUVA444P16; @@ -257,7 +254,6 @@ static void check_input_planar_rgb_to_y(void) } #undef LARGEST_INPUT_SIZE -#undef INPUT_SIZES static void check_input_planar_rgb_to_uv(void) { @@ -267,7 +263,6 @@ static void check_input_planar_rgb_to_uv(void) int fmi, isi; int dstW, byte_size; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; const uint8_t *src[4]; int32_t rgb2yuv[9] = {0}; @@ -303,7 +298,7 @@ static void check_input_planar_rgb_to_uv(void) c = sws_internal(sws); for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { - for (isi = 0; isi < INPUT_SIZES; isi++ ) { + for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); c->srcFormat = planar_fmts[fmi]; c->dstFormat = AV_PIX_FMT_YUVA444P16; @@ -332,7 +327,6 @@ static void check_input_planar_rgb_to_uv(void) } #undef LARGEST_INPUT_SIZE -#undef INPUT_SIZES static void check_input_planar_rgb_to_a(void) { @@ -342,7 +336,6 @@ static void check_input_planar_rgb_to_a(void) int fmi, isi; int dstW, byte_size; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; const uint8_t *src[4]; int32_t rgb2yuv[9] = {0}; @@ -375,7 +368,7 @@ static void check_input_planar_rgb_to_a(void) c = sws_internal(sws); for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { - for (isi = 0; isi < INPUT_SIZES; isi++ ) { + for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); if (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) continue; diff --git a/tests/checkasm/sw_range_convert.c b/tests/checkasm/sw_range_convert.c index 7da29b896e..06ea3474e4 100644 --- a/tests/checkasm/sw_range_convert.c +++ b/tests/checkasm/sw_range_convert.c @@ -32,7 +32,6 @@ static void check_lumConvertRange(int from) { const char *func_str = from ? "lumRangeFromJpeg" : "lumRangeToJpeg"; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; SwsContext *sws; SwsInternal *c; @@ -52,7 +51,7 @@ static void check_lumConvertRange(int from) c->srcRange = from; c->dstRange = !from; - for (int dstWi = 0; dstWi < INPUT_SIZES; dstWi++) { + for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) { int width = input_sizes[dstWi]; for (int i = 0; i < width; i++) { uint8_t r = rnd(); @@ -72,13 +71,11 @@ static void check_lumConvertRange(int from) sws_freeContext(sws); } #undef LARGEST_INPUT_SIZE -#undef INPUT_SIZES static void check_chrConvertRange(int from) { const char *func_str = from ? "chrRangeFromJpeg" : "chrRangeToJpeg"; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; SwsContext *sws; SwsInternal *c; @@ -100,7 +97,7 @@ static void check_chrConvertRange(int from) c->srcRange = from; c->dstRange = !from; - for (int dstWi = 0; dstWi < INPUT_SIZES; dstWi++) { + for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) { int width = input_sizes[dstWi]; for (int i = 0; i < width; i++) { uint8_t r = rnd(); @@ -123,7 +120,6 @@ static void check_chrConvertRange(int from) sws_freeContext(sws); } #undef LARGEST_INPUT_SIZE -#undef INPUT_SIZES void checkasm_check_sw_range_convert(void) { diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c index b383fa0930..7580c8b56c 100644 --- a/tests/checkasm/sw_scale.c +++ b/tests/checkasm/sw_scale.c @@ -105,7 +105,6 @@ static void check_yuv2yuv1(int accurate) int dstW, offset; size_t fail_offset; const int input_sizes[] = {8, 24, 128, 144, 256, 512}; - const int INPUT_SIZES = sizeof(input_sizes)/sizeof(input_sizes[0]); #define LARGEST_INPUT_SIZE 512 const int offsets[] = {0, 3, 8, 11, 16, 19}; @@ -131,7 +130,7 @@ static void check_yuv2yuv1(int accurate) fail(); ff_sws_init_scale(c); - for (isi = 0; isi < INPUT_SIZES; ++isi) { + for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); ++isi) { dstW = input_sizes[isi]; for (osi = 0; osi < OFFSET_SIZES; osi++) { offset = offsets[osi]; @@ -171,7 +170,6 @@ static void check_yuv2yuvX(int accurate) const int FILTER_SIZES = sizeof(filter_sizes)/sizeof(filter_sizes[0]); #define LARGEST_INPUT_SIZE 512 static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; - const int INPUT_SIZES = sizeof(input_sizes)/sizeof(input_sizes[0]); const char *accurate_str = (accurate) ? "accurate" : "approximate"; declare_func_emms(AV_CPU_FLAG_MMX, void, const int16_t *filter, @@ -199,7 +197,7 @@ static void check_yuv2yuvX(int accurate) fail(); ff_sws_init_scale(c); - for(isi = 0; isi < INPUT_SIZES; ++isi){ + for(isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); ++isi){ dstW = input_sizes[isi]; for(osi = 0; osi < 64; osi += 16){ if (dstW <= osi) @@ -274,8 +272,7 @@ static void check_hscale(void) }; #define LARGEST_INPUT_SIZE 512 -#define INPUT_SIZES 6 - static const int input_sizes[INPUT_SIZES] = {8, 24, 128, 144, 256, 512}; + static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; int i, j, fsi, hpi, width, dstWi; SwsContext *sws; @@ -307,7 +304,7 @@ static void check_hscale(void) for (hpi = 0; hpi < HSCALE_PAIRS; hpi++) { for (fsi = 0; fsi < FILTER_SIZES; fsi++) { - for (dstWi = 0; dstWi < INPUT_SIZES; dstWi++) { + for (dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) { width = filter_sizes[fsi]; c->srcBpc = hscale_pairs[hpi][0];