Merge pull request #391 from mstorsjo/threaded-test

Add a test with sliced encoding
This commit is contained in:
Ethan Hugg 2014-03-03 07:54:14 -08:00
commit a86c1b048b
4 changed files with 46 additions and 20 deletions

View File

@ -6,7 +6,8 @@
#include "BaseEncoderTest.h"
static int InitWithParam(ISVCEncoder* encoder, int width,
int height, float frameRate) {
int height, float frameRate, bool slices) {
if (!slices) {
SEncParamBase param;
memset (&param, 0, sizeof(SEncParamBase));
@ -15,7 +16,27 @@ static int InitWithParam(ISVCEncoder* encoder, int width,
param.iPicHeight = height;
param.iTargetBitrate = 5000000;
param.iInputCsp = videoFormatI420;
return encoder->Initialize(&param);
} else {
SEncParamExt param;
encoder->GetDefaultParams(&param);
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(&param);
}
}
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);
}

View File

@ -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_;

View File

@ -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()) {

View File

@ -31,6 +31,7 @@ struct EncodeFileParam {
int width;
int height;
float frameRate;
bool slices;
};
class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>,
@ -53,7 +54,7 @@ class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>,
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
},
};