Bug 1771985 [wpt PR 34266] - [FedCM] Move set_cookie into the helper file to share...
[gecko.git] / third_party / aom / test / codec_factory.h
blobdd99110ee6a08e285530f8db5110bfc17ad8cffc
1 /*
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"
20 #endif
21 #if CONFIG_AV1_DECODER
22 #include "aom/aomdx.h"
23 #endif
25 #include "test/decode_test_driver.h"
26 #include "test/encode_test_driver.h"
27 namespace libaom_test {
29 const int kCodecFactoryParam = 0;
31 class CodecFactory {
32 public:
33 CodecFactory() {}
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,
47 int usage) const = 0;
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
52 * definition.
54 template <class T1>
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 {
83 public:
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) {}
89 protected:
90 virtual aom_codec_iface_t *CodecInterface() const {
91 #if CONFIG_AV1_DECODER
92 return aom_codec_av1_dx();
93 #else
94 return NULL;
95 #endif
99 class AV1Encoder : public Encoder {
100 public:
101 AV1Encoder(aom_codec_enc_cfg_t cfg, const uint32_t init_flags,
102 TwopassStatsStore *stats)
103 : Encoder(cfg, init_flags, stats) {}
105 protected:
106 virtual aom_codec_iface_t *CodecInterface() const {
107 #if CONFIG_AV1_ENCODER
108 return aom_codec_av1_cx();
109 #else
110 return NULL;
111 #endif
115 class AV1CodecFactory : public CodecFactory {
116 public:
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);
127 #else
128 (void)cfg;
129 (void)flags;
130 return NULL;
131 #endif
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);
139 #else
140 (void)cfg;
141 (void)init_flags;
142 (void)stats;
143 return NULL;
144 #endif
147 virtual aom_codec_err_t DefaultEncoderConfig(aom_codec_enc_cfg_t *cfg,
148 int usage) const {
149 #if CONFIG_AV1_ENCODER
150 return aom_codec_enc_config_default(aom_codec_av1_cx(), cfg, usage);
151 #else
152 (void)cfg;
153 (void)usage;
154 return AOM_CODEC_INCAPABLE;
155 #endif
159 const libaom_test::AV1CodecFactory kAV1;
161 #define AV1_INSTANTIATE_TEST_CASE(test, ...) \
162 INSTANTIATE_TEST_CASE_P( \
163 AV1, test, \
164 ::testing::Combine( \
165 ::testing::Values(static_cast<const libaom_test::CodecFactory *>( \
166 &libaom_test::kAV1)), \
167 __VA_ARGS__))
169 } // namespace libaom_test
170 #endif // AOM_TEST_CODEC_FACTORY_H_