MCPcopy Create free account
hub / github.com/cisco/openh264 / WelsCodeOnePicPartition

Function WelsCodeOnePicPartition

codec/encoder/core/src/encoder_ext.cpp:4534–4633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4532}
4533
4534int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx,
4535 SFrameBSInfo* pFrameBSInfo,
4536 SLayerBSInfo* pLayerBsInfo,
4537 int32_t* pNalIdxInLayer,
4538 int32_t* pLayerSize,
4539 int32_t iFirstMbIdxInPartition,
4540 int32_t iEndMbIdxInPartition,
4541 int32_t iStartSliceIdx
4542 ) {
4543
4544 SDqLayer* pCurLayer = pCtx->pCurDqLayer;
4545 uint32_t uSlcBuffIdx = 0;
4546 SSlice* pStartSlice = &pCurLayer->sSliceBufferInfo[uSlcBuffIdx].pSliceBuffer[iStartSliceIdx];
4547 int32_t iNalIdxInLayer = *pNalIdxInLayer;
4548 int32_t iSliceIdx = iStartSliceIdx;
4549 const int32_t kiSliceStep = pCtx->iActiveThreadsNum;
4550 const int32_t kiPartitionId = iStartSliceIdx % kiSliceStep;
4551 int32_t iPartitionBsSize = 0;
4552 int32_t iAnyMbLeftInPartition = iEndMbIdxInPartition - iFirstMbIdxInPartition + 1;
4553 const EWelsNalUnitType keNalType = pCtx->eNalType;
4554 const EWelsNalRefIdc keNalRefIdc = pCtx->eNalPriority;
4555 const bool kbNeedPrefix = pCtx->bNeedPrefixNalFlag;
4556 const int32_t kiSliceIdxStep = pCtx->iActiveThreadsNum;
4557 int32_t iReturn = ENC_RETURN_SUCCESS;
4558
4559 pStartSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = iFirstMbIdxInPartition;
4560
4561 while (iAnyMbLeftInPartition > 0) {
4562 int32_t iSliceSize = 0;
4563 int32_t iPayloadSize = 0;
4564 SSlice* pCurSlice = NULL;
4565
4566 if (iSliceIdx >= (pCurLayer->sSliceBufferInfo[uSlcBuffIdx].iMaxSliceNum -
4567 kiSliceIdxStep)) { // insufficient memory in pSliceInLayer[]
4568 if (pCtx->iActiveThreadsNum == 1) {
4569 //only single thread support re-alloc now
4570 if (DynSliceRealloc (pCtx, pFrameBSInfo, pLayerBsInfo)) {
4571 WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
4572 "CWelsH264SVCEncoder::WelsCodeOnePicPartition: DynSliceRealloc not successful");
4573 return ENC_RETURN_MEMALLOCERR;
4574 }
4575 } else if (iSliceIdx >= pCurLayer->iMaxSliceNum) {
4576 WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
4577 "CWelsH264SVCEncoder::WelsCodeOnePicPartition: iSliceIdx(%d) over iMaxSliceNum(%d)", iSliceIdx,
4578 pCurLayer->iMaxSliceNum);
4579 return ENC_RETURN_MEMALLOCERR;
4580 }
4581 }
4582
4583 if (kbNeedPrefix) {
4584 iReturn = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, keNalType, keNalRefIdc,
4585 iPayloadSize);
4586 WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
4587 iPartitionBsSize += iPayloadSize;
4588 }
4589
4590 WelsLoadNal (pCtx->pOut, keNalType, keNalRefIdc);
4591 pCurSlice = &pCtx->pCurDqLayer->sSliceBufferInfo[uSlcBuffIdx].pSliceBuffer[iSliceIdx];

Callers 1

WelsEncoderEncodeExtFunction · 0.85

Calls 7

DynSliceReallocFunction · 0.85
WelsLogFunction · 0.85
AddPrefixNalFunction · 0.85
WelsLoadNalFunction · 0.85
WelsCodeOneSliceFunction · 0.85
WelsUnloadNalFunction · 0.85
WelsEncodeNalFunction · 0.85

Tested by

no test coverage detected