]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix support of odd heights in YUV conversion for video capture
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 14 Aug 2011 14:50:49 +0000 (14:50 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 14 Aug 2011 14:50:49 +0000 (14:50 +0000)
(prevents a memory corruption there)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11272 d7cf8633-e32d-0410-b094-e92efae38249

cap_avi.c
cap_ogg.c

index e7cf88d675f9cf363a5876d7c0b4f2fec8fcf8b5..e1b9e9a4e82c15bede4e556c99d627fb77bc24d9 100644 (file)
--- a/cap_avi.c
+++ b/cap_avi.c
@@ -352,7 +352,7 @@ static void SCR_CaptureVideo_ConvertFrame_BGRA_to_I420_flip(int width, int heigh
                        blockb = b[0];
                        *out = cls.capturevideo.yuvnormalizetable[0][cls.capturevideo.rgbtoyuvscaletable[0][0][blockr] + cls.capturevideo.rgbtoyuvscaletable[0][1][blockg] + cls.capturevideo.rgbtoyuvscaletable[0][2][blockb]];
                }
-               if ((y & 1) == 0)
+               if ((y & 1) == 0 && y/2 < h/2) // if h is odd, this skips the last row
                {
                        // 2x2 Cr and Cb planes
                        int inpitch = width*4;
index eef3f90d6e3503b5febb2172d58ca318915a6389..609947ca3d02a32fc6f23b7eff8daec98c18ef62 100644 (file)
--- a/cap_ogg.c
+++ b/cap_ogg.c
@@ -847,7 +847,7 @@ static void SCR_CaptureVideo_Ogg_ConvertFrame_BGRA_to_YUV(void)
                        b += 4;
                }
 
-               if((y & 1) == 0)
+               if ((y & 1) == 0 && y/2 < h/2) // if h is odd, this skips the last row
                {
                        for(b = cls.capturevideo.outbuffer + (h-2-y)*w*4, x = 0; x < w/2; ++x)
                        {