For the first encoded frame, is bEncCurFrmAsIdrFlag true while bIdrPeriodFlag is false. Previously, the scene detection code unnecessarily checked for a scene change in the first encoded frame (where the reference frame was an uninitialized frame), triggering valgrind warnings about using uninitialized memory.
Showing the changes to codec/encoder/core/src/wels_preprocess.cpp (1 of 1 file). Show all
Unified · Split
| @@ -410,6 +410,7 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (void* pCtx, const SSourcePicture · 409 unmodified lines | ||
| 410 | 410 | DownsamplePadding (pSrcPic, pDstPic, iSrcWidth, iSrcHeight, iShrinkWidth, iShrinkHeight, iTargetWidth, iTargetHeight); |
| 411 | 411 | |
| 412 | 412 | if (pSvcParam->bEnableSceneChangeDetect && !pEncCtx->pVaa->bIdrPeriodFlag |
| 413 | + && !pEncCtx->bEncCurFrmAsIdrFlag | |
| 413 | 414 | && ! (pEncCtx->iCodingIndex & (pSvcParam->uiGopSize - 1))) { |
| 414 | 415 | SPicture* pRefPic = pEncCtx->pLtr[iDependencyId].bReceivedT0LostFlag ? |
| 415 | 416 | pEncCtx->pSpatialPic[iDependencyId][pEncCtx->uiSpatialLayersInTemporal[iDependencyId] + |
| @@ -510,7 +511,7 @@ int32_t CWelsPreProcess::MultiLayerPreprocess (void* pCtx, const SSourcePicture* · 94 unmodified lines | ||
| 510 | 511 | } while (i < kiSpatialNum); |
| 511 | 512 | |
| 512 | 513 | if (pSvcParam->bEnableSceneChangeDetect && (kiSpatialNum == pSvcParam->iNumDependencyLayer) |
| 513 | − && !pEncCtx->pVaa->bIdrPeriodFlag) { | |
| 514 | + && !pEncCtx->pVaa->bIdrPeriodFlag && !pEncCtx->bEncCurFrmAsIdrFlag) { | |
| 514 | 515 | SPicture* pRef = pEncCtx->pLtr[0].bReceivedT0LostFlag ? |
| 515 | 516 | pEncCtx->pSpatialPic[0][pEncCtx->uiSpatialLayersInTemporal[0] + pEncCtx->pVaa->uiValidLongTermPicIdx] : |
| 516 | 517 | m_pLastSpatialPicture[0][0]; |