History

put class notification to header file

sijchen committed 10 years ago

Commit 5d03a8a1 parent 2d3071e1 file · +19 −145Browse files

Showing the changes to test/api/encode_decode_api_test.cpp (1 of 1 file). Show all

Unified · Split

test/api/encode_decode_api_test.cpp+19−145
@@ -8,87 +8,11 @@ · 7 unmodified lines
88 #include "utils/HashFunctions.h"
99 #include <string>
1010 #include <vector>
11+#include "encode_decode_api_test.h"
1112 using namespace WelsCommon;
1213
13−#define TRY_TIME_RANGE (10)
14−#define ENCODE_FRAME_NUM (30)
15−#define LEVEL_ID_RANGE (18)
16−#define MAX_WIDTH (4096)
17−#define MAX_HEIGHT (2304)
18−#define MAX_FRAME_RATE (30)
19−#define MIN_FRAME_RATE (1)
20−#define FRAME_RATE_RANGE (2*MAX_FRAME_RATE)
21−#define RC_MODE_RANGE (4)
22−#define BIT_RATE_RANGE (10000)
23−#define MAX_QP (51)
24−#define MIN_QP (0)
25−#define QP_RANGE (2*MAX_QP)
26−#define SPATIAL_LAYER_NUM_RANGE (2*MAX_SPATIAL_LAYER_NUM)
27−#define TEMPORAL_LAYER_NUM_RANGE (2*MAX_TEMPORAL_LAYER_NUM)
28−#define SAVED_NALUNIT_NUM ( (MAX_SPATIAL_LAYER_NUM*MAX_QUALITY_LAYER_NUM) + 1 + MAX_SPATIAL_LAYER_NUM )
29−#define MAX_SLICES_NUM ( ( MAX_NAL_UNITS_IN_LAYER - SAVED_NALUNIT_NUM ) / 3 )
30−#define SLICE_MODE_NUM (6)
31−#define LOOP_FILTER_IDC_NUM (3)
32−#define LOOF_FILTER_OFFSET_RANGE (6)
33−#define MAX_REF_PIC_COUNT (16)
34−#define MIN_REF_PIC_COUNT (1)
35−#define LONG_TERM_REF_NUM (2)
36−#define LONG_TERM_REF_NUM_SCREEN (4)
37−#define MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA (6)
38−#define MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN (8)
39−#define VALID_SIZE(iSize) (((iSize)>16)?(iSize):16)
40−#define GET_MB_WIDTH(x) (((x) + 15)/16)
41−
42−typedef struct SLost_Sim {
43− WelsCommon::EWelsNalUnitType eNalType;
44− bool isLost;
45−} SLostSim;
46−
47−
48−struct EncodeDecodeFileParamBase {
49− int numframes;
50− int width;
51− int height;
52− float frameRate;
53− int slicenum;
54− bool bLostPara;
55− const char* pLossSequence;
56−};
57−
58−static void welsStderrTraceOrigin (void* ctx, int level, const char* string) {
59− fprintf (stderr, "%s\n", string);
60−}
61−
62−typedef struct STrace_Unit {
63− int iTarLevel;
64−} STraceUnit;
65−
66−static void TestOutPutTrace (void* ctx, int level, const char* string) {
67− STraceUnit* pTraceUnit = (STraceUnit*) ctx;
68− EXPECT_LE (level, pTraceUnit->iTarLevel);
69−}
70−
71−class EncodeDecodeTestBase : public BaseEncoderTest, public BaseDecoderTest {
72− public:
73− uint8_t iRandValue;
74− public:
75− virtual void SetUp() {
76− BaseEncoderTest::SetUp();
77− BaseDecoderTest::SetUp();
78− pFunc = welsStderrTraceOrigin;
79− pTraceInfo = NULL;
80− encoder_->SetOption (ENCODER_OPTION_TRACE_CALLBACK, &pFunc);
81− encoder_->SetOption (ENCODER_OPTION_TRACE_CALLBACK_CONTEXT, &pTraceInfo);
82− decoder_->SetOption (DECODER_OPTION_TRACE_CALLBACK, &pFunc);
83− decoder_->SetOption (DECODER_OPTION_TRACE_CALLBACK_CONTEXT, &pTraceInfo);
84− }
85−
86− virtual void TearDown() {
87− BaseEncoderTest::TearDown();
88− BaseDecoderTest::TearDown();
89− }
9014
91− virtual void prepareParam (int iLayers, int iSlices, int width, int height, float framerate, SEncParamExt* pParam) {
15+void EncodeDecodeTestBase::prepareParam (int iLayers, int iSlices, int width, int height, float framerate, SEncParamExt* pParam) {
9216 pParam->iUsageType = CAMERA_VIDEO_REAL_TIME;
9317 pParam->iPicWidth = width;
9418 pParam->iPicHeight = height;
@@ -104,9 +28,9 @@ class EncodeDecodeTestBase : public BaseEncoderTest, public BaseDecoderTest { · 9 unmodified lines
10428 pParam->sSpatialLayers[i].sSliceArgument.uiSliceMode = SM_FIXEDSLCNUM_SLICE;
10529 pParam->sSpatialLayers[i].sSliceArgument.uiSliceNum = iSlices;
10630 }
107− }
31+}
10832
109− virtual void prepareEncDecParam (const EncodeDecodeFileParamBase EncDecFileParam) {
33+void EncodeDecodeTestBase::prepareEncDecParam (const EncodeDecodeFileParamBase EncDecFileParam) {
11034 //for encoder
11135 //I420: 1(Y) + 1/4(U) + 1/4(V)
11236 int frameSize = EncDecFileParam.width * EncDecFileParam.height * 3 / 2;
@@ -125,9 +49,9 @@ class EncodeDecodeTestBase : public BaseEncoderTest, public BaseDecoderTest { · 12 unmodified lines
12549 memset (&info, 0, sizeof (SFrameBSInfo));
12650 //set a fixed random value
12751 iRandValue = rand() % 256;
128− }
52+}
12953
130− virtual void encToDecData (const SFrameBSInfo& info, int& len) {
54+void EncodeDecodeTestBase::encToDecData (const SFrameBSInfo& info, int& len) {
13155 len = 0;
13256 for (int i = 0; i < info.iLayerNum; ++i) {
13357 const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
@@ -135,68 +59,29 @@ class EncodeDecodeTestBase : public BaseEncoderTest, public BaseDecoderTest { · 1 unmodified line
13559 len += layerInfo.pNalLengthInByte[j];
13660 }
13761 }
138− }
62+}
13963
140− virtual void encToDecSliceData (const int iLayerNum, const int iSliceNum, const SFrameBSInfo& info, int& len) {
64+void EncodeDecodeTestBase::encToDecSliceData (const int iLayerNum, const int iSliceNum, const SFrameBSInfo& info, int& len) {
14165 ASSERT_TRUE (iLayerNum < MAX_LAYER_NUM_OF_FRAME);
14266 len = 0;
14367 const SLayerBSInfo& layerInfo = info.sLayerInfo[iLayerNum];
14468 if (iSliceNum < layerInfo.iNalCount)
14569 len = layerInfo.pNalLengthInByte[iSliceNum];
146− }
147−
148−
149− virtual int GetRandWidth() {
150− return WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 16, MAX_WIDTH);
151− }
152−
153− virtual int GetRandHeight() {
154− return WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 16, MAX_HEIGHT);
155− }
156−
157− protected:
158− SEncParamExt param_;
159− BufferedData buf_;
160− SSourcePicture EncPic;
161− SFrameBSInfo info;
162− SBufferInfo dstBufInfo_;
163− std::vector<SLostSim> m_SLostSim;
164− WelsTraceCallback pFunc;
165− STraceUnit sTrace;
166− STraceUnit* pTraceInfo;
167−};
168−
169−class EncodeDecodeTestAPIBase : public EncodeDecodeTestBase {
170− public:
171− uint8_t iRandValue;
172− public:
173− void SetUp() {
174− EncodeDecodeTestBase::SetUp();
175− }
176−
177− void TearDown() {
178− EncodeDecodeTestBase::TearDown();
179− }
70+}
18071
181− void prepareParam0 (int iLayers, int iSlices, int width, int height, float framerate, SEncParamExt* pParam) {
72+void EncodeDecodeTestAPIBase::prepareParam0 (int iLayers, int iSlices, int width, int height, float framerate, SEncParamExt* pParam) {
18273 memset (pParam, 0, sizeof (SEncParamExt));
18374 EncodeDecodeTestBase::prepareParam (iLayers, iSlices, width, height, framerate, pParam);
184− }
75+}
18576
186− void prepareParamDefault (int iLayers, int iSlices, int width, int height, float framerate, SEncParamExt* pParam) {
77+void EncodeDecodeTestAPIBase::prepareParamDefault (int iLayers, int iSlices, int width, int height, float framerate, SEncParamExt* pParam) {
18778 memset (pParam, 0, sizeof (SEncParamExt));
18879 encoder_->GetDefaultParams (pParam);
18980 EncodeDecodeTestBase::prepareParam (iLayers, iSlices, width, height, framerate, pParam);
190− }
81+}
19182
192− void InitialEncDec (int iWidth, int iHeight);
193− void RandomParamExtCombination();
194− void ValidateParamExtCombination();
195− void SliceParamValidationForMode2 (int iSpatialIdx);
196− void SliceParamValidationForMode3 (int iSpatialIdx);
197− void SliceParamValidationForMode4();
19883
199− void EncodeOneFrame (int iCheckTypeIndex) {
84+void EncodeDecodeTestAPIBase::EncodeOneFrame (int iCheckTypeIndex) {
20085 int frameSize = EncPic.iPicWidth * EncPic.iPicHeight * 3 / 2;
20186 memset (buf_.data(), iRandValue, (frameSize >> 2));
20287 memset (buf_.data() + (frameSize >> 2), rand() % 256, (frameSize - (frameSize >> 2)));
@@ -205,9 +90,9 @@ class EncodeDecodeTestAPIBase : public EncodeDecodeTestBase { · 2 unmodified lines
20590 ASSERT_TRUE (rv == cmResultSuccess);
20691 else if (1 == iCheckTypeIndex)
20792 ASSERT_TRUE (rv == cmResultSuccess || rv == cmUnknownReason);
208− }
93+}
20994
210− void EncDecOneFrame (const int iWidth, const int iHeight, const int iFrame, FILE* pfEnc) {
95+void EncodeDecodeTestAPIBase::EncDecOneFrame (const int iWidth, const int iHeight, const int iFrame, FILE* pfEnc) {
21196 int iLen = 0, rv;
21297 InitialEncDec (iWidth, iHeight);
21398 EncodeOneFrame (iFrame);
@@ -223,9 +108,9 @@ class EncodeDecodeTestAPIBase : public EncodeDecodeTestBase { · 9 unmodified lines
223108 if (NULL != pfEnc) {
224109 fwrite (info.sLayerInfo[0].pBsBuf, iLen, 1, pfEnc);
225110 }
226− }
111+}
227112
228− void TestOneSimulcastAVC (SEncParamExt* pParam, ISVCDecoder** decoder, unsigned char** pBsBuf, int iSpatialLayerNum,
113+void EncodeDecodeTestAPIBase::TestOneSimulcastAVC (SEncParamExt* pParam, ISVCDecoder** decoder, unsigned char** pBsBuf, int iSpatialLayerNum,
229114 int iEncFrameNum,
230115 int iCallTimes) {
231116 //#define DEBUG_FILE_SAVE4
@@ -297,18 +182,7 @@ class EncodeDecodeTestAPIBase : public EncodeDecodeTestBase { · 65 unmodified lines
297182 fclose (fEnc[2]);
298183 fclose (fEnc[3]);
299184 #endif
300− }
301−};
302−
303−class EncodeDecodeTestAPI : public ::testing::TestWithParam<EncodeDecodeFileParamBase>, public EncodeDecodeTestAPIBase {
304− void SetUp() {
305− EncodeDecodeTestAPIBase::SetUp();
306− }
307−
308− void TearDown() {
309− EncodeDecodeTestAPIBase::TearDown();
310− }
311−};
185+}
312186
313187 void EncodeDecodeTestAPIBase::InitialEncDec (int iWidth, int iHeight) {
314188

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t