2013-01-18 20:51:12 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 The WebM 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 TEST_CODEC_FACTORY_H_
|
|
|
|
#define TEST_CODEC_FACTORY_H_
|
|
|
|
|
|
|
|
#include "./vpx_config.h"
|
|
|
|
#include "vpx/vpx_decoder.h"
|
|
|
|
#include "vpx/vpx_encoder.h"
|
2016-06-18 00:22:11 +02:00
|
|
|
#if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER
|
2013-01-18 20:51:12 +01:00
|
|
|
#include "vpx/vp8cx.h"
|
|
|
|
#endif
|
2016-06-18 00:22:11 +02:00
|
|
|
#if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER
|
2013-01-18 20:51:12 +01:00
|
|
|
#include "vpx/vp8dx.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "test/decode_test_driver.h"
|
|
|
|
#include "test/encode_test_driver.h"
|
|
|
|
namespace libvpx_test {
|
|
|
|
|
2014-02-07 02:13:08 +01:00
|
|
|
const int kCodecFactoryParam = 0;
|
|
|
|
|
2013-01-18 20:51:12 +01:00
|
|
|
class CodecFactory {
|
|
|
|
public:
|
|
|
|
CodecFactory() {}
|
|
|
|
|
|
|
|
virtual ~CodecFactory() {}
|
|
|
|
|
2016-08-05 08:11:26 +02:00
|
|
|
virtual Decoder *CreateDecoder(vpx_codec_dec_cfg_t cfg) const = 0;
|
2013-01-18 20:51:12 +01:00
|
|
|
|
2016-07-26 07:50:48 +02:00
|
|
|
virtual Decoder *CreateDecoder(vpx_codec_dec_cfg_t cfg,
|
2016-08-05 08:11:26 +02:00
|
|
|
const vpx_codec_flags_t flags) const = 0;
|
2014-11-21 00:39:56 +01:00
|
|
|
|
2016-07-26 07:50:48 +02:00
|
|
|
virtual Encoder *CreateEncoder(vpx_codec_enc_cfg_t cfg,
|
2013-01-18 20:51:12 +01:00
|
|
|
unsigned long deadline,
|
|
|
|
const unsigned long init_flags,
|
|
|
|
TwopassStatsStore *stats) const = 0;
|
|
|
|
|
|
|
|
virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
|
|
|
|
int usage) const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Provide CodecTestWith<n>Params classes for a variable number of parameters
|
|
|
|
* to avoid having to include a pointer to the CodecFactory in every test
|
|
|
|
* definition.
|
|
|
|
*/
|
2016-07-26 07:50:48 +02:00
|
|
|
template <class T1>
|
|
|
|
class CodecTestWithParam
|
|
|
|
: public ::testing::TestWithParam<
|
|
|
|
std::tr1::tuple<const libvpx_test::CodecFactory *, T1> > {};
|
2013-01-18 20:51:12 +01:00
|
|
|
|
2016-07-26 07:50:48 +02:00
|
|
|
template <class T1, class T2>
|
|
|
|
class CodecTestWith2Params
|
|
|
|
: public ::testing::TestWithParam<
|
|
|
|
std::tr1::tuple<const libvpx_test::CodecFactory *, T1, T2> > {};
|
2013-01-18 20:51:12 +01:00
|
|
|
|
2016-07-26 07:50:48 +02:00
|
|
|
template <class T1, class T2, class T3>
|
|
|
|
class CodecTestWith3Params
|
|
|
|
: public ::testing::TestWithParam<
|
|
|
|
std::tr1::tuple<const libvpx_test::CodecFactory *, T1, T2, T3> > {};
|
2013-01-18 20:51:12 +01:00
|
|
|
|
2016-10-19 20:07:41 +02:00
|
|
|
template <class T1, class T2, class T3, class T4>
|
|
|
|
class CodecTestWith4Params
|
|
|
|
: public ::testing::TestWithParam<
|
|
|
|
std::tr1::tuple<const libvpx_test::CodecFactory *, T1, T2, T3, T4> > {
|
|
|
|
};
|
|
|
|
|
2013-01-18 20:51:12 +01:00
|
|
|
/*
|
|
|
|
* VP8 Codec Definitions
|
|
|
|
*/
|
|
|
|
#if CONFIG_VP8
|
|
|
|
class VP8Decoder : public Decoder {
|
|
|
|
public:
|
2016-08-05 08:11:26 +02:00
|
|
|
explicit VP8Decoder(vpx_codec_dec_cfg_t cfg) : Decoder(cfg) {}
|
2013-01-18 20:51:12 +01:00
|
|
|
|
2016-08-05 08:11:26 +02:00
|
|
|
VP8Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag)
|
|
|
|
: Decoder(cfg, flag) {}
|
2014-11-21 00:39:56 +01:00
|
|
|
|
2013-01-18 20:51:12 +01:00
|
|
|
protected:
|
2016-07-26 07:50:48 +02:00
|
|
|
virtual vpx_codec_iface_t *CodecInterface() const {
|
2013-01-18 20:51:12 +01:00
|
|
|
#if CONFIG_VP8_DECODER
|
|
|
|
return &vpx_codec_vp8_dx_algo;
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class VP8Encoder : public Encoder {
|
|
|
|
public:
|
|
|
|
VP8Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
|
|
|
|
const unsigned long init_flags, TwopassStatsStore *stats)
|
|
|
|
: Encoder(cfg, deadline, init_flags, stats) {}
|
|
|
|
|
|
|
|
protected:
|
2016-07-26 07:50:48 +02:00
|
|
|
virtual vpx_codec_iface_t *CodecInterface() const {
|
2013-01-18 20:51:12 +01:00
|
|
|
#if CONFIG_VP8_ENCODER
|
|
|
|
return &vpx_codec_vp8_cx_algo;
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class VP8CodecFactory : public CodecFactory {
|
|
|
|
public:
|
|
|
|
VP8CodecFactory() : CodecFactory() {}
|
|
|
|
|
2016-08-05 08:11:26 +02:00
|
|
|
virtual Decoder *CreateDecoder(vpx_codec_dec_cfg_t cfg) const {
|
|
|
|
return CreateDecoder(cfg, 0);
|
2014-11-21 00:39:56 +01:00
|
|
|
}
|
|
|
|
|
2016-07-26 07:50:48 +02:00
|
|
|
virtual Decoder *CreateDecoder(vpx_codec_dec_cfg_t cfg,
|
2016-08-05 08:11:26 +02:00
|
|
|
const vpx_codec_flags_t flags) const {
|
2013-01-18 20:51:12 +01:00
|
|
|
#if CONFIG_VP8_DECODER
|
2016-08-05 08:11:26 +02:00
|
|
|
return new VP8Decoder(cfg, flags);
|
2013-01-18 20:51:12 +01:00
|
|
|
#else
|
2016-07-14 21:33:48 +02:00
|
|
|
(void)cfg;
|
|
|
|
(void)flags;
|
2013-01-18 20:51:12 +01:00
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-07-26 07:50:48 +02:00
|
|
|
virtual Encoder *CreateEncoder(vpx_codec_enc_cfg_t cfg,
|
2013-01-18 20:51:12 +01:00
|
|
|
unsigned long deadline,
|
|
|
|
const unsigned long init_flags,
|
|
|
|
TwopassStatsStore *stats) const {
|
|
|
|
#if CONFIG_VP8_ENCODER
|
|
|
|
return new VP8Encoder(cfg, deadline, init_flags, stats);
|
|
|
|
#else
|
2016-07-14 21:33:48 +02:00
|
|
|
(void)cfg;
|
|
|
|
(void)deadline;
|
|
|
|
(void)init_flags;
|
|
|
|
(void)stats;
|
2013-01-18 20:51:12 +01:00
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
|
|
|
|
int usage) const {
|
|
|
|
#if CONFIG_VP8_ENCODER
|
|
|
|
return vpx_codec_enc_config_default(&vpx_codec_vp8_cx_algo, cfg, usage);
|
|
|
|
#else
|
2016-07-14 21:33:48 +02:00
|
|
|
(void)cfg;
|
|
|
|
(void)usage;
|
2013-01-18 20:51:12 +01:00
|
|
|
return VPX_CODEC_INCAPABLE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const libvpx_test::VP8CodecFactory kVP8;
|
|
|
|
|
2016-07-26 07:50:48 +02:00
|
|
|
#define VP8_INSTANTIATE_TEST_CASE(test, ...) \
|
|
|
|
INSTANTIATE_TEST_CASE_P( \
|
|
|
|
VP8, test, \
|
|
|
|
::testing::Combine( \
|
|
|
|
::testing::Values(static_cast<const libvpx_test::CodecFactory *>( \
|
|
|
|
&libvpx_test::kVP8)), \
|
2013-07-02 23:14:16 +02:00
|
|
|
__VA_ARGS__))
|
2013-01-18 20:51:12 +01:00
|
|
|
#else
|
2013-07-02 23:14:16 +02:00
|
|
|
#define VP8_INSTANTIATE_TEST_CASE(test, ...)
|
2013-01-18 20:51:12 +01:00
|
|
|
#endif // CONFIG_VP8
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VP9 Codec Definitions
|
|
|
|
*/
|
|
|
|
#if CONFIG_VP9
|
|
|
|
class VP9Decoder : public Decoder {
|
|
|
|
public:
|
2016-08-05 08:11:26 +02:00
|
|
|
explicit VP9Decoder(vpx_codec_dec_cfg_t cfg) : Decoder(cfg) {}
|
2013-01-18 20:51:12 +01:00
|
|
|
|
2016-08-05 08:11:26 +02:00
|
|
|
VP9Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag)
|
|
|
|
: Decoder(cfg, flag) {}
|
2014-11-21 00:39:56 +01:00
|
|
|
|
2013-01-18 20:51:12 +01:00
|
|
|
protected:
|
2016-07-26 07:50:48 +02:00
|
|
|
virtual vpx_codec_iface_t *CodecInterface() const {
|
2013-01-18 20:51:12 +01:00
|
|
|
#if CONFIG_VP9_DECODER
|
|
|
|
return &vpx_codec_vp9_dx_algo;
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class VP9Encoder : public Encoder {
|
|
|
|
public:
|
|
|
|
VP9Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
|
|
|
|
const unsigned long init_flags, TwopassStatsStore *stats)
|
|
|
|
: Encoder(cfg, deadline, init_flags, stats) {}
|
|
|
|
|
|
|
|
protected:
|
2016-07-26 07:50:48 +02:00
|
|
|
virtual vpx_codec_iface_t *CodecInterface() const {
|
2013-01-18 20:51:12 +01:00
|
|
|
#if CONFIG_VP9_ENCODER
|
|
|
|
return &vpx_codec_vp9_cx_algo;
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class VP9CodecFactory : public CodecFactory {
|
|
|
|
public:
|
|
|
|
VP9CodecFactory() : CodecFactory() {}
|
|
|
|
|
2016-08-05 08:11:26 +02:00
|
|
|
virtual Decoder *CreateDecoder(vpx_codec_dec_cfg_t cfg) const {
|
|
|
|
return CreateDecoder(cfg, 0);
|
2014-11-21 00:39:56 +01:00
|
|
|
}
|
|
|
|
|
2016-07-26 07:50:48 +02:00
|
|
|
virtual Decoder *CreateDecoder(vpx_codec_dec_cfg_t cfg,
|
2016-08-05 08:11:26 +02:00
|
|
|
const vpx_codec_flags_t flags) const {
|
2013-01-18 20:51:12 +01:00
|
|
|
#if CONFIG_VP9_DECODER
|
2016-08-05 08:11:26 +02:00
|
|
|
return new VP9Decoder(cfg, flags);
|
2013-01-18 20:51:12 +01:00
|
|
|
#else
|
2016-07-14 21:33:48 +02:00
|
|
|
(void)cfg;
|
|
|
|
(void)flags;
|
2013-01-18 20:51:12 +01:00
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-07-26 07:50:48 +02:00
|
|
|
virtual Encoder *CreateEncoder(vpx_codec_enc_cfg_t cfg,
|
2013-01-18 20:51:12 +01:00
|
|
|
unsigned long deadline,
|
|
|
|
const unsigned long init_flags,
|
|
|
|
TwopassStatsStore *stats) const {
|
|
|
|
#if CONFIG_VP9_ENCODER
|
|
|
|
return new VP9Encoder(cfg, deadline, init_flags, stats);
|
|
|
|
#else
|
2016-07-14 21:33:48 +02:00
|
|
|
(void)cfg;
|
|
|
|
(void)deadline;
|
|
|
|
(void)init_flags;
|
|
|
|
(void)stats;
|
2013-01-18 20:51:12 +01:00
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
|
|
|
|
int usage) const {
|
|
|
|
#if CONFIG_VP9_ENCODER
|
|
|
|
return vpx_codec_enc_config_default(&vpx_codec_vp9_cx_algo, cfg, usage);
|
|
|
|
#else
|
2016-07-14 21:33:48 +02:00
|
|
|
(void)cfg;
|
|
|
|
(void)usage;
|
2013-01-18 20:51:12 +01:00
|
|
|
return VPX_CODEC_INCAPABLE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const libvpx_test::VP9CodecFactory kVP9;
|
|
|
|
|
2016-07-26 07:50:48 +02:00
|
|
|
#define VP9_INSTANTIATE_TEST_CASE(test, ...) \
|
|
|
|
INSTANTIATE_TEST_CASE_P( \
|
|
|
|
VP9, test, \
|
|
|
|
::testing::Combine( \
|
|
|
|
::testing::Values(static_cast<const libvpx_test::CodecFactory *>( \
|
|
|
|
&libvpx_test::kVP9)), \
|
2013-07-02 23:14:16 +02:00
|
|
|
__VA_ARGS__))
|
2013-01-18 20:51:12 +01:00
|
|
|
#else
|
2013-07-02 23:14:16 +02:00
|
|
|
#define VP9_INSTANTIATE_TEST_CASE(test, ...)
|
2013-01-18 20:51:12 +01:00
|
|
|
#endif // CONFIG_VP9
|
|
|
|
|
2015-08-06 04:00:31 +02:00
|
|
|
} // namespace libvpx_test
|
2013-01-18 20:51:12 +01:00
|
|
|
#endif // TEST_CODEC_FACTORY_H_
|