From ba58c96c1cf005a337a7300fb035a3a2d5c15f46 Mon Sep 17 00:00:00 2001 From: cantabile Date: Mon, 18 Jan 2016 17:28:00 +0200 Subject: [PATCH] Initialise some variables Found with valgrind's uninitialised memory detector. --- src/MVAnalyse.cpp | 10 +++++----- src/MVRecalculate.cpp | 10 +++++----- src/MVSuper.cpp | 12 ++++++------ src/PlaneOfBlocks.cpp | 25 ++++++++++++++++--------- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/MVAnalyse.cpp b/src/MVAnalyse.cpp index 7b68ed6..7096778 100644 --- a/src/MVAnalyse.cpp +++ b/src/MVAnalyse.cpp @@ -124,11 +124,11 @@ static const VSFrameRef *VS_CC mvanalyseGetFrame(int n, int activationReason, vo GroupOfPlanes *vectorFields = new GroupOfPlanes(d->analysisData.nBlkSizeX, d->analysisData.nBlkSizeY, d->analysisData.nLvCount, d->analysisData.nPel, d->analysisData.nMotionFlags, d->analysisData.nCPUFlags, d->analysisData.nOverlapX, d->analysisData.nOverlapY, d->analysisData.nBlkX, d->analysisData.nBlkY, d->analysisData.xRatioUV, d->analysisData.yRatioUV, d->divideExtra, d->supervi->format->bitsPerSample); - const uint8_t *pSrc[3]; - const uint8_t *pRef[3]; - uint8_t *pDst; - int nSrcPitch[3]; - int nRefPitch[3]; + const uint8_t *pSrc[3] = { nullptr }; + const uint8_t *pRef[3] = { nullptr }; + uint8_t *pDst = { nullptr }; + int nSrcPitch[3] = { 0 }; + int nRefPitch[3] = { 0 }; int nref; diff --git a/src/MVRecalculate.cpp b/src/MVRecalculate.cpp index c6c81c5..e879568 100644 --- a/src/MVRecalculate.cpp +++ b/src/MVRecalculate.cpp @@ -103,11 +103,11 @@ static const VSFrameRef *VS_CC mvrecalculateGetFrame(int n, int activationReason GroupOfPlanes *vectorFields = new GroupOfPlanes(d->analysisData.nBlkSizeX, d->analysisData.nBlkSizeY, d->analysisData.nLvCount, d->analysisData.nPel, d->analysisData.nMotionFlags, d->analysisData.nCPUFlags, d->analysisData.nOverlapX, d->analysisData.nOverlapY, d->analysisData.nBlkX, d->analysisData.nBlkY, d->analysisData.xRatioUV, d->analysisData.yRatioUV, d->divideExtra, d->supervi->format->bitsPerSample); - const uint8_t *pSrc[3]; - const uint8_t *pRef[3]; - uint8_t *pDst; - int nSrcPitch[3]; - int nRefPitch[3]; + const uint8_t *pSrc[3] = { nullptr }; + const uint8_t *pRef[3] = { nullptr }; + uint8_t *pDst = { nullptr }; + int nSrcPitch[3] = { 0 }; + int nRefPitch[3] = { 0 }; int offset = ( d->analysisData.isBackward ) ? d->analysisData.nDeltaFrame : -d->analysisData.nDeltaFrame; int nref = n + offset; diff --git a/src/MVSuper.cpp b/src/MVSuper.cpp index 5ec12d8..37a3d7f 100644 --- a/src/MVSuper.cpp +++ b/src/MVSuper.cpp @@ -55,12 +55,12 @@ static const VSFrameRef *VS_CC mvsuperGetFrame(int n, int activationReason, void } else if (activationReason == arAllFramesReady) { const VSFrameRef *src = vsapi->getFrameFilter(n, d->node, frameCtx); - const uint8_t *pSrc[3]; - uint8_t *pDst[3]; - const uint8_t *pSrcPel[3]; - int nSrcPitch[3]; - int nDstPitch[3]; - int nSrcPelPitch[3]; + const uint8_t *pSrc[3] = { nullptr }; + uint8_t *pDst[3] = { nullptr }; + const uint8_t *pSrcPel[3] = { nullptr }; + int nSrcPitch[3] = { 0 }; + int nDstPitch[3] = { 0 }; + int nSrcPelPitch[3] = { 0 }; const VSFrameRef *srcPel = NULL; if (d->usePelClip) diff --git a/src/PlaneOfBlocks.cpp b/src/PlaneOfBlocks.cpp index 903681c..34089a2 100644 --- a/src/PlaneOfBlocks.cpp +++ b/src/PlaneOfBlocks.cpp @@ -517,8 +517,10 @@ void PlaneOfBlocks::SearchMVs(MVFrame *_pSrcFrame, MVFrame *_pRefFrame, if ( iblkx < nBlkX-1 ) { x[0] += (nBlkSizeX - nOverlapX) * blkScanDir; - x[1] += ((nBlkSizeX - nOverlapX) >> nLogxRatioUV) * blkScanDir; - x[2] += ((nBlkSizeX - nOverlapX) >> nLogxRatioUV) * blkScanDir; + if (pSrcFrame->GetMode() & UPLANE) + x[1] += ((nBlkSizeX - nOverlapX) >> nLogxRatioUV) * blkScanDir; + if (pSrcFrame->GetMode() & VPLANE) + x[2] += ((nBlkSizeX - nOverlapX) >> nLogxRatioUV) * blkScanDir; } } pBlkData += nBlkX*N_PER_BLOCK; @@ -526,8 +528,10 @@ void PlaneOfBlocks::SearchMVs(MVFrame *_pSrcFrame, MVFrame *_pRefFrame, outfilebuf += nBlkX*4;// 4 short word per block y[0] += (nBlkSizeY - nOverlapY); - y[1] += ((nBlkSizeY - nOverlapY) >> nLogyRatioUV ); - y[2] += ((nBlkSizeY - nOverlapY) >> nLogyRatioUV ); + if (pSrcFrame->GetMode() & UPLANE) + y[1] += ((nBlkSizeY - nOverlapY) >> nLogyRatioUV ); + if (pSrcFrame->GetMode() & VPLANE) + y[2] += ((nBlkSizeY - nOverlapY) >> nLogyRatioUV ); } if (smallestPlane) *pmeanLumaChange = sumLumaChange/nBlkCount; // for all finer planes @@ -752,7 +756,6 @@ void PlaneOfBlocks::RecalculateMVs(MVClipBalls & mvClip, MVFrame *_pSrcFrame, MV bestMV.sad = sad; nMinCost = sad; - if (bestMV.sad > thSAD)// if old interpolated vector is bad { // then, we refine, according to the search type @@ -831,8 +834,10 @@ void PlaneOfBlocks::RecalculateMVs(MVClipBalls & mvClip, MVFrame *_pSrcFrame, MV if ( iblkx < nBlkX-1 ) { x[0] += (nBlkSizeX - nOverlapX) * blkScanDir; - x[1] += ((nBlkSizeX - nOverlapX) >> nLogxRatioUV) * blkScanDir; - x[2] += ((nBlkSizeX - nOverlapX) >> nLogxRatioUV) * blkScanDir; + if (pSrcFrame->GetMode() & UPLANE) + x[1] += ((nBlkSizeX - nOverlapX) >> nLogxRatioUV) * blkScanDir; + if (pSrcFrame->GetMode() & VPLANE) + x[2] += ((nBlkSizeX - nOverlapX) >> nLogxRatioUV) * blkScanDir; } } pBlkData += nBlkX*N_PER_BLOCK; @@ -840,8 +845,10 @@ void PlaneOfBlocks::RecalculateMVs(MVClipBalls & mvClip, MVFrame *_pSrcFrame, MV outfilebuf += nBlkX*4;// 4 short word per block y[0] += (nBlkSizeY - nOverlapY); - y[1] += ((nBlkSizeY - nOverlapY) >> nLogyRatioUV ); - y[2] += ((nBlkSizeY - nOverlapY) >> nLogyRatioUV ); + if (pSrcFrame->GetMode() & UPLANE) + y[1] += ((nBlkSizeY - nOverlapY) >> nLogyRatioUV ); + if (pSrcFrame->GetMode() & VPLANE) + y[2] += ((nBlkSizeY - nOverlapY) >> nLogyRatioUV ); } }