Add fix for simulcast if frame rate in the middle spatial layer is smaller
This commit is contained in:
parent
f9f2bbf805
commit
82cc0535ae
@ -3114,11 +3114,8 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) {
|
|||||||
* \brief swap pDq layers between current pDq layer and reference pDq layer
|
* \brief swap pDq layers between current pDq layer and reference pDq layer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline void WelsSwapDqLayers (sWelsEncCtx* pCtx) {
|
static inline void WelsSwapDqLayers (sWelsEncCtx* pCtx, const int32_t kiNextDqIdx) {
|
||||||
// swap and assign reference
|
// swap and assign reference
|
||||||
const int32_t kiDid = pCtx->uiDependencyId;
|
|
||||||
const int32_t kiNextDqIdx = 1 + kiDid;
|
|
||||||
|
|
||||||
SDqLayer* pTmpLayer = pCtx->ppDqLayerList[kiNextDqIdx];
|
SDqLayer* pTmpLayer = pCtx->ppDqLayerList[kiNextDqIdx];
|
||||||
SDqLayer* pRefLayer = pCtx->pCurDqLayer;
|
SDqLayer* pRefLayer = pCtx->pCurDqLayer;
|
||||||
pCtx->pCurDqLayer = pTmpLayer;
|
pCtx->pCurDqLayer = pTmpLayer;
|
||||||
@ -4384,7 +4381,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
++ iSpatialIdx;
|
++ iSpatialIdx;
|
||||||
|
|
||||||
if (iCurDid + 1 < pSvcParam->iSpatialLayerNum) {
|
if (iCurDid + 1 < pSvcParam->iSpatialLayerNum) {
|
||||||
WelsSwapDqLayers (pCtx);
|
//for next layer, note that iSpatialIdx has been ++ so it is pointer to next layer
|
||||||
|
WelsSwapDqLayers (pCtx, (pSpatialIndexMap + iSpatialIdx)->iDid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, iDidIdx) != 0) {
|
if (pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, iDidIdx) != 0) {
|
||||||
@ -4400,7 +4398,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
&& (pCtx->pLtr[pCtx->uiDependencyId].iLTRMarkMode == LTR_DIRECT_MARK)) || eFrameType == videoFrameTypeIDR)) {
|
&& (pCtx->pLtr[pCtx->uiDependencyId].iLTRMarkMode == LTR_DIRECT_MARK)) || eFrameType == videoFrameTypeIDR)) {
|
||||||
pCtx->bRefOfCurTidIsLtr[iDidIdx][iCurTid] = true;
|
pCtx->bRefOfCurTidIsLtr[iDidIdx][iCurTid] = true;
|
||||||
}
|
}
|
||||||
}
|
}//end of (iSpatialIdx/iSpatialNum)
|
||||||
|
|
||||||
if (ENC_RETURN_CORRECTED == pCtx->iEncoderError) {
|
if (ENC_RETURN_CORRECTED == pCtx->iEncoderError) {
|
||||||
pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, (pSpatialIndexMap + iSpatialIdx)->iDid);
|
pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, (pSpatialIndexMap + iSpatialIdx)->iDid);
|
||||||
@ -4448,8 +4446,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
|||||||
iLayerNum,
|
iLayerNum,
|
||||||
pFbi->iSubSeqId, iFrameSize);
|
pFbi->iSubSeqId, iFrameSize);
|
||||||
for (int32_t i = 0; i < iLayerNum; i++)
|
for (int32_t i = 0; i < iLayerNum; i++)
|
||||||
WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsEncoderEncodeExt() OutputInfo iLayerId = %d,iNalType = %d,iNalCount = %d", i,
|
WelsLog (pLogCtx, WELS_LOG_DEBUG,
|
||||||
pFbi->sLayerInfo[i].uiLayerType, pFbi->sLayerInfo[i].iNalCount);
|
"WelsEncoderEncodeExt() OutputInfo iLayerId = %d,iNalType = %d,iNalCount = %d, first Nal Length=%d", i,
|
||||||
|
pFbi->sLayerInfo[i].uiLayerType, pFbi->sLayerInfo[i].iNalCount, pFbi->sLayerInfo[i].pNalLengthInByte[0]);
|
||||||
WelsEmms();
|
WelsEmms();
|
||||||
|
|
||||||
pFbi->eFrameType = eFrameType;
|
pFbi->eFrameType = eFrameType;
|
||||||
|
@ -3596,7 +3596,7 @@ TEST_P (EncodeTestAPI, SetEncOptionSize) {
|
|||||||
|
|
||||||
|
|
||||||
TEST_F (EncodeDecodeTestAPI, SimulcastAVCDiffFps) {
|
TEST_F (EncodeDecodeTestAPI, SimulcastAVCDiffFps) {
|
||||||
//#define DEBUG_FILE_SAVE3
|
//#define DEBUG_FILE_SAVE_SimulcastAVCDiffFps
|
||||||
int iSpatialLayerNum = WelsClip3 ((rand() % MAX_SPATIAL_LAYER_NUM), 2, MAX_SPATIAL_LAYER_NUM);
|
int iSpatialLayerNum = WelsClip3 ((rand() % MAX_SPATIAL_LAYER_NUM), 2, MAX_SPATIAL_LAYER_NUM);
|
||||||
int iWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 1 << iSpatialLayerNum, MAX_WIDTH);
|
int iWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 1 << iSpatialLayerNum, MAX_WIDTH);
|
||||||
int iHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 1 << iSpatialLayerNum, MAX_HEIGHT);
|
int iHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 1 << iSpatialLayerNum, MAX_HEIGHT);
|
||||||
@ -3608,10 +3608,7 @@ TEST_F (EncodeDecodeTestAPI, SimulcastAVCDiffFps) {
|
|||||||
|
|
||||||
//set flag of bSimulcastAVC
|
//set flag of bSimulcastAVC
|
||||||
param_.bSimulcastAVC = true;
|
param_.bSimulcastAVC = true;
|
||||||
param_.iTemporalLayerNum = 3;
|
param_.iTemporalLayerNum = (rand() % 2) ? 3 : 4;
|
||||||
|
|
||||||
int rv = encoder_->InitializeExt (¶m_);
|
|
||||||
ASSERT_TRUE (rv == cmResultSuccess);
|
|
||||||
|
|
||||||
unsigned char* pBsBuf[MAX_SPATIAL_LAYER_NUM];
|
unsigned char* pBsBuf[MAX_SPATIAL_LAYER_NUM];
|
||||||
int aLen[MAX_SPATIAL_LAYER_NUM] = {0};
|
int aLen[MAX_SPATIAL_LAYER_NUM] = {0};
|
||||||
@ -3648,10 +3645,10 @@ TEST_F (EncodeDecodeTestAPI, SimulcastAVCDiffFps) {
|
|||||||
ASSERT_EQ (0, rv);
|
ASSERT_EQ (0, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PATTERN_NUM (16)
|
#define PATTERN_NUM (18)
|
||||||
const int32_t iTemporalPattern[PATTERN_NUM][MAX_SPATIAL_LAYER_NUM] = { {2, 1, 1, 1}, {2, 2, 2, 1}, {4, 1, 1, 1}, {4, 2, 1, 1},
|
const int32_t iTemporalPattern[PATTERN_NUM][MAX_SPATIAL_LAYER_NUM] = { {2, 1, 1, 1}, {2, 2, 2, 1}, {4, 1, 1, 1}, {4, 2, 1, 1},
|
||||||
{1, 2, 1, 1}, {1, 1, 2, 1}, {1, 4, 1, 1}, {2, 4, 2, 1}, {1, 4, 2, 1},
|
{1, 2, 1, 1}, {1, 1, 2, 1}, {1, 4, 1, 1}, {2, 4, 2, 1}, {1, 4, 2, 1}, {1, 4, 4, 1},
|
||||||
{1, 2, 2, 1}, {1, 2, 4, 1},
|
{1, 2, 2, 1}, {2, 1, 2, 1}, {1, 2, 4, 1},
|
||||||
{1, 1, 1, 2}, {1, 2, 2, 2}, {1, 2, 2, 4}, {1, 2, 4, 2}, {1, 4, 4, 4},
|
{1, 1, 1, 2}, {1, 2, 2, 2}, {1, 2, 2, 4}, {1, 2, 4, 2}, {1, 4, 4, 4},
|
||||||
};
|
};
|
||||||
for (int iPatternIdx = 0; iPatternIdx < PATTERN_NUM; iPatternIdx++) {
|
for (int iPatternIdx = 0; iPatternIdx < PATTERN_NUM; iPatternIdx++) {
|
||||||
@ -3659,7 +3656,11 @@ TEST_F (EncodeDecodeTestAPI, SimulcastAVCDiffFps) {
|
|||||||
param_.sSpatialLayers[i].fFrameRate = (fFrameRate / iTemporalPattern[iPatternIdx][i]);
|
param_.sSpatialLayers[i].fFrameRate = (fFrameRate / iTemporalPattern[iPatternIdx][i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int rv = encoder_->InitializeExt (¶m_);
|
||||||
|
ASSERT_TRUE (rv == cmResultSuccess);
|
||||||
|
|
||||||
iEncFrameNum = 10;
|
iEncFrameNum = 10;
|
||||||
|
int iInsertIdr = rand() % iEncFrameNum;
|
||||||
for (int iFrame = 0; iFrame < iEncFrameNum; iFrame++) {
|
for (int iFrame = 0; iFrame < iEncFrameNum; iFrame++) {
|
||||||
int iResult;
|
int iResult;
|
||||||
int iLayerLen = 0;
|
int iLayerLen = 0;
|
||||||
@ -3668,7 +3669,11 @@ TEST_F (EncodeDecodeTestAPI, SimulcastAVCDiffFps) {
|
|||||||
InitialEncDec (param_.iPicWidth, param_.iPicHeight);
|
InitialEncDec (param_.iPicWidth, param_.iPicHeight);
|
||||||
EncodeOneFrame (0);
|
EncodeOneFrame (0);
|
||||||
|
|
||||||
// init
|
if (iInsertIdr == iFrame) {
|
||||||
|
encoder_->ForceIntraFrame (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// init aLen for the current frame
|
||||||
for (iIdx = 0; iIdx < iSpatialLayerNum; iIdx++) {
|
for (iIdx = 0; iIdx < iSpatialLayerNum; iIdx++) {
|
||||||
aLen[iIdx] = 0;
|
aLen[iIdx] = 0;
|
||||||
}
|
}
|
||||||
@ -3700,7 +3705,7 @@ TEST_F (EncodeDecodeTestAPI, SimulcastAVCDiffFps) {
|
|||||||
EXPECT_TRUE (iResult == cmResultSuccess) << "iResult=" << iResult << "LayerIdx=" << iIdx;
|
EXPECT_TRUE (iResult == cmResultSuccess) << "iResult=" << iResult << "LayerIdx=" << iIdx;
|
||||||
|
|
||||||
iResult = decoder[iIdx]->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_);
|
iResult = decoder[iIdx]->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_);
|
||||||
EXPECT_TRUE (iResult == cmResultSuccess) << "iResult=" << iResult << "LayerIdx=" << iIdx;
|
EXPECT_TRUE (iResult == cmResultSuccess) << "iResult=" << iResult << "LayerIdx=" << iIdx << iPatternIdx;
|
||||||
EXPECT_EQ (dstBufInfo_.iBufferStatus, 1) << "LayerIdx=" << iIdx;
|
EXPECT_EQ (dstBufInfo_.iBufferStatus, 1) << "LayerIdx=" << iIdx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3716,12 +3721,10 @@ TEST_F (EncodeDecodeTestAPI, SimulcastAVCDiffFps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_FILE_SAVE_SimulcastAVCDiffFps
|
#ifdef DEBUG_FILE_SAVE_SimulcastAVCDiffFps
|
||||||
for (int i = 0; i <)MAX_SPATIAL_LAYER_NUM;
|
for (int i = 0; i < MAX_SPATIAL_LAYER_NUM; i++) {
|
||||||
i++) {
|
|
||||||
fclose (fEnc[i]);
|
fclose (fEnc[i]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user