openh264/test/api/encoder_test.cpp
Martin Storsjö 53e2f67e80 Set constraint set 0 and 1 flags for non-scalable as well
This allows decoders to know that a baseline stream doesn't
contain any of the features that aren't in the constrained
baseline subset.

Set the flags based on what profile we target.
2014-10-31 10:48:09 +02:00

146 lines
5.2 KiB
C++

#include <gtest/gtest.h>
#include "utils/HashFunctions.h"
#include "BaseEncoderTest.h"
#include <string>
static void UpdateHashFromFrame (const SFrameBSInfo& info, SHA1Context* ctx) {
for (int i = 0; i < info.iLayerNum; ++i) {
const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
int layerSize = 0;
for (int j = 0; j < layerInfo.iNalCount; ++j) {
layerSize += layerInfo.pNalLengthInByte[j];
}
SHA1Input (ctx, layerInfo.pBsBuf, layerSize);
}
}
class EncoderInitTest : public ::testing::Test, public BaseEncoderTest {
public:
virtual void SetUp() {
BaseEncoderTest::SetUp();
}
virtual void TearDown() {
BaseEncoderTest::TearDown();
}
};
TEST_F (EncoderInitTest, JustInit) {}
struct EncodeFileParam {
const char* fileName;
const char* hashStr;
EUsageType usageType;
int width;
int height;
float frameRate;
SliceModeEnum slices;
bool denoise;
int layers;
bool isLossless;
bool enableLtr;
bool cabac;
};
class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>,
public EncoderInitTest , public BaseEncoderTest::Callback {
public:
virtual void SetUp() {
EncoderInitTest::SetUp();
if (HasFatalFailure()) {
return;
}
SHA1Reset (&ctx_);
}
virtual void onEncodeFrame (const SFrameBSInfo& frameInfo) {
UpdateHashFromFrame (frameInfo, &ctx_);
}
protected:
SHA1Context ctx_;
};
TEST_P (EncoderOutputTest, CompareOutput) {
EncodeFileParam p = GetParam();
#if defined(ANDROID_NDK)
std::string filename = std::string ("/sdcard/") + p.fileName;
EncodeFile (filename.c_str(), p.usageType , p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, p.isLossless,
p.enableLtr,p.cabac, this);
#else
EncodeFile (p.fileName, p.usageType , p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, p.isLossless,
p.enableLtr, p.cabac, this);
#endif
//will remove this after screen content algorithms are ready,
//because the bitstream output will vary when the different algorithms are added.
unsigned char digest[SHA_DIGEST_LENGTH];
SHA1Result (&ctx_, digest);
if (!HasFatalFailure()) {
CompareHash (digest, p.hashStr);
}
}
static const EncodeFileParam kFileParamArray[] = {
{
"res/CiscoVT2people_320x192_12fps.yuv",
"16b145cf76a677d87240ef6c8efff0ff8d3a2f3a", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, false
},
{
"res/CiscoVT2people_160x96_6fps.yuv",
"874ab77ba13f199d70b67cd75f8e23baf482c1ed", CAMERA_VIDEO_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
},
{
"res/Static_152_100.yuv",
"73b40ad71e1f1ffbbd5425de2b094ccbdfa798a6", CAMERA_VIDEO_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
},
{
"res/CiscoVT2people_320x192_12fps.yuv",
"c1b187be92a35ac8f4f9724b594559e0394c1df8", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_ROWMB_SLICE, false, 1, false, false, false // One slice per MB row
},
{
"res/CiscoVT2people_320x192_12fps.yuv",
"959a94ea684bf37eaf39909f6460e02b50ad0a5f", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, true, 1, false, false, false
},
{
"res/CiscoVT2people_320x192_12fps.yuv",
"684e6d141ada776892bdb01ee93efe475983ed36", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 2, false, false, false
},
{
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
"27a595af0e9598feb4dc1403fd99affddfa51f46", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, false, false, false
},
{
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
"68c3220e49b7a57d563faf7c99a870ab34a23400", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_SINGLE_SLICE, false, 4, false, false, false
},
// the following values may be adjusted for times since we start tuning the strategy
{
"res/CiscoVT2people_320x192_12fps.yuv",
"7113004abe156bf69c399803f302644645ac42be", SCREEN_CONTENT_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, false
},
{
"res/CiscoVT2people_160x96_6fps.yuv",
"51fc38d467509f94e85f9678f11429220e46d862", SCREEN_CONTENT_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
},
{
"res/Static_152_100.yuv",
"1af33ad3d8c40756ef1f6074c019a06535c35ab0", SCREEN_CONTENT_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
},
{
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
"e032f8f8b153f37e614676735074cdce843032de", SCREEN_CONTENT_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, false, false, false
},
//for different strategy
{
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
"28e290b204257eae5c735b2b96491358ec14221e", SCREEN_CONTENT_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, true, true, false
},
{
"res/CiscoVT2people_320x192_12fps.yuv",
"59e51ffc741172df4a729d7fc1f85645885311a5", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, true //turn on cabac
},
{
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
"f4361779554ae66ce62308f1e01218369ca0edf4", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, false, false, true
},
};
INSTANTIATE_TEST_CASE_P (EncodeFile, EncoderOutputTest,
::testing::ValuesIn (kFileParamArray));