diff --git a/test/BaseEncoderTest.cpp b/test/BaseEncoderTest.cpp index d8d0b26c..12d53d17 100644 --- a/test/BaseEncoderTest.cpp +++ b/test/BaseEncoderTest.cpp @@ -6,16 +6,37 @@ #include "BaseEncoderTest.h" static int InitWithParam(ISVCEncoder* encoder, int width, - int height, float frameRate) { - SEncParamBase param; - memset (¶m, 0, sizeof(SEncParamBase)); + int height, float frameRate, bool slices) { + if (!slices) { + SEncParamBase param; + memset (¶m, 0, sizeof(SEncParamBase)); - param.fMaxFrameRate = frameRate; - param.iPicWidth = width; - param.iPicHeight = height; - param.iTargetBitrate = 5000000; - param.iInputCsp = videoFormatI420; - return encoder->Initialize(¶m); + param.fMaxFrameRate = frameRate; + param.iPicWidth = width; + param.iPicHeight = height; + param.iTargetBitrate = 5000000; + param.iInputCsp = videoFormatI420; + + return encoder->Initialize(¶m); + } else { + SEncParamExt param; + encoder->GetDefaultParams(¶m); + + param.fMaxFrameRate = frameRate; + param.iPicWidth = width; + param.iPicHeight = height; + param.iTargetBitrate = 5000000; + param.iInputCsp = videoFormatI420; + + param.sSpatialLayers[0].iVideoWidth = width; + param.sSpatialLayers[0].iVideoHeight = height; + param.sSpatialLayers[0].fFrameRate = frameRate; + param.sSpatialLayers[0].iSpatialBitrate = param.iTargetBitrate; + + param.sSpatialLayers[0].sSliceCfg.uiSliceMode = 3; // One slice per MB row + + return encoder->InitializeExt(¶m); + } } BaseEncoderTest::BaseEncoderTest() : encoder_(NULL) {} @@ -34,8 +55,8 @@ void BaseEncoderTest::TearDown() { } void BaseEncoderTest::EncodeStream(InputStream* in, int width, int height, - float frameRate, Callback* cbk) { - int rv = InitWithParam(encoder_, width, height, frameRate); + float frameRate, bool slices, Callback* cbk) { + int rv = InitWithParam(encoder_, width, height, frameRate, slices); ASSERT_TRUE(rv == cmResultSuccess); // I420: 1(Y) + 1/4(U) + 1/4(V) @@ -68,8 +89,8 @@ void BaseEncoderTest::EncodeStream(InputStream* in, int width, int height, } void BaseEncoderTest::EncodeFile(const char* fileName, int width, int height, - float frameRate, Callback* cbk) { + float frameRate, bool slices, Callback* cbk) { FileInputStream fileStream; ASSERT_TRUE(fileStream.Open(fileName)); - EncodeStream(&fileStream, width, height, frameRate, cbk); + EncodeStream(&fileStream, width, height, frameRate, slices, cbk); } diff --git a/test/BaseEncoderTest.h b/test/BaseEncoderTest.h index 3689603b..eaf740d2 100644 --- a/test/BaseEncoderTest.h +++ b/test/BaseEncoderTest.h @@ -14,8 +14,8 @@ class BaseEncoderTest { BaseEncoderTest(); void SetUp(); void TearDown(); - void EncodeFile(const char* fileName, int width, int height, float frameRate, Callback* cbk); - void EncodeStream(InputStream* in, int width, int height, float frameRate, Callback* cbk); + void EncodeFile(const char* fileName, int width, int height, float frameRate, bool slices, Callback* cbk); + void EncodeStream(InputStream* in, int width, int height, float frameRate, bool slices, Callback* cbk); private: ISVCEncoder* encoder_; diff --git a/test/decode_encode_test.cpp b/test/decode_encode_test.cpp index 42bc2d94..01e4d90d 100644 --- a/test/decode_encode_test.cpp +++ b/test/decode_encode_test.cpp @@ -95,7 +95,7 @@ TEST_P(DecodeEncodeTest, CompareOutput) { DecodeEncodeFileParam p = GetParam(); ASSERT_TRUE(Open(p.fileName)); - EncodeStream(this, p.width, p.height, p.frameRate, this); + EncodeStream(this, p.width, p.height, p.frameRate, false, this); unsigned char digest[SHA_DIGEST_LENGTH]; SHA1Result(&ctx_, digest); if (!HasFatalFailure()) { diff --git a/test/encoder_test.cpp b/test/encoder_test.cpp index 319d38db..ffa0352d 100644 --- a/test/encoder_test.cpp +++ b/test/encoder_test.cpp @@ -31,6 +31,7 @@ struct EncodeFileParam { int width; int height; float frameRate; + bool slices; }; class EncoderOutputTest : public ::testing::WithParamInterface, @@ -53,7 +54,7 @@ class EncoderOutputTest : public ::testing::WithParamInterface, TEST_P(EncoderOutputTest, CompareOutput) { EncodeFileParam p = GetParam(); - EncodeFile(p.fileName, p.width, p.height, p.frameRate, this); + EncodeFile(p.fileName, p.width, p.height, p.frameRate, p.slices, this); unsigned char digest[SHA_DIGEST_LENGTH]; SHA1Result(&ctx_, digest); @@ -65,15 +66,19 @@ TEST_P(EncoderOutputTest, CompareOutput) { static const EncodeFileParam kFileParamArray[] = { { "res/CiscoVT2people_320x192_12fps.yuv", - "06441376891cbc237a36e59b62131cd94ff9cb19", 320, 192, 12.0f + "06441376891cbc237a36e59b62131cd94ff9cb19", 320, 192, 12.0f, false }, { "res/CiscoVT2people_160x96_6fps.yuv", - "4f3759fc44125b27a179ebff158dbba9e431bd0b", 160, 96, 6.0f + "4f3759fc44125b27a179ebff158dbba9e431bd0b", 160, 96, 6.0f, false }, { "res/Static_152_100.yuv", - "af5c6a41b567ce1b2cb6fd427f4379473d3b829f", 152, 100, 6.0f + "af5c6a41b567ce1b2cb6fd427f4379473d3b829f", 152, 100, 6.0f, false + }, + { + "res/CiscoVT2people_320x192_12fps.yuv", + "be0079b022b18fdce04570db24e4327ca26a0ecb", 320, 192, 12.0f, true }, };