Switching to I420VideoFrame

Review URL: https://webrtc-codereview.appspot.com/922004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2983 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org
2012-10-24 18:33:04 +00:00
parent 6392657643
commit 9fedff7c17
152 changed files with 2076 additions and 1862 deletions

View File

@ -114,15 +114,20 @@ CodecDataBaseTest::Perform(CmdArgs& args)
// registering the callback - encode and decode with the same vcm (could be later changed)
_encodeCompleteCallback->RegisterReceiverVCM(_vcm);
// preparing a frame to be encoded
VideoFrame sourceFrame;
sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
WebRtc_UWord8* tmpBuffer = new WebRtc_UWord8[_lengthSourceFrame];
TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width);
I420VideoFrame sourceFrame;
int half_width = (_width + 1) / 2;
int half_height = (_height + 1) / 2;
int size_y = _width * _height;
int size_uv = half_width * half_height;
sourceFrame.CreateFrame(size_y, tmpBuffer,
size_uv, tmpBuffer + size_y,
size_uv, tmpBuffer + size_y + size_uv,
_width, _height,
_width, half_width, half_width);
_timeStamp += (WebRtc_UWord32)(9e4 / _frameRate);
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
// Encoder registration
TEST (VideoCodingModule::NumberOfCodecs() > 0);
TEST(VideoCodingModule::Codec(-1, &sendCodec) < 0);
@ -199,7 +204,7 @@ CodecDataBaseTest::Perform(CmdArgs& args)
TEST(_vcm->Decode() == VCM_OK);
waitEvent->Wait(33);
_timeStamp += (WebRtc_UWord32)(9e4 / _frameRate);
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
TEST(_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
TEST(_vcm->Decode() == VCM_OK);
@ -234,14 +239,14 @@ CodecDataBaseTest::Perform(CmdArgs& args)
TEST(_vcm->ResetDecoder() == VCM_OK);
waitEvent->Wait(33);
_timeStamp += (WebRtc_UWord32)(9e4 / _frameRate);
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
TEST(_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
// Try to decode a delta frame. Should get a warning since we have enabled the "require key frame" setting
// and because no frame type request callback has been registered.
TEST(_vcm->Decode() == VCM_MISSING_CALLBACK);
TEST(_vcm->IntraFrameRequest(0) == VCM_OK);
_timeStamp += (WebRtc_UWord32)(9e4 / _frameRate);
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
TEST(_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
TEST(_vcm->Decode() == VCM_OK);
@ -254,13 +259,13 @@ CodecDataBaseTest::Perform(CmdArgs& args)
TEST(_vcm->IntraFrameRequest(0) == VCM_OK);
waitEvent->Wait(33);
_timeStamp += (WebRtc_UWord32)(9e4 / _frameRate);
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
TEST(_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
TEST(_vcm->Decode() == VCM_OK);
TEST(_vcm->RegisterReceiveCodec(&sendCodec, 1) == VCM_OK);
waitEvent->Wait(33);
_timeStamp += (WebRtc_UWord32)(9e4 / _frameRate);
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
TEST(_vcm->IntraFrameRequest(0) == VCM_OK);
TEST(_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
TEST(_vcm->Decode() == VCM_OK);
@ -280,7 +285,6 @@ CodecDataBaseTest::Perform(CmdArgs& args)
rewind(_sourceFile);
_vcm->InitializeReceiver();
_vcm->InitializeSender();
sourceFrame.Free();
VCMDecodeCompleteCallback* decodeCallCDT = new VCMDecodeCompleteCallback(_decodedFile);
VCMEncodeCompleteCallback* encodeCallCDT = new VCMEncodeCompleteCallback(_encodedFile);
_vcm->RegisterReceiveCallback(decodeCallCDT);
@ -290,8 +294,8 @@ CodecDataBaseTest::Perform(CmdArgs& args)
{
// Register all available decoders.
int i, j;
//double psnr;
sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
sourceFrame.CreateEmptyFrame(_width, _height, _width,
(_width + 1) / 2, (_width + 1) / 2);
_vcm->RegisterReceiveCallback(decodeCallCDT);
for (i=0; i < VideoCodingModule::NumberOfCodecs(); i++)
{
@ -326,17 +330,18 @@ CodecDataBaseTest::Perform(CmdArgs& args)
_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
// Assuming 300 frames, NumberOfCodecs <= 10.
for (j=0; j < int(300/VideoCodingModule::NumberOfCodecs()); j++)
{
frameCnt++;
TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
// building source frame
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width);
sourceFrame.SetLength(_lengthSourceFrame);
sourceFrame.CreateFrame(size_y, tmpBuffer,
size_uv, tmpBuffer + size_y,
size_uv, tmpBuffer + size_y + size_uv,
_width, _height,
_width, half_width, half_width);
_timeStamp += (WebRtc_UWord32)(9e4 / _frameRate);
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
// send frame to the encoder
TEST (_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
waitEvent->Wait(33); // was 100
@ -373,7 +378,6 @@ CodecDataBaseTest::Perform(CmdArgs& args)
}
} // end: iterate codecs
rewind(_sourceFile);
sourceFrame.Free();
delete [] tmpBuffer;
delete decodeCallCDT;
delete encodeCallCDT;

View File

@ -13,7 +13,7 @@
#include <stdio.h>
#include "../source/event.h"
#include "rtp_rtcp.h"
#include "module_common_types.h"
#include "common_video/interface/i420_video_frame.h"
#include "test_macros.h"
#include "modules/video_coding/main/source/mock/fake_tick_time.h"
@ -122,8 +122,7 @@ GenericCodecTest::Perform(CmdArgs& args)
_vcm->Codec(0, &_sendCodec);
TEST(_vcm->RegisterSendCodec(&_sendCodec, 4, 1440) == VCM_OK);
// sanity on encoder registration
VideoFrame sourceFrame;
sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
I420VideoFrame sourceFrame;
_vcm->InitializeSender();
TEST(_vcm->Codec(kVideoCodecVP8, &sendCodec) == 0);
TEST(_vcm->RegisterSendCodec(&sendCodec, -1, 1440) < 0); // bad number of cores
@ -147,12 +146,16 @@ GenericCodecTest::Perform(CmdArgs& args)
}
WebRtc_UWord8* tmpBuffer = new WebRtc_UWord8[_lengthSourceFrame];
TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
// building source frame
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width);
sourceFrame.SetTimeStamp(_timeStamp++);
// encode/decode
int half_width = (_width + 1) / 2;
int half_height = (_height + 1) / 2;
int size_y = _width * _height;
int size_uv = half_width * half_height;
sourceFrame.CreateFrame(size_y, tmpBuffer,
size_uv, tmpBuffer + size_y,
size_uv, tmpBuffer + size_y + size_uv,
_width, _height,
_width, half_width, half_width);
sourceFrame.set_timestamp(_timeStamp++);
TEST(_vcm->AddVideoFrame(sourceFrame) < 0 ); // encoder uninitialized
_vcm->InitializeReceiver();
TEST(_vcm->SetChannelParameters(100, 0, 0) < 0);// setting rtt when receiver uninitialized
@ -162,7 +165,6 @@ GenericCodecTest::Perform(CmdArgs& args)
/**************************************/
//Register both encoder and decoder, reset decoder - encode, set up decoder, reset encoder - decode.
rewind(_sourceFile);
sourceFrame.Free();
_vcm->InitializeReceiver();
_vcm->InitializeSender();
NumberOfCodecs = _vcm->NumberOfCodecs();
@ -195,11 +197,13 @@ GenericCodecTest::Perform(CmdArgs& args)
for (i = 0; i < _frameRate; i++)
{
TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width);
sourceFrame.CreateFrame(size_y, tmpBuffer,
size_uv, tmpBuffer + size_y,
size_uv, tmpBuffer + size_y + size_uv,
_width, _height,
_width, half_width, half_width);
_timeStamp += (WebRtc_UWord32)(9e4 / static_cast<float>(_frameRate));
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
TEST(_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
IncrementDebugClock(_frameRate);
_vcm->Process();
@ -245,7 +249,7 @@ GenericCodecTest::Perform(CmdArgs& args)
TEST(_vcm->RegisterReceiveCodec(&sendCodec, 1) == VCM_OK);
TEST(_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
_timeStamp += (WebRtc_UWord32)(9e4 / static_cast<float>(_frameRate));
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
// First packet of a subsequent frame required before the jitter buffer
// will allow decoding an incomplete frame.
TEST(_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
@ -269,8 +273,8 @@ GenericCodecTest::Perform(CmdArgs& args)
_vcm->InitializeSender();
_vcm->InitializeReceiver();
rewind(_sourceFile);
sourceFrame.Free();
sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
sourceFrame.CreateEmptyFrame(_width, _height, _width,
(_width + 1) / 2, (_width + 1) / 2);
const float bitRate[] = {100, 400, 600, 1000, 2000};
const float nBitrates = sizeof(bitRate)/sizeof(*bitRate);
float _bitRate = 0;
@ -315,11 +319,14 @@ GenericCodecTest::Perform(CmdArgs& args)
_lengthSourceFrame)
{
_frameCnt++;
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width);
sourceFrame.CreateFrame(size_y, tmpBuffer,
size_uv, tmpBuffer + size_y,
size_uv, tmpBuffer + size_y + size_uv,
_width, _height,
_width, (_width + 1) / 2,
(_width + 1) / 2);
_timeStamp += (WebRtc_UWord32)(9e4 / static_cast<float>(_frameRate));
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
ret = _vcm->AddVideoFrame(sourceFrame);
IncrementDebugClock(_frameRate);
@ -364,8 +371,6 @@ GenericCodecTest::Perform(CmdArgs& args)
/* Encoder Pipeline Delay Test */
/******************************/
_vcm->InitializeSender();
sourceFrame.Free();
sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
NumberOfCodecs = _vcm->NumberOfCodecs();
bool encodeComplete = false;
// going over all available codecs
@ -383,11 +388,13 @@ GenericCodecTest::Perform(CmdArgs& args)
{
TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
_frameCnt++;
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width);
sourceFrame.CreateFrame(size_y, tmpBuffer,
size_uv, tmpBuffer + size_y,
size_uv, tmpBuffer + size_y + size_uv,
_width, _height,
_width, half_width, half_width);
_timeStamp += (WebRtc_UWord32)(9e4 / static_cast<float>(_frameRate));
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
_vcm->AddVideoFrame(sourceFrame);
encodeComplete = _encodeCompleteCallback->EncodeComplete();
} // first frame encoded
@ -410,47 +417,6 @@ GenericCodecTest::Perform(CmdArgs& args)
VCMRTPEncodeCompleteCallback encCompleteCallback(&rtpModule);
_vcm->InitializeSender();
// TEST DISABLED FOR NOW SINCE VP8 DOESN'T HAVE THIS FEATURE
// sourceFrame.Free();
// sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
// NumberOfCodecs = _vcm->NumberOfCodecs();
// WebRtc_UWord32 targetPayloadSize = 500;
// rtpModule.SetMaxTransferUnit(targetPayloadSize);
// // going over all available codecs
// for (int k = 0; k < NumberOfCodecs; k++)
// {
// _vcm->Codec(k, &_sendCodec);
// if (strncmp(_sendCodec.plName, "VP8", 3) == 0)
// {
// // Only test with VP8
// continue;
// }
// rtpModule.RegisterSendPayload(_sendCodec.plName, _sendCodec.plType);
// // Make sure we only get one NAL unit per packet
// _vcm->InitializeSender();
// _vcm->RegisterSendCodec(&_sendCodec, 4, targetPayloadSize);
// sendCallback.SetMaxPayloadSize(targetPayloadSize);
// _vcm->RegisterTransportCallback(&encCompleteCallback);
// sendCallback.Reset();
// _frameCnt = 0;
// rewind(_sourceFile);
// while (!feof(_sourceFile))
// {
// fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile);
// _frameCnt++;
// sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
// sourceFrame.SetHeight(_height);
// sourceFrame.SetWidth(_width);
// _timeStamp += (WebRtc_UWord32)(9e4 / static_cast<float>(_frameRate));
// sourceFrame.SetTimeStamp(_timeStamp);
// ret = _vcm->AddVideoFrame(sourceFrame);
// } // first frame encoded
// printf ("\n Codec type = %s \n",_sendCodec.plName);
// printf(" Average payload size = %f bytes, target = %u bytes\n", sendCallback.AveragePayloadSize(), targetPayloadSize);
// } // end for all codecs
// Test temporal decimation settings
for (int k = 0; k < NumberOfCodecs; k++)
{
@ -474,13 +440,14 @@ GenericCodecTest::Perform(CmdArgs& args)
_vcm->RegisterSendStatisticsCallback(&sendStats);
rewind(_sourceFile);
while (fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) ==
_lengthSourceFrame)
{
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width);
_lengthSourceFrame) {
sourceFrame.CreateFrame(size_y, tmpBuffer,
size_uv, tmpBuffer + size_y,
size_uv, tmpBuffer + size_y + size_uv,
_width, _height,
_width, half_width, half_width);
_timeStamp += (WebRtc_UWord32)(9e4 / static_cast<float>(_frameRate));
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
ret = _vcm->AddVideoFrame(sourceFrame);
if (_vcm->TimeUntilNextProcess() <= 0)
{

View File

@ -290,8 +290,7 @@ MediaOptTest::Perform()
}
// START TEST
VideoFrame sourceFrame;
sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
I420VideoFrame sourceFrame;
WebRtc_UWord8* tmpBuffer = new WebRtc_UWord8[_lengthSourceFrame];
_vcm->SetChannelParameters((WebRtc_UWord32)_bitRate, (WebRtc_UWord8)_lossRate, _rttMS);
_vcm->RegisterReceiveCallback(&receiveCallback);
@ -299,17 +298,22 @@ MediaOptTest::Perform()
_frameCnt = 0;
_sumEncBytes = 0.0;
_numFramesDropped = 0;
int half_width = (_width + 1) / 2;
int half_height = (_height + 1) / 2;
int size_y = _width * _height;
int size_uv = half_width * half_height;
while (feof(_sourceFile)== 0)
{
TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
_frameCnt++;
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width);
sourceFrame.CreateFrame(size_y, tmpBuffer,
size_uv, tmpBuffer + size_y,
size_uv, tmpBuffer + size_y + size_uv,
_width, _height,
_width, half_width, half_width);
_timeStamp += (WebRtc_UWord32)(9e4 / static_cast<float>(_frameRate));
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
TEST(_vcm->AddVideoFrame(sourceFrame) == VCM_OK);
// inform RTP Module of error resilience features
//_rtp->SetFECCodeRate(protectionCallback.FECKeyRate(),protectionCallback.FECDeltaRate());
@ -331,8 +335,7 @@ MediaOptTest::Perform()
else
{
// write frame to file
if (fwrite(sourceFrame.Buffer(), 1, sourceFrame.Length(),
_actualSourceFile) != sourceFrame.Length()) {
if (PrintI420VideoFrame(sourceFrame, _actualSourceFile) < 0) {
return -1;
}
}

View File

@ -34,12 +34,11 @@ MainSenderThread(void* obj)
SendSharedState* state = static_cast<SendSharedState*>(obj);
EventWrapper& waitEvent = *EventWrapper::Create();
// preparing a frame for encoding
VideoFrame sourceFrame;
I420VideoFrame sourceFrame;
WebRtc_Word32 width = state->_args.width;
WebRtc_Word32 height = state->_args.height;
float frameRate = state->_args.frameRate;
WebRtc_Word32 lengthSourceFrame = 3*width*height/2;
sourceFrame.VerifyAndAllocate(lengthSourceFrame);
WebRtc_UWord8* tmpBuffer = new WebRtc_UWord8[lengthSourceFrame];
if (state->_sourceFile == NULL)
@ -58,11 +57,17 @@ MainSenderThread(void* obj)
TEST(fread(tmpBuffer, 1, lengthSourceFrame,state->_sourceFile) > 0 ||
feof(state->_sourceFile));
state->_frameCnt++;
sourceFrame.CopyFrame(lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(height);
sourceFrame.SetWidth(width);
int size_y = width * height;
int half_width = (width + 1) / 2;
int half_height = (height + 1) / 2;
int size_uv = half_width * half_height;
sourceFrame.CreateFrame(size_y, tmpBuffer,
size_uv, tmpBuffer + size_y,
size_uv, tmpBuffer + size_y + size_uv,
width, height,
width, half_width, half_width);
state->_timestamp += (WebRtc_UWord32)(9e4 / frameRate);
sourceFrame.SetTimeStamp(state->_timestamp);
sourceFrame.set_timestamp(state->_timestamp);
WebRtc_Word32 ret = state->_vcm.AddVideoFrame(sourceFrame);
if (ret < 0)

View File

@ -16,6 +16,7 @@
#include <time.h>
#include "../source/event.h"
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "common_types.h"
#include "modules/video_coding/main/source/mock/fake_tick_time.h"
#include "test_callbacks.h"
@ -152,13 +153,13 @@ VCMNTDecodeCompleCallback::~VCMNTDecodeCompleCallback()
fclose(_decodedFile);
}
WebRtc_Word32
VCMNTDecodeCompleCallback::FrameToRender(webrtc::VideoFrame& videoFrame)
VCMNTDecodeCompleCallback::FrameToRender(webrtc::I420VideoFrame& videoFrame)
{
if (videoFrame.Width() != _currentWidth ||
videoFrame.Height() != _currentHeight)
if (videoFrame.width() != _currentWidth ||
videoFrame.height() != _currentHeight)
{
_currentWidth = videoFrame.Width();
_currentHeight = videoFrame.Height();
_currentWidth = videoFrame.width();
_currentHeight = videoFrame.height();
if (_decodedFile != NULL)
{
fclose(_decodedFile);
@ -166,11 +167,11 @@ VCMNTDecodeCompleCallback::FrameToRender(webrtc::VideoFrame& videoFrame)
}
_decodedFile = fopen(_outname.c_str(), "wb");
}
if (fwrite(videoFrame.Buffer(), 1, videoFrame.Length(),
_decodedFile) != videoFrame.Length()) {
if (PrintI420VideoFrame(videoFrame, _decodedFile) < 0) {
return -1;
}
_decodedBytes+= videoFrame.Length();
_decodedBytes+= webrtc::CalcBufferSize(webrtc::kI420,
videoFrame.width(), videoFrame.height());
return VCM_OK;
}
@ -270,8 +271,13 @@ NormalTest::Perform(CmdArgs& args)
///////////////////////
/// Start Test
///////////////////////
VideoFrame sourceFrame;
sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
I420VideoFrame sourceFrame;
int size_y = _width * _height;
int half_width = (_width + 1) / 2;
int half_height = (_height + 1) / 2;
int size_uv = half_width * half_height;
sourceFrame.CreateEmptyFrame(_width, _height,
_width, half_width, half_width);
WebRtc_UWord8* tmpBuffer = new WebRtc_UWord8[_lengthSourceFrame];
double startTime = clock()/(double)CLOCKS_PER_SEC;
_vcm->SetChannelParameters((WebRtc_UWord32)_bitRate, 0, 0);
@ -288,23 +294,29 @@ NormalTest::Perform(CmdArgs& args)
TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0 ||
feof(_sourceFile));
_frameCnt++;
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_height);
sourceFrame.SetWidth(_width);
sourceFrame.CreateFrame(size_y, tmpBuffer,
size_uv, tmpBuffer + size_y,
size_uv, tmpBuffer + size_y + size_uv,
_width, _height,
_width, half_width, half_width);
_timeStamp += (WebRtc_UWord32)(9e4 / static_cast<float>(_sendCodec.maxFramerate));
sourceFrame.SetTimeStamp(_timeStamp);
_encodeTimes[int(sourceFrame.TimeStamp())] = clock()/(double)CLOCKS_PER_SEC;
sourceFrame.set_timestamp(_timeStamp);
_encodeTimes[int(sourceFrame.timestamp())] =
clock()/(double)CLOCKS_PER_SEC;
WebRtc_Word32 ret = _vcm->AddVideoFrame(sourceFrame);
double encodeTime = clock()/(double)CLOCKS_PER_SEC - _encodeTimes[int(sourceFrame.TimeStamp())];
double encodeTime = clock()/(double)CLOCKS_PER_SEC -
_encodeTimes[int(sourceFrame.timestamp())];
_totalEncodeTime += encodeTime;
if (ret < 0)
{
printf("Error in AddFrame: %d\n", ret);
//exit(1);
}
_decodeTimes[int(sourceFrame.TimeStamp())] = clock()/(double)CLOCKS_PER_SEC; // same timestamp value for encode and decode
_decodeTimes[int(sourceFrame.timestamp())] =
clock()/(double)CLOCKS_PER_SEC;
ret = _vcm->Decode();
_totalDecodeTime += clock()/(double)CLOCKS_PER_SEC - _decodeTimes[int(sourceFrame.TimeStamp())];
_totalDecodeTime += clock()/(double)CLOCKS_PER_SEC -
_decodeTimes[int(sourceFrame.timestamp())];
if (ret < 0)
{
printf("Error in Decode: %d\n", ret);

View File

@ -68,14 +68,14 @@ public:
virtual ~VCMNTDecodeCompleCallback();
void SetUserReceiveCallback(webrtc::VCMReceiveCallback* receiveCallback);
// will write decoded frame into file
WebRtc_Word32 FrameToRender(webrtc::VideoFrame& videoFrame);
WebRtc_Word32 FrameToRender(webrtc::I420VideoFrame& videoFrame);
WebRtc_Word32 DecodedBytes();
private:
FILE* _decodedFile;
std::string _outname;
WebRtc_UWord32 _decodedBytes;
WebRtc_UWord32 _currentWidth;
WebRtc_UWord32 _currentHeight;
int _decodedBytes;
int _currentWidth;
int _currentHeight;
}; // end of VCMDecodeCompleCallback class
@ -89,8 +89,8 @@ public:
static int RunTest(CmdArgs& args);
WebRtc_Word32 Perform(CmdArgs& args);
// option:: turn into private and call from perform
WebRtc_UWord32 Width() const { return _width; };
WebRtc_UWord32 Height() const { return _height; };
int Width() const { return _width; };
int Height() const { return _height; };
webrtc::VideoCodecType VideoType() const { return _videoType; };
@ -118,8 +118,8 @@ protected:
FILE* _decodedFile;
FILE* _encodedFile;
std::fstream _log;
WebRtc_UWord32 _width;
WebRtc_UWord32 _height;
int _width;
int _height;
float _frameRate;
float _bitRate;
WebRtc_UWord32 _lengthSourceFrame;

View File

@ -15,11 +15,11 @@
#include <time.h>
#include "../source/event.h"
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "modules/video_coding/main/source/tick_time_base.h"
#include "test_callbacks.h"
#include "test_macros.h"
#include "testsupport/metrics/video_metrics.h"
#include "common_video/libyuv/include/webrtc_libyuv.h"
using namespace webrtc;
@ -215,9 +215,8 @@ QualityModesTest::Perform()
// disabling internal VCM frame dropper
_vcm->EnableFrameDropper(false);
VideoFrame sourceFrame;
VideoFrame *decimatedFrame = NULL;
sourceFrame.VerifyAndAllocate(_lengthSourceFrame);
I420VideoFrame sourceFrame;
I420VideoFrame *decimatedFrame = NULL;
WebRtc_UWord8* tmpBuffer = new WebRtc_UWord8[_lengthSourceFrame];
double startTime = clock()/(double)CLOCKS_PER_SEC;
_vcm->SetChannelParameters((WebRtc_UWord32)_bitRate, 0, 0);
@ -238,18 +237,22 @@ QualityModesTest::Perform()
WebRtc_Word32 ret = 0;
_numFramesDroppedVPM = 0;
_numFramesDroppedVPM = 0;
while (feof(_sourceFile)== 0)
{
TEST(fread(tmpBuffer, 1, _lengthSourceFrame, _sourceFile) > 0);
_frameCnt++;
sourceFrame.CopyFrame(_lengthSourceFrame, tmpBuffer);
sourceFrame.SetHeight(_nativeHeight);
sourceFrame.SetWidth(_nativeWidth);
int size_y = _nativeWidth * _nativeHeight;
int size_uv = ((_nativeWidth + 1) / 2) * ((_nativeHeight + 1) / 2);
sourceFrame.CreateFrame(size_y, tmpBuffer,
size_uv, tmpBuffer + size_y,
size_uv, tmpBuffer + size_y + size_uv,
_nativeWidth, _nativeHeight,
_nativeWidth, (_nativeWidth + 1) / 2,
(_nativeWidth + 1) / 2);
_timeStamp += (WebRtc_UWord32)(9e4 / static_cast<float>(codec.maxFramerate));
sourceFrame.SetTimeStamp(_timeStamp);
sourceFrame.set_timestamp(_timeStamp);
ret = _vpm->PreprocessFrame(sourceFrame, &decimatedFrame);
if (ret == 1)
@ -270,20 +273,24 @@ QualityModesTest::Perform()
}
// counting only encoding time
_encodeTimes[int(sourceFrame.TimeStamp())] = clock()/(double)CLOCKS_PER_SEC;
_encodeTimes[int(sourceFrame.timestamp())] =
clock()/(double)CLOCKS_PER_SEC;
WebRtc_Word32 ret = _vcm->AddVideoFrame(*decimatedFrame, contentMetrics);
_totalEncodeTime += clock()/(double)CLOCKS_PER_SEC - _encodeTimes[int(sourceFrame.TimeStamp())];
_totalEncodeTime += clock()/(double)CLOCKS_PER_SEC -
_encodeTimes[int(sourceFrame.timestamp())];
if (ret < 0)
{
printf("Error in AddFrame: %d\n", ret);
//exit(1);
}
_decodeTimes[int(sourceFrame.TimeStamp())] = clock()/(double)CLOCKS_PER_SEC; // same timestamp value for encode and decode
_decodeTimes[int(sourceFrame.timestamp())] = clock() /
(double)CLOCKS_PER_SEC - _decodeTimes[int(sourceFrame.timestamp())];
ret = _vcm->Decode();
_totalDecodeTime += clock()/(double)CLOCKS_PER_SEC - _decodeTimes[int(sourceFrame.TimeStamp())];
_totalDecodeTime += clock()/(double)CLOCKS_PER_SEC -
_decodeTimes[int(sourceFrame.timestamp())];
if (ret < 0)
{
printf("Error in Decode: %d\n", ret);
@ -308,7 +315,7 @@ QualityModesTest::Perform()
_frameRate = frameRateUpdate[change];
codec.startBitrate = (int)_bitRate;
codec.maxFramerate = (WebRtc_UWord8) _frameRate;
TEST(_vcm->RegisterSendCodec(&codec, 2, 1440) == VCM_OK);// will also set and init the desired codec
TEST(_vcm->RegisterSendCodec(&codec, 2, 1440) == VCM_OK);
change++;
}
}
@ -326,8 +333,6 @@ QualityModesTest::Perform()
return 0;
}
// implementing callback to be called from VCM to update VPM of frame rate and size
QMTestVideoSettingsCallback::QMTestVideoSettingsCallback():
_vpm(NULL),
_vcm(NULL)
@ -415,48 +420,32 @@ VCMQMDecodeCompleCallback::~VCMQMDecodeCompleCallback()
}
}
WebRtc_Word32
VCMQMDecodeCompleCallback::FrameToRender(VideoFrame& videoFrame)
VCMQMDecodeCompleCallback::FrameToRender(I420VideoFrame& videoFrame)
{
if ((_origWidth == videoFrame.Width()) && (_origHeight == videoFrame.Height()))
if ((_origWidth == videoFrame.width()) &&
(_origHeight == videoFrame.height()))
{
if (fwrite(videoFrame.Buffer(), 1, videoFrame.Length(),
_decodedFile) != videoFrame.Length()) {
if (PrintI420VideoFrame(videoFrame, _decodedFile) < 0) {
return -1;
}
_frameCnt++;
//printf("frame dec # %d", _frameCnt);
// no need for interpolator and decBuffer
if (_decBuffer != NULL)
{
delete [] _decBuffer;
_decBuffer = NULL;
}
// if (_interpolator != NULL)
// {
// deleteInterpolator(_interpolator);
// _interpolator = NULL;
// }
_decWidth = 0;
_decHeight = 0;
}
else
{
if ((_decWidth != videoFrame.Width()) || (_decHeight != videoFrame.Height()))
{
_decWidth = videoFrame.Width();
_decHeight = videoFrame.Height();
buildInterpolator();
}
// interpolateFrame(_interpolator, videoFrame.Buffer(),_decBuffer);
if (fwrite(_decBuffer, 1, _origWidth*_origHeight * 3/2,
_decodedFile) != _origWidth*_origHeight * 3/2) {
return -1;
}
_frameCnt++;
// TODO(mikhal): Add support for scaling.
return -1;
}
_decodedBytes += videoFrame.Length();
_decodedBytes += CalcBufferSize(kI420, videoFrame.width(),
videoFrame.height());
return VCM_OK;
}
@ -467,7 +456,8 @@ VCMQMDecodeCompleCallback::DecodedBytes()
}
void
VCMQMDecodeCompleCallback::SetOriginalFrameDimensions(WebRtc_Word32 width, WebRtc_Word32 height)
VCMQMDecodeCompleCallback::SetOriginalFrameDimensions(WebRtc_Word32 width,
WebRtc_Word32 height)
{
_origWidth = width;
_origHeight = height;

View File

@ -34,11 +34,11 @@ private:
webrtc::VideoProcessingModule* _vpm;
WebRtc_UWord32 _width;
WebRtc_UWord32 _height;
int _width;
int _height;
float _frameRate;
WebRtc_UWord32 _nativeWidth;
WebRtc_UWord32 _nativeHeight;
int _nativeWidth;
int _nativeHeight;
float _nativeFrameRate;
WebRtc_UWord32 _numFramesDroppedVPM;
@ -54,7 +54,7 @@ public:
virtual ~VCMQMDecodeCompleCallback();
void SetUserReceiveCallback(webrtc::VCMReceiveCallback* receiveCallback);
// will write decoded frame into file
WebRtc_Word32 FrameToRender(webrtc::VideoFrame& videoFrame);
WebRtc_Word32 FrameToRender(webrtc::I420VideoFrame& videoFrame);
WebRtc_Word32 DecodedBytes();
void SetOriginalFrameDimensions(WebRtc_Word32 width, WebRtc_Word32 height);
WebRtc_Word32 buildInterpolator();
@ -62,10 +62,10 @@ private:
FILE* _decodedFile;
WebRtc_UWord32 _decodedBytes;
// QualityModesTest& _test;
WebRtc_UWord32 _origWidth;
WebRtc_UWord32 _origHeight;
WebRtc_UWord32 _decWidth;
WebRtc_UWord32 _decHeight;
int _origWidth;
int _origHeight;
int _decWidth;
int _decHeight;
// VideoInterpolator* _interpolator;
WebRtc_UWord8* _decBuffer;
WebRtc_UWord32 _frameCnt; // debug

View File

@ -47,7 +47,7 @@ public:
virtual ~FrameReceiveCallback();
WebRtc_Word32 FrameToRender(webrtc::VideoFrame& videoFrame);
WebRtc_Word32 FrameToRender(webrtc::I420VideoFrame& videoFrame);
private:
static void SplitFilename(std::string filename, std::string* basename,

View File

@ -12,6 +12,7 @@
#include <cmath>
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "modules/video_coding/main/source/tick_time_base.h"
#include "rtp_dump.h"
#include "test_macros.h"
@ -187,13 +188,13 @@ VCMRTPEncodeCompleteCallback::EncodeComplete()
// Decoded Frame Callback Implementation
WebRtc_Word32
VCMDecodeCompleteCallback::FrameToRender(VideoFrame& videoFrame)
VCMDecodeCompleteCallback::FrameToRender(I420VideoFrame& videoFrame)
{
if (fwrite(videoFrame.Buffer(), 1, videoFrame.Length(),
_decodedFile) != videoFrame.Length()) {
if (PrintI420VideoFrame(videoFrame, _decodedFile) < 0) {
return -1;
}
_decodedBytes+= videoFrame.Length();
_decodedBytes+= CalcBufferSize(kI420, videoFrame.width(),
videoFrame.height());
return VCM_OK;
}

View File

@ -142,7 +142,7 @@ public:
_decodedFile(decodedFile), _decodedBytes(0) {}
virtual ~VCMDecodeCompleteCallback() {}
// Write decoded frame into file
WebRtc_Word32 FrameToRender(webrtc::VideoFrame& videoFrame);
WebRtc_Word32 FrameToRender(webrtc::I420VideoFrame& videoFrame);
WebRtc_Word32 DecodedBytes();
private:
FILE* _decodedFile;

View File

@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "receiver_tests.h"
#include "video_coding.h"
#include "rtp_rtcp.h"
@ -45,7 +46,7 @@ FrameReceiveCallback::~FrameReceiveCallback()
}
WebRtc_Word32
FrameReceiveCallback::FrameToRender(VideoFrame& videoFrame)
FrameReceiveCallback::FrameToRender(I420VideoFrame& videoFrame)
{
if (_timingFile == NULL)
{
@ -56,15 +57,16 @@ FrameReceiveCallback::FrameToRender(VideoFrame& videoFrame)
return -1;
}
}
if (_outFile == NULL || videoFrame.Width() != width_ ||
videoFrame.Height() != height_)
if (_outFile == NULL ||
videoFrame.width() != static_cast<int>(width_) ||
videoFrame.height() != static_cast<int>(height_))
{
if (_outFile) {
fclose(_outFile);
}
printf("New size: %ux%u\n", videoFrame.Width(), videoFrame.Height());
width_ = videoFrame.Width();
height_ = videoFrame.Height();
printf("New size: %ux%u\n", videoFrame.width(), videoFrame.height());
width_ = videoFrame.width();
height_ = videoFrame.height();
std::string filename_with_width_height = AppendWidthAndHeight(
_outFilename, width_, height_);
_outFile = fopen(filename_with_width_height.c_str(), "wb");
@ -74,10 +76,9 @@ FrameReceiveCallback::FrameToRender(VideoFrame& videoFrame)
}
}
fprintf(_timingFile, "%u, %u\n",
videoFrame.TimeStamp(),
MaskWord64ToUWord32(videoFrame.RenderTimeMs()));
if (fwrite(videoFrame.Buffer(), 1, videoFrame.Length(),
_outFile) != videoFrame.Length()) {
videoFrame.timestamp(),
MaskWord64ToUWord32(videoFrame.render_time_ms()));
if (PrintI420VideoFrame(videoFrame, _outFile) < 0) {
return -1;
}
return 0;