Commit 7a00653b authored by Thomas Lee's avatar Thomas Lee Committed by Luca Barbato

tiny_psnr: Support large files

If an input file is bigger than 2GB (assume sizeof(int) == 4)),
size0/size1 will overflow, making stddev and PSNR invalid.
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent 99214d42
...@@ -117,7 +117,7 @@ static double get_f64l(uint8_t *p) ...@@ -117,7 +117,7 @@ static double get_f64l(uint8_t *p)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int i, j; uint64_t i, j;
uint64_t sse = 0; uint64_t sse = 0;
double sse_d = 0.0; double sse_d = 0.0;
FILE *f[2]; FILE *f[2];
...@@ -126,8 +126,8 @@ int main(int argc, char *argv[]) ...@@ -126,8 +126,8 @@ int main(int argc, char *argv[])
int64_t max; int64_t max;
int shift = argc < 5 ? 0 : atoi(argv[4]); int shift = argc < 5 ? 0 : atoi(argv[4]);
int skip_bytes = argc < 6 ? 0 : atoi(argv[5]); int skip_bytes = argc < 6 ? 0 : atoi(argv[5]);
int size0 = 0; uint64_t size0 = 0;
int size1 = 0; uint64_t size1 = 0;
uint64_t maxdist = 0; uint64_t maxdist = 0;
double maxdist_d = 0.0; double maxdist_d = 0.0;
...@@ -251,7 +251,7 @@ int main(int argc, char *argv[]) ...@@ -251,7 +251,7 @@ int main(int argc, char *argv[])
else else
psnr = 1000 * F - 1; // floating point free infinity :) psnr = 1000 * F - 1; // floating point free infinity :)
printf("stddev:%5d.%02d PSNR:%3d.%02d MAXDIFF:%5"PRIu64" bytes:%9d/%9d\n", printf("stddev:%5d.%02d PSNR:%3d.%02d MAXDIFF:%5"PRIu64" bytes:%9"PRIu64"/%9"PRIu64"\n",
(int)(dev / F), (int)(dev % F), (int)(dev / F), (int)(dev % F),
(int)(psnr / F), (int)(psnr % F), (int)(psnr / F), (int)(psnr % F),
maxdist, size0, size1); maxdist, size0, size1);
...@@ -271,7 +271,7 @@ int main(int argc, char *argv[]) ...@@ -271,7 +271,7 @@ int main(int argc, char *argv[])
maxdist = maxdist_d * scale; maxdist = maxdist_d * scale;
printf("stddev:%10.2f PSNR:%s MAXDIFF:%10"PRIu64" bytes:%9d/%9d\n", printf("stddev:%10.2f PSNR:%s MAXDIFF:%10"PRIu64" bytes:%9"PRIu64"/%9"PRIu64"\n",
dev * scale, psnr_str, maxdist, size0, size1); dev * scale, psnr_str, maxdist, size0, size1);
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment