History

checkasm: use FF_ARRAY_ELEMS instead of hardcoding size of arrays

Ramiro Polla committed 2 years ago

Commit a8ef1fa1 parent 8b30dae3 files · +10 −24Browse files

Unified · Split

3 files
  1. tests/checkasm/sw_gbrp.c +4 −11
  2. tests/checkasm/sw_range_convert.c +2 −6
  3. tests/checkasm/sw_scale.c +4 −7
tests/checkasm/sw_gbrp.c+4−11
@@ -72,7 +72,6 @@ static void check_output_yuv2gbrp(void) · 71 unmodified lines
72#define FILTER_SIZES 472#define FILTER_SIZES 4
73 static const int filter_sizes[] = {1, 4, 8, 16};73 static const int filter_sizes[] = {1, 4, 8, 16};
74#define LARGEST_INPUT_SIZE 51274#define LARGEST_INPUT_SIZE 512
75#define INPUT_SIZES 6
76 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};75 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
77 uint8_t *dst0[4];76 uint8_t *dst0[4];
78 uint8_t *dst1[4];77 uint8_t *dst1[4];
@@ -140,7 +139,7 @@ static void check_output_yuv2gbrp(void) · 61 unmodified lines
140 139
141 for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {140 for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
142 for (fsi = 0; fsi < FILTER_SIZES; fsi++) {141 for (fsi = 0; fsi < FILTER_SIZES; fsi++) {
143 for (isi = 0; isi < INPUT_SIZES; isi++ ) {142 for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) {
144 desc = av_pix_fmt_desc_get(planar_fmts[fmi]);143 desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
145 c->dstFormat = planar_fmts[fmi];144 c->dstFormat = planar_fmts[fmi];
146 145
@@ -187,7 +186,6 @@ static void check_output_yuv2gbrp(void) · 40 unmodified lines
187}186}
188 187
189#undef LARGEST_INPUT_SIZE188#undef LARGEST_INPUT_SIZE
190#undef INPUT_SIZES
191 189
192static void check_input_planar_rgb_to_y(void)190static void check_input_planar_rgb_to_y(void)
193{191{
@@ -197,7 +195,6 @@ static void check_input_planar_rgb_to_y(void) · 3 unmodified lines
197 int fmi, isi;195 int fmi, isi;
198 int dstW, byte_size;196 int dstW, byte_size;
199#define LARGEST_INPUT_SIZE 512197#define LARGEST_INPUT_SIZE 512
200#define INPUT_SIZES 6
201 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};198 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
202 const uint8_t *src[4];199 const uint8_t *src[4];
203 int32_t rgb2yuv[9] = {0};200 int32_t rgb2yuv[9] = {0};
@@ -230,7 +227,7 @@ static void check_input_planar_rgb_to_y(void) · 26 unmodified lines
230 227
231 c = sws_internal(sws);228 c = sws_internal(sws);
232 for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {229 for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
233 for (isi = 0; isi < INPUT_SIZES; isi++ ) {230 for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) {
234 desc = av_pix_fmt_desc_get(planar_fmts[fmi]);231 desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
235 c->srcFormat = planar_fmts[fmi];232 c->srcFormat = planar_fmts[fmi];
236 c->dstFormat = AV_PIX_FMT_YUVA444P16;233 c->dstFormat = AV_PIX_FMT_YUVA444P16;
@@ -257,7 +254,6 @@ static void check_input_planar_rgb_to_y(void) · 20 unmodified lines
257}254}
258 255
259#undef LARGEST_INPUT_SIZE256#undef LARGEST_INPUT_SIZE
260#undef INPUT_SIZES
261 257
262static void check_input_planar_rgb_to_uv(void)258static void check_input_planar_rgb_to_uv(void)
263{259{
@@ -267,7 +263,6 @@ static void check_input_planar_rgb_to_uv(void) · 3 unmodified lines
267 int fmi, isi;263 int fmi, isi;
268 int dstW, byte_size;264 int dstW, byte_size;
269#define LARGEST_INPUT_SIZE 512265#define LARGEST_INPUT_SIZE 512
270#define INPUT_SIZES 6
271 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};266 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
272 const uint8_t *src[4];267 const uint8_t *src[4];
273 int32_t rgb2yuv[9] = {0};268 int32_t rgb2yuv[9] = {0};
@@ -303,7 +298,7 @@ static void check_input_planar_rgb_to_uv(void) · 29 unmodified lines
303 298
304 c = sws_internal(sws);299 c = sws_internal(sws);
305 for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {300 for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
306 for (isi = 0; isi < INPUT_SIZES; isi++ ) {301 for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) {
307 desc = av_pix_fmt_desc_get(planar_fmts[fmi]);302 desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
308 c->srcFormat = planar_fmts[fmi];303 c->srcFormat = planar_fmts[fmi];
309 c->dstFormat = AV_PIX_FMT_YUVA444P16;304 c->dstFormat = AV_PIX_FMT_YUVA444P16;
@@ -332,7 +327,6 @@ static void check_input_planar_rgb_to_uv(void) · 22 unmodified lines
332}327}
333 328
334#undef LARGEST_INPUT_SIZE329#undef LARGEST_INPUT_SIZE
335#undef INPUT_SIZES
336 330
337static void check_input_planar_rgb_to_a(void)331static void check_input_planar_rgb_to_a(void)
338{332{
@@ -342,7 +336,6 @@ static void check_input_planar_rgb_to_a(void) · 3 unmodified lines
342 int fmi, isi;336 int fmi, isi;
343 int dstW, byte_size;337 int dstW, byte_size;
344#define LARGEST_INPUT_SIZE 512338#define LARGEST_INPUT_SIZE 512
345#define INPUT_SIZES 6
346 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};339 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
347 const uint8_t *src[4];340 const uint8_t *src[4];
348 int32_t rgb2yuv[9] = {0};341 int32_t rgb2yuv[9] = {0};
@@ -375,7 +368,7 @@ static void check_input_planar_rgb_to_a(void) · 26 unmodified lines
375 368
376 c = sws_internal(sws);369 c = sws_internal(sws);
377 for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {370 for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) {
378 for (isi = 0; isi < INPUT_SIZES; isi++ ) {371 for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) {
379 desc = av_pix_fmt_desc_get(planar_fmts[fmi]);372 desc = av_pix_fmt_desc_get(planar_fmts[fmi]);
380 if (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA))373 if (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA))
381 continue;374 continue;
tests/checkasm/sw_range_convert.c+2−6
@@ -32,7 +32,6 @@ static void check_lumConvertRange(int from) · 31 unmodified lines
32{32{
33 const char *func_str = from ? "lumRangeFromJpeg" : "lumRangeToJpeg";33 const char *func_str = from ? "lumRangeFromJpeg" : "lumRangeToJpeg";
34#define LARGEST_INPUT_SIZE 51234#define LARGEST_INPUT_SIZE 512
35#define INPUT_SIZES 6
36 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};35 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
37 SwsContext *sws;36 SwsContext *sws;
38 SwsInternal *c;37 SwsInternal *c;
@@ -52,7 +51,7 @@ static void check_lumConvertRange(int from) · 13 unmodified lines
52 c->srcRange = from;51 c->srcRange = from;
53 c->dstRange = !from;52 c->dstRange = !from;
54 53
55 for (int dstWi = 0; dstWi < INPUT_SIZES; dstWi++) {54 for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) {
56 int width = input_sizes[dstWi];55 int width = input_sizes[dstWi];
57 for (int i = 0; i < width; i++) {56 for (int i = 0; i < width; i++) {
58 uint8_t r = rnd();57 uint8_t r = rnd();
@@ -72,13 +71,11 @@ static void check_lumConvertRange(int from) · 13 unmodified lines
72 sws_freeContext(sws);71 sws_freeContext(sws);
73}72}
74#undef LARGEST_INPUT_SIZE73#undef LARGEST_INPUT_SIZE
75#undef INPUT_SIZES
76 74
77static void check_chrConvertRange(int from)75static void check_chrConvertRange(int from)
78{76{
79 const char *func_str = from ? "chrRangeFromJpeg" : "chrRangeToJpeg";77 const char *func_str = from ? "chrRangeFromJpeg" : "chrRangeToJpeg";
80#define LARGEST_INPUT_SIZE 51278#define LARGEST_INPUT_SIZE 512
81#define INPUT_SIZES 6
82 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};79 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
83 SwsContext *sws;80 SwsContext *sws;
84 SwsInternal *c;81 SwsInternal *c;
@@ -100,7 +97,7 @@ static void check_chrConvertRange(int from) · 15 unmodified lines
100 c->srcRange = from;97 c->srcRange = from;
101 c->dstRange = !from;98 c->dstRange = !from;
102 99
103 for (int dstWi = 0; dstWi < INPUT_SIZES; dstWi++) {100 for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) {
104 int width = input_sizes[dstWi];101 int width = input_sizes[dstWi];
105 for (int i = 0; i < width; i++) {102 for (int i = 0; i < width; i++) {
106 uint8_t r = rnd();103 uint8_t r = rnd();
@@ -123,7 +120,6 @@ static void check_chrConvertRange(int from) · 16 unmodified lines
123 sws_freeContext(sws);120 sws_freeContext(sws);
124}121}
125#undef LARGEST_INPUT_SIZE122#undef LARGEST_INPUT_SIZE
126#undef INPUT_SIZES
127 123
128void checkasm_check_sw_range_convert(void)124void checkasm_check_sw_range_convert(void)
129{125{
tests/checkasm/sw_scale.c+4−7
@@ -105,7 +105,6 @@ static void check_yuv2yuv1(int accurate) · 104 unmodified lines
105 int dstW, offset;105 int dstW, offset;
106 size_t fail_offset;106 size_t fail_offset;
107 const int input_sizes[] = {8, 24, 128, 144, 256, 512};107 const int input_sizes[] = {8, 24, 128, 144, 256, 512};
108 const int INPUT_SIZES = sizeof(input_sizes)/sizeof(input_sizes[0]);
109 #define LARGEST_INPUT_SIZE 512108 #define LARGEST_INPUT_SIZE 512
110 109
111 const int offsets[] = {0, 3, 8, 11, 16, 19};110 const int offsets[] = {0, 3, 8, 11, 16, 19};
@@ -131,7 +130,7 @@ static void check_yuv2yuv1(int accurate) · 19 unmodified lines
131 fail();130 fail();
132 131
133 ff_sws_init_scale(c);132 ff_sws_init_scale(c);
134 for (isi = 0; isi < INPUT_SIZES; ++isi) {133 for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); ++isi) {
135 dstW = input_sizes[isi];134 dstW = input_sizes[isi];
136 for (osi = 0; osi < OFFSET_SIZES; osi++) {135 for (osi = 0; osi < OFFSET_SIZES; osi++) {
137 offset = offsets[osi];136 offset = offsets[osi];
@@ -171,7 +170,6 @@ static void check_yuv2yuvX(int accurate) · 33 unmodified lines
171 const int FILTER_SIZES = sizeof(filter_sizes)/sizeof(filter_sizes[0]);170 const int FILTER_SIZES = sizeof(filter_sizes)/sizeof(filter_sizes[0]);
172#define LARGEST_INPUT_SIZE 512171#define LARGEST_INPUT_SIZE 512
173 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};172 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
174 const int INPUT_SIZES = sizeof(input_sizes)/sizeof(input_sizes[0]);
175 const char *accurate_str = (accurate) ? "accurate" : "approximate";173 const char *accurate_str = (accurate) ? "accurate" : "approximate";
176 174
177 declare_func_emms(AV_CPU_FLAG_MMX, void, const int16_t *filter,175 declare_func_emms(AV_CPU_FLAG_MMX, void, const int16_t *filter,
@@ -199,7 +197,7 @@ static void check_yuv2yuvX(int accurate) · 21 unmodified lines
199 fail();197 fail();
200 198
201 ff_sws_init_scale(c);199 ff_sws_init_scale(c);
202 for(isi = 0; isi < INPUT_SIZES; ++isi){200 for(isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); ++isi){
203 dstW = input_sizes[isi];201 dstW = input_sizes[isi];
204 for(osi = 0; osi < 64; osi += 16){202 for(osi = 0; osi < 64; osi += 16){
205 if (dstW <= osi)203 if (dstW <= osi)
@@ -274,8 +272,7 @@ static void check_hscale(void) · 68 unmodified lines
274 };272 };
275 273
276#define LARGEST_INPUT_SIZE 512274#define LARGEST_INPUT_SIZE 512
277#define INPUT_SIZES 6275 static const int input_sizes[] = {8, 24, 128, 144, 256, 512};
278 static const int input_sizes[INPUT_SIZES] = {8, 24, 128, 144, 256, 512};
279 276
280 int i, j, fsi, hpi, width, dstWi;277 int i, j, fsi, hpi, width, dstWi;
281 SwsContext *sws;278 SwsContext *sws;
@@ -307,7 +304,7 @@ static void check_hscale(void) · 25 unmodified lines
307 304
308 for (hpi = 0; hpi < HSCALE_PAIRS; hpi++) {305 for (hpi = 0; hpi < HSCALE_PAIRS; hpi++) {
309 for (fsi = 0; fsi < FILTER_SIZES; fsi++) {306 for (fsi = 0; fsi < FILTER_SIZES; fsi++) {
310 for (dstWi = 0; dstWi < INPUT_SIZES; dstWi++) {307 for (dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) {
311 width = filter_sizes[fsi];308 width = filter_sizes[fsi];
312 309
313 c->srcBpc = hscale_pairs[hpi][0];310 c->srcBpc = hscale_pairs[hpi][0];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t