git-svn-id: http://webrtc.googlecode.com/svn/trunk@4 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
44
modules/video_coding/codecs/vp8/main/test/benchmark.cc
Normal file
44
modules/video_coding/codecs/vp8/main/test/benchmark.cc
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "benchmark.h"
|
||||
#include "vp8.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
VP8Benchmark::VP8Benchmark()
|
||||
:
|
||||
Benchmark("VP8Benchmark", "VP8 benchmark over a range of test cases", "../../VP8Benchmark.txt", "VP8")
|
||||
{
|
||||
}
|
||||
|
||||
VP8Benchmark::VP8Benchmark(std::string name, std::string description)
|
||||
:
|
||||
Benchmark(name, description, "../../VP8Benchmark.txt", "VP8")
|
||||
{
|
||||
}
|
||||
|
||||
VP8Benchmark::VP8Benchmark(std::string name, std::string description, std::string resultsFileName)
|
||||
:
|
||||
Benchmark(name, description, resultsFileName, "VP8")
|
||||
{
|
||||
}
|
||||
|
||||
VideoEncoder*
|
||||
VP8Benchmark::GetNewEncoder()
|
||||
{
|
||||
return new VP8Encoder();
|
||||
}
|
||||
|
||||
VideoDecoder*
|
||||
VP8Benchmark::GetNewDecoder()
|
||||
{
|
||||
return new VP8Decoder();
|
||||
}
|
28
modules/video_coding/codecs/vp8/main/test/benchmark.h
Normal file
28
modules/video_coding/codecs/vp8/main/test/benchmark.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_BENCHMARK_H_
|
||||
#define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_BENCHMARK_H_
|
||||
|
||||
#include "../../../test_framework/benchmark.h"
|
||||
|
||||
class VP8Benchmark : public Benchmark
|
||||
{
|
||||
public:
|
||||
VP8Benchmark();
|
||||
VP8Benchmark(std::string name, std::string description);
|
||||
VP8Benchmark(std::string name, std::string description, std::string resultsFileName);
|
||||
|
||||
protected:
|
||||
virtual webrtc::VideoEncoder* GetNewEncoder();
|
||||
virtual webrtc::VideoDecoder* GetNewDecoder();
|
||||
};
|
||||
|
||||
#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_BENCHMARK_H_
|
219
modules/video_coding/codecs/vp8/main/test/dual_decoder_test.cc
Normal file
219
modules/video_coding/codecs/vp8/main/test/dual_decoder_test.cc
Normal file
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "dual_decoder_test.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h> // memcmp
|
||||
#include <time.h>
|
||||
|
||||
VP8DualDecoderTest::VP8DualDecoderTest(float bitRate)
|
||||
:
|
||||
VP8NormalAsyncTest(bitRate)
|
||||
{
|
||||
_decoder2 = NULL;
|
||||
}
|
||||
|
||||
VP8DualDecoderTest::VP8DualDecoderTest()
|
||||
:
|
||||
_decoder2(NULL),
|
||||
VP8NormalAsyncTest("VP8 Dual Decoder Test", "Tests VP8 dual decoder", 1)
|
||||
{}
|
||||
|
||||
VP8DualDecoderTest::~VP8DualDecoderTest()
|
||||
{
|
||||
if(_decoder2)
|
||||
{
|
||||
_decoder2->Release();
|
||||
delete _decoder2;
|
||||
}
|
||||
|
||||
_decodedVideoBuffer2.Free();
|
||||
}
|
||||
|
||||
void
|
||||
VP8DualDecoderTest::Perform()
|
||||
{
|
||||
_inname = "test/testFiles/foreman_cif.yuv";
|
||||
CodecSettings(352, 288, 30, _bitRate);
|
||||
Setup();
|
||||
_inputVideoBuffer.VerifyAndAllocate(_lengthSourceFrame);
|
||||
_decodedVideoBuffer.VerifyAndAllocate(_lengthSourceFrame);
|
||||
_decodedVideoBuffer2.VerifyAndAllocate(_lengthSourceFrame);
|
||||
if(_encoder->InitEncode(&_inst, 4, 1460) < 0)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
_decoder->InitDecode(&_inst,1);
|
||||
|
||||
FrameQueue frameQueue;
|
||||
VideoEncodeCompleteCallback encCallback(_encodedFile, &frameQueue, *this);
|
||||
DualDecoderCompleteCallback decCallback(&_decodedVideoBuffer);
|
||||
DualDecoderCompleteCallback decCallback2(&_decodedVideoBuffer2);
|
||||
_encoder->RegisterEncodeCompleteCallback(&encCallback);
|
||||
_decoder->RegisterDecodeCompleteCallback(&decCallback);
|
||||
if (SetCodecSpecificParameters() != WEBRTC_VIDEO_CODEC_OK)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
_totalEncodeTime = _totalDecodeTime = 0;
|
||||
_totalEncodePipeTime = _totalDecodePipeTime = 0;
|
||||
bool complete = false;
|
||||
_framecnt = 0;
|
||||
_encFrameCnt = 0;
|
||||
_decFrameCnt = 0;
|
||||
_sumEncBytes = 0;
|
||||
_lengthEncFrame = 0;
|
||||
double starttime = clock()/(double)CLOCKS_PER_SEC;
|
||||
while (!complete)
|
||||
{
|
||||
if (_encFrameCnt == 10)
|
||||
{
|
||||
// initialize second decoder and copy state
|
||||
_decoder2 = static_cast<webrtc::VP8Decoder *>(_decoder->Copy());
|
||||
assert(_decoder2 != NULL);
|
||||
_decoder2->RegisterDecodeCompleteCallback(&decCallback2);
|
||||
}
|
||||
CodecSpecific_InitBitrate();
|
||||
complete = Encode();
|
||||
if (!frameQueue.Empty() || complete)
|
||||
{
|
||||
while (!frameQueue.Empty())
|
||||
{
|
||||
_frameToDecode =
|
||||
static_cast<FrameQueueTuple *>(frameQueue.PopFrame());
|
||||
int lost = DoPacketLoss();
|
||||
if (lost == 2)
|
||||
{
|
||||
// Lost the whole frame, continue
|
||||
_missingFrames = true;
|
||||
delete _frameToDecode;
|
||||
_frameToDecode = NULL;
|
||||
continue;
|
||||
}
|
||||
int ret = Decode(lost);
|
||||
delete _frameToDecode;
|
||||
_frameToDecode = NULL;
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr,"\n\nError in decoder: %d\n\n", ret);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else if (ret == 0)
|
||||
{
|
||||
_framecnt++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,
|
||||
"\n\nPositive return value from decode!\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double endtime = clock()/(double)CLOCKS_PER_SEC;
|
||||
double totalExecutionTime = endtime - starttime;
|
||||
printf("Total execution time: %.1f s\n", totalExecutionTime);
|
||||
_sumEncBytes = encCallback.EncodedBytes();
|
||||
double actualBitRate = ActualBitRate(_encFrameCnt) / 1000.0;
|
||||
double avgEncTime = _totalEncodeTime / _encFrameCnt;
|
||||
double avgDecTime = _totalDecodeTime / _decFrameCnt;
|
||||
printf("Actual bitrate: %f kbps\n", actualBitRate);
|
||||
printf("Average encode time: %.1f ms\n", 1000 * avgEncTime);
|
||||
printf("Average decode time: %.1f ms\n", 1000 * avgDecTime);
|
||||
printf("Average encode pipeline time: %.1f ms\n",
|
||||
1000 * _totalEncodePipeTime / _encFrameCnt);
|
||||
printf("Average decode pipeline time: %.1f ms\n",
|
||||
1000 * _totalDecodePipeTime / _decFrameCnt);
|
||||
printf("Number of encoded frames: %u\n", _encFrameCnt);
|
||||
printf("Number of decoded frames: %u\n", _decFrameCnt);
|
||||
(*_log) << "Actual bitrate: " << actualBitRate << " kbps\tTarget: " <<
|
||||
_bitRate << " kbps" << std::endl;
|
||||
(*_log) << "Average encode time: " << avgEncTime << " s" << std::endl;
|
||||
(*_log) << "Average decode time: " << avgDecTime << " s" << std::endl;
|
||||
_encoder->Release();
|
||||
_decoder->Release();
|
||||
Teardown();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
VP8DualDecoderTest::Decode(int lossValue)
|
||||
{
|
||||
_sumEncBytes += _frameToDecode->_frame->GetLength();
|
||||
double starttime = 0;
|
||||
webrtc::EncodedImage encodedImage;
|
||||
VideoEncodedBufferToEncodedImage(*(_frameToDecode->_frame), encodedImage);
|
||||
encodedImage._completeFrame = !lossValue;
|
||||
_decodeCompleteTime = 0;
|
||||
_decodeTimes[encodedImage._timeStamp] = clock()/(double)CLOCKS_PER_SEC;
|
||||
int ret = _decoder->Decode(encodedImage, _missingFrames,
|
||||
_frameToDecode->_codecSpecificInfo);
|
||||
// second decoder
|
||||
if (_decoder2)
|
||||
{
|
||||
int ret2 = _decoder2->Decode(encodedImage, _missingFrames,
|
||||
_frameToDecode->_codecSpecificInfo, 0 /* dummy */);
|
||||
|
||||
// check return values
|
||||
if (ret < 0 || ret2 < 0 || ret2 != ret)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// compare decoded images
|
||||
if (!CheckIfBitExact(_decodedVideoBuffer.GetBuffer(),
|
||||
_decodedVideoBuffer.GetLength(),
|
||||
_decodedVideoBuffer2.GetBuffer(), _decodedVideoBuffer.GetLength()))
|
||||
{
|
||||
fprintf(stderr,"\n\nClone output different from master.\n\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_missingFrames = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
VP8DualDecoderTest::CheckIfBitExact(const void* ptrA, unsigned int aLengthBytes,
|
||||
const void* ptrB, unsigned int bLengthBytes)
|
||||
{
|
||||
if (aLengthBytes != bLengthBytes)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return memcmp(ptrA, ptrB, aLengthBytes) == 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32 DualDecoderCompleteCallback::Decoded(webrtc::RawImage& image)
|
||||
{
|
||||
_decodedVideoBuffer->VerifyAndAllocate(image._length);
|
||||
_decodedVideoBuffer->CopyBuffer(image._length, image._buffer);
|
||||
_decodedVideoBuffer->SetWidth(image._width);
|
||||
_decodedVideoBuffer->SetHeight(image._height);
|
||||
_decodedVideoBuffer->SetTimeStamp(image._timeStamp);
|
||||
_decodeComplete = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DualDecoderCompleteCallback::DecodeComplete()
|
||||
{
|
||||
if (_decodeComplete)
|
||||
{
|
||||
_decodeComplete = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DUAL_DECODER_TEST_H_
|
||||
#define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DUAL_DECODER_TEST_H_
|
||||
|
||||
#include "vp8.h"
|
||||
#include "normal_async_test.h"
|
||||
|
||||
class DualDecoderCompleteCallback;
|
||||
|
||||
class VP8DualDecoderTest : public VP8NormalAsyncTest
|
||||
{
|
||||
public:
|
||||
VP8DualDecoderTest(float bitRate);
|
||||
VP8DualDecoderTest();
|
||||
virtual ~VP8DualDecoderTest();
|
||||
virtual void Perform();
|
||||
protected:
|
||||
VP8DualDecoderTest(std::string name, std::string description,
|
||||
unsigned int testNo)
|
||||
: VP8NormalAsyncTest(name, description, testNo) {}
|
||||
virtual int Decode(int lossValue = 0);
|
||||
|
||||
webrtc::VP8Decoder* _decoder2;
|
||||
TestVideoBuffer _decodedVideoBuffer2;
|
||||
static bool CheckIfBitExact(const void *ptrA, unsigned int aLengthBytes,
|
||||
const void *ptrB, unsigned int bLengthBytes);
|
||||
private:
|
||||
};
|
||||
|
||||
class DualDecoderCompleteCallback : public webrtc::DecodedImageCallback
|
||||
{
|
||||
public:
|
||||
DualDecoderCompleteCallback(TestVideoBuffer* buffer)
|
||||
: _decodedVideoBuffer(buffer), _decodeComplete(false) {}
|
||||
WebRtc_Word32 Decoded(webrtc::RawImage& decodedImage);
|
||||
bool DecodeComplete();
|
||||
private:
|
||||
TestVideoBuffer* _decodedVideoBuffer;
|
||||
bool _decodeComplete;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "normal_async_test.h"
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
VP8NormalAsyncTest::VP8NormalAsyncTest(WebRtc_UWord32 bitRate) :
|
||||
NormalAsyncTest("VP8 Normal Test 1", "Tests VP8 normal execution", bitRate, 1),
|
||||
_hasReceivedRPSI(false)
|
||||
{
|
||||
}
|
||||
|
||||
VP8NormalAsyncTest::VP8NormalAsyncTest(WebRtc_UWord32 bitRate, unsigned int testNo):
|
||||
NormalAsyncTest("VP8 Normal Test 1", "Tests VP8 normal execution", bitRate, testNo),
|
||||
_hasReceivedRPSI(false)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VP8NormalAsyncTest::CodecSettings(int width, int height, WebRtc_UWord32 frameRate /*=30*/, WebRtc_UWord32 bitRate /*=0*/)
|
||||
{
|
||||
if (bitRate > 0)
|
||||
{
|
||||
_bitRate = bitRate;
|
||||
|
||||
}else if (_bitRate == 0)
|
||||
{
|
||||
_bitRate = 600;
|
||||
}
|
||||
_inst.codecType = kVideoCodecVP8;
|
||||
_inst.codecSpecific.VP8.feedbackModeOn = true;
|
||||
_inst.codecSpecific.VP8.pictureLossIndicationOn = true;
|
||||
_inst.codecSpecific.VP8.complexity;
|
||||
_inst.maxFramerate = (unsigned char)frameRate;
|
||||
_inst.startBitrate = _bitRate;
|
||||
_inst.maxBitrate = 8000;
|
||||
_inst.width = width;
|
||||
_inst.height = height;
|
||||
}
|
||||
|
||||
void
|
||||
VP8NormalAsyncTest::CodecSpecific_InitBitrate()
|
||||
{
|
||||
if (_bitRate == 0)
|
||||
{
|
||||
_encoder->SetRates(600, _inst.maxFramerate);
|
||||
}else
|
||||
{
|
||||
_encoder->SetRates(_bitRate, _inst.maxFramerate);
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
VP8NormalAsyncTest::ReceivedDecodedReferenceFrame(const WebRtc_UWord64 pictureId)
|
||||
{
|
||||
_pictureIdRPSI = pictureId;
|
||||
_hasReceivedRPSI = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void*
|
||||
VP8NormalAsyncTest::CreateEncoderSpecificInfo() const
|
||||
{
|
||||
CodecSpecificInfo* vp8CodecSpecificInfo = new CodecSpecificInfo();
|
||||
vp8CodecSpecificInfo->codecType = kVideoCodecVP8;
|
||||
vp8CodecSpecificInfo->codecSpecific.VP8.hasReceivedRPSI = _hasReceivedRPSI;
|
||||
vp8CodecSpecificInfo->codecSpecific.VP8.pictureIdRPSI = _pictureIdRPSI;
|
||||
vp8CodecSpecificInfo->codecSpecific.VP8.hasReceivedSLI = false;
|
||||
|
||||
_hasReceivedRPSI = false;
|
||||
|
||||
return vp8CodecSpecificInfo;
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_NORMAL_ASYNC_TEST_H_
|
||||
#define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_NORMAL_ASYNC_TEST_H_
|
||||
|
||||
#include "../../../test_framework/normal_async_test.h"
|
||||
|
||||
class VP8NormalAsyncTest : public NormalAsyncTest
|
||||
{
|
||||
public:
|
||||
VP8NormalAsyncTest(WebRtc_UWord32 bitRate);
|
||||
VP8NormalAsyncTest(WebRtc_UWord32 bitRate, unsigned int testNo);
|
||||
VP8NormalAsyncTest() : NormalAsyncTest("VP8 Normal Test 1", "Tests VP8 normal execution", 1) {}
|
||||
protected:
|
||||
VP8NormalAsyncTest(std::string name, std::string description, unsigned int testNo) : NormalAsyncTest(name, description, testNo) {}
|
||||
virtual void CodecSpecific_InitBitrate();
|
||||
virtual void CodecSettings(int width, int height, WebRtc_UWord32 frameRate=30, WebRtc_UWord32 bitRate=0);
|
||||
virtual void* CreateEncoderSpecificInfo() const;
|
||||
virtual WebRtc_Word32 ReceivedDecodedReferenceFrame(const WebRtc_UWord64 pictureId);
|
||||
private:
|
||||
mutable bool _hasReceivedRPSI;
|
||||
WebRtc_UWord64 _pictureIdRPSI;
|
||||
};
|
||||
|
||||
#endif
|
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "packet_loss_test.h"
|
||||
#include <cassert>
|
||||
|
||||
VP8PacketLossTest::VP8PacketLossTest()
|
||||
:
|
||||
PacketLossTest("VP8PacketLossTest", "Encode, remove lost packets, decode")
|
||||
{
|
||||
}
|
||||
|
||||
VP8PacketLossTest::VP8PacketLossTest(std::string name, std::string description)
|
||||
:
|
||||
PacketLossTest(name, description)
|
||||
{
|
||||
}
|
||||
|
||||
VP8PacketLossTest::VP8PacketLossTest(double lossRate, bool useNack)
|
||||
:
|
||||
PacketLossTest("VP8PacketLossTest", "Encode, remove lost packets, decode", lossRate, useNack)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VP8PacketLossTest::CodecSpecific_InitBitrate()
|
||||
{
|
||||
assert(_bitRate > 0);
|
||||
WebRtc_UWord32 simulatedBitRate;
|
||||
if (_lossProbability != _lossRate)
|
||||
{
|
||||
// Simulating NACK
|
||||
simulatedBitRate = (WebRtc_UWord32)(_bitRate / (1 + _lossRate));
|
||||
}
|
||||
else
|
||||
{
|
||||
simulatedBitRate = _bitRate;
|
||||
}
|
||||
_encoder->SetRates(simulatedBitRate, _inst.maxFramerate);
|
||||
}
|
||||
|
||||
int VP8PacketLossTest::ByteLoss(int size, unsigned char* /* pkg */, int bytesToLose)
|
||||
{
|
||||
int retLength = size - bytesToLose;
|
||||
if (retLength < 4)
|
||||
{
|
||||
retLength = 4;
|
||||
}
|
||||
return retLength;
|
||||
}
|
29
modules/video_coding/codecs/vp8/main/test/packet_loss_test.h
Normal file
29
modules/video_coding/codecs/vp8/main/test/packet_loss_test.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_PACKET_LOSS_TEST_H_
|
||||
#define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_PACKET_LOSS_TEST_H_
|
||||
|
||||
#include "../../../test_framework/packet_loss_test.h"
|
||||
|
||||
class VP8PacketLossTest : public PacketLossTest
|
||||
{
|
||||
public:
|
||||
VP8PacketLossTest();
|
||||
VP8PacketLossTest(double lossRate, bool useNack);
|
||||
|
||||
protected:
|
||||
VP8PacketLossTest(std::string name, std::string description);
|
||||
virtual void CodecSpecific_InitBitrate();
|
||||
virtual int ByteLoss(int size, unsigned char *pkg, int bytesToLose);
|
||||
|
||||
};
|
||||
|
||||
#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_PACKET_LOSS_TEST_H_
|
57
modules/video_coding/codecs/vp8/main/test/tester.cc
Normal file
57
modules/video_coding/codecs/vp8/main/test/tester.cc
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* 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>
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
void PopulateTests(std::vector<Test*>* tests)
|
||||
{
|
||||
tests->push_back(new VP8UnitTest());
|
||||
// tests->push_back(new VP8DualDecoderTest());
|
||||
// tests->push_back(new VP8Benchmark());
|
||||
// tests->push_back(new VP8PacketLossTest());
|
||||
// tests->push_back(new VP8NormalAsyncTest());
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
VP8Encoder* enc;
|
||||
VP8Decoder* dec;
|
||||
std::vector<Test*> tests;
|
||||
PopulateTests(&tests);
|
||||
std::fstream log;
|
||||
log.open("../../TestLog.txt", std::fstream::out | std::fstream::app);
|
||||
std::vector<Test*>::iterator it;
|
||||
for (it = tests.begin() ; it < tests.end(); it++)
|
||||
{
|
||||
enc = new VP8Encoder();
|
||||
dec = new VP8Decoder();
|
||||
(*it)->SetEncoder(enc);
|
||||
(*it)->SetDecoder(dec);
|
||||
(*it)->SetLog(&log);
|
||||
(*it)->Perform();
|
||||
(*it)->Print();
|
||||
delete enc;
|
||||
delete dec;
|
||||
delete *it;
|
||||
}
|
||||
log.close();
|
||||
tests.pop_back();
|
||||
return 0;
|
||||
}
|
168
modules/video_coding/codecs/vp8/main/test/unit_test.cc
Normal file
168
modules/video_coding/codecs/vp8/main/test/unit_test.cc
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "unit_test.h"
|
||||
#include "../../../test_framework/video_source.h"
|
||||
#include "vp8.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
using namespace webrtc;
|
||||
|
||||
VP8UnitTest::VP8UnitTest()
|
||||
:
|
||||
UnitTest("VP8UnitTest", "Unit test")
|
||||
{
|
||||
}
|
||||
|
||||
VP8UnitTest::VP8UnitTest(std::string name, std::string description)
|
||||
:
|
||||
UnitTest(name, description)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VP8UnitTest::Print()
|
||||
{
|
||||
WebRtc_Word8 versionStr[64];
|
||||
|
||||
// GetVersion tests.
|
||||
|
||||
VIDEO_TEST(_encoder->Version(versionStr, sizeof(versionStr)) > 0);
|
||||
// printf("\n%s", versionStr);
|
||||
// UnitTest::Print();
|
||||
}
|
||||
|
||||
WebRtc_UWord32
|
||||
VP8UnitTest::CodecSpecific_SetBitrate(WebRtc_UWord32 bitRate, WebRtc_UWord32 /*frameRate*/)
|
||||
{
|
||||
bitRate = _encoder->SetRates(bitRate, _inst.maxFramerate);
|
||||
VIDEO_TEST_EXIT_ON_ERR(bitRate >= 0);
|
||||
return bitRate;
|
||||
}
|
||||
|
||||
bool
|
||||
VP8UnitTest::CheckIfBitExact(const void* ptrA, unsigned int aLengthBytes,
|
||||
const void* ptrB, unsigned int bLengthBytes)
|
||||
{
|
||||
const unsigned char* cPtrA = (const unsigned char*)ptrA;
|
||||
const unsigned char* cPtrB = (const unsigned char*)ptrB;
|
||||
// Skip picture ID before comparing
|
||||
int aSkip = PicIdLength(cPtrA);
|
||||
int bSkip = PicIdLength(cPtrB);
|
||||
return UnitTest::CheckIfBitExact(cPtrA + aSkip, aLengthBytes,
|
||||
cPtrB + bSkip, bLengthBytes);
|
||||
}
|
||||
|
||||
int
|
||||
VP8UnitTest::PicIdLength(const unsigned char* ptr)
|
||||
{
|
||||
WebRtc_UWord8 numberOfBytes;
|
||||
WebRtc_UWord64 pictureID = 0;
|
||||
for (numberOfBytes = 0; (ptr[numberOfBytes] & 0x80) && numberOfBytes < 8; numberOfBytes++)
|
||||
{
|
||||
pictureID += ptr[numberOfBytes] & 0x7f;
|
||||
pictureID <<= 7;
|
||||
}
|
||||
pictureID += ptr[numberOfBytes] & 0x7f;
|
||||
numberOfBytes++;
|
||||
return numberOfBytes;
|
||||
}
|
||||
|
||||
void
|
||||
VP8UnitTest::Perform()
|
||||
{
|
||||
Setup();
|
||||
FILE *outFile = NULL;
|
||||
std::string outFileName;
|
||||
VP8Encoder* enc = (VP8Encoder*)_encoder;
|
||||
VP8Decoder* dec = (VP8Decoder*)_decoder;
|
||||
int frameLength = 0;
|
||||
|
||||
//----- 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);
|
||||
|
||||
VIDEO_TEST(enc->SetRates(_bitRate, _inst.maxFramerate) == WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
// VIDEO_TEST(enc->GetCodecConfigParameters(configParameters, sizeof(configParameters)) ==
|
||||
// WEBRTC_VIDEO_CODEC_UNINITIALIZED);
|
||||
|
||||
|
||||
VideoCodec codecInst;
|
||||
strncpy(codecInst.plName, "VP8", 31);
|
||||
codecInst.plType = 126;
|
||||
codecInst.maxBitrate = 0;
|
||||
codecInst.minBitrate = 0;
|
||||
codecInst.width = 1440;
|
||||
codecInst.height = 1080;
|
||||
codecInst.maxFramerate = 30;
|
||||
codecInst.startBitrate = 300;
|
||||
codecInst.codecSpecific.VP8.complexity = kComplexityNormal;
|
||||
VIDEO_TEST(enc->InitEncode(&codecInst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
|
||||
|
||||
//-- Test two problematic level settings --
|
||||
strncpy(codecInst.plName, "VP8", 31);
|
||||
codecInst.plType = 126;
|
||||
codecInst.maxBitrate = 0;
|
||||
codecInst.minBitrate = 0;
|
||||
codecInst.width = 352;
|
||||
codecInst.height = 288;
|
||||
codecInst.maxFramerate = 30;
|
||||
codecInst.codecSpecific.VP8.complexity = kComplexityNormal;
|
||||
codecInst.startBitrate = 300;
|
||||
VIDEO_TEST(enc->InitEncode(&codecInst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
|
||||
|
||||
// Settings not correct for this profile
|
||||
strncpy(codecInst.plName, "VP8", 31);
|
||||
codecInst.plType = 126;
|
||||
codecInst.maxBitrate = 0;
|
||||
codecInst.minBitrate = 0;
|
||||
codecInst.width = 176;
|
||||
codecInst.height = 144;
|
||||
codecInst.maxFramerate = 15;
|
||||
codecInst.codecSpecific.VP8.complexity = kComplexityNormal;
|
||||
codecInst.startBitrate = 300;
|
||||
//VIDEO_TEST(enc->InitEncode(&codecInst, 1, 1440) == WEBRTC_VIDEO_CODEC_LEVEL_EXCEEDED);
|
||||
|
||||
VIDEO_TEST_EXIT_ON_ERR(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);
|
||||
|
||||
// Signaling not used.
|
||||
|
||||
// Bad packetloss.
|
||||
// VIDEO_TEST(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);
|
||||
|
||||
//-- SetCodecConfigParameters() errors --
|
||||
unsigned char tmpBuf[128];
|
||||
VIDEO_TEST(dec->SetCodecConfigParameters(NULL, sizeof(tmpBuf)) == -1);
|
||||
VIDEO_TEST(dec->SetCodecConfigParameters(tmpBuf, 1) == -1);
|
||||
// Garbage data.
|
||||
VIDEO_TEST(dec->SetCodecConfigParameters(tmpBuf, sizeof(tmpBuf)) == -1);
|
||||
|
||||
//----- Function tests -----
|
||||
outFileName = "../../" + _source->GetName() + "-errResTest.yuv";
|
||||
outFile = fopen(outFileName.c_str(), "wb");
|
||||
VIDEO_TEST_EXIT_ON_ERR(outFile != NULL);
|
||||
|
||||
UnitTest::Perform();
|
||||
Teardown();
|
||||
|
||||
}
|
40
modules/video_coding/codecs/vp8/main/test/unit_test.h
Normal file
40
modules/video_coding/codecs/vp8/main/test/unit_test.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_UNIT_TEST_H_
|
||||
#define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_UNIT_TEST_H_
|
||||
|
||||
#include "../../../test_framework/unit_test.h"
|
||||
|
||||
class VP8UnitTest : public UnitTest
|
||||
{
|
||||
public:
|
||||
VP8UnitTest();
|
||||
VP8UnitTest(std::string name, std::string description);
|
||||
virtual void Perform();
|
||||
virtual void Print();
|
||||
|
||||
protected:
|
||||
virtual WebRtc_UWord32 CodecSpecific_SetBitrate(WebRtc_UWord32 bitRate,
|
||||
WebRtc_UWord32 /*frameRate*/);
|
||||
virtual bool CheckIfBitExact(const void *ptrA, unsigned int aLengthBytes,
|
||||
const void *ptrB, unsigned int bLengthBytes);
|
||||
static int PicIdLength(const unsigned char* ptr);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// RESERVATIONS TO PASSING UNIT TEST ON VP8 CODEC //
|
||||
// Test that will not pass: //
|
||||
// 1. Check bit exact for decoded images. //
|
||||
// 2. Target bitrate - Allow a margin of 10% instead of 5% //
|
||||
// 3. Detecting errors in bit stream - NA. //
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_UNIT_TEST_H_
|
Reference in New Issue
Block a user