History

astyle all

huili2 committed 12 years ago

Commit dc3fae41 parent 101265385 files · +4906 −4701Browse files

Showing the changes to test/api/BaseEncoderTest.cpp (1 of 85 files). Show all

Unified · Split

test/api/BaseEncoderTest.cpp+31−31
@@ -5,12 +5,12 @@ · 4 unmodified lines
55 #include "utils/FileInputStream.h"
66 #include "BaseEncoderTest.h"
77
8−static int InitWithParam(ISVCEncoder* encoder, EUsageType usageType,int width,
9− int height, float frameRate, SliceModeEnum sliceMode, bool denoise, int layers) {
8+static int InitWithParam (ISVCEncoder* encoder, EUsageType usageType, int width,
9+ int height, float frameRate, SliceModeEnum sliceMode, bool denoise, int layers) {
1010 if (SM_SINGLE_SLICE == sliceMode && !denoise && layers == 1) {
1111 SEncParamBase param;
12− memset (&param, 0, sizeof(SEncParamBase));
13−
12+ memset (&param, 0, sizeof (SEncParamBase));
13+
1414 param.iUsageType = usageType;
1515 param.fMaxFrameRate = frameRate;
1616 param.iPicWidth = width;
@@ -18,10 +18,10 @@ static int InitWithParam(ISVCEncoder* encoder, EUsageType usageType,int width, · 1 unmodified line
1818 param.iTargetBitrate = 5000000;
1919 param.iInputCsp = videoFormatI420;
2020
21− return encoder->Initialize(&param);
21+ return encoder->Initialize (&param);
2222 } else {
2323 SEncParamExt param;
24− encoder->GetDefaultParams(&param);
24+ encoder->GetDefaultParams (&param);
2525
2626 param.iUsageType = usageType;
2727 param.fMaxFrameRate = frameRate;
@@ -49,62 +49,62 @@ static int InitWithParam(ISVCEncoder* encoder, EUsageType usageType,int width, · 21 unmodified lines
4949 }
5050 param.iTargetBitrate *= param.iSpatialLayerNum;
5151
52− return encoder->InitializeExt(&param);
52+ return encoder->InitializeExt (&param);
5353 }
5454 }
5555
56−BaseEncoderTest::BaseEncoderTest() : encoder_(NULL) {}
56+BaseEncoderTest::BaseEncoderTest() : encoder_ (NULL) {}
5757
5858 void BaseEncoderTest::SetUp() {
59− int rv = WelsCreateSVCEncoder(&encoder_);
60− ASSERT_EQ(0, rv);
61− ASSERT_TRUE(encoder_ != NULL);
59+ int rv = WelsCreateSVCEncoder (&encoder_);
60+ ASSERT_EQ (0, rv);
61+ ASSERT_TRUE (encoder_ != NULL);
6262 }
6363
6464 void BaseEncoderTest::TearDown() {
6565 if (encoder_) {
6666 encoder_->Uninitialize();
67− WelsDestroySVCEncoder(encoder_);
67+ WelsDestroySVCEncoder (encoder_);
6868 }
6969 }
7070
71−void BaseEncoderTest::EncodeStream(InputStream* in, EUsageType usageType, int width, int height,
72− float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk) {
73− int rv = InitWithParam(encoder_, usageType, width, height, frameRate, slices, denoise, layers);
74− ASSERT_TRUE(rv == cmResultSuccess);
71+void BaseEncoderTest::EncodeStream (InputStream* in, EUsageType usageType, int width, int height,
72+ float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk) {
73+ int rv = InitWithParam (encoder_, usageType, width, height, frameRate, slices, denoise, layers);
74+ ASSERT_TRUE (rv == cmResultSuccess);
7575
7676 // I420: 1(Y) + 1/4(U) + 1/4(V)
7777 int frameSize = width * height * 3 / 2;
7878
7979 BufferedData buf;
80− buf.SetLength(frameSize);
81− ASSERT_TRUE(buf.Length() == (size_t)frameSize);
80+ buf.SetLength (frameSize);
81+ ASSERT_TRUE (buf.Length() == (size_t)frameSize);
8282
8383 SFrameBSInfo info;
84− memset(&info, 0, sizeof(SFrameBSInfo));
84+ memset (&info, 0, sizeof (SFrameBSInfo));
8585
8686 SSourcePicture pic;
87− memset(&pic,0,sizeof(SSourcePicture));
87+ memset (&pic, 0, sizeof (SSourcePicture));
8888 pic.iPicWidth = width;
8989 pic.iPicHeight = height;
9090 pic.iColorFormat = videoFormatI420;
9191 pic.iStride[0] = pic.iPicWidth;
92− pic.iStride[1] = pic.iStride[2] = pic.iPicWidth>>1;
92+ pic.iStride[1] = pic.iStride[2] = pic.iPicWidth >> 1;
9393 pic.pData[0] = buf.data();
94− pic.pData[1] = pic.pData[0] + width *height;
95− pic.pData[2] = pic.pData[1] + (width*height>>2);
96− while (in->read(buf.data(), frameSize) == frameSize) {
97− rv = encoder_->EncodeFrame(&pic, &info);
98− ASSERT_TRUE(rv == cmResultSuccess);
94+ pic.pData[1] = pic.pData[0] + width * height;
95+ pic.pData[2] = pic.pData[1] + (width * height >> 2);
96+ while (in->read (buf.data(), frameSize) == frameSize) {
97+ rv = encoder_->EncodeFrame (&pic, &info);
98+ ASSERT_TRUE (rv == cmResultSuccess);
9999 if (info.eFrameType != videoFrameTypeSkip && cbk != NULL) {
100− cbk->onEncodeFrame(info);
100+ cbk->onEncodeFrame (info);
101101 }
102102 }
103103 }
104104
105−void BaseEncoderTest::EncodeFile(const char* fileName, EUsageType usageType, int width, int height,
106− float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk) {
105+void BaseEncoderTest::EncodeFile (const char* fileName, EUsageType usageType, int width, int height,
106+ float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk) {
107107 FileInputStream fileStream;
108− ASSERT_TRUE(fileStream.Open(fileName));
109− EncodeStream(&fileStream, usageType, width, height, frameRate, slices, denoise, layers, cbk);
108+ ASSERT_TRUE (fileStream.Open (fileName));
109+ EncodeStream (&fileStream, usageType, width, height, frameRate, slices, denoise, layers, cbk);
110110 }

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