Optimize psnr calculation process