ref: f13f502203140574eb0e5c7bf15c0571ce7a57be
parent: e6d9d44344dce64f42cff27569bb6fa4b5a0417f
parent: 2dab8bf08778f369f0549eef687e414e2233f225
author: HaiboZhu <haibozhu@cisco.com>
date: Wed Nov 4 04:24:08 EST 2015
Merge pull request #2208 from sijchen/fixslc [Encoder] Fix for a slicing and multi-threading setting
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3975,6 +3975,11 @@
WelsLoadNal (pCtx->pOut, eNalType, eNalRefIdc);
+ //the following line is to fix a problem with a specific setting as in test DiffSlicingInDlayerMixed:
+ // (multi-th on with SM_SINGLE_SLICE in one of the D layers)
+ //TODO: this may not be needed any more after the slice buffer refactoring
+ pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[0].pSliceBsa = &(pCtx->pOut->sBsWrite);
+
pCtx->iEncoderError = WelsCodeOneSlice (pCtx, 0, eNalType);
WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
--- a/test/api/encode_decode_api_test.cpp
+++ b/test/api/encode_decode_api_test.cpp
@@ -3796,6 +3796,70 @@
}
}
+TEST_F (EncodeDecodeTestAPI, DiffSlicingInDlayerMixed) {
+ int iSpatialLayerNum = 2;
+ int iWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, (64 << 2), MAX_WIDTH);
+ int iHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, (64 << 2),
+ 1120);//TODO: use MAX_HEIGHT after the limit is removed
+ float fFrameRate = rand() + 0.5f;
+ int iEncFrameNum = WelsClip3 ((rand() % ENCODE_FRAME_NUM) + 1, 1, ENCODE_FRAME_NUM);
+
+ // prepare params
+ SEncParamExt sParam;
+ encoder_->GetDefaultParams (&sParam);
+ prepareParamDefault (iSpatialLayerNum, 1, iWidth, iHeight, fFrameRate, &sParam);
+ sParam.iMultipleThreadIdc = (rand() % 4) + 1;
+ sParam.bSimulcastAVC = 1;
+ sParam.sSpatialLayers[0].iVideoWidth = (iWidth >> 2);
+ sParam.sSpatialLayers[0].iVideoHeight = (iHeight >> 2);
+ sParam.sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_ROWMB_SLICE;
+
+ sParam.sSpatialLayers[1].iVideoWidth = iWidth;
+ sParam.sSpatialLayers[1].iVideoHeight = iHeight;
+ sParam.sSpatialLayers[1].sSliceCfg.uiSliceMode = SM_FIXEDSLCNUM_SLICE;
+ sParam.sSpatialLayers[1].sSliceCfg.sSliceArgument.uiSliceNum = 1;
+
+ int rv = encoder_->InitializeExt (&sParam);
+ ASSERT_TRUE (rv == cmResultSuccess) << "Init Failed sParam: rv = " << rv;;
+
+ unsigned char* pBsBuf[MAX_SPATIAL_LAYER_NUM];
+ ISVCDecoder* decoder[MAX_SPATIAL_LAYER_NUM];
+
+ int iIdx = 0;
+
+ //create decoder
+ for (iIdx = 0; iIdx < iSpatialLayerNum; iIdx++) {
+ pBsBuf[iIdx] = static_cast<unsigned char*> (malloc (iWidth * iHeight * 3 * sizeof (unsigned char) / 2));
+ EXPECT_TRUE (pBsBuf[iIdx] != NULL);
+
+ long rv = WelsCreateDecoder (&decoder[iIdx]);
+ ASSERT_EQ (0, rv);
+ EXPECT_TRUE (decoder[iIdx] != NULL);
+
+ SDecodingParam decParam;
+ memset (&decParam, 0, sizeof (SDecodingParam));
+ decParam.eOutputColorFormat = videoFormatI420;
+ decParam.uiTargetDqLayer = UCHAR_MAX;
+ decParam.eEcActiveIdc = ERROR_CON_SLICE_COPY;
+ decParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
+
+ rv = decoder[iIdx]->Initialize (&decParam);
+ ASSERT_EQ (0, rv);
+ }
+
+ TestOneSimulcastAVC (&sParam, decoder, pBsBuf, iSpatialLayerNum, iEncFrameNum, 0);
+
+ for (iIdx = 0; iIdx < iSpatialLayerNum; iIdx++) {
+ free (pBsBuf[iIdx]);
+
+ if (decoder[iIdx] != NULL) {
+ decoder[iIdx]->Uninitialize();
+ WelsDestroyDecoder (decoder[iIdx]);
+ }
+
+ }
+}
+
TEST_F (EncodeDecodeTestAPI, ThreadNumAndSliceNum) {
int iSpatialLayerNum = 1;
int iWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, (64 << 2), MAX_WIDTH);