]> granicus.if.org Git - libvpx/blob - test/codec_factory.h
Merge "remove vp8 unused uvstride parm in simple loop filter"
[libvpx] / test / codec_factory.h
1 /*
2  *  Copyright (c) 2013 The WebM project authors. All Rights Reserved.
3  *
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.
9  */
10 #ifndef TEST_CODEC_FACTORY_H_
11 #define TEST_CODEC_FACTORY_H_
12
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"
18 #endif
19 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER
20 #include "vpx/vp8dx.h"
21 #endif
22
23 #include "test/decode_test_driver.h"
24 #include "test/encode_test_driver.h"
25 namespace libvpx_test {
26
27 const int kCodecFactoryParam = 0;
28
29 class CodecFactory {
30  public:
31   CodecFactory() {}
32
33   virtual ~CodecFactory() {}
34
35   virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
36                                  unsigned long deadline) const = 0;
37
38   virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
39                                  const vpx_codec_flags_t flags,
40                                  unsigned long deadline)  // NOLINT(runtime/int)
41                                  const = 0;
42
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;
47
48   virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
49                                                int usage) const = 0;
50 };
51
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
54  * definition.
55  */
56 template<class T1>
57 class CodecTestWithParam : public ::testing::TestWithParam<
58     std::tr1::tuple< const libvpx_test::CodecFactory*, T1 > > {
59 };
60
61 template<class T1, class T2>
62 class CodecTestWith2Params : public ::testing::TestWithParam<
63     std::tr1::tuple< const libvpx_test::CodecFactory*, T1, T2 > > {
64 };
65
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 > > {
69 };
70
71 /*
72  * VP8 Codec Definitions
73  */
74 #if CONFIG_VP8
75 class VP8Decoder : public Decoder {
76  public:
77   VP8Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
78       : Decoder(cfg, deadline) {}
79
80   VP8Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
81              unsigned long deadline)  // NOLINT
82       : Decoder(cfg, flag, deadline) {}
83
84  protected:
85   virtual vpx_codec_iface_t* CodecInterface() const {
86 #if CONFIG_VP8_DECODER
87     return &vpx_codec_vp8_dx_algo;
88 #else
89     return NULL;
90 #endif
91   }
92 };
93
94 class VP8Encoder : public Encoder {
95  public:
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) {}
99
100  protected:
101   virtual vpx_codec_iface_t* CodecInterface() const {
102 #if CONFIG_VP8_ENCODER
103     return &vpx_codec_vp8_cx_algo;
104 #else
105     return NULL;
106 #endif
107   }
108 };
109
110 class VP8CodecFactory : public CodecFactory {
111  public:
112   VP8CodecFactory() : CodecFactory() {}
113
114   virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
115                                  unsigned long deadline) const {
116     return CreateDecoder(cfg, 0, deadline);
117   }
118
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);
124 #else
125     return NULL;
126 #endif
127   }
128
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);
135 #else
136     return NULL;
137 #endif
138   }
139
140   virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
141                                                int usage) const {
142 #if CONFIG_VP8_ENCODER
143     return vpx_codec_enc_config_default(&vpx_codec_vp8_cx_algo, cfg, usage);
144 #else
145     return VPX_CODEC_INCAPABLE;
146 #endif
147   }
148 };
149
150 const libvpx_test::VP8CodecFactory kVP8;
151
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)), \
157           __VA_ARGS__))
158 #else
159 #define VP8_INSTANTIATE_TEST_CASE(test, ...)
160 #endif  // CONFIG_VP8
161
162
163 /*
164  * VP9 Codec Definitions
165  */
166 #if CONFIG_VP9
167 class VP9Decoder : public Decoder {
168  public:
169   VP9Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
170       : Decoder(cfg, deadline) {}
171
172   VP9Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
173              unsigned long deadline)  // NOLINT
174       : Decoder(cfg, flag, deadline) {}
175
176  protected:
177   virtual vpx_codec_iface_t* CodecInterface() const {
178 #if CONFIG_VP9_DECODER
179     return &vpx_codec_vp9_dx_algo;
180 #else
181     return NULL;
182 #endif
183   }
184 };
185
186 class VP9Encoder : public Encoder {
187  public:
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) {}
191
192  protected:
193   virtual vpx_codec_iface_t* CodecInterface() const {
194 #if CONFIG_VP9_ENCODER
195     return &vpx_codec_vp9_cx_algo;
196 #else
197     return NULL;
198 #endif
199   }
200 };
201
202 class VP9CodecFactory : public CodecFactory {
203  public:
204   VP9CodecFactory() : CodecFactory() {}
205
206   virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
207                                  unsigned long deadline) const {
208     return CreateDecoder(cfg, 0, deadline);
209   }
210
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);
216 #else
217     return NULL;
218 #endif
219   }
220
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);
227 #else
228     return NULL;
229 #endif
230   }
231
232   virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
233                                                int usage) const {
234 #if CONFIG_VP9_ENCODER
235     return vpx_codec_enc_config_default(&vpx_codec_vp9_cx_algo, cfg, usage);
236 #else
237     return VPX_CODEC_INCAPABLE;
238 #endif
239   }
240 };
241
242 const libvpx_test::VP9CodecFactory kVP9;
243
244 #define VP9_INSTANTIATE_TEST_CASE(test, ...)\
245   INSTANTIATE_TEST_CASE_P(VP9, test, \
246       ::testing::Combine( \
247           ::testing::Values(static_cast<const libvpx_test::CodecFactory*>( \
248                &libvpx_test::kVP9)), \
249           __VA_ARGS__))
250 #else
251 #define VP9_INSTANTIATE_TEST_CASE(test, ...)
252 #endif  // CONFIG_VP9
253
254
255 }  // namespace libvpx_test
256
257 #endif  // TEST_CODEC_FACTORY_H_