Showing the changes to test/encoder/EncUT_EncoderExt.cpp (1 of 3 files). Show all
Unified · Split
| @@ -927,3 +927,112 @@ TEST_F (EncoderInterfaceTest, SkipFrameCheck) { · 926 unmodified lines | ||
| 927 | 927 | // finish |
| 928 | 928 | pPtrEnc->Uninitialize(); |
| 929 | 929 | } |
| 930 | + | |
| 931 | +TEST_F (EncoderInterfaceTest, DiffResolutionCheck) { | |
| 932 | + SEncParamExt sEncParamExt; | |
| 933 | + int iResult = pPtrEnc->GetDefaultParams (&sEncParamExt); | |
| 934 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 935 | + | |
| 936 | + //actual encode param: iUsageType = 0, spatial_layer_num = 1, temporal_layer_num = 3, frame_rate = 28.248587, target_bitrate = 573000, denoise =0, background_detection = 1, adaptive_quant = 1, enable_crop_pic = 1, scenechange_detection = 0, enable_long_term_reference = 0, ltr_mark_period = 30, ltr_ref_num = 0, enable_multiple_slice = 1, padding = 0, rc_mode = 1, enable_frame_skip = 1, max_bitrate = 573000, max_nalu_size = 0s | |
| 937 | + //actual encode param: spatial 0: width=360, height=640, frame_rate=28.248587, spatial_bitrate=573000, max_layer_bitrate =895839855, max_nalu_size=0, slice_mode=1,this=0x7c62ee48 | |
| 938 | + sEncParamExt.iUsageType = CAMERA_VIDEO_REAL_TIME; | |
| 939 | + sEncParamExt.iPicWidth = 360; | |
| 940 | + sEncParamExt.iPicHeight = 640; | |
| 941 | + sEncParamExt.iTargetBitrate = 1000000; | |
| 942 | + sEncParamExt.iRCMode = RC_BITRATE_MODE; | |
| 943 | + sEncParamExt.fMaxFrameRate = 24; | |
| 944 | + | |
| 945 | + sEncParamExt.iTemporalLayerNum = 3; | |
| 946 | + sEncParamExt.iSpatialLayerNum = 3; | |
| 947 | + sEncParamExt.bEnableLongTermReference = 0; | |
| 948 | + sEncParamExt.bEnableSceneChangeDetect = 0; | |
| 949 | + sEncParamExt.bEnableFrameSkip = 1; | |
| 950 | + sEncParamExt.uiMaxNalSize = 0; | |
| 951 | + | |
| 952 | + sEncParamExt.sSpatialLayers[0].uiLevelIdc = LEVEL_UNKNOWN; | |
| 953 | + sEncParamExt.sSpatialLayers[0].iVideoWidth = 90; | |
| 954 | + sEncParamExt.sSpatialLayers[0].iVideoHeight = 160; | |
| 955 | + sEncParamExt.sSpatialLayers[0].fFrameRate = 6; | |
| 956 | + sEncParamExt.sSpatialLayers[0].iSpatialBitrate = 80000; | |
| 957 | + sEncParamExt.sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_FIXEDSLCNUM_SLICE; | |
| 958 | + | |
| 959 | + sEncParamExt.sSpatialLayers[1].uiLevelIdc = LEVEL_UNKNOWN; | |
| 960 | + sEncParamExt.sSpatialLayers[1].iVideoWidth = 180; | |
| 961 | + sEncParamExt.sSpatialLayers[1].iVideoHeight = 320; | |
| 962 | + sEncParamExt.sSpatialLayers[1].fFrameRate = 12; | |
| 963 | + sEncParamExt.sSpatialLayers[1].iSpatialBitrate = 200000; | |
| 964 | + sEncParamExt.sSpatialLayers[1].sSliceCfg.uiSliceMode = SM_FIXEDSLCNUM_SLICE; | |
| 965 | + | |
| 966 | + sEncParamExt.sSpatialLayers[2].uiLevelIdc = LEVEL_UNKNOWN; | |
| 967 | + sEncParamExt.sSpatialLayers[2].iVideoWidth = 360; | |
| 968 | + sEncParamExt.sSpatialLayers[2].iVideoHeight = 640; | |
| 969 | + sEncParamExt.sSpatialLayers[2].fFrameRate = 24; | |
| 970 | + sEncParamExt.sSpatialLayers[2].iSpatialBitrate = 600000; | |
| 971 | + sEncParamExt.sSpatialLayers[2].sSliceCfg.uiSliceMode = SM_FIXEDSLCNUM_SLICE; | |
| 972 | + | |
| 973 | + pParamExt->iPicWidth = sEncParamExt.iPicWidth; | |
| 974 | + pParamExt->iPicHeight = sEncParamExt.iPicWidth; | |
| 975 | + | |
| 976 | + iResult = pPtrEnc->InitializeExt (&sEncParamExt); | |
| 977 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)) << "iUsageType = " << sEncParamExt.iUsageType << | |
| 978 | + ", iPicWidth = " << sEncParamExt.iPicWidth << ", iPicHeight = " << sEncParamExt.iPicHeight << ", iTargetBitrate = " << | |
| 979 | + sEncParamExt.iTargetBitrate << ", fMaxFrameRate = " << sEncParamExt.fMaxFrameRate; | |
| 980 | + | |
| 981 | + PrepareOneSrcFrame(); | |
| 982 | + iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | |
| 983 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 984 | + pSrcPic->uiTimeStamp += 30; | |
| 985 | + | |
| 986 | + //correct setting | |
| 987 | + sEncParamExt.iSpatialLayerNum = 2; | |
| 988 | + sEncParamExt.sSpatialLayers[1].uiLevelIdc = LEVEL_UNKNOWN; | |
| 989 | + sEncParamExt.sSpatialLayers[1].iVideoWidth = 360; | |
| 990 | + sEncParamExt.sSpatialLayers[1].iVideoHeight = 640; | |
| 991 | + sEncParamExt.sSpatialLayers[1].fFrameRate = 24; | |
| 992 | + sEncParamExt.sSpatialLayers[1].iSpatialBitrate = 600000; | |
| 993 | + iResult = pPtrEnc->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sEncParamExt); | |
| 994 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 995 | + | |
| 996 | + PrepareOneSrcFrame(); | |
| 997 | + iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | |
| 998 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 999 | + pSrcPic->uiTimeStamp += 30; | |
| 1000 | + | |
| 1001 | + //incorrect setting | |
| 1002 | + int uiTraceLevel = WELS_LOG_QUIET; | |
| 1003 | + pPtrEnc->SetOption (ENCODER_OPTION_TRACE_LEVEL, &uiTraceLevel); | |
| 1004 | + | |
| 1005 | + sEncParamExt.sSpatialLayers[1].iVideoWidth = 90; | |
| 1006 | + sEncParamExt.sSpatialLayers[1].iVideoHeight = 160; | |
| 1007 | + sEncParamExt.sSpatialLayers[1].fFrameRate = 6; | |
| 1008 | + sEncParamExt.sSpatialLayers[1].iSpatialBitrate = 80000; | |
| 1009 | + | |
| 1010 | + sEncParamExt.sSpatialLayers[0].iVideoWidth = 360; | |
| 1011 | + sEncParamExt.sSpatialLayers[0].iVideoHeight = 640; | |
| 1012 | + sEncParamExt.sSpatialLayers[0].fFrameRate = 24; | |
| 1013 | + sEncParamExt.sSpatialLayers[0].iSpatialBitrate = 600000; | |
| 1014 | + iResult = pPtrEnc->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sEncParamExt); | |
| 1015 | + EXPECT_EQ (iResult, static_cast<int> (cmInitParaError)); | |
| 1016 | + | |
| 1017 | + //incorrect setting | |
| 1018 | + sEncParamExt.iSpatialLayerNum = 3; | |
| 1019 | + sEncParamExt.sSpatialLayers[1].iVideoWidth = 90; | |
| 1020 | + sEncParamExt.sSpatialLayers[1].iVideoHeight = 160; | |
| 1021 | + sEncParamExt.sSpatialLayers[1].fFrameRate = 6; | |
| 1022 | + sEncParamExt.sSpatialLayers[1].iSpatialBitrate = 80000; | |
| 1023 | + | |
| 1024 | + sEncParamExt.sSpatialLayers[0].iVideoWidth = 180; | |
| 1025 | + sEncParamExt.sSpatialLayers[0].iVideoHeight = 320; | |
| 1026 | + sEncParamExt.sSpatialLayers[0].fFrameRate = 12; | |
| 1027 | + sEncParamExt.sSpatialLayers[0].iSpatialBitrate = 200000; | |
| 1028 | + | |
| 1029 | + sEncParamExt.sSpatialLayers[2].iVideoWidth = 360; | |
| 1030 | + sEncParamExt.sSpatialLayers[2].iVideoHeight = 640; | |
| 1031 | + sEncParamExt.sSpatialLayers[2].fFrameRate = 24; | |
| 1032 | + sEncParamExt.sSpatialLayers[2].iSpatialBitrate = 600000; | |
| 1033 | + iResult = pPtrEnc->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sEncParamExt); | |
| 1034 | + EXPECT_EQ (iResult, static_cast<int> (cmInitParaError)); | |
| 1035 | + | |
| 1036 | + // finish | |
| 1037 | + pPtrEnc->Uninitialize(); | |
| 1038 | +} | |