This refine is to remove slice number limitation in the future. The changes contains:
1. add pNalLen in Structure SWelsEncoderOutput to store each nal length 2. rename iNalLengthInByte[MAX_NAL_UNITS_IN_LAYER] to pNalLengthInByte in Structure SLayerBSInfo, the pointer point to pNalLen, like pBSBuf point to pFrameBS.
This commit is contained in:
@@ -347,7 +347,7 @@ typedef struct {
|
|||||||
unsigned char uiLayerType;
|
unsigned char uiLayerType;
|
||||||
|
|
||||||
int iNalCount; // Count number of NAL coded already
|
int iNalCount; // Count number of NAL coded already
|
||||||
int iNalLengthInByte[MAX_NAL_UNITS_IN_LAYER]; // Length of NAL size in byte from 0 to iNalCount-1
|
int* pNalLengthInByte; // Length of NAL size in byte from 0 to iNalCount-1
|
||||||
unsigned char* pBsBuf; // Buffer of bitstream contained
|
unsigned char* pBsBuf; // Buffer of bitstream contained
|
||||||
} SLayerBSInfo, *PLayerBSInfo;
|
} SLayerBSInfo, *PLayerBSInfo;
|
||||||
|
|
||||||
|
|||||||
@@ -782,7 +782,7 @@ int ProcessEncoding(ISVCEncoder* pPtrEnc, int argc, char** argv,bool bConfigFile
|
|||||||
int iLayerSize = 0;
|
int iLayerSize = 0;
|
||||||
int iNalIdx = pLayerBsInfo->iNalCount - 1;
|
int iNalIdx = pLayerBsInfo->iNalCount - 1;
|
||||||
do {
|
do {
|
||||||
iLayerSize += pLayerBsInfo->iNalLengthInByte[iNalIdx];
|
iLayerSize += pLayerBsInfo->pNalLengthInByte[iNalIdx];
|
||||||
-- iNalIdx;
|
-- iNalIdx;
|
||||||
} while (iNalIdx >= 0);
|
} while (iNalIdx >= 0);
|
||||||
#if defined(COMPARE_DATA)
|
#if defined(COMPARE_DATA)
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ typedef struct TagWelsEncoderOutput {
|
|||||||
|
|
||||||
// SWelsNalRaw raw_nals[MAX_DEPENDENCY_LAYER*2+MAX_DEPENDENCY_LAYER*MAX_QUALITY_LEVEL]; // AVC: max up to SPS+PPS+max_slice_idc (2 + 8) for FMO;
|
// SWelsNalRaw raw_nals[MAX_DEPENDENCY_LAYER*2+MAX_DEPENDENCY_LAYER*MAX_QUALITY_LEVEL]; // AVC: max up to SPS+PPS+max_slice_idc (2 + 8) for FMO;
|
||||||
SWelsNalRaw* sNalList; // nal list, adaptive for AVC/SVC in case single slice, multiple slices or fmo
|
SWelsNalRaw* sNalList; // nal list, adaptive for AVC/SVC in case single slice, multiple slices or fmo
|
||||||
|
int32_t* pNalLen;
|
||||||
int32_t iCountNals; // count number of NAL in list
|
int32_t iCountNals; // count number of NAL in list
|
||||||
// SVC: num_sps (MAX_D) + num_pps (MAX_D) + num_vcl (MAX_D * MAX_Q)
|
// SVC: num_sps (MAX_D) + num_pps (MAX_D) + num_vcl (MAX_D * MAX_Q)
|
||||||
int32_t iNalIndex; // coding NAL currently, 0 based
|
int32_t iNalIndex; // coding NAL currently, 0 based
|
||||||
|
|||||||
@@ -1303,6 +1303,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
|
|||||||
(*ppCtx)->pOut->uiSize = iCountBsLen;
|
(*ppCtx)->pOut->uiSize = iCountBsLen;
|
||||||
(*ppCtx)->pOut->sNalList = (SWelsNalRaw*)pMa->WelsMalloc (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList");
|
(*ppCtx)->pOut->sNalList = (SWelsNalRaw*)pMa->WelsMalloc (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList");
|
||||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->sNalList), FreeMemorySvc (ppCtx))
|
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->sNalList), FreeMemorySvc (ppCtx))
|
||||||
|
(*ppCtx)->pOut->pNalLen = (int32_t*)pMa->WelsMallocz(iCountNals * sizeof (int32_t), "pOut->pNalLen");
|
||||||
|
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->pNalLen), FreeMemorySvc(ppCtx))
|
||||||
(*ppCtx)->pOut->iCountNals = iCountNals;
|
(*ppCtx)->pOut->iCountNals = iCountNals;
|
||||||
(*ppCtx)->pOut->iNalIndex = 0;
|
(*ppCtx)->pOut->iNalIndex = 0;
|
||||||
|
|
||||||
@@ -1497,6 +1499,11 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) {
|
|||||||
pMa->WelsFree (pCtx->pOut->sNalList, "pOut->sNalList");
|
pMa->WelsFree (pCtx->pOut->sNalList, "pOut->sNalList");
|
||||||
pCtx->pOut->sNalList = NULL;
|
pCtx->pOut->sNalList = NULL;
|
||||||
}
|
}
|
||||||
|
// NALs len
|
||||||
|
if (NULL != pCtx->pOut->pNalLen) {
|
||||||
|
pMa->WelsFree (pCtx->pOut->pNalLen, "pOut->pNalLen");
|
||||||
|
pCtx->pOut->pNalLen = NULL;
|
||||||
|
}
|
||||||
pMa->WelsFree (pCtx->pOut, "SWelsEncoderOutput");
|
pMa->WelsFree (pCtx->pOut, "SWelsEncoderOutput");
|
||||||
pCtx->pOut = NULL;
|
pCtx->pOut = NULL;
|
||||||
}
|
}
|
||||||
@@ -2733,7 +2740,6 @@ static inline int32_t AddPrefixNal (sWelsEncCtx* pCtx,
|
|||||||
iPayloadSize = pNalLen[*pNalIdxInLayer];
|
iPayloadSize = pNalLen[*pNalIdxInLayer];
|
||||||
|
|
||||||
pCtx->iPosBsBuffer += iPayloadSize;
|
pCtx->iPosBsBuffer += iPayloadSize;
|
||||||
pLayerBsInfo->iNalLengthInByte[*pNalIdxInLayer] = iPayloadSize;
|
|
||||||
|
|
||||||
(*pNalIdxInLayer) ++;
|
(*pNalIdxInLayer) ++;
|
||||||
} else { // No Prefix NAL Unit RBSP syntax here, but need add NAL Unit Header extension
|
} else { // No Prefix NAL Unit RBSP syntax here, but need add NAL Unit Header extension
|
||||||
@@ -2750,7 +2756,6 @@ static inline int32_t AddPrefixNal (sWelsEncCtx* pCtx,
|
|||||||
iPayloadSize = pNalLen[*pNalIdxInLayer];
|
iPayloadSize = pNalLen[*pNalIdxInLayer];
|
||||||
|
|
||||||
pCtx->iPosBsBuffer += iPayloadSize;
|
pCtx->iPosBsBuffer += iPayloadSize;
|
||||||
pLayerBsInfo->iNalLengthInByte[*pNalIdxInLayer] = iPayloadSize;
|
|
||||||
|
|
||||||
(*pNalIdxInLayer) ++;
|
(*pNalIdxInLayer) ++;
|
||||||
}
|
}
|
||||||
@@ -2816,13 +2821,13 @@ int32_t ForceCodingIDR (sWelsEncCtx* pCtx) {
|
|||||||
int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) {
|
int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) {
|
||||||
SFrameBSInfo* pFbi = (SFrameBSInfo*)pDst;
|
SFrameBSInfo* pFbi = (SFrameBSInfo*)pDst;
|
||||||
SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0];
|
SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0];
|
||||||
int32_t iNalLen[128] = {0};
|
|
||||||
int32_t iCountNal = 0;
|
int32_t iCountNal = 0;
|
||||||
|
|
||||||
pLayerBsInfo->pBsBuf = pCtx->pFrameBs;
|
pLayerBsInfo->pBsBuf = pCtx->pFrameBs;
|
||||||
|
pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen;
|
||||||
InitBits (&pCtx->pOut->sBsWrite, pCtx->pOut->pBsBuffer, pCtx->pOut->uiSize);
|
InitBits (&pCtx->pOut->sBsWrite, pCtx->pOut->pBsBuffer, pCtx->pOut->uiSize);
|
||||||
|
|
||||||
int32_t iReturn = WelsWriteParameterSets (pCtx, &iNalLen[0], &iCountNal);
|
int32_t iReturn = WelsWriteParameterSets (pCtx, &pLayerBsInfo->pNalLengthInByte[0], &iCountNal);
|
||||||
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
|
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
|
||||||
|
|
||||||
pLayerBsInfo->uiPriorityId = 0;
|
pLayerBsInfo->uiPriorityId = 0;
|
||||||
@@ -2831,9 +2836,6 @@ int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) {
|
|||||||
pLayerBsInfo->uiQualityId = 0;
|
pLayerBsInfo->uiQualityId = 0;
|
||||||
pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER;
|
pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER;
|
||||||
pLayerBsInfo->iNalCount = iCountNal;
|
pLayerBsInfo->iNalCount = iCountNal;
|
||||||
for (int32_t iNalIndex = 0; iNalIndex < iCountNal; ++ iNalIndex) {
|
|
||||||
pLayerBsInfo->iNalLengthInByte[iNalIndex] = iNalLen[iNalIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
pCtx->eLastNalPriority = NRI_PRI_HIGHEST;
|
pCtx->eLastNalPriority = NRI_PRI_HIGHEST;
|
||||||
pFbi->iLayerNum = 1;
|
pFbi->iLayerNum = 1;
|
||||||
@@ -2865,7 +2867,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
int32_t iSpatialNum = 0; // available count number of spatial layers due to frame size changed in this given frame
|
int32_t iSpatialNum = 0; // available count number of spatial layers due to frame size changed in this given frame
|
||||||
int32_t iSpatialIdx = 0; // iIndex of spatial layers due to frame size changed in this given frame
|
int32_t iSpatialIdx = 0; // iIndex of spatial layers due to frame size changed in this given frame
|
||||||
int32_t iFrameSize = 0;
|
int32_t iFrameSize = 0;
|
||||||
int32_t iNalLen[128] = {0};
|
|
||||||
int32_t iNalIdxInLayer = 0;
|
int32_t iNalIdxInLayer = 0;
|
||||||
int32_t iCountNal = 0;
|
int32_t iCountNal = 0;
|
||||||
EVideoFrameType eFrameType = videoFrameTypeInvalid;
|
EVideoFrameType eFrameType = videoFrameTypeInvalid;
|
||||||
@@ -2909,13 +2910,14 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
pCtx->uiTemporalId = iCurTid;
|
pCtx->uiTemporalId = iCurTid;
|
||||||
|
|
||||||
pLayerBsInfo->pBsBuf = pCtx->pFrameBs ;
|
pLayerBsInfo->pBsBuf = pCtx->pFrameBs ;
|
||||||
|
pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen;
|
||||||
|
|
||||||
if (eFrameType == videoFrameTypeIDR) {
|
if (eFrameType == videoFrameTypeIDR) {
|
||||||
++ pCtx->sPSOVector.uiIdrPicId;
|
++ pCtx->sPSOVector.uiIdrPicId;
|
||||||
//if ( pSvcParam->bEnableSSEI )
|
//if ( pSvcParam->bEnableSSEI )
|
||||||
|
|
||||||
// write parameter sets bitstream here
|
// write parameter sets bitstream here
|
||||||
pCtx->iEncoderError = WelsWriteParameterSets (pCtx, &iNalLen[0], &iCountNal);
|
pCtx->iEncoderError = WelsWriteParameterSets (pCtx, &pLayerBsInfo->pNalLengthInByte[0], &iCountNal);
|
||||||
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
|
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
|
||||||
|
|
||||||
pLayerBsInfo->uiPriorityId = 0;
|
pLayerBsInfo->uiPriorityId = 0;
|
||||||
@@ -2924,12 +2926,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
pLayerBsInfo->uiQualityId = 0;
|
pLayerBsInfo->uiQualityId = 0;
|
||||||
pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER;
|
pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER;
|
||||||
pLayerBsInfo->iNalCount = iCountNal;
|
pLayerBsInfo->iNalCount = iCountNal;
|
||||||
for (int32_t iNalIndex = 0; iNalIndex < iCountNal; ++ iNalIndex) {
|
|
||||||
pLayerBsInfo->iNalLengthInByte[iNalIndex] = iNalLen[iNalIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
++ pLayerBsInfo;
|
++ pLayerBsInfo;
|
||||||
pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer;
|
pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer;
|
||||||
|
pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal;
|
||||||
++ iLayerNum;
|
++ iLayerNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3050,7 +3050,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
int32_t iPayloadSize = 0;
|
int32_t iPayloadSize = 0;
|
||||||
|
|
||||||
if (pCtx->bNeedPrefixNalFlag) {
|
if (pCtx->bNeedPrefixNalFlag) {
|
||||||
pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &iNalLen[0], &iNalIdxInLayer, eNalType, eNalRefIdc,
|
pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType, eNalRefIdc,
|
||||||
iPayloadSize);
|
iPayloadSize);
|
||||||
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
|
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
|
||||||
iLayerSize += iPayloadSize;
|
iLayerSize += iPayloadSize;
|
||||||
@@ -3067,9 +3067,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
&pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt,
|
&pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt,
|
||||||
pCtx->iFrameBsSize - pCtx->iPosBsBuffer,
|
pCtx->iFrameBsSize - pCtx->iPosBsBuffer,
|
||||||
pCtx->pFrameBs + pCtx->iPosBsBuffer,
|
pCtx->pFrameBs + pCtx->iPosBsBuffer,
|
||||||
&iNalLen[iNalIdxInLayer]);
|
&pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer]);
|
||||||
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
|
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
|
||||||
iSliceSize = iNalLen[iNalIdxInLayer];
|
iSliceSize = pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer];
|
||||||
|
|
||||||
iLayerSize += iSliceSize;
|
iLayerSize += iSliceSize;
|
||||||
pCtx->iPosBsBuffer += iSliceSize;
|
pCtx->iPosBsBuffer += iSliceSize;
|
||||||
@@ -3078,7 +3078,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
pLayerBsInfo->uiTemporalId = iCurTid;
|
pLayerBsInfo->uiTemporalId = iCurTid;
|
||||||
pLayerBsInfo->uiQualityId = 0;
|
pLayerBsInfo->uiQualityId = 0;
|
||||||
pLayerBsInfo->uiPriorityId = 0;
|
pLayerBsInfo->uiPriorityId = 0;
|
||||||
pLayerBsInfo->iNalLengthInByte[iNalIdxInLayer] = iSliceSize;
|
|
||||||
pLayerBsInfo->iNalCount = ++ iNalIdxInLayer;
|
pLayerBsInfo->iNalCount = ++ iNalIdxInLayer;
|
||||||
}
|
}
|
||||||
// for dynamic slicing single threading..
|
// for dynamic slicing single threading..
|
||||||
@@ -3221,7 +3220,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
int32_t iSliceSize = 0;
|
int32_t iSliceSize = 0;
|
||||||
int32_t iPayloadSize = 0;
|
int32_t iPayloadSize = 0;
|
||||||
if (bNeedPrefix) {
|
if (bNeedPrefix) {
|
||||||
pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &iNalLen[0], &iNalIdxInLayer, eNalType, eNalRefIdc,
|
pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType, eNalRefIdc,
|
||||||
iPayloadSize);
|
iPayloadSize);
|
||||||
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
|
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
|
||||||
iLayerSize += iPayloadSize;
|
iLayerSize += iPayloadSize;
|
||||||
@@ -3236,13 +3235,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
pCtx->iEncoderError = WelsEncodeNal (&pCtx->pOut->sNalList[pCtx->pOut->iNalIndex - 1],
|
pCtx->iEncoderError = WelsEncodeNal (&pCtx->pOut->sNalList[pCtx->pOut->iNalIndex - 1],
|
||||||
&pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt,
|
&pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt,
|
||||||
pCtx->iFrameBsSize - pCtx->iPosBsBuffer,
|
pCtx->iFrameBsSize - pCtx->iPosBsBuffer,
|
||||||
pCtx->pFrameBs + pCtx->iPosBsBuffer, &iNalLen[iNalIdxInLayer]);
|
pCtx->pFrameBs + pCtx->iPosBsBuffer, &pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer]);
|
||||||
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
|
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
|
||||||
iSliceSize = iNalLen[iNalIdxInLayer];
|
iSliceSize = pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer];
|
||||||
|
|
||||||
pCtx->iPosBsBuffer += iSliceSize;
|
pCtx->iPosBsBuffer += iSliceSize;
|
||||||
iLayerSize += iSliceSize;
|
iLayerSize += iSliceSize;
|
||||||
pLayerBsInfo->iNalLengthInByte[iNalIdxInLayer] = iSliceSize;
|
|
||||||
|
|
||||||
#if defined(SLICE_INFO_OUTPUT)
|
#if defined(SLICE_INFO_OUTPUT)
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
@@ -3374,10 +3372,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
}
|
}
|
||||||
#endif//STAT_OUTPUT
|
#endif//STAT_OUTPUT
|
||||||
|
|
||||||
|
iCountNal = pLayerBsInfo->iNalCount;
|
||||||
++ iLayerNum;
|
++ iLayerNum;
|
||||||
++ pLayerBsInfo;
|
++ pLayerBsInfo;
|
||||||
|
|
||||||
pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer;
|
pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer;
|
||||||
|
pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal;
|
||||||
|
|
||||||
if (pSvcParam->iPaddingFlag && pCtx->pWelsSvcRc[pCtx->uiDependencyId].iPaddingSize > 0) {
|
if (pSvcParam->iPaddingFlag && pCtx->pWelsSvcRc[pCtx->uiDependencyId].iPaddingSize > 0) {
|
||||||
int32_t iPaddingNalSize = 0;
|
int32_t iPaddingNalSize = 0;
|
||||||
@@ -3401,9 +3401,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
pLayerBsInfo->uiQualityId = 0;
|
pLayerBsInfo->uiQualityId = 0;
|
||||||
pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER;
|
pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER;
|
||||||
pLayerBsInfo->iNalCount = 1;
|
pLayerBsInfo->iNalCount = 1;
|
||||||
pLayerBsInfo->iNalLengthInByte[0] = iPaddingNalSize;
|
pLayerBsInfo->pNalLengthInByte[0] = iPaddingNalSize;
|
||||||
++ pLayerBsInfo;
|
++ pLayerBsInfo;
|
||||||
pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer;
|
pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer;
|
||||||
|
pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + 1;
|
||||||
++ iLayerNum;
|
++ iLayerNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3657,7 +3658,6 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx,
|
|||||||
|
|
||||||
SDqLayer* pCurLayer = pCtx->pCurDqLayer;
|
SDqLayer* pCurLayer = pCtx->pCurDqLayer;
|
||||||
SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx;
|
SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx;
|
||||||
int32_t iNalLen[MAX_NAL_UNITS_IN_LAYER] = {0};
|
|
||||||
int32_t iNalIdxInLayer = *pNalIdxInLayer;
|
int32_t iNalIdxInLayer = *pNalIdxInLayer;
|
||||||
int32_t iSliceIdx = iStartSliceIdx;
|
int32_t iSliceIdx = iStartSliceIdx;
|
||||||
const int32_t kiSliceStep = pCtx->iActiveThreadsNum;
|
const int32_t kiSliceStep = pCtx->iActiveThreadsNum;
|
||||||
@@ -3688,7 +3688,7 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (kbNeedPrefix) {
|
if (kbNeedPrefix) {
|
||||||
iReturn = AddPrefixNal (pCtx, pLayerBsInfo, &iNalLen[0], &iNalIdxInLayer, keNalType, keNalRefIdc, iPayloadSize);
|
iReturn = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, keNalType, keNalRefIdc, iPayloadSize);
|
||||||
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
|
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
|
||||||
iPartitionBsSize += iPayloadSize;
|
iPartitionBsSize += iPayloadSize;
|
||||||
}
|
}
|
||||||
@@ -3702,13 +3702,12 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx,
|
|||||||
&pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt,
|
&pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt,
|
||||||
pCtx->iFrameBsSize - pCtx->iPosBsBuffer,
|
pCtx->iFrameBsSize - pCtx->iPosBsBuffer,
|
||||||
pCtx->pFrameBs + pCtx->iPosBsBuffer,
|
pCtx->pFrameBs + pCtx->iPosBsBuffer,
|
||||||
&iNalLen[iNalIdxInLayer]);
|
&pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer]);
|
||||||
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
|
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
|
||||||
iSliceSize = iNalLen[iNalIdxInLayer];
|
iSliceSize = pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer];
|
||||||
|
|
||||||
pCtx->iPosBsBuffer += iSliceSize;
|
pCtx->iPosBsBuffer += iSliceSize;
|
||||||
iPartitionBsSize += iSliceSize;
|
iPartitionBsSize += iSliceSize;
|
||||||
pLayerBsInfo->iNalLengthInByte[iNalIdxInLayer] = iSliceSize;
|
|
||||||
|
|
||||||
#if defined(SLICE_INFO_OUTPUT)
|
#if defined(SLICE_INFO_OUTPUT)
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
|
|||||||
@@ -548,7 +548,7 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32
|
|||||||
iLayerSize += pSliceBs->uiBsPos;
|
iLayerSize += pSliceBs->uiBsPos;
|
||||||
|
|
||||||
while (iNalIdx < iCountNal) {
|
while (iNalIdx < iCountNal) {
|
||||||
pLbi->iNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
|
pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
|
||||||
++ iNalIdx;
|
++ iNalIdx;
|
||||||
}
|
}
|
||||||
pLbi->iNalCount += iCountNal;
|
pLbi->iNalCount += iCountNal;
|
||||||
@@ -580,7 +580,7 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32
|
|||||||
iLayerSize += pSliceBs->uiBsPos;
|
iLayerSize += pSliceBs->uiBsPos;
|
||||||
|
|
||||||
while (iNalIdx < iCountNal) {
|
while (iNalIdx < iCountNal) {
|
||||||
pLbi->iNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
|
pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
|
||||||
++ iNalIdx;
|
++ iNalIdx;
|
||||||
}
|
}
|
||||||
pLbi->iNalCount += iCountNal;
|
pLbi->iNalCount += iCountNal;
|
||||||
@@ -621,7 +621,7 @@ int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFr
|
|||||||
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
|
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
|
||||||
iSliceSize += iNalSize;
|
iSliceSize += iNalSize;
|
||||||
pDst += iNalSize;
|
pDst += iNalSize;
|
||||||
pLbi->iNalLengthInByte[iNalBase + iNalIdx] = iNalSize;
|
pLbi->pNalLengthInByte[iNalBase + iNalIdx] = iNalSize;
|
||||||
|
|
||||||
++ iNalIdx;
|
++ iNalIdx;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ int CWelsH264SVCEncoder::EncodeFrameInternal (const SSourcePicture* pSrcPic, SF
|
|||||||
|
|
||||||
iCurLayerBits = 0;
|
iCurLayerBits = 0;
|
||||||
for (j = 0; j < pLayer->iNalCount; j++) {
|
for (j = 0; j < pLayer->iNalCount; j++) {
|
||||||
iCurLayerBits += pLayer->iNalLengthInByte[j];
|
iCurLayerBits += pLayer->pNalLengthInByte[j];
|
||||||
}
|
}
|
||||||
total_bits += iCurLayerBits;
|
total_bits += iCurLayerBits;
|
||||||
if (m_pFileBs != NULL)
|
if (m_pFileBs != NULL)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ static void UpdateHashFromFrame(const SFrameBSInfo& info, SHA1Context* ctx) {
|
|||||||
const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
|
const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
|
||||||
int layerSize = 0;
|
int layerSize = 0;
|
||||||
for (int j = 0; j < layerInfo.iNalCount; ++j) {
|
for (int j = 0; j < layerInfo.iNalCount; ++j) {
|
||||||
layerSize += layerInfo.iNalLengthInByte[j];
|
layerSize += layerInfo.pNalLengthInByte[j];
|
||||||
}
|
}
|
||||||
SHA1Input(ctx, layerInfo.pBsBuf, layerSize);
|
SHA1Input(ctx, layerInfo.pBsBuf, layerSize);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ static void UpdateHashFromFrame(const SFrameBSInfo& info, SHA1Context* ctx) {
|
|||||||
const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
|
const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
|
||||||
int layerSize = 0;
|
int layerSize = 0;
|
||||||
for (int j = 0; j < layerInfo.iNalCount; ++j) {
|
for (int j = 0; j < layerInfo.iNalCount; ++j) {
|
||||||
layerSize += layerInfo.iNalLengthInByte[j];
|
layerSize += layerInfo.pNalLengthInByte[j];
|
||||||
}
|
}
|
||||||
SHA1Input(ctx, layerInfo.pBsBuf, layerSize);
|
SHA1Input(ctx, layerInfo.pBsBuf, layerSize);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user