Make all video_coding tests use the resources and output directories.

BUG=
TEST=

Review URL: http://webrtc-codereview.appspot.com/298001

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1060 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org 2011-11-30 14:23:39 +00:00
parent d2daa5c13e
commit ac2c677bf6
14 changed files with 111 additions and 57 deletions

View File

@ -21,6 +21,7 @@
#include "test_callbacks.h"
#include "test_macros.h"
#include "test_util.h"
#include "testsupport/fileutils.h"
#include "testsupport/metrics/video_metrics.h"
#include "vp8.h" // for external codecs test
@ -60,11 +61,11 @@ CodecDataBaseTest::Setup(CmdArgs& args)
_frameRate = args.frameRate;
_lengthSourceFrame = 3*_width*_height/2;
if (args.outputFile.compare(""))
_outname = "CDBtest_decoded.yuv";
_outname = test::OutputPath() + "CDBtest_decoded.yuv";
else
_outname = args.outputFile;
_outname = args.outputFile;
_encodedName = "../CDBtest_encoded.vp8";
_encodedName = test::OutputPath() + "CDBtest_encoded.vp8";
if ((_sourceFile = fopen(_inname.c_str(), "rb")) == NULL)
{
@ -147,9 +148,10 @@ CodecDataBaseTest::Perform(CmdArgs& args)
}
printf("\n\nVerify that all requested codecs are used\n \n \n");
// testing with first codec registered
VideoCodingModule::Codec(0, &sendCodec);
// Testing with VP8.
VideoCodingModule::Codec(kVideoCodecVP8, &sendCodec);
_vcm->RegisterSendCodec(&sendCodec, 1, 1440);
_encodeCompleteCallback->SetCodecType(kRTPVideoVP8);
_vcm->InitializeReceiver();
TEST (_vcm->AddVideoFrame(sourceFrame) == VCM_OK );
_vcm->InitializeSender();
@ -242,6 +244,8 @@ CodecDataBaseTest::Perform(CmdArgs& args)
// and because no frame type request callback has been registered.
TEST(_vcm->Decode() == VCM_MISSING_CALLBACK);
TEST(_vcm->FrameTypeRequest(kVideoFrameKey, 0) == VCM_OK);
_timeStamp += (WebRtc_UWord32)(9e4 / _frameRate);
sourceFrame.SetTimeStamp(_timeStamp);
TEST(_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
TEST(_vcm->Decode() == VCM_OK);
@ -288,7 +292,7 @@ CodecDataBaseTest::Perform(CmdArgs& args)
encodeCallCDT->RegisterReceiverVCM(_vcm);
if (VideoCodingModule::NumberOfCodecs() > 0)
{
// registrating all available decoders
// Register all available decoders.
int i, j;
//double psnr;
sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
@ -320,6 +324,11 @@ CodecDataBaseTest::Perform(CmdArgs& args)
encodeCallCDT->SetCodecType(ConvertCodecType(sendCodec.plName));
TEST(_vcm->RegisterSendCodec(&sendCodec, 1, 1440) == VCM_OK);
// We disable the frame dropper to avoid dropping frames due to
// bad rate control. This isn't a codec performance test, and the
// I420 codec is expected to produce too many bits.
_vcm->EnableFrameDropper(false);
printf("Encoding with %s \n\n", sendCodec.plName);
for (j=0; j < int(300/VideoCodingModule::NumberOfCodecs()); j++)// assuming 300 frames, NumberOfCodecs <= 10
{
@ -357,6 +366,14 @@ CodecDataBaseTest::Perform(CmdArgs& args)
// decode what's left in the buffer....
_vcm->Decode();
_vcm->Decode();
// Don't measure PSNR for I420 since it will be perfect.
if (sendCodec.codecType != kVideoCodecI420) {
QualityMetricsResult psnr;
PsnrFromFiles(_inname.c_str(), _outname.c_str(), _width, _height, &psnr);
printf("\n @ %d KBPS: ", sendCodec.startBitrate);
printf("PSNR from encoder-decoder send-receive control test"
"is %f\n\n", psnr.average);
}
} // end: iterate codecs
rewind(_sourceFile);
sourceFrame.Free();
@ -365,10 +382,6 @@ CodecDataBaseTest::Perform(CmdArgs& args)
delete encodeCallCDT;
// closing and calculating PSNR for prior encoder-decoder test
TearDown(); // closing open files
QualityMetricsResult psnr;
PsnrFromFiles(_inname.c_str(), _outname.c_str(), _width, _height, &psnr);
printf(" \n @ %d KBPS: ", sendCodec.startBitrate);
printf("PSNR from encoder-decoder send-receive control test is %f \n \n", psnr.average);
} // end of #codecs >1
delete waitEvent;

View File

@ -52,14 +52,15 @@ int DecodeFromStorageTest(CmdArgs& args)
std::string rtpFilename = args.inputFile;
std::string outFilename = args.outputFile;
if (outFilename == "")
outFilename = "DecodeFromStorage.yuv";
outFilename = test::OutputPath() + "DecodeFromStorage.yuv";
FrameReceiveCallback receiveCallback(outFilename.c_str());
// END Settings
Trace::CreateTrace();
Trace::SetTraceFile("decodeFromStorageTestTrace.txt");
Trace::SetTraceFile(
(test::OutputPath() + "decodeFromStorageTestTrace.txt").c_str());
Trace::SetLevelFilter(webrtc::kTraceAll);

View File

@ -23,14 +23,15 @@ enum { kMaxWaitEncTimeMs = 100 };
int GenericCodecTest::RunTest(CmdArgs& args)
{
// Don't run this test with debug time
#if !defined(TICK_TIME_DEBUG) || !defined(EVENT_DEBUG)
printf("\n\nEnable debug time to run this test!\n\n");
return -1;
#endif
VideoCodingModule* vcm = VideoCodingModule::Create(1);
GenericCodecTest* get = new GenericCodecTest(vcm);
Trace::CreateTrace();
Trace::SetTraceFile("genericCodecTestTrace.txt");
Trace::SetTraceFile(
(test::OutputPath() + "genericCodecTestTrace.txt").c_str());
Trace::SetLevelFilter(webrtc::kTraceAll);
get->Perform(args);
Trace::ReturnTrace();
@ -62,10 +63,10 @@ GenericCodecTest::Setup(CmdArgs& args)
_inname= args.inputFile;
if (args.outputFile.compare(""))
_outname = "GCTest_decoded.yuv";
_outname = test::OutputPath() + "GCTest_decoded.yuv";
else
_outname = args.outputFile;
_encodedName = "../GCTest_encoded.vp8";
_encodedName = test::OutputPath() + "GCTest_encoded.vp8";
_width = args.width;
_height = args.height;
_frameRate = args.frameRate;
@ -241,6 +242,11 @@ GenericCodecTest::Perform(CmdArgs& args)
TEST(_vcm->RegisterFrameTypeCallback(&frameTypeCallback) == VCM_OK);
TEST(_vcm->RegisterReceiveCodec(&sendCodec, 1) == VCM_OK);
TEST(_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
_timeStamp += (WebRtc_UWord32)(9e4 / static_cast<float>(_frameRate));
sourceFrame.SetTimeStamp(_timeStamp);
// First packet of a subsequent frame required before the jitter buffer
// will allow decoding an incomplete frame.
TEST(_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
TEST(_vcm->Decode() == VCM_OK);
printf("API tests complete \n");
@ -263,7 +269,7 @@ GenericCodecTest::Perform(CmdArgs& args)
rewind(_sourceFile);
sourceFrame.Free();
sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
const float bitRate[] = {100, 400, 600, 1000, 2000, 3000};
const float bitRate[] = {100, 400, 600, 1000, 2000};
const float nBitrates = sizeof(bitRate)/sizeof(*bitRate);
float _bitRate = 0;
int _frameCnt = 0;
@ -305,7 +311,8 @@ GenericCodecTest::Perform(CmdArgs& args)
_encodeCompleteCallback->Initialize();
sendStats.SetTargetFrameRate(static_cast<WebRtc_UWord32>(_frameRate));
_vcm->RegisterSendStatisticsCallback(&sendStats);
while (fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0)
while (fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) ==
_lengthSourceFrame)
{
_frameCnt++;
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
@ -465,9 +472,9 @@ GenericCodecTest::Perform(CmdArgs& args)
sendStats.SetTargetFrameRate(static_cast<WebRtc_UWord32>(_frameRate));
_vcm->RegisterSendStatisticsCallback(&sendStats);
rewind(_sourceFile);
while (!feof(_sourceFile))
while (fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) ==
_lengthSourceFrame)
{
TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width);

View File

@ -32,7 +32,7 @@ using namespace webrtc;
int MediaOptTest::RunTest(int testNum, CmdArgs& args)
{
Trace::CreateTrace();
Trace::SetTraceFile("mediaOptTestTrace.txt");
Trace::SetTraceFile((test::OutputPath() + "mediaOptTestTrace.txt").c_str());
Trace::SetLevelFilter(webrtc::kTraceAll);
VideoCodingModule* vcm = VideoCodingModule::Create(1);
MediaOptTest* mot = new MediaOptTest(vcm);
@ -98,10 +98,11 @@ MediaOptTest::Setup(int testType, CmdArgs& args)
// test parameters
_inname = args.inputFile;
if (args.outputFile == "")
_outname = "../MOTest_out.vp8";
_outname = test::OutputPath() + "MOTest_out.vp8";
else
_outname = args.outputFile;
_actualSourcename = "../MOTestSource.yuv"; // actual source after frame dropping
// actual source after frame dropping
_actualSourcename = test::OutputPath() + "MOTestSource.yuv";
_codecName = args.codecName;
_sendCodecType = args.codecType;
_width = args.width;
@ -163,7 +164,8 @@ MediaOptTest::Setup(int testType, CmdArgs& args)
/* test settings end*/
_lengthSourceFrame = 3*_width*_height/2;
_log.open("../VCM_MediaOptLog.txt", std::fstream::out | std::fstream::app);
_log.open((test::OutputPath() + "VCM_MediaOptLog.txt").c_str(),
std::fstream::out | std::fstream::app);
return;
}
@ -384,12 +386,16 @@ MediaOptTest::RTTest()
_rttMS = 20;
_renderDelayMs = 0;
_outname = "../RTMOTest_out.yuv"; // same out name for all
_actualSourcename = "../RTMOTestSource.yuv"; // actual source after frame dropping
// same out name for all
_outname = test::OutputPath() + "RTMOTest_out.yuv";
// actual source after frame dropping
_actualSourcename = test::OutputPath() + "RTMOTestSource.yuv";
_codecName = "VP8"; // for now just this one - later iterate over all codec types
_log.open("../VCM_RTMediaOptLog.txt", std::fstream::out | std::fstream::app);
_outputRes=fopen("../VCM_MediaOpt","ab");
_log.open((test::OutputPath() + "/VCM_RTMediaOptLog.txt").c_str(),
std::fstream::out | std::fstream::app);
_outputRes=fopen((test::OutputPath() + "VCM_MediaOptResults.txt").c_str(),
"ab");
//char filename[128];
/* test settings end*/

View File

@ -55,7 +55,8 @@ MainSenderThread(void* obj)
}
if (feof(state->_sourceFile) == 0)
{
TEST(fread(tmpBuffer, 1, lengthSourceFrame,state->_sourceFile) > 0);
TEST(fread(tmpBuffer, 1, lengthSourceFrame,state->_sourceFile) > 0 ||
feof(state->_sourceFile));
state->_frameCnt++;
sourceFrame.CopyFrame(lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(height);
@ -96,7 +97,7 @@ int MTRxTxTest(CmdArgs& args)
std::string inname = args.inputFile;
std::string outname;
if (args.outputFile == "")
outname = "../MTRxTxTest_decoded.yuv";
outname = test::OutputPath() + "MTRxTxTest_decoded.yuv";
else
outname = args.outputFile;
@ -120,7 +121,7 @@ int MTRxTxTest(CmdArgs& args)
// Set up trace
Trace::CreateTrace();
Trace::SetTraceFile("MTRxTxTestTrace.txt");
Trace::SetTraceFile((test::OutputPath() + "MTRxTxTestTrace.txt").c_str());
Trace::SetLevelFilter(webrtc::kTraceAll);
FILE* sourceFile;
@ -161,6 +162,7 @@ int MTRxTxTest(CmdArgs& args)
strncpy(videoCodec.plName, args.codecName.c_str(), 32);
videoCodec.plType = VCM_VP8_PAYLOAD_TYPE;
videoCodec.maxBitrate = 10000;
videoCodec.codecType = args.codecType;
TEST(rtp->RegisterReceivePayload(videoCodec) == 0);
TEST(rtp->RegisterSendPayload(videoCodec) == 0);

View File

@ -35,7 +35,8 @@ int NormalTest::RunTest(CmdArgs& args)
printf("REAL-TIME\n");
#endif
Trace::CreateTrace();
Trace::SetTraceFile("VCMNormalTestTrace.txt");
Trace::SetTraceFile(
(test::OutputPath() + "VCMNormalTestTrace.txt").c_str());
Trace::SetLevelFilter(webrtc::kTraceAll);
VideoCodingModule* vcm = VideoCodingModule::Create(1);
NormalTest VCMNTest(vcm);
@ -205,7 +206,7 @@ void
NormalTest::Setup(CmdArgs& args)
{
_inname = args.inputFile;
_encodedName = "encoded_normaltest.yuv";
_encodedName = test::OutputPath() + "encoded_normaltest.yuv";
_width = args.width;
_height = args.height;
_frameRate = args.frameRate;
@ -213,7 +214,8 @@ NormalTest::Setup(CmdArgs& args)
if (args.outputFile == "")
{
std::ostringstream filename;
filename << "../NormalTest_" << _width << "x" << _height << "_" << _frameRate << "Hz_P420.yuv";
filename << test::OutputPath() << "NormalTest_" <<
_width << "x" << _height << "_" << _frameRate << "Hz_P420.yuv";
_outname = filename.str();
}
else
@ -234,7 +236,8 @@ NormalTest::Setup(CmdArgs& args)
exit(1);
}
_log.open("../TestLog.txt", std::fstream::out | std::fstream::app);
_log.open((test::OutputPath() + "TestLog.txt").c_str(),
std::fstream::out | std::fstream::app);
return;
}
@ -274,12 +277,13 @@ NormalTest::Perform(CmdArgs& args)
sendStats.SetTargetFrameRate(static_cast<WebRtc_UWord32>(_frameRate));
_vcm->RegisterSendStatisticsCallback(&sendStats);
while (feof(_sourceFile)== 0)
while (feof(_sourceFile) == 0)
{
#if !(defined(TICK_TIME_DEBUG) || defined(EVENT_DEBUG))
WebRtc_Word64 processStartTime = VCMTickTime::MillisecondTimestamp();
#endif
TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0 ||
feof(_sourceFile));
_frameCnt++;
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height);

View File

@ -54,9 +54,9 @@ QualityModesTest::Setup()
{
_inname= "../codecs/testFiles/database/crew_30f_4CIF.yuv";
_outname = "../out_qmtest.yuv";
_encodedName = "../encoded_qmtest.yuv";
_inname= test::ProjectRootPath() + "resources/crew_30f_4CIF.yuv";
_outname = test::OutputPath() + "out_qmtest.yuv";
_encodedName = test::OutputPath() + "encoded_qmtest.yuv";
//NATIVE/SOURCE VALUES
_nativeWidth = 2*352;
@ -91,7 +91,8 @@ QualityModesTest::Setup()
exit(1);
}
_log.open("../TestLog.txt", std::fstream::out | std::fstream::app);
_log.open((test::OutputPath() + "TestLog.txt").c_str(),
std::fstream::out | std::fstream::app);
return;
}

View File

@ -56,7 +56,7 @@ int ReceiverTimingTests(CmdArgs& args)
// Set up trace
Trace::CreateTrace();
Trace::SetTraceFile("receiverTestTrace.txt");
Trace::SetTraceFile((test::OutputPath() + "receiverTestTrace.txt").c_str());
Trace::SetLevelFilter(webrtc::kTraceAll);
// A static random seed

View File

@ -80,7 +80,7 @@ private:
VideoCodingModule* _VCMReceiver;
FrameType _frameType;
WebRtc_UWord8* _payloadData;
WebRtc_UWord8 _seqNo;
WebRtc_UWord16 _seqNo;
bool _encodeComplete;
WebRtc_Word32 _width;
WebRtc_Word32 _height;

View File

@ -15,22 +15,33 @@
* General declarations used through out VCM offline tests.
*/
#include "module_common_types.h"
#include <string.h>
#include <fstream>
#include <cstdlib>
#include "module_common_types.h"
#include "testsupport/fileutils.h"
// Class used for passing command line arguments to tests
class CmdArgs
{
public:
CmdArgs() : codecName(""), codecType(webrtc::kVideoCodecVP8), width(-1),
height(-1), bitRate(-1), frameRate(-1), packetLoss(0), rtt(0),
protectionMode(0), camaEnable(0), inputFile(""), outputFile(""),
testNum(-1)
{}
public:
CmdArgs()
: codecName("VP8"),
codecType(webrtc::kVideoCodecVP8),
width(352),
height(288),
bitRate(500),
frameRate(30),
packetLoss(0),
rtt(0),
protectionMode(0),
camaEnable(0),
inputFile(webrtc::test::ProjectRootPath() +
"/resources/foreman_cif.yuv"),
outputFile(webrtc::test::OutputPath() +
"video_coding_test_output_352x288.yuv"),
testNum(11) {}
std::string codecName;
webrtc::VideoCodecType codecType;
int width;

View File

@ -196,6 +196,11 @@ int main(int argc, char **argv)
case 10:
ret = DecodeFromStorageTest(args);
break;
case 11:
ret = NormalTest::RunTest(args);
ret |= CodecDataBaseTest::RunTest(args);
ret |= ReceiverTimingTests(args);
ret |= JitterBufferTest(args);
default:
ret = -1;
break;

View File

@ -48,7 +48,8 @@ FrameReceiveCallback::FrameToRender(VideoFrame& videoFrame)
{
if (_timingFile == NULL)
{
_timingFile = fopen("renderTiming.txt", "w");
_timingFile = fopen((test::OutputPath() + "renderTiming.txt").c_str(),
"w");
if (_timingFile == NULL)
{
return -1;
@ -87,7 +88,7 @@ int RtpPlay(CmdArgs& args)
const WebRtc_Word64 MAX_RUNTIME_MS = -1;
std::string outFile = args.outputFile;
if (outFile == "")
outFile = "RtpPlay_decoded.yuv";
outFile = test::OutputPath() + "RtpPlay_decoded.yuv";
FrameReceiveCallback receiveCallback(outFile);
VideoCodingModule* vcm = VideoCodingModule::Create(1);
RtpDataCallback dataCallback(vcm);
@ -98,7 +99,7 @@ int RtpPlay(CmdArgs& args)
payloadTypes.PushFront(new PayloadCodecTuple(VCM_VP8_PAYLOAD_TYPE, "VP8", kVideoCodecVP8));
Trace::CreateTrace();
Trace::SetTraceFile("receiverTestTrace.txt");
Trace::SetTraceFile((test::OutputPath() + "receiverTestTrace.txt").c_str());
Trace::SetLevelFilter(webrtc::kTraceAll);
// END Settings

View File

@ -76,7 +76,7 @@ int RtpPlayMT(CmdArgs& args, int releaseTestNo, webrtc::VideoCodecType releaseTe
const WebRtc_Word64 MAX_RUNTIME_MS = 10000;
std::string outFilename = args.outputFile;
if (outFilename == "")
outFilename = "RtpPlayMT_decoded.yuv";
outFilename = test::OutputPath() + "RtpPlayMT_decoded.yuv";
bool nackEnabled = (protectionEnabled &&
(protection == kProtectionDualDecoder ||
@ -94,7 +94,7 @@ int RtpPlayMT(CmdArgs& args, int releaseTestNo, webrtc::VideoCodecType releaseTe
{
case webrtc::kVideoCodecVP8:
rtpFilename = args.inputFile;
outFilename = "MTReceiveTest_VP8";
outFilename = test::OutputPath() + "MTReceiveTest_VP8";
break;
default:
return -1;

View File

@ -8,13 +8,16 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "vplib.h"
#include "video_source.h"
#include <cassert>
#include "testsupport/fileutils.h"
#include "vplib.h"
VideoSource::VideoSource()
:
_fileName("../../../../../codecs_video/testFiles/foreman.yuv"),
_fileName(webrtc::test::ProjectRootPath() + "resources/foreman_cif.yuv"),
_width(352),
_height(288),
_type(webrtc::kI420),