|
|
|
@ -53,7 +53,8 @@ uint64_t exp16_table[21]={ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 16.16 fixpoint log()
|
|
|
|
|
static int64_t log16(uint64_t a){ |
|
|
|
|
static int64_t log16(uint64_t a) |
|
|
|
|
{ |
|
|
|
|
int i; |
|
|
|
|
int out = 0; |
|
|
|
|
|
|
|
|
@ -63,7 +64,8 @@ static int64_t log16(uint64_t a){ |
|
|
|
|
|
|
|
|
|
for (i = 20; i >= 0; i--) { |
|
|
|
|
int64_t b = exp16_table[i]; |
|
|
|
|
if(a<(b<<16)) continue; |
|
|
|
|
if (a < (b << 16)) |
|
|
|
|
continue; |
|
|
|
|
out |= 1 << i; |
|
|
|
|
a = ((a / b) << 16) + (((a % b) << 16) + b / 2) / b; |
|
|
|
|
} |
|
|
|
@ -73,8 +75,8 @@ static int64_t log16(uint64_t a){ |
|
|
|
|
static uint64_t int_sqrt(uint64_t a) |
|
|
|
|
{ |
|
|
|
|
uint64_t ret = 0; |
|
|
|
|
int s; |
|
|
|
|
uint64_t ret_sq = 0; |
|
|
|
|
int s; |
|
|
|
|
|
|
|
|
|
for (s = 31; s >= 0; s--) { |
|
|
|
|
uint64_t b = ret_sq + (1ULL << (s * 2)) + (ret << s) * 2; |
|
|
|
@ -86,7 +88,8 @@ static uint64_t int_sqrt(uint64_t a) |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int main(int argc,char* argv[]){ |
|
|
|
|
int main(int argc, char *argv[]) |
|
|
|
|
{ |
|
|
|
|
int i, j; |
|
|
|
|
uint64_t sse = 0; |
|
|
|
|
uint64_t dev; |
|
|
|
@ -152,7 +155,8 @@ int main(int argc,char* argv[]){ |
|
|
|
|
} |
|
|
|
|
sse += (a - b) * (a - b); |
|
|
|
|
dist = abs(a - b); |
|
|
|
|
if (dist > maxdist) maxdist = dist; |
|
|
|
|
if (dist > maxdist) |
|
|
|
|
maxdist = dist; |
|
|
|
|
} |
|
|
|
|
size0 += s0; |
|
|
|
|
size1 += s1; |
|
|
|
@ -161,19 +165,18 @@ int main(int argc,char* argv[]){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
i = FFMIN(size0, size1) / len; |
|
|
|
|
if(!i) i=1; |
|
|
|
|
if (!i) |
|
|
|
|
i = 1; |
|
|
|
|
dev = int_sqrt(((sse / i) * F * F) + (((sse % i) * F * F) + i / 2) / i); |
|
|
|
|
if (sse) |
|
|
|
|
psnr= ((2*log16(max<<16) + log16(i) - log16(sse))*284619LL*F + (1LL<<31)) / (1LL<<32); |
|
|
|
|
psnr = ((2 * log16(max << 16) + log16(i) - log16(sse)) * |
|
|
|
|
284619LL * F + (1LL << 31)) / (1LL << 32); |
|
|
|
|
else |
|
|
|
|
psnr = 1000 * F - 1; // floating point free infinity :)
|
|
|
|
|
|
|
|
|
|
printf("stddev:%5d.%02d PSNR:%3d.%02d MAXDIFF:%5d bytes:%9d/%9d\n", |
|
|
|
|
(int)(dev / F), (int)(dev % F), |
|
|
|
|
(int)(psnr / F), (int)(psnr % F), |
|
|
|
|
maxdist, |
|
|
|
|
size0, size1); |
|
|
|
|
maxdist, size0, size1); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|