mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-28 03:34:06 +00:00
Fix PSNR calculation, broken after the introduction of frame padding
This commit is contained in:
parent
c6baa8ad62
commit
3c75500cd4
|
@ -110,14 +110,27 @@ static void compute_psnr(const kvz_picture *const src,
|
||||||
double sse[3] = { 0.0 };
|
double sse[3] = { 0.0 };
|
||||||
|
|
||||||
for (int32_t c = 0; c < colors; ++c) {
|
for (int32_t c = 0; c < colors; ++c) {
|
||||||
|
|
||||||
|
kvz_pixel* src_ptr = src->data[c];
|
||||||
|
kvz_pixel* rec_ptr = rec->data[c];
|
||||||
|
int32_t width = src->width;
|
||||||
|
int32_t height = src->height;
|
||||||
|
int32_t stride = src->stride;
|
||||||
int32_t num_pixels = pixels;
|
int32_t num_pixels = pixels;
|
||||||
if (c != COLOR_Y) {
|
if (c != COLOR_Y) {
|
||||||
|
width >>= 1;
|
||||||
|
height >>= 1;
|
||||||
|
stride >>= 1;
|
||||||
num_pixels >>= 2;
|
num_pixels >>= 2;
|
||||||
}
|
}
|
||||||
for (int32_t i = 0; i < num_pixels; ++i) {
|
for (int32_t y = 0; y < height; ++y) {
|
||||||
const int32_t error = src->data[c][i] - rec->data[c][i];
|
for (int32_t x = 0; x < width; ++x) {
|
||||||
|
const int32_t error = src_ptr[x] - rec_ptr[x];
|
||||||
sse[c] += error * error;
|
sse[c] += error * error;
|
||||||
}
|
}
|
||||||
|
src_ptr += stride;
|
||||||
|
rec_ptr += stride;
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid division by zero
|
// Avoid division by zero
|
||||||
if (sse[c] == 0.0) {
|
if (sse[c] == 0.0) {
|
||||||
|
|
Loading…
Reference in a new issue