summaryrefslogtreecommitdiff
path: root/test/decode_test_driver.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/decode_test_driver.h')
-rw-r--r--test/decode_test_driver.h33
1 files changed, 21 insertions, 12 deletions
diff --git a/test/decode_test_driver.h b/test/decode_test_driver.h
index 7d31a0895..49e7384f4 100644
--- a/test/decode_test_driver.h
+++ b/test/decode_test_driver.h
@@ -14,10 +14,10 @@
#include "third_party/googletest/src/include/gtest/gtest.h"
#include "vpx_config.h"
#include "vpx/vpx_decoder.h"
-#include "vpx/vp8dx.h"
namespace libvpx_test {
+class CodecFactory;
class CompressedVideoSource;
// Provides an object to handle decoding output
@@ -42,12 +42,11 @@ class DxDataIterator {
class Decoder {
public:
Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
- : cfg_(cfg), deadline_(deadline) {
+ : cfg_(cfg), deadline_(deadline), init_done_(false) {
memset(&decoder_, 0, sizeof(decoder_));
- Init();
}
- ~Decoder() {
+ virtual ~Decoder() {
vpx_codec_destroy(&decoder_);
}
@@ -62,37 +61,45 @@ class Decoder {
}
void Control(int ctrl_id, int arg) {
+ InitOnce();
const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg);
ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
}
void Control(int ctrl_id, const void *arg) {
+ InitOnce();
const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg);
ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
}
- const char *DecodeError() {
+ const char* DecodeError() {
const char *detail = vpx_codec_error_detail(&decoder_);
return detail ? detail : vpx_codec_error(&decoder_);
}
protected:
- void Init() {
- const vpx_codec_err_t res = vpx_codec_dec_init(&decoder_,
- &vpx_codec_vp8_dx_algo,
- &cfg_, 0);
- ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
+ virtual const vpx_codec_iface_t* CodecInterface() const = 0;
+
+ void InitOnce() {
+ if (!init_done_) {
+ const vpx_codec_err_t res = vpx_codec_dec_init(&decoder_,
+ CodecInterface(),
+ &cfg_, 0);
+ ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
+ init_done_ = true;
+ }
}
vpx_codec_ctx_t decoder_;
vpx_codec_dec_cfg_t cfg_;
unsigned int deadline_;
+ bool init_done_;
};
// Common test functionality for all Decoder tests.
class DecoderTest {
public:
- // Main loop.
+ // Main decoding loop
virtual void RunLoop(CompressedVideoSource *video);
// Hook to be called on every decompressed frame.
@@ -100,9 +107,11 @@ class DecoderTest {
const unsigned int frame_number) {}
protected:
- DecoderTest() {}
+ explicit DecoderTest(const CodecFactory *codec) : codec_(codec) {}
virtual ~DecoderTest() {}
+
+ const CodecFactory *codec_;
};
} // namespace libvpx_test