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_
13 #include "./vpx_config.h"
14 #include "vpx/vpx_decoder.h"
15 #include "vpx/vpx_encoder.h"
16 #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER || CONFIG_VP10_ENCODER
17 #include "vpx/vp8cx.h"
19 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER || CONFIG_VP10_DECODER
20 #include "vpx/vp8dx.h"
23 #include "test/decode_test_driver.h"
24 #include "test/encode_test_driver.h"
25 namespace libvpx_test {
27 const int kCodecFactoryParam = 0;
33 virtual ~CodecFactory() {}
35 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
36 unsigned long deadline) const = 0;
38 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
39 const vpx_codec_flags_t flags,
40 unsigned long deadline) // NOLINT(runtime/int)
43 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
44 unsigned long deadline,
45 const unsigned long init_flags,
46 TwopassStatsStore *stats) const = 0;
48 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
52 /* Provide CodecTestWith<n>Params classes for a variable number of parameters
53 * to avoid having to include a pointer to the CodecFactory in every test
57 class CodecTestWithParam : public ::testing::TestWithParam<
58 std::tr1::tuple< const libvpx_test::CodecFactory*, T1 > > {
61 template<class T1, class T2>
62 class CodecTestWith2Params : public ::testing::TestWithParam<
63 std::tr1::tuple< const libvpx_test::CodecFactory*, T1, T2 > > {
66 template<class T1, class T2, class T3>
67 class CodecTestWith3Params : public ::testing::TestWithParam<
68 std::tr1::tuple< const libvpx_test::CodecFactory*, T1, T2, T3 > > {
72 * VP8 Codec Definitions
75 class VP8Decoder : public Decoder {
77 VP8Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
78 : Decoder(cfg, deadline) {}
80 VP8Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
81 unsigned long deadline) // NOLINT
82 : Decoder(cfg, flag, deadline) {}
85 virtual vpx_codec_iface_t* CodecInterface() const {
86 #if CONFIG_VP8_DECODER
87 return &vpx_codec_vp8_dx_algo;
94 class VP8Encoder : public Encoder {
96 VP8Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
97 const unsigned long init_flags, TwopassStatsStore *stats)
98 : Encoder(cfg, deadline, init_flags, stats) {}
101 virtual vpx_codec_iface_t* CodecInterface() const {
102 #if CONFIG_VP8_ENCODER
103 return &vpx_codec_vp8_cx_algo;
110 class VP8CodecFactory : public CodecFactory {
112 VP8CodecFactory() : CodecFactory() {}
114 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
115 unsigned long deadline) const {
116 return CreateDecoder(cfg, 0, deadline);
119 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
120 const vpx_codec_flags_t flags,
121 unsigned long deadline) const { // NOLINT
122 #if CONFIG_VP8_DECODER
123 return new VP8Decoder(cfg, flags, deadline);
129 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
130 unsigned long deadline,
131 const unsigned long init_flags,
132 TwopassStatsStore *stats) const {
133 #if CONFIG_VP8_ENCODER
134 return new VP8Encoder(cfg, deadline, init_flags, stats);
140 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
142 #if CONFIG_VP8_ENCODER
143 return vpx_codec_enc_config_default(&vpx_codec_vp8_cx_algo, cfg, usage);
145 return VPX_CODEC_INCAPABLE;
150 const libvpx_test::VP8CodecFactory kVP8;
152 #define VP8_INSTANTIATE_TEST_CASE(test, ...)\
153 INSTANTIATE_TEST_CASE_P(VP8, test, \
154 ::testing::Combine( \
155 ::testing::Values(static_cast<const libvpx_test::CodecFactory*>( \
156 &libvpx_test::kVP8)), \
159 #define VP8_INSTANTIATE_TEST_CASE(test, ...)
164 * VP9 Codec Definitions
167 class VP9Decoder : public Decoder {
169 VP9Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
170 : Decoder(cfg, deadline) {}
172 VP9Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
173 unsigned long deadline) // NOLINT
174 : Decoder(cfg, flag, deadline) {}
177 virtual vpx_codec_iface_t* CodecInterface() const {
178 #if CONFIG_VP9_DECODER
179 return &vpx_codec_vp9_dx_algo;
186 class VP9Encoder : public Encoder {
188 VP9Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
189 const unsigned long init_flags, TwopassStatsStore *stats)
190 : Encoder(cfg, deadline, init_flags, stats) {}
193 virtual vpx_codec_iface_t* CodecInterface() const {
194 #if CONFIG_VP9_ENCODER
195 return &vpx_codec_vp9_cx_algo;
202 class VP9CodecFactory : public CodecFactory {
204 VP9CodecFactory() : CodecFactory() {}
206 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
207 unsigned long deadline) const {
208 return CreateDecoder(cfg, 0, deadline);
211 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
212 const vpx_codec_flags_t flags,
213 unsigned long deadline) const { // NOLINT
214 #if CONFIG_VP9_DECODER
215 return new VP9Decoder(cfg, flags, deadline);
221 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
222 unsigned long deadline,
223 const unsigned long init_flags,
224 TwopassStatsStore *stats) const {
225 #if CONFIG_VP9_ENCODER
226 return new VP9Encoder(cfg, deadline, init_flags, stats);
232 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
234 #if CONFIG_VP9_ENCODER
235 return vpx_codec_enc_config_default(&vpx_codec_vp9_cx_algo, cfg, usage);
236 #elif CONFIG_VP10_ENCODER
237 return vpx_codec_enc_config_default(&vpx_codec_vp10_cx_algo, cfg, usage);
239 return VPX_CODEC_INCAPABLE;
244 const libvpx_test::VP9CodecFactory kVP9;
246 #define VP9_INSTANTIATE_TEST_CASE(test, ...)\
247 INSTANTIATE_TEST_CASE_P(VP9, test, \
248 ::testing::Combine( \
249 ::testing::Values(static_cast<const libvpx_test::CodecFactory*>( \
250 &libvpx_test::kVP9)), \
253 #define VP9_INSTANTIATE_TEST_CASE(test, ...)
257 * VP10 Codec Definitions
260 class VP10Decoder : public Decoder {
262 VP10Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
263 : Decoder(cfg, deadline) {}
265 VP10Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
266 unsigned long deadline) // NOLINT
267 : Decoder(cfg, flag, deadline) {}
270 virtual vpx_codec_iface_t* CodecInterface() const {
271 #if CONFIG_VP10_DECODER
272 return &vpx_codec_vp10_dx_algo;
279 class VP10Encoder : public Encoder {
281 VP10Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
282 const unsigned long init_flags, TwopassStatsStore *stats)
283 : Encoder(cfg, deadline, init_flags, stats) {}
286 virtual vpx_codec_iface_t* CodecInterface() const {
287 #if CONFIG_VP10_ENCODER
288 return &vpx_codec_vp10_cx_algo;
295 class VP10CodecFactory : public CodecFactory {
297 VP10CodecFactory() : CodecFactory() {}
299 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
300 unsigned long deadline) const {
301 return CreateDecoder(cfg, 0, deadline);
304 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
305 const vpx_codec_flags_t flags,
306 unsigned long deadline) const { // NOLINT
307 #if CONFIG_VP10_DECODER
308 return new VP10Decoder(cfg, flags, deadline);
314 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
315 unsigned long deadline,
316 const unsigned long init_flags,
317 TwopassStatsStore *stats) const {
318 #if CONFIG_VP10_ENCODER
319 return new VP10Encoder(cfg, deadline, init_flags, stats);
325 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
327 #if CONFIG_VP10_ENCODER
328 return vpx_codec_enc_config_default(&vpx_codec_vp10_cx_algo, cfg, usage);
330 return VPX_CODEC_INCAPABLE;
335 const libvpx_test::VP10CodecFactory kVP10;
337 #define VP10_INSTANTIATE_TEST_CASE(test, ...)\
338 INSTANTIATE_TEST_CASE_P(VP10, test, \
339 ::testing::Combine( \
340 ::testing::Values(static_cast<const libvpx_test::CodecFactory*>( \
341 &libvpx_test::kVP10)), \
344 #define VP10_INSTANTIATE_TEST_CASE(test, ...)
345 #endif // CONFIG_VP10
347 } // namespace libvpx_test
348 #endif // TEST_CODEC_FACTORY_H_