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 Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
39 const vpx_codec_flags_t flags,
40 unsigned long deadline) const = 0; // NOLINT
42 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
43 unsigned long deadline,
44 const unsigned long init_flags,
45 TwopassStatsStore *stats) const = 0;
47 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
51 /* Provide CodecTestWith<n>Params classes for a variable number of parameters
52 * to avoid having to include a pointer to the CodecFactory in every test
56 class CodecTestWithParam : public ::testing::TestWithParam<
57 std::tr1::tuple< const libvpx_test::CodecFactory*, T1 > > {
60 template<class T1, class T2>
61 class CodecTestWith2Params : public ::testing::TestWithParam<
62 std::tr1::tuple< const libvpx_test::CodecFactory*, T1, T2 > > {
65 template<class T1, class T2, class T3>
66 class CodecTestWith3Params : public ::testing::TestWithParam<
67 std::tr1::tuple< const libvpx_test::CodecFactory*, T1, T2, T3 > > {
71 * VP8 Codec Definitions
74 class VP8Decoder : public Decoder {
76 VP8Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
77 : Decoder(cfg, deadline) {}
79 VP8Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
80 unsigned long deadline) // NOLINT
81 : Decoder(cfg, flag, deadline) {}
84 virtual vpx_codec_iface_t* CodecInterface() const {
85 #if CONFIG_VP8_DECODER
86 return &vpx_codec_vp8_dx_algo;
93 class VP8Encoder : public Encoder {
95 VP8Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
96 const unsigned long init_flags, TwopassStatsStore *stats)
97 : Encoder(cfg, deadline, init_flags, stats) {}
100 virtual vpx_codec_iface_t* CodecInterface() const {
101 #if CONFIG_VP8_ENCODER
102 return &vpx_codec_vp8_cx_algo;
109 class VP8CodecFactory : public CodecFactory {
111 VP8CodecFactory() : CodecFactory() {}
113 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
114 unsigned long deadline) const {
115 return CreateDecoder(cfg, 0, deadline);
118 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
119 const vpx_codec_flags_t flags,
120 unsigned long deadline) const { // NOLINT
121 #if CONFIG_VP8_DECODER
122 return new VP8Decoder(cfg, flags, deadline);
128 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
129 unsigned long deadline,
130 const unsigned long init_flags,
131 TwopassStatsStore *stats) const {
132 #if CONFIG_VP8_ENCODER
133 return new VP8Encoder(cfg, deadline, init_flags, stats);
139 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
141 #if CONFIG_VP8_ENCODER
142 return vpx_codec_enc_config_default(&vpx_codec_vp8_cx_algo, cfg, usage);
144 return VPX_CODEC_INCAPABLE;
149 const libvpx_test::VP8CodecFactory kVP8;
151 #define VP8_INSTANTIATE_TEST_CASE(test, ...)\
152 INSTANTIATE_TEST_CASE_P(VP8, test, \
153 ::testing::Combine( \
154 ::testing::Values(static_cast<const libvpx_test::CodecFactory*>( \
155 &libvpx_test::kVP8)), \
158 #define VP8_INSTANTIATE_TEST_CASE(test, ...)
163 * VP9 Codec Definitions
166 class VP9Decoder : public Decoder {
168 VP9Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
169 : Decoder(cfg, deadline) {}
171 VP9Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
172 unsigned long deadline) // NOLINT
173 : Decoder(cfg, flag, deadline) {}
176 virtual vpx_codec_iface_t* CodecInterface() const {
177 #if CONFIG_VP9_DECODER
178 return &vpx_codec_vp9_dx_algo;
185 class VP9Encoder : public Encoder {
187 VP9Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
188 const unsigned long init_flags, TwopassStatsStore *stats)
189 : Encoder(cfg, deadline, init_flags, stats) {}
192 virtual vpx_codec_iface_t* CodecInterface() const {
193 #if CONFIG_VP9_ENCODER
194 return &vpx_codec_vp9_cx_algo;
201 class VP9CodecFactory : public CodecFactory {
203 VP9CodecFactory() : CodecFactory() {}
205 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
206 unsigned long deadline) const {
207 return CreateDecoder(cfg, 0, deadline);
210 virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
211 const vpx_codec_flags_t flags,
212 unsigned long deadline) const { // NOLINT
213 #if CONFIG_VP9_DECODER
214 return new VP9Decoder(cfg, flags, deadline);
220 virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
221 unsigned long deadline,
222 const unsigned long init_flags,
223 TwopassStatsStore *stats) const {
224 #if CONFIG_VP9_ENCODER
225 return new VP9Encoder(cfg, deadline, init_flags, stats);
231 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
233 #if CONFIG_VP9_ENCODER
234 return vpx_codec_enc_config_default(&vpx_codec_vp9_cx_algo, cfg, usage);
236 return VPX_CODEC_INCAPABLE;
241 const libvpx_test::VP9CodecFactory kVP9;
243 #define VP9_INSTANTIATE_TEST_CASE(test, ...)\
244 INSTANTIATE_TEST_CASE_P(VP9, test, \
245 ::testing::Combine( \
246 ::testing::Values(static_cast<const libvpx_test::CodecFactory*>( \
247 &libvpx_test::kVP9)), \
250 #define VP9_INSTANTIATE_TEST_CASE(test, ...)
254 } // namespace libvpx_test
256 #endif // TEST_CODEC_FACTORY_H_