Support multiple codecs in test infrastructure

This commit starts to convert the tests to a system where the codec
to be used is provided by a factory object. Currently no tests are
instantiated for VP9 since they all fail for various reasons, but it
was verified that they're called and the correct codec is
instantiated.

Change-Id: Ia7506df2ca3a7651218ba3ca560634f08c9fbdeb
This commit is contained in:
John Koleszar
2013-01-18 11:51:12 -08:00
parent bed59eb8de
commit 706cafe336
14 changed files with 368 additions and 98 deletions

View File

@@ -8,10 +8,9 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "vpx_config.h"
#include "test/codec_factory.h"
#include "test/encode_test_driver.h"
#if CONFIG_VP8_DECODER
#include "test/decode_test_driver.h"
#endif
#include "test/register_state_check.h"
#include "test/video_source.h"
#include "third_party/googletest/src/include/gtest/gtest.h"
@@ -45,7 +44,7 @@ void Encoder::EncodeFrameInternal(const VideoSource &video,
cfg_.g_h = img->d_h;
cfg_.g_timebase = video.timebase();
cfg_.rc_twopass_stats_in = stats_->buf();
res = vpx_codec_enc_init(&encoder_, &vpx_codec_vp8_cx_algo, &cfg_,
res = vpx_codec_enc_init(&encoder_, CodecInterface(), &cfg_,
init_flags_);
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
}
@@ -72,6 +71,11 @@ void Encoder::Flush() {
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
}
void EncoderTest::InitializeConfig() {
const vpx_codec_err_t res = codec_->DefaultEncoderConfig(&cfg_, 0);
ASSERT_EQ(VPX_CODEC_OK, res);
}
void EncoderTest::SetMode(TestMode mode) {
switch (mode) {
case kRealTime:
@@ -126,9 +130,7 @@ static bool compare_img(const vpx_image_t *img1,
}
void EncoderTest::RunLoop(VideoSource *video) {
#if CONFIG_VP8_DECODER
vpx_codec_dec_cfg_t dec_cfg = {0};
#endif
stats_.Reset();
@@ -143,31 +145,30 @@ void EncoderTest::RunLoop(VideoSource *video) {
cfg_.g_pass = VPX_RC_LAST_PASS;
BeginPassHook(pass);
Encoder encoder(cfg_, deadline_, init_flags_, &stats_);
#if CONFIG_VP8_DECODER
Decoder decoder(dec_cfg, 0);
Encoder* const encoder = codec_->CreateEncoder(cfg_, deadline_, init_flags_,
&stats_);
ASSERT_TRUE(encoder != NULL);
Decoder* const decoder = codec_->CreateDecoder(dec_cfg, 0);
bool has_cxdata = false;
#endif
bool again;
for (again = true, video->Begin(); again; video->Next()) {
again = video->img() != NULL;
PreEncodeFrameHook(video);
PreEncodeFrameHook(video, &encoder);
encoder.EncodeFrame(video, frame_flags_);
PreEncodeFrameHook(video, encoder);
encoder->EncodeFrame(video, frame_flags_);
CxDataIterator iter = encoder.GetCxData();
CxDataIterator iter = encoder->GetCxData();
while (const vpx_codec_cx_pkt_t *pkt = iter.Next()) {
again = true;
switch (pkt->kind) {
case VPX_CODEC_CX_FRAME_PKT:
#if CONFIG_VP8_DECODER
has_cxdata = true;
decoder.DecodeFrame((const uint8_t*)pkt->data.frame.buf,
pkt->data.frame.sz);
#endif
if (decoder)
decoder->DecodeFrame((const uint8_t*)pkt->data.frame.buf,
pkt->data.frame.sz);
ASSERT_GE(pkt->data.frame.pts, last_pts_);
last_pts_ = pkt->data.frame.pts;
FramePktHook(pkt);
@@ -182,23 +183,26 @@ void EncoderTest::RunLoop(VideoSource *video) {
}
}
#if CONFIG_VP8_DECODER
if (has_cxdata) {
const vpx_image_t *img_enc = encoder.GetPreviewFrame();
DxDataIterator dec_iter = decoder.GetDxData();
if (decoder && has_cxdata) {
const vpx_image_t *img_enc = encoder->GetPreviewFrame();
DxDataIterator dec_iter = decoder->GetDxData();
const vpx_image_t *img_dec = dec_iter.Next();
if(img_enc && img_dec) {
const bool res = compare_img(img_enc, img_dec);
ASSERT_TRUE(res)<< "Encoder/Decoder mismatch found.";
}
}
#endif
if (!Continue())
break;
}
EndPassHook();
if (decoder)
delete decoder;
delete encoder;
if (!Continue())
break;
}