Skip to content

Commit e647f73

Browse files
author
Isaac
committed
feat: gate padding recon override on bSubcodecMode with hardcoded 1-MB border
1 parent 9871479 commit e647f73

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

third-party/openh264/third_party/openh264/src/codec/encoder/core/src/svc_encode_slice.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,33 @@ int32_t WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encodin
564564
if (ENC_RETURN_SUCCESS != iEncReturn)
565565
return iEncReturn;
566566

567+
// [subcodec] For padding MBs, overwrite reconstruction buffer with exact black.
568+
// This ensures content MBs' I_16x16 predictions are computed against exact-black
569+
// neighbors, making their coefficients transplantable to the composite frame.
570+
{
571+
if (pEncCtx->pSvcParam->bSubcodecMode) {
572+
const int32_t kiMbX = iCurMbIdx % pCurLayer->iMbWidth;
573+
const int32_t kiMbY = iCurMbIdx / pCurLayer->iMbWidth;
574+
if (kiMbX < 1 || kiMbX >= pCurLayer->iMbWidth - 1 ||
575+
kiMbY < 1 || kiMbY >= pCurLayer->iMbHeight - 1) {
576+
// Overwrite luma reconstruction to black (Y=0)
577+
uint8_t* pCsY = pMbCache->SPicData.pCsMb[0];
578+
const int32_t kiCsStrideY = pCurLayer->iCsStride[0];
579+
for (int32_t r = 0; r < MB_WIDTH_LUMA; r++) {
580+
memset(pCsY + r * kiCsStrideY, 0, MB_WIDTH_LUMA);
581+
}
582+
// Overwrite chroma reconstruction to neutral (Cb=128, Cr=128)
583+
uint8_t* pCsCb = pMbCache->SPicData.pCsMb[1];
584+
uint8_t* pCsCr = pMbCache->SPicData.pCsMb[2];
585+
const int32_t kiCsStrideUV = pCurLayer->iCsStride[1];
586+
for (int32_t r = 0; r < MB_WIDTH_CHROMA; r++) {
587+
memset(pCsCb + r * kiCsStrideUV, 128, MB_WIDTH_CHROMA);
588+
memset(pCsCr + r * kiCsStrideUV, 128, MB_WIDTH_CHROMA);
589+
}
590+
}
591+
}
592+
}
593+
567594
pCurMb->uiSliceIdc = kiSliceIdx;
568595

569596
#if defined(MB_TYPES_CHECK)

0 commit comments

Comments
 (0)