Skip to content

Commit

Permalink
Merge pull request webmproject#53 from webmproject/psnr
Browse files Browse the repository at this point in the history
make GetPSNR() be the same on ARM and x86
  • Loading branch information
skal65535 authored Mar 21, 2018
2 parents 494a85d + dea51ad commit 78148b2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/dichotomy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,11 @@ float Encoder::ComputeSize(const DCTCoeffs* coeffs) {

////////////////////////////////////////////////////////////////////////////////

static double GetPSNR(uint64_t err, uint64_t size) {
return (err > 0 && size > 0) ? 10. * log10(255. * 255. * size / err) : 99.;
static float GetPSNR(uint64_t err, uint64_t size) {
// This expression is written such that it gives the same result on ARM
// and x86 (for large values of err/size in particular). Don't change it!
return (err > 0 && size > 0) ? -4.3429448f * log(size / (err / 255. / 255.))
: 99.f;
}

float Encoder::ComputePSNR() const {
Expand Down

0 comments on commit 78148b2

Please sign in to comment.