ref: fc6f756436a039e437db63ee9b7f2a1223e231bd
parent: c94acc98ea5cc7bb4ed614f765cc8aea2f1d54e0
parent: 02b4beb70dd0ed8be9f8bc05eef8007f3612fc36
author: Ethan Hugg <[email protected]>
date: Tue Mar 18 05:46:00 EDT 2014
Merge pull request #522 from mstorsjo/layered-encoding-test Add a test of encoding multiple spatial layers
--- a/test/BaseEncoderTest.cpp
+++ b/test/BaseEncoderTest.cpp
@@ -6,8 +6,8 @@
#include "BaseEncoderTest.h"
static int InitWithParam(ISVCEncoder* encoder, int width,
- int height, float frameRate, SliceModeEnum sliceMode, bool denoise, int deblock) {
- if (SM_SINGLE_SLICE == sliceMode && !denoise && deblock == 1) {
+ int height, float frameRate, SliceModeEnum sliceMode, bool denoise, int deblock, int layers) {
+ if (SM_SINGLE_SLICE == sliceMode && !denoise && deblock == 1 && layers == 1) {
SEncParamBase param;
memset (¶m, 0, sizeof(SEncParamBase));
@@ -29,13 +29,16 @@
param.iInputCsp = videoFormatI420;
param.bEnableDenoise = denoise;
param.iLoopFilterDisableIdc = deblock;
+ param.iSpatialLayerNum = layers;
- param.sSpatialLayers[0].iVideoWidth = width;
- param.sSpatialLayers[0].iVideoHeight = height;
- param.sSpatialLayers[0].fFrameRate = frameRate;
- param.sSpatialLayers[0].iSpatialBitrate = param.iTargetBitrate;
+ for (int i = 0; i < param.iSpatialLayerNum; i++) {
+ param.sSpatialLayers[i].iVideoWidth = width >> (param.iSpatialLayerNum - 1 - i);
+ param.sSpatialLayers[i].iVideoHeight = height >> (param.iSpatialLayerNum - 1 - i);
+ param.sSpatialLayers[i].fFrameRate = frameRate;
+ param.sSpatialLayers[i].iSpatialBitrate = param.iTargetBitrate;
- param.sSpatialLayers[0].sSliceCfg.uiSliceMode = sliceMode;
+ param.sSpatialLayers[i].sSliceCfg.uiSliceMode = sliceMode;
+ }
return encoder->InitializeExt(¶m);
}
@@ -57,8 +60,8 @@
}
void BaseEncoderTest::EncodeStream(InputStream* in, int width, int height,
- float frameRate, SliceModeEnum slices, bool denoise, int deblock, Callback* cbk) {
- int rv = InitWithParam(encoder_, width, height, frameRate, slices, denoise, deblock);
+ float frameRate, SliceModeEnum slices, bool denoise, int deblock, int layers, Callback* cbk) {
+ int rv = InitWithParam(encoder_, width, height, frameRate, slices, denoise, deblock, layers);
ASSERT_TRUE(rv == cmResultSuccess);
// I420: 1(Y) + 1/4(U) + 1/4(V)
@@ -91,8 +94,8 @@
}
void BaseEncoderTest::EncodeFile(const char* fileName, int width, int height,
- float frameRate, SliceModeEnum slices, bool denoise, int deblock, Callback* cbk) {
+ float frameRate, SliceModeEnum slices, bool denoise, int deblock, int layers, Callback* cbk) {
FileInputStream fileStream;
ASSERT_TRUE(fileStream.Open(fileName));
- EncodeStream(&fileStream, width, height, frameRate, slices, denoise, deblock, cbk);
+ EncodeStream(&fileStream, width, height, frameRate, slices, denoise, deblock, layers, cbk);
}
--- a/test/BaseEncoderTest.h
+++ b/test/BaseEncoderTest.h
@@ -14,8 +14,8 @@
BaseEncoderTest();
void SetUp();
void TearDown();
- void EncodeFile(const char* fileName, int width, int height, float frameRate, SliceModeEnum slices, bool denoise, int deblock, Callback* cbk);
- void EncodeStream(InputStream* in, int width, int height, float frameRate, SliceModeEnum slices, bool denoise, int deblock, Callback* cbk);
+ void EncodeFile(const char* fileName, int width, int height, float frameRate, SliceModeEnum slices, bool denoise, int deblock, int layers, Callback* cbk);
+ void EncodeStream(InputStream* in, int width, int height, float frameRate, SliceModeEnum slices, bool denoise, int deblock, int layers, Callback* cbk);
private:
ISVCEncoder* encoder_;
--- a/test/decode_encode_test.cpp
+++ b/test/decode_encode_test.cpp
@@ -95,7 +95,7 @@
DecodeEncodeFileParam p = GetParam();
ASSERT_TRUE(Open(p.fileName));
- EncodeStream(this, p.width, p.height, p.frameRate, SM_SINGLE_SLICE, false, 1, this);
+ EncodeStream(this, p.width, p.height, p.frameRate, SM_SINGLE_SLICE, false, 1, 1, this);
unsigned char digest[SHA_DIGEST_LENGTH];
SHA1Result(&ctx_, digest);
if (!HasFatalFailure()) {
--- a/test/encoder_test.cpp
+++ b/test/encoder_test.cpp
@@ -34,6 +34,7 @@
SliceModeEnum slices;
bool denoise;
int deblocking;
+ int layers;
};
class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>,
@@ -56,7 +57,7 @@
TEST_P(EncoderOutputTest, CompareOutput) {
EncodeFileParam p = GetParam();
- EncodeFile(p.fileName, p.width, p.height, p.frameRate, p.slices, p.denoise, p.deblocking, this);
+ EncodeFile(p.fileName, p.width, p.height, p.frameRate, p.slices, p.denoise, p.deblocking, p.layers, this);
unsigned char digest[SHA_DIGEST_LENGTH];
SHA1Result(&ctx_, digest);
@@ -68,27 +69,31 @@
static const EncodeFileParam kFileParamArray[] = {
{
"res/CiscoVT2people_320x192_12fps.yuv",
- "06441376891cbc237a36e59b62131cd94ff9cb19", 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1
+ "06441376891cbc237a36e59b62131cd94ff9cb19", 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, 1
},
{
"res/CiscoVT2people_160x96_6fps.yuv",
- "4f3759fc44125b27a179ebff158dbba9e431bd0b", 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1
+ "4f3759fc44125b27a179ebff158dbba9e431bd0b", 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1, 1
},
{
"res/Static_152_100.yuv",
- "af5c6a41b567ce1b2cb6fd427f4379473d3b829f", 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1
+ "af5c6a41b567ce1b2cb6fd427f4379473d3b829f", 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1, 1
},
{
"res/CiscoVT2people_320x192_12fps.yuv",
- "be0079b022b18fdce04570db24e4327ca26a0ecb", 320, 192, 12.0f, SM_ROWMB_SLICE, false, 1 // One slice per MB row
+ "be0079b022b18fdce04570db24e4327ca26a0ecb", 320, 192, 12.0f, SM_ROWMB_SLICE, false, 1, 1 // One slice per MB row
},
{
"res/CiscoVT2people_320x192_12fps.yuv",
- "f4649601ca15f9693671d7e161e9daa8efd3a7a1", 320, 192, 12.0f, SM_SINGLE_SLICE, true, 1
+ "f4649601ca15f9693671d7e161e9daa8efd3a7a1", 320, 192, 12.0f, SM_SINGLE_SLICE, true, 1, 1
},
{
"res/CiscoVT2people_320x192_12fps.yuv",
- "e4bcd744d2e6f885f6c0dbe5d52818ba64d986d9", 320, 192, 12.0f, SM_SINGLE_SLICE, false, 0
+ "e4bcd744d2e6f885f6c0dbe5d52818ba64d986d9", 320, 192, 12.0f, SM_SINGLE_SLICE, false, 0, 1
+ },
+ {
+ "res/CiscoVT2people_320x192_12fps.yuv",
+ "ba81a0f1a14214e6d3c7f1608991b3ac97789370", 320, 192, 12.0f, SM_SINGLE_SLICE, false, 0, 2
},
};