xref: /aosp_15_r20/external/libaom/aom/aom_encoder.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 #ifndef AOM_AOM_AOM_ENCODER_H_
12*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AOM_AOM_ENCODER_H_
13*77c1e3ccSAndroid Build Coastguard Worker 
14*77c1e3ccSAndroid Build Coastguard Worker /*!\defgroup encoder Encoder Algorithm Interface
15*77c1e3ccSAndroid Build Coastguard Worker  * \ingroup codec
16*77c1e3ccSAndroid Build Coastguard Worker  * This abstraction allows applications using this encoder to easily support
17*77c1e3ccSAndroid Build Coastguard Worker  * multiple video formats with minimal code duplication. This section describes
18*77c1e3ccSAndroid Build Coastguard Worker  * the interface common to all encoders.
19*77c1e3ccSAndroid Build Coastguard Worker  * @{
20*77c1e3ccSAndroid Build Coastguard Worker  */
21*77c1e3ccSAndroid Build Coastguard Worker 
22*77c1e3ccSAndroid Build Coastguard Worker /*!\file
23*77c1e3ccSAndroid Build Coastguard Worker  * \brief Describes the encoder algorithm interface to applications.
24*77c1e3ccSAndroid Build Coastguard Worker  *
25*77c1e3ccSAndroid Build Coastguard Worker  * This file describes the interface between an application and a
26*77c1e3ccSAndroid Build Coastguard Worker  * video encoder algorithm.
27*77c1e3ccSAndroid Build Coastguard Worker  *
28*77c1e3ccSAndroid Build Coastguard Worker  */
29*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
30*77c1e3ccSAndroid Build Coastguard Worker extern "C" {
31*77c1e3ccSAndroid Build Coastguard Worker #endif
32*77c1e3ccSAndroid Build Coastguard Worker 
33*77c1e3ccSAndroid Build Coastguard Worker #include "aom/aom_codec.h"  // IWYU pragma: export
34*77c1e3ccSAndroid Build Coastguard Worker #include "aom/aom_external_partition.h"
35*77c1e3ccSAndroid Build Coastguard Worker 
36*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Current ABI version number
37*77c1e3ccSAndroid Build Coastguard Worker  *
38*77c1e3ccSAndroid Build Coastguard Worker  * \hideinitializer
39*77c1e3ccSAndroid Build Coastguard Worker  * \internal
40*77c1e3ccSAndroid Build Coastguard Worker  * If this file is altered in any way that changes the ABI, this value
41*77c1e3ccSAndroid Build Coastguard Worker  * must be bumped.  Examples include, but are not limited to, changing
42*77c1e3ccSAndroid Build Coastguard Worker  * types, removing or reassigning enums, adding/removing/rearranging
43*77c1e3ccSAndroid Build Coastguard Worker  * fields to structures
44*77c1e3ccSAndroid Build Coastguard Worker  *
45*77c1e3ccSAndroid Build Coastguard Worker  * Note: In the definition of AOM_ENCODER_ABI_VERSION, 3 is the value of
46*77c1e3ccSAndroid Build Coastguard Worker  * AOM_EXT_PART_ABI_VERSION in libaom v3.2.0. The old value of
47*77c1e3ccSAndroid Build Coastguard Worker  * AOM_EXT_PART_ABI_VERSION is used so as to not break the ABI version check in
48*77c1e3ccSAndroid Build Coastguard Worker  * aom_codec_enc_init_ver() when an application compiled against libaom v3.2.0
49*77c1e3ccSAndroid Build Coastguard Worker  * passes the old value of AOM_ENCODER_ABI_VERSION to aom_codec_enc_init_ver().
50*77c1e3ccSAndroid Build Coastguard Worker  * The external partition API is still experimental. When it is declared stable,
51*77c1e3ccSAndroid Build Coastguard Worker  * we will replace 3 with AOM_EXT_PART_ABI_VERSION in the definition of
52*77c1e3ccSAndroid Build Coastguard Worker  * AOM_ENCODER_ABI_VERSION.
53*77c1e3ccSAndroid Build Coastguard Worker  */
54*77c1e3ccSAndroid Build Coastguard Worker #define AOM_ENCODER_ABI_VERSION \
55*77c1e3ccSAndroid Build Coastguard Worker   (10 + AOM_CODEC_ABI_VERSION + /*AOM_EXT_PART_ABI_VERSION=*/3)
56*77c1e3ccSAndroid Build Coastguard Worker 
57*77c1e3ccSAndroid Build Coastguard Worker /*! \brief Encoder capabilities bitfield
58*77c1e3ccSAndroid Build Coastguard Worker  *
59*77c1e3ccSAndroid Build Coastguard Worker  *  Each encoder advertises the capabilities it supports as part of its
60*77c1e3ccSAndroid Build Coastguard Worker  *  ::aom_codec_iface_t interface structure. Capabilities are extra
61*77c1e3ccSAndroid Build Coastguard Worker  *  interfaces or functionality, and are not required to be supported
62*77c1e3ccSAndroid Build Coastguard Worker  *  by an encoder.
63*77c1e3ccSAndroid Build Coastguard Worker  *
64*77c1e3ccSAndroid Build Coastguard Worker  *  The available flags are specified by AOM_CODEC_CAP_* defines.
65*77c1e3ccSAndroid Build Coastguard Worker  */
66*77c1e3ccSAndroid Build Coastguard Worker #define AOM_CODEC_CAP_PSNR 0x10000 /**< Can issue PSNR packets */
67*77c1e3ccSAndroid Build Coastguard Worker 
68*77c1e3ccSAndroid Build Coastguard Worker /*! Can support input images at greater than 8 bitdepth.
69*77c1e3ccSAndroid Build Coastguard Worker  */
70*77c1e3ccSAndroid Build Coastguard Worker #define AOM_CODEC_CAP_HIGHBITDEPTH 0x40000
71*77c1e3ccSAndroid Build Coastguard Worker 
72*77c1e3ccSAndroid Build Coastguard Worker /*! \brief Initialization-time Feature Enabling
73*77c1e3ccSAndroid Build Coastguard Worker  *
74*77c1e3ccSAndroid Build Coastguard Worker  *  Certain codec features must be known at initialization time, to allow
75*77c1e3ccSAndroid Build Coastguard Worker  *  for proper memory allocation.
76*77c1e3ccSAndroid Build Coastguard Worker  *
77*77c1e3ccSAndroid Build Coastguard Worker  *  The available flags are specified by AOM_CODEC_USE_* defines.
78*77c1e3ccSAndroid Build Coastguard Worker  */
79*77c1e3ccSAndroid Build Coastguard Worker #define AOM_CODEC_USE_PSNR 0x10000         /**< Calculate PSNR on each frame */
80*77c1e3ccSAndroid Build Coastguard Worker #define AOM_CODEC_USE_HIGHBITDEPTH 0x40000 /**< Use high bitdepth */
81*77c1e3ccSAndroid Build Coastguard Worker // 0x80000 was used for the experimental feature AOM_CODEC_USE_PRESET during
82*77c1e3ccSAndroid Build Coastguard Worker // libaom v3.11.0 development but was removed before the release.
83*77c1e3ccSAndroid Build Coastguard Worker 
84*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Generic fixed size buffer structure
85*77c1e3ccSAndroid Build Coastguard Worker  *
86*77c1e3ccSAndroid Build Coastguard Worker  * This structure is able to hold a reference to any fixed size buffer.
87*77c1e3ccSAndroid Build Coastguard Worker  */
88*77c1e3ccSAndroid Build Coastguard Worker typedef struct aom_fixed_buf {
89*77c1e3ccSAndroid Build Coastguard Worker   void *buf;       /**< Pointer to the data. Does NOT own the data! */
90*77c1e3ccSAndroid Build Coastguard Worker   size_t sz;       /**< Length of the buffer, in chars */
91*77c1e3ccSAndroid Build Coastguard Worker } aom_fixed_buf_t; /**< alias for struct aom_fixed_buf */
92*77c1e3ccSAndroid Build Coastguard Worker 
93*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Error Resilient flags
94*77c1e3ccSAndroid Build Coastguard Worker  *
95*77c1e3ccSAndroid Build Coastguard Worker  * These flags define which error resilient features to enable in the
96*77c1e3ccSAndroid Build Coastguard Worker  * encoder. The flags are specified through the
97*77c1e3ccSAndroid Build Coastguard Worker  * aom_codec_enc_cfg::g_error_resilient variable.
98*77c1e3ccSAndroid Build Coastguard Worker  */
99*77c1e3ccSAndroid Build Coastguard Worker typedef uint32_t aom_codec_er_flags_t;
100*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Improve resiliency against losses of whole frames */
101*77c1e3ccSAndroid Build Coastguard Worker #define AOM_ERROR_RESILIENT_DEFAULT 0x1
102*77c1e3ccSAndroid Build Coastguard Worker 
103*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Encoder output packet variants
104*77c1e3ccSAndroid Build Coastguard Worker  *
105*77c1e3ccSAndroid Build Coastguard Worker  * This enumeration lists the different kinds of data packets that can be
106*77c1e3ccSAndroid Build Coastguard Worker  * returned by calls to aom_codec_get_cx_data(). Algorithms \ref MAY
107*77c1e3ccSAndroid Build Coastguard Worker  * extend this list to provide additional functionality.
108*77c1e3ccSAndroid Build Coastguard Worker  */
109*77c1e3ccSAndroid Build Coastguard Worker enum aom_codec_cx_pkt_kind {
110*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_CX_FRAME_PKT,    /**< Compressed video frame */
111*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_STATS_PKT,       /**< Two-pass statistics for this frame */
112*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_FPMB_STATS_PKT,  /**< first pass mb statistics for this frame */
113*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_PSNR_PKT,        /**< PSNR statistics for this frame */
114*77c1e3ccSAndroid Build Coastguard Worker   AOM_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions  */
115*77c1e3ccSAndroid Build Coastguard Worker };
116*77c1e3ccSAndroid Build Coastguard Worker 
117*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Encoder output packet
118*77c1e3ccSAndroid Build Coastguard Worker  *
119*77c1e3ccSAndroid Build Coastguard Worker  * This structure contains the different kinds of output data the encoder
120*77c1e3ccSAndroid Build Coastguard Worker  * may produce while compressing a frame.
121*77c1e3ccSAndroid Build Coastguard Worker  */
122*77c1e3ccSAndroid Build Coastguard Worker typedef struct aom_codec_cx_pkt {
123*77c1e3ccSAndroid Build Coastguard Worker   enum aom_codec_cx_pkt_kind kind; /**< packet variant */
124*77c1e3ccSAndroid Build Coastguard Worker   union {
125*77c1e3ccSAndroid Build Coastguard Worker     struct {
126*77c1e3ccSAndroid Build Coastguard Worker       void *buf; /**< compressed data buffer */
127*77c1e3ccSAndroid Build Coastguard Worker       size_t sz; /**< length of compressed data */
128*77c1e3ccSAndroid Build Coastguard Worker       /*!\brief time stamp to show frame (in timebase units) */
129*77c1e3ccSAndroid Build Coastguard Worker       aom_codec_pts_t pts;
130*77c1e3ccSAndroid Build Coastguard Worker       /*!\brief duration to show frame (in timebase units) */
131*77c1e3ccSAndroid Build Coastguard Worker       unsigned long duration;
132*77c1e3ccSAndroid Build Coastguard Worker       aom_codec_frame_flags_t flags; /**< flags for this frame */
133*77c1e3ccSAndroid Build Coastguard Worker       /*!\brief the partition id defines the decoding order of the partitions.
134*77c1e3ccSAndroid Build Coastguard Worker        * Only applicable when "output partition" mode is enabled. First
135*77c1e3ccSAndroid Build Coastguard Worker        * partition has id 0.*/
136*77c1e3ccSAndroid Build Coastguard Worker       int partition_id;
137*77c1e3ccSAndroid Build Coastguard Worker       /*!\brief size of the visible frame in this packet */
138*77c1e3ccSAndroid Build Coastguard Worker       size_t vis_frame_size;
139*77c1e3ccSAndroid Build Coastguard Worker     } frame;                            /**< data for compressed frame packet */
140*77c1e3ccSAndroid Build Coastguard Worker     aom_fixed_buf_t twopass_stats;      /**< data for two-pass packet */
141*77c1e3ccSAndroid Build Coastguard Worker     aom_fixed_buf_t firstpass_mb_stats; /**< first pass mb packet */
142*77c1e3ccSAndroid Build Coastguard Worker     struct aom_psnr_pkt {
143*77c1e3ccSAndroid Build Coastguard Worker       unsigned int samples[4]; /**< Number of samples, total/y/u/v */
144*77c1e3ccSAndroid Build Coastguard Worker       uint64_t sse[4];         /**< sum squared error, total/y/u/v */
145*77c1e3ccSAndroid Build Coastguard Worker       double psnr[4];          /**< PSNR, total/y/u/v */
146*77c1e3ccSAndroid Build Coastguard Worker       /*!\brief Number of samples, total/y/u/v when
147*77c1e3ccSAndroid Build Coastguard Worker        * input bit-depth < stream bit-depth.*/
148*77c1e3ccSAndroid Build Coastguard Worker       unsigned int samples_hbd[4];
149*77c1e3ccSAndroid Build Coastguard Worker       /*!\brief sum squared error, total/y/u/v when
150*77c1e3ccSAndroid Build Coastguard Worker        * input bit-depth < stream bit-depth.*/
151*77c1e3ccSAndroid Build Coastguard Worker       uint64_t sse_hbd[4];
152*77c1e3ccSAndroid Build Coastguard Worker       /*!\brief PSNR, total/y/u/v when
153*77c1e3ccSAndroid Build Coastguard Worker        * input bit-depth < stream bit-depth.*/
154*77c1e3ccSAndroid Build Coastguard Worker       double psnr_hbd[4];
155*77c1e3ccSAndroid Build Coastguard Worker     } psnr;              /**< data for PSNR packet */
156*77c1e3ccSAndroid Build Coastguard Worker     aom_fixed_buf_t raw; /**< data for arbitrary packets */
157*77c1e3ccSAndroid Build Coastguard Worker   } data;                /**< packet data */
158*77c1e3ccSAndroid Build Coastguard Worker } aom_codec_cx_pkt_t;    /**< alias for struct aom_codec_cx_pkt */
159*77c1e3ccSAndroid Build Coastguard Worker 
160*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Rational Number
161*77c1e3ccSAndroid Build Coastguard Worker  *
162*77c1e3ccSAndroid Build Coastguard Worker  * This structure holds a fractional value.
163*77c1e3ccSAndroid Build Coastguard Worker  */
164*77c1e3ccSAndroid Build Coastguard Worker typedef struct aom_rational {
165*77c1e3ccSAndroid Build Coastguard Worker   int num;        /**< fraction numerator */
166*77c1e3ccSAndroid Build Coastguard Worker   int den;        /**< fraction denominator */
167*77c1e3ccSAndroid Build Coastguard Worker } aom_rational_t; /**< alias for struct aom_rational */
168*77c1e3ccSAndroid Build Coastguard Worker 
169*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Multi-pass Encoding Pass
170*77c1e3ccSAndroid Build Coastguard Worker  *
171*77c1e3ccSAndroid Build Coastguard Worker  * AOM_RC_LAST_PASS is kept for backward compatibility.
172*77c1e3ccSAndroid Build Coastguard Worker  * If passes is not given and pass==2, the codec will assume passes=2.
173*77c1e3ccSAndroid Build Coastguard Worker  * For new code, it is recommended to use AOM_RC_SECOND_PASS and set
174*77c1e3ccSAndroid Build Coastguard Worker  * the "passes" member to 2 via the key & val API for two-pass encoding.
175*77c1e3ccSAndroid Build Coastguard Worker  */
176*77c1e3ccSAndroid Build Coastguard Worker enum aom_enc_pass {
177*77c1e3ccSAndroid Build Coastguard Worker   AOM_RC_ONE_PASS = 0,    /**< Single pass mode */
178*77c1e3ccSAndroid Build Coastguard Worker   AOM_RC_FIRST_PASS = 1,  /**< First pass of multi-pass mode */
179*77c1e3ccSAndroid Build Coastguard Worker   AOM_RC_SECOND_PASS = 2, /**< Second pass of multi-pass mode */
180*77c1e3ccSAndroid Build Coastguard Worker   AOM_RC_THIRD_PASS = 3,  /**< Third pass of multi-pass mode */
181*77c1e3ccSAndroid Build Coastguard Worker   AOM_RC_LAST_PASS = 2,   /**< Final pass of two-pass mode */
182*77c1e3ccSAndroid Build Coastguard Worker };
183*77c1e3ccSAndroid Build Coastguard Worker 
184*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Rate control mode */
185*77c1e3ccSAndroid Build Coastguard Worker enum aom_rc_mode {
186*77c1e3ccSAndroid Build Coastguard Worker   AOM_VBR, /**< Variable Bit Rate (VBR) mode */
187*77c1e3ccSAndroid Build Coastguard Worker   AOM_CBR, /**< Constant Bit Rate (CBR) mode */
188*77c1e3ccSAndroid Build Coastguard Worker   AOM_CQ,  /**< Constrained Quality (CQ)  mode */
189*77c1e3ccSAndroid Build Coastguard Worker   AOM_Q,   /**< Constant Quality (Q) mode */
190*77c1e3ccSAndroid Build Coastguard Worker };
191*77c1e3ccSAndroid Build Coastguard Worker 
192*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Keyframe placement mode.
193*77c1e3ccSAndroid Build Coastguard Worker  *
194*77c1e3ccSAndroid Build Coastguard Worker  * This enumeration determines whether keyframes are placed automatically by
195*77c1e3ccSAndroid Build Coastguard Worker  * the encoder or whether this behavior is disabled. Older releases of this
196*77c1e3ccSAndroid Build Coastguard Worker  * SDK were implemented such that AOM_KF_FIXED meant keyframes were disabled.
197*77c1e3ccSAndroid Build Coastguard Worker  * This name is confusing for this behavior, so the new symbols to be used
198*77c1e3ccSAndroid Build Coastguard Worker  * are AOM_KF_AUTO and AOM_KF_DISABLED.
199*77c1e3ccSAndroid Build Coastguard Worker  */
200*77c1e3ccSAndroid Build Coastguard Worker enum aom_kf_mode {
201*77c1e3ccSAndroid Build Coastguard Worker   AOM_KF_FIXED,       /**< deprecated, implies AOM_KF_DISABLED */
202*77c1e3ccSAndroid Build Coastguard Worker   AOM_KF_AUTO,        /**< Encoder determines optimal placement automatically */
203*77c1e3ccSAndroid Build Coastguard Worker   AOM_KF_DISABLED = 0 /**< Encoder does not place keyframes. */
204*77c1e3ccSAndroid Build Coastguard Worker };
205*77c1e3ccSAndroid Build Coastguard Worker 
206*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Frame super-resolution mode. */
207*77c1e3ccSAndroid Build Coastguard Worker typedef enum {
208*77c1e3ccSAndroid Build Coastguard Worker   /**< Frame super-resolution is disabled for all frames. */
209*77c1e3ccSAndroid Build Coastguard Worker   AOM_SUPERRES_NONE,
210*77c1e3ccSAndroid Build Coastguard Worker   /**< All frames are coded at the specified scale and super-resolved. */
211*77c1e3ccSAndroid Build Coastguard Worker   AOM_SUPERRES_FIXED,
212*77c1e3ccSAndroid Build Coastguard Worker   /**< All frames are coded at a random scale and super-resolved. */
213*77c1e3ccSAndroid Build Coastguard Worker   AOM_SUPERRES_RANDOM,
214*77c1e3ccSAndroid Build Coastguard Worker   /**< Super-resolution scale for each frame is determined based on the q index
215*77c1e3ccSAndroid Build Coastguard Worker      of that frame. */
216*77c1e3ccSAndroid Build Coastguard Worker   AOM_SUPERRES_QTHRESH,
217*77c1e3ccSAndroid Build Coastguard Worker   /**< Full-resolution or super-resolution and the scale (in case of
218*77c1e3ccSAndroid Build Coastguard Worker      super-resolution) are automatically selected for each frame. */
219*77c1e3ccSAndroid Build Coastguard Worker   AOM_SUPERRES_AUTO,
220*77c1e3ccSAndroid Build Coastguard Worker } aom_superres_mode;
221*77c1e3ccSAndroid Build Coastguard Worker 
222*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Encoder Config Options
223*77c1e3ccSAndroid Build Coastguard Worker  *
224*77c1e3ccSAndroid Build Coastguard Worker  * This type allows to enumerate and control flags defined for encoder control
225*77c1e3ccSAndroid Build Coastguard Worker  * via config file at runtime.
226*77c1e3ccSAndroid Build Coastguard Worker  */
227*77c1e3ccSAndroid Build Coastguard Worker typedef struct cfg_options {
228*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Indicate init by cfg file
229*77c1e3ccSAndroid Build Coastguard Worker    * 0 or 1
230*77c1e3ccSAndroid Build Coastguard Worker    */
231*77c1e3ccSAndroid Build Coastguard Worker   unsigned int init_by_cfg_file;
232*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Superblock size
233*77c1e3ccSAndroid Build Coastguard Worker    * 0, 64 or 128
234*77c1e3ccSAndroid Build Coastguard Worker    */
235*77c1e3ccSAndroid Build Coastguard Worker   unsigned int super_block_size;
236*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief max partition size
237*77c1e3ccSAndroid Build Coastguard Worker    * 8, 16, 32, 64, 128
238*77c1e3ccSAndroid Build Coastguard Worker    */
239*77c1e3ccSAndroid Build Coastguard Worker   unsigned int max_partition_size;
240*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief min partition size
241*77c1e3ccSAndroid Build Coastguard Worker    * 8, 16, 32, 64, 128
242*77c1e3ccSAndroid Build Coastguard Worker    */
243*77c1e3ccSAndroid Build Coastguard Worker   unsigned int min_partition_size;
244*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable AB Shape partition type
245*77c1e3ccSAndroid Build Coastguard Worker    *
246*77c1e3ccSAndroid Build Coastguard Worker    */
247*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_ab_partition_type;
248*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable rectangular partition type
249*77c1e3ccSAndroid Build Coastguard Worker    *
250*77c1e3ccSAndroid Build Coastguard Worker    */
251*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_rect_partition_type;
252*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable 1:4/4:1 partition type
253*77c1e3ccSAndroid Build Coastguard Worker    *
254*77c1e3ccSAndroid Build Coastguard Worker    */
255*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_1to4_partition_type;
256*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable flip and identity transform type
257*77c1e3ccSAndroid Build Coastguard Worker    *
258*77c1e3ccSAndroid Build Coastguard Worker    */
259*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_flip_idtx;
260*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable CDEF filter
261*77c1e3ccSAndroid Build Coastguard Worker    *
262*77c1e3ccSAndroid Build Coastguard Worker    */
263*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_cdef;
264*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable Loop Restoration Filter
265*77c1e3ccSAndroid Build Coastguard Worker    *
266*77c1e3ccSAndroid Build Coastguard Worker    */
267*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_lr;
268*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable OBMC
269*77c1e3ccSAndroid Build Coastguard Worker    *
270*77c1e3ccSAndroid Build Coastguard Worker    */
271*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_obmc;
272*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable Warped Motion
273*77c1e3ccSAndroid Build Coastguard Worker    *
274*77c1e3ccSAndroid Build Coastguard Worker    */
275*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_warp_motion;
276*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable global motion
277*77c1e3ccSAndroid Build Coastguard Worker    *
278*77c1e3ccSAndroid Build Coastguard Worker    */
279*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_global_motion;
280*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable dist weighted compound
281*77c1e3ccSAndroid Build Coastguard Worker    *
282*77c1e3ccSAndroid Build Coastguard Worker    */
283*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_dist_wtd_comp;
284*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable diff weighted compound
285*77c1e3ccSAndroid Build Coastguard Worker    *
286*77c1e3ccSAndroid Build Coastguard Worker    */
287*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_diff_wtd_comp;
288*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable inter/intra compound
289*77c1e3ccSAndroid Build Coastguard Worker    *
290*77c1e3ccSAndroid Build Coastguard Worker    */
291*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_inter_intra_comp;
292*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable masked compound
293*77c1e3ccSAndroid Build Coastguard Worker    *
294*77c1e3ccSAndroid Build Coastguard Worker    */
295*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_masked_comp;
296*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable one sided compound
297*77c1e3ccSAndroid Build Coastguard Worker    *
298*77c1e3ccSAndroid Build Coastguard Worker    */
299*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_one_sided_comp;
300*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable Palette
301*77c1e3ccSAndroid Build Coastguard Worker    *
302*77c1e3ccSAndroid Build Coastguard Worker    */
303*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_palette;
304*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable Intra Block Copy
305*77c1e3ccSAndroid Build Coastguard Worker    *
306*77c1e3ccSAndroid Build Coastguard Worker    */
307*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_intrabc;
308*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable chroma from luma
309*77c1e3ccSAndroid Build Coastguard Worker    *
310*77c1e3ccSAndroid Build Coastguard Worker    */
311*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_cfl;
312*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable intra smooth mode
313*77c1e3ccSAndroid Build Coastguard Worker    *
314*77c1e3ccSAndroid Build Coastguard Worker    */
315*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_smooth_intra;
316*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable filter intra
317*77c1e3ccSAndroid Build Coastguard Worker    *
318*77c1e3ccSAndroid Build Coastguard Worker    */
319*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_filter_intra;
320*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable dual filter
321*77c1e3ccSAndroid Build Coastguard Worker    *
322*77c1e3ccSAndroid Build Coastguard Worker    */
323*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_dual_filter;
324*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable intra angle delta
325*77c1e3ccSAndroid Build Coastguard Worker    *
326*77c1e3ccSAndroid Build Coastguard Worker    */
327*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_intra_angle_delta;
328*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable intra edge filter
329*77c1e3ccSAndroid Build Coastguard Worker    *
330*77c1e3ccSAndroid Build Coastguard Worker    */
331*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_intra_edge_filter;
332*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable 64x64 transform
333*77c1e3ccSAndroid Build Coastguard Worker    *
334*77c1e3ccSAndroid Build Coastguard Worker    */
335*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_tx_64x64;
336*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable smooth inter/intra
337*77c1e3ccSAndroid Build Coastguard Worker    *
338*77c1e3ccSAndroid Build Coastguard Worker    */
339*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_smooth_inter_intra;
340*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable inter/inter wedge comp
341*77c1e3ccSAndroid Build Coastguard Worker    *
342*77c1e3ccSAndroid Build Coastguard Worker    */
343*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_inter_inter_wedge;
344*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable inter/intra wedge comp
345*77c1e3ccSAndroid Build Coastguard Worker    *
346*77c1e3ccSAndroid Build Coastguard Worker    */
347*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_inter_intra_wedge;
348*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable paeth intra
349*77c1e3ccSAndroid Build Coastguard Worker    *
350*77c1e3ccSAndroid Build Coastguard Worker    */
351*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_paeth_intra;
352*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable trellis quantization
353*77c1e3ccSAndroid Build Coastguard Worker    *
354*77c1e3ccSAndroid Build Coastguard Worker    */
355*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_trellis_quant;
356*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief disable ref frame MV
357*77c1e3ccSAndroid Build Coastguard Worker    *
358*77c1e3ccSAndroid Build Coastguard Worker    */
359*77c1e3ccSAndroid Build Coastguard Worker   unsigned int disable_ref_frame_mv;
360*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief use reduced reference frame set
361*77c1e3ccSAndroid Build Coastguard Worker    *
362*77c1e3ccSAndroid Build Coastguard Worker    */
363*77c1e3ccSAndroid Build Coastguard Worker   unsigned int reduced_reference_set;
364*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief use reduced transform type set
365*77c1e3ccSAndroid Build Coastguard Worker    *
366*77c1e3ccSAndroid Build Coastguard Worker    */
367*77c1e3ccSAndroid Build Coastguard Worker   unsigned int reduced_tx_type_set;
368*77c1e3ccSAndroid Build Coastguard Worker } cfg_options_t;
369*77c1e3ccSAndroid Build Coastguard Worker 
370*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Encoded Frame Flags
371*77c1e3ccSAndroid Build Coastguard Worker  *
372*77c1e3ccSAndroid Build Coastguard Worker  * This type indicates a bitfield to be passed to aom_codec_encode(), defining
373*77c1e3ccSAndroid Build Coastguard Worker  * per-frame boolean values. By convention, bits common to all codecs will be
374*77c1e3ccSAndroid Build Coastguard Worker  * named AOM_EFLAG_*, and bits specific to an algorithm will be named
375*77c1e3ccSAndroid Build Coastguard Worker  * /algo/_eflag_*. The lower order 16 bits are reserved for common use.
376*77c1e3ccSAndroid Build Coastguard Worker  */
377*77c1e3ccSAndroid Build Coastguard Worker typedef long aom_enc_frame_flags_t;
378*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Force this frame to be a keyframe */
379*77c1e3ccSAndroid Build Coastguard Worker #define AOM_EFLAG_FORCE_KF (1 << 0)
380*77c1e3ccSAndroid Build Coastguard Worker 
381*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Encoder configuration structure
382*77c1e3ccSAndroid Build Coastguard Worker  *
383*77c1e3ccSAndroid Build Coastguard Worker  * This structure contains the encoder settings that have common representations
384*77c1e3ccSAndroid Build Coastguard Worker  * across all codecs. This doesn't imply that all codecs support all features,
385*77c1e3ccSAndroid Build Coastguard Worker  * however.
386*77c1e3ccSAndroid Build Coastguard Worker  */
387*77c1e3ccSAndroid Build Coastguard Worker typedef struct aom_codec_enc_cfg {
388*77c1e3ccSAndroid Build Coastguard Worker   /*
389*77c1e3ccSAndroid Build Coastguard Worker    * generic settings (g)
390*77c1e3ccSAndroid Build Coastguard Worker    */
391*77c1e3ccSAndroid Build Coastguard Worker 
392*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Algorithm specific "usage" value
393*77c1e3ccSAndroid Build Coastguard Worker    *
394*77c1e3ccSAndroid Build Coastguard Worker    * Algorithms may define multiple values for usage, which may convey the
395*77c1e3ccSAndroid Build Coastguard Worker    * intent of how the application intends to use the stream. If this value
396*77c1e3ccSAndroid Build Coastguard Worker    * is non-zero, consult the documentation for the codec to determine its
397*77c1e3ccSAndroid Build Coastguard Worker    * meaning.
398*77c1e3ccSAndroid Build Coastguard Worker    */
399*77c1e3ccSAndroid Build Coastguard Worker   unsigned int g_usage;
400*77c1e3ccSAndroid Build Coastguard Worker 
401*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Maximum number of threads to use
402*77c1e3ccSAndroid Build Coastguard Worker    *
403*77c1e3ccSAndroid Build Coastguard Worker    * For multi-threaded implementations, use no more than this number of
404*77c1e3ccSAndroid Build Coastguard Worker    * threads. The codec may use fewer threads than allowed. The value
405*77c1e3ccSAndroid Build Coastguard Worker    * 0 is equivalent to the value 1.
406*77c1e3ccSAndroid Build Coastguard Worker    */
407*77c1e3ccSAndroid Build Coastguard Worker   unsigned int g_threads;
408*77c1e3ccSAndroid Build Coastguard Worker 
409*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Bitstream profile to use
410*77c1e3ccSAndroid Build Coastguard Worker    *
411*77c1e3ccSAndroid Build Coastguard Worker    * Some codecs support a notion of multiple bitstream profiles. Typically
412*77c1e3ccSAndroid Build Coastguard Worker    * this maps to a set of features that are turned on or off. Often the
413*77c1e3ccSAndroid Build Coastguard Worker    * profile to use is determined by the features of the intended decoder.
414*77c1e3ccSAndroid Build Coastguard Worker    * Consult the documentation for the codec to determine the valid values
415*77c1e3ccSAndroid Build Coastguard Worker    * for this parameter, or set to zero for a sane default.
416*77c1e3ccSAndroid Build Coastguard Worker    */
417*77c1e3ccSAndroid Build Coastguard Worker   unsigned int g_profile; /**< profile of bitstream to use */
418*77c1e3ccSAndroid Build Coastguard Worker 
419*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Width of the frame
420*77c1e3ccSAndroid Build Coastguard Worker    *
421*77c1e3ccSAndroid Build Coastguard Worker    * This value identifies the presentation resolution of the frame,
422*77c1e3ccSAndroid Build Coastguard Worker    * in pixels. Note that the frames passed as input to the encoder must
423*77c1e3ccSAndroid Build Coastguard Worker    * have this resolution. Frames will be presented by the decoder in this
424*77c1e3ccSAndroid Build Coastguard Worker    * resolution, independent of any spatial resampling the encoder may do.
425*77c1e3ccSAndroid Build Coastguard Worker    */
426*77c1e3ccSAndroid Build Coastguard Worker   unsigned int g_w;
427*77c1e3ccSAndroid Build Coastguard Worker 
428*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Height of the frame
429*77c1e3ccSAndroid Build Coastguard Worker    *
430*77c1e3ccSAndroid Build Coastguard Worker    * This value identifies the presentation resolution of the frame,
431*77c1e3ccSAndroid Build Coastguard Worker    * in pixels. Note that the frames passed as input to the encoder must
432*77c1e3ccSAndroid Build Coastguard Worker    * have this resolution. Frames will be presented by the decoder in this
433*77c1e3ccSAndroid Build Coastguard Worker    * resolution, independent of any spatial resampling the encoder may do.
434*77c1e3ccSAndroid Build Coastguard Worker    */
435*77c1e3ccSAndroid Build Coastguard Worker   unsigned int g_h;
436*77c1e3ccSAndroid Build Coastguard Worker 
437*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Max number of frames to encode
438*77c1e3ccSAndroid Build Coastguard Worker    *
439*77c1e3ccSAndroid Build Coastguard Worker    * If force video mode is off (the default) and g_limit is 1, the encoder
440*77c1e3ccSAndroid Build Coastguard Worker    * will encode a still picture (still_picture is set to 1 in the sequence
441*77c1e3ccSAndroid Build Coastguard Worker    * header OBU). If in addition full_still_picture_hdr is 0 (the default),
442*77c1e3ccSAndroid Build Coastguard Worker    * the encoder will use a reduced header (reduced_still_picture_header is
443*77c1e3ccSAndroid Build Coastguard Worker    * set to 1 in the sequence header OBU) for the still picture.
444*77c1e3ccSAndroid Build Coastguard Worker    */
445*77c1e3ccSAndroid Build Coastguard Worker   unsigned int g_limit;
446*77c1e3ccSAndroid Build Coastguard Worker 
447*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Forced maximum width of the frame
448*77c1e3ccSAndroid Build Coastguard Worker    *
449*77c1e3ccSAndroid Build Coastguard Worker    * If this value is non-zero then it is used to force the maximum frame
450*77c1e3ccSAndroid Build Coastguard Worker    * width written in write_sequence_header().
451*77c1e3ccSAndroid Build Coastguard Worker    */
452*77c1e3ccSAndroid Build Coastguard Worker   unsigned int g_forced_max_frame_width;
453*77c1e3ccSAndroid Build Coastguard Worker 
454*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Forced maximum height of the frame
455*77c1e3ccSAndroid Build Coastguard Worker    *
456*77c1e3ccSAndroid Build Coastguard Worker    * If this value is non-zero then it is used to force the maximum frame
457*77c1e3ccSAndroid Build Coastguard Worker    * height written in write_sequence_header().
458*77c1e3ccSAndroid Build Coastguard Worker    */
459*77c1e3ccSAndroid Build Coastguard Worker   unsigned int g_forced_max_frame_height;
460*77c1e3ccSAndroid Build Coastguard Worker 
461*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Bit-depth of the codec
462*77c1e3ccSAndroid Build Coastguard Worker    *
463*77c1e3ccSAndroid Build Coastguard Worker    * This value identifies the bit_depth of the codec,
464*77c1e3ccSAndroid Build Coastguard Worker    * Only certain bit-depths are supported as identified in the
465*77c1e3ccSAndroid Build Coastguard Worker    * aom_bit_depth_t enum.
466*77c1e3ccSAndroid Build Coastguard Worker    */
467*77c1e3ccSAndroid Build Coastguard Worker   aom_bit_depth_t g_bit_depth;
468*77c1e3ccSAndroid Build Coastguard Worker 
469*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Bit-depth of the input frames
470*77c1e3ccSAndroid Build Coastguard Worker    *
471*77c1e3ccSAndroid Build Coastguard Worker    * This value identifies the bit_depth of the input frames in bits.
472*77c1e3ccSAndroid Build Coastguard Worker    * Note that the frames passed as input to the encoder must have
473*77c1e3ccSAndroid Build Coastguard Worker    * this bit-depth.
474*77c1e3ccSAndroid Build Coastguard Worker    */
475*77c1e3ccSAndroid Build Coastguard Worker   unsigned int g_input_bit_depth;
476*77c1e3ccSAndroid Build Coastguard Worker 
477*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Stream timebase units
478*77c1e3ccSAndroid Build Coastguard Worker    *
479*77c1e3ccSAndroid Build Coastguard Worker    * Indicates the smallest interval of time, in seconds, used by the stream.
480*77c1e3ccSAndroid Build Coastguard Worker    * For fixed frame rate material, or variable frame rate material where
481*77c1e3ccSAndroid Build Coastguard Worker    * frames are timed at a multiple of a given clock (ex: video capture),
482*77c1e3ccSAndroid Build Coastguard Worker    * the \ref RECOMMENDED method is to set the timebase to the reciprocal
483*77c1e3ccSAndroid Build Coastguard Worker    * of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the
484*77c1e3ccSAndroid Build Coastguard Worker    * pts to correspond to the frame number, which can be handy. For
485*77c1e3ccSAndroid Build Coastguard Worker    * re-encoding video from containers with absolute time timestamps, the
486*77c1e3ccSAndroid Build Coastguard Worker    * \ref RECOMMENDED method is to set the timebase to that of the parent
487*77c1e3ccSAndroid Build Coastguard Worker    * container or multimedia framework (ex: 1/1000 for ms, as in FLV).
488*77c1e3ccSAndroid Build Coastguard Worker    */
489*77c1e3ccSAndroid Build Coastguard Worker   struct aom_rational g_timebase;
490*77c1e3ccSAndroid Build Coastguard Worker 
491*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Enable error resilient modes.
492*77c1e3ccSAndroid Build Coastguard Worker    *
493*77c1e3ccSAndroid Build Coastguard Worker    * The error resilient bitfield indicates to the encoder which features
494*77c1e3ccSAndroid Build Coastguard Worker    * it should enable to take measures for streaming over lossy or noisy
495*77c1e3ccSAndroid Build Coastguard Worker    * links.
496*77c1e3ccSAndroid Build Coastguard Worker    */
497*77c1e3ccSAndroid Build Coastguard Worker   aom_codec_er_flags_t g_error_resilient;
498*77c1e3ccSAndroid Build Coastguard Worker 
499*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Multi-pass Encoding Mode
500*77c1e3ccSAndroid Build Coastguard Worker    *
501*77c1e3ccSAndroid Build Coastguard Worker    * This value should be set to the current phase for multi-pass encoding.
502*77c1e3ccSAndroid Build Coastguard Worker    * For single pass, set to #AOM_RC_ONE_PASS.
503*77c1e3ccSAndroid Build Coastguard Worker    */
504*77c1e3ccSAndroid Build Coastguard Worker   enum aom_enc_pass g_pass;
505*77c1e3ccSAndroid Build Coastguard Worker 
506*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Allow lagged encoding
507*77c1e3ccSAndroid Build Coastguard Worker    *
508*77c1e3ccSAndroid Build Coastguard Worker    * If set, this value allows the encoder to consume a number of input
509*77c1e3ccSAndroid Build Coastguard Worker    * frames before producing output frames. This allows the encoder to
510*77c1e3ccSAndroid Build Coastguard Worker    * base decisions for the current frame on future frames. This does
511*77c1e3ccSAndroid Build Coastguard Worker    * increase the latency of the encoding pipeline, so it is not appropriate
512*77c1e3ccSAndroid Build Coastguard Worker    * in all situations (ex: realtime encoding).
513*77c1e3ccSAndroid Build Coastguard Worker    *
514*77c1e3ccSAndroid Build Coastguard Worker    * Note that this is a maximum value -- the encoder may produce frames
515*77c1e3ccSAndroid Build Coastguard Worker    * sooner than the given limit. Set this value to 0 to disable this
516*77c1e3ccSAndroid Build Coastguard Worker    * feature.
517*77c1e3ccSAndroid Build Coastguard Worker    */
518*77c1e3ccSAndroid Build Coastguard Worker   unsigned int g_lag_in_frames;
519*77c1e3ccSAndroid Build Coastguard Worker 
520*77c1e3ccSAndroid Build Coastguard Worker   /*
521*77c1e3ccSAndroid Build Coastguard Worker    * rate control settings (rc)
522*77c1e3ccSAndroid Build Coastguard Worker    */
523*77c1e3ccSAndroid Build Coastguard Worker 
524*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Temporal resampling configuration, if supported by the codec.
525*77c1e3ccSAndroid Build Coastguard Worker    *
526*77c1e3ccSAndroid Build Coastguard Worker    * Temporal resampling allows the codec to "drop" frames as a strategy to
527*77c1e3ccSAndroid Build Coastguard Worker    * meet its target data rate. This can cause temporal discontinuities in
528*77c1e3ccSAndroid Build Coastguard Worker    * the encoded video, which may appear as stuttering during playback. This
529*77c1e3ccSAndroid Build Coastguard Worker    * trade-off is often acceptable, but for many applications is not. It can
530*77c1e3ccSAndroid Build Coastguard Worker    * be disabled in these cases.
531*77c1e3ccSAndroid Build Coastguard Worker    *
532*77c1e3ccSAndroid Build Coastguard Worker    * Note that not all codecs support this feature. All aom AVx codecs do.
533*77c1e3ccSAndroid Build Coastguard Worker    * For other codecs, consult the documentation for that algorithm.
534*77c1e3ccSAndroid Build Coastguard Worker    *
535*77c1e3ccSAndroid Build Coastguard Worker    * This threshold is described as a percentage of the target data buffer.
536*77c1e3ccSAndroid Build Coastguard Worker    * When the data buffer falls below this percentage of fullness, a
537*77c1e3ccSAndroid Build Coastguard Worker    * dropped frame is indicated. Set the threshold to zero (0) to disable
538*77c1e3ccSAndroid Build Coastguard Worker    * this feature.
539*77c1e3ccSAndroid Build Coastguard Worker    */
540*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_dropframe_thresh;
541*77c1e3ccSAndroid Build Coastguard Worker 
542*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Mode for spatial resampling, if supported by the codec.
543*77c1e3ccSAndroid Build Coastguard Worker    *
544*77c1e3ccSAndroid Build Coastguard Worker    * Spatial resampling allows the codec to compress a lower resolution
545*77c1e3ccSAndroid Build Coastguard Worker    * version of the frame, which is then upscaled by the decoder to the
546*77c1e3ccSAndroid Build Coastguard Worker    * correct presentation resolution. This increases visual quality at
547*77c1e3ccSAndroid Build Coastguard Worker    * low data rates, at the expense of CPU time on the encoder/decoder.
548*77c1e3ccSAndroid Build Coastguard Worker    */
549*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_resize_mode;
550*77c1e3ccSAndroid Build Coastguard Worker 
551*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Frame resize denominator.
552*77c1e3ccSAndroid Build Coastguard Worker    *
553*77c1e3ccSAndroid Build Coastguard Worker    * The denominator for resize to use, assuming 8 as the numerator.
554*77c1e3ccSAndroid Build Coastguard Worker    *
555*77c1e3ccSAndroid Build Coastguard Worker    * Valid denominators are  8 - 16 for now.
556*77c1e3ccSAndroid Build Coastguard Worker    */
557*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_resize_denominator;
558*77c1e3ccSAndroid Build Coastguard Worker 
559*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Keyframe resize denominator.
560*77c1e3ccSAndroid Build Coastguard Worker    *
561*77c1e3ccSAndroid Build Coastguard Worker    * The denominator for resize to use, assuming 8 as the numerator.
562*77c1e3ccSAndroid Build Coastguard Worker    *
563*77c1e3ccSAndroid Build Coastguard Worker    * Valid denominators are  8 - 16 for now.
564*77c1e3ccSAndroid Build Coastguard Worker    */
565*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_resize_kf_denominator;
566*77c1e3ccSAndroid Build Coastguard Worker 
567*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Frame super-resolution scaling mode.
568*77c1e3ccSAndroid Build Coastguard Worker    *
569*77c1e3ccSAndroid Build Coastguard Worker    * Similar to spatial resampling, frame super-resolution integrates
570*77c1e3ccSAndroid Build Coastguard Worker    * upscaling after the encode/decode process. Taking control of upscaling and
571*77c1e3ccSAndroid Build Coastguard Worker    * using restoration filters should allow it to outperform normal resizing.
572*77c1e3ccSAndroid Build Coastguard Worker    */
573*77c1e3ccSAndroid Build Coastguard Worker   aom_superres_mode rc_superres_mode;
574*77c1e3ccSAndroid Build Coastguard Worker 
575*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Frame super-resolution denominator.
576*77c1e3ccSAndroid Build Coastguard Worker    *
577*77c1e3ccSAndroid Build Coastguard Worker    * The denominator for superres to use. If fixed it will only change if the
578*77c1e3ccSAndroid Build Coastguard Worker    * cumulative scale change over resizing and superres is greater than 1/2;
579*77c1e3ccSAndroid Build Coastguard Worker    * this forces superres to reduce scaling.
580*77c1e3ccSAndroid Build Coastguard Worker    *
581*77c1e3ccSAndroid Build Coastguard Worker    * Valid denominators are 8 to 16.
582*77c1e3ccSAndroid Build Coastguard Worker    *
583*77c1e3ccSAndroid Build Coastguard Worker    * Used only by AOM_SUPERRES_FIXED.
584*77c1e3ccSAndroid Build Coastguard Worker    */
585*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_superres_denominator;
586*77c1e3ccSAndroid Build Coastguard Worker 
587*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Keyframe super-resolution denominator.
588*77c1e3ccSAndroid Build Coastguard Worker    *
589*77c1e3ccSAndroid Build Coastguard Worker    * The denominator for superres to use. If fixed it will only change if the
590*77c1e3ccSAndroid Build Coastguard Worker    * cumulative scale change over resizing and superres is greater than 1/2;
591*77c1e3ccSAndroid Build Coastguard Worker    * this forces superres to reduce scaling.
592*77c1e3ccSAndroid Build Coastguard Worker    *
593*77c1e3ccSAndroid Build Coastguard Worker    * Valid denominators are 8 - 16 for now.
594*77c1e3ccSAndroid Build Coastguard Worker    */
595*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_superres_kf_denominator;
596*77c1e3ccSAndroid Build Coastguard Worker 
597*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Frame super-resolution q threshold.
598*77c1e3ccSAndroid Build Coastguard Worker    *
599*77c1e3ccSAndroid Build Coastguard Worker    * The q level threshold after which superres is used.
600*77c1e3ccSAndroid Build Coastguard Worker    * Valid values are 1 to 63.
601*77c1e3ccSAndroid Build Coastguard Worker    *
602*77c1e3ccSAndroid Build Coastguard Worker    * Used only by AOM_SUPERRES_QTHRESH
603*77c1e3ccSAndroid Build Coastguard Worker    */
604*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_superres_qthresh;
605*77c1e3ccSAndroid Build Coastguard Worker 
606*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Keyframe super-resolution q threshold.
607*77c1e3ccSAndroid Build Coastguard Worker    *
608*77c1e3ccSAndroid Build Coastguard Worker    * The q level threshold after which superres is used for key frames.
609*77c1e3ccSAndroid Build Coastguard Worker    * Valid values are 1 to 63.
610*77c1e3ccSAndroid Build Coastguard Worker    *
611*77c1e3ccSAndroid Build Coastguard Worker    * Used only by AOM_SUPERRES_QTHRESH
612*77c1e3ccSAndroid Build Coastguard Worker    */
613*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_superres_kf_qthresh;
614*77c1e3ccSAndroid Build Coastguard Worker 
615*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Rate control algorithm to use.
616*77c1e3ccSAndroid Build Coastguard Worker    *
617*77c1e3ccSAndroid Build Coastguard Worker    * Indicates whether the end usage of this stream is to be streamed over
618*77c1e3ccSAndroid Build Coastguard Worker    * a bandwidth constrained link, indicating that Constant Bit Rate (CBR)
619*77c1e3ccSAndroid Build Coastguard Worker    * mode should be used, or whether it will be played back on a high
620*77c1e3ccSAndroid Build Coastguard Worker    * bandwidth link, as from a local disk, where higher variations in
621*77c1e3ccSAndroid Build Coastguard Worker    * bitrate are acceptable.
622*77c1e3ccSAndroid Build Coastguard Worker    */
623*77c1e3ccSAndroid Build Coastguard Worker   enum aom_rc_mode rc_end_usage;
624*77c1e3ccSAndroid Build Coastguard Worker 
625*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Two-pass stats buffer.
626*77c1e3ccSAndroid Build Coastguard Worker    *
627*77c1e3ccSAndroid Build Coastguard Worker    * A buffer containing all of the stats packets produced in the first
628*77c1e3ccSAndroid Build Coastguard Worker    * pass, concatenated.
629*77c1e3ccSAndroid Build Coastguard Worker    */
630*77c1e3ccSAndroid Build Coastguard Worker   aom_fixed_buf_t rc_twopass_stats_in;
631*77c1e3ccSAndroid Build Coastguard Worker 
632*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief first pass mb stats buffer.
633*77c1e3ccSAndroid Build Coastguard Worker    *
634*77c1e3ccSAndroid Build Coastguard Worker    * A buffer containing all of the first pass mb stats packets produced
635*77c1e3ccSAndroid Build Coastguard Worker    * in the first pass, concatenated.
636*77c1e3ccSAndroid Build Coastguard Worker    */
637*77c1e3ccSAndroid Build Coastguard Worker   aom_fixed_buf_t rc_firstpass_mb_stats_in;
638*77c1e3ccSAndroid Build Coastguard Worker 
639*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Target data rate
640*77c1e3ccSAndroid Build Coastguard Worker    *
641*77c1e3ccSAndroid Build Coastguard Worker    * Target bitrate to use for this stream, in kilobits per second.
642*77c1e3ccSAndroid Build Coastguard Worker    * Max allowed value is 2000000
643*77c1e3ccSAndroid Build Coastguard Worker    */
644*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_target_bitrate;
645*77c1e3ccSAndroid Build Coastguard Worker 
646*77c1e3ccSAndroid Build Coastguard Worker   /*
647*77c1e3ccSAndroid Build Coastguard Worker    * quantizer settings
648*77c1e3ccSAndroid Build Coastguard Worker    */
649*77c1e3ccSAndroid Build Coastguard Worker 
650*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Minimum (Best Quality) Quantizer
651*77c1e3ccSAndroid Build Coastguard Worker    *
652*77c1e3ccSAndroid Build Coastguard Worker    * The quantizer is the most direct control over the quality of the
653*77c1e3ccSAndroid Build Coastguard Worker    * encoded image. The range of valid values for the quantizer is codec
654*77c1e3ccSAndroid Build Coastguard Worker    * specific. Consult the documentation for the codec to determine the
655*77c1e3ccSAndroid Build Coastguard Worker    * values to use. To determine the range programmatically, call
656*77c1e3ccSAndroid Build Coastguard Worker    * aom_codec_enc_config_default() with a usage value of 0.
657*77c1e3ccSAndroid Build Coastguard Worker    */
658*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_min_quantizer;
659*77c1e3ccSAndroid Build Coastguard Worker 
660*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Maximum (Worst Quality) Quantizer
661*77c1e3ccSAndroid Build Coastguard Worker    *
662*77c1e3ccSAndroid Build Coastguard Worker    * The quantizer is the most direct control over the quality of the
663*77c1e3ccSAndroid Build Coastguard Worker    * encoded image. The range of valid values for the quantizer is codec
664*77c1e3ccSAndroid Build Coastguard Worker    * specific. Consult the documentation for the codec to determine the
665*77c1e3ccSAndroid Build Coastguard Worker    * values to use. To determine the range programmatically, call
666*77c1e3ccSAndroid Build Coastguard Worker    * aom_codec_enc_config_default() with a usage value of 0.
667*77c1e3ccSAndroid Build Coastguard Worker    */
668*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_max_quantizer;
669*77c1e3ccSAndroid Build Coastguard Worker 
670*77c1e3ccSAndroid Build Coastguard Worker   /*
671*77c1e3ccSAndroid Build Coastguard Worker    * bitrate tolerance
672*77c1e3ccSAndroid Build Coastguard Worker    */
673*77c1e3ccSAndroid Build Coastguard Worker 
674*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Rate control adaptation undershoot control
675*77c1e3ccSAndroid Build Coastguard Worker    *
676*77c1e3ccSAndroid Build Coastguard Worker    * This value, controls the tolerance of the VBR algorithm to undershoot
677*77c1e3ccSAndroid Build Coastguard Worker    * and is used as a trigger threshold for more aggressive adaptation of Q.
678*77c1e3ccSAndroid Build Coastguard Worker    *
679*77c1e3ccSAndroid Build Coastguard Worker    * Valid values in the range 0-100.
680*77c1e3ccSAndroid Build Coastguard Worker    */
681*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_undershoot_pct;
682*77c1e3ccSAndroid Build Coastguard Worker 
683*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Rate control adaptation overshoot control
684*77c1e3ccSAndroid Build Coastguard Worker    *
685*77c1e3ccSAndroid Build Coastguard Worker    * This value, controls the tolerance of the VBR algorithm to overshoot
686*77c1e3ccSAndroid Build Coastguard Worker    * and is used as a trigger threshold for more aggressive adaptation of Q.
687*77c1e3ccSAndroid Build Coastguard Worker    *
688*77c1e3ccSAndroid Build Coastguard Worker    * Valid values in the range 0-100.
689*77c1e3ccSAndroid Build Coastguard Worker    */
690*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_overshoot_pct;
691*77c1e3ccSAndroid Build Coastguard Worker 
692*77c1e3ccSAndroid Build Coastguard Worker   /*
693*77c1e3ccSAndroid Build Coastguard Worker    * decoder buffer model parameters
694*77c1e3ccSAndroid Build Coastguard Worker    */
695*77c1e3ccSAndroid Build Coastguard Worker 
696*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Decoder Buffer Size
697*77c1e3ccSAndroid Build Coastguard Worker    *
698*77c1e3ccSAndroid Build Coastguard Worker    * This value indicates the amount of data that may be buffered by the
699*77c1e3ccSAndroid Build Coastguard Worker    * decoding application. Note that this value is expressed in units of
700*77c1e3ccSAndroid Build Coastguard Worker    * time (milliseconds). For example, a value of 5000 indicates that the
701*77c1e3ccSAndroid Build Coastguard Worker    * client will buffer (at least) 5000ms worth of encoded data. Use the
702*77c1e3ccSAndroid Build Coastguard Worker    * target bitrate (#rc_target_bitrate) to convert to bits/bytes, if
703*77c1e3ccSAndroid Build Coastguard Worker    * necessary.
704*77c1e3ccSAndroid Build Coastguard Worker    */
705*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_buf_sz;
706*77c1e3ccSAndroid Build Coastguard Worker 
707*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Decoder Buffer Initial Size
708*77c1e3ccSAndroid Build Coastguard Worker    *
709*77c1e3ccSAndroid Build Coastguard Worker    * This value indicates the amount of data that will be buffered by the
710*77c1e3ccSAndroid Build Coastguard Worker    * decoding application prior to beginning playback. This value is
711*77c1e3ccSAndroid Build Coastguard Worker    * expressed in units of time (milliseconds). Use the target bitrate
712*77c1e3ccSAndroid Build Coastguard Worker    * (#rc_target_bitrate) to convert to bits/bytes, if necessary.
713*77c1e3ccSAndroid Build Coastguard Worker    */
714*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_buf_initial_sz;
715*77c1e3ccSAndroid Build Coastguard Worker 
716*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Decoder Buffer Optimal Size
717*77c1e3ccSAndroid Build Coastguard Worker    *
718*77c1e3ccSAndroid Build Coastguard Worker    * This value indicates the amount of data that the encoder should try
719*77c1e3ccSAndroid Build Coastguard Worker    * to maintain in the decoder's buffer. This value is expressed in units
720*77c1e3ccSAndroid Build Coastguard Worker    * of time (milliseconds). Use the target bitrate (#rc_target_bitrate)
721*77c1e3ccSAndroid Build Coastguard Worker    * to convert to bits/bytes, if necessary.
722*77c1e3ccSAndroid Build Coastguard Worker    */
723*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_buf_optimal_sz;
724*77c1e3ccSAndroid Build Coastguard Worker 
725*77c1e3ccSAndroid Build Coastguard Worker   /*
726*77c1e3ccSAndroid Build Coastguard Worker    * 2 pass rate control parameters
727*77c1e3ccSAndroid Build Coastguard Worker    */
728*77c1e3ccSAndroid Build Coastguard Worker 
729*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Two-pass mode CBR/VBR bias
730*77c1e3ccSAndroid Build Coastguard Worker    *
731*77c1e3ccSAndroid Build Coastguard Worker    * Bias, expressed on a scale of 0 to 100, for determining target size
732*77c1e3ccSAndroid Build Coastguard Worker    * for the current frame. The value 0 indicates the optimal CBR mode
733*77c1e3ccSAndroid Build Coastguard Worker    * value should be used. The value 100 indicates the optimal VBR mode
734*77c1e3ccSAndroid Build Coastguard Worker    * value should be used. Values in between indicate which way the
735*77c1e3ccSAndroid Build Coastguard Worker    * encoder should "lean."
736*77c1e3ccSAndroid Build Coastguard Worker    */
737*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_2pass_vbr_bias_pct;
738*77c1e3ccSAndroid Build Coastguard Worker 
739*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Two-pass mode per-GOP minimum bitrate
740*77c1e3ccSAndroid Build Coastguard Worker    *
741*77c1e3ccSAndroid Build Coastguard Worker    * This value, expressed as a percentage of the target bitrate, indicates
742*77c1e3ccSAndroid Build Coastguard Worker    * the minimum bitrate to be used for a single GOP (aka "section")
743*77c1e3ccSAndroid Build Coastguard Worker    */
744*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_2pass_vbr_minsection_pct;
745*77c1e3ccSAndroid Build Coastguard Worker 
746*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Two-pass mode per-GOP maximum bitrate
747*77c1e3ccSAndroid Build Coastguard Worker    *
748*77c1e3ccSAndroid Build Coastguard Worker    * This value, expressed as a percentage of the target bitrate, indicates
749*77c1e3ccSAndroid Build Coastguard Worker    * the maximum bitrate to be used for a single GOP (aka "section")
750*77c1e3ccSAndroid Build Coastguard Worker    */
751*77c1e3ccSAndroid Build Coastguard Worker   unsigned int rc_2pass_vbr_maxsection_pct;
752*77c1e3ccSAndroid Build Coastguard Worker 
753*77c1e3ccSAndroid Build Coastguard Worker   /*
754*77c1e3ccSAndroid Build Coastguard Worker    * keyframing settings (kf)
755*77c1e3ccSAndroid Build Coastguard Worker    */
756*77c1e3ccSAndroid Build Coastguard Worker 
757*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Option to enable forward reference key frame
758*77c1e3ccSAndroid Build Coastguard Worker    *
759*77c1e3ccSAndroid Build Coastguard Worker    */
760*77c1e3ccSAndroid Build Coastguard Worker   int fwd_kf_enabled;
761*77c1e3ccSAndroid Build Coastguard Worker 
762*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Keyframe placement mode
763*77c1e3ccSAndroid Build Coastguard Worker    *
764*77c1e3ccSAndroid Build Coastguard Worker    * This value indicates whether the encoder should place keyframes at a
765*77c1e3ccSAndroid Build Coastguard Worker    * fixed interval, or determine the optimal placement automatically
766*77c1e3ccSAndroid Build Coastguard Worker    * (as governed by the #kf_min_dist and #kf_max_dist parameters)
767*77c1e3ccSAndroid Build Coastguard Worker    */
768*77c1e3ccSAndroid Build Coastguard Worker   enum aom_kf_mode kf_mode;
769*77c1e3ccSAndroid Build Coastguard Worker 
770*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Keyframe minimum interval
771*77c1e3ccSAndroid Build Coastguard Worker    *
772*77c1e3ccSAndroid Build Coastguard Worker    * This value, expressed as a number of frames, prevents the encoder from
773*77c1e3ccSAndroid Build Coastguard Worker    * placing a keyframe nearer than kf_min_dist to the previous keyframe. At
774*77c1e3ccSAndroid Build Coastguard Worker    * least kf_min_dist frames non-keyframes will be coded before the next
775*77c1e3ccSAndroid Build Coastguard Worker    * keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval.
776*77c1e3ccSAndroid Build Coastguard Worker    */
777*77c1e3ccSAndroid Build Coastguard Worker   unsigned int kf_min_dist;
778*77c1e3ccSAndroid Build Coastguard Worker 
779*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Keyframe maximum interval
780*77c1e3ccSAndroid Build Coastguard Worker    *
781*77c1e3ccSAndroid Build Coastguard Worker    * This value, expressed as a number of frames, forces the encoder to code
782*77c1e3ccSAndroid Build Coastguard Worker    * a keyframe if one has not been coded in the last kf_max_dist frames.
783*77c1e3ccSAndroid Build Coastguard Worker    * A value of 0 implies all frames will be keyframes. Set kf_min_dist
784*77c1e3ccSAndroid Build Coastguard Worker    * equal to kf_max_dist for a fixed interval.
785*77c1e3ccSAndroid Build Coastguard Worker    */
786*77c1e3ccSAndroid Build Coastguard Worker   unsigned int kf_max_dist;
787*77c1e3ccSAndroid Build Coastguard Worker 
788*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief sframe interval
789*77c1e3ccSAndroid Build Coastguard Worker    *
790*77c1e3ccSAndroid Build Coastguard Worker    * This value, expressed as a number of frames, forces the encoder to code
791*77c1e3ccSAndroid Build Coastguard Worker    * an S-Frame every sframe_dist frames.
792*77c1e3ccSAndroid Build Coastguard Worker    */
793*77c1e3ccSAndroid Build Coastguard Worker   unsigned int sframe_dist;
794*77c1e3ccSAndroid Build Coastguard Worker 
795*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief sframe insertion mode
796*77c1e3ccSAndroid Build Coastguard Worker    *
797*77c1e3ccSAndroid Build Coastguard Worker    * This value must be set to 1 or 2, and tells the encoder how to insert
798*77c1e3ccSAndroid Build Coastguard Worker    * S-Frames. It will only have an effect if sframe_dist != 0.
799*77c1e3ccSAndroid Build Coastguard Worker    *
800*77c1e3ccSAndroid Build Coastguard Worker    * If altref is enabled:
801*77c1e3ccSAndroid Build Coastguard Worker    *   - if sframe_mode == 1, the considered frame will be made into an
802*77c1e3ccSAndroid Build Coastguard Worker    *     S-Frame only if it is an altref frame
803*77c1e3ccSAndroid Build Coastguard Worker    *   - if sframe_mode == 2, the next altref frame will be made into an
804*77c1e3ccSAndroid Build Coastguard Worker    *     S-Frame.
805*77c1e3ccSAndroid Build Coastguard Worker    *
806*77c1e3ccSAndroid Build Coastguard Worker    * Otherwise: the considered frame will be made into an S-Frame.
807*77c1e3ccSAndroid Build Coastguard Worker    *
808*77c1e3ccSAndroid Build Coastguard Worker    * \attention Not implemented.
809*77c1e3ccSAndroid Build Coastguard Worker    */
810*77c1e3ccSAndroid Build Coastguard Worker   unsigned int sframe_mode;
811*77c1e3ccSAndroid Build Coastguard Worker 
812*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Tile coding mode
813*77c1e3ccSAndroid Build Coastguard Worker    *
814*77c1e3ccSAndroid Build Coastguard Worker    * This value indicates the tile coding mode.
815*77c1e3ccSAndroid Build Coastguard Worker    * A value of 0 implies a normal non-large-scale tile coding. A value of 1
816*77c1e3ccSAndroid Build Coastguard Worker    * implies a large-scale tile coding.
817*77c1e3ccSAndroid Build Coastguard Worker    */
818*77c1e3ccSAndroid Build Coastguard Worker   unsigned int large_scale_tile;
819*77c1e3ccSAndroid Build Coastguard Worker 
820*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Monochrome mode
821*77c1e3ccSAndroid Build Coastguard Worker    *
822*77c1e3ccSAndroid Build Coastguard Worker    * If this is nonzero, the encoder will generate a monochrome stream
823*77c1e3ccSAndroid Build Coastguard Worker    * with no chroma planes.
824*77c1e3ccSAndroid Build Coastguard Worker    */
825*77c1e3ccSAndroid Build Coastguard Worker   unsigned int monochrome;
826*77c1e3ccSAndroid Build Coastguard Worker 
827*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief full_still_picture_hdr
828*77c1e3ccSAndroid Build Coastguard Worker    *
829*77c1e3ccSAndroid Build Coastguard Worker    * If this is nonzero, the encoder will generate a full header
830*77c1e3ccSAndroid Build Coastguard Worker    * (reduced_still_picture_header is set to 0 in the sequence header OBU) even
831*77c1e3ccSAndroid Build Coastguard Worker    * for still picture encoding. If this is zero (the default), a reduced
832*77c1e3ccSAndroid Build Coastguard Worker    * header (reduced_still_picture_header is set to 1 in the sequence header
833*77c1e3ccSAndroid Build Coastguard Worker    * OBU) is used for still picture encoding. This flag has no effect when a
834*77c1e3ccSAndroid Build Coastguard Worker    * regular video with more than a single frame is encoded.
835*77c1e3ccSAndroid Build Coastguard Worker    */
836*77c1e3ccSAndroid Build Coastguard Worker   unsigned int full_still_picture_hdr;
837*77c1e3ccSAndroid Build Coastguard Worker 
838*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Bitstream syntax mode
839*77c1e3ccSAndroid Build Coastguard Worker    *
840*77c1e3ccSAndroid Build Coastguard Worker    * This value indicates the bitstream syntax mode.
841*77c1e3ccSAndroid Build Coastguard Worker    * A value of 0 indicates bitstream is saved as Section 5 bitstream. A value
842*77c1e3ccSAndroid Build Coastguard Worker    * of 1 indicates the bitstream is saved in Annex-B format
843*77c1e3ccSAndroid Build Coastguard Worker    */
844*77c1e3ccSAndroid Build Coastguard Worker   unsigned int save_as_annexb;
845*77c1e3ccSAndroid Build Coastguard Worker 
846*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Number of explicit tile widths specified
847*77c1e3ccSAndroid Build Coastguard Worker    *
848*77c1e3ccSAndroid Build Coastguard Worker    * This value indicates the number of tile widths specified
849*77c1e3ccSAndroid Build Coastguard Worker    * A value of 0 implies no tile widths are specified.
850*77c1e3ccSAndroid Build Coastguard Worker    * Tile widths are given in the array tile_widths[]
851*77c1e3ccSAndroid Build Coastguard Worker    */
852*77c1e3ccSAndroid Build Coastguard Worker   int tile_width_count;
853*77c1e3ccSAndroid Build Coastguard Worker 
854*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Number of explicit tile heights specified
855*77c1e3ccSAndroid Build Coastguard Worker    *
856*77c1e3ccSAndroid Build Coastguard Worker    * This value indicates the number of tile heights specified
857*77c1e3ccSAndroid Build Coastguard Worker    * A value of 0 implies no tile heights are specified.
858*77c1e3ccSAndroid Build Coastguard Worker    * Tile heights are given in the array tile_heights[]
859*77c1e3ccSAndroid Build Coastguard Worker    */
860*77c1e3ccSAndroid Build Coastguard Worker   int tile_height_count;
861*77c1e3ccSAndroid Build Coastguard Worker 
862*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Maximum number of tile widths in tile widths array
863*77c1e3ccSAndroid Build Coastguard Worker  *
864*77c1e3ccSAndroid Build Coastguard Worker  * This define gives the maximum number of elements in the tile_widths array.
865*77c1e3ccSAndroid Build Coastguard Worker  */
866*77c1e3ccSAndroid Build Coastguard Worker #define MAX_TILE_WIDTHS 64  // maximum tile width array length
867*77c1e3ccSAndroid Build Coastguard Worker 
868*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Array of specified tile widths
869*77c1e3ccSAndroid Build Coastguard Worker    *
870*77c1e3ccSAndroid Build Coastguard Worker    * This array specifies tile widths (and may be empty)
871*77c1e3ccSAndroid Build Coastguard Worker    * The number of widths specified is given by tile_width_count
872*77c1e3ccSAndroid Build Coastguard Worker    */
873*77c1e3ccSAndroid Build Coastguard Worker   int tile_widths[MAX_TILE_WIDTHS];
874*77c1e3ccSAndroid Build Coastguard Worker 
875*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Maximum number of tile heights in tile heights array.
876*77c1e3ccSAndroid Build Coastguard Worker  *
877*77c1e3ccSAndroid Build Coastguard Worker  * This define gives the maximum number of elements in the tile_heights array.
878*77c1e3ccSAndroid Build Coastguard Worker  */
879*77c1e3ccSAndroid Build Coastguard Worker #define MAX_TILE_HEIGHTS 64  // maximum tile height array length
880*77c1e3ccSAndroid Build Coastguard Worker 
881*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Array of specified tile heights
882*77c1e3ccSAndroid Build Coastguard Worker    *
883*77c1e3ccSAndroid Build Coastguard Worker    * This array specifies tile heights (and may be empty)
884*77c1e3ccSAndroid Build Coastguard Worker    * The number of heights specified is given by tile_height_count
885*77c1e3ccSAndroid Build Coastguard Worker    */
886*77c1e3ccSAndroid Build Coastguard Worker   int tile_heights[MAX_TILE_HEIGHTS];
887*77c1e3ccSAndroid Build Coastguard Worker 
888*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Whether encoder should use fixed QP offsets.
889*77c1e3ccSAndroid Build Coastguard Worker    *
890*77c1e3ccSAndroid Build Coastguard Worker    * If a value of 1 is provided, encoder will use fixed QP offsets for frames
891*77c1e3ccSAndroid Build Coastguard Worker    * at different levels of the pyramid.
892*77c1e3ccSAndroid Build Coastguard Worker    * If a value of 0 is provided, encoder will NOT use fixed QP offsets.
893*77c1e3ccSAndroid Build Coastguard Worker    * Note: This option is only relevant for --end-usage=q.
894*77c1e3ccSAndroid Build Coastguard Worker    */
895*77c1e3ccSAndroid Build Coastguard Worker   unsigned int use_fixed_qp_offsets;
896*77c1e3ccSAndroid Build Coastguard Worker 
897*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Deprecated and ignored. DO NOT USE.
898*77c1e3ccSAndroid Build Coastguard Worker    *
899*77c1e3ccSAndroid Build Coastguard Worker    * TODO(aomedia:3269): Remove fixed_qp_offsets in libaom v4.0.0.
900*77c1e3ccSAndroid Build Coastguard Worker    */
901*77c1e3ccSAndroid Build Coastguard Worker   int fixed_qp_offsets[5];
902*77c1e3ccSAndroid Build Coastguard Worker 
903*77c1e3ccSAndroid Build Coastguard Worker   /*!\brief Options defined per config file
904*77c1e3ccSAndroid Build Coastguard Worker    *
905*77c1e3ccSAndroid Build Coastguard Worker    */
906*77c1e3ccSAndroid Build Coastguard Worker   cfg_options_t encoder_cfg;
907*77c1e3ccSAndroid Build Coastguard Worker } aom_codec_enc_cfg_t; /**< alias for struct aom_codec_enc_cfg */
908*77c1e3ccSAndroid Build Coastguard Worker 
909*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Initialize an encoder instance
910*77c1e3ccSAndroid Build Coastguard Worker  *
911*77c1e3ccSAndroid Build Coastguard Worker  * Initializes an encoder context using the given interface. Applications
912*77c1e3ccSAndroid Build Coastguard Worker  * should call the aom_codec_enc_init convenience macro instead of this
913*77c1e3ccSAndroid Build Coastguard Worker  * function directly, to ensure that the ABI version number parameter
914*77c1e3ccSAndroid Build Coastguard Worker  * is properly initialized.
915*77c1e3ccSAndroid Build Coastguard Worker  *
916*77c1e3ccSAndroid Build Coastguard Worker  * If the library was configured with -DCONFIG_MULTITHREAD=0, this call
917*77c1e3ccSAndroid Build Coastguard Worker  * is not thread safe and should be guarded with a lock if being used
918*77c1e3ccSAndroid Build Coastguard Worker  * in a multithreaded context.
919*77c1e3ccSAndroid Build Coastguard Worker  *
920*77c1e3ccSAndroid Build Coastguard Worker  * If aom_codec_enc_init_ver() fails, it is not necessary to call
921*77c1e3ccSAndroid Build Coastguard Worker  * aom_codec_destroy() on the encoder context.
922*77c1e3ccSAndroid Build Coastguard Worker  *
923*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ctx     Pointer to this instance's context.
924*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    iface   Pointer to the algorithm interface to use.
925*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    cfg     Configuration to use, if known.
926*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    flags   Bitfield of AOM_CODEC_USE_* flags
927*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ver     ABI version number. Must be set to
928*77c1e3ccSAndroid Build Coastguard Worker  *                       AOM_ENCODER_ABI_VERSION
929*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_OK
930*77c1e3ccSAndroid Build Coastguard Worker  *     The encoder algorithm has been initialized.
931*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_MEM_ERROR
932*77c1e3ccSAndroid Build Coastguard Worker  *     Memory allocation failed.
933*77c1e3ccSAndroid Build Coastguard Worker  */
934*77c1e3ccSAndroid Build Coastguard Worker aom_codec_err_t aom_codec_enc_init_ver(aom_codec_ctx_t *ctx,
935*77c1e3ccSAndroid Build Coastguard Worker                                        aom_codec_iface_t *iface,
936*77c1e3ccSAndroid Build Coastguard Worker                                        const aom_codec_enc_cfg_t *cfg,
937*77c1e3ccSAndroid Build Coastguard Worker                                        aom_codec_flags_t flags, int ver);
938*77c1e3ccSAndroid Build Coastguard Worker 
939*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Convenience macro for aom_codec_enc_init_ver()
940*77c1e3ccSAndroid Build Coastguard Worker  *
941*77c1e3ccSAndroid Build Coastguard Worker  * Ensures the ABI version parameter is properly set.
942*77c1e3ccSAndroid Build Coastguard Worker  */
943*77c1e3ccSAndroid Build Coastguard Worker #define aom_codec_enc_init(ctx, iface, cfg, flags) \
944*77c1e3ccSAndroid Build Coastguard Worker   aom_codec_enc_init_ver(ctx, iface, cfg, flags, AOM_ENCODER_ABI_VERSION)
945*77c1e3ccSAndroid Build Coastguard Worker 
946*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Get the default configuration for a usage.
947*77c1e3ccSAndroid Build Coastguard Worker  *
948*77c1e3ccSAndroid Build Coastguard Worker  * Initializes an encoder configuration structure with default values. Supports
949*77c1e3ccSAndroid Build Coastguard Worker  * the notion of "usages" so that an algorithm may offer different default
950*77c1e3ccSAndroid Build Coastguard Worker  * settings depending on the user's intended goal. This function \ref SHOULD
951*77c1e3ccSAndroid Build Coastguard Worker  * be called by all applications to initialize the configuration structure
952*77c1e3ccSAndroid Build Coastguard Worker  * before specializing the configuration with application specific values.
953*77c1e3ccSAndroid Build Coastguard Worker  *
954*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    iface     Pointer to the algorithm interface to use.
955*77c1e3ccSAndroid Build Coastguard Worker  * \param[out]   cfg       Configuration buffer to populate.
956*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    usage     Algorithm specific usage value. For AV1, must be
957*77c1e3ccSAndroid Build Coastguard Worker  *                         set to AOM_USAGE_GOOD_QUALITY (0),
958*77c1e3ccSAndroid Build Coastguard Worker  *                         AOM_USAGE_REALTIME (1), or AOM_USAGE_ALL_INTRA (2).
959*77c1e3ccSAndroid Build Coastguard Worker  *
960*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_OK
961*77c1e3ccSAndroid Build Coastguard Worker  *     The configuration was populated.
962*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_INCAPABLE
963*77c1e3ccSAndroid Build Coastguard Worker  *     Interface is not an encoder interface.
964*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_INVALID_PARAM
965*77c1e3ccSAndroid Build Coastguard Worker  *     A parameter was NULL, or the usage value was not recognized.
966*77c1e3ccSAndroid Build Coastguard Worker  */
967*77c1e3ccSAndroid Build Coastguard Worker aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface,
968*77c1e3ccSAndroid Build Coastguard Worker                                              aom_codec_enc_cfg_t *cfg,
969*77c1e3ccSAndroid Build Coastguard Worker                                              unsigned int usage);
970*77c1e3ccSAndroid Build Coastguard Worker 
971*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Set or change configuration
972*77c1e3ccSAndroid Build Coastguard Worker  *
973*77c1e3ccSAndroid Build Coastguard Worker  * Reconfigures an encoder instance according to the given configuration.
974*77c1e3ccSAndroid Build Coastguard Worker  *
975*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ctx     Pointer to this instance's context
976*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    cfg     Configuration buffer to use
977*77c1e3ccSAndroid Build Coastguard Worker  *
978*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_OK
979*77c1e3ccSAndroid Build Coastguard Worker  *     The configuration was populated.
980*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_INCAPABLE
981*77c1e3ccSAndroid Build Coastguard Worker  *     Interface is not an encoder interface.
982*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_INVALID_PARAM
983*77c1e3ccSAndroid Build Coastguard Worker  *     A parameter was NULL, or the usage value was not recognized.
984*77c1e3ccSAndroid Build Coastguard Worker  */
985*77c1e3ccSAndroid Build Coastguard Worker aom_codec_err_t aom_codec_enc_config_set(aom_codec_ctx_t *ctx,
986*77c1e3ccSAndroid Build Coastguard Worker                                          const aom_codec_enc_cfg_t *cfg);
987*77c1e3ccSAndroid Build Coastguard Worker 
988*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Get global stream headers
989*77c1e3ccSAndroid Build Coastguard Worker  *
990*77c1e3ccSAndroid Build Coastguard Worker  * Retrieves a stream level global header packet, if supported by the codec.
991*77c1e3ccSAndroid Build Coastguard Worker  * Calls to this function should be deferred until all configuration information
992*77c1e3ccSAndroid Build Coastguard Worker  * has been passed to libaom. Otherwise the global header data may be
993*77c1e3ccSAndroid Build Coastguard Worker  * invalidated by additional configuration changes.
994*77c1e3ccSAndroid Build Coastguard Worker  *
995*77c1e3ccSAndroid Build Coastguard Worker  * The AV1 implementation of this function returns an OBU. The OBU returned is
996*77c1e3ccSAndroid Build Coastguard Worker  * in Low Overhead Bitstream Format. Specifically, the obu_has_size_field bit is
997*77c1e3ccSAndroid Build Coastguard Worker  * set, and the buffer contains the obu_size field for the returned OBU.
998*77c1e3ccSAndroid Build Coastguard Worker  *
999*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ctx     Pointer to this instance's context
1000*77c1e3ccSAndroid Build Coastguard Worker  *
1001*77c1e3ccSAndroid Build Coastguard Worker  * \retval NULL
1002*77c1e3ccSAndroid Build Coastguard Worker  *     Encoder does not support global header, or an error occurred while
1003*77c1e3ccSAndroid Build Coastguard Worker  *     generating the global header.
1004*77c1e3ccSAndroid Build Coastguard Worker  *
1005*77c1e3ccSAndroid Build Coastguard Worker  * \retval Non-NULL
1006*77c1e3ccSAndroid Build Coastguard Worker  *     Pointer to buffer containing global header packet. The caller owns the
1007*77c1e3ccSAndroid Build Coastguard Worker  *     memory associated with this buffer, and must free the 'buf' member of the
1008*77c1e3ccSAndroid Build Coastguard Worker  *     aom_fixed_buf_t as well as the aom_fixed_buf_t pointer. Memory returned
1009*77c1e3ccSAndroid Build Coastguard Worker  *     must be freed via call to free().
1010*77c1e3ccSAndroid Build Coastguard Worker  */
1011*77c1e3ccSAndroid Build Coastguard Worker aom_fixed_buf_t *aom_codec_get_global_headers(aom_codec_ctx_t *ctx);
1012*77c1e3ccSAndroid Build Coastguard Worker 
1013*77c1e3ccSAndroid Build Coastguard Worker /*!\brief usage parameter analogous to AV1 GOOD QUALITY mode. */
1014*77c1e3ccSAndroid Build Coastguard Worker #define AOM_USAGE_GOOD_QUALITY 0u
1015*77c1e3ccSAndroid Build Coastguard Worker /*!\brief usage parameter analogous to AV1 REALTIME mode. */
1016*77c1e3ccSAndroid Build Coastguard Worker #define AOM_USAGE_REALTIME 1u
1017*77c1e3ccSAndroid Build Coastguard Worker /*!\brief usage parameter analogous to AV1 all intra mode. */
1018*77c1e3ccSAndroid Build Coastguard Worker #define AOM_USAGE_ALL_INTRA 2u
1019*77c1e3ccSAndroid Build Coastguard Worker 
1020*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Encode a frame
1021*77c1e3ccSAndroid Build Coastguard Worker  *
1022*77c1e3ccSAndroid Build Coastguard Worker  * Encodes a video frame at the given "presentation time." The presentation
1023*77c1e3ccSAndroid Build Coastguard Worker  * time stamp (PTS) \ref MUST be strictly increasing.
1024*77c1e3ccSAndroid Build Coastguard Worker  *
1025*77c1e3ccSAndroid Build Coastguard Worker  * When the last frame has been passed to the encoder, this function should
1026*77c1e3ccSAndroid Build Coastguard Worker  * continue to be called in a loop, with the img parameter set to NULL. This
1027*77c1e3ccSAndroid Build Coastguard Worker  * will signal the end-of-stream condition to the encoder and allow it to
1028*77c1e3ccSAndroid Build Coastguard Worker  * encode any held buffers. Encoding is complete when aom_codec_encode() is
1029*77c1e3ccSAndroid Build Coastguard Worker  * called with img set to NULL and aom_codec_get_cx_data() returns no data.
1030*77c1e3ccSAndroid Build Coastguard Worker  *
1031*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ctx       Pointer to this instance's context
1032*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    img       Image data to encode, NULL to flush.
1033*77c1e3ccSAndroid Build Coastguard Worker  *                         Encoding sample values outside the range
1034*77c1e3ccSAndroid Build Coastguard Worker  *                         [0..(1<<img->bit_depth)-1] is undefined behavior.
1035*77c1e3ccSAndroid Build Coastguard Worker  *                         Note: Although img is declared as a const pointer,
1036*77c1e3ccSAndroid Build Coastguard Worker  *                         if AV1E_SET_DENOISE_NOISE_LEVEL is set to a nonzero
1037*77c1e3ccSAndroid Build Coastguard Worker  *                         value aom_codec_encode() modifies (denoises) the
1038*77c1e3ccSAndroid Build Coastguard Worker  *                         samples in img->planes[i] .
1039*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    pts       Presentation time stamp, in timebase units. If img
1040*77c1e3ccSAndroid Build Coastguard Worker  *                         is NULL, pts is ignored.
1041*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    duration  Duration to show frame, in timebase units. If img
1042*77c1e3ccSAndroid Build Coastguard Worker  *                         is not NULL, duration must be nonzero. If img is
1043*77c1e3ccSAndroid Build Coastguard Worker  *                         NULL, duration is ignored.
1044*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    flags     Flags to use for encoding this frame.
1045*77c1e3ccSAndroid Build Coastguard Worker  *
1046*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_OK
1047*77c1e3ccSAndroid Build Coastguard Worker  *     The configuration was populated.
1048*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_INCAPABLE
1049*77c1e3ccSAndroid Build Coastguard Worker  *     Interface is not an encoder interface.
1050*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_INVALID_PARAM
1051*77c1e3ccSAndroid Build Coastguard Worker  *     A parameter was NULL, the image format is unsupported, etc.
1052*77c1e3ccSAndroid Build Coastguard Worker  *
1053*77c1e3ccSAndroid Build Coastguard Worker  * \note
1054*77c1e3ccSAndroid Build Coastguard Worker  * `duration` is of the unsigned long type, which can be 32 or 64 bits.
1055*77c1e3ccSAndroid Build Coastguard Worker  * `duration` must be less than or equal to UINT32_MAX so that its range is
1056*77c1e3ccSAndroid Build Coastguard Worker  * independent of the size of unsigned long.
1057*77c1e3ccSAndroid Build Coastguard Worker  */
1058*77c1e3ccSAndroid Build Coastguard Worker aom_codec_err_t aom_codec_encode(aom_codec_ctx_t *ctx, const aom_image_t *img,
1059*77c1e3ccSAndroid Build Coastguard Worker                                  aom_codec_pts_t pts, unsigned long duration,
1060*77c1e3ccSAndroid Build Coastguard Worker                                  aom_enc_frame_flags_t flags);
1061*77c1e3ccSAndroid Build Coastguard Worker 
1062*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Set compressed data output buffer
1063*77c1e3ccSAndroid Build Coastguard Worker  *
1064*77c1e3ccSAndroid Build Coastguard Worker  * Sets the buffer that the codec should output the compressed data
1065*77c1e3ccSAndroid Build Coastguard Worker  * into. This call effectively sets the buffer pointer returned in the
1066*77c1e3ccSAndroid Build Coastguard Worker  * next AOM_CODEC_CX_FRAME_PKT packet. Subsequent packets will be
1067*77c1e3ccSAndroid Build Coastguard Worker  * appended into this buffer. The buffer is preserved across frames,
1068*77c1e3ccSAndroid Build Coastguard Worker  * so applications must periodically call this function after flushing
1069*77c1e3ccSAndroid Build Coastguard Worker  * the accumulated compressed data to disk or to the network to reset
1070*77c1e3ccSAndroid Build Coastguard Worker  * the pointer to the buffer's head.
1071*77c1e3ccSAndroid Build Coastguard Worker  *
1072*77c1e3ccSAndroid Build Coastguard Worker  * `pad_before` bytes will be skipped before writing the compressed
1073*77c1e3ccSAndroid Build Coastguard Worker  * data, and `pad_after` bytes will be appended to the packet. The size
1074*77c1e3ccSAndroid Build Coastguard Worker  * of the packet will be the sum of the size of the actual compressed
1075*77c1e3ccSAndroid Build Coastguard Worker  * data, pad_before, and pad_after. The padding bytes will be preserved
1076*77c1e3ccSAndroid Build Coastguard Worker  * (not overwritten).
1077*77c1e3ccSAndroid Build Coastguard Worker  *
1078*77c1e3ccSAndroid Build Coastguard Worker  * Note that calling this function does not guarantee that the returned
1079*77c1e3ccSAndroid Build Coastguard Worker  * compressed data will be placed into the specified buffer. In the
1080*77c1e3ccSAndroid Build Coastguard Worker  * event that the encoded data will not fit into the buffer provided,
1081*77c1e3ccSAndroid Build Coastguard Worker  * the returned packet \ref MAY point to an internal buffer, as it would
1082*77c1e3ccSAndroid Build Coastguard Worker  * if this call were never used. In this event, the output packet will
1083*77c1e3ccSAndroid Build Coastguard Worker  * NOT have any padding, and the application must free space and copy it
1084*77c1e3ccSAndroid Build Coastguard Worker  * to the proper place. This is of particular note in configurations
1085*77c1e3ccSAndroid Build Coastguard Worker  * that may output multiple packets for a single encoded frame (e.g., lagged
1086*77c1e3ccSAndroid Build Coastguard Worker  * encoding) or if the application does not reset the buffer periodically.
1087*77c1e3ccSAndroid Build Coastguard Worker  *
1088*77c1e3ccSAndroid Build Coastguard Worker  * Applications may restore the default behavior of the codec providing
1089*77c1e3ccSAndroid Build Coastguard Worker  * the compressed data buffer by calling this function with a NULL
1090*77c1e3ccSAndroid Build Coastguard Worker  * buffer.
1091*77c1e3ccSAndroid Build Coastguard Worker  *
1092*77c1e3ccSAndroid Build Coastguard Worker  * Applications \ref MUSTNOT call this function during iteration of
1093*77c1e3ccSAndroid Build Coastguard Worker  * aom_codec_get_cx_data().
1094*77c1e3ccSAndroid Build Coastguard Worker  *
1095*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    ctx         Pointer to this instance's context
1096*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    buf         Buffer to store compressed data into
1097*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    pad_before  Bytes to skip before writing compressed data
1098*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]    pad_after   Bytes to skip after writing compressed data
1099*77c1e3ccSAndroid Build Coastguard Worker  *
1100*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_OK
1101*77c1e3ccSAndroid Build Coastguard Worker  *     The buffer was set successfully.
1102*77c1e3ccSAndroid Build Coastguard Worker  * \retval #AOM_CODEC_INVALID_PARAM
1103*77c1e3ccSAndroid Build Coastguard Worker  *     A parameter was NULL, the image format is unsupported, etc.
1104*77c1e3ccSAndroid Build Coastguard Worker  */
1105*77c1e3ccSAndroid Build Coastguard Worker aom_codec_err_t aom_codec_set_cx_data_buf(aom_codec_ctx_t *ctx,
1106*77c1e3ccSAndroid Build Coastguard Worker                                           const aom_fixed_buf_t *buf,
1107*77c1e3ccSAndroid Build Coastguard Worker                                           unsigned int pad_before,
1108*77c1e3ccSAndroid Build Coastguard Worker                                           unsigned int pad_after);
1109*77c1e3ccSAndroid Build Coastguard Worker 
1110*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Encoded data iterator
1111*77c1e3ccSAndroid Build Coastguard Worker  *
1112*77c1e3ccSAndroid Build Coastguard Worker  * Iterates over a list of data packets to be passed from the encoder to the
1113*77c1e3ccSAndroid Build Coastguard Worker  * application. The different kinds of packets available are enumerated in
1114*77c1e3ccSAndroid Build Coastguard Worker  * #aom_codec_cx_pkt_kind.
1115*77c1e3ccSAndroid Build Coastguard Worker  *
1116*77c1e3ccSAndroid Build Coastguard Worker  * #AOM_CODEC_CX_FRAME_PKT packets should be passed to the application's
1117*77c1e3ccSAndroid Build Coastguard Worker  * muxer. Multiple compressed frames may be in the list.
1118*77c1e3ccSAndroid Build Coastguard Worker  * #AOM_CODEC_STATS_PKT packets should be appended to a global buffer.
1119*77c1e3ccSAndroid Build Coastguard Worker  *
1120*77c1e3ccSAndroid Build Coastguard Worker  * The application \ref MUST silently ignore any packet kinds that it does
1121*77c1e3ccSAndroid Build Coastguard Worker  * not recognize or support.
1122*77c1e3ccSAndroid Build Coastguard Worker  *
1123*77c1e3ccSAndroid Build Coastguard Worker  * The data buffers returned from this function are only guaranteed to be
1124*77c1e3ccSAndroid Build Coastguard Worker  * valid until the application makes another call to any aom_codec_* function.
1125*77c1e3ccSAndroid Build Coastguard Worker  *
1126*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]     ctx      Pointer to this instance's context
1127*77c1e3ccSAndroid Build Coastguard Worker  * \param[in,out] iter     Iterator storage, initialized to NULL
1128*77c1e3ccSAndroid Build Coastguard Worker  *
1129*77c1e3ccSAndroid Build Coastguard Worker  * \return Returns a pointer to an output data packet (compressed frame data,
1130*77c1e3ccSAndroid Build Coastguard Worker  *         two-pass statistics, etc.) or NULL to signal end-of-list.
1131*77c1e3ccSAndroid Build Coastguard Worker  *
1132*77c1e3ccSAndroid Build Coastguard Worker  */
1133*77c1e3ccSAndroid Build Coastguard Worker const aom_codec_cx_pkt_t *aom_codec_get_cx_data(aom_codec_ctx_t *ctx,
1134*77c1e3ccSAndroid Build Coastguard Worker                                                 aom_codec_iter_t *iter);
1135*77c1e3ccSAndroid Build Coastguard Worker 
1136*77c1e3ccSAndroid Build Coastguard Worker /*!\brief Get Preview Frame
1137*77c1e3ccSAndroid Build Coastguard Worker  *
1138*77c1e3ccSAndroid Build Coastguard Worker  * Returns an image that can be used as a preview. Shows the image as it would
1139*77c1e3ccSAndroid Build Coastguard Worker  * exist at the decompressor. The application \ref MUST NOT write into this
1140*77c1e3ccSAndroid Build Coastguard Worker  * image buffer.
1141*77c1e3ccSAndroid Build Coastguard Worker  *
1142*77c1e3ccSAndroid Build Coastguard Worker  * \param[in]     ctx      Pointer to this instance's context
1143*77c1e3ccSAndroid Build Coastguard Worker  *
1144*77c1e3ccSAndroid Build Coastguard Worker  * \return Returns a pointer to a preview image, or NULL if no image is
1145*77c1e3ccSAndroid Build Coastguard Worker  *         available.
1146*77c1e3ccSAndroid Build Coastguard Worker  *
1147*77c1e3ccSAndroid Build Coastguard Worker  */
1148*77c1e3ccSAndroid Build Coastguard Worker const aom_image_t *aom_codec_get_preview_frame(aom_codec_ctx_t *ctx);
1149*77c1e3ccSAndroid Build Coastguard Worker 
1150*77c1e3ccSAndroid Build Coastguard Worker /*!@} - end defgroup encoder*/
1151*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus
1152*77c1e3ccSAndroid Build Coastguard Worker }
1153*77c1e3ccSAndroid Build Coastguard Worker #endif
1154*77c1e3ccSAndroid Build Coastguard Worker #endif  // AOM_AOM_AOM_ENCODER_H_
1155