aom_encoder.h 32.6 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
/*
Yaowu Xu's avatar
Yaowu Xu committed
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
John Koleszar's avatar
John Koleszar committed
3
 *
Yaowu Xu's avatar
Yaowu Xu committed
4
5
6
7
8
9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
John Koleszar's avatar
John Koleszar committed
10
 */
Yaowu Xu's avatar
Yaowu Xu committed
11
12
#ifndef AOM_AOM_ENCODER_H_
#define AOM_AOM_ENCODER_H_
John Koleszar's avatar
John Koleszar committed
13
14
15
16
17
18
19
20
21

/*!\defgroup encoder Encoder Algorithm Interface
 * \ingroup codec
 * This abstraction allows applications using this encoder to easily support
 * multiple video formats with minimal code duplication. This section describes
 * the interface common to all encoders.
 * @{
 */

James Zern's avatar
James Zern committed
22
/*!\file
John Koleszar's avatar
John Koleszar committed
23
24
25
26
27
28
29
30
31
32
 * \brief Describes the encoder algorithm interface to applications.
 *
 * This file describes the interface between an application and a
 * video encoder algorithm.
 *
 */
#ifdef __cplusplus
extern "C" {
#endif

Yaowu Xu's avatar
Yaowu Xu committed
33
#include "./aom_codec.h"
John Koleszar's avatar
John Koleszar committed
34

clang-format's avatar
clang-format committed
35
36
37
38
39
40
41
42
/*!\brief Current ABI version number
 *
 * \internal
 * If this file is altered in any way that changes the ABI, this value
 * must be bumped.  Examples include, but are not limited to, changing
 * types, removing or reassigning enums, adding/removing/rearranging
 * fields to structures
 */
Yaowu Xu's avatar
Yaowu Xu committed
43
44
#define AOM_ENCODER_ABI_VERSION \
  (5 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
John Koleszar's avatar
John Koleszar committed
45

clang-format's avatar
clang-format committed
46
47
48
/*! \brief Encoder capabilities bitfield
 *
 *  Each encoder advertises the capabilities it supports as part of its
Yaowu Xu's avatar
Yaowu Xu committed
49
 *  ::aom_codec_iface_t interface structure. Capabilities are extra
clang-format's avatar
clang-format committed
50
51
52
 *  interfaces or functionality, and are not required to be supported
 *  by an encoder.
 *
Yaowu Xu's avatar
Yaowu Xu committed
53
 *  The available flags are specified by AOM_CODEC_CAP_* defines.
clang-format's avatar
clang-format committed
54
 */
Yaowu Xu's avatar
Yaowu Xu committed
55
#define AOM_CODEC_CAP_PSNR 0x10000 /**< Can issue PSNR packets */
John Koleszar's avatar
John Koleszar committed
56

clang-format's avatar
clang-format committed
57
/*! Can output one partition at a time. Each partition is returned in its
Yaowu Xu's avatar
Yaowu Xu committed
58
 *  own AOM_CODEC_CX_FRAME_PKT, with the FRAME_IS_FRAGMENT flag set for
clang-format's avatar
clang-format committed
59
60
61
 *  every partition but the last. In this mode all frames are always
 *  returned partition by partition.
 */
Yaowu Xu's avatar
Yaowu Xu committed
62
#define AOM_CODEC_CAP_OUTPUT_PARTITION 0x20000
63

64
65
/*! Can support input images at greater than 8 bitdepth.
 */
Yaowu Xu's avatar
Yaowu Xu committed
66
#define AOM_CODEC_CAP_HIGHBITDEPTH 0x40000
John Koleszar's avatar
John Koleszar committed
67

clang-format's avatar
clang-format committed
68
69
70
71
72
/*! \brief Initialization-time Feature Enabling
 *
 *  Certain codec features must be known at initialization time, to allow
 *  for proper memory allocation.
 *
Yaowu Xu's avatar
Yaowu Xu committed
73
 *  The available flags are specified by AOM_CODEC_USE_* defines.
clang-format's avatar
clang-format committed
74
 */
Yaowu Xu's avatar
Yaowu Xu committed
75
#define AOM_CODEC_USE_PSNR 0x10000 /**< Calculate PSNR on each frame */
clang-format's avatar
clang-format committed
76
/*!\brief Make the encoder output one  partition at a time. */
Yaowu Xu's avatar
Yaowu Xu committed
77
78
#define AOM_CODEC_USE_OUTPUT_PARTITION 0x20000
#define AOM_CODEC_USE_HIGHBITDEPTH 0x40000 /**< Use high bitdepth */
John Koleszar's avatar
John Koleszar committed
79

clang-format's avatar
clang-format committed
80
81
82
83
/*!\brief Generic fixed size buffer structure
 *
 * This structure is able to hold a reference to any fixed size buffer.
 */
Yaowu Xu's avatar
Yaowu Xu committed
84
typedef struct aom_fixed_buf {
clang-format's avatar
clang-format committed
85
86
  void *buf;       /**< Pointer to the data */
  size_t sz;       /**< Length of the buffer, in chars */
Yaowu Xu's avatar
Yaowu Xu committed
87
} aom_fixed_buf_t; /**< alias for struct aom_fixed_buf */
John Koleszar's avatar
John Koleszar committed
88

clang-format's avatar
clang-format committed
89
90
91
92
93
/*!\brief Time Stamp Type
 *
 * An integer, which when multiplied by the stream's time base, provides
 * the absolute time of a sample.
 */
Yaowu Xu's avatar
Yaowu Xu committed
94
typedef int64_t aom_codec_pts_t;
John Koleszar's avatar
John Koleszar committed
95

clang-format's avatar
clang-format committed
96
97
98
99
100
101
102
/*!\brief Compressed Frame Flags
 *
 * This type represents a bitfield containing information about a compressed
 * frame that may be useful to an application. The most significant 16 bits
 * can be used by an algorithm to provide additional detail, for example to
 * support frame types that are codec specific (MPEG-1 D-frames for example)
 */
Yaowu Xu's avatar
Yaowu Xu committed
103
104
typedef uint32_t aom_codec_frame_flags_t;
#define AOM_FRAME_IS_KEY 0x1 /**< frame is the start of a GOP */
clang-format's avatar
clang-format committed
105
106
/*!\brief frame can be dropped without affecting the stream (no future frame
 * depends on this one) */
Yaowu Xu's avatar
Yaowu Xu committed
107
#define AOM_FRAME_IS_DROPPABLE 0x2
clang-format's avatar
clang-format committed
108
/*!\brief frame should be decoded but will not be shown */
Yaowu Xu's avatar
Yaowu Xu committed
109
#define AOM_FRAME_IS_INVISIBLE 0x4
clang-format's avatar
clang-format committed
110
/*!\brief this is a fragment of the encoded frame */
Yaowu Xu's avatar
Yaowu Xu committed
111
#define AOM_FRAME_IS_FRAGMENT 0x8
clang-format's avatar
clang-format committed
112
113
114
115
116

/*!\brief Error Resilient flags
 *
 * These flags define which error resilient features to enable in the
 * encoder. The flags are specified through the
Yaowu Xu's avatar
Yaowu Xu committed
117
 * aom_codec_enc_cfg::g_error_resilient variable.
clang-format's avatar
clang-format committed
118
 */
Yaowu Xu's avatar
Yaowu Xu committed
119
typedef uint32_t aom_codec_er_flags_t;
clang-format's avatar
clang-format committed
120
/*!\brief Improve resiliency against losses of whole frames */
Yaowu Xu's avatar
Yaowu Xu committed
121
#define AOM_ERROR_RESILIENT_DEFAULT 0x1
clang-format's avatar
clang-format committed
122
123
124
125
/*!\brief The frame partitions are independently decodable by the bool decoder,
 * meaning that partitions can be decoded even though earlier partitions have
 * been lost. Note that intra prediction is still done over the partition
 * boundary. */
Yaowu Xu's avatar
Yaowu Xu committed
126
#define AOM_ERROR_RESILIENT_PARTITIONS 0x2
clang-format's avatar
clang-format committed
127
128
129
130

/*!\brief Encoder output packet variants
 *
 * This enumeration lists the different kinds of data packets that can be
Yaowu Xu's avatar
Yaowu Xu committed
131
 * returned by calls to aom_codec_get_cx_data(). Algorithms \ref MAY
clang-format's avatar
clang-format committed
132
133
 * extend this list to provide additional functionality.
 */
Yaowu Xu's avatar
Yaowu Xu committed
134
135
136
137
138
139
enum aom_codec_cx_pkt_kind {
  AOM_CODEC_CX_FRAME_PKT,    /**< Compressed video frame */
  AOM_CODEC_STATS_PKT,       /**< Two-pass statistics for this frame */
  AOM_CODEC_FPMB_STATS_PKT,  /**< first pass mb statistics for this frame */
  AOM_CODEC_PSNR_PKT,        /**< PSNR statistics for this frame */
  AOM_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions  */
clang-format's avatar
clang-format committed
140
141
142
143
144
145
146
};

/*!\brief Encoder output packet
 *
 * This structure contains the different kinds of output data the encoder
 * may produce while compressing a frame.
 */
Yaowu Xu's avatar
Yaowu Xu committed
147
148
typedef struct aom_codec_cx_pkt {
  enum aom_codec_cx_pkt_kind kind; /**< packet variant */
clang-format's avatar
clang-format committed
149
150
151
152
153
  union {
    struct {
      void *buf; /**< compressed data buffer */
      size_t sz; /**< length of compressed data */
      /*!\brief time stamp to show frame (in timebase units) */
Yaowu Xu's avatar
Yaowu Xu committed
154
      aom_codec_pts_t pts;
clang-format's avatar
clang-format committed
155
156
      /*!\brief duration to show frame (in timebase units) */
      unsigned long duration;
Yaowu Xu's avatar
Yaowu Xu committed
157
      aom_codec_frame_flags_t flags; /**< flags for this frame */
clang-format's avatar
clang-format committed
158
159
160
161
162
      /*!\brief the partition id defines the decoding order of the partitions.
       * Only applicable when "output partition" mode is enabled. First
       * partition has id 0.*/
      int partition_id;
    } frame;                            /**< data for compressed frame packet */
Yaowu Xu's avatar
Yaowu Xu committed
163
164
165
    aom_fixed_buf_t twopass_stats;      /**< data for two-pass packet */
    aom_fixed_buf_t firstpass_mb_stats; /**< first pass mb packet */
    struct aom_psnr_pkt {
clang-format's avatar
clang-format committed
166
167
168
169
      unsigned int samples[4]; /**< Number of samples, total/y/u/v */
      uint64_t sse[4];         /**< sum squared error, total/y/u/v */
      double psnr[4];          /**< PSNR, total/y/u/v */
    } psnr;                    /**< data for PSNR packet */
Yaowu Xu's avatar
Yaowu Xu committed
170
    aom_fixed_buf_t raw;       /**< data for arbitrary packets */
clang-format's avatar
clang-format committed
171
172
173
174
175
176

    /* This packet size is fixed to allow codecs to extend this
     * interface without having to manage storage for raw packets,
     * i.e., if it's smaller than 128 bytes, you can store in the
     * packet list directly.
     */
Yaowu Xu's avatar
Yaowu Xu committed
177
    char pad[128 - sizeof(enum aom_codec_cx_pkt_kind)]; /**< fixed sz */
clang-format's avatar
clang-format committed
178
  } data;                                               /**< packet data */
Yaowu Xu's avatar
Yaowu Xu committed
179
} aom_codec_cx_pkt_t; /**< alias for struct aom_codec_cx_pkt */
clang-format's avatar
clang-format committed
180
181
182
183
184

/*!\brief Rational Number
 *
 * This structure holds a fractional value.
 */
Yaowu Xu's avatar
Yaowu Xu committed
185
typedef struct aom_rational {
clang-format's avatar
clang-format committed
186
187
  int num;        /**< fraction numerator */
  int den;        /**< fraction denominator */
Yaowu Xu's avatar
Yaowu Xu committed
188
} aom_rational_t; /**< alias for struct aom_rational */
clang-format's avatar
clang-format committed
189
190

/*!\brief Multi-pass Encoding Pass */
Yaowu Xu's avatar
Yaowu Xu committed
191
192
193
194
enum aom_enc_pass {
  AOM_RC_ONE_PASS,   /**< Single pass mode */
  AOM_RC_FIRST_PASS, /**< First pass of multi-pass mode */
  AOM_RC_LAST_PASS   /**< Final pass of multi-pass mode */
clang-format's avatar
clang-format committed
195
196
197
};

/*!\brief Rate control mode */
Yaowu Xu's avatar
Yaowu Xu committed
198
199
200
201
202
enum aom_rc_mode {
  AOM_VBR, /**< Variable Bit Rate (VBR) mode */
  AOM_CBR, /**< Constant Bit Rate (CBR) mode */
  AOM_CQ,  /**< Constrained Quality (CQ)  mode */
  AOM_Q,   /**< Constant Quality (Q) mode */
clang-format's avatar
clang-format committed
203
204
205
206
207
208
};

/*!\brief Keyframe placement mode.
 *
 * This enumeration determines whether keyframes are placed automatically by
 * the encoder or whether this behavior is disabled. Older releases of this
Yaowu Xu's avatar
Yaowu Xu committed
209
 * SDK were implemented such that AOM_KF_FIXED meant keyframes were disabled.
clang-format's avatar
clang-format committed
210
 * This name is confusing for this behavior, so the new symbols to be used
Yaowu Xu's avatar
Yaowu Xu committed
211
 * are AOM_KF_AUTO and AOM_KF_DISABLED.
clang-format's avatar
clang-format committed
212
 */
Yaowu Xu's avatar
Yaowu Xu committed
213
214
215
216
enum aom_kf_mode {
  AOM_KF_FIXED,       /**< deprecated, implies AOM_KF_DISABLED */
  AOM_KF_AUTO,        /**< Encoder determines optimal placement automatically */
  AOM_KF_DISABLED = 0 /**< Encoder does not place keyframes. */
clang-format's avatar
clang-format committed
217
};
John Koleszar's avatar
John Koleszar committed
218

clang-format's avatar
clang-format committed
219
220
/*!\brief Encoded Frame Flags
 *
Yaowu Xu's avatar
Yaowu Xu committed
221
 * This type indicates a bitfield to be passed to aom_codec_encode(), defining
clang-format's avatar
clang-format committed
222
 * per-frame boolean values. By convention, bits common to all codecs will be
Yaowu Xu's avatar
Yaowu Xu committed
223
 * named AOM_EFLAG_*, and bits specific to an algorithm will be named
clang-format's avatar
clang-format committed
224
225
 * /algo/_eflag_*. The lower order 16 bits are reserved for common use.
 */
Yaowu Xu's avatar
Yaowu Xu committed
226
227
typedef long aom_enc_frame_flags_t;
#define AOM_EFLAG_FORCE_KF (1 << 0) /**< Force this frame to be a keyframe */
John Koleszar's avatar
John Koleszar committed
228

clang-format's avatar
clang-format committed
229
230
231
232
233
234
/*!\brief Encoder configuration structure
 *
 * This structure contains the encoder settings that have common representations
 * across all codecs. This doesn't imply that all codecs support all features,
 * however.
 */
Yaowu Xu's avatar
Yaowu Xu committed
235
typedef struct aom_codec_enc_cfg {
clang-format's avatar
clang-format committed
236
237
238
  /*
   * generic settings (g)
   */
John Koleszar's avatar
John Koleszar committed
239

clang-format's avatar
clang-format committed
240
241
242
243
244
245
246
247
  /*!\brief Algorithm specific "usage" value
   *
   * Algorithms may define multiple values for usage, which may convey the
   * intent of how the application intends to use the stream. If this value
   * is non-zero, consult the documentation for the codec to determine its
   * meaning.
   */
  unsigned int g_usage;
John Koleszar's avatar
John Koleszar committed
248

clang-format's avatar
clang-format committed
249
250
251
252
253
254
255
  /*!\brief Maximum number of threads to use
   *
   * For multi-threaded implementations, use no more than this number of
   * threads. The codec may use fewer threads than allowed. The value
   * 0 is equivalent to the value 1.
   */
  unsigned int g_threads;
John Koleszar's avatar
John Koleszar committed
256

clang-format's avatar
clang-format committed
257
258
259
260
261
262
263
264
265
  /*!\brief Bitstream profile to use
   *
   * Some codecs support a notion of multiple bitstream profiles. Typically
   * this maps to a set of features that are turned on or off. Often the
   * profile to use is determined by the features of the intended decoder.
   * Consult the documentation for the codec to determine the valid values
   * for this parameter, or set to zero for a sane default.
   */
  unsigned int g_profile; /**< profile of bitstream to use */
John Koleszar's avatar
John Koleszar committed
266

clang-format's avatar
clang-format committed
267
268
269
270
271
272
273
274
  /*!\brief Width of the frame
   *
   * This value identifies the presentation resolution of the frame,
   * in pixels. Note that the frames passed as input to the encoder must
   * have this resolution. Frames will be presented by the decoder in this
   * resolution, independent of any spatial resampling the encoder may do.
   */
  unsigned int g_w;
John Koleszar's avatar
John Koleszar committed
275

clang-format's avatar
clang-format committed
276
277
278
279
280
281
282
283
  /*!\brief Height of the frame
   *
   * This value identifies the presentation resolution of the frame,
   * in pixels. Note that the frames passed as input to the encoder must
   * have this resolution. Frames will be presented by the decoder in this
   * resolution, independent of any spatial resampling the encoder may do.
   */
  unsigned int g_h;
John Koleszar's avatar
John Koleszar committed
284

clang-format's avatar
clang-format committed
285
286
287
288
  /*!\brief Bit-depth of the codec
   *
   * This value identifies the bit_depth of the codec,
   * Only certain bit-depths are supported as identified in the
Yaowu Xu's avatar
Yaowu Xu committed
289
   * aom_bit_depth_t enum.
clang-format's avatar
clang-format committed
290
   */
Yaowu Xu's avatar
Yaowu Xu committed
291
  aom_bit_depth_t g_bit_depth;
John Koleszar's avatar
John Koleszar committed
292

clang-format's avatar
clang-format committed
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
  /*!\brief Bit-depth of the input frames
   *
   * This value identifies the bit_depth of the input frames in bits.
   * Note that the frames passed as input to the encoder must have
   * this bit-depth.
   */
  unsigned int g_input_bit_depth;

  /*!\brief Stream timebase units
   *
   * Indicates the smallest interval of time, in seconds, used by the stream.
   * For fixed frame rate material, or variable frame rate material where
   * frames are timed at a multiple of a given clock (ex: video capture),
   * the \ref RECOMMENDED method is to set the timebase to the reciprocal
   * of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the
   * pts to correspond to the frame number, which can be handy. For
   * re-encoding video from containers with absolute time timestamps, the
   * \ref RECOMMENDED method is to set the timebase to that of the parent
   * container or multimedia framework (ex: 1/1000 for ms, as in FLV).
   */
Yaowu Xu's avatar
Yaowu Xu committed
313
  struct aom_rational g_timebase;
John Koleszar's avatar
John Koleszar committed
314

clang-format's avatar
clang-format committed
315
316
317
318
319
320
  /*!\brief Enable error resilient modes.
   *
   * The error resilient bitfield indicates to the encoder which features
   * it should enable to take measures for streaming over lossy or noisy
   * links.
   */
Yaowu Xu's avatar
Yaowu Xu committed
321
  aom_codec_er_flags_t g_error_resilient;
John Koleszar's avatar
John Koleszar committed
322

clang-format's avatar
clang-format committed
323
324
325
  /*!\brief Multi-pass Encoding Mode
   *
   * This value should be set to the current phase for multi-pass encoding.
Yaowu Xu's avatar
Yaowu Xu committed
326
   * For single pass, set to #AOM_RC_ONE_PASS.
clang-format's avatar
clang-format committed
327
   */
Yaowu Xu's avatar
Yaowu Xu committed
328
  enum aom_enc_pass g_pass;
John Koleszar's avatar
John Koleszar committed
329

clang-format's avatar
clang-format committed
330
331
332
333
334
335
336
337
338
339
340
341
342
  /*!\brief Allow lagged encoding
   *
   * If set, this value allows the encoder to consume a number of input
   * frames before producing output frames. This allows the encoder to
   * base decisions for the current frame on future frames. This does
   * increase the latency of the encoding pipeline, so it is not appropriate
   * in all situations (ex: realtime encoding).
   *
   * Note that this is a maximum value -- the encoder may produce frames
   * sooner than the given limit. Set this value to 0 to disable this
   * feature.
   */
  unsigned int g_lag_in_frames;
John Koleszar's avatar
John Koleszar committed
343

clang-format's avatar
clang-format committed
344
345
346
  /*
   * rate control settings (rc)
   */
John Koleszar's avatar
John Koleszar committed
347

clang-format's avatar
clang-format committed
348
  /*!\brief Temporal resampling configuration, if supported by the codec.
John Koleszar's avatar
John Koleszar committed
349
   *
clang-format's avatar
clang-format committed
350
351
352
353
354
   * Temporal resampling allows the codec to "drop" frames as a strategy to
   * meet its target data rate. This can cause temporal discontinuities in
   * the encoded video, which may appear as stuttering during playback. This
   * trade-off is often acceptable, but for many applications is not. It can
   * be disabled in these cases.
John Koleszar's avatar
John Koleszar committed
355
   *
Yaowu Xu's avatar
Yaowu Xu committed
356
   * Note that not all codecs support this feature. All aom AVx codecs do.
clang-format's avatar
clang-format committed
357
   * For other codecs, consult the documentation for that algorithm.
John Koleszar's avatar
John Koleszar committed
358
   *
clang-format's avatar
clang-format committed
359
360
361
362
   * This threshold is described as a percentage of the target data buffer.
   * When the data buffer falls below this percentage of fullness, a
   * dropped frame is indicated. Set the threshold to zero (0) to disable
   * this feature.
John Koleszar's avatar
John Koleszar committed
363
   */
clang-format's avatar
clang-format committed
364
  unsigned int rc_dropframe_thresh;
John Koleszar's avatar
John Koleszar committed
365

366
  /*!\brief Mode for spatial resampling, if supported by the codec.
John Koleszar's avatar
John Koleszar committed
367
   *
clang-format's avatar
clang-format committed
368
   * Spatial resampling allows the codec to compress a lower resolution
369
   * version of the frame, which is then upscaled by the decoder to the
clang-format's avatar
clang-format committed
370
371
   * correct presentation resolution. This increases visual quality at
   * low data rates, at the expense of CPU time on the encoder/decoder.
John Koleszar's avatar
John Koleszar committed
372
   */
373
  unsigned int rc_resize_mode;
John Koleszar's avatar
John Koleszar committed
374

375
  /*!\brief Frame resize numerator.
John Koleszar's avatar
John Koleszar committed
376
   *
377
   * The numerator for resize to use, assuming 16 as the denominator.
John Koleszar's avatar
John Koleszar committed
378
   *
379
   * Valid numerators are  8 - 16 for now.
clang-format's avatar
clang-format committed
380
   */
381
  unsigned int rc_resize_numerator;
clang-format's avatar
clang-format committed
382

383
384
385
386
387
388
389
390
  /*!\brief Keyframe resize numerator.
   *
   * The numerator for resize to use, assuming 16 as the denominator.
   *
   * Valid numerators are  8 - 16 for now.
   */
  unsigned int rc_resize_kf_numerator;

391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
  /*!\brief Frame super-resolution scaling mode.
   *
   * Similar to spatial resampling, frame super-resolution integrates
   * upscaling after the encode/decode process. Taking control of upscaling and
   * using restoration filters should allow it to outperform normal resizing.
   *
   * Mode 0 is SUPERRES_NONE, mode 1 is SUPERRES_FIXED, and mode 2 is
   * SUPERRES_DYNAMIC.
   */
  unsigned int rc_superres_mode;

  /*!\brief Frame super-resolution numerator.
   *
   * The numerator for superres to use. If fixed it will only change if the
   * cumulative scale change over resizing and superres is greater than 1/2;
   * this forces superres to reduce scaling.
   *
   * Valid numerators are 8 to 16.
   *
   * Ignored by SUPERRES_DYNAMIC.
   */
  unsigned int rc_superres_numerator;

414
415
416
417
418
419
420
421
422
423
  /*!\brief Keyframe super-resolution numerator.
   *
   * The numerator for superres to use. If fixed it will only change if the
   * cumulative scale change over resizing and superres is greater than 1/2;
   * this forces superres to reduce scaling.
   *
   * Valid numerators are 8 - 16 for now.
   */
  unsigned int rc_superres_kf_numerator;

clang-format's avatar
clang-format committed
424
  /*!\brief Rate control algorithm to use.
John Koleszar's avatar
John Koleszar committed
425
   *
clang-format's avatar
clang-format committed
426
427
428
429
430
431
   * Indicates whether the end usage of this stream is to be streamed over
   * a bandwidth constrained link, indicating that Constant Bit Rate (CBR)
   * mode should be used, or whether it will be played back on a high
   * bandwidth link, as from a local disk, where higher variations in
   * bitrate are acceptable.
   */
Yaowu Xu's avatar
Yaowu Xu committed
432
  enum aom_rc_mode rc_end_usage;
clang-format's avatar
clang-format committed
433
434

  /*!\brief Two-pass stats buffer.
John Koleszar's avatar
John Koleszar committed
435
   *
clang-format's avatar
clang-format committed
436
437
438
   * A buffer containing all of the stats packets produced in the first
   * pass, concatenated.
   */
Yaowu Xu's avatar
Yaowu Xu committed
439
  aom_fixed_buf_t rc_twopass_stats_in;
clang-format's avatar
clang-format committed
440
441

  /*!\brief first pass mb stats buffer.
John Koleszar's avatar
John Koleszar committed
442
   *
clang-format's avatar
clang-format committed
443
444
   * A buffer containing all of the first pass mb stats packets produced
   * in the first pass, concatenated.
John Koleszar's avatar
John Koleszar committed
445
   */
Yaowu Xu's avatar
Yaowu Xu committed
446
  aom_fixed_buf_t rc_firstpass_mb_stats_in;
John Koleszar's avatar
John Koleszar committed
447

clang-format's avatar
clang-format committed
448
  /*!\brief Target data rate
John Koleszar's avatar
John Koleszar committed
449
   *
clang-format's avatar
clang-format committed
450
451
452
453
454
455
456
457
458
   * Target bandwidth to use for this stream, in kilobits per second.
   */
  unsigned int rc_target_bitrate;

  /*
   * quantizer settings
   */

  /*!\brief Minimum (Best Quality) Quantizer
John Koleszar's avatar
John Koleszar committed
459
   *
clang-format's avatar
clang-format committed
460
461
462
463
   * The quantizer is the most direct control over the quality of the
   * encoded image. The range of valid values for the quantizer is codec
   * specific. Consult the documentation for the codec to determine the
   * values to use. To determine the range programmatically, call
Yaowu Xu's avatar
Yaowu Xu committed
464
   * aom_codec_enc_config_default() with a usage value of 0.
clang-format's avatar
clang-format committed
465
466
467
468
   */
  unsigned int rc_min_quantizer;

  /*!\brief Maximum (Worst Quality) Quantizer
John Koleszar's avatar
John Koleszar committed
469
   *
clang-format's avatar
clang-format committed
470
471
472
473
   * The quantizer is the most direct control over the quality of the
   * encoded image. The range of valid values for the quantizer is codec
   * specific. Consult the documentation for the codec to determine the
   * values to use. To determine the range programmatically, call
Yaowu Xu's avatar
Yaowu Xu committed
474
   * aom_codec_enc_config_default() with a usage value of 0.
clang-format's avatar
clang-format committed
475
476
477
478
479
480
481
482
   */
  unsigned int rc_max_quantizer;

  /*
   * bitrate tolerance
   */

  /*!\brief Rate control adaptation undershoot control
John Koleszar's avatar
John Koleszar committed
483
   *
clang-format's avatar
clang-format committed
484
485
486
487
488
   * This value, expressed as a percentage of the target bitrate,
   * controls the maximum allowed adaptation speed of the codec.
   * This factor controls the maximum amount of bits that can
   * be subtracted from the target bitrate in order to compensate
   * for prior overshoot.
John Koleszar's avatar
John Koleszar committed
489
   *
clang-format's avatar
clang-format committed
490
491
492
493
494
   * Valid values in the range 0-1000.
   */
  unsigned int rc_undershoot_pct;

  /*!\brief Rate control adaptation overshoot control
John Koleszar's avatar
John Koleszar committed
495
   *
clang-format's avatar
clang-format committed
496
497
498
499
500
   * This value, expressed as a percentage of the target bitrate,
   * controls the maximum allowed adaptation speed of the codec.
   * This factor controls the maximum amount of bits that can
   * be added to the target bitrate in order to compensate for
   * prior undershoot.
John Koleszar's avatar
John Koleszar committed
501
   *
clang-format's avatar
clang-format committed
502
   * Valid values in the range 0-1000.
John Koleszar's avatar
John Koleszar committed
503
   */
clang-format's avatar
clang-format committed
504
  unsigned int rc_overshoot_pct;
John Koleszar's avatar
John Koleszar committed
505

clang-format's avatar
clang-format committed
506
507
508
  /*
   * decoder buffer model parameters
   */
John Koleszar's avatar
John Koleszar committed
509

clang-format's avatar
clang-format committed
510
  /*!\brief Decoder Buffer Size
John Koleszar's avatar
John Koleszar committed
511
   *
clang-format's avatar
clang-format committed
512
513
514
515
516
517
518
519
520
521
   * This value indicates the amount of data that may be buffered by the
   * decoding application. Note that this value is expressed in units of
   * time (milliseconds). For example, a value of 5000 indicates that the
   * client will buffer (at least) 5000ms worth of encoded data. Use the
   * target bitrate (#rc_target_bitrate) to convert to bits/bytes, if
   * necessary.
   */
  unsigned int rc_buf_sz;

  /*!\brief Decoder Buffer Initial Size
John Koleszar's avatar
John Koleszar committed
522
   *
clang-format's avatar
clang-format committed
523
524
525
526
527
528
529
530
   * This value indicates the amount of data that will be buffered by the
   * decoding application prior to beginning playback. This value is
   * expressed in units of time (milliseconds). Use the target bitrate
   * (#rc_target_bitrate) to convert to bits/bytes, if necessary.
   */
  unsigned int rc_buf_initial_sz;

  /*!\brief Decoder Buffer Optimal Size
John Koleszar's avatar
John Koleszar committed
531
   *
clang-format's avatar
clang-format committed
532
533
534
535
536
537
538
539
540
541
542
543
   * This value indicates the amount of data that the encoder should try
   * to maintain in the decoder's buffer. This value is expressed in units
   * of time (milliseconds). Use the target bitrate (#rc_target_bitrate)
   * to convert to bits/bytes, if necessary.
   */
  unsigned int rc_buf_optimal_sz;

  /*
   * 2 pass rate control parameters
   */

  /*!\brief Two-pass mode CBR/VBR bias
John Koleszar's avatar
John Koleszar committed
544
   *
clang-format's avatar
clang-format committed
545
546
547
548
549
550
551
552
553
   * Bias, expressed on a scale of 0 to 100, for determining target size
   * for the current frame. The value 0 indicates the optimal CBR mode
   * value should be used. The value 100 indicates the optimal VBR mode
   * value should be used. Values in between indicate which way the
   * encoder should "lean."
   */
  unsigned int rc_2pass_vbr_bias_pct;

  /*!\brief Two-pass mode per-GOP minimum bitrate
John Koleszar's avatar
John Koleszar committed
554
   *
clang-format's avatar
clang-format committed
555
556
557
558
559
560
   * This value, expressed as a percentage of the target bitrate, indicates
   * the minimum bitrate to be used for a single GOP (aka "section")
   */
  unsigned int rc_2pass_vbr_minsection_pct;

  /*!\brief Two-pass mode per-GOP maximum bitrate
John Koleszar's avatar
John Koleszar committed
561
   *
clang-format's avatar
clang-format committed
562
563
   * This value, expressed as a percentage of the target bitrate, indicates
   * the maximum bitrate to be used for a single GOP (aka "section")
John Koleszar's avatar
John Koleszar committed
564
   */
clang-format's avatar
clang-format committed
565
  unsigned int rc_2pass_vbr_maxsection_pct;
John Koleszar's avatar
John Koleszar committed
566

clang-format's avatar
clang-format committed
567
568
569
  /*
   * keyframing settings (kf)
   */
John Koleszar's avatar
John Koleszar committed
570

clang-format's avatar
clang-format committed
571
  /*!\brief Keyframe placement mode
John Koleszar's avatar
John Koleszar committed
572
   *
clang-format's avatar
clang-format committed
573
574
575
576
   * This value indicates whether the encoder should place keyframes at a
   * fixed interval, or determine the optimal placement automatically
   * (as governed by the #kf_min_dist and #kf_max_dist parameters)
   */
Yaowu Xu's avatar
Yaowu Xu committed
577
  enum aom_kf_mode kf_mode;
clang-format's avatar
clang-format committed
578
579

  /*!\brief Keyframe minimum interval
John Koleszar's avatar
John Koleszar committed
580
   *
clang-format's avatar
clang-format committed
581
582
583
584
585
586
587
588
   * This value, expressed as a number of frames, prevents the encoder from
   * placing a keyframe nearer than kf_min_dist to the previous keyframe. At
   * least kf_min_dist frames non-keyframes will be coded before the next
   * keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval.
   */
  unsigned int kf_min_dist;

  /*!\brief Keyframe maximum interval
John Koleszar's avatar
John Koleszar committed
589
   *
clang-format's avatar
clang-format committed
590
591
592
593
   * This value, expressed as a number of frames, forces the encoder to code
   * a keyframe if one has not been coded in the last kf_max_dist frames.
   * A value of 0 implies all frames will be keyframes. Set kf_min_dist
   * equal to kf_max_dist for a fixed interval.
John Koleszar's avatar
John Koleszar committed
594
   */
clang-format's avatar
clang-format committed
595
  unsigned int kf_max_dist;
Yaowu Xu's avatar
Yaowu Xu committed
596
} aom_codec_enc_cfg_t; /**< alias for struct aom_codec_enc_cfg */
clang-format's avatar
clang-format committed
597
598
599
600

/*!\brief Initialize an encoder instance
 *
 * Initializes a encoder context using the given interface. Applications
Yaowu Xu's avatar
Yaowu Xu committed
601
 * should call the aom_codec_enc_init convenience macro instead of this
clang-format's avatar
clang-format committed
602
603
604
605
606
607
608
609
610
611
 * function directly, to ensure that the ABI version number parameter
 * is properly initialized.
 *
 * If the library was configured with --disable-multithread, this call
 * is not thread safe and should be guarded with a lock if being used
 * in a multithreaded context.
 *
 * \param[in]    ctx     Pointer to this instance's context.
 * \param[in]    iface   Pointer to the algorithm interface to use.
 * \param[in]    cfg     Configuration to use, if known. May be NULL.
Yaowu Xu's avatar
Yaowu Xu committed
612
 * \param[in]    flags   Bitfield of AOM_CODEC_USE_* flags
clang-format's avatar
clang-format committed
613
 * \param[in]    ver     ABI version number. Must be set to
Yaowu Xu's avatar
Yaowu Xu committed
614
615
 *                       AOM_ENCODER_ABI_VERSION
 * \retval #AOM_CODEC_OK
clang-format's avatar
clang-format committed
616
 *     The decoder algorithm initialized.
Yaowu Xu's avatar
Yaowu Xu committed
617
 * \retval #AOM_CODEC_MEM_ERROR
clang-format's avatar
clang-format committed
618
619
 *     Memory allocation failed.
 */
Yaowu Xu's avatar
Yaowu Xu committed
620
621
622
623
aom_codec_err_t aom_codec_enc_init_ver(aom_codec_ctx_t *ctx,
                                       aom_codec_iface_t *iface,
                                       const aom_codec_enc_cfg_t *cfg,
                                       aom_codec_flags_t flags, int ver);
clang-format's avatar
clang-format committed
624

Yaowu Xu's avatar
Yaowu Xu committed
625
/*!\brief Convenience macro for aom_codec_enc_init_ver()
clang-format's avatar
clang-format committed
626
627
628
 *
 * Ensures the ABI version parameter is properly set.
 */
Yaowu Xu's avatar
Yaowu Xu committed
629
630
#define aom_codec_enc_init(ctx, iface, cfg, flags) \
  aom_codec_enc_init_ver(ctx, iface, cfg, flags, AOM_ENCODER_ABI_VERSION)
clang-format's avatar
clang-format committed
631
632
633
634

/*!\brief Initialize multi-encoder instance
 *
 * Initializes multi-encoder context using the given interface.
Yaowu Xu's avatar
Yaowu Xu committed
635
 * Applications should call the aom_codec_enc_init_multi convenience macro
clang-format's avatar
clang-format committed
636
637
638
639
640
641
642
 * instead of this function directly, to ensure that the ABI version number
 * parameter is properly initialized.
 *
 * \param[in]    ctx     Pointer to this instance's context.
 * \param[in]    iface   Pointer to the algorithm interface to use.
 * \param[in]    cfg     Configuration to use, if known. May be NULL.
 * \param[in]    num_enc Total number of encoders.
Yaowu Xu's avatar
Yaowu Xu committed
643
 * \param[in]    flags   Bitfield of AOM_CODEC_USE_* flags
clang-format's avatar
clang-format committed
644
645
 * \param[in]    dsf     Pointer to down-sampling factors.
 * \param[in]    ver     ABI version number. Must be set to
Yaowu Xu's avatar
Yaowu Xu committed
646
647
 *                       AOM_ENCODER_ABI_VERSION
 * \retval #AOM_CODEC_OK
clang-format's avatar
clang-format committed
648
 *     The decoder algorithm initialized.
Yaowu Xu's avatar
Yaowu Xu committed
649
 * \retval #AOM_CODEC_MEM_ERROR
clang-format's avatar
clang-format committed
650
651
 *     Memory allocation failed.
 */
Yaowu Xu's avatar
Yaowu Xu committed
652
653
654
aom_codec_err_t aom_codec_enc_init_multi_ver(
    aom_codec_ctx_t *ctx, aom_codec_iface_t *iface, aom_codec_enc_cfg_t *cfg,
    int num_enc, aom_codec_flags_t flags, aom_rational_t *dsf, int ver);
clang-format's avatar
clang-format committed
655

Yaowu Xu's avatar
Yaowu Xu committed
656
/*!\brief Convenience macro for aom_codec_enc_init_multi_ver()
clang-format's avatar
clang-format committed
657
658
659
 *
 * Ensures the ABI version parameter is properly set.
 */
Yaowu Xu's avatar
Yaowu Xu committed
660
661
662
#define aom_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
  aom_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf,   \
                               AOM_ENCODER_ABI_VERSION)
clang-format's avatar
clang-format committed
663
664
665
666
667
668
669
670
671
672
673

/*!\brief Get a default configuration
 *
 * Initializes a encoder configuration structure with default values. Supports
 * the notion of "usages" so that an algorithm may offer different default
 * settings depending on the user's intended goal. This function \ref SHOULD
 * be called by all applications to initialize the configuration structure
 * before specializing the configuration with application specific values.
 *
 * \param[in]    iface     Pointer to the algorithm interface to use.
 * \param[out]   cfg       Configuration buffer to populate.
674
 * \param[in]    reserved  Must set to 0.
clang-format's avatar
clang-format committed
675
 *
Yaowu Xu's avatar
Yaowu Xu committed
676
 * \retval #AOM_CODEC_OK
clang-format's avatar
clang-format committed
677
 *     The configuration was populated.
Yaowu Xu's avatar
Yaowu Xu committed
678
 * \retval #AOM_CODEC_INCAPABLE
clang-format's avatar
clang-format committed
679
 *     Interface is not an encoder interface.
Yaowu Xu's avatar
Yaowu Xu committed
680
 * \retval #AOM_CODEC_INVALID_PARAM
clang-format's avatar
clang-format committed
681
682
 *     A parameter was NULL, or the usage value was not recognized.
 */
Yaowu Xu's avatar
Yaowu Xu committed
683
684
aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface,
                                             aom_codec_enc_cfg_t *cfg,
clang-format's avatar
clang-format committed
685
686
687
688
689
690
691
692
693
                                             unsigned int reserved);

/*!\brief Set or change configuration
 *
 * Reconfigures an encoder instance according to the given configuration.
 *
 * \param[in]    ctx     Pointer to this instance's context
 * \param[in]    cfg     Configuration buffer to use
 *
Yaowu Xu's avatar
Yaowu Xu committed
694
 * \retval #AOM_CODEC_OK
clang-format's avatar
clang-format committed
695
 *     The configuration was populated.
Yaowu Xu's avatar
Yaowu Xu committed
696
 * \retval #AOM_CODEC_INCAPABLE
clang-format's avatar
clang-format committed
697
 *     Interface is not an encoder interface.
Yaowu Xu's avatar
Yaowu Xu committed
698
 * \retval #AOM_CODEC_INVALID_PARAM
clang-format's avatar
clang-format committed
699
700
 *     A parameter was NULL, or the usage value was not recognized.
 */
Yaowu Xu's avatar
Yaowu Xu committed
701
702
aom_codec_err_t aom_codec_enc_config_set(aom_codec_ctx_t *ctx,
                                         const aom_codec_enc_cfg_t *cfg);
clang-format's avatar
clang-format committed
703
704
705
706
707
708
709
710
711
712
713
714

/*!\brief Get global stream headers
 *
 * Retrieves a stream level global header packet, if supported by the codec.
 *
 * \param[in]    ctx     Pointer to this instance's context
 *
 * \retval NULL
 *     Encoder does not support global header
 * \retval Non-NULL
 *     Pointer to buffer containing global header packet
 */
Yaowu Xu's avatar
Yaowu Xu committed
715
716
717
718
aom_fixed_buf_t *aom_codec_get_global_headers(aom_codec_ctx_t *ctx);

/*!\brief deadline parameter analogous to  AVx GOOD QUALITY mode. */
#define AOM_DL_GOOD_QUALITY (1000000)
clang-format's avatar
clang-format committed
719
720
721
722
723
724
725
726
727
728
729
/*!\brief Encode a frame
 *
 * Encodes a video frame at the given "presentation time." The presentation
 * time stamp (PTS) \ref MUST be strictly increasing.
 *
 * The encoder supports the notion of a soft real-time deadline. Given a
 * non-zero value to the deadline parameter, the encoder will make a "best
 * effort" guarantee to  return before the given time slice expires. It is
 * implicit that limiting the available time to encode will degrade the
 * output quality. The encoder can be given an unlimited time to produce the
 * best possible frame by specifying a deadline of '0'. This deadline
Yaowu Xu's avatar
Yaowu Xu committed
730
 * supercedes the AVx notion of "best quality, good quality, realtime".
clang-format's avatar
clang-format committed
731
 * Applications that wish to map these former settings to the new deadline
Thomas Daede's avatar
Thomas Daede committed
732
 * based system can use the symbol #AOM_DL_GOOD_QUALITY.
clang-format's avatar
clang-format committed
733
734
735
736
 *
 * When the last frame has been passed to the encoder, this function should
 * continue to be called, with the img parameter set to NULL. This will
 * signal the end-of-stream condition to the encoder and allow it to encode
Yaowu Xu's avatar
Yaowu Xu committed
737
738
 * any held buffers. Encoding is complete when aom_codec_encode() is called
 * and aom_codec_get_cx_data() returns no data.
clang-format's avatar
clang-format committed
739
740
741
742
743
744
745
746
 *
 * \param[in]    ctx       Pointer to this instance's context
 * \param[in]    img       Image data to encode, NULL to flush.
 * \param[in]    pts       Presentation time stamp, in timebase units.
 * \param[in]    duration  Duration to show frame, in timebase units.
 * \param[in]    flags     Flags to use for encoding this frame.
 * \param[in]    deadline  Time to spend encoding, in microseconds. (0=infinite)
 *
Yaowu Xu's avatar
Yaowu Xu committed
747
 * \retval #AOM_CODEC_OK
clang-format's avatar
clang-format committed
748
 *     The configuration was populated.
Yaowu Xu's avatar
Yaowu Xu committed
749
 * \retval #AOM_CODEC_INCAPABLE
clang-format's avatar
clang-format committed
750
 *     Interface is not an encoder interface.
Yaowu Xu's avatar
Yaowu Xu committed
751
 * \retval #AOM_CODEC_INVALID_PARAM
clang-format's avatar
clang-format committed
752
753
 *     A parameter was NULL, the image format is unsupported, etc.
 */
Yaowu Xu's avatar
Yaowu Xu committed
754
755
756
aom_codec_err_t aom_codec_encode(aom_codec_ctx_t *ctx, const aom_image_t *img,
                                 aom_codec_pts_t pts, unsigned long duration,
                                 aom_enc_frame_flags_t flags,
clang-format's avatar
clang-format committed
757
758
759
760
761
762
                                 unsigned long deadline);

/*!\brief Set compressed data output buffer
 *
 * Sets the buffer that the codec should output the compressed data
 * into. This call effectively sets the buffer pointer returned in the
Yaowu Xu's avatar
Yaowu Xu committed
763
 * next AOM_CODEC_CX_FRAME_PKT packet. Subsequent packets will be
clang-format's avatar
clang-format committed
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
 * appended into this buffer. The buffer is preserved across frames,
 * so applications must periodically call this function after flushing
 * the accumulated compressed data to disk or to the network to reset
 * the pointer to the buffer's head.
 *
 * `pad_before` bytes will be skipped before writing the compressed
 * data, and `pad_after` bytes will be appended to the packet. The size
 * of the packet will be the sum of the size of the actual compressed
 * data, pad_before, and pad_after. The padding bytes will be preserved
 * (not overwritten).
 *
 * Note that calling this function does not guarantee that the returned
 * compressed data will be placed into the specified buffer. In the
 * event that the encoded data will not fit into the buffer provided,
 * the returned packet \ref MAY point to an internal buffer, as it would
 * if this call were never used. In this event, the output packet will
 * NOT have any padding, and the application must free space and copy it
 * to the proper place. This is of particular note in configurations
 * that may output multiple packets for a single encoded frame (e.g., lagged
 * encoding) or if the application does not reset the buffer periodically.
 *
 * Applications may restore the default behavior of the codec providing
 * the compressed data buffer by calling this function with a NULL
 * buffer.
 *
 * Applications \ref MUSTNOT call this function during iteration of
Yaowu Xu's avatar
Yaowu Xu committed
790
 * aom_codec_get_cx_data().
clang-format's avatar
clang-format committed
791
792
793
794
795
796
 *
 * \param[in]    ctx         Pointer to this instance's context
 * \param[in]    buf         Buffer to store compressed data into
 * \param[in]    pad_before  Bytes to skip before writing compressed data
 * \param[in]    pad_after   Bytes to skip after writing compressed data
 *
Yaowu Xu's avatar
Yaowu Xu committed
797
 * \retval #AOM_CODEC_OK
clang-format's avatar
clang-format committed
798
 *     The buffer was set successfully.
Yaowu Xu's avatar
Yaowu Xu committed
799
 * \retval #AOM_CODEC_INVALID_PARAM
clang-format's avatar
clang-format committed
800
801
 *     A parameter was NULL, the image format is unsupported, etc.
 */
Yaowu Xu's avatar
Yaowu Xu committed
802
803
aom_codec_err_t aom_codec_set_cx_data_buf(aom_codec_ctx_t *ctx,
                                          const aom_fixed_buf_t *buf,
clang-format's avatar
clang-format committed
804
805
                                          unsigned int pad_before,
                                          unsigned int pad_after);
John Koleszar's avatar
John Koleszar committed
806

clang-format's avatar
clang-format committed
807
808
809
810
/*!\brief Encoded data iterator
 *
 * Iterates over a list of data packets to be passed from the encoder to the
 * application. The different kinds of packets available are enumerated in
Yaowu Xu's avatar
Yaowu Xu committed
811
 * #aom_codec_cx_pkt_kind.
clang-format's avatar
clang-format committed
812
 *
Yaowu Xu's avatar
Yaowu Xu committed
813
 * #AOM_CODEC_CX_FRAME_PKT packets should be passed to the application's
clang-format's avatar
clang-format committed
814
 * muxer. Multiple compressed frames may be in the list.
Yaowu Xu's avatar
Yaowu Xu committed
815
 * #AOM_CODEC_STATS_PKT packets should be appended to a global buffer.
clang-format's avatar
clang-format committed
816
817
818
819
820
 *
 * The application \ref MUST silently ignore any packet kinds that it does
 * not recognize or support.
 *
 * The data buffers returned from this function are only guaranteed to be
Yaowu Xu's avatar
Yaowu Xu committed
821
 * valid until the application makes another call to any aom_codec_* function.
clang-format's avatar
clang-format committed
822
823
824
825
826
827
828
829
 *
 * \param[in]     ctx      Pointer to this instance's context
 * \param[in,out] iter     Iterator storage, initialized to NULL
 *
 * \return Returns a pointer to an output data packet (compressed frame data,
 *         two-pass statistics, etc.) or NULL to signal end-of-list.
 *
 */
Yaowu Xu's avatar
Yaowu Xu committed
830
831
const aom_codec_cx_pkt_t *aom_codec_get_cx_data(aom_codec_ctx_t *ctx,
                                                aom_codec_iter_t *iter);
clang-format's avatar
clang-format committed
832
833
834
835
836
837
838
839
840
841
842
843
844

/*!\brief Get Preview Frame
 *
 * Returns an image that can be used as a preview. Shows the image as it would
 * exist at the decompressor. The application \ref MUST NOT write into this
 * image buffer.
 *
 * \param[in]     ctx      Pointer to this instance's context
 *
 * \return Returns a pointer to a preview image, or NULL if no image is
 *         available.
 *
 */
Yaowu Xu's avatar
Yaowu Xu committed
845
const aom_image_t *aom_codec_get_preview_frame(aom_codec_ctx_t *ctx);
John Koleszar's avatar
John Koleszar committed
846

clang-format's avatar
clang-format committed
847
/*!@} - end defgroup encoder*/
John Koleszar's avatar
John Koleszar committed
848
849
850
#ifdef __cplusplus
}
#endif
Yaowu Xu's avatar
Yaowu Xu committed
851
#endif  // AOM_AOM_ENCODER_H_