From ca0d212d6434f25e048b20020239f3f90c5f4fe9 Mon Sep 17 00:00:00 2001 From: "yuzhuohuang@qq.com" Date: Fri, 5 Oct 2012 18:03:58 +0800 Subject: [PATCH] Fix corruption bug with 8x8 bilinear sub-pixel positioning option --- src/subtitles/Rasterizer.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/subtitles/Rasterizer.cpp b/src/subtitles/Rasterizer.cpp index fbbbee3..8c1051d 100644 --- a/src/subtitles/Rasterizer.cpp +++ b/src/subtitles/Rasterizer.cpp @@ -2479,7 +2479,8 @@ Overlay* Overlay::GetSubpixelVariance(unsigned int xshift, unsigned int yshift) { return NULL; } - overlay->mBody.reset(body, xy_free); + overlay->mBody.reset(body, xy_free); + memset(body, 0, overlay->mOverlayPitch*overlay->mOverlayHeight); BYTE* border = NULL; if (!overlay->mfWideOutlineEmpty) { @@ -2488,15 +2489,16 @@ Overlay* Overlay::GetSubpixelVariance(unsigned int xshift, unsigned int yshift) { return NULL; } - overlay->mBorder.reset(border, xy_free); + overlay->mBorder.reset(border, xy_free); + memset(border, 0, overlay->mOverlayPitch*overlay->mOverlayHeight); } - if(overlay->mOverlayPitch==mOverlayPitch && overlay->mOverlayHeight>=mOverlayHeight) + if( overlay->mOverlayPitch==mOverlayPitch && overlay->mOverlayWidth==mOverlayWidth && + overlay->mOverlayHeight>=mOverlayHeight ) { if (body && mBody) { - memcpy(body, mBody.get(), mOverlayPitch * mOverlayHeight); - memset(body+mOverlayPitch*mOverlayHeight, 0, mOverlayPitch * (overlay->mOverlayHeight-mOverlayHeight)); + memcpy(body, mBody.get(), mOverlayPitch * mOverlayHeight); } else if ( (!!body)!=(!!mBody)/*==NULL*/) { @@ -2505,8 +2507,7 @@ Overlay* Overlay::GetSubpixelVariance(unsigned int xshift, unsigned int yshift) if (border && mBorder) { - memcpy(border, mBorder.get(), mOverlayPitch * mOverlayHeight); - memset(border+mOverlayPitch*mOverlayHeight, 0, mOverlayPitch * (overlay->mOverlayHeight-mOverlayHeight)); + memcpy(border, mBorder.get(), mOverlayPitch * mOverlayHeight); } else if ( (!!border)!=(!!mBorder)/*==NULL*/ ) { @@ -2515,28 +2516,26 @@ Overlay* Overlay::GetSubpixelVariance(unsigned int xshift, unsigned int yshift) } else { - memset(body, 0, overlay->mOverlayPitch * overlay->mOverlayHeight); byte* dst = body; const byte* src = mBody.get(); for (int i=0;imOverlayPitch; src += mOverlayPitch; } if (!overlay->mfWideOutlineEmpty) { ASSERT(border && mBorder); - memset(border, 0, overlay->mOverlayPitch * overlay->mOverlayHeight); dst = border; src = mBorder.get(); for (int i=0;imOverlayPitch; src += mOverlayPitch; } - } + } } //not equal // Bilinear(overlay->mpOverlayBuffer.base, overlay->mOverlayWidth, 2*overlay->mOverlayHeight, overlay->mOverlayPitch, xshift, yshift); -- 2.11.4.GIT