From 2667ad46dc38b54dde62ee1ab7844502531eb96a Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 14 Aug 2011 14:50:49 +0000 Subject: [PATCH] fix support of odd heights in YUV conversion for video capture (prevents a memory corruption there) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11272 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=17f11d9577883fb59f2175b92d88d0d3323ad025 --- cap_avi.c | 2 +- cap_ogg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cap_avi.c b/cap_avi.c index e7cf88d6..e1b9e9a4 100644 --- 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; diff --git a/cap_ogg.c b/cap_ogg.c index eef3f90d..609947ca 100644 --- 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) { -- 2.39.2