2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
11 #ifndef AOM_TEST_CODEC_FACTORY_H_
12 #define AOM_TEST_CODEC_FACTORY_H_
14 #include "config/aom_config.h"
16 #include "aom/aom_decoder.h"
17 #include "aom/aom_encoder.h"
18 #if CONFIG_AV1_ENCODER
19 #include "aom/aomcx.h"
21 #if CONFIG_AV1_DECODER
22 #include "aom/aomdx.h"
25 #include "test/decode_test_driver.h"
26 #include "test/encode_test_driver.h"
27 namespace libaom_test
{
29 const int kCodecFactoryParam
= 0;
35 virtual ~CodecFactory() {}
37 virtual Decoder
*CreateDecoder(aom_codec_dec_cfg_t cfg
) const = 0;
39 virtual Decoder
*CreateDecoder(aom_codec_dec_cfg_t cfg
,
40 const aom_codec_flags_t flags
) const = 0;
42 virtual Encoder
*CreateEncoder(aom_codec_enc_cfg_t cfg
,
43 const unsigned long init_flags
,
44 TwopassStatsStore
*stats
) const = 0;
46 virtual aom_codec_err_t
DefaultEncoderConfig(aom_codec_enc_cfg_t
*cfg
,
50 /* Provide CodecTestWith<n>Params classes for a variable number of parameters
51 * to avoid having to include a pointer to the CodecFactory in every test
55 class CodecTestWithParam
56 : public ::testing::TestWithParam
<
57 ::testing::tuple
<const libaom_test::CodecFactory
*, T1
> > {};
59 template <class T1
, class T2
>
60 class CodecTestWith2Params
61 : public ::testing::TestWithParam
<
62 ::testing::tuple
<const libaom_test::CodecFactory
*, T1
, T2
> > {};
64 template <class T1
, class T2
, class T3
>
65 class CodecTestWith3Params
66 : public ::testing::TestWithParam
<
67 ::testing::tuple
<const libaom_test::CodecFactory
*, T1
, T2
, T3
> > {};
69 template <class T1
, class T2
, class T3
, class T4
>
70 class CodecTestWith4Params
71 : public ::testing::TestWithParam
< ::testing::tuple
<
72 const libaom_test::CodecFactory
*, T1
, T2
, T3
, T4
> > {};
74 template <class T1
, class T2
, class T3
, class T4
, class T5
>
75 class CodecTestWith5Params
76 : public ::testing::TestWithParam
< ::testing::tuple
<
77 const libaom_test::CodecFactory
*, T1
, T2
, T3
, T4
, T5
> > {};
80 * AV1 Codec Definitions
82 class AV1Decoder
: public Decoder
{
84 explicit AV1Decoder(aom_codec_dec_cfg_t cfg
) : Decoder(cfg
) {}
86 AV1Decoder(aom_codec_dec_cfg_t cfg
, const aom_codec_flags_t flag
)
87 : Decoder(cfg
, flag
) {}
90 virtual aom_codec_iface_t
*CodecInterface() const {
91 #if CONFIG_AV1_DECODER
92 return aom_codec_av1_dx();
99 class AV1Encoder
: public Encoder
{
101 AV1Encoder(aom_codec_enc_cfg_t cfg
, const uint32_t init_flags
,
102 TwopassStatsStore
*stats
)
103 : Encoder(cfg
, init_flags
, stats
) {}
106 virtual aom_codec_iface_t
*CodecInterface() const {
107 #if CONFIG_AV1_ENCODER
108 return aom_codec_av1_cx();
115 class AV1CodecFactory
: public CodecFactory
{
117 AV1CodecFactory() : CodecFactory() {}
119 virtual Decoder
*CreateDecoder(aom_codec_dec_cfg_t cfg
) const {
120 return CreateDecoder(cfg
, 0);
123 virtual Decoder
*CreateDecoder(aom_codec_dec_cfg_t cfg
,
124 const aom_codec_flags_t flags
) const {
125 #if CONFIG_AV1_DECODER
126 return new AV1Decoder(cfg
, flags
);
134 virtual Encoder
*CreateEncoder(aom_codec_enc_cfg_t cfg
,
135 const unsigned long init_flags
,
136 TwopassStatsStore
*stats
) const {
137 #if CONFIG_AV1_ENCODER
138 return new AV1Encoder(cfg
, init_flags
, stats
);
147 virtual aom_codec_err_t
DefaultEncoderConfig(aom_codec_enc_cfg_t
*cfg
,
149 #if CONFIG_AV1_ENCODER
150 return aom_codec_enc_config_default(aom_codec_av1_cx(), cfg
, usage
);
154 return AOM_CODEC_INCAPABLE
;
159 const libaom_test::AV1CodecFactory kAV1
;
161 #define AV1_INSTANTIATE_TEST_CASE(test, ...) \
162 INSTANTIATE_TEST_CASE_P( \
164 ::testing::Combine( \
165 ::testing::Values(static_cast<const libaom_test::CodecFactory *>( \
166 &libaom_test::kAV1)), \
169 } // namespace libaom_test
170 #endif // AOM_TEST_CODEC_FACTORY_H_