xref: /aosp_15_r20/external/libaom/aom/aom_codec.h (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker  *
4*77c1e3ccSAndroid Build Coastguard Worker  * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker  * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker  * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker  */
11*77c1e3ccSAndroid Build Coastguard Worker 
12*77c1e3ccSAndroid Build Coastguard Worker ///////////////////////////////////////////////////////////////////////////////
13*77c1e3ccSAndroid Build Coastguard Worker // Internal implementation details
14*77c1e3ccSAndroid Build Coastguard Worker ///////////////////////////////////////////////////////////////////////////////
15*77c1e3ccSAndroid Build Coastguard Worker //
16*77c1e3ccSAndroid Build Coastguard Worker // There are two levels of interfaces used to access the AOM codec: the
17*77c1e3ccSAndroid Build Coastguard Worker // aom_codec_iface and the aom_codec_ctx.
18*77c1e3ccSAndroid Build Coastguard Worker //
19*77c1e3ccSAndroid Build Coastguard Worker // 1. aom_codec_iface_t
20*77c1e3ccSAndroid Build Coastguard Worker //    (Related files: aom/aom_codec.h, aom/src/aom_codec.c,
21*77c1e3ccSAndroid Build Coastguard Worker //    aom/internal/aom_codec_internal.h, av1/av1_cx_iface.c,
22*77c1e3ccSAndroid Build Coastguard Worker //    av1/av1_dx_iface.c)
23*77c1e3ccSAndroid Build Coastguard Worker //
24*77c1e3ccSAndroid Build Coastguard Worker // Used to initialize the codec context, which contains the configuration for
25*77c1e3ccSAndroid Build Coastguard Worker // for modifying the encoder/decoder during run-time. See the other
26*77c1e3ccSAndroid Build Coastguard Worker // documentation in this header file for more details. For the most part,
27*77c1e3ccSAndroid Build Coastguard Worker // users will call helper functions, such as aom_codec_iface_name,
28*77c1e3ccSAndroid Build Coastguard Worker // aom_codec_get_caps, etc., to interact with it.
29*77c1e3ccSAndroid Build Coastguard Worker //
30*77c1e3ccSAndroid Build Coastguard Worker // The main purpose of the aom_codec_iface_t is to provide a way to generate
31*77c1e3ccSAndroid Build Coastguard Worker // a default codec config, find out what capabilities the implementation has,
32*77c1e3ccSAndroid Build Coastguard Worker // and create an aom_codec_ctx_t (which is actually used to interact with the
33*77c1e3ccSAndroid Build Coastguard Worker // codec).
34*77c1e3ccSAndroid Build Coastguard Worker //
35*77c1e3ccSAndroid Build Coastguard Worker // Note that the implementations for the AV1 algorithm are located in
36*77c1e3ccSAndroid Build Coastguard Worker // av1/av1_cx_iface.c and av1/av1_dx_iface.c
37*77c1e3ccSAndroid Build Coastguard Worker //
38*77c1e3ccSAndroid Build Coastguard Worker //
39*77c1e3ccSAndroid Build Coastguard Worker // 2. aom_codec_ctx_t
40*77c1e3ccSAndroid Build Coastguard Worker //  (Related files: aom/aom_codec.h, av1/av1_cx_iface.c, av1/av1_dx_iface.c,
41*77c1e3ccSAndroid Build Coastguard Worker //   aom/aomcx.h, aom/aomdx.h, aom/src/aom_encoder.c, aom/src/aom_decoder.c)
42*77c1e3ccSAndroid Build Coastguard Worker //
43*77c1e3ccSAndroid Build Coastguard Worker // The actual interface between user code and the codec. It stores the name
44*77c1e3ccSAndroid Build Coastguard Worker // of the codec, a pointer back to the aom_codec_iface_t that initialized it,
45*77c1e3ccSAndroid Build Coastguard Worker // initialization flags, a config for either encoder or the decoder, and a
46*77c1e3ccSAndroid Build Coastguard Worker // pointer to internal data.
47*77c1e3ccSAndroid Build Coastguard Worker //
48*77c1e3ccSAndroid Build Coastguard Worker // The codec is configured / queried through calls to aom_codec_control,
49*77c1e3ccSAndroid Build Coastguard Worker // which takes a control ID (listed in aomcx.h and aomdx.h) and a parameter.
50*77c1e3ccSAndroid Build Coastguard Worker // In the case of "getter" control IDs, the parameter is modified to have
51*77c1e3ccSAndroid Build Coastguard Worker // the requested value; in the case of "setter" control IDs, the codec's
52*77c1e3ccSAndroid Build Coastguard Worker // configuration is changed based on the parameter. Note that a aom_codec_err_t
53*77c1e3ccSAndroid Build Coastguard Worker // is returned, which indicates if the operation was successful or not.
54*77c1e3ccSAndroid Build Coastguard Worker //
55*77c1e3ccSAndroid Build Coastguard Worker // Note that for the encoder, the aom_codec_alg_priv_t points to the
56*77c1e3ccSAndroid Build Coastguard Worker // the aom_codec_alg_priv structure in av1/av1_cx_iface.c, and for the decoder,
57*77c1e3ccSAndroid Build Coastguard Worker // the struct in av1/av1_dx_iface.c. Variables such as AV1_COMP cpi are stored
58*77c1e3ccSAndroid Build Coastguard Worker // here and also used in the core algorithm.
59*77c1e3ccSAndroid Build Coastguard Worker //
60*77c1e3ccSAndroid Build Coastguard Worker // At the end, aom_codec_destroy should be called for each initialized
61*77c1e3ccSAndroid Build Coastguard Worker // aom_codec_ctx_t.
62*77c1e3ccSAndroid Build Coastguard Worker 
63*77c1e3ccSAndroid Build Coastguard Worker /*!\defgroup codec Common Algorithm Interface
64*77c1e3ccSAndroid Build Coastguard Worker  * This abstraction allows applications to easily support multiple video
65*77c1e3ccSAndroid Build Coastguard Worker  * formats with minimal code duplication. This section describes the interface
66*77c1e3ccSAndroid Build Coastguard Worker  * common to all codecs (both encoders and decoders).
67*77c1e3ccSAndroid Build Coastguard Worker  * @{
68*77c1e3ccSAndroid Build Coastguard Worker  */
69*77c1e3ccSAndroid Build Coastguard Worker 
70*77c1e3ccSAndroid Build Coastguard Worker /*!\file
71*77c1e3ccSAndroid Build Coastguard Worker  * \brief Describes the codec algorithm interface to applications.
72*77c1e3ccSAndroid Build Coastguard Worker  *
73*77c1e3ccSAndroid Build Coastguard Worker  * This file describes the interface between an application and a
74*77c1e3ccSAndroid Build Coastguard Worker  * video codec algorithm.
75*77c1e3ccSAndroid Build Coastguard Worker  *
76*77c1e3ccSAndroid Build Coastguard Worker  * An application instantiates a specific codec instance by using
77*77c1e3ccSAndroid Build Coastguard Worker  * aom_codec_dec_init() or aom_codec_enc_init() and a pointer to the
78*77c1e3ccSAndroid Build Coastguard Worker  * algorithm's interface structure:
79*77c1e3ccSAndroid Build Coastguard Worker  *     <pre>
80*77c1e3ccSAndroid Build Coastguard Worker  *     my_app.c:
81*77c1e3ccSAndroid Build Coastguard Worker  *       extern aom_codec_iface_t my_codec;
82*77c1e3ccSAndroid Build Coastguard Worker  *       {
83*77c1e3ccSAndroid Build Coastguard Worker  *           aom_codec_ctx_t algo;
84*77c1e3ccSAndroid Build Coastguard Worker  *           int threads = 4;
85*77c1e3ccSAndroid Build Coastguard Worker  *           aom_codec_dec_cfg_t cfg = { threads, 0, 0, 1 };
86*77c1e3ccSAndroid Build Coastguard Worker  *           res = aom_codec_dec_init(&algo, &my_codec, &cfg, 0);
87*77c1e3ccSAndroid Build Coastguard Worker  *       }
88*77c1e3ccSAndroid Build Coastguard Worker  *     </pre>
89*77c1e3ccSAndroid Build Coastguard Worker  *
90*77c1e3ccSAndroid Build Coastguard Worker  * Once initialized, the instance is managed using other functions from
91*77c1e3ccSAndroid Build Coastguard Worker  * the aom_codec_* family.
92*77c1e3ccSAndroid Build Coastguard Worker  */
93*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_AOM_AOM_CODEC_H_
94*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AOM_AOM_CODEC_H_
95*77c1e3ccSAndroid Build Coastguard Worker 
96*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
97*77c1e3ccSAndroid Build Coastguard Worker extern "C" {
98*77c1e3ccSAndroid Build Coastguard Worker #endif
99*77c1e3ccSAndroid Build Coastguard Worker 
100*77c1e3ccSAndroid Build Coastguard Worker #include "aom/aom_image.h"
101*77c1e3ccSAndroid Build Coastguard Worker #include "aom/aom_integer.h"
102*77c1e3ccSAndroid Build Coastguard Worker 
103*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Decorator indicating a function is deprecated */
104*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_DEPRECATED
105*77c1e3ccSAndroid Build Coastguard Worker #if defined(__GNUC__)
106*77c1e3ccSAndroid Build Coastguard Worker #define AOM_DEPRECATED __attribute__((deprecated))
107*77c1e3ccSAndroid Build Coastguard Worker #elif defined(_MSC_VER)
108*77c1e3ccSAndroid Build Coastguard Worker #define AOM_DEPRECATED
109*77c1e3ccSAndroid Build Coastguard Worker #else
110*77c1e3ccSAndroid Build Coastguard Worker #define AOM_DEPRECATED
111*77c1e3ccSAndroid Build Coastguard Worker #endif
112*77c1e3ccSAndroid Build Coastguard Worker #endif /* AOM_DEPRECATED */
113*77c1e3ccSAndroid Build Coastguard Worker 
114*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_DECLSPEC_DEPRECATED
115*77c1e3ccSAndroid Build Coastguard Worker #if defined(__GNUC__)
116*77c1e3ccSAndroid Build Coastguard Worker #define AOM_DECLSPEC_DEPRECATED /**< \copydoc #AOM_DEPRECATED */
117*77c1e3ccSAndroid Build Coastguard Worker #elif defined(_MSC_VER)
118*77c1e3ccSAndroid Build Coastguard Worker /*!\brief \copydoc #AOM_DEPRECATED */
119*77c1e3ccSAndroid Build Coastguard Worker #define AOM_DECLSPEC_DEPRECATED __declspec(deprecated)
120*77c1e3ccSAndroid Build Coastguard Worker #else
121*77c1e3ccSAndroid Build Coastguard Worker #define AOM_DECLSPEC_DEPRECATED /**< \copydoc #AOM_DEPRECATED */
122*77c1e3ccSAndroid Build Coastguard Worker #endif
123*77c1e3ccSAndroid Build Coastguard Worker #endif /* AOM_DECLSPEC_DEPRECATED */
124*77c1e3ccSAndroid Build Coastguard Worker 
125*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Decorator indicating a function is potentially unused */
126*77c1e3ccSAndroid Build Coastguard Worker #ifdef AOM_UNUSED
127*77c1e3ccSAndroid Build Coastguard Worker #elif defined(__GNUC__) || defined(__clang__)
128*77c1e3ccSAndroid Build Coastguard Worker #define AOM_UNUSED __attribute__((unused))
129*77c1e3ccSAndroid Build Coastguard Worker #else
130*77c1e3ccSAndroid Build Coastguard Worker #define AOM_UNUSED
131*77c1e3ccSAndroid Build Coastguard Worker #endif
132*77c1e3ccSAndroid Build Coastguard Worker 
133*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Decorator indicating that given struct/union/enum is packed */
134*77c1e3ccSAndroid Build Coastguard Worker #ifndef ATTRIBUTE_PACKED
135*77c1e3ccSAndroid Build Coastguard Worker #if defined(__GNUC__)
136*77c1e3ccSAndroid Build Coastguard Worker #define ATTRIBUTE_PACKED __attribute__((packed))
137*77c1e3ccSAndroid Build Coastguard Worker #elif defined(_MSC_VER)
138*77c1e3ccSAndroid Build Coastguard Worker #define ATTRIBUTE_PACKED
139*77c1e3ccSAndroid Build Coastguard Worker #else
140*77c1e3ccSAndroid Build Coastguard Worker #define ATTRIBUTE_PACKED
141*77c1e3ccSAndroid Build Coastguard Worker #endif
142*77c1e3ccSAndroid Build Coastguard Worker #endif /* ATTRIBUTE_PACKED */
143*77c1e3ccSAndroid Build Coastguard Worker 
144*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Current ABI version number
145*77c1e3ccSAndroid Build Coastguard Worker  *
146*77c1e3ccSAndroid Build Coastguard Worker  * \internal
147*77c1e3ccSAndroid Build Coastguard Worker  * If this file is altered in any way that changes the ABI, this value
148*77c1e3ccSAndroid Build Coastguard Worker  * must be bumped.  Examples include, but are not limited to, changing
149*77c1e3ccSAndroid Build Coastguard Worker  * types, removing or reassigning enums, adding/removing/rearranging
150*77c1e3ccSAndroid Build Coastguard Worker  * fields to structures
151*77c1e3ccSAndroid Build Coastguard Worker  */
152*77c1e3ccSAndroid Build Coastguard Worker #define AOM_CODEC_ABI_VERSION (7 + AOM_IMAGE_ABI_VERSION) /**<\hideinitializer*/
153*77c1e3ccSAndroid Build Coastguard Worker 
154*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Algorithm return codes */
155*77c1e3ccSAndroid Build Coastguard Worker typedef enum {
156*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Operation completed without error */
157*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_OK,
158*77c1e3ccSAndroid Build Coastguard Worker 
159*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Unspecified error */
160*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_ERROR,
161*77c1e3ccSAndroid Build Coastguard Worker 
162*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Memory operation failed */
163*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_MEM_ERROR,
164*77c1e3ccSAndroid Build Coastguard Worker 
165*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief ABI version mismatch */
166*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_ABI_MISMATCH,
167*77c1e3ccSAndroid Build Coastguard Worker 
168*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Algorithm does not have required capability */
169*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_INCAPABLE,
170*77c1e3ccSAndroid Build Coastguard Worker 
171*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief The given bitstream is not supported.
172*77c1e3ccSAndroid Build Coastguard Worker    *
173*77c1e3ccSAndroid Build Coastguard Worker    * The bitstream was unable to be parsed at the highest level. The decoder
174*77c1e3ccSAndroid Build Coastguard Worker    * is unable to proceed. This error \ref SHOULD be treated as fatal to the
175*77c1e3ccSAndroid Build Coastguard Worker    * stream. */
176*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_UNSUP_BITSTREAM,
177*77c1e3ccSAndroid Build Coastguard Worker 
178*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Encoded bitstream uses an unsupported feature
179*77c1e3ccSAndroid Build Coastguard Worker    *
180*77c1e3ccSAndroid Build Coastguard Worker    * The decoder does not implement a feature required by the encoder. This
181*77c1e3ccSAndroid Build Coastguard Worker    * return code should only be used for features that prevent future
182*77c1e3ccSAndroid Build Coastguard Worker    * pictures from being properly decoded. This error \ref MAY be treated as
183*77c1e3ccSAndroid Build Coastguard Worker    * fatal to the stream or \ref MAY be treated as fatal to the current GOP.
184*77c1e3ccSAndroid Build Coastguard Worker    */
185*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_UNSUP_FEATURE,
186*77c1e3ccSAndroid Build Coastguard Worker 
187*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief The coded data for this stream is corrupt or incomplete
188*77c1e3ccSAndroid Build Coastguard Worker    *
189*77c1e3ccSAndroid Build Coastguard Worker    * There was a problem decoding the current frame.  This return code
190*77c1e3ccSAndroid Build Coastguard Worker    * should only be used for failures that prevent future pictures from
191*77c1e3ccSAndroid Build Coastguard Worker    * being properly decoded. This error \ref MAY be treated as fatal to the
192*77c1e3ccSAndroid Build Coastguard Worker    * stream or \ref MAY be treated as fatal to the current GOP. If decoding
193*77c1e3ccSAndroid Build Coastguard Worker    * is continued for the current GOP, artifacts may be present.
194*77c1e3ccSAndroid Build Coastguard Worker    */
195*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_CORRUPT_FRAME,
196*77c1e3ccSAndroid Build Coastguard Worker 
197*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief An application-supplied parameter is not valid.
198*77c1e3ccSAndroid Build Coastguard Worker    *
199*77c1e3ccSAndroid Build Coastguard Worker    */
200*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_INVALID_PARAM,
201*77c1e3ccSAndroid Build Coastguard Worker 
202*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief An iterator reached the end of list.
203*77c1e3ccSAndroid Build Coastguard Worker    *
204*77c1e3ccSAndroid Build Coastguard Worker    */
205*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_LIST_END
206*77c1e3ccSAndroid Build Coastguard Worker 
207*77c1e3ccSAndroid Build Coastguard Worker } aom_codec_err_t;
208*77c1e3ccSAndroid Build Coastguard Worker 
209*77c1e3ccSAndroid Build Coastguard Worker /*! \brief Codec capabilities bitfield
210*77c1e3ccSAndroid Build Coastguard Worker  *
211*77c1e3ccSAndroid Build Coastguard Worker  *  Each codec advertises the capabilities it supports as part of its
212*77c1e3ccSAndroid Build Coastguard Worker  *  ::aom_codec_iface_t interface structure. Capabilities are extra interfaces
213*77c1e3ccSAndroid Build Coastguard Worker  *  or functionality, and are not required to be supported.
214*77c1e3ccSAndroid Build Coastguard Worker  *
215*77c1e3ccSAndroid Build Coastguard Worker  *  The available flags are specified by AOM_CODEC_CAP_* defines.
216*77c1e3ccSAndroid Build Coastguard Worker  */
217*77c1e3ccSAndroid Build Coastguard Worker typedef long aom_codec_caps_t;
218*77c1e3ccSAndroid Build Coastguard Worker #define AOM_CODEC_CAP_DECODER 0x1 /**< Is a decoder */
219*77c1e3ccSAndroid Build Coastguard Worker #define AOM_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */
220*77c1e3ccSAndroid Build Coastguard Worker 
221*77c1e3ccSAndroid Build Coastguard Worker /*! \brief Initialization-time Feature Enabling
222*77c1e3ccSAndroid Build Coastguard Worker  *
223*77c1e3ccSAndroid Build Coastguard Worker  *  Certain codec features must be known at initialization time, to allow for
224*77c1e3ccSAndroid Build Coastguard Worker  *  proper memory allocation.
225*77c1e3ccSAndroid Build Coastguard Worker  *
226*77c1e3ccSAndroid Build Coastguard Worker  *  The available flags are specified by AOM_CODEC_USE_* defines. The bits are
227*77c1e3ccSAndroid Build Coastguard Worker  *  allocated as follows:
228*77c1e3ccSAndroid Build Coastguard Worker  *      0x1 -     0x80: codec (common to decoder and encoder)
229*77c1e3ccSAndroid Build Coastguard Worker  *    0x100 -   0x8000: decoder
230*77c1e3ccSAndroid Build Coastguard Worker  *  0x10000 - 0x800000: encoder
231*77c1e3ccSAndroid Build Coastguard Worker  */
232*77c1e3ccSAndroid Build Coastguard Worker typedef long aom_codec_flags_t;
233*77c1e3ccSAndroid Build Coastguard Worker 
234*77c1e3ccSAndroid Build Coastguard Worker // Experimental feature policy
235*77c1e3ccSAndroid Build Coastguard Worker //
236*77c1e3ccSAndroid Build Coastguard Worker // New features may be marked as experimental. Experimental features are not
237*77c1e3ccSAndroid Build Coastguard Worker // part of the stable API and may be modified or removed in a future release.
238*77c1e3ccSAndroid Build Coastguard Worker // Experimental features are made available only if you pass the
239*77c1e3ccSAndroid Build Coastguard Worker // AOM_CODEC_USE_EXPERIMENTAL flag to the codec init function.
240*77c1e3ccSAndroid Build Coastguard Worker //
241*77c1e3ccSAndroid Build Coastguard Worker // If you use experimental features, you must rebuild your code whenever you
242*77c1e3ccSAndroid Build Coastguard Worker // update to a new libaom release, and you must be prepared to modify your code
243*77c1e3ccSAndroid Build Coastguard Worker // when an experimental feature you use is modified or removed. If you are not
244*77c1e3ccSAndroid Build Coastguard Worker // sure, DO NOT use experimental features.
245*77c1e3ccSAndroid Build Coastguard Worker #define AOM_CODEC_USE_EXPERIMENTAL 0x1 /**< Enables experimental features */
246*77c1e3ccSAndroid Build Coastguard Worker 
247*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Time Stamp Type
248*77c1e3ccSAndroid Build Coastguard Worker  *
249*77c1e3ccSAndroid Build Coastguard Worker  * An integer, which when multiplied by the stream's time base, provides
250*77c1e3ccSAndroid Build Coastguard Worker  * the absolute time of a sample.
251*77c1e3ccSAndroid Build Coastguard Worker  */
252*77c1e3ccSAndroid Build Coastguard Worker typedef int64_t aom_codec_pts_t;
253*77c1e3ccSAndroid Build Coastguard Worker 
254*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Codec interface structure.
255*77c1e3ccSAndroid Build Coastguard Worker  *
256*77c1e3ccSAndroid Build Coastguard Worker  * Contains function pointers and other data private to the codec
257*77c1e3ccSAndroid Build Coastguard Worker  * implementation. This structure is opaque to the application. Common
258*77c1e3ccSAndroid Build Coastguard Worker  * functions used with this structure:
259*77c1e3ccSAndroid Build Coastguard Worker  *   - aom_codec_iface_name(aom_codec_iface_t *iface): get the
260*77c1e3ccSAndroid Build Coastguard Worker  *     name of the codec
261*77c1e3ccSAndroid Build Coastguard Worker  *   - aom_codec_get_caps(aom_codec_iface_t *iface): returns
262*77c1e3ccSAndroid Build Coastguard Worker  *     the capabilities of the codec
263*77c1e3ccSAndroid Build Coastguard Worker  *   - aom_codec_enc_config_default: generate the default config for
264*77c1e3ccSAndroid Build Coastguard Worker  *     initializing the encoder (see documentation in aom_encoder.h)
265*77c1e3ccSAndroid Build Coastguard Worker  *   - aom_codec_dec_init, aom_codec_enc_init: initialize the codec context
266*77c1e3ccSAndroid Build Coastguard Worker  *     structure (see documentation on aom_codec_ctx).
267*77c1e3ccSAndroid Build Coastguard Worker  *
268*77c1e3ccSAndroid Build Coastguard Worker  * To get access to the AV1 encoder and decoder, use aom_codec_av1_cx() and
269*77c1e3ccSAndroid Build Coastguard Worker  *  aom_codec_av1_dx().
270*77c1e3ccSAndroid Build Coastguard Worker  */
271*77c1e3ccSAndroid Build Coastguard Worker typedef const struct aom_codec_iface aom_codec_iface_t;
272*77c1e3ccSAndroid Build Coastguard Worker 
273*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Codec private data structure.
274*77c1e3ccSAndroid Build Coastguard Worker  *
275*77c1e3ccSAndroid Build Coastguard Worker  * Contains data private to the codec implementation. This structure is opaque
276*77c1e3ccSAndroid Build Coastguard Worker  * to the application.
277*77c1e3ccSAndroid Build Coastguard Worker  */
278*77c1e3ccSAndroid Build Coastguard Worker typedef struct aom_codec_priv aom_codec_priv_t;
279*77c1e3ccSAndroid Build Coastguard Worker 
280*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Compressed Frame Flags
281*77c1e3ccSAndroid Build Coastguard Worker  *
282*77c1e3ccSAndroid Build Coastguard Worker  * This type represents a bitfield containing information about a compressed
283*77c1e3ccSAndroid Build Coastguard Worker  * frame that may be useful to an application. The most significant 16 bits
284*77c1e3ccSAndroid Build Coastguard Worker  * can be used by an algorithm to provide additional detail, for example to
285*77c1e3ccSAndroid Build Coastguard Worker  * support frame types that are codec specific (MPEG-1 D-frames for example)
286*77c1e3ccSAndroid Build Coastguard Worker  */
287*77c1e3ccSAndroid Build Coastguard Worker typedef uint32_t aom_codec_frame_flags_t;
288*77c1e3ccSAndroid Build Coastguard Worker #define AOM_FRAME_IS_KEY 0x1u /**< frame is the start of a GOP */
289*77c1e3ccSAndroid Build Coastguard Worker /*!\brief frame can be dropped without affecting the stream (no future frame
290*77c1e3ccSAndroid Build Coastguard Worker  * depends on this one) */
291*77c1e3ccSAndroid Build Coastguard Worker #define AOM_FRAME_IS_DROPPABLE 0x2u
292*77c1e3ccSAndroid Build Coastguard Worker /*!\brief this is an INTRA_ONLY frame */
293*77c1e3ccSAndroid Build Coastguard Worker #define AOM_FRAME_IS_INTRAONLY 0x10u
294*77c1e3ccSAndroid Build Coastguard Worker /*!\brief this is an S-frame */
295*77c1e3ccSAndroid Build Coastguard Worker #define AOM_FRAME_IS_SWITCH 0x20u
296*77c1e3ccSAndroid Build Coastguard Worker /*!\brief this is an error-resilient frame */
297*77c1e3ccSAndroid Build Coastguard Worker #define AOM_FRAME_IS_ERROR_RESILIENT 0x40u
298*77c1e3ccSAndroid Build Coastguard Worker /*!\brief this is a key-frame dependent recovery-point frame */
299*77c1e3ccSAndroid Build Coastguard Worker #define AOM_FRAME_IS_DELAYED_RANDOM_ACCESS_POINT 0x80u
300*77c1e3ccSAndroid Build Coastguard Worker 
301*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Iterator
302*77c1e3ccSAndroid Build Coastguard Worker  *
303*77c1e3ccSAndroid Build Coastguard Worker  * Opaque storage used for iterating over lists.
304*77c1e3ccSAndroid Build Coastguard Worker  */
305*77c1e3ccSAndroid Build Coastguard Worker typedef const void *aom_codec_iter_t;
306*77c1e3ccSAndroid Build Coastguard Worker 
307*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Codec context structure
308*77c1e3ccSAndroid Build Coastguard Worker  *
309*77c1e3ccSAndroid Build Coastguard Worker  * All codecs \ref MUST support this context structure fully. In general,
310*77c1e3ccSAndroid Build Coastguard Worker  * this data should be considered private to the codec algorithm, and
311*77c1e3ccSAndroid Build Coastguard Worker  * not be manipulated or examined by the calling application. Applications
312*77c1e3ccSAndroid Build Coastguard Worker  * may reference the 'name' member to get a printable description of the
313*77c1e3ccSAndroid Build Coastguard Worker  * algorithm.
314*77c1e3ccSAndroid Build Coastguard Worker  */
315*77c1e3ccSAndroid Build Coastguard Worker typedef struct aom_codec_ctx {
316*77c1e3ccSAndroid Build Coastguard Worker   const char *name;             /**< Printable interface name */
317*77c1e3ccSAndroid Build Coastguard Worker   aom_codec_iface_t *iface;     /**< Interface pointers */
318*77c1e3ccSAndroid Build Coastguard Worker   aom_codec_err_t err;          /**< Last returned error */
319*77c1e3ccSAndroid Build Coastguard Worker   const char *err_detail;       /**< Detailed info, if available */
320*77c1e3ccSAndroid Build Coastguard Worker   aom_codec_flags_t init_flags; /**< Flags passed at init time */
321*77c1e3ccSAndroid Build Coastguard Worker   union {
322*77c1e3ccSAndroid Build Coastguard Worker     /**< Decoder Configuration Pointer */
323*77c1e3ccSAndroid Build Coastguard Worker     const struct aom_codec_dec_cfg *dec;
324*77c1e3ccSAndroid Build Coastguard Worker     /**< Encoder Configuration Pointer */
325*77c1e3ccSAndroid Build Coastguard Worker     const struct aom_codec_enc_cfg *enc;
326*77c1e3ccSAndroid Build Coastguard Worker     const void *raw;
327*77c1e3ccSAndroid Build Coastguard Worker   } config;               /**< Configuration pointer aliasing union */
328*77c1e3ccSAndroid Build Coastguard Worker   aom_codec_priv_t *priv; /**< Algorithm private storage */
329*77c1e3ccSAndroid Build Coastguard Worker } aom_codec_ctx_t;
330*77c1e3ccSAndroid Build Coastguard Worker 
331*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Bit depth for codec
332*77c1e3ccSAndroid Build Coastguard Worker  * *
333*77c1e3ccSAndroid Build Coastguard Worker  * This enumeration determines the bit depth of the codec.
334*77c1e3ccSAndroid Build Coastguard Worker  */
335*77c1e3ccSAndroid Build Coastguard Worker typedef enum aom_bit_depth {
336*77c1e3ccSAndroid Build Coastguard Worker   AOM_BITS_8 = 8,   /**<  8 bits */
337*77c1e3ccSAndroid Build Coastguard Worker   AOM_BITS_10 = 10, /**< 10 bits */
338*77c1e3ccSAndroid Build Coastguard Worker   AOM_BITS_12 = 12, /**< 12 bits */
339*77c1e3ccSAndroid Build Coastguard Worker } aom_bit_depth_t;
340*77c1e3ccSAndroid Build Coastguard Worker 
341*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Superblock size selection.
342*77c1e3ccSAndroid Build Coastguard Worker  *
343*77c1e3ccSAndroid Build Coastguard Worker  * Defines the superblock size used for encoding. The superblock size can
344*77c1e3ccSAndroid Build Coastguard Worker  * either be fixed at 64x64 or 128x128 pixels, or it can be dynamically
345*77c1e3ccSAndroid Build Coastguard Worker  * selected by the encoder for each frame.
346*77c1e3ccSAndroid Build Coastguard Worker  */
347*77c1e3ccSAndroid Build Coastguard Worker typedef enum aom_superblock_size {
348*77c1e3ccSAndroid Build Coastguard Worker   AOM_SUPERBLOCK_SIZE_64X64,   /**< Always use 64x64 superblocks. */
349*77c1e3ccSAndroid Build Coastguard Worker   AOM_SUPERBLOCK_SIZE_128X128, /**< Always use 128x128 superblocks. */
350*77c1e3ccSAndroid Build Coastguard Worker   AOM_SUPERBLOCK_SIZE_DYNAMIC  /**< Select superblock size dynamically. */
351*77c1e3ccSAndroid Build Coastguard Worker } aom_superblock_size_t;
352*77c1e3ccSAndroid Build Coastguard Worker 
353*77c1e3ccSAndroid Build Coastguard Worker /*
354*77c1e3ccSAndroid Build Coastguard Worker  * Library Version Number Interface
355*77c1e3ccSAndroid Build Coastguard Worker  *
356*77c1e3ccSAndroid Build Coastguard Worker  * For example, see the following sample return values:
357*77c1e3ccSAndroid Build Coastguard Worker  *     aom_codec_version()           (1<<16 | 2<<8 | 3)
358*77c1e3ccSAndroid Build Coastguard Worker  *     aom_codec_version_str()       "v1.2.3-rc1-16-gec6a1ba"
359*77c1e3ccSAndroid Build Coastguard Worker  *     aom_codec_version_extra_str() "rc1-16-gec6a1ba"
360*77c1e3ccSAndroid Build Coastguard Worker  */
361*77c1e3ccSAndroid Build Coastguard Worker 
362*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Return the version information (as an integer)
363*77c1e3ccSAndroid Build Coastguard Worker  *
364*77c1e3ccSAndroid Build Coastguard Worker  * Returns a packed encoding of the library version number. This will only
365*77c1e3ccSAndroid Build Coastguard Worker  * include the major.minor.patch component of the version number. Note that this
366*77c1e3ccSAndroid Build Coastguard Worker  * encoded value should be accessed through the macros provided, as the encoding
367*77c1e3ccSAndroid Build Coastguard Worker  * may change in the future.
368*77c1e3ccSAndroid Build Coastguard Worker  *
369*77c1e3ccSAndroid Build Coastguard Worker  */
370*77c1e3ccSAndroid Build Coastguard Worker int aom_codec_version(void);
371*77c1e3ccSAndroid Build Coastguard Worker 
372*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Return the major version number */
373*77c1e3ccSAndroid Build Coastguard Worker #define aom_codec_version_major() ((aom_codec_version() >> 16) & 0xff)
374*77c1e3ccSAndroid Build Coastguard Worker 
375*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Return the minor version number */
376*77c1e3ccSAndroid Build Coastguard Worker #define aom_codec_version_minor() ((aom_codec_version() >> 8) & 0xff)
377*77c1e3ccSAndroid Build Coastguard Worker 
378*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Return the patch version number */
379*77c1e3ccSAndroid Build Coastguard Worker #define aom_codec_version_patch() ((aom_codec_version() >> 0) & 0xff)
380*77c1e3ccSAndroid Build Coastguard Worker 
381*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Return the version information (as a string)
382*77c1e3ccSAndroid Build Coastguard Worker  *
383*77c1e3ccSAndroid Build Coastguard Worker  * Returns a printable string containing the full library version number. This
384*77c1e3ccSAndroid Build Coastguard Worker  * may contain additional text following the three digit version number, as to
385*77c1e3ccSAndroid Build Coastguard Worker  * indicate release candidates, pre-release versions, etc.
386*77c1e3ccSAndroid Build Coastguard Worker  *
387*77c1e3ccSAndroid Build Coastguard Worker  */
388*77c1e3ccSAndroid Build Coastguard Worker const char *aom_codec_version_str(void);
389*77c1e3ccSAndroid Build Coastguard Worker 
390*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Return the version information (as a string)
391*77c1e3ccSAndroid Build Coastguard Worker  *
392*77c1e3ccSAndroid Build Coastguard Worker  * Returns a printable "extra string". This is the component of the string
393*77c1e3ccSAndroid Build Coastguard Worker  * returned by aom_codec_version_str() following the three digit version number.
394*77c1e3ccSAndroid Build Coastguard Worker  *
395*77c1e3ccSAndroid Build Coastguard Worker  */
396*77c1e3ccSAndroid Build Coastguard Worker const char *aom_codec_version_extra_str(void);
397*77c1e3ccSAndroid Build Coastguard Worker 
398*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Return the build configuration
399*77c1e3ccSAndroid Build Coastguard Worker  *
400*77c1e3ccSAndroid Build Coastguard Worker  * Returns a printable string containing an encoded version of the build
401*77c1e3ccSAndroid Build Coastguard Worker  * configuration. This may be useful to aom support.
402*77c1e3ccSAndroid Build Coastguard Worker  *
403*77c1e3ccSAndroid Build Coastguard Worker  */
404*77c1e3ccSAndroid Build Coastguard Worker const char *aom_codec_build_config(void);
405*77c1e3ccSAndroid Build Coastguard Worker 
406*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Return the name for a given interface
407*77c1e3ccSAndroid Build Coastguard Worker  *
408*77c1e3ccSAndroid Build Coastguard Worker  * Returns a human readable string for name of the given codec interface.
409*77c1e3ccSAndroid Build Coastguard Worker  *
410*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    iface     Interface pointer
411*77c1e3ccSAndroid Build Coastguard Worker  *
412*77c1e3ccSAndroid Build Coastguard Worker  */
413*77c1e3ccSAndroid Build Coastguard Worker const char *aom_codec_iface_name(aom_codec_iface_t *iface);
414*77c1e3ccSAndroid Build Coastguard Worker 
415*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Convert error number to printable string
416*77c1e3ccSAndroid Build Coastguard Worker  *
417*77c1e3ccSAndroid Build Coastguard Worker  * Returns a human readable string for the last error returned by the
418*77c1e3ccSAndroid Build Coastguard Worker  * algorithm. The returned error will be one line and will not contain
419*77c1e3ccSAndroid Build Coastguard Worker  * any newline characters.
420*77c1e3ccSAndroid Build Coastguard Worker  *
421*77c1e3ccSAndroid Build Coastguard Worker  *
422*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    err     Error number.
423*77c1e3ccSAndroid Build Coastguard Worker  *
424*77c1e3ccSAndroid Build Coastguard Worker  */
425*77c1e3ccSAndroid Build Coastguard Worker const char *aom_codec_err_to_string(aom_codec_err_t err);
426*77c1e3ccSAndroid Build Coastguard Worker 
427*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Retrieve error synopsis for codec context
428*77c1e3ccSAndroid Build Coastguard Worker  *
429*77c1e3ccSAndroid Build Coastguard Worker  * Returns a human readable string for the last error returned by the
430*77c1e3ccSAndroid Build Coastguard Worker  * algorithm. The returned error will be one line and will not contain
431*77c1e3ccSAndroid Build Coastguard Worker  * any newline characters.
432*77c1e3ccSAndroid Build Coastguard Worker  *
433*77c1e3ccSAndroid Build Coastguard Worker  *
434*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ctx     Pointer to this instance's context.
435*77c1e3ccSAndroid Build Coastguard Worker  *
436*77c1e3ccSAndroid Build Coastguard Worker  */
437*77c1e3ccSAndroid Build Coastguard Worker const char *aom_codec_error(const aom_codec_ctx_t *ctx);
438*77c1e3ccSAndroid Build Coastguard Worker 
439*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Retrieve detailed error information for codec context
440*77c1e3ccSAndroid Build Coastguard Worker  *
441*77c1e3ccSAndroid Build Coastguard Worker  * Returns a human readable string providing detailed information about
442*77c1e3ccSAndroid Build Coastguard Worker  * the last error. The returned string is only valid until the next
443*77c1e3ccSAndroid Build Coastguard Worker  * aom_codec_* function call (except aom_codec_error and
444*77c1e3ccSAndroid Build Coastguard Worker  * aom_codec_error_detail) on the codec context.
445*77c1e3ccSAndroid Build Coastguard Worker  *
446*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ctx     Pointer to this instance's context.
447*77c1e3ccSAndroid Build Coastguard Worker  *
448*77c1e3ccSAndroid Build Coastguard Worker  * \retval NULL
449*77c1e3ccSAndroid Build Coastguard Worker  *     No detailed information is available.
450*77c1e3ccSAndroid Build Coastguard Worker  */
451*77c1e3ccSAndroid Build Coastguard Worker const char *aom_codec_error_detail(const aom_codec_ctx_t *ctx);
452*77c1e3ccSAndroid Build Coastguard Worker 
453*77c1e3ccSAndroid Build Coastguard Worker /* REQUIRED FUNCTIONS
454*77c1e3ccSAndroid Build Coastguard Worker  *
455*77c1e3ccSAndroid Build Coastguard Worker  * The following functions are required to be implemented for all codecs.
456*77c1e3ccSAndroid Build Coastguard Worker  * They represent the base case functionality expected of all codecs.
457*77c1e3ccSAndroid Build Coastguard Worker  */
458*77c1e3ccSAndroid Build Coastguard Worker 
459*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Destroy a codec instance
460*77c1e3ccSAndroid Build Coastguard Worker  *
461*77c1e3ccSAndroid Build Coastguard Worker  * Destroys a codec context, freeing any associated memory buffers.
462*77c1e3ccSAndroid Build Coastguard Worker  *
463*77c1e3ccSAndroid Build Coastguard Worker  * \param[in] ctx   Pointer to this instance's context
464*77c1e3ccSAndroid Build Coastguard Worker  *
465*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_OK
466*77c1e3ccSAndroid Build Coastguard Worker  *     The codec instance has been destroyed.
467*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_INVALID_PARAM
468*77c1e3ccSAndroid Build Coastguard Worker  *     ctx is a null pointer.
469*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_ERROR
470*77c1e3ccSAndroid Build Coastguard Worker  *     Codec context not initialized.
471*77c1e3ccSAndroid Build Coastguard Worker  */
472*77c1e3ccSAndroid Build Coastguard Worker aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx);
473*77c1e3ccSAndroid Build Coastguard Worker 
474*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Get the capabilities of an algorithm.
475*77c1e3ccSAndroid Build Coastguard Worker  *
476*77c1e3ccSAndroid Build Coastguard Worker  * Retrieves the capabilities bitfield from the algorithm's interface.
477*77c1e3ccSAndroid Build Coastguard Worker  *
478*77c1e3ccSAndroid Build Coastguard Worker  * \param[in] iface   Pointer to the algorithm interface
479*77c1e3ccSAndroid Build Coastguard Worker  *
480*77c1e3ccSAndroid Build Coastguard Worker  */
481*77c1e3ccSAndroid Build Coastguard Worker aom_codec_caps_t aom_codec_get_caps(aom_codec_iface_t *iface);
482*77c1e3ccSAndroid Build Coastguard Worker 
483*77c1e3ccSAndroid Build Coastguard Worker /*!\name Codec Control
484*77c1e3ccSAndroid Build Coastguard Worker  *
485*77c1e3ccSAndroid Build Coastguard Worker  * The aom_codec_control function exchanges algorithm specific data with the
486*77c1e3ccSAndroid Build Coastguard Worker  * codec instance. Additionally, the macro AOM_CODEC_CONTROL_TYPECHECKED is
487*77c1e3ccSAndroid Build Coastguard Worker  * provided, which will type-check the parameter against the control ID before
488*77c1e3ccSAndroid Build Coastguard Worker  * calling aom_codec_control - note that this macro requires the control ID
489*77c1e3ccSAndroid Build Coastguard Worker  * to be directly encoded in it, e.g.,
490*77c1e3ccSAndroid Build Coastguard Worker  * AOM_CODEC_CONTROL_TYPECHECKED(&ctx, AOME_SET_CPUUSED, 8).
491*77c1e3ccSAndroid Build Coastguard Worker  *
492*77c1e3ccSAndroid Build Coastguard Worker  * The codec control IDs can be found in aom.h, aomcx.h, and aomdx.h
493*77c1e3ccSAndroid Build Coastguard Worker  * (defined as aom_com_control_id, aome_enc_control_id, and aom_dec_control_id).
494*77c1e3ccSAndroid Build Coastguard Worker  * @{
495*77c1e3ccSAndroid Build Coastguard Worker  */
496*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Algorithm Control
497*77c1e3ccSAndroid Build Coastguard Worker  *
498*77c1e3ccSAndroid Build Coastguard Worker  * aom_codec_control takes a context, a control ID, and a third parameter
499*77c1e3ccSAndroid Build Coastguard Worker  * (with varying type). If the context is non-null and an error occurs,
500*77c1e3ccSAndroid Build Coastguard Worker  * ctx->err will be set to the same value as the return value.
501*77c1e3ccSAndroid Build Coastguard Worker  *
502*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]     ctx              Pointer to this instance's context
503*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]     ctrl_id          Algorithm specific control identifier.
504*77c1e3ccSAndroid Build Coastguard Worker  *                                 Must be nonzero.
505*77c1e3ccSAndroid Build Coastguard Worker  *
506*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_OK
507*77c1e3ccSAndroid Build Coastguard Worker  *     The control request was processed.
508*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_ERROR
509*77c1e3ccSAndroid Build Coastguard Worker  *     The control request was not processed.
510*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_INVALID_PARAM
511*77c1e3ccSAndroid Build Coastguard Worker  *     The control ID was zero, or the data was not valid.
512*77c1e3ccSAndroid Build Coastguard Worker  */
513*77c1e3ccSAndroid Build Coastguard Worker aom_codec_err_t aom_codec_control(aom_codec_ctx_t *ctx, int ctrl_id, ...);
514*77c1e3ccSAndroid Build Coastguard Worker 
515*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Key & Value API
516*77c1e3ccSAndroid Build Coastguard Worker  *
517*77c1e3ccSAndroid Build Coastguard Worker  * aom_codec_set_option() takes a context, a key (option name) and a value. If
518*77c1e3ccSAndroid Build Coastguard Worker  * the context is non-null and an error occurs, ctx->err will be set to the same
519*77c1e3ccSAndroid Build Coastguard Worker  * value as the return value.
520*77c1e3ccSAndroid Build Coastguard Worker  *
521*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]     ctx              Pointer to this instance's context
522*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]     name             The name of the option (key)
523*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]     value            The value of the option
524*77c1e3ccSAndroid Build Coastguard Worker  *
525*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_OK
526*77c1e3ccSAndroid Build Coastguard Worker  *     The value of the option was set.
527*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_INVALID_PARAM
528*77c1e3ccSAndroid Build Coastguard Worker  *     The data was not valid.
529*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_ERROR
530*77c1e3ccSAndroid Build Coastguard Worker  *     The option was not successfully set.
531*77c1e3ccSAndroid Build Coastguard Worker  */
532*77c1e3ccSAndroid Build Coastguard Worker aom_codec_err_t aom_codec_set_option(aom_codec_ctx_t *ctx, const char *name,
533*77c1e3ccSAndroid Build Coastguard Worker                                      const char *value);
534*77c1e3ccSAndroid Build Coastguard Worker 
535*77c1e3ccSAndroid Build Coastguard Worker /*!\brief aom_codec_control wrapper macro (adds type-checking, less flexible)
536*77c1e3ccSAndroid Build Coastguard Worker  *
537*77c1e3ccSAndroid Build Coastguard Worker  * This macro allows for type safe conversions across the variadic parameter
538*77c1e3ccSAndroid Build Coastguard Worker  * to aom_codec_control(). However, it requires the explicit control ID
539*77c1e3ccSAndroid Build Coastguard Worker  * be passed in (it cannot be passed in via a variable) -- otherwise a compiler
540*77c1e3ccSAndroid Build Coastguard Worker  * error will occur. After the type checking, it calls aom_codec_control.
541*77c1e3ccSAndroid Build Coastguard Worker  */
542*77c1e3ccSAndroid Build Coastguard Worker #define AOM_CODEC_CONTROL_TYPECHECKED(ctx, id, data) \
543*77c1e3ccSAndroid Build Coastguard Worker   aom_codec_control_typechecked_##id(ctx, id, data) /**<\hideinitializer*/
544*77c1e3ccSAndroid Build Coastguard Worker 
545*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Creates type checking mechanisms for aom_codec_control
546*77c1e3ccSAndroid Build Coastguard Worker  *
547*77c1e3ccSAndroid Build Coastguard Worker  * It defines a static function with the correctly typed arguments as a wrapper
548*77c1e3ccSAndroid Build Coastguard Worker  * to the type-unsafe aom_codec_control function. It also creates a typedef
549*77c1e3ccSAndroid Build Coastguard Worker  * for each type.
550*77c1e3ccSAndroid Build Coastguard Worker  */
551*77c1e3ccSAndroid Build Coastguard Worker #define AOM_CTRL_USE_TYPE(id, typ)                           \
552*77c1e3ccSAndroid Build Coastguard Worker   static aom_codec_err_t aom_codec_control_typechecked_##id( \
553*77c1e3ccSAndroid Build Coastguard Worker       aom_codec_ctx_t *, int, typ) AOM_UNUSED;               \
554*77c1e3ccSAndroid Build Coastguard Worker   static aom_codec_err_t aom_codec_control_typechecked_##id( \
555*77c1e3ccSAndroid Build Coastguard Worker       aom_codec_ctx_t *ctx, int ctrl, typ data) {            \
556*77c1e3ccSAndroid Build Coastguard Worker     return aom_codec_control(ctx, ctrl, data);               \
557*77c1e3ccSAndroid Build Coastguard Worker   } /**<\hideinitializer*/                                   \
558*77c1e3ccSAndroid Build Coastguard Worker   typedef typ aom_codec_control_type_##id;
559*77c1e3ccSAndroid Build Coastguard Worker /*!@} end Codec Control group */
560*77c1e3ccSAndroid Build Coastguard Worker 
561*77c1e3ccSAndroid Build Coastguard Worker /*!\brief OBU types. */
562*77c1e3ccSAndroid Build Coastguard Worker typedef enum ATTRIBUTE_PACKED {
563*77c1e3ccSAndroid Build Coastguard Worker   OBU_SEQUENCE_HEADER = 1,
564*77c1e3ccSAndroid Build Coastguard Worker   OBU_TEMPORAL_DELIMITER = 2,
565*77c1e3ccSAndroid Build Coastguard Worker   OBU_FRAME_HEADER = 3,
566*77c1e3ccSAndroid Build Coastguard Worker   OBU_TILE_GROUP = 4,
567*77c1e3ccSAndroid Build Coastguard Worker   OBU_METADATA = 5,
568*77c1e3ccSAndroid Build Coastguard Worker   OBU_FRAME = 6,
569*77c1e3ccSAndroid Build Coastguard Worker   OBU_REDUNDANT_FRAME_HEADER = 7,
570*77c1e3ccSAndroid Build Coastguard Worker   OBU_TILE_LIST = 8,
571*77c1e3ccSAndroid Build Coastguard Worker   OBU_PADDING = 15,
572*77c1e3ccSAndroid Build Coastguard Worker } OBU_TYPE;
573*77c1e3ccSAndroid Build Coastguard Worker 
574*77c1e3ccSAndroid Build Coastguard Worker /*!\brief OBU metadata types. */
575*77c1e3ccSAndroid Build Coastguard Worker typedef enum {
576*77c1e3ccSAndroid Build Coastguard Worker   OBU_METADATA_TYPE_AOM_RESERVED_0 = 0,
577*77c1e3ccSAndroid Build Coastguard Worker   OBU_METADATA_TYPE_HDR_CLL = 1,
578*77c1e3ccSAndroid Build Coastguard Worker   OBU_METADATA_TYPE_HDR_MDCV = 2,
579*77c1e3ccSAndroid Build Coastguard Worker   OBU_METADATA_TYPE_SCALABILITY = 3,
580*77c1e3ccSAndroid Build Coastguard Worker   OBU_METADATA_TYPE_ITUT_T35 = 4,
581*77c1e3ccSAndroid Build Coastguard Worker   OBU_METADATA_TYPE_TIMECODE = 5,
582*77c1e3ccSAndroid Build Coastguard Worker } OBU_METADATA_TYPE;
583*77c1e3ccSAndroid Build Coastguard Worker 
584*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Returns string representation of OBU_TYPE.
585*77c1e3ccSAndroid Build Coastguard Worker  *
586*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]     type            The OBU_TYPE to convert to string.
587*77c1e3ccSAndroid Build Coastguard Worker  */
588*77c1e3ccSAndroid Build Coastguard Worker const char *aom_obu_type_to_string(OBU_TYPE type);
589*77c1e3ccSAndroid Build Coastguard Worker 
590*77c1e3ccSAndroid Build Coastguard Worker /*!@} - end defgroup codec*/
591*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
592*77c1e3ccSAndroid Build Coastguard Worker }
593*77c1e3ccSAndroid Build Coastguard Worker #endif
594*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_AOM_AOM_CODEC_H_
595