MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / main

Function main

Utils/astc_test_autoextract.cpp:59–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59int main(int argc, char **argv)
60{
61
62 // Parse command line
63 if (argc < 6)
64 {
65 printf("Usage: astc_test_extract <blocksize> <ref> <good> <bad> <out>\n");
66 return 1;
67 }
68
69 int blockdim_x, blockdim_y;
70 if (sscanf(argv[1], "%dx%d", &blockdim_x, &blockdim_y) < 2)
71 {
72 printf("blocksize must be of form WxH; e.g. 8x4\n");
73 return 1;
74 }
75
76 // Load the original reference image
77 int ref_dim_x, ref_dim_y, ref_ncomp;
78 uint8_t* data_ref = (uint8_t*)stbi_load(argv[2], &ref_dim_x, &ref_dim_y, &ref_ncomp, 4);
79 if (!data_ref)
80 {
81 printf("Failed to load reference image.\n");
82 return 1;
83 }
84
85 // Load the good test image
86 int good_dim_x, good_dim_y, good_ncomp;
87 uint8_t* data_good = (uint8_t*)stbi_load(argv[3], &good_dim_x, &good_dim_y, &good_ncomp, 4);
88 if (!data_good)
89 {
90 printf("Failed to load good test image.\n");
91 return 1;
92 }
93
94 // Load the bad test image
95 int bad_dim_x, bad_dim_y, bad_ncomp;
96 uint8_t* data_bad = (uint8_t*)stbi_load(argv[4], &bad_dim_x, &bad_dim_y, &bad_ncomp, 4);
97 if (!data_bad)
98 {
99 printf("Failed to load bad test image.\n");
100 return 1;
101 }
102
103 if (ref_dim_x != good_dim_x || ref_dim_x != bad_dim_x ||
104 ref_dim_y != good_dim_y || ref_dim_y != bad_dim_y)
105 {
106 printf("Failed as images are different resolutions.\n");
107 return 1;
108 }
109
110
111 int x_blocks = (ref_dim_x + blockdim_x - 1) / blockdim_x;
112 int y_blocks = (ref_dim_y + blockdim_y - 1) / blockdim_y;
113
114 int *errorsums = (int*)malloc(x_blocks * y_blocks * 4);
115 for (int i = 0; i < x_blocks * y_blocks; i++)
116 {

Callers

nothing calls this directly

Calls 4

stbi_loadFunction · 0.85
stbi_write_pngFunction · 0.85
stbi_image_freeFunction · 0.85
pixFunction · 0.70

Tested by

no test coverage detected