Showing the changes to test/api/BaseEncoderTest.cpp (1 of 5 files). Show all
Unified · Split
| @@ -5,16 +5,20 @@ · 4 unmodified lines | ||
| 5 | 5 | #include "utils/FileInputStream.h" |
| 6 | 6 | #include "BaseEncoderTest.h" |
| 7 | 7 | |
| 8 | −static int InitWithParam (ISVCEncoder* encoder, EUsageType usageType, int width, | |
| 9 | − int height, float frameRate, SliceModeEnum sliceMode, bool denoise, int layers, bool losslessLink, bool enableLtr,bool cabac) { | |
| 10 | − if (SM_SINGLE_SLICE == sliceMode && !denoise && layers == 1 && !losslessLink && !enableLtr &&!cabac) { | |
| 8 | +static int InitWithParam (ISVCEncoder* encoder, SEncParamExt* pEncParamExt) { | |
| 9 | + | |
| 10 | + SliceModeEnum eSliceMode = pEncParamExt->sSpatialLayers[0].sSliceCfg.uiSliceMode; | |
| 11 | + bool bBaseParamFlag = (SM_SINGLE_SLICE == eSliceMode && !pEncParamExt->bEnableDenoise | |
| 12 | + && pEncParamExt->iSpatialLayerNum == 1 && !pEncParamExt->bIsLosslessLink | |
| 13 | + && !pEncParamExt->bEnableLongTermReference && !pEncParamExt->iEntropyCodingModeFlag) ? true : false; | |
| 14 | + if (bBaseParamFlag) { | |
| 11 | 15 | SEncParamBase param; |
| 12 | 16 | memset (¶m, 0, sizeof (SEncParamBase)); |
| 13 | 17 | |
| 14 | − param.iUsageType = usageType; | |
| 15 | − param.fMaxFrameRate = frameRate; | |
| 16 | − param.iPicWidth = width; | |
| 17 | − param.iPicHeight = height; | |
| 18 | + param.iUsageType = pEncParamExt->iUsageType; | |
| 19 | + param.fMaxFrameRate = pEncParamExt->fMaxFrameRate; | |
| 20 | + param.iPicWidth = pEncParamExt->iPicWidth; | |
| 21 | + param.iPicHeight = pEncParamExt->iPicHeight; | |
| 18 | 22 | param.iTargetBitrate = 5000000; |
| 19 | 23 | |
| 20 | 24 | return encoder->Initialize (¶m); |
| @@ -22,27 +26,27 @@ static int InitWithParam (ISVCEncoder* encoder, EUsageType usageType, int width, · 1 unmodified line | ||
| 22 | 26 | SEncParamExt param; |
| 23 | 27 | encoder->GetDefaultParams (¶m); |
| 24 | 28 | |
| 25 | − param.iUsageType = usageType; | |
| 26 | − param.fMaxFrameRate = frameRate; | |
| 27 | − param.iPicWidth = width; | |
| 28 | − param.iPicHeight = height; | |
| 29 | − param.iTargetBitrate = 5000000; | |
| 30 | − param.bEnableDenoise = denoise; | |
| 31 | − param.iSpatialLayerNum = layers; | |
| 32 | − param.bIsLosslessLink = losslessLink; | |
| 33 | − param.bEnableLongTermReference = enableLtr; | |
| 34 | − param.iEntropyCodingModeFlag = cabac?1:0; | |
| 35 | − if (sliceMode != SM_SINGLE_SLICE && sliceMode != SM_DYN_SLICE) //SM_DYN_SLICE don't support multi-thread now | |
| 29 | + param.iUsageType = pEncParamExt->iUsageType; | |
| 30 | + param.fMaxFrameRate = pEncParamExt->fMaxFrameRate; | |
| 31 | + param.iPicWidth = pEncParamExt->iPicWidth; | |
| 32 | + param.iPicHeight = pEncParamExt->iPicHeight; | |
| 33 | + param.iTargetBitrate = 5000000; | |
| 34 | + param.bEnableDenoise = pEncParamExt->bEnableDenoise; | |
| 35 | + param.iSpatialLayerNum = pEncParamExt->iSpatialLayerNum; | |
| 36 | + param.bIsLosslessLink = pEncParamExt->bIsLosslessLink; | |
| 37 | + param.bEnableLongTermReference = pEncParamExt->bEnableLongTermReference; | |
| 38 | + param.iEntropyCodingModeFlag = pEncParamExt->iEntropyCodingModeFlag ? 1 : 0; | |
| 39 | + if (eSliceMode != SM_SINGLE_SLICE && eSliceMode != SM_DYN_SLICE) //SM_DYN_SLICE don't support multi-thread now | |
| 36 | 40 | param.iMultipleThreadIdc = 2; |
| 37 | 41 | |
| 38 | 42 | for (int i = 0; i < param.iSpatialLayerNum; i++) { |
| 39 | − param.sSpatialLayers[i].iVideoWidth = width >> (param.iSpatialLayerNum - 1 - i); | |
| 40 | − param.sSpatialLayers[i].iVideoHeight = height >> (param.iSpatialLayerNum - 1 - i); | |
| 41 | − param.sSpatialLayers[i].fFrameRate = frameRate; | |
| 43 | + param.sSpatialLayers[i].iVideoWidth = pEncParamExt->iPicWidth >> (param.iSpatialLayerNum - 1 - i); | |
| 44 | + param.sSpatialLayers[i].iVideoHeight = pEncParamExt->iPicHeight >> (param.iSpatialLayerNum - 1 - i); | |
| 45 | + param.sSpatialLayers[i].fFrameRate = pEncParamExt->fMaxFrameRate; | |
| 42 | 46 | param.sSpatialLayers[i].iSpatialBitrate = param.iTargetBitrate; |
| 43 | 47 | |
| 44 | − param.sSpatialLayers[i].sSliceCfg.uiSliceMode = sliceMode; | |
| 45 | − if (sliceMode == SM_DYN_SLICE) { | |
| 48 | + param.sSpatialLayers[i].sSliceCfg.uiSliceMode = eSliceMode; | |
| 49 | + if (eSliceMode == SM_DYN_SLICE) { | |
| 46 | 50 | param.sSpatialLayers[i].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 600; |
| 47 | 51 | param.uiMaxNalSize = 1500; |
| 48 | 52 | } |
| @@ -68,13 +72,15 @@ void BaseEncoderTest::TearDown() { · 19 unmodified lines | ||
| 68 | 72 | } |
| 69 | 73 | } |
| 70 | 74 | |
| 71 | −void BaseEncoderTest::EncodeStream (InputStream* in, EUsageType usageType, int width, int height, | |
| 72 | − float frameRate, SliceModeEnum slices, bool denoise, int layers, bool losslessLink, bool enableLtr, bool cabac,Callback* cbk) { | |
| 73 | − int rv = InitWithParam (encoder_, usageType, width, height, frameRate, slices, denoise, layers, losslessLink, enableLtr,cabac); | |
| 75 | +void BaseEncoderTest::EncodeStream (InputStream* in, SEncParamExt* pEncParamExt, Callback* cbk) { | |
| 76 | + | |
| 77 | + ASSERT_TRUE (NULL != pEncParamExt); | |
| 78 | + | |
| 79 | + int rv = InitWithParam (encoder_, pEncParamExt); | |
| 74 | 80 | ASSERT_TRUE (rv == cmResultSuccess); |
| 75 | 81 | |
| 76 | 82 | // I420: 1(Y) + 1/4(U) + 1/4(V) |
| 77 | − int frameSize = width * height * 3 / 2; | |
| 83 | + int frameSize = pEncParamExt->iPicWidth * pEncParamExt->iPicHeight * 3 / 2; | |
| 78 | 84 | |
| 79 | 85 | BufferedData buf; |
| 80 | 86 | buf.SetLength (frameSize); |
| @@ -85,14 +91,14 @@ void BaseEncoderTest::EncodeStream (InputStream* in, EUsageType usageType, int w · 4 unmodified lines | ||
| 85 | 91 | |
| 86 | 92 | SSourcePicture pic; |
| 87 | 93 | memset (&pic, 0, sizeof (SSourcePicture)); |
| 88 | − pic.iPicWidth = width; | |
| 89 | − pic.iPicHeight = height; | |
| 94 | + pic.iPicWidth = pEncParamExt->iPicWidth; | |
| 95 | + pic.iPicHeight = pEncParamExt->iPicHeight; | |
| 90 | 96 | pic.iColorFormat = videoFormatI420; |
| 91 | − pic.iStride[0] = pic.iPicWidth; | |
| 92 | − pic.iStride[1] = pic.iStride[2] = pic.iPicWidth >> 1; | |
| 93 | − pic.pData[0] = buf.data(); | |
| 94 | − pic.pData[1] = pic.pData[0] + width * height; | |
| 95 | − pic.pData[2] = pic.pData[1] + (width * height >> 2); | |
| 97 | + pic.iStride[0] = pic.iPicWidth; | |
| 98 | + pic.iStride[1] = pic.iStride[2] = pic.iPicWidth >> 1; | |
| 99 | + pic.pData[0] = buf.data(); | |
| 100 | + pic.pData[1] = pic.pData[0] + pEncParamExt->iPicWidth * pEncParamExt->iPicHeight; | |
| 101 | + pic.pData[2] = pic.pData[1] + (pEncParamExt->iPicWidth * pEncParamExt->iPicHeight >> 2); | |
| 96 | 102 | while (in->read (buf.data(), frameSize) == frameSize) { |
| 97 | 103 | rv = encoder_->EncodeFrame (&pic, &info); |
| 98 | 104 | ASSERT_TRUE (rv == cmResultSuccess); |
| @@ -102,9 +108,9 @@ void BaseEncoderTest::EncodeStream (InputStream* in, EUsageType usageType, int w · 3 unmodified lines | ||
| 102 | 108 | } |
| 103 | 109 | } |
| 104 | 110 | |
| 105 | −void BaseEncoderTest::EncodeFile (const char* fileName, EUsageType usageType, int width, int height, | |
| 106 | − float frameRate, SliceModeEnum slices, bool denoise, int layers, bool losslessLink, bool enableLtr, bool cabac,Callback* cbk) { | |
| 111 | +void BaseEncoderTest::EncodeFile (const char* fileName, SEncParamExt* pEncParamExt, Callback* cbk) { | |
| 107 | 112 | FileInputStream fileStream; |
| 108 | 113 | ASSERT_TRUE (fileStream.Open (fileName)); |
| 109 | − EncodeStream (&fileStream, usageType, width, height, frameRate, slices, denoise, layers, losslessLink, enableLtr, cabac,cbk); | |
| 114 | + ASSERT_TRUE (NULL != pEncParamExt); | |
| 115 | + EncodeStream (&fileStream, pEncParamExt, cbk); | |
| 110 | 116 | } |