Merge pull request #391 from mstorsjo/threaded-test
Add a test with sliced encoding
This commit is contained in:
commit
a86c1b048b
@ -6,16 +6,37 @@
|
|||||||
#include "BaseEncoderTest.h"
|
#include "BaseEncoderTest.h"
|
||||||
|
|
||||||
static int InitWithParam(ISVCEncoder* encoder, int width,
|
static int InitWithParam(ISVCEncoder* encoder, int width,
|
||||||
int height, float frameRate) {
|
int height, float frameRate, bool slices) {
|
||||||
SEncParamBase param;
|
if (!slices) {
|
||||||
memset (¶m, 0, sizeof(SEncParamBase));
|
SEncParamBase param;
|
||||||
|
memset (¶m, 0, sizeof(SEncParamBase));
|
||||||
|
|
||||||
param.fMaxFrameRate = frameRate;
|
param.fMaxFrameRate = frameRate;
|
||||||
param.iPicWidth = width;
|
param.iPicWidth = width;
|
||||||
param.iPicHeight = height;
|
param.iPicHeight = height;
|
||||||
param.iTargetBitrate = 5000000;
|
param.iTargetBitrate = 5000000;
|
||||||
param.iInputCsp = videoFormatI420;
|
param.iInputCsp = videoFormatI420;
|
||||||
return encoder->Initialize(¶m);
|
|
||||||
|
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) {}
|
BaseEncoderTest::BaseEncoderTest() : encoder_(NULL) {}
|
||||||
@ -34,8 +55,8 @@ void BaseEncoderTest::TearDown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BaseEncoderTest::EncodeStream(InputStream* in, int width, int height,
|
void BaseEncoderTest::EncodeStream(InputStream* in, int width, int height,
|
||||||
float frameRate, Callback* cbk) {
|
float frameRate, bool slices, Callback* cbk) {
|
||||||
int rv = InitWithParam(encoder_, width, height, frameRate);
|
int rv = InitWithParam(encoder_, width, height, frameRate, slices);
|
||||||
ASSERT_TRUE(rv == cmResultSuccess);
|
ASSERT_TRUE(rv == cmResultSuccess);
|
||||||
|
|
||||||
// I420: 1(Y) + 1/4(U) + 1/4(V)
|
// 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,
|
void BaseEncoderTest::EncodeFile(const char* fileName, int width, int height,
|
||||||
float frameRate, Callback* cbk) {
|
float frameRate, bool slices, Callback* cbk) {
|
||||||
FileInputStream fileStream;
|
FileInputStream fileStream;
|
||||||
ASSERT_TRUE(fileStream.Open(fileName));
|
ASSERT_TRUE(fileStream.Open(fileName));
|
||||||
EncodeStream(&fileStream, width, height, frameRate, cbk);
|
EncodeStream(&fileStream, width, height, frameRate, slices, cbk);
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ class BaseEncoderTest {
|
|||||||
BaseEncoderTest();
|
BaseEncoderTest();
|
||||||
void SetUp();
|
void SetUp();
|
||||||
void TearDown();
|
void TearDown();
|
||||||
void EncodeFile(const char* fileName, 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, Callback* cbk);
|
void EncodeStream(InputStream* in, int width, int height, float frameRate, bool slices, Callback* cbk);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ISVCEncoder* encoder_;
|
ISVCEncoder* encoder_;
|
||||||
|
@ -95,7 +95,7 @@ TEST_P(DecodeEncodeTest, CompareOutput) {
|
|||||||
DecodeEncodeFileParam p = GetParam();
|
DecodeEncodeFileParam p = GetParam();
|
||||||
|
|
||||||
ASSERT_TRUE(Open(p.fileName));
|
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];
|
unsigned char digest[SHA_DIGEST_LENGTH];
|
||||||
SHA1Result(&ctx_, digest);
|
SHA1Result(&ctx_, digest);
|
||||||
if (!HasFatalFailure()) {
|
if (!HasFatalFailure()) {
|
||||||
|
@ -31,6 +31,7 @@ struct EncodeFileParam {
|
|||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
float frameRate;
|
float frameRate;
|
||||||
|
bool slices;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>,
|
class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>,
|
||||||
@ -53,7 +54,7 @@ class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>,
|
|||||||
|
|
||||||
TEST_P(EncoderOutputTest, CompareOutput) {
|
TEST_P(EncoderOutputTest, CompareOutput) {
|
||||||
EncodeFileParam p = GetParam();
|
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];
|
unsigned char digest[SHA_DIGEST_LENGTH];
|
||||||
SHA1Result(&ctx_, digest);
|
SHA1Result(&ctx_, digest);
|
||||||
@ -65,15 +66,19 @@ TEST_P(EncoderOutputTest, CompareOutput) {
|
|||||||
static const EncodeFileParam kFileParamArray[] = {
|
static const EncodeFileParam kFileParamArray[] = {
|
||||||
{
|
{
|
||||||
"res/CiscoVT2people_320x192_12fps.yuv",
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
||||||
"06441376891cbc237a36e59b62131cd94ff9cb19", 320, 192, 12.0f
|
"06441376891cbc237a36e59b62131cd94ff9cb19", 320, 192, 12.0f, false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/CiscoVT2people_160x96_6fps.yuv",
|
"res/CiscoVT2people_160x96_6fps.yuv",
|
||||||
"4f3759fc44125b27a179ebff158dbba9e431bd0b", 160, 96, 6.0f
|
"4f3759fc44125b27a179ebff158dbba9e431bd0b", 160, 96, 6.0f, false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/Static_152_100.yuv",
|
"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
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user