Showing the changes to test/api/BaseEncoderTest.cpp (1 of 85 files). Show all
Unified · Split
| @@ -5,12 +5,12 @@ · 4 unmodified lines | |||
| 5 | #include "utils/FileInputStream.h" | 5 | #include "utils/FileInputStream.h" |
| 6 | #include "BaseEncoderTest.h" | 6 | #include "BaseEncoderTest.h" |
| 7 | 7 | ||
| 8 | static int InitWithParam(ISVCEncoder* encoder, EUsageType usageType,int width, | 8 | static int InitWithParam (ISVCEncoder* encoder, EUsageType usageType, int width, |
| 9 | int height, float frameRate, SliceModeEnum sliceMode, bool denoise, int layers) { | 9 | int height, float frameRate, SliceModeEnum sliceMode, bool denoise, int layers) { |
| 10 | if (SM_SINGLE_SLICE == sliceMode && !denoise && layers == 1) { | 10 | if (SM_SINGLE_SLICE == sliceMode && !denoise && layers == 1) { |
| 11 | SEncParamBase param; | 11 | SEncParamBase param; |
| 12 | memset (¶m, 0, sizeof(SEncParamBase)); | 12 | memset (¶m, 0, sizeof (SEncParamBase)); |
| 13 | 13 | ||
| 14 | param.iUsageType = usageType; | 14 | param.iUsageType = usageType; |
| 15 | param.fMaxFrameRate = frameRate; | 15 | param.fMaxFrameRate = frameRate; |
| 16 | param.iPicWidth = width; | 16 | param.iPicWidth = width; |
| @@ -18,10 +18,10 @@ static int InitWithParam(ISVCEncoder* encoder, EUsageType usageType,int width, · 1 unmodified line | |||
| 18 | param.iTargetBitrate = 5000000; | 18 | param.iTargetBitrate = 5000000; |
| 19 | param.iInputCsp = videoFormatI420; | 19 | param.iInputCsp = videoFormatI420; |
| 20 | 20 | ||
| 21 | return encoder->Initialize(¶m); | 21 | return encoder->Initialize (¶m); |
| 22 | } else { | 22 | } else { |
| 23 | SEncParamExt param; | 23 | SEncParamExt param; |
| 24 | encoder->GetDefaultParams(¶m); | 24 | encoder->GetDefaultParams (¶m); |
| 25 | 25 | ||
| 26 | param.iUsageType = usageType; | 26 | param.iUsageType = usageType; |
| 27 | param.fMaxFrameRate = frameRate; | 27 | param.fMaxFrameRate = frameRate; |
| @@ -49,62 +49,62 @@ static int InitWithParam(ISVCEncoder* encoder, EUsageType usageType,int width, · 21 unmodified lines | |||
| 49 | } | 49 | } |
| 50 | param.iTargetBitrate *= param.iSpatialLayerNum; | 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 | void BaseEncoderTest::SetUp() { | 58 | void BaseEncoderTest::SetUp() { |
| 59 | int rv = WelsCreateSVCEncoder(&encoder_); | 59 | int rv = WelsCreateSVCEncoder (&encoder_); |
| 60 | ASSERT_EQ(0, rv); | 60 | ASSERT_EQ (0, rv); |
| 61 | ASSERT_TRUE(encoder_ != NULL); | 61 | ASSERT_TRUE (encoder_ != NULL); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | void BaseEncoderTest::TearDown() { | 64 | void BaseEncoderTest::TearDown() { |
| 65 | if (encoder_) { | 65 | if (encoder_) { |
| 66 | encoder_->Uninitialize(); | 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, | 71 | void BaseEncoderTest::EncodeStream (InputStream* in, EUsageType usageType, int width, int height, |
| 72 | float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk) { | 72 | float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk) { |
| 73 | int rv = InitWithParam(encoder_, usageType, width, height, frameRate, slices, denoise, layers); | 73 | int rv = InitWithParam (encoder_, usageType, width, height, frameRate, slices, denoise, layers); |
| 74 | ASSERT_TRUE(rv == cmResultSuccess); | 74 | ASSERT_TRUE (rv == cmResultSuccess); |
| 75 | 75 | ||
| 76 | // I420: 1(Y) + 1/4(U) + 1/4(V) | 76 | // I420: 1(Y) + 1/4(U) + 1/4(V) |
| 77 | int frameSize = width * height * 3 / 2; | 77 | int frameSize = width * height * 3 / 2; |
| 78 | 78 | ||
| 79 | BufferedData buf; | 79 | BufferedData buf; |
| 80 | buf.SetLength(frameSize); | 80 | buf.SetLength (frameSize); |
| 81 | ASSERT_TRUE(buf.Length() == (size_t)frameSize); | 81 | ASSERT_TRUE (buf.Length() == (size_t)frameSize); |
| 82 | 82 | ||
| 83 | SFrameBSInfo info; | 83 | SFrameBSInfo info; |
| 84 | memset(&info, 0, sizeof(SFrameBSInfo)); | 84 | memset (&info, 0, sizeof (SFrameBSInfo)); |
| 85 | 85 | ||
| 86 | SSourcePicture pic; | 86 | SSourcePicture pic; |
| 87 | memset(&pic,0,sizeof(SSourcePicture)); | 87 | memset (&pic, 0, sizeof (SSourcePicture)); |
| 88 | pic.iPicWidth = width; | 88 | pic.iPicWidth = width; |
| 89 | pic.iPicHeight = height; | 89 | pic.iPicHeight = height; |
| 90 | pic.iColorFormat = videoFormatI420; | 90 | pic.iColorFormat = videoFormatI420; |
| 91 | pic.iStride[0] = pic.iPicWidth; | 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 | pic.pData[0] = buf.data(); | 93 | pic.pData[0] = buf.data(); |
| 94 | pic.pData[1] = pic.pData[0] + width *height; | 94 | pic.pData[1] = pic.pData[0] + width * height; |
| 95 | pic.pData[2] = pic.pData[1] + (width*height>>2); | 95 | pic.pData[2] = pic.pData[1] + (width * height >> 2); |
| 96 | while (in->read(buf.data(), frameSize) == frameSize) { | 96 | while (in->read (buf.data(), frameSize) == frameSize) { |
| 97 | rv = encoder_->EncodeFrame(&pic, &info); | 97 | rv = encoder_->EncodeFrame (&pic, &info); |
| 98 | ASSERT_TRUE(rv == cmResultSuccess); | 98 | ASSERT_TRUE (rv == cmResultSuccess); |
| 99 | if (info.eFrameType != videoFrameTypeSkip && cbk != NULL) { | 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, | 105 | void BaseEncoderTest::EncodeFile (const char* fileName, EUsageType usageType, int width, int height, |
| 106 | float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk) { | 106 | float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk) { |
| 107 | FileInputStream fileStream; | 107 | FileInputStream fileStream; |
| 108 | ASSERT_TRUE(fileStream.Open(fileName)); | 108 | ASSERT_TRUE (fileStream.Open (fileName)); |
| 109 | EncodeStream(&fileStream, usageType, width, height, frameRate, slices, denoise, layers, cbk); | 109 | EncodeStream (&fileStream, usageType, width, height, frameRate, slices, denoise, layers, cbk); |
| 110 | } | 110 | } |