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
17 #include "vpx/vp8cx.h"
19 #if CONFIG_VP8_DECODER || CONFIG_VP9_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 Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
39 unsigned long deadline,
40 const unsigned long init_flags,
41 TwopassStatsStore *stats) const = 0;
43 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
47 /* Provide CodecTestWith<n>Params classes for a variable number of parameters
48 * to avoid having to include a pointer to the CodecFactory in every test
52 class CodecTestWithParam : public ::testing::TestWithParam<
53 std::tr1::tuple< const libvpx_test::CodecFactory*, T1 > > {
56 template<class T1, class T2>
57 class CodecTestWith2Params : public ::testing::TestWithParam<
58 std::tr1::tuple< const libvpx_test::CodecFactory*, T1, T2 > > {
61 template<class T1, class T2, class T3>
62 class CodecTestWith3Params : public ::testing::TestWithParam<
63 std::tr1::tuple< const libvpx_test::CodecFactory*, T1, T2, T3 > > {
67 * VP8 Codec Definitions
70 class VP8Decoder : public Decoder {
72 VP8Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
73 : Decoder(cfg, deadline) {}
76 virtual const vpx_codec_iface_t* CodecInterface() const {
77 #if CONFIG_VP8_DECODER
78 return &vpx_codec_vp8_dx_algo;
85 class VP8Encoder : public Encoder {
87 VP8Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
88 const unsigned long init_flags, TwopassStatsStore *stats)
89 : Encoder(cfg, deadline, init_flags, stats) {}
92 virtual const vpx_codec_iface_t* CodecInterface() const {
93 #if CONFIG_VP8_ENCODER
94 return &vpx_codec_vp8_cx_algo;
101 class VP8CodecFactory : public CodecFactory {
103 VP8CodecFactory() : CodecFactory() {}
105 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
106 unsigned long deadline) const {
107 #if CONFIG_VP8_DECODER
108 return new VP8Decoder(cfg, deadline);
114 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
115 unsigned long deadline,
116 const unsigned long init_flags,
117 TwopassStatsStore *stats) const {
118 #if CONFIG_VP8_ENCODER
119 return new VP8Encoder(cfg, deadline, init_flags, stats);
125 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
127 #if CONFIG_VP8_ENCODER
128 return vpx_codec_enc_config_default(&vpx_codec_vp8_cx_algo, cfg, usage);
130 return VPX_CODEC_INCAPABLE;
135 const libvpx_test::VP8CodecFactory kVP8;
137 #define VP8_INSTANTIATE_TEST_CASE(test, ...)\
138 INSTANTIATE_TEST_CASE_P(VP8, test, \
139 ::testing::Combine( \
140 ::testing::Values(static_cast<const libvpx_test::CodecFactory*>( \
141 &libvpx_test::kVP8)), \
144 #define VP8_INSTANTIATE_TEST_CASE(test, ...)
149 * VP9 Codec Definitions
152 class VP9Decoder : public Decoder {
154 VP9Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
155 : Decoder(cfg, deadline) {}
158 virtual const vpx_codec_iface_t* CodecInterface() const {
159 #if CONFIG_VP9_DECODER
160 return &vpx_codec_vp9_dx_algo;
167 class VP9Encoder : public Encoder {
169 VP9Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
170 const unsigned long init_flags, TwopassStatsStore *stats)
171 : Encoder(cfg, deadline, init_flags, stats) {}
174 virtual const vpx_codec_iface_t* CodecInterface() const {
175 #if CONFIG_VP9_ENCODER
176 return &vpx_codec_vp9_cx_algo;
183 class VP9CodecFactory : public CodecFactory {
185 VP9CodecFactory() : CodecFactory() {}
187 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
188 unsigned long deadline) const {
189 #if CONFIG_VP9_DECODER
190 return new VP9Decoder(cfg, deadline);
196 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
197 unsigned long deadline,
198 const unsigned long init_flags,
199 TwopassStatsStore *stats) const {
200 #if CONFIG_VP9_ENCODER
201 return new VP9Encoder(cfg, deadline, init_flags, stats);
207 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
209 #if CONFIG_VP9_ENCODER
210 return vpx_codec_enc_config_default(&vpx_codec_vp9_cx_algo, cfg, usage);
212 return VPX_CODEC_INCAPABLE;
217 const libvpx_test::VP9CodecFactory kVP9;
219 #define VP9_INSTANTIATE_TEST_CASE(test, ...)\
220 INSTANTIATE_TEST_CASE_P(VP9, test, \
221 ::testing::Combine( \
222 ::testing::Values(static_cast<const libvpx_test::CodecFactory*>( \
223 &libvpx_test::kVP9)), \
226 #define VP9_INSTANTIATE_TEST_CASE(test, ...)
230 } // namespace libvpx_test
232 #endif // TEST_CODEC_FACTORY_H_