2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
10 #ifndef TEST_CODEC_FACTORY_H_
11 #define TEST_CODEC_FACTORY_H_
14 #include "./vpx_config.h"
15 #include "vpx/vpx_decoder.h"
16 #include "vpx/vpx_encoder.h"
17 #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER
18 #include "vpx/vp8cx.h"
20 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER
21 #include "vpx/vp8dx.h"
25 #include "test/decode_test_driver.h"
26 #include "test/encode_test_driver.h"
27 namespace libvpx_test {
29 const int kCodecFactoryParam = 0;
35 virtual ~CodecFactory() {}
37 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
38 unsigned long deadline) const = 0;
40 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
41 unsigned long deadline,
42 const unsigned long init_flags,
43 TwopassStatsStore *stats) const = 0;
45 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
49 /* Provide CodecTestWith<n>Params classes for a variable number of parameters
50 * to avoid having to include a pointer to the CodecFactory in every test
54 class CodecTestWithParam : public ::testing::TestWithParam<
55 std::tr1::tuple< const libvpx_test::CodecFactory*, T1 > > {
58 template<class T1, class T2>
59 class CodecTestWith2Params : public ::testing::TestWithParam<
60 std::tr1::tuple< const libvpx_test::CodecFactory*, T1, T2 > > {
63 template<class T1, class T2, class T3>
64 class CodecTestWith3Params : public ::testing::TestWithParam<
65 std::tr1::tuple< const libvpx_test::CodecFactory*, T1, T2, T3 > > {
69 * VP8 Codec Definitions
72 class VP8Decoder : public Decoder {
74 VP8Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
75 : Decoder(cfg, deadline) {}
78 virtual const vpx_codec_iface_t* CodecInterface() const {
79 #if CONFIG_VP8_DECODER
80 return &vpx_codec_vp8_dx_algo;
87 class VP8Encoder : public Encoder {
89 VP8Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
90 const unsigned long init_flags, TwopassStatsStore *stats)
91 : Encoder(cfg, deadline, init_flags, stats) {}
94 virtual const vpx_codec_iface_t* CodecInterface() const {
95 #if CONFIG_VP8_ENCODER
96 return &vpx_codec_vp8_cx_algo;
103 class VP8CodecFactory : public CodecFactory {
105 VP8CodecFactory() : CodecFactory() {}
107 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
108 unsigned long deadline) const {
109 #if CONFIG_VP8_DECODER
110 return new VP8Decoder(cfg, deadline);
116 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
117 unsigned long deadline,
118 const unsigned long init_flags,
119 TwopassStatsStore *stats) const {
120 #if CONFIG_VP8_ENCODER
121 return new VP8Encoder(cfg, deadline, init_flags, stats);
127 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
129 #if CONFIG_VP8_ENCODER
130 return vpx_codec_enc_config_default(&vpx_codec_vp8_cx_algo, cfg, usage);
132 return VPX_CODEC_INCAPABLE;
137 const libvpx_test::VP8CodecFactory kVP8;
139 #define VP8_INSTANTIATE_TEST_CASE(test, ...)\
140 INSTANTIATE_TEST_CASE_P(VP8, test, \
141 ::testing::Combine( \
142 ::testing::Values(static_cast<const libvpx_test::CodecFactory*>( \
143 &libvpx_test::kVP8)), \
146 #define VP8_INSTANTIATE_TEST_CASE(test, ...)
151 * VP9 Codec Definitions
154 class VP9Decoder : public Decoder {
156 VP9Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
157 : Decoder(cfg, deadline) {}
160 virtual const vpx_codec_iface_t* CodecInterface() const {
161 #if CONFIG_VP9_DECODER
162 return &vpx_codec_vp9_dx_algo;
169 class VP9Encoder : public Encoder {
171 VP9Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
172 const unsigned long init_flags, TwopassStatsStore *stats)
173 : Encoder(cfg, deadline, init_flags, stats) {}
176 virtual const vpx_codec_iface_t* CodecInterface() const {
177 #if CONFIG_VP9_ENCODER
178 return &vpx_codec_vp9_cx_algo;
185 class VP9CodecFactory : public CodecFactory {
187 VP9CodecFactory() : CodecFactory() {}
189 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
190 unsigned long deadline) const {
191 #if CONFIG_VP9_DECODER
192 return new VP9Decoder(cfg, deadline);
198 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
199 unsigned long deadline,
200 const unsigned long init_flags,
201 TwopassStatsStore *stats) const {
202 #if CONFIG_VP9_ENCODER
203 return new VP9Encoder(cfg, deadline, init_flags, stats);
209 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
211 #if CONFIG_VP9_ENCODER
212 return vpx_codec_enc_config_default(&vpx_codec_vp9_cx_algo, cfg, usage);
214 return VPX_CODEC_INCAPABLE;
219 const libvpx_test::VP9CodecFactory kVP9;
221 #define VP9_INSTANTIATE_TEST_CASE(test, ...)\
222 INSTANTIATE_TEST_CASE_P(VP9, test, \
223 ::testing::Combine( \
224 ::testing::Values(static_cast<const libvpx_test::CodecFactory*>( \
225 &libvpx_test::kVP9)), \
228 #define VP9_INSTANTIATE_TEST_CASE(test, ...)
232 } // namespace libvpx_test
234 #endif // TEST_CODEC_FACTORY_H_