| 2994 | } |
| 2995 | |
| 2996 | int32_t WritePadding (sWelsEncCtx* pCtx, int32_t iLen, int32_t& iSize) { |
| 2997 | int32_t i = 0; |
| 2998 | int32_t iNal = 0; |
| 2999 | SBitStringAux* pBs = NULL; |
| 3000 | int32_t iNalLen; |
| 3001 | |
| 3002 | iSize = 0; |
| 3003 | iNal = pCtx->pOut->iNalIndex; |
| 3004 | pBs = &pCtx->pOut->sBsWrite; // SBitStringAux instance for non VCL NALs decoding |
| 3005 | |
| 3006 | if ((pBs->pEndBuf - pBs->pCurBuf) < iLen || iNal >= pCtx->pOut->iCountNals) { |
| 3007 | #if GOM_TRACE_FLAG |
| 3008 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, |
| 3009 | "[RC] paddingcal pBuffer overflow, bufferlen=%lld, paddinglen=%d, iNalIdx= %d, iCountNals= %d", |
| 3010 | static_cast<long long int> (pBs->pEndBuf - pBs->pCurBuf), iLen, iNal, pCtx->pOut->iCountNals); |
| 3011 | #endif |
| 3012 | return ENC_RETURN_MEMOVERFLOWFOUND; |
| 3013 | } |
| 3014 | |
| 3015 | WelsLoadNal (pCtx->pOut, NAL_UNIT_FILLER_DATA, NRI_PRI_LOWEST); |
| 3016 | |
| 3017 | for (i = 0; i < iLen; i++) { |
| 3018 | BsWriteBits (pBs, 8, 0xff); |
| 3019 | } |
| 3020 | |
| 3021 | BsRbspTrailingBits (pBs); |
| 3022 | |
| 3023 | WelsUnloadNal (pCtx->pOut); |
| 3024 | int32_t iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[iNal], NULL, |
| 3025 | pCtx->iFrameBsSize - pCtx->iPosBsBuffer, |
| 3026 | pCtx->pFrameBs + pCtx->iPosBsBuffer, |
| 3027 | &iNalLen); |
| 3028 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 3029 | |
| 3030 | pCtx->iPosBsBuffer += iNalLen; |
| 3031 | iSize += iNalLen; |
| 3032 | |
| 3033 | return ENC_RETURN_SUCCESS; |
| 3034 | } |
| 3035 | |
| 3036 | /* |
| 3037 | * Force coding IDR as follows |
no test coverage detected