checkasm: use FF_ARRAY_ELEMS instead of hardcoding size of arrays

This commit is contained in:
Ramiro Polla 2024-09-18 16:29:14 +02:00
parent 8b30daedf7
commit a8ef1fac0d
3 changed files with 10 additions and 24 deletions

View File

@ -72,7 +72,6 @@ static void check_output_yuv2gbrp(void)
#define FILTER_SIZES 4 #define FILTER_SIZES 4
static const int filter_sizes[] = {1, 4, 8, 16}; static const int filter_sizes[] = {1, 4, 8, 16};
#define LARGEST_INPUT_SIZE 512 #define LARGEST_INPUT_SIZE 512
#define INPUT_SIZES 6
static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
uint8_t *dst0[4]; uint8_t *dst0[4];
uint8_t *dst1[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 (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
for (fsi = 0; fsi < FILTER_SIZES; fsi++) { 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]); desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
c->dstFormat = planar_fmts[fmi]; c->dstFormat = planar_fmts[fmi];
@ -187,7 +186,6 @@ static void check_output_yuv2gbrp(void)
} }
#undef LARGEST_INPUT_SIZE #undef LARGEST_INPUT_SIZE
#undef INPUT_SIZES
static void check_input_planar_rgb_to_y(void) 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 fmi, isi;
int dstW, byte_size; int dstW, byte_size;
#define LARGEST_INPUT_SIZE 512 #define LARGEST_INPUT_SIZE 512
#define INPUT_SIZES 6
static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
const uint8_t *src[4]; const uint8_t *src[4];
int32_t rgb2yuv[9] = {0}; int32_t rgb2yuv[9] = {0};
@ -230,7 +227,7 @@ static void check_input_planar_rgb_to_y(void)
c = sws_internal(sws); c = sws_internal(sws);
for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { 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]); desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
c->srcFormat = planar_fmts[fmi]; c->srcFormat = planar_fmts[fmi];
c->dstFormat = AV_PIX_FMT_YUVA444P16; c->dstFormat = AV_PIX_FMT_YUVA444P16;
@ -257,7 +254,6 @@ static void check_input_planar_rgb_to_y(void)
} }
#undef LARGEST_INPUT_SIZE #undef LARGEST_INPUT_SIZE
#undef INPUT_SIZES
static void check_input_planar_rgb_to_uv(void) 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 fmi, isi;
int dstW, byte_size; int dstW, byte_size;
#define LARGEST_INPUT_SIZE 512 #define LARGEST_INPUT_SIZE 512
#define INPUT_SIZES 6
static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
const uint8_t *src[4]; const uint8_t *src[4];
int32_t rgb2yuv[9] = {0}; int32_t rgb2yuv[9] = {0};
@ -303,7 +298,7 @@ static void check_input_planar_rgb_to_uv(void)
c = sws_internal(sws); c = sws_internal(sws);
for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { 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]); desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
c->srcFormat = planar_fmts[fmi]; c->srcFormat = planar_fmts[fmi];
c->dstFormat = AV_PIX_FMT_YUVA444P16; c->dstFormat = AV_PIX_FMT_YUVA444P16;
@ -332,7 +327,6 @@ static void check_input_planar_rgb_to_uv(void)
} }
#undef LARGEST_INPUT_SIZE #undef LARGEST_INPUT_SIZE
#undef INPUT_SIZES
static void check_input_planar_rgb_to_a(void) 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 fmi, isi;
int dstW, byte_size; int dstW, byte_size;
#define LARGEST_INPUT_SIZE 512 #define LARGEST_INPUT_SIZE 512
#define INPUT_SIZES 6
static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
const uint8_t *src[4]; const uint8_t *src[4];
int32_t rgb2yuv[9] = {0}; int32_t rgb2yuv[9] = {0};
@ -375,7 +368,7 @@ static void check_input_planar_rgb_to_a(void)
c = sws_internal(sws); c = sws_internal(sws);
for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { 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]); desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
if (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) if (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA))
continue; continue;

View File

@ -32,7 +32,6 @@ static void check_lumConvertRange(int from)
{ {
const char *func_str = from ? "lumRangeFromJpeg" : "lumRangeToJpeg"; const char *func_str = from ? "lumRangeFromJpeg" : "lumRangeToJpeg";
#define LARGEST_INPUT_SIZE 512 #define LARGEST_INPUT_SIZE 512
#define INPUT_SIZES 6
static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
SwsContext *sws; SwsContext *sws;
SwsInternal *c; SwsInternal *c;
@ -52,7 +51,7 @@ static void check_lumConvertRange(int from)
c->srcRange = from; c->srcRange = from;
c->dstRange = !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]; int width = input_sizes[dstWi];
for (int i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
uint8_t r = rnd(); uint8_t r = rnd();
@ -72,13 +71,11 @@ static void check_lumConvertRange(int from)
sws_freeContext(sws); sws_freeContext(sws);
} }
#undef LARGEST_INPUT_SIZE #undef LARGEST_INPUT_SIZE
#undef INPUT_SIZES
static void check_chrConvertRange(int from) static void check_chrConvertRange(int from)
{ {
const char *func_str = from ? "chrRangeFromJpeg" : "chrRangeToJpeg"; const char *func_str = from ? "chrRangeFromJpeg" : "chrRangeToJpeg";
#define LARGEST_INPUT_SIZE 512 #define LARGEST_INPUT_SIZE 512
#define INPUT_SIZES 6
static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
SwsContext *sws; SwsContext *sws;
SwsInternal *c; SwsInternal *c;
@ -100,7 +97,7 @@ static void check_chrConvertRange(int from)
c->srcRange = from; c->srcRange = from;
c->dstRange = !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]; int width = input_sizes[dstWi];
for (int i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
uint8_t r = rnd(); uint8_t r = rnd();
@ -123,7 +120,6 @@ static void check_chrConvertRange(int from)
sws_freeContext(sws); sws_freeContext(sws);
} }
#undef LARGEST_INPUT_SIZE #undef LARGEST_INPUT_SIZE
#undef INPUT_SIZES
void checkasm_check_sw_range_convert(void) void checkasm_check_sw_range_convert(void)
{ {

View File

@ -105,7 +105,6 @@ static void check_yuv2yuv1(int accurate)
int dstW, offset; int dstW, offset;
size_t fail_offset; size_t fail_offset;
const int input_sizes[] = {8, 24, 128, 144, 256, 512}; 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 #define LARGEST_INPUT_SIZE 512
const int offsets[] = {0, 3, 8, 11, 16, 19}; const int offsets[] = {0, 3, 8, 11, 16, 19};
@ -131,7 +130,7 @@ static void check_yuv2yuv1(int accurate)
fail(); fail();
ff_sws_init_scale(c); 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]; dstW = input_sizes[isi];
for (osi = 0; osi < OFFSET_SIZES; osi++) { for (osi = 0; osi < OFFSET_SIZES; osi++) {
offset = offsets[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]); const int FILTER_SIZES = sizeof(filter_sizes)/sizeof(filter_sizes[0]);
#define LARGEST_INPUT_SIZE 512 #define LARGEST_INPUT_SIZE 512
static const int input_sizes[] = {8, 24, 128, 144, 256, 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"; const char *accurate_str = (accurate) ? "accurate" : "approximate";
declare_func_emms(AV_CPU_FLAG_MMX, void, const int16_t *filter, declare_func_emms(AV_CPU_FLAG_MMX, void, const int16_t *filter,
@ -199,7 +197,7 @@ static void check_yuv2yuvX(int accurate)
fail(); fail();
ff_sws_init_scale(c); 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]; dstW = input_sizes[isi];
for(osi = 0; osi < 64; osi += 16){ for(osi = 0; osi < 64; osi += 16){
if (dstW <= osi) if (dstW <= osi)
@ -274,8 +272,7 @@ static void check_hscale(void)
}; };
#define LARGEST_INPUT_SIZE 512 #define LARGEST_INPUT_SIZE 512
#define INPUT_SIZES 6 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
static const int input_sizes[INPUT_SIZES] = {8, 24, 128, 144, 256, 512};
int i, j, fsi, hpi, width, dstWi; int i, j, fsi, hpi, width, dstWi;
SwsContext *sws; SwsContext *sws;
@ -307,7 +304,7 @@ static void check_hscale(void)
for (hpi = 0; hpi < HSCALE_PAIRS; hpi++) { for (hpi = 0; hpi < HSCALE_PAIRS; hpi++) {
for (fsi = 0; fsi < FILTER_SIZES; fsi++) { 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]; width = filter_sizes[fsi];
c->srcBpc = hscale_pairs[hpi][0]; c->srcBpc = hscale_pairs[hpi][0];