Converting vp8_test to use fileutils and gtest
Review URL: http://webrtc-codereview.appspot.com/289012 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1074 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
f64162c335
commit
4c4b7f500f
@ -9,18 +9,22 @@
|
||||
*/
|
||||
|
||||
#include "benchmark.h"
|
||||
#include "video_source.h"
|
||||
#include "vplib.h"
|
||||
#include <vector>
|
||||
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "event_wrapper.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
#include "video_codec_interface.h"
|
||||
#include "video_source.h"
|
||||
#include "vplib.h"
|
||||
|
||||
|
||||
#define SSIM_CALC 0 // by default, don't compute SSIM
|
||||
|
||||
@ -29,7 +33,7 @@ using namespace webrtc;
|
||||
Benchmark::Benchmark()
|
||||
:
|
||||
NormalAsyncTest("Benchmark", "Codec benchmark over a range of test cases", 6),
|
||||
_resultsFileName("../../../../testFiles/benchmark.txt"),
|
||||
_resultsFileName(webrtc::test::OutputPath() + "benchmark.txt"),
|
||||
_codecName("Default")
|
||||
{
|
||||
}
|
||||
@ -37,7 +41,7 @@ _codecName("Default")
|
||||
Benchmark::Benchmark(std::string name, std::string description)
|
||||
:
|
||||
NormalAsyncTest(name, description, 6),
|
||||
_resultsFileName("../../../../testFiles/benchmark.txt"),
|
||||
_resultsFileName(webrtc::test::OutputPath() + "benchmark.txt"),
|
||||
_codecName("Default")
|
||||
{
|
||||
}
|
||||
@ -57,8 +61,10 @@ Benchmark::Perform()
|
||||
std::vector<const VideoSource*>::iterator it;
|
||||
|
||||
// Configuration --------------------------
|
||||
sources.push_back(new const VideoSource("test/testFiles/foreman_cif.yuv", kCIF));
|
||||
sources.push_back(new const VideoSource("test/testFiles/akiyo_cif.yuv", kCIF));
|
||||
sources.push_back(new const VideoSource(webrtc::test::ProjectRootPath() +
|
||||
"resources/foreman_cif.yuv", kCIF));
|
||||
// sources.push_back(new const VideoSource(webrtc::test::ProjectRootPath() +
|
||||
// "resources/akiyo_cif.yuv", kCIF));
|
||||
|
||||
const VideoSize size[] = {kQCIF, kCIF};
|
||||
const int frameRate[] = {10, 15, 30};
|
||||
|
@ -10,13 +10,14 @@
|
||||
|
||||
#include "normal_async_test.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <assert.h>
|
||||
#include <queue>
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <queue>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "tick_util.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
#include "typedefs.h"
|
||||
|
||||
using namespace webrtc;
|
||||
@ -132,12 +133,14 @@ NormalAsyncTest::Setup()
|
||||
// Check if settings exist. Otherwise use defaults.
|
||||
if (_outname == "")
|
||||
{
|
||||
_outname = "../../out_normaltest" + strTestNo + ".yuv";
|
||||
_outname = webrtc::test::OutputPath() + "out_normaltest" + strTestNo +
|
||||
".yuv";
|
||||
}
|
||||
|
||||
if (_encodedName == "")
|
||||
{
|
||||
_encodedName = "../../encoded_normaltest" + strTestNo + ".yuv";
|
||||
_encodedName = webrtc::test::OutputPath() + "encoded_normaltest" +
|
||||
strTestNo + ".yuv";
|
||||
}
|
||||
|
||||
if ((_sourceFile = fopen(_inname.c_str(), "rb")) == NULL)
|
||||
@ -298,7 +301,7 @@ NormalAsyncTest::Decoded(const RawImage& decodedImage)
|
||||
void
|
||||
NormalAsyncTest::Perform()
|
||||
{
|
||||
_inname = "test/testFiles/foreman_cif.yuv";
|
||||
_inname = webrtc::test::ProjectRootPath() + "resources/foreman_cif.yuv";
|
||||
CodecSettings(352, 288, 30, _bitRate);
|
||||
Setup();
|
||||
_inputVideoBuffer.VerifyAndAllocate(_lengthSourceFrame);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
|
||||
NormalTest::NormalTest()
|
||||
:
|
||||
@ -25,7 +26,8 @@ _appendNext(false)
|
||||
{
|
||||
}
|
||||
|
||||
NormalTest::NormalTest(std::string name, std::string description, unsigned int testNo)
|
||||
NormalTest::NormalTest(std::string name, std::string description,
|
||||
unsigned int testNo)
|
||||
:
|
||||
Test(name, description),
|
||||
_requestKeyFrame(false),
|
||||
@ -35,7 +37,8 @@ _appendNext(false)
|
||||
{
|
||||
}
|
||||
|
||||
NormalTest::NormalTest(std::string name, std::string description, WebRtc_UWord32 bitRate, unsigned int testNo)
|
||||
NormalTest::NormalTest(std::string name, std::string description,
|
||||
WebRtc_UWord32 bitRate, unsigned int testNo)
|
||||
:
|
||||
Test(name, description, bitRate),
|
||||
_requestKeyFrame(false),
|
||||
@ -57,12 +60,14 @@ NormalTest::Setup()
|
||||
// Check if settings exist. Otherwise use defaults.
|
||||
if (_outname == "")
|
||||
{
|
||||
_outname = "../../out_normaltest" + strTestNo + ".yuv";
|
||||
_outname = webrtc::test::OutputPath() + "out_normaltest" + strTestNo +
|
||||
".yuv";
|
||||
}
|
||||
|
||||
if (_encodedName == "")
|
||||
{
|
||||
_encodedName = "../../encoded_normaltest" + strTestNo + ".yuv";
|
||||
_encodedName = webrtc::test::OutputPath() + "encoded_normaltest" +
|
||||
strTestNo + ".yuv";
|
||||
}
|
||||
|
||||
if ((_sourceFile = fopen(_inname.c_str(), "rb")) == NULL)
|
||||
@ -103,7 +108,7 @@ NormalTest::Teardown()
|
||||
void
|
||||
NormalTest::Perform()
|
||||
{
|
||||
_inname = "../../../../testFiles/foreman.yuv";
|
||||
_inname = webrtc::test::ProjectRootPath() + "resources/foreman_cif.yuv";
|
||||
CodecSettings(352, 288, 30, _bitRate);
|
||||
Setup();
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
#include "tick_util.h"
|
||||
|
||||
using namespace webrtc;
|
||||
@ -87,7 +88,7 @@ PerformanceTest::~PerformanceTest()
|
||||
void
|
||||
PerformanceTest::Setup()
|
||||
{
|
||||
_inname = "../../../../testFiles/foreman.yuv";
|
||||
_inname = webrtc::test::ProjectRootPath() + "resources/foreman_cif.yuv";
|
||||
NormalAsyncTest::Setup(); // Setup input and output files
|
||||
CodecSettings(352, 288, 30, _bitRate); // common to all codecs
|
||||
for (int i=0; i < _numCodecs; i++)
|
||||
|
@ -16,6 +16,7 @@
|
||||
'type': '<(library)',
|
||||
|
||||
'dependencies': [
|
||||
'<(webrtc_root)/../test/test.gyp:test_support',
|
||||
'<(webrtc_root)/../testing/gtest.gyp:gtest',
|
||||
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
|
||||
'<(webrtc_root)/common_video/common_video.gyp:webrtc_vplib',
|
||||
@ -23,6 +24,7 @@
|
||||
|
||||
'include_dirs': [
|
||||
'../interface',
|
||||
'<(webrtc_root)/../testing/gtest/include',
|
||||
'../../../../common_video/interface',
|
||||
],
|
||||
|
||||
|
@ -8,13 +8,17 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "unit_test.h"
|
||||
#include "video_source.h"
|
||||
#include "tick_util.h"
|
||||
#include <cassert>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
#include "tick_util.h"
|
||||
#include "unit_test.h"
|
||||
#include "video_source.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
@ -202,14 +206,15 @@ UnitTest::Setup()
|
||||
_encoder->RegisterEncodeCompleteCallback(_encodeCompleteCallback);
|
||||
_decoder->RegisterDecodeCompleteCallback(_decodeCompleteCallback);
|
||||
|
||||
_source = new VideoSource("test/testFiles/foreman_cif.yuv", kCIF);
|
||||
_source = new VideoSource(webrtc::test::ProjectRootPath() +
|
||||
"resources/foreman_cif.yuv", kCIF);
|
||||
|
||||
_lengthSourceFrame = _source->GetFrameLength();
|
||||
_refFrame = new unsigned char[_lengthSourceFrame];
|
||||
_refDecFrame = new unsigned char[_lengthSourceFrame];
|
||||
_sourceBuffer = new unsigned char [_lengthSourceFrame];
|
||||
_sourceFile = fopen(_source->GetFileName().c_str(), "rb");
|
||||
VIDEO_TEST_EXIT_ON_ERR(_sourceFile != NULL);
|
||||
ASSERT_TRUE(_sourceFile != NULL);
|
||||
|
||||
_inst.maxFramerate = _source->GetFrameRate();
|
||||
_bitRate = 300;
|
||||
@ -220,7 +225,7 @@ UnitTest::Setup()
|
||||
|
||||
// Get input frame.
|
||||
_inputVideoBuffer.VerifyAndAllocate(_lengthSourceFrame);
|
||||
VIDEO_TEST_EXIT_ON_ERR(fread(_refFrame, 1, _lengthSourceFrame, _sourceFile)
|
||||
ASSERT_TRUE(fread(_refFrame, 1, _lengthSourceFrame, _sourceFile)
|
||||
== _lengthSourceFrame);
|
||||
_inputVideoBuffer.CopyBuffer(_lengthSourceFrame, _refFrame);
|
||||
rewind(_sourceFile);
|
||||
@ -232,17 +237,17 @@ UnitTest::Setup()
|
||||
VideoBufferToRawImage(_inputVideoBuffer, image);
|
||||
|
||||
// Ensures our initial parameters are valid.
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
VideoFrameType videoFrameType = kDeltaFrame;
|
||||
_encoder->Encode(image, NULL, &videoFrameType);
|
||||
_refEncFrameLength = WaitForEncodedFrame();
|
||||
VIDEO_TEST_EXIT_ON_ERR(_refEncFrameLength > 0);
|
||||
ASSERT_TRUE(_refEncFrameLength > 0);
|
||||
_refEncFrame = new unsigned char[_refEncFrameLength];
|
||||
memcpy(_refEncFrame, _encodedVideoBuffer.GetBuffer(), _refEncFrameLength);
|
||||
|
||||
// Get a reference decoded frame.
|
||||
_decodedVideoBuffer.VerifyAndAllocate(_lengthSourceFrame);
|
||||
VIDEO_TEST(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
|
||||
if (SetCodecSpecificParameters() != WEBRTC_VIDEO_CODEC_OK)
|
||||
{
|
||||
@ -257,18 +262,18 @@ UnitTest::Setup()
|
||||
{
|
||||
// Insert yet another frame
|
||||
_inputVideoBuffer.VerifyAndAllocate(_lengthSourceFrame);
|
||||
VIDEO_TEST_EXIT_ON_ERR(fread(_refFrame, 1, _lengthSourceFrame,
|
||||
ASSERT_TRUE(fread(_refFrame, 1, _lengthSourceFrame,
|
||||
_sourceFile) == _lengthSourceFrame);
|
||||
_inputVideoBuffer.CopyBuffer(_lengthSourceFrame, _refFrame);
|
||||
_inputVideoBuffer.SetWidth(_source->GetWidth());
|
||||
_inputVideoBuffer.SetHeight(_source->GetHeight());
|
||||
VideoBufferToRawImage(_inputVideoBuffer, image);
|
||||
_encoder->Encode(image, NULL, &videoFrameType);
|
||||
VIDEO_TEST_EXIT_ON_ERR(WaitForEncodedFrame() > 0);
|
||||
ASSERT_TRUE(WaitForEncodedFrame() > 0);
|
||||
}
|
||||
EncodedImage encodedImage;
|
||||
VideoEncodedBufferToEncodedImage(_encodedVideoBuffer, encodedImage);
|
||||
VIDEO_TEST_EXIT_ON_ERR(_decoder->Decode(encodedImage, 0, NULL)
|
||||
ASSERT_TRUE(_decoder->Decode(encodedImage, 0, NULL)
|
||||
== WEBRTC_VIDEO_CODEC_OK);
|
||||
frameLength = WaitForDecodedFrame();
|
||||
_encodedVideoBuffer.Reset();
|
||||
@ -276,7 +281,7 @@ UnitTest::Setup()
|
||||
i++;
|
||||
}
|
||||
rewind(_sourceFile);
|
||||
VIDEO_TEST(frameLength == _lengthSourceFrame);
|
||||
EXPECT_TRUE(frameLength == _lengthSourceFrame);
|
||||
memcpy(_refDecFrame, _decodedVideoBuffer.GetBuffer(), _lengthSourceFrame);
|
||||
}
|
||||
|
||||
@ -343,7 +348,7 @@ UnitTest::Decode()
|
||||
unsigned int frameLength = WaitForDecodedFrame();
|
||||
assert(ret == WEBRTC_VIDEO_CODEC_OK && (frameLength == 0 || frameLength
|
||||
== _lengthSourceFrame));
|
||||
VIDEO_TEST(ret == WEBRTC_VIDEO_CODEC_OK && (frameLength == 0 || frameLength
|
||||
EXPECT_TRUE(ret == WEBRTC_VIDEO_CODEC_OK && (frameLength == 0 || frameLength
|
||||
== _lengthSourceFrame));
|
||||
_encodedVideoBuffer.Reset();
|
||||
_encodedVideoBuffer.UpdateLength(0);
|
||||
@ -365,76 +370,76 @@ UnitTest::Perform()
|
||||
|
||||
//-- Calls before InitEncode() --
|
||||
// We want to revert the initialization done in Setup().
|
||||
VIDEO_TEST(_encoder->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VideoBufferToRawImage(_inputVideoBuffer, inputImage);
|
||||
VIDEO_TEST(_encoder->Encode(inputImage, NULL, &videoFrameType )
|
||||
EXPECT_TRUE(_encoder->Encode(inputImage, NULL, &videoFrameType )
|
||||
== WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
VIDEO_TEST(_encoder->Reset() == WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
EXPECT_TRUE(_encoder->Reset() == WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
|
||||
//-- InitEncode() errors --
|
||||
// Null pointer.
|
||||
VIDEO_TEST(_encoder->InitEncode(NULL, 1, 1440) ==
|
||||
EXPECT_TRUE(_encoder->InitEncode(NULL, 1, 1440) ==
|
||||
WEBRTC_VIDEO_CODEC_ERR_PARAMETER);
|
||||
// bit rate exceeds max bit rate
|
||||
WebRtc_Word32 tmpBitRate = _inst.startBitrate;
|
||||
WebRtc_Word32 tmpMaxBitRate = _inst.maxBitrate;
|
||||
_inst.startBitrate = 4000;
|
||||
_inst.maxBitrate = 3000;
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) ==
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) ==
|
||||
WEBRTC_VIDEO_CODEC_ERR_PARAMETER);
|
||||
_inst.startBitrate = tmpBitRate;
|
||||
_inst.maxBitrate = tmpMaxBitRate; //unspecified value
|
||||
|
||||
// Bad framerate.
|
||||
_inst.maxFramerate = 0;
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) ==
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) ==
|
||||
WEBRTC_VIDEO_CODEC_ERR_PARAMETER);
|
||||
// Seems like we should allow any framerate in range [0, 255].
|
||||
//_inst.frameRate = 100;
|
||||
//VIDEO_TEST(_encoder->InitEncode(&_inst, 1) == -1); // FAILS
|
||||
//EXPECT_TRUE(_encoder->InitEncode(&_inst, 1) == -1); // FAILS
|
||||
_inst.maxFramerate = 30;
|
||||
|
||||
// Bad bitrate.
|
||||
_inst.startBitrate = -1;
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) ==
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) ==
|
||||
WEBRTC_VIDEO_CODEC_ERR_PARAMETER);
|
||||
_inst.maxBitrate = _inst.startBitrate - 1;
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) ==
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) ==
|
||||
WEBRTC_VIDEO_CODEC_ERR_PARAMETER);
|
||||
_inst.maxBitrate = 0;
|
||||
_inst.startBitrate = 300;
|
||||
|
||||
// Bad maxBitRate.
|
||||
_inst.maxBitrate = 200;
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) ==
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) ==
|
||||
WEBRTC_VIDEO_CODEC_ERR_PARAMETER);
|
||||
_inst.maxBitrate = 4000;
|
||||
|
||||
// Bad width.
|
||||
_inst.width = 0;
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) < 0);
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) < 0);
|
||||
// Should there be a width and height cap?
|
||||
//_inst.width = 10000;
|
||||
//VIDEO_TEST(_encoder->InitEncode(&_inst, 1) == -1);
|
||||
//EXPECT_TRUE(_encoder->InitEncode(&_inst, 1) == -1);
|
||||
_inst.width = _source->GetWidth();
|
||||
|
||||
// Bad height.
|
||||
_inst.height = 0;
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) < 0);
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) < 0);
|
||||
_inst.height = _source->GetHeight();
|
||||
|
||||
// Bad number of cores.
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, -1, 1440) ==
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, -1, 1440) ==
|
||||
WEBRTC_VIDEO_CODEC_ERR_PARAMETER);
|
||||
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
|
||||
//-- Encode() errors --
|
||||
|
||||
// inputVideoBuffer unallocated.
|
||||
_inputVideoBuffer.Free();
|
||||
VideoBufferToRawImage(_inputVideoBuffer, inputImage);
|
||||
VIDEO_TEST(_encoder->Encode(inputImage, NULL, &videoFrameType) ==
|
||||
EXPECT_TRUE(_encoder->Encode(inputImage, NULL, &videoFrameType) ==
|
||||
WEBRTC_VIDEO_CODEC_ERR_PARAMETER);
|
||||
_inputVideoBuffer.VerifyAndAllocate(_lengthSourceFrame);
|
||||
_inputVideoBuffer.CopyBuffer(_lengthSourceFrame, _refFrame);
|
||||
@ -446,65 +451,65 @@ UnitTest::Perform()
|
||||
for (int i = 1; i <= 60; i++)
|
||||
{
|
||||
VideoFrameType frameType = !(i % 2) ? kKeyFrame : kDeltaFrame;
|
||||
VIDEO_TEST(_encoder->Encode(inputImage, NULL, &frameType) ==
|
||||
EXPECT_TRUE(_encoder->Encode(inputImage, NULL, &frameType) ==
|
||||
WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(WaitForEncodedFrame() > 0);
|
||||
EXPECT_TRUE(WaitForEncodedFrame() > 0);
|
||||
sleepEvent.Wait(10); // Allow the encoder's queue to realize it's empty.
|
||||
}
|
||||
|
||||
// Init then encode.
|
||||
_encodedVideoBuffer.UpdateLength(0);
|
||||
_encodedVideoBuffer.Reset();
|
||||
VIDEO_TEST(_encoder->Encode(inputImage, NULL, &videoFrameType) ==
|
||||
EXPECT_TRUE(_encoder->Encode(inputImage, NULL, &videoFrameType) ==
|
||||
WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(WaitForEncodedFrame() > 0);
|
||||
EXPECT_TRUE(WaitForEncodedFrame() > 0);
|
||||
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
_encoder->Encode(inputImage, NULL, &videoFrameType);
|
||||
frameLength = WaitForEncodedFrame();
|
||||
VIDEO_TEST(frameLength > 0);
|
||||
VIDEO_TEST(CheckIfBitExact(_refEncFrame, _refEncFrameLength,
|
||||
EXPECT_TRUE(frameLength > 0);
|
||||
EXPECT_TRUE(CheckIfBitExact(_refEncFrame, _refEncFrameLength,
|
||||
_encodedVideoBuffer.GetBuffer(), frameLength) == true);
|
||||
|
||||
// Reset then encode.
|
||||
_encodedVideoBuffer.UpdateLength(0);
|
||||
_encodedVideoBuffer.Reset();
|
||||
VIDEO_TEST(_encoder->Encode(inputImage, NULL, &videoFrameType) ==
|
||||
EXPECT_TRUE(_encoder->Encode(inputImage, NULL, &videoFrameType) ==
|
||||
WEBRTC_VIDEO_CODEC_OK);
|
||||
WaitForEncodedFrame();
|
||||
VIDEO_TEST(_encoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
_encoder->Encode(inputImage, NULL, &videoFrameType);
|
||||
frameLength = WaitForEncodedFrame();
|
||||
VIDEO_TEST(frameLength > 0);
|
||||
VIDEO_TEST(CheckIfBitExact(_refEncFrame, _refEncFrameLength,
|
||||
EXPECT_TRUE(frameLength > 0);
|
||||
EXPECT_TRUE(CheckIfBitExact(_refEncFrame, _refEncFrameLength,
|
||||
_encodedVideoBuffer.GetBuffer(), frameLength) == true);
|
||||
|
||||
// Release then encode.
|
||||
_encodedVideoBuffer.UpdateLength(0);
|
||||
_encodedVideoBuffer.Reset();
|
||||
VIDEO_TEST(_encoder->Encode(inputImage, NULL, &videoFrameType) ==
|
||||
EXPECT_TRUE(_encoder->Encode(inputImage, NULL, &videoFrameType) ==
|
||||
WEBRTC_VIDEO_CODEC_OK);
|
||||
WaitForEncodedFrame();
|
||||
VIDEO_TEST(_encoder->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
_encoder->Encode(inputImage, NULL, &videoFrameType);
|
||||
frameLength = WaitForEncodedFrame();
|
||||
VIDEO_TEST(frameLength > 0);
|
||||
VIDEO_TEST(CheckIfBitExact(_refEncFrame, _refEncFrameLength,
|
||||
EXPECT_TRUE(frameLength > 0);
|
||||
EXPECT_TRUE(CheckIfBitExact(_refEncFrame, _refEncFrameLength,
|
||||
_encodedVideoBuffer.GetBuffer(), frameLength) == true);
|
||||
|
||||
//----- Decoder parameter tests -----
|
||||
|
||||
//-- Calls before InitDecode() --
|
||||
// We want to revert the initialization done in Setup().
|
||||
VIDEO_TEST(_decoder->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VideoEncodedBufferToEncodedImage(_encodedVideoBuffer, encodedImage);
|
||||
VIDEO_TEST(_decoder->Decode(encodedImage, false, NULL) ==
|
||||
EXPECT_TRUE(_decoder->Decode(encodedImage, false, NULL) ==
|
||||
WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
WaitForDecodedFrame();
|
||||
VIDEO_TEST(_decoder->Reset() == WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
VIDEO_TEST(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
EXPECT_TRUE(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
|
||||
if (SetCodecSpecificParameters() != WEBRTC_VIDEO_CODEC_OK)
|
||||
{
|
||||
@ -516,8 +521,8 @@ UnitTest::Perform()
|
||||
_encodedVideoBuffer.Free();
|
||||
VideoEncodedBufferToEncodedImage(_encodedVideoBuffer, encodedImage);
|
||||
encodedImage._length = 10; // Buffer NULL but length > 0
|
||||
VIDEO_TEST(_decoder->Decode(encodedImage, false, NULL) ==
|
||||
WEBRTC_VIDEO_CODEC_ERR_PARAMETER);
|
||||
EXPECT_EQ(_decoder->Decode(encodedImage, false, NULL),
|
||||
WEBRTC_VIDEO_CODEC_ERR_PARAMETER);
|
||||
_encodedVideoBuffer.VerifyAndAllocate(_lengthSourceFrame);
|
||||
|
||||
//----- Decoder stress tests -----
|
||||
@ -527,24 +532,24 @@ UnitTest::Perform()
|
||||
// We either expect an error, or at the least, no output.
|
||||
// This relies on the codec's ability to detect an erroneous bitstream.
|
||||
/*
|
||||
VIDEO_TEST(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
if (SetCodecSpecificParameters() != WEBRTC_VIDEO_CODEC_OK)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
VIDEO_TEST_EXIT_ON_ERR(fread(tmpBuf, 1, _refEncFrameLength, _sourceFile)
|
||||
ASSERT_TRUE(fread(tmpBuf, 1, _refEncFrameLength, _sourceFile)
|
||||
== _refEncFrameLength);
|
||||
_encodedVideoBuffer.CopyBuffer(_refEncFrameLength, tmpBuf);
|
||||
VideoEncodedBufferToEncodedImage(_encodedVideoBuffer, encodedImage);
|
||||
FillDecoderSpecificInfo(encodedImage);
|
||||
int ret = _decoder->Decode(encodedImage, false, _decoderSpecificInfo);
|
||||
VIDEO_TEST(ret <= 0);
|
||||
EXPECT_TRUE(ret <= 0);
|
||||
if (ret == 0)
|
||||
{
|
||||
VIDEO_TEST(WaitForDecodedFrame() == 0);
|
||||
EXPECT_TRUE(WaitForDecodedFrame() == 0);
|
||||
}
|
||||
|
||||
memset(tmpBuf, 0, _refEncFrameLength);
|
||||
@ -552,10 +557,10 @@ UnitTest::Perform()
|
||||
VideoEncodedBufferToEncodedImage(_encodedVideoBuffer, encodedImage);
|
||||
FillDecoderSpecificInfo(encodedImage);
|
||||
ret = _decoder->Decode(encodedImage, false, _decoderSpecificInfo);
|
||||
VIDEO_TEST(ret <= 0);
|
||||
EXPECT_TRUE(ret <= 0);
|
||||
if (ret == 0)
|
||||
{
|
||||
VIDEO_TEST(WaitForDecodedFrame() == 0);
|
||||
EXPECT_TRUE(WaitForDecodedFrame() == 0);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -565,7 +570,7 @@ UnitTest::Perform()
|
||||
_encodedVideoBuffer.CopyBuffer(_refEncFrameLength, _refEncFrame);
|
||||
|
||||
// Init then decode.
|
||||
VIDEO_TEST(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
if (SetCodecSpecificParameters() != WEBRTC_VIDEO_CODEC_OK)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
@ -577,11 +582,11 @@ UnitTest::Perform()
|
||||
_decoder->Decode(encodedImage, false, NULL);
|
||||
frameLength = WaitForDecodedFrame();
|
||||
}
|
||||
VIDEO_TEST(CheckIfBitExact(_decodedVideoBuffer.GetBuffer(), frameLength,
|
||||
EXPECT_TRUE(CheckIfBitExact(_decodedVideoBuffer.GetBuffer(), frameLength,
|
||||
_refDecFrame, _lengthSourceFrame) == true);
|
||||
|
||||
// Reset then decode.
|
||||
VIDEO_TEST(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
frameLength = 0;
|
||||
VideoEncodedBufferToEncodedImage(_encodedVideoBuffer, encodedImage);
|
||||
while (frameLength == 0)
|
||||
@ -589,7 +594,7 @@ UnitTest::Perform()
|
||||
_decoder->Decode(encodedImage, false, NULL);
|
||||
frameLength = WaitForDecodedFrame();
|
||||
}
|
||||
VIDEO_TEST(CheckIfBitExact(_decodedVideoBuffer.GetBuffer(), frameLength,
|
||||
EXPECT_TRUE(CheckIfBitExact(_decodedVideoBuffer.GetBuffer(), frameLength,
|
||||
_refDecFrame, _lengthSourceFrame) == true);
|
||||
|
||||
// Decode with other size, reset, then decode with original size again
|
||||
@ -597,7 +602,7 @@ UnitTest::Perform()
|
||||
{
|
||||
// assert that input frame size is a factor of two, so that we can use
|
||||
// quarter size below
|
||||
VIDEO_TEST((_inst.width % 2 == 0) && (_inst.height % 2 == 0));
|
||||
EXPECT_TRUE((_inst.width % 2 == 0) && (_inst.height % 2 == 0));
|
||||
|
||||
VideoCodec tempInst;
|
||||
memcpy(&tempInst, &_inst, sizeof(VideoCodec));
|
||||
@ -605,18 +610,18 @@ UnitTest::Perform()
|
||||
tempInst.height /= 2;
|
||||
|
||||
// Encode reduced (quarter) frame size
|
||||
VIDEO_TEST(_encoder->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(_encoder->InitEncode(&tempInst, 1, 1440) ==
|
||||
EXPECT_TRUE(_encoder->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->InitEncode(&tempInst, 1, 1440) ==
|
||||
WEBRTC_VIDEO_CODEC_OK);
|
||||
RawImage tempInput(inputImage._buffer, inputImage._length/4,
|
||||
inputImage._size/4);
|
||||
VideoFrameType videoFrameType = kDeltaFrame;
|
||||
_encoder->Encode(tempInput, NULL, &videoFrameType);
|
||||
frameLength = WaitForEncodedFrame();
|
||||
VIDEO_TEST(frameLength > 0);
|
||||
EXPECT_TRUE(frameLength > 0);
|
||||
|
||||
// Reset then decode.
|
||||
VIDEO_TEST(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
frameLength = 0;
|
||||
VideoEncodedBufferToEncodedImage(_encodedVideoBuffer, encodedImage);
|
||||
while (frameLength == 0)
|
||||
@ -626,15 +631,15 @@ UnitTest::Perform()
|
||||
}
|
||||
|
||||
// Encode original frame again
|
||||
VIDEO_TEST(_encoder->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) ==
|
||||
EXPECT_TRUE(_encoder->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) ==
|
||||
WEBRTC_VIDEO_CODEC_OK);
|
||||
_encoder->Encode(inputImage, NULL, &videoFrameType);
|
||||
frameLength = WaitForEncodedFrame();
|
||||
VIDEO_TEST(frameLength > 0);
|
||||
EXPECT_TRUE(frameLength > 0);
|
||||
|
||||
// Reset then decode original frame again.
|
||||
VIDEO_TEST(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
frameLength = 0;
|
||||
VideoEncodedBufferToEncodedImage(_encodedVideoBuffer, encodedImage);
|
||||
while (frameLength == 0)
|
||||
@ -644,14 +649,14 @@ UnitTest::Perform()
|
||||
}
|
||||
|
||||
// check that decoded frame matches with reference
|
||||
VIDEO_TEST(CheckIfBitExact(_decodedVideoBuffer.GetBuffer(), frameLength,
|
||||
EXPECT_TRUE(CheckIfBitExact(_decodedVideoBuffer.GetBuffer(), frameLength,
|
||||
_refDecFrame, _lengthSourceFrame) == true);
|
||||
|
||||
}
|
||||
|
||||
// Release then decode.
|
||||
VIDEO_TEST(_decoder->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
if (SetCodecSpecificParameters() != WEBRTC_VIDEO_CODEC_OK)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
@ -663,7 +668,7 @@ UnitTest::Perform()
|
||||
_decoder->Decode(encodedImage, false, NULL);
|
||||
frameLength = WaitForDecodedFrame();
|
||||
}
|
||||
VIDEO_TEST(CheckIfBitExact(_decodedVideoBuffer.GetBuffer(), frameLength,
|
||||
EXPECT_TRUE(CheckIfBitExact(_decodedVideoBuffer.GetBuffer(), frameLength,
|
||||
_refDecFrame, _lengthSourceFrame) == true);
|
||||
_encodedVideoBuffer.UpdateLength(0);
|
||||
_encodedVideoBuffer.Reset();
|
||||
@ -676,10 +681,10 @@ UnitTest::Perform()
|
||||
_inst.maxBitrate = 0;
|
||||
|
||||
//-- Timestamp propagation --
|
||||
VIDEO_TEST(_encoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
if (SetCodecSpecificParameters() != WEBRTC_VIDEO_CODEC_OK)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
@ -697,15 +702,15 @@ UnitTest::Perform()
|
||||
_inputVideoBuffer.SetTimeStamp(frames);
|
||||
VideoBufferToRawImage(_inputVideoBuffer, inputImage);
|
||||
VideoFrameType videoFrameType = kDeltaFrame;
|
||||
VIDEO_TEST_EXIT_ON_ERR(_encoder->Encode(inputImage,
|
||||
ASSERT_TRUE(_encoder->Encode(inputImage,
|
||||
NULL,
|
||||
&videoFrameType) ==
|
||||
WEBRTC_VIDEO_CODEC_OK);
|
||||
frameLength = WaitForEncodedFrame();
|
||||
//VIDEO_TEST_EXIT_ON_ERR(frameLength);
|
||||
VIDEO_TEST(frameLength > 0);
|
||||
//ASSERT_TRUE(frameLength);
|
||||
EXPECT_TRUE(frameLength > 0);
|
||||
encTimeStamp = _encodedVideoBuffer.GetTimeStamp();
|
||||
VIDEO_TEST(_inputVideoBuffer.GetTimeStamp() ==
|
||||
EXPECT_TRUE(_inputVideoBuffer.GetTimeStamp() ==
|
||||
static_cast<unsigned>(encTimeStamp));
|
||||
|
||||
frameLength = Decode();
|
||||
@ -719,13 +724,13 @@ UnitTest::Perform()
|
||||
{
|
||||
encTimeStamp = 0;
|
||||
}
|
||||
VIDEO_TEST(_decodedVideoBuffer.GetTimeStamp() ==
|
||||
EXPECT_TRUE(_decodedVideoBuffer.GetTimeStamp() ==
|
||||
static_cast<unsigned>(encTimeStamp));
|
||||
frames++;
|
||||
sleepEvent.Wait(33);
|
||||
}
|
||||
delete &sleepEvent;
|
||||
VIDEO_TEST_EXIT_ON_ERR(feof(_sourceFile) != 0);
|
||||
ASSERT_TRUE(feof(_sourceFile) != 0);
|
||||
rewind(_sourceFile);
|
||||
|
||||
RateControlTests();
|
||||
@ -745,10 +750,10 @@ UnitTest::RateControlTests()
|
||||
// Do not specify maxBitRate (as in ViE).
|
||||
_inst.maxBitrate = 0;
|
||||
//-- Verify rate control --
|
||||
VIDEO_TEST(_encoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
// add: should also be 0, and 1
|
||||
const int bitRate[] =
|
||||
{100, 200, 300, 400, 500, 600, 800, 1000, 2000, 3000, 4000, 10000};
|
||||
@ -784,12 +789,10 @@ UnitTest::RateControlTests()
|
||||
static_cast<float>(_inst.maxFramerate)));
|
||||
VideoBufferToRawImage(_inputVideoBuffer, inputImage);
|
||||
VideoFrameType videoFrameType = kDeltaFrame;
|
||||
VIDEO_TEST_EXIT_ON_ERR(_encoder->Encode(inputImage,
|
||||
NULL,
|
||||
&videoFrameType) ==
|
||||
WEBRTC_VIDEO_CODEC_OK);
|
||||
ASSERT_EQ(_encoder->Encode(inputImage, NULL, &videoFrameType),
|
||||
WEBRTC_VIDEO_CODEC_OK);
|
||||
frameLength = WaitForEncodedFrame();
|
||||
VIDEO_TEST_EXIT_ON_ERR(frameLength >= 0);
|
||||
ASSERT_GE(frameLength, 0u);
|
||||
totalBytes += frameLength;
|
||||
frames++;
|
||||
|
||||
@ -805,10 +808,10 @@ UnitTest::RateControlTests()
|
||||
// Test for close match over reasonable range.
|
||||
if (_bitRate >= 100 && _bitRate <= 2500)
|
||||
{
|
||||
VIDEO_TEST(abs(WebRtc_Word32(actualBitrate - _bitRate)) <
|
||||
EXPECT_TRUE(abs(WebRtc_Word32(actualBitrate - _bitRate)) <
|
||||
0.1 * _bitRate); // for VP8
|
||||
}
|
||||
VIDEO_TEST_EXIT_ON_ERR(feof(_sourceFile) != 0);
|
||||
ASSERT_TRUE(feof(_sourceFile) != 0);
|
||||
rewind(_sourceFile);
|
||||
}
|
||||
}
|
||||
|
@ -24,30 +24,6 @@
|
||||
#pragma warning(disable : 4127)
|
||||
#endif
|
||||
|
||||
#define VIDEO_TEST(expr) \
|
||||
do \
|
||||
{ \
|
||||
_tests++; \
|
||||
if (!(expr)) \
|
||||
{ \
|
||||
fprintf(stderr, "Error at line %i of %s\nAssertion failed: %s\n\n",\
|
||||
__LINE__, __FILE__, #expr); \
|
||||
_errors++; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define VIDEO_TEST_EXIT_ON_ERR(expr) \
|
||||
do \
|
||||
{ \
|
||||
if (!(expr)) \
|
||||
{ \
|
||||
fprintf(stderr, "Error at line %i of %s\nAssertion failed: %s\n", \
|
||||
__LINE__, __FILE__, #expr); \
|
||||
fprintf(stderr, "Exiting...\n\n"); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
class VideoSource;
|
||||
class UnitTestEncodeCompleteCallback;
|
||||
class UnitTestDecodeCompleteCallback;
|
||||
|
@ -9,13 +9,16 @@
|
||||
*/
|
||||
|
||||
#include "video_source.h"
|
||||
#include "vplib.h"
|
||||
#include <cassert>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cassert>
|
||||
|
||||
#include "testsupport/fileutils.h"
|
||||
#include "vplib.h"
|
||||
|
||||
VideoSource::VideoSource()
|
||||
:
|
||||
_fileName("../../../../testFiles/foreman.yuv"),
|
||||
_fileName(webrtc::test::ProjectRootPath() + "resources/foreman_cif.yuv"),
|
||||
_width(352),
|
||||
_height(288),
|
||||
_type(webrtc::kI420),
|
||||
|
@ -65,6 +65,8 @@
|
||||
'webrtc_vp8',
|
||||
'<(webrtc_root)/common_video/common_video.gyp:webrtc_vplib',
|
||||
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
|
||||
'<(webrtc_root)/../test/test.gyp:test_support',
|
||||
'<(webrtc_root)/../testing/gtest.gyp:gtest',
|
||||
],
|
||||
'sources': [
|
||||
# header files
|
||||
|
@ -9,23 +9,27 @@
|
||||
*/
|
||||
|
||||
#include "benchmark.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
#include "vp8.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
VP8Benchmark::VP8Benchmark()
|
||||
:
|
||||
Benchmark("VP8Benchmark", "VP8 benchmark over a range of test cases", "../../VP8Benchmark.txt", "VP8")
|
||||
Benchmark("VP8Benchmark", "VP8 benchmark over a range of test cases",
|
||||
webrtc::test::OutputPath() + "VP8Benchmark.txt", "VP8")
|
||||
{
|
||||
}
|
||||
|
||||
VP8Benchmark::VP8Benchmark(std::string name, std::string description)
|
||||
:
|
||||
Benchmark(name, description, "../../VP8Benchmark.txt", "VP8")
|
||||
Benchmark(name, description, webrtc::test::OutputPath() + "VP8Benchmark.txt",
|
||||
"VP8")
|
||||
{
|
||||
}
|
||||
|
||||
VP8Benchmark::VP8Benchmark(std::string name, std::string description, std::string resultsFileName)
|
||||
VP8Benchmark::VP8Benchmark(std::string name, std::string description,
|
||||
std::string resultsFileName)
|
||||
:
|
||||
Benchmark(name, description, resultsFileName, "VP8")
|
||||
{
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <string.h> // memcmp
|
||||
#include <time.h>
|
||||
|
||||
#include "testsupport/fileutils.h"
|
||||
|
||||
VP8DualDecoderTest::VP8DualDecoderTest(float bitRate)
|
||||
:
|
||||
VP8NormalAsyncTest(bitRate)
|
||||
@ -41,7 +43,7 @@ VP8DualDecoderTest::~VP8DualDecoderTest()
|
||||
void
|
||||
VP8DualDecoderTest::Perform()
|
||||
{
|
||||
_inname = "test/testFiles/foreman_cif.yuv";
|
||||
_inname = webrtc::test::ProjectRootPath() + "resources/foreman_cif.yuv";
|
||||
CodecSettings(352, 288, 30, _bitRate);
|
||||
Setup();
|
||||
_inputVideoBuffer.VerifyAndAllocate(_lengthSourceFrame);
|
||||
|
@ -8,16 +8,18 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "packet_loss_test.h"
|
||||
#include "benchmark.h"
|
||||
#include "unit_test.h"
|
||||
#include "normal_async_test.h"
|
||||
#include "dual_decoder_test.h"
|
||||
#include "vp8.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "benchmark.h"
|
||||
#include "dual_decoder_test.h"
|
||||
#include "normal_async_test.h"
|
||||
#include "packet_loss_test.h"
|
||||
#include "unit_test.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
#include "vp8.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
void PopulateTests(std::vector<Test*>* tests)
|
||||
@ -36,7 +38,8 @@ int main()
|
||||
std::vector<Test*> tests;
|
||||
PopulateTests(&tests);
|
||||
std::fstream log;
|
||||
log.open("../../TestLog.txt", std::fstream::out | std::fstream::app);
|
||||
std::string log_file = webrtc::test::OutputPath() + "VP8_test_log.txt";
|
||||
log.open(log_file.c_str(), std::fstream::out | std::fstream::app);
|
||||
std::vector<Test*>::iterator it;
|
||||
for (it = tests.begin() ; it < tests.end(); it++)
|
||||
{
|
||||
|
@ -9,11 +9,14 @@
|
||||
*/
|
||||
|
||||
#include "unit_test.h"
|
||||
#include "../../../test_framework/video_source.h"
|
||||
#include "vp8.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "../../../test_framework/video_source.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
#include "vp8.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
VP8UnitTest::VP8UnitTest()
|
||||
@ -35,7 +38,7 @@ VP8UnitTest::Print()
|
||||
|
||||
// GetVersion tests.
|
||||
|
||||
VIDEO_TEST(_encoder->Version(versionStr, sizeof(versionStr)) > 0);
|
||||
EXPECT_TRUE(_encoder->Version(versionStr, sizeof(versionStr)) > 0);
|
||||
// printf("\n%s", versionStr);
|
||||
// UnitTest::Print();
|
||||
}
|
||||
@ -44,7 +47,7 @@ WebRtc_UWord32
|
||||
VP8UnitTest::CodecSpecific_SetBitrate(WebRtc_UWord32 bitRate, WebRtc_UWord32 /*frameRate*/)
|
||||
{
|
||||
int rate = _encoder->SetRates(bitRate, _inst.maxFramerate);
|
||||
VIDEO_TEST_EXIT_ON_ERR(rate >= 0);
|
||||
EXPECT_TRUE(rate >= 0);
|
||||
return rate;
|
||||
}
|
||||
|
||||
@ -87,11 +90,13 @@ VP8UnitTest::Perform()
|
||||
|
||||
//----- Encoder parameter tests -----
|
||||
//-- Calls before InitEncode() --
|
||||
VIDEO_TEST(enc->Release() == WEBRTC_VIDEO_CODEC_OK);
|
||||
VIDEO_TEST(enc->SetRates(_bitRate, _inst.maxFramerate) == WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
EXPECT_EQ(enc->Release(), WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_EQ(enc->SetRates(_bitRate, _inst.maxFramerate),
|
||||
WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
|
||||
VIDEO_TEST(enc->SetRates(_bitRate, _inst.maxFramerate) == WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
// VIDEO_TEST(enc->GetCodecConfigParameters(configParameters, sizeof(configParameters)) ==
|
||||
EXPECT_EQ(enc->SetRates(_bitRate, _inst.maxFramerate),
|
||||
WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
// EXPECT_TRUE(enc->GetCodecConfigParameters(configParameters, sizeof(configParameters)) ==
|
||||
// WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
|
||||
|
||||
@ -105,7 +110,7 @@ VP8UnitTest::Perform()
|
||||
codecInst.maxFramerate = 30;
|
||||
codecInst.startBitrate = 300;
|
||||
codecInst.codecSpecific.VP8.complexity = kComplexityNormal;
|
||||
VIDEO_TEST(enc->InitEncode(&codecInst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_EQ(enc->InitEncode(&codecInst, 1, 1440), WEBRTC_VIDEO_CODEC_OK);
|
||||
|
||||
|
||||
//-- Test two problematic level settings --
|
||||
@ -118,7 +123,7 @@ VP8UnitTest::Perform()
|
||||
codecInst.maxFramerate = 30;
|
||||
codecInst.codecSpecific.VP8.complexity = kComplexityNormal;
|
||||
codecInst.startBitrate = 300;
|
||||
VIDEO_TEST(enc->InitEncode(&codecInst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_EQ(enc->InitEncode(&codecInst, 1, 1440), WEBRTC_VIDEO_CODEC_OK);
|
||||
|
||||
// Settings not correct for this profile
|
||||
strncpy(codecInst.plName, "VP8", 31);
|
||||
@ -130,36 +135,37 @@ VP8UnitTest::Perform()
|
||||
codecInst.maxFramerate = 15;
|
||||
codecInst.codecSpecific.VP8.complexity = kComplexityNormal;
|
||||
codecInst.startBitrate = 300;
|
||||
//VIDEO_TEST(enc->InitEncode(&codecInst, 1, 1440) == WEBRTC_VIDEO_CODEC_LEVEL_EXCEEDED);
|
||||
//EXPECT_TRUE(enc->InitEncode(&codecInst, 1, 1440) == WEBRTC_VIDEO_CODEC_LEVEL_EXCEEDED);
|
||||
|
||||
VIDEO_TEST_EXIT_ON_ERR(enc->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
ASSERT_EQ(enc->InitEncode(&_inst, 1, 1440), WEBRTC_VIDEO_CODEC_OK);
|
||||
|
||||
|
||||
//-- ProcessNewBitrate() errors --
|
||||
// Bad bitrate.
|
||||
VIDEO_TEST(enc->SetRates(_inst.maxBitrate + 1, _inst.maxFramerate) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_EQ(enc->SetRates(_inst.maxBitrate + 1, _inst.maxFramerate),
|
||||
WEBRTC_VIDEO_CODEC_OK);
|
||||
|
||||
// Signaling not used.
|
||||
|
||||
// Bad packetloss.
|
||||
// VIDEO_TEST(enc->SetPacketLoss(300) < 0);
|
||||
// EXPECT_TRUE(enc->SetPacketLoss(300) < 0);
|
||||
|
||||
//----- Decoder parameter tests -----
|
||||
//-- Calls before InitDecode() --
|
||||
VIDEO_TEST(dec->Release() == 0);
|
||||
VIDEO_TEST_EXIT_ON_ERR(dec->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_TRUE(dec->Release() == 0);
|
||||
ASSERT_TRUE(dec->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
|
||||
|
||||
//-- SetCodecConfigParameters() errors --
|
||||
unsigned char tmpBuf[128];
|
||||
VIDEO_TEST(dec->SetCodecConfigParameters(NULL, sizeof(tmpBuf)) == -1);
|
||||
VIDEO_TEST(dec->SetCodecConfigParameters(tmpBuf, 1) == -1);
|
||||
EXPECT_TRUE(dec->SetCodecConfigParameters(NULL, sizeof(tmpBuf)) == -1);
|
||||
EXPECT_TRUE(dec->SetCodecConfigParameters(tmpBuf, 1) == -1);
|
||||
// Garbage data.
|
||||
VIDEO_TEST(dec->SetCodecConfigParameters(tmpBuf, sizeof(tmpBuf)) == -1);
|
||||
EXPECT_TRUE(dec->SetCodecConfigParameters(tmpBuf, sizeof(tmpBuf)) == -1);
|
||||
|
||||
//----- Function tests -----
|
||||
outFileName = "../../" + _source->GetName() + "-errResTest.yuv";
|
||||
outFileName = webrtc::test::OutputPath() + _source->GetName() + "-errResTest.yuv";
|
||||
outFile = fopen(outFileName.c_str(), "wb");
|
||||
VIDEO_TEST_EXIT_ON_ERR(outFile != NULL);
|
||||
ASSERT_TRUE(outFile != NULL);
|
||||
|
||||
UnitTest::Perform();
|
||||
Teardown();
|
||||
|
Loading…
x
Reference in New Issue
Block a user