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 VPX_TEST_CODEC_FACTORY_H_
11 #define VPX_TEST_CODEC_FACTORY_H_
15 #include "./vpx_config.h"
16 #include "vpx/vpx_decoder.h"
17 #include "vpx/vpx_encoder.h"
18 #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER
19 #include "vpx/vp8cx.h"
21 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER
22 #include "vpx/vp8dx.h"
25 #include "test/decode_test_driver.h"
26 #include "test/encode_test_driver.h"
27 namespace libvpx_test {
29 const int kCodecFactoryParam = 0;
35 virtual ~CodecFactory() {}
37 virtual Decoder *CreateDecoder(vpx_codec_dec_cfg_t cfg) const = 0;
39 virtual Decoder *CreateDecoder(vpx_codec_dec_cfg_t cfg,
40 const vpx_codec_flags_t flags) const = 0;
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
57 : public ::testing::TestWithParam<
58 std::tuple<const libvpx_test::CodecFactory *, T1> > {};
60 template <class T1, class T2>
61 class CodecTestWith2Params
62 : public ::testing::TestWithParam<
63 std::tuple<const libvpx_test::CodecFactory *, T1, T2> > {};
65 template <class T1, class T2, class T3>
66 class CodecTestWith3Params
67 : public ::testing::TestWithParam<
68 std::tuple<const libvpx_test::CodecFactory *, T1, T2, T3> > {};
70 template <class T1, class T2, class T3, class T4>
71 class CodecTestWith4Params
72 : public ::testing::TestWithParam<
73 std::tuple<const libvpx_test::CodecFactory *, T1, T2, T3, T4> > {};
76 * VP8 Codec Definitions
79 class VP8Decoder : public Decoder {
81 explicit VP8Decoder(vpx_codec_dec_cfg_t cfg) : Decoder(cfg) {}
83 VP8Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag)
84 : Decoder(cfg, flag) {}
87 virtual vpx_codec_iface_t *CodecInterface() const {
88 #if CONFIG_VP8_DECODER
89 return &vpx_codec_vp8_dx_algo;
96 class VP8Encoder : public Encoder {
98 VP8Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
99 const unsigned long init_flags, TwopassStatsStore *stats)
100 : Encoder(cfg, deadline, init_flags, stats) {}
103 virtual vpx_codec_iface_t *CodecInterface() const {
104 #if CONFIG_VP8_ENCODER
105 return &vpx_codec_vp8_cx_algo;
112 class VP8CodecFactory : public CodecFactory {
114 VP8CodecFactory() : CodecFactory() {}
116 virtual Decoder *CreateDecoder(vpx_codec_dec_cfg_t cfg) const {
117 return CreateDecoder(cfg, 0);
120 virtual Decoder *CreateDecoder(vpx_codec_dec_cfg_t cfg,
121 const vpx_codec_flags_t flags) const {
122 #if CONFIG_VP8_DECODER
123 return new VP8Decoder(cfg, flags);
131 virtual Encoder *CreateEncoder(vpx_codec_enc_cfg_t cfg,
132 unsigned long deadline,
133 const unsigned long init_flags,
134 TwopassStatsStore *stats) const {
135 #if CONFIG_VP8_ENCODER
136 return new VP8Encoder(cfg, deadline, init_flags, stats);
146 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
148 #if CONFIG_VP8_ENCODER
149 return vpx_codec_enc_config_default(&vpx_codec_vp8_cx_algo, cfg, usage);
153 return VPX_CODEC_INCAPABLE;
158 const libvpx_test::VP8CodecFactory kVP8;
160 #define VP8_INSTANTIATE_TEST_SUITE(test, ...) \
161 INSTANTIATE_TEST_SUITE_P( \
163 ::testing::Combine( \
164 ::testing::Values(static_cast<const libvpx_test::CodecFactory *>( \
165 &libvpx_test::kVP8)), \
168 #define VP8_INSTANTIATE_TEST_SUITE(test, ...)
172 * VP9 Codec Definitions
175 class VP9Decoder : public Decoder {
177 explicit VP9Decoder(vpx_codec_dec_cfg_t cfg) : Decoder(cfg) {}
179 VP9Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag)
180 : Decoder(cfg, flag) {}
183 virtual vpx_codec_iface_t *CodecInterface() const {
184 #if CONFIG_VP9_DECODER
185 return &vpx_codec_vp9_dx_algo;
192 class VP9Encoder : public Encoder {
194 VP9Encoder(vpx_codec_enc_cfg_t cfg, unsigned long deadline,
195 const unsigned long init_flags, TwopassStatsStore *stats)
196 : Encoder(cfg, deadline, init_flags, stats) {}
199 virtual vpx_codec_iface_t *CodecInterface() const {
200 #if CONFIG_VP9_ENCODER
201 return &vpx_codec_vp9_cx_algo;
208 class VP9CodecFactory : public CodecFactory {
210 VP9CodecFactory() : CodecFactory() {}
212 virtual Decoder *CreateDecoder(vpx_codec_dec_cfg_t cfg) const {
213 return CreateDecoder(cfg, 0);
216 virtual Decoder *CreateDecoder(vpx_codec_dec_cfg_t cfg,
217 const vpx_codec_flags_t flags) const {
218 #if CONFIG_VP9_DECODER
219 return new VP9Decoder(cfg, flags);
227 virtual Encoder *CreateEncoder(vpx_codec_enc_cfg_t cfg,
228 unsigned long deadline,
229 const unsigned long init_flags,
230 TwopassStatsStore *stats) const {
231 #if CONFIG_VP9_ENCODER
232 return new VP9Encoder(cfg, deadline, init_flags, stats);
242 virtual vpx_codec_err_t DefaultEncoderConfig(vpx_codec_enc_cfg_t *cfg,
244 #if CONFIG_VP9_ENCODER
245 return vpx_codec_enc_config_default(&vpx_codec_vp9_cx_algo, cfg, usage);
249 return VPX_CODEC_INCAPABLE;
254 const libvpx_test::VP9CodecFactory kVP9;
256 #define VP9_INSTANTIATE_TEST_SUITE(test, ...) \
257 INSTANTIATE_TEST_SUITE_P( \
259 ::testing::Combine( \
260 ::testing::Values(static_cast<const libvpx_test::CodecFactory *>( \
261 &libvpx_test::kVP9)), \
264 #define VP9_INSTANTIATE_TEST_SUITE(test, ...)
267 } // namespace libvpx_test
268 #endif // VPX_TEST_CODEC_FACTORY_H_