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 {
31 virtual ~CodecFactory() {}
33 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
34 unsigned long deadline) const = 0;
36 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
37 unsigned long deadline,
38 const unsigned long init_flags,
39 TwopassStatsStore *stats) const = 0;
41 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
45 /* Provide CodecTestWith<n>Params classes for a variable number of parameters
46 * to avoid having to include a pointer to the CodecFactory in every test
50 class CodecTestWithParam : public ::testing::TestWithParam<
51 std::tr1::tuple< const libvpx_test::CodecFactory*, T1 > > {
54 template<class T1, class T2>
55 class CodecTestWith2Params : public ::testing::TestWithParam<
56 std::tr1::tuple< const libvpx_test::CodecFactory*, T1, T2 > > {
59 template<class T1, class T2, class T3>
60 class CodecTestWith3Params : public ::testing::TestWithParam<
61 std::tr1::tuple< const libvpx_test::CodecFactory*, T1, T2, T3 > > {
65 * VP8 Codec Definitions
68 class VP8Decoder : public Decoder {
70 VP8Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
71 : Decoder(cfg, deadline) {}
74 virtual vpx_codec_iface_t* CodecInterface() const {
75 #if CONFIG_VP8_DECODER
76 return &vpx_codec_vp8_dx_algo;
83 class VP8Encoder : public Encoder {
85 VP8Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
86 const unsigned long init_flags, TwopassStatsStore *stats)
87 : Encoder(cfg, deadline, init_flags, stats) {}
90 virtual vpx_codec_iface_t* CodecInterface() const {
91 #if CONFIG_VP8_ENCODER
92 return &vpx_codec_vp8_cx_algo;
99 class VP8CodecFactory : public CodecFactory {
101 VP8CodecFactory() : CodecFactory() {}
103 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
104 unsigned long deadline) const {
105 #if CONFIG_VP8_DECODER
106 return new VP8Decoder(cfg, deadline);
112 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
113 unsigned long deadline,
114 const unsigned long init_flags,
115 TwopassStatsStore *stats) const {
116 #if CONFIG_VP8_ENCODER
117 return new VP8Encoder(cfg, deadline, init_flags, stats);
123 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
125 #if CONFIG_VP8_ENCODER
126 return vpx_codec_enc_config_default(&vpx_codec_vp8_cx_algo, cfg, usage);
128 return VPX_CODEC_INCAPABLE;
133 const libvpx_test::VP8CodecFactory kVP8;
135 #define VP8_INSTANTIATE_TEST_CASE(test, ...)\
136 INSTANTIATE_TEST_CASE_P(VP8, test, \
137 ::testing::Combine( \
138 ::testing::Values(static_cast<const libvpx_test::CodecFactory*>( \
139 &libvpx_test::kVP8)), \
142 #define VP8_INSTANTIATE_TEST_CASE(test, ...)
147 * VP9 Codec Definitions
150 class VP9Decoder : public Decoder {
152 VP9Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
153 : Decoder(cfg, deadline) {}
156 virtual vpx_codec_iface_t* CodecInterface() const {
157 #if CONFIG_VP9_DECODER
158 return &vpx_codec_vp9_dx_algo;
165 class VP9Encoder : public Encoder {
167 VP9Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
168 const unsigned long init_flags, TwopassStatsStore *stats)
169 : Encoder(cfg, deadline, init_flags, stats) {}
172 virtual vpx_codec_iface_t* CodecInterface() const {
173 #if CONFIG_VP9_ENCODER
174 return &vpx_codec_vp9_cx_algo;
181 class VP9CodecFactory : public CodecFactory {
183 VP9CodecFactory() : CodecFactory() {}
185 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
186 unsigned long deadline) const {
187 #if CONFIG_VP9_DECODER
188 return new VP9Decoder(cfg, deadline);
194 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
195 unsigned long deadline,
196 const unsigned long init_flags,
197 TwopassStatsStore *stats) const {
198 #if CONFIG_VP9_ENCODER
199 return new VP9Encoder(cfg, deadline, init_flags, stats);
205 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
207 #if CONFIG_VP9_ENCODER
208 return vpx_codec_enc_config_default(&vpx_codec_vp9_cx_algo, cfg, usage);
210 return VPX_CODEC_INCAPABLE;
215 const libvpx_test::VP9CodecFactory kVP9;
217 #define VP9_INSTANTIATE_TEST_CASE(test, ...)\
218 INSTANTIATE_TEST_CASE_P(VP9, test, \
219 ::testing::Combine( \
220 ::testing::Values(static_cast<const libvpx_test::CodecFactory*>( \
221 &libvpx_test::kVP9)), \
224 #define VP9_INSTANTIATE_TEST_CASE(test, ...)
228 } // namespace libvpx_test
230 #endif // TEST_CODEC_FACTORY_H_