From 0ee1cc85ecc7601fa1d8634f8296d65efd05952d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Jun 2022 08:09:50 +0200 Subject: [PATCH] - 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. --- src/common/cutscenes/movieplayer.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/common/cutscenes/movieplayer.cpp b/src/common/cutscenes/movieplayer.cpp index 3d32d872c..f709defcd 100644 --- a/src/common/cutscenes/movieplayer.cpp +++ b/src/common/cutscenes/movieplayer.cpp @@ -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; }