#include "test/video_source.h"
namespace libvpx_test {
- void Decoder::DecodeFrame(const uint8_t *cxdata, int size) {
- if (!decoder_.priv) {
- const vpx_codec_err_t res_init = vpx_codec_dec_init(&decoder_,
- CodecInterface(),
- &cfg_, 0);
- ASSERT_EQ(VPX_CODEC_OK, res_init) << DecodeError();
- }
-#if CONFIG_VP8_DECODER
+ vpx_codec_err_t Decoder::DecodeFrame(const uint8_t *cxdata, int size) {
vpx_codec_err_t res_dec;
++ InitOnce();
REGISTER_STATE_CHECK(res_dec = vpx_codec_decode(&decoder_,
cxdata, size, NULL, 0));
- ASSERT_EQ(VPX_CODEC_OK, res_dec) << DecodeError();
+ return res_dec;
}
void DecoderTest::RunLoop(CompressedVideoSource *video) {
// Decode frames.
for (video->Begin(); video->cxdata(); video->Next()) {
- decoder->DecodeFrame(video->cxdata(), video->frame_size());
- vpx_codec_err_t res_dec = decoder.DecodeFrame(video->cxdata(),
- video->frame_size());
- ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder.DecodeError();
++ vpx_codec_err_t res_dec = decoder->DecodeFrame(video->cxdata(),
++ video->frame_size());
++ ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder->DecodeError();
- DxDataIterator dec_iter = decoder.GetDxData();
+ DxDataIterator dec_iter = decoder->GetDxData();
const vpx_image_t *img = NULL;
// Get decompressed data
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_);
}
}
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();
}
- protected:
- virtual const vpx_codec_iface_t* CodecInterface() const = 0;
+ 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_);
}
- 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();
+ protected:
++ 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.
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();
+ bool has_cxdata = false;
+ bool has_dxdata = false;
while (const vpx_codec_cx_pkt_t *pkt = iter.Next()) {
+ pkt = MutateEncoderOutputHook(pkt);
again = true;
-#if CONFIG_VP8_DECODER
- vpx_codec_err_t res_dec;
-#endif
switch (pkt->kind) {
case VPX_CODEC_CX_FRAME_PKT:
-#if CONFIG_VP8_DECODER
has_cxdata = true;
- res_dec = decoder.DecodeFrame((const uint8_t*)pkt->data.frame.buf,
- pkt->data.frame.sz);
- ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder.DecodeError();
-#endif
+ if (decoder && DoDecode()) {
- decoder->DecodeFrame((const uint8_t*)pkt->data.frame.buf,
- pkt->data.frame.sz);
++ vpx_codec_err_t res_dec = decoder->DecodeFrame(
++ (const uint8_t*)pkt->data.frame.buf, pkt->data.frame.sz);
++ ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder->DecodeError();
+ has_dxdata = true;
+ }
ASSERT_GE(pkt->data.frame.pts, last_pts_);
last_pts_ = pkt->data.frame.pts;
FramePktHook(pkt);
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += keyframe_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += resize_test.cc
-LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += ../md5_utils.h ../md5_utils.c
-LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += decode_test_driver.cc
-LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += decode_test_driver.h
-LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += ivf_video_source.h
+LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += ../md5_utils.h ../md5_utils.c
+LIBVPX_TEST_SRCS-yes += decode_test_driver.cc
+LIBVPX_TEST_SRCS-yes += decode_test_driver.h
+LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += ivf_video_source.h
+
+
LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += test_vector_test.cc
+
##
## WHITE BOX TESTS
##
VP8_CX_SRCS-$(HAVE_MMX) += encoder/x86/vp8_enc_stubs_mmx.c
VP8_CX_SRCS-$(HAVE_SSE2) += encoder/x86/dct_sse2.asm
VP8_CX_SRCS-$(HAVE_SSE2) += encoder/x86/fwalsh_sse2.asm
-VP8_CX_SRCS-$(HAVE_SSE2) += encoder/x86/quantize_sse2.c
+VP8_CX_SRCS-$(HAVE_SSE2) += encoder/x86/quantize_sse2_intrinsics.c
- VP8_CX_SRCS-$(HAVE_SSE2) += encoder/x86/quantize_sse2.asm
# TODO(johann) make this generic
ifeq ($(HAVE_SSE2),yes)