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

Function compute_error_metrics

Source/astcenccli_error_metrics.cpp:110–413  ·  view source on GitHub ↗

See header for documentation */

Source from the content-addressed store, hash-verified

108
109/* See header for documentation */
110void compute_error_metrics(
111 bool compute_hdr_metrics,
112 bool compute_normal_metrics,
113 int input_components,
114 const astcenc_image* img1,
115 const astcenc_image* img2,
116 int fstop_lo,
117 int fstop_hi
118) {
119 static const int componentmasks[5] { 0x00, 0x07, 0x0C, 0x07, 0x0F };
120 int componentmask = componentmasks[input_components];
121
122 error_accum4 errorsum;
123 error_accum4 alpha_scaled_errorsum;
124 error_accum4 log_errorsum;
125 error_accum4 mpsnr_errorsum;
126 double mean_angular_errorsum = 0.0;
127 double worst_angular_errorsum = 0.0;
128
129 unsigned int dim_x = astc::min(img1->dim_x, img2->dim_x);
130 unsigned int dim_y = astc::min(img1->dim_y, img2->dim_y);
131 unsigned int dim_z = astc::min(img1->dim_z, img2->dim_z);
132
133 if (img1->dim_x != img2->dim_x ||
134 img1->dim_y != img2->dim_y ||
135 img1->dim_z != img2->dim_z)
136 {
137 printf("WARNING: Only intersection of images will be compared:\n"
138 " Image 1: %ux%ux%u\n"
139 " Image 2: %ux%ux%u\n",
140 img1->dim_x, img1->dim_y, img1->dim_z,
141 img2->dim_x, img2->dim_y, img2->dim_z);
142 }
143
144 double rgb_peak = 0.0;
145 unsigned int xsize1 = img1->dim_x;
146 unsigned int xsize2 = img2->dim_x;
147
148 for (unsigned int z = 0; z < dim_z; z++)
149 {
150 for (unsigned int y = 0; y < dim_y; y++)
151 {
152 for (unsigned int x = 0; x < dim_x; x++)
153 {
154 vfloat4 color1;
155 vfloat4 color2;
156
157 if (img1->data_type == ASTCENC_TYPE_U8)
158 {
159 uint8_t* data8 = static_cast<uint8_t*>(img1->data[z]);
160
161 color1 = vfloat4(
162 data8[(4 * xsize1 * y) + (4 * x )],
163 data8[(4 * xsize1 * y) + (4 * x + 1)],
164 data8[(4 * xsize1 * y) + (4 * x + 2)],
165 data8[(4 * xsize1 * y) + (4 * x + 3)]);
166
167 color1 = color1 / 255.0f;

Callers 1

astcenc_mainFunction · 0.85

Calls 12

log2Function · 0.85
mpsnr_sumdiffFunction · 0.85
normalize_safeFunction · 0.85
unit3Function · 0.85
minFunction · 0.70
vfloat4Class · 0.70
vint4Class · 0.70
float16_to_floatFunction · 0.70
clampFunction · 0.70
maxFunction · 0.70
dot3Function · 0.70
sqrtFunction · 0.70

Tested by

no test coverage detected