- fixed: The IVF decoder never accounted for odd dimensions when applying the UV subsampling.

To simplify the code the 'optimized' loop was replaced with one iterating over all pixels - even in the worst of cases the little savings are hardly performance relevant.
This commit is contained in:
Christoph Oelckers 2022-06-05 08:09:50 +02:00
parent 6f22eeac00
commit 0ee1cc85ec

View file

@ -255,6 +255,7 @@ public:
failed = true;
}
// The decoder needs a buffer with even height
Pic.Resize(width * height * 4);
@ -382,23 +383,17 @@ public:
const int ustride = img->stride[VPX_PLANE_U];
const int vstride = img->stride[VPX_PLANE_V];
for (unsigned int y = 0; y < height; y += 2)
for (unsigned int y = 0; y < height; y++)
{
unsigned int y1 = y + 1;
unsigned int wy = width * y;
unsigned int wy1 = width * y1;
for (unsigned int x = 0; x < width; x += 2)
for (unsigned int x = 0; x < width; x++)
{
uint8_t u = uplane[ustride * (y >> 1) + (x >> 1)];
uint8_t v = vplane[vstride * (y >> 1) + (x >> 1)];
SetPixel(&Pic[(wy + x) << 2], yplane[ystride * y + x], u, v);
SetPixel(&Pic[(wy + x + 1) << 2], yplane[ystride * y + x + 1], u, v);
SetPixel(&Pic[(wy1 + x) << 2], yplane[ystride * y1 + x], u, v);
SetPixel(&Pic[(wy1 + x + 1) << 2], yplane[ystride * y1 + x + 1], u, v);
SetPixel(&Pic[(x + y * width) << 2], yplane[ystride * y + x], u, v);
}
}
return true;
}