Showing the changes to test/api/BaseEncoderTest.cpp (1 of 85 files). Show all
Unified · Split
| @@ -5,12 +5,12 @@ · 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) { | |
| 8 | +static int InitWithParam (ISVCEncoder* encoder, EUsageType usageType, int width, | |
| 9 | + int height, float frameRate, SliceModeEnum sliceMode, bool denoise, int layers) { | |
| 10 | 10 | if (SM_SINGLE_SLICE == sliceMode && !denoise && layers == 1) { |
| 11 | 11 | SEncParamBase param; |
| 12 | − memset (¶m, 0, sizeof(SEncParamBase)); | |
| 13 | − | |
| 12 | + memset (¶m, 0, sizeof (SEncParamBase)); | |
| 13 | + | |
| 14 | 14 | param.iUsageType = usageType; |
| 15 | 15 | param.fMaxFrameRate = frameRate; |
| 16 | 16 | param.iPicWidth = width; |
| @@ -18,10 +18,10 @@ static int InitWithParam(ISVCEncoder* encoder, EUsageType usageType,int width, · 1 unmodified line | ||
| 18 | 18 | param.iTargetBitrate = 5000000; |
| 19 | 19 | param.iInputCsp = videoFormatI420; |
| 20 | 20 | |
| 21 | − return encoder->Initialize(¶m); | |
| 21 | + return encoder->Initialize (¶m); | |
| 22 | 22 | } else { |
| 23 | 23 | SEncParamExt param; |
| 24 | − encoder->GetDefaultParams(¶m); | |
| 24 | + encoder->GetDefaultParams (¶m); | |
| 25 | 25 | |
| 26 | 26 | param.iUsageType = usageType; |
| 27 | 27 | param.fMaxFrameRate = frameRate; |
| @@ -49,62 +49,62 @@ static int InitWithParam(ISVCEncoder* encoder, EUsageType usageType,int width, · 21 unmodified lines | ||
| 49 | 49 | } |
| 50 | 50 | param.iTargetBitrate *= param.iSpatialLayerNum; |
| 51 | 51 | |
| 52 | − return encoder->InitializeExt(¶m); | |
| 52 | + return encoder->InitializeExt (¶m); | |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | −BaseEncoderTest::BaseEncoderTest() : encoder_(NULL) {} | |
| 56 | +BaseEncoderTest::BaseEncoderTest() : encoder_ (NULL) {} | |
| 57 | 57 | |
| 58 | 58 | 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); | |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | void BaseEncoderTest::TearDown() { |
| 65 | 65 | if (encoder_) { |
| 66 | 66 | encoder_->Uninitialize(); |
| 67 | − WelsDestroySVCEncoder(encoder_); | |
| 67 | + WelsDestroySVCEncoder (encoder_); | |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 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); | |
| 75 | 75 | |
| 76 | 76 | // I420: 1(Y) + 1/4(U) + 1/4(V) |
| 77 | 77 | int frameSize = width * height * 3 / 2; |
| 78 | 78 | |
| 79 | 79 | 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); | |
| 82 | 82 | |
| 83 | 83 | SFrameBSInfo info; |
| 84 | − memset(&info, 0, sizeof(SFrameBSInfo)); | |
| 84 | + memset (&info, 0, sizeof (SFrameBSInfo)); | |
| 85 | 85 | |
| 86 | 86 | SSourcePicture pic; |
| 87 | − memset(&pic,0,sizeof(SSourcePicture)); | |
| 87 | + memset (&pic, 0, sizeof (SSourcePicture)); | |
| 88 | 88 | pic.iPicWidth = width; |
| 89 | 89 | pic.iPicHeight = height; |
| 90 | 90 | pic.iColorFormat = videoFormatI420; |
| 91 | 91 | 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; | |
| 93 | 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); | |
| 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); | |
| 99 | 99 | if (info.eFrameType != videoFrameTypeSkip && cbk != NULL) { |
| 100 | − cbk->onEncodeFrame(info); | |
| 100 | + cbk->onEncodeFrame (info); | |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
| 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) { | |
| 107 | 107 | 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); | |
| 110 | 110 | } |