| 472 | } |
| 473 | |
| 474 | void imageMakeDist(bx::AllocatorI* _allocator, void* _dst, uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src) |
| 475 | { |
| 476 | const uint32_t numPixels = _width*_height; |
| 477 | |
| 478 | double* imgIn = (double*)bx::alloc(_allocator, numPixels*sizeof(double) ); |
| 479 | double* outside = (double*)bx::alloc(_allocator, numPixels*sizeof(double) ); |
| 480 | double* inside = (double*)bx::alloc(_allocator, numPixels*sizeof(double) ); |
| 481 | |
| 482 | for (uint32_t yy = 0; yy < _height; ++yy) |
| 483 | { |
| 484 | const uint8_t* src = (const uint8_t*)_src + yy*_srcPitch; |
| 485 | double* dst = &imgIn[yy*_width]; |
| 486 | for (uint32_t xx = 0; xx < _width; ++xx) |
| 487 | { |
| 488 | dst[xx] = double(src[xx])/255.0; |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | edtaa3(_allocator, outside, _width, _height, imgIn); |
| 493 | |
| 494 | for (uint32_t ii = 0; ii < numPixels; ++ii) |
| 495 | { |
| 496 | imgIn[ii] = 1.0 - imgIn[ii]; |
| 497 | } |
| 498 | |
| 499 | edtaa3(_allocator, inside, _width, _height, imgIn); |
| 500 | |
| 501 | bx::free(_allocator, imgIn); |
| 502 | |
| 503 | uint8_t* dst = (uint8_t*)_dst; |
| 504 | |
| 505 | for (uint32_t ii = 0; ii < numPixels; ++ii) |
| 506 | { |
| 507 | double dist = bx::clamp( (outside[ii] - inside[ii]) * 1.0/16.0 + 0.5, 0.0, 1.0); |
| 508 | dst[ii] = 255-uint8_t(dist * 255.0); |
| 509 | } |
| 510 | |
| 511 | bx::free(_allocator, inside); |
| 512 | bx::free(_allocator, outside); |
| 513 | } |
| 514 | |
| 515 | static const iqa_ssim_args s_iqaArgs = |
| 516 | { |