blob: 39f1ae3e559054735fa3bf6a92f6478f010fa4cd [file] [log] [blame]
John Koleszar0ea50ce2010-05-18 11:58:33 -04001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
John Koleszar0ea50ce2010-05-18 11:58:33 -04003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
John Koleszar0ea50ce2010-05-18 11:58:33 -040010 */
Yaowu Xuf883b422016-08-30 14:01:10 -070011#ifndef AOM_AOM_ENCODER_H_
12#define AOM_AOM_ENCODER_H_
John Koleszar0ea50ce2010-05-18 11:58:33 -040013
14/*!\defgroup encoder Encoder Algorithm Interface
15 * \ingroup codec
16 * This abstraction allows applications using this encoder to easily support
17 * multiple video formats with minimal code duplication. This section describes
18 * the interface common to all encoders.
19 * @{
20 */
21
James Zernf42d52e2011-02-16 17:54:49 -080022/*!\file
John Koleszar0ea50ce2010-05-18 11:58:33 -040023 * \brief Describes the encoder algorithm interface to applications.
24 *
25 * This file describes the interface between an application and a
26 * video encoder algorithm.
27 *
28 */
29#ifdef __cplusplus
30extern "C" {
31#endif
32
Yaowu Xuf883b422016-08-30 14:01:10 -070033#include "./aom_codec.h"
John Koleszar0ea50ce2010-05-18 11:58:33 -040034
clang-format83a52072016-08-08 20:22:13 -070035/*!\brief Current ABI version number
36 *
37 * \internal
38 * If this file is altered in any way that changes the ABI, this value
39 * must be bumped. Examples include, but are not limited to, changing
40 * types, removing or reassigning enums, adding/removing/rearranging
41 * fields to structures
42 */
Yaowu Xuf883b422016-08-30 14:01:10 -070043#define AOM_ENCODER_ABI_VERSION \
44 (5 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
John Koleszar0ea50ce2010-05-18 11:58:33 -040045
clang-format83a52072016-08-08 20:22:13 -070046/*! \brief Encoder capabilities bitfield
47 *
48 * Each encoder advertises the capabilities it supports as part of its
Yaowu Xuf883b422016-08-30 14:01:10 -070049 * ::aom_codec_iface_t interface structure. Capabilities are extra
clang-format83a52072016-08-08 20:22:13 -070050 * interfaces or functionality, and are not required to be supported
51 * by an encoder.
52 *
Yaowu Xuf883b422016-08-30 14:01:10 -070053 * The available flags are specified by AOM_CODEC_CAP_* defines.
clang-format83a52072016-08-08 20:22:13 -070054 */
Yaowu Xuf883b422016-08-30 14:01:10 -070055#define AOM_CODEC_CAP_PSNR 0x10000 /**< Can issue PSNR packets */
John Koleszar0ea50ce2010-05-18 11:58:33 -040056
clang-format83a52072016-08-08 20:22:13 -070057/*! Can output one partition at a time. Each partition is returned in its
Yaowu Xuf883b422016-08-30 14:01:10 -070058 * own AOM_CODEC_CX_FRAME_PKT, with the FRAME_IS_FRAGMENT flag set for
clang-format83a52072016-08-08 20:22:13 -070059 * every partition but the last. In this mode all frames are always
60 * returned partition by partition.
61 */
Yaowu Xuf883b422016-08-30 14:01:10 -070062#define AOM_CODEC_CAP_OUTPUT_PARTITION 0x20000
Stefan Holmerb433e122011-06-10 15:58:22 +020063
Deb Mukherjee5acfafb2014-08-26 12:35:15 -070064/*! Can support input images at greater than 8 bitdepth.
65 */
Yaowu Xuf883b422016-08-30 14:01:10 -070066#define AOM_CODEC_CAP_HIGHBITDEPTH 0x40000
John Koleszar0ea50ce2010-05-18 11:58:33 -040067
clang-format83a52072016-08-08 20:22:13 -070068/*! \brief Initialization-time Feature Enabling
69 *
70 * Certain codec features must be known at initialization time, to allow
71 * for proper memory allocation.
72 *
Yaowu Xuf883b422016-08-30 14:01:10 -070073 * The available flags are specified by AOM_CODEC_USE_* defines.
clang-format83a52072016-08-08 20:22:13 -070074 */
Yaowu Xuf883b422016-08-30 14:01:10 -070075#define AOM_CODEC_USE_PSNR 0x10000 /**< Calculate PSNR on each frame */
clang-format83a52072016-08-08 20:22:13 -070076/*!\brief Make the encoder output one partition at a time. */
Yaowu Xuf883b422016-08-30 14:01:10 -070077#define AOM_CODEC_USE_OUTPUT_PARTITION 0x20000
78#define AOM_CODEC_USE_HIGHBITDEPTH 0x40000 /**< Use high bitdepth */
John Koleszar0ea50ce2010-05-18 11:58:33 -040079
clang-format83a52072016-08-08 20:22:13 -070080/*!\brief Generic fixed size buffer structure
81 *
82 * This structure is able to hold a reference to any fixed size buffer.
83 */
Yaowu Xuf883b422016-08-30 14:01:10 -070084typedef struct aom_fixed_buf {
clang-format83a52072016-08-08 20:22:13 -070085 void *buf; /**< Pointer to the data */
86 size_t sz; /**< Length of the buffer, in chars */
Yaowu Xuf883b422016-08-30 14:01:10 -070087} aom_fixed_buf_t; /**< alias for struct aom_fixed_buf */
John Koleszar0ea50ce2010-05-18 11:58:33 -040088
clang-format83a52072016-08-08 20:22:13 -070089/*!\brief Time Stamp Type
90 *
91 * An integer, which when multiplied by the stream's time base, provides
92 * the absolute time of a sample.
93 */
Yaowu Xuf883b422016-08-30 14:01:10 -070094typedef int64_t aom_codec_pts_t;
clang-format83a52072016-08-08 20:22:13 -070095
96/*!\brief Compressed Frame Flags
97 *
98 * This type represents a bitfield containing information about a compressed
99 * frame that may be useful to an application. The most significant 16 bits
100 * can be used by an algorithm to provide additional detail, for example to
101 * support frame types that are codec specific (MPEG-1 D-frames for example)
102 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700103typedef uint32_t aom_codec_frame_flags_t;
104#define AOM_FRAME_IS_KEY 0x1 /**< frame is the start of a GOP */
clang-format83a52072016-08-08 20:22:13 -0700105/*!\brief frame can be dropped without affecting the stream (no future frame
106 * depends on this one) */
Yaowu Xuf883b422016-08-30 14:01:10 -0700107#define AOM_FRAME_IS_DROPPABLE 0x2
clang-format83a52072016-08-08 20:22:13 -0700108/*!\brief frame should be decoded but will not be shown */
Yaowu Xuf883b422016-08-30 14:01:10 -0700109#define AOM_FRAME_IS_INVISIBLE 0x4
clang-format83a52072016-08-08 20:22:13 -0700110/*!\brief this is a fragment of the encoded frame */
Yaowu Xuf883b422016-08-30 14:01:10 -0700111#define AOM_FRAME_IS_FRAGMENT 0x8
clang-format83a52072016-08-08 20:22:13 -0700112
113/*!\brief Error Resilient flags
114 *
115 * These flags define which error resilient features to enable in the
116 * encoder. The flags are specified through the
Yaowu Xuf883b422016-08-30 14:01:10 -0700117 * aom_codec_enc_cfg::g_error_resilient variable.
clang-format83a52072016-08-08 20:22:13 -0700118 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700119typedef uint32_t aom_codec_er_flags_t;
clang-format83a52072016-08-08 20:22:13 -0700120/*!\brief Improve resiliency against losses of whole frames */
Yaowu Xuf883b422016-08-30 14:01:10 -0700121#define AOM_ERROR_RESILIENT_DEFAULT 0x1
clang-format83a52072016-08-08 20:22:13 -0700122/*!\brief The frame partitions are independently decodable by the bool decoder,
123 * meaning that partitions can be decoded even though earlier partitions have
124 * been lost. Note that intra prediction is still done over the partition
125 * boundary. */
Yaowu Xuf883b422016-08-30 14:01:10 -0700126#define AOM_ERROR_RESILIENT_PARTITIONS 0x2
clang-format83a52072016-08-08 20:22:13 -0700127
128/*!\brief Encoder output packet variants
129 *
130 * This enumeration lists the different kinds of data packets that can be
Yaowu Xuf883b422016-08-30 14:01:10 -0700131 * returned by calls to aom_codec_get_cx_data(). Algorithms \ref MAY
clang-format83a52072016-08-08 20:22:13 -0700132 * extend this list to provide additional functionality.
133 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700134enum aom_codec_cx_pkt_kind {
135 AOM_CODEC_CX_FRAME_PKT, /**< Compressed video frame */
136 AOM_CODEC_STATS_PKT, /**< Two-pass statistics for this frame */
137 AOM_CODEC_FPMB_STATS_PKT, /**< first pass mb statistics for this frame */
138 AOM_CODEC_PSNR_PKT, /**< PSNR statistics for this frame */
139 AOM_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions */
clang-format83a52072016-08-08 20:22:13 -0700140};
141
142/*!\brief Encoder output packet
143 *
144 * This structure contains the different kinds of output data the encoder
145 * may produce while compressing a frame.
146 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700147typedef struct aom_codec_cx_pkt {
148 enum aom_codec_cx_pkt_kind kind; /**< packet variant */
clang-format83a52072016-08-08 20:22:13 -0700149 union {
150 struct {
151 void *buf; /**< compressed data buffer */
152 size_t sz; /**< length of compressed data */
153 /*!\brief time stamp to show frame (in timebase units) */
Yaowu Xuf883b422016-08-30 14:01:10 -0700154 aom_codec_pts_t pts;
clang-format83a52072016-08-08 20:22:13 -0700155 /*!\brief duration to show frame (in timebase units) */
156 unsigned long duration;
Yaowu Xuf883b422016-08-30 14:01:10 -0700157 aom_codec_frame_flags_t flags; /**< flags for this frame */
clang-format83a52072016-08-08 20:22:13 -0700158 /*!\brief the partition id defines the decoding order of the partitions.
159 * Only applicable when "output partition" mode is enabled. First
160 * partition has id 0.*/
161 int partition_id;
162 } frame; /**< data for compressed frame packet */
Yaowu Xuf883b422016-08-30 14:01:10 -0700163 aom_fixed_buf_t twopass_stats; /**< data for two-pass packet */
164 aom_fixed_buf_t firstpass_mb_stats; /**< first pass mb packet */
165 struct aom_psnr_pkt {
clang-format83a52072016-08-08 20:22:13 -0700166 unsigned int samples[4]; /**< Number of samples, total/y/u/v */
167 uint64_t sse[4]; /**< sum squared error, total/y/u/v */
168 double psnr[4]; /**< PSNR, total/y/u/v */
169 } psnr; /**< data for PSNR packet */
Yaowu Xuf883b422016-08-30 14:01:10 -0700170 aom_fixed_buf_t raw; /**< data for arbitrary packets */
clang-format83a52072016-08-08 20:22:13 -0700171
172 /* This packet size is fixed to allow codecs to extend this
173 * interface without having to manage storage for raw packets,
174 * i.e., if it's smaller than 128 bytes, you can store in the
175 * packet list directly.
176 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700177 char pad[128 - sizeof(enum aom_codec_cx_pkt_kind)]; /**< fixed sz */
clang-format83a52072016-08-08 20:22:13 -0700178 } data; /**< packet data */
Yaowu Xuf883b422016-08-30 14:01:10 -0700179} aom_codec_cx_pkt_t; /**< alias for struct aom_codec_cx_pkt */
clang-format83a52072016-08-08 20:22:13 -0700180
181/*!\brief Rational Number
182 *
183 * This structure holds a fractional value.
184 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700185typedef struct aom_rational {
clang-format83a52072016-08-08 20:22:13 -0700186 int num; /**< fraction numerator */
187 int den; /**< fraction denominator */
Yaowu Xuf883b422016-08-30 14:01:10 -0700188} aom_rational_t; /**< alias for struct aom_rational */
clang-format83a52072016-08-08 20:22:13 -0700189
190/*!\brief Multi-pass Encoding Pass */
Yaowu Xuf883b422016-08-30 14:01:10 -0700191enum aom_enc_pass {
192 AOM_RC_ONE_PASS, /**< Single pass mode */
193 AOM_RC_FIRST_PASS, /**< First pass of multi-pass mode */
194 AOM_RC_LAST_PASS /**< Final pass of multi-pass mode */
clang-format83a52072016-08-08 20:22:13 -0700195};
196
197/*!\brief Rate control mode */
Yaowu Xuf883b422016-08-30 14:01:10 -0700198enum aom_rc_mode {
199 AOM_VBR, /**< Variable Bit Rate (VBR) mode */
200 AOM_CBR, /**< Constant Bit Rate (CBR) mode */
201 AOM_CQ, /**< Constrained Quality (CQ) mode */
202 AOM_Q, /**< Constant Quality (Q) mode */
clang-format83a52072016-08-08 20:22:13 -0700203};
204
205/*!\brief Keyframe placement mode.
206 *
207 * This enumeration determines whether keyframes are placed automatically by
208 * the encoder or whether this behavior is disabled. Older releases of this
Yaowu Xuf883b422016-08-30 14:01:10 -0700209 * SDK were implemented such that AOM_KF_FIXED meant keyframes were disabled.
clang-format83a52072016-08-08 20:22:13 -0700210 * This name is confusing for this behavior, so the new symbols to be used
Yaowu Xuf883b422016-08-30 14:01:10 -0700211 * are AOM_KF_AUTO and AOM_KF_DISABLED.
clang-format83a52072016-08-08 20:22:13 -0700212 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700213enum aom_kf_mode {
214 AOM_KF_FIXED, /**< deprecated, implies AOM_KF_DISABLED */
215 AOM_KF_AUTO, /**< Encoder determines optimal placement automatically */
216 AOM_KF_DISABLED = 0 /**< Encoder does not place keyframes. */
clang-format83a52072016-08-08 20:22:13 -0700217};
218
219/*!\brief Encoded Frame Flags
220 *
Yaowu Xuf883b422016-08-30 14:01:10 -0700221 * This type indicates a bitfield to be passed to aom_codec_encode(), defining
clang-format83a52072016-08-08 20:22:13 -0700222 * per-frame boolean values. By convention, bits common to all codecs will be
Yaowu Xuf883b422016-08-30 14:01:10 -0700223 * named AOM_EFLAG_*, and bits specific to an algorithm will be named
clang-format83a52072016-08-08 20:22:13 -0700224 * /algo/_eflag_*. The lower order 16 bits are reserved for common use.
225 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700226typedef long aom_enc_frame_flags_t;
227#define AOM_EFLAG_FORCE_KF (1 << 0) /**< Force this frame to be a keyframe */
clang-format83a52072016-08-08 20:22:13 -0700228
229/*!\brief Encoder configuration structure
230 *
231 * This structure contains the encoder settings that have common representations
232 * across all codecs. This doesn't imply that all codecs support all features,
233 * however.
234 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700235typedef struct aom_codec_enc_cfg {
clang-format83a52072016-08-08 20:22:13 -0700236 /*
237 * generic settings (g)
John Koleszarc6b90392012-07-13 15:21:29 -0700238 */
John Koleszar0ea50ce2010-05-18 11:58:33 -0400239
clang-format83a52072016-08-08 20:22:13 -0700240 /*!\brief Algorithm specific "usage" value
John Koleszarc6b90392012-07-13 15:21:29 -0700241 *
clang-format83a52072016-08-08 20:22:13 -0700242 * Algorithms may define multiple values for usage, which may convey the
243 * intent of how the application intends to use the stream. If this value
244 * is non-zero, consult the documentation for the codec to determine its
245 * meaning.
John Koleszarc6b90392012-07-13 15:21:29 -0700246 */
clang-format83a52072016-08-08 20:22:13 -0700247 unsigned int g_usage;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400248
clang-format83a52072016-08-08 20:22:13 -0700249 /*!\brief Maximum number of threads to use
John Koleszarc6b90392012-07-13 15:21:29 -0700250 *
clang-format83a52072016-08-08 20:22:13 -0700251 * For multi-threaded implementations, use no more than this number of
252 * threads. The codec may use fewer threads than allowed. The value
253 * 0 is equivalent to the value 1.
John Koleszarc6b90392012-07-13 15:21:29 -0700254 */
clang-format83a52072016-08-08 20:22:13 -0700255 unsigned int g_threads;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400256
clang-format83a52072016-08-08 20:22:13 -0700257 /*!\brief Bitstream profile to use
John Koleszarc6b90392012-07-13 15:21:29 -0700258 *
clang-format83a52072016-08-08 20:22:13 -0700259 * Some codecs support a notion of multiple bitstream profiles. Typically
260 * this maps to a set of features that are turned on or off. Often the
261 * profile to use is determined by the features of the intended decoder.
262 * Consult the documentation for the codec to determine the valid values
263 * for this parameter, or set to zero for a sane default.
John Koleszarc6b90392012-07-13 15:21:29 -0700264 */
clang-format83a52072016-08-08 20:22:13 -0700265 unsigned int g_profile; /**< profile of bitstream to use */
John Koleszar0ea50ce2010-05-18 11:58:33 -0400266
clang-format83a52072016-08-08 20:22:13 -0700267 /*!\brief Width of the frame
John Koleszarc6b90392012-07-13 15:21:29 -0700268 *
clang-format83a52072016-08-08 20:22:13 -0700269 * This value identifies the presentation resolution of the frame,
270 * in pixels. Note that the frames passed as input to the encoder must
271 * have this resolution. Frames will be presented by the decoder in this
272 * resolution, independent of any spatial resampling the encoder may do.
John Koleszarc6b90392012-07-13 15:21:29 -0700273 */
clang-format83a52072016-08-08 20:22:13 -0700274 unsigned int g_w;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400275
clang-format83a52072016-08-08 20:22:13 -0700276 /*!\brief Height of the frame
John Koleszarc6b90392012-07-13 15:21:29 -0700277 *
clang-format83a52072016-08-08 20:22:13 -0700278 * This value identifies the presentation resolution of the frame,
279 * in pixels. Note that the frames passed as input to the encoder must
280 * have this resolution. Frames will be presented by the decoder in this
281 * resolution, independent of any spatial resampling the encoder may do.
John Koleszarc6b90392012-07-13 15:21:29 -0700282 */
clang-format83a52072016-08-08 20:22:13 -0700283 unsigned int g_h;
Stefan Holmer7296b3f2011-06-13 16:42:27 +0200284
clang-format83a52072016-08-08 20:22:13 -0700285 /*!\brief Bit-depth of the codec
John Koleszarc6b90392012-07-13 15:21:29 -0700286 *
clang-format83a52072016-08-08 20:22:13 -0700287 * This value identifies the bit_depth of the codec,
288 * Only certain bit-depths are supported as identified in the
Yaowu Xuf883b422016-08-30 14:01:10 -0700289 * aom_bit_depth_t enum.
John Koleszarc6b90392012-07-13 15:21:29 -0700290 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700291 aom_bit_depth_t g_bit_depth;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400292
clang-format83a52072016-08-08 20:22:13 -0700293 /*!\brief Bit-depth of the input frames
John Koleszarc6b90392012-07-13 15:21:29 -0700294 *
clang-format83a52072016-08-08 20:22:13 -0700295 * This value identifies the bit_depth of the input frames in bits.
296 * Note that the frames passed as input to the encoder must have
297 * this bit-depth.
John Koleszarc6b90392012-07-13 15:21:29 -0700298 */
clang-format83a52072016-08-08 20:22:13 -0700299 unsigned int g_input_bit_depth;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400300
clang-format83a52072016-08-08 20:22:13 -0700301 /*!\brief Stream timebase units
John Koleszarc6b90392012-07-13 15:21:29 -0700302 *
clang-format83a52072016-08-08 20:22:13 -0700303 * Indicates the smallest interval of time, in seconds, used by the stream.
304 * For fixed frame rate material, or variable frame rate material where
305 * frames are timed at a multiple of a given clock (ex: video capture),
306 * the \ref RECOMMENDED method is to set the timebase to the reciprocal
307 * of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the
308 * pts to correspond to the frame number, which can be handy. For
309 * re-encoding video from containers with absolute time timestamps, the
310 * \ref RECOMMENDED method is to set the timebase to that of the parent
311 * container or multimedia framework (ex: 1/1000 for ms, as in FLV).
John Koleszarc6b90392012-07-13 15:21:29 -0700312 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700313 struct aom_rational g_timebase;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400314
clang-format83a52072016-08-08 20:22:13 -0700315 /*!\brief Enable error resilient modes.
John Koleszarc6b90392012-07-13 15:21:29 -0700316 *
clang-format83a52072016-08-08 20:22:13 -0700317 * The error resilient bitfield indicates to the encoder which features
318 * it should enable to take measures for streaming over lossy or noisy
319 * links.
John Koleszarc6b90392012-07-13 15:21:29 -0700320 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700321 aom_codec_er_flags_t g_error_resilient;
John Koleszar0ea50ce2010-05-18 11:58:33 -0400322
clang-format83a52072016-08-08 20:22:13 -0700323 /*!\brief Multi-pass Encoding Mode
John Koleszarc6b90392012-07-13 15:21:29 -0700324 *
clang-format83a52072016-08-08 20:22:13 -0700325 * This value should be set to the current phase for multi-pass encoding.
Yaowu Xuf883b422016-08-30 14:01:10 -0700326 * For single pass, set to #AOM_RC_ONE_PASS.
John Koleszarc6b90392012-07-13 15:21:29 -0700327 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700328 enum aom_enc_pass g_pass;
John Koleszarc6b90392012-07-13 15:21:29 -0700329
clang-format83a52072016-08-08 20:22:13 -0700330 /*!\brief Allow lagged encoding
John Koleszarc6b90392012-07-13 15:21:29 -0700331 *
clang-format83a52072016-08-08 20:22:13 -0700332 * If set, this value allows the encoder to consume a number of input
333 * frames before producing output frames. This allows the encoder to
334 * base decisions for the current frame on future frames. This does
335 * increase the latency of the encoding pipeline, so it is not appropriate
336 * in all situations (ex: realtime encoding).
337 *
338 * Note that this is a maximum value -- the encoder may produce frames
339 * sooner than the given limit. Set this value to 0 to disable this
340 * feature.
John Koleszarc6b90392012-07-13 15:21:29 -0700341 */
clang-format83a52072016-08-08 20:22:13 -0700342 unsigned int g_lag_in_frames;
343
344 /*
345 * rate control settings (rc)
346 */
347
348 /*!\brief Temporal resampling configuration, if supported by the codec.
349 *
350 * Temporal resampling allows the codec to "drop" frames as a strategy to
351 * meet its target data rate. This can cause temporal discontinuities in
352 * the encoded video, which may appear as stuttering during playback. This
353 * trade-off is often acceptable, but for many applications is not. It can
354 * be disabled in these cases.
355 *
Yaowu Xuf883b422016-08-30 14:01:10 -0700356 * Note that not all codecs support this feature. All aom AVx codecs do.
clang-format83a52072016-08-08 20:22:13 -0700357 * For other codecs, consult the documentation for that algorithm.
358 *
359 * This threshold is described as a percentage of the target data buffer.
360 * When the data buffer falls below this percentage of fullness, a
361 * dropped frame is indicated. Set the threshold to zero (0) to disable
362 * this feature.
363 */
364 unsigned int rc_dropframe_thresh;
365
Debargha Mukherjee29e40a62017-06-14 09:37:12 -0700366 /*!\brief Mode for spatial resampling, if supported by the codec.
clang-format83a52072016-08-08 20:22:13 -0700367 *
368 * Spatial resampling allows the codec to compress a lower resolution
Debargha Mukherjee29e40a62017-06-14 09:37:12 -0700369 * version of the frame, which is then upscaled by the decoder to the
clang-format83a52072016-08-08 20:22:13 -0700370 * correct presentation resolution. This increases visual quality at
371 * low data rates, at the expense of CPU time on the encoder/decoder.
372 */
Debargha Mukherjee29e40a62017-06-14 09:37:12 -0700373 unsigned int rc_resize_mode;
clang-format83a52072016-08-08 20:22:13 -0700374
Debargha Mukherjee29e40a62017-06-14 09:37:12 -0700375 /*!\brief Frame resize numerator.
clang-format83a52072016-08-08 20:22:13 -0700376 *
Debargha Mukherjee29e40a62017-06-14 09:37:12 -0700377 * The numerator for resize to use, assuming 16 as the denominator.
clang-format83a52072016-08-08 20:22:13 -0700378 *
Debargha Mukherjee29e40a62017-06-14 09:37:12 -0700379 * Valid numerators are 8 - 16 for now.
clang-format83a52072016-08-08 20:22:13 -0700380 */
Debargha Mukherjee29e40a62017-06-14 09:37:12 -0700381 unsigned int rc_resize_numerator;
clang-format83a52072016-08-08 20:22:13 -0700382
Fergus Simpson87cf61b2017-06-15 00:50:34 -0700383 /*!\brief Keyframe resize numerator.
384 *
385 * The numerator for resize to use, assuming 16 as the denominator.
386 *
387 * Valid numerators are 8 - 16 for now.
388 */
389 unsigned int rc_resize_kf_numerator;
390
Fergus Simpsonc4e78942017-04-10 14:59:00 -0700391 /*!\brief Frame super-resolution scaling mode.
392 *
393 * Similar to spatial resampling, frame super-resolution integrates
394 * upscaling after the encode/decode process. Taking control of upscaling and
395 * using restoration filters should allow it to outperform normal resizing.
396 *
397 * Mode 0 is SUPERRES_NONE, mode 1 is SUPERRES_FIXED, and mode 2 is
398 * SUPERRES_DYNAMIC.
399 */
400 unsigned int rc_superres_mode;
401
402 /*!\brief Frame super-resolution numerator.
403 *
404 * The numerator for superres to use. If fixed it will only change if the
405 * cumulative scale change over resizing and superres is greater than 1/2;
406 * this forces superres to reduce scaling.
407 *
408 * Valid numerators are 8 to 16.
409 *
410 * Ignored by SUPERRES_DYNAMIC.
411 */
412 unsigned int rc_superres_numerator;
413
Fergus Simpson87cf61b2017-06-15 00:50:34 -0700414 /*!\brief Keyframe super-resolution numerator.
415 *
416 * The numerator for superres to use. If fixed it will only change if the
417 * cumulative scale change over resizing and superres is greater than 1/2;
418 * this forces superres to reduce scaling.
419 *
420 * Valid numerators are 8 - 16 for now.
421 */
422 unsigned int rc_superres_kf_numerator;
423
clang-format83a52072016-08-08 20:22:13 -0700424 /*!\brief Rate control algorithm to use.
425 *
426 * Indicates whether the end usage of this stream is to be streamed over
427 * a bandwidth constrained link, indicating that Constant Bit Rate (CBR)
428 * mode should be used, or whether it will be played back on a high
429 * bandwidth link, as from a local disk, where higher variations in
430 * bitrate are acceptable.
431 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700432 enum aom_rc_mode rc_end_usage;
clang-format83a52072016-08-08 20:22:13 -0700433
434 /*!\brief Two-pass stats buffer.
435 *
436 * A buffer containing all of the stats packets produced in the first
437 * pass, concatenated.
438 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700439 aom_fixed_buf_t rc_twopass_stats_in;
clang-format83a52072016-08-08 20:22:13 -0700440
441 /*!\brief first pass mb stats buffer.
442 *
443 * A buffer containing all of the first pass mb stats packets produced
444 * in the first pass, concatenated.
445 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700446 aom_fixed_buf_t rc_firstpass_mb_stats_in;
clang-format83a52072016-08-08 20:22:13 -0700447
448 /*!\brief Target data rate
449 *
450 * Target bandwidth to use for this stream, in kilobits per second.
451 */
452 unsigned int rc_target_bitrate;
453
454 /*
455 * quantizer settings
456 */
457
458 /*!\brief Minimum (Best Quality) Quantizer
459 *
460 * The quantizer is the most direct control over the quality of the
461 * encoded image. The range of valid values for the quantizer is codec
462 * specific. Consult the documentation for the codec to determine the
463 * values to use. To determine the range programmatically, call
Yaowu Xuf883b422016-08-30 14:01:10 -0700464 * aom_codec_enc_config_default() with a usage value of 0.
clang-format83a52072016-08-08 20:22:13 -0700465 */
466 unsigned int rc_min_quantizer;
467
468 /*!\brief Maximum (Worst Quality) Quantizer
469 *
470 * The quantizer is the most direct control over the quality of the
471 * encoded image. The range of valid values for the quantizer is codec
472 * specific. Consult the documentation for the codec to determine the
473 * values to use. To determine the range programmatically, call
Yaowu Xuf883b422016-08-30 14:01:10 -0700474 * aom_codec_enc_config_default() with a usage value of 0.
clang-format83a52072016-08-08 20:22:13 -0700475 */
476 unsigned int rc_max_quantizer;
477
478 /*
479 * bitrate tolerance
480 */
481
482 /*!\brief Rate control adaptation undershoot control
483 *
484 * This value, expressed as a percentage of the target bitrate,
485 * controls the maximum allowed adaptation speed of the codec.
486 * This factor controls the maximum amount of bits that can
487 * be subtracted from the target bitrate in order to compensate
488 * for prior overshoot.
489 *
490 * Valid values in the range 0-1000.
491 */
492 unsigned int rc_undershoot_pct;
493
494 /*!\brief Rate control adaptation overshoot control
495 *
496 * This value, expressed as a percentage of the target bitrate,
497 * controls the maximum allowed adaptation speed of the codec.
498 * This factor controls the maximum amount of bits that can
499 * be added to the target bitrate in order to compensate for
500 * prior undershoot.
501 *
502 * Valid values in the range 0-1000.
503 */
504 unsigned int rc_overshoot_pct;
505
506 /*
507 * decoder buffer model parameters
508 */
509
510 /*!\brief Decoder Buffer Size
511 *
512 * This value indicates the amount of data that may be buffered by the
513 * decoding application. Note that this value is expressed in units of
514 * time (milliseconds). For example, a value of 5000 indicates that the
515 * client will buffer (at least) 5000ms worth of encoded data. Use the
516 * target bitrate (#rc_target_bitrate) to convert to bits/bytes, if
517 * necessary.
518 */
519 unsigned int rc_buf_sz;
520
521 /*!\brief Decoder Buffer Initial Size
522 *
523 * This value indicates the amount of data that will be buffered by the
524 * decoding application prior to beginning playback. This value is
525 * expressed in units of time (milliseconds). Use the target bitrate
526 * (#rc_target_bitrate) to convert to bits/bytes, if necessary.
527 */
528 unsigned int rc_buf_initial_sz;
529
530 /*!\brief Decoder Buffer Optimal Size
531 *
532 * This value indicates the amount of data that the encoder should try
533 * to maintain in the decoder's buffer. This value is expressed in units
534 * of time (milliseconds). Use the target bitrate (#rc_target_bitrate)
535 * to convert to bits/bytes, if necessary.
536 */
537 unsigned int rc_buf_optimal_sz;
538
539 /*
540 * 2 pass rate control parameters
541 */
542
543 /*!\brief Two-pass mode CBR/VBR bias
544 *
545 * Bias, expressed on a scale of 0 to 100, for determining target size
546 * for the current frame. The value 0 indicates the optimal CBR mode
547 * value should be used. The value 100 indicates the optimal VBR mode
548 * value should be used. Values in between indicate which way the
549 * encoder should "lean."
550 */
551 unsigned int rc_2pass_vbr_bias_pct;
552
553 /*!\brief Two-pass mode per-GOP minimum bitrate
554 *
555 * This value, expressed as a percentage of the target bitrate, indicates
556 * the minimum bitrate to be used for a single GOP (aka "section")
557 */
558 unsigned int rc_2pass_vbr_minsection_pct;
559
560 /*!\brief Two-pass mode per-GOP maximum bitrate
561 *
562 * This value, expressed as a percentage of the target bitrate, indicates
563 * the maximum bitrate to be used for a single GOP (aka "section")
564 */
565 unsigned int rc_2pass_vbr_maxsection_pct;
566
567 /*
568 * keyframing settings (kf)
569 */
570
571 /*!\brief Keyframe placement mode
572 *
573 * This value indicates whether the encoder should place keyframes at a
574 * fixed interval, or determine the optimal placement automatically
575 * (as governed by the #kf_min_dist and #kf_max_dist parameters)
576 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700577 enum aom_kf_mode kf_mode;
clang-format83a52072016-08-08 20:22:13 -0700578
579 /*!\brief Keyframe minimum interval
580 *
581 * This value, expressed as a number of frames, prevents the encoder from
582 * placing a keyframe nearer than kf_min_dist to the previous keyframe. At
583 * least kf_min_dist frames non-keyframes will be coded before the next
584 * keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval.
585 */
586 unsigned int kf_min_dist;
587
588 /*!\brief Keyframe maximum interval
589 *
590 * This value, expressed as a number of frames, forces the encoder to code
591 * a keyframe if one has not been coded in the last kf_max_dist frames.
592 * A value of 0 implies all frames will be keyframes. Set kf_min_dist
593 * equal to kf_max_dist for a fixed interval.
594 */
595 unsigned int kf_max_dist;
Yunqing Wangeeb08a92017-07-07 21:25:18 -0700596
597 /*!\brief Tile coding mode
598 *
599 * This value indicates the tile coding mode.
600 * A value of 0 implies a normal non-large-scale tile coding. A value of 1
601 * implies a large-scale tile coding.
602 */
603 unsigned int large_scale_tile;
Yaowu Xuf883b422016-08-30 14:01:10 -0700604} aom_codec_enc_cfg_t; /**< alias for struct aom_codec_enc_cfg */
clang-format83a52072016-08-08 20:22:13 -0700605
606/*!\brief Initialize an encoder instance
607 *
608 * Initializes a encoder context using the given interface. Applications
Yaowu Xuf883b422016-08-30 14:01:10 -0700609 * should call the aom_codec_enc_init convenience macro instead of this
clang-format83a52072016-08-08 20:22:13 -0700610 * function directly, to ensure that the ABI version number parameter
611 * is properly initialized.
612 *
613 * If the library was configured with --disable-multithread, this call
614 * is not thread safe and should be guarded with a lock if being used
615 * in a multithreaded context.
616 *
617 * \param[in] ctx Pointer to this instance's context.
618 * \param[in] iface Pointer to the algorithm interface to use.
619 * \param[in] cfg Configuration to use, if known. May be NULL.
Yaowu Xuf883b422016-08-30 14:01:10 -0700620 * \param[in] flags Bitfield of AOM_CODEC_USE_* flags
clang-format83a52072016-08-08 20:22:13 -0700621 * \param[in] ver ABI version number. Must be set to
Yaowu Xuf883b422016-08-30 14:01:10 -0700622 * AOM_ENCODER_ABI_VERSION
623 * \retval #AOM_CODEC_OK
clang-format83a52072016-08-08 20:22:13 -0700624 * The decoder algorithm initialized.
Yaowu Xuf883b422016-08-30 14:01:10 -0700625 * \retval #AOM_CODEC_MEM_ERROR
clang-format83a52072016-08-08 20:22:13 -0700626 * Memory allocation failed.
627 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700628aom_codec_err_t aom_codec_enc_init_ver(aom_codec_ctx_t *ctx,
629 aom_codec_iface_t *iface,
630 const aom_codec_enc_cfg_t *cfg,
631 aom_codec_flags_t flags, int ver);
clang-format83a52072016-08-08 20:22:13 -0700632
Yaowu Xuf883b422016-08-30 14:01:10 -0700633/*!\brief Convenience macro for aom_codec_enc_init_ver()
clang-format83a52072016-08-08 20:22:13 -0700634 *
635 * Ensures the ABI version parameter is properly set.
636 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700637#define aom_codec_enc_init(ctx, iface, cfg, flags) \
638 aom_codec_enc_init_ver(ctx, iface, cfg, flags, AOM_ENCODER_ABI_VERSION)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400639
clang-format83a52072016-08-08 20:22:13 -0700640/*!\brief Initialize multi-encoder instance
641 *
642 * Initializes multi-encoder context using the given interface.
Yaowu Xuf883b422016-08-30 14:01:10 -0700643 * Applications should call the aom_codec_enc_init_multi convenience macro
clang-format83a52072016-08-08 20:22:13 -0700644 * instead of this function directly, to ensure that the ABI version number
645 * parameter is properly initialized.
646 *
647 * \param[in] ctx Pointer to this instance's context.
648 * \param[in] iface Pointer to the algorithm interface to use.
649 * \param[in] cfg Configuration to use, if known. May be NULL.
650 * \param[in] num_enc Total number of encoders.
Yaowu Xuf883b422016-08-30 14:01:10 -0700651 * \param[in] flags Bitfield of AOM_CODEC_USE_* flags
clang-format83a52072016-08-08 20:22:13 -0700652 * \param[in] dsf Pointer to down-sampling factors.
653 * \param[in] ver ABI version number. Must be set to
Yaowu Xuf883b422016-08-30 14:01:10 -0700654 * AOM_ENCODER_ABI_VERSION
655 * \retval #AOM_CODEC_OK
clang-format83a52072016-08-08 20:22:13 -0700656 * The decoder algorithm initialized.
Yaowu Xuf883b422016-08-30 14:01:10 -0700657 * \retval #AOM_CODEC_MEM_ERROR
clang-format83a52072016-08-08 20:22:13 -0700658 * Memory allocation failed.
659 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700660aom_codec_err_t aom_codec_enc_init_multi_ver(
661 aom_codec_ctx_t *ctx, aom_codec_iface_t *iface, aom_codec_enc_cfg_t *cfg,
662 int num_enc, aom_codec_flags_t flags, aom_rational_t *dsf, int ver);
John Koleszar0ea50ce2010-05-18 11:58:33 -0400663
Yaowu Xuf883b422016-08-30 14:01:10 -0700664/*!\brief Convenience macro for aom_codec_enc_init_multi_ver()
clang-format83a52072016-08-08 20:22:13 -0700665 *
666 * Ensures the ABI version parameter is properly set.
667 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700668#define aom_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
669 aom_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
670 AOM_ENCODER_ABI_VERSION)
John Koleszar83b1d902012-11-05 12:37:14 -0800671
clang-format83a52072016-08-08 20:22:13 -0700672/*!\brief Get a default configuration
673 *
674 * Initializes a encoder configuration structure with default values. Supports
675 * the notion of "usages" so that an algorithm may offer different default
676 * settings depending on the user's intended goal. This function \ref SHOULD
677 * be called by all applications to initialize the configuration structure
678 * before specializing the configuration with application specific values.
679 *
680 * \param[in] iface Pointer to the algorithm interface to use.
681 * \param[out] cfg Configuration buffer to populate.
Alex Converse6e3c8052016-12-16 09:48:56 -0800682 * \param[in] reserved Must set to 0.
clang-format83a52072016-08-08 20:22:13 -0700683 *
Yaowu Xuf883b422016-08-30 14:01:10 -0700684 * \retval #AOM_CODEC_OK
clang-format83a52072016-08-08 20:22:13 -0700685 * The configuration was populated.
Yaowu Xuf883b422016-08-30 14:01:10 -0700686 * \retval #AOM_CODEC_INCAPABLE
clang-format83a52072016-08-08 20:22:13 -0700687 * Interface is not an encoder interface.
Yaowu Xuf883b422016-08-30 14:01:10 -0700688 * \retval #AOM_CODEC_INVALID_PARAM
clang-format83a52072016-08-08 20:22:13 -0700689 * A parameter was NULL, or the usage value was not recognized.
690 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700691aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface,
692 aom_codec_enc_cfg_t *cfg,
clang-format83a52072016-08-08 20:22:13 -0700693 unsigned int reserved);
John Koleszar83b1d902012-11-05 12:37:14 -0800694
clang-format83a52072016-08-08 20:22:13 -0700695/*!\brief Set or change configuration
696 *
697 * Reconfigures an encoder instance according to the given configuration.
698 *
699 * \param[in] ctx Pointer to this instance's context
700 * \param[in] cfg Configuration buffer to use
701 *
Yaowu Xuf883b422016-08-30 14:01:10 -0700702 * \retval #AOM_CODEC_OK
clang-format83a52072016-08-08 20:22:13 -0700703 * The configuration was populated.
Yaowu Xuf883b422016-08-30 14:01:10 -0700704 * \retval #AOM_CODEC_INCAPABLE
clang-format83a52072016-08-08 20:22:13 -0700705 * Interface is not an encoder interface.
Yaowu Xuf883b422016-08-30 14:01:10 -0700706 * \retval #AOM_CODEC_INVALID_PARAM
clang-format83a52072016-08-08 20:22:13 -0700707 * A parameter was NULL, or the usage value was not recognized.
708 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700709aom_codec_err_t aom_codec_enc_config_set(aom_codec_ctx_t *ctx,
710 const aom_codec_enc_cfg_t *cfg);
John Koleszar0ea50ce2010-05-18 11:58:33 -0400711
clang-format83a52072016-08-08 20:22:13 -0700712/*!\brief Get global stream headers
713 *
714 * Retrieves a stream level global header packet, if supported by the codec.
715 *
716 * \param[in] ctx Pointer to this instance's context
717 *
718 * \retval NULL
719 * Encoder does not support global header
720 * \retval Non-NULL
721 * Pointer to buffer containing global header packet
722 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700723aom_fixed_buf_t *aom_codec_get_global_headers(aom_codec_ctx_t *ctx);
John Koleszar0ea50ce2010-05-18 11:58:33 -0400724
Yaowu Xuf883b422016-08-30 14:01:10 -0700725/*!\brief deadline parameter analogous to AVx GOOD QUALITY mode. */
726#define AOM_DL_GOOD_QUALITY (1000000)
clang-format83a52072016-08-08 20:22:13 -0700727/*!\brief Encode a frame
728 *
729 * Encodes a video frame at the given "presentation time." The presentation
730 * time stamp (PTS) \ref MUST be strictly increasing.
731 *
732 * The encoder supports the notion of a soft real-time deadline. Given a
733 * non-zero value to the deadline parameter, the encoder will make a "best
734 * effort" guarantee to return before the given time slice expires. It is
735 * implicit that limiting the available time to encode will degrade the
736 * output quality. The encoder can be given an unlimited time to produce the
737 * best possible frame by specifying a deadline of '0'. This deadline
Yaowu Xuf883b422016-08-30 14:01:10 -0700738 * supercedes the AVx notion of "best quality, good quality, realtime".
clang-format83a52072016-08-08 20:22:13 -0700739 * Applications that wish to map these former settings to the new deadline
Thomas Daede80826142017-03-20 15:44:24 -0700740 * based system can use the symbol #AOM_DL_GOOD_QUALITY.
clang-format83a52072016-08-08 20:22:13 -0700741 *
742 * When the last frame has been passed to the encoder, this function should
743 * continue to be called, with the img parameter set to NULL. This will
744 * signal the end-of-stream condition to the encoder and allow it to encode
Yaowu Xuf883b422016-08-30 14:01:10 -0700745 * any held buffers. Encoding is complete when aom_codec_encode() is called
746 * and aom_codec_get_cx_data() returns no data.
clang-format83a52072016-08-08 20:22:13 -0700747 *
748 * \param[in] ctx Pointer to this instance's context
749 * \param[in] img Image data to encode, NULL to flush.
750 * \param[in] pts Presentation time stamp, in timebase units.
751 * \param[in] duration Duration to show frame, in timebase units.
752 * \param[in] flags Flags to use for encoding this frame.
753 * \param[in] deadline Time to spend encoding, in microseconds. (0=infinite)
754 *
Yaowu Xuf883b422016-08-30 14:01:10 -0700755 * \retval #AOM_CODEC_OK
clang-format83a52072016-08-08 20:22:13 -0700756 * The configuration was populated.
Yaowu Xuf883b422016-08-30 14:01:10 -0700757 * \retval #AOM_CODEC_INCAPABLE
clang-format83a52072016-08-08 20:22:13 -0700758 * Interface is not an encoder interface.
Yaowu Xuf883b422016-08-30 14:01:10 -0700759 * \retval #AOM_CODEC_INVALID_PARAM
clang-format83a52072016-08-08 20:22:13 -0700760 * A parameter was NULL, the image format is unsupported, etc.
761 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700762aom_codec_err_t aom_codec_encode(aom_codec_ctx_t *ctx, const aom_image_t *img,
763 aom_codec_pts_t pts, unsigned long duration,
764 aom_enc_frame_flags_t flags,
clang-format83a52072016-08-08 20:22:13 -0700765 unsigned long deadline);
John Koleszar0ea50ce2010-05-18 11:58:33 -0400766
clang-format83a52072016-08-08 20:22:13 -0700767/*!\brief Set compressed data output buffer
768 *
769 * Sets the buffer that the codec should output the compressed data
770 * into. This call effectively sets the buffer pointer returned in the
Yaowu Xuf883b422016-08-30 14:01:10 -0700771 * next AOM_CODEC_CX_FRAME_PKT packet. Subsequent packets will be
clang-format83a52072016-08-08 20:22:13 -0700772 * appended into this buffer. The buffer is preserved across frames,
773 * so applications must periodically call this function after flushing
774 * the accumulated compressed data to disk or to the network to reset
775 * the pointer to the buffer's head.
776 *
777 * `pad_before` bytes will be skipped before writing the compressed
778 * data, and `pad_after` bytes will be appended to the packet. The size
779 * of the packet will be the sum of the size of the actual compressed
780 * data, pad_before, and pad_after. The padding bytes will be preserved
781 * (not overwritten).
782 *
783 * Note that calling this function does not guarantee that the returned
784 * compressed data will be placed into the specified buffer. In the
785 * event that the encoded data will not fit into the buffer provided,
786 * the returned packet \ref MAY point to an internal buffer, as it would
787 * if this call were never used. In this event, the output packet will
788 * NOT have any padding, and the application must free space and copy it
789 * to the proper place. This is of particular note in configurations
790 * that may output multiple packets for a single encoded frame (e.g., lagged
791 * encoding) or if the application does not reset the buffer periodically.
792 *
793 * Applications may restore the default behavior of the codec providing
794 * the compressed data buffer by calling this function with a NULL
795 * buffer.
796 *
797 * Applications \ref MUSTNOT call this function during iteration of
Yaowu Xuf883b422016-08-30 14:01:10 -0700798 * aom_codec_get_cx_data().
clang-format83a52072016-08-08 20:22:13 -0700799 *
800 * \param[in] ctx Pointer to this instance's context
801 * \param[in] buf Buffer to store compressed data into
802 * \param[in] pad_before Bytes to skip before writing compressed data
803 * \param[in] pad_after Bytes to skip after writing compressed data
804 *
Yaowu Xuf883b422016-08-30 14:01:10 -0700805 * \retval #AOM_CODEC_OK
clang-format83a52072016-08-08 20:22:13 -0700806 * The buffer was set successfully.
Yaowu Xuf883b422016-08-30 14:01:10 -0700807 * \retval #AOM_CODEC_INVALID_PARAM
clang-format83a52072016-08-08 20:22:13 -0700808 * A parameter was NULL, the image format is unsupported, etc.
809 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700810aom_codec_err_t aom_codec_set_cx_data_buf(aom_codec_ctx_t *ctx,
811 const aom_fixed_buf_t *buf,
clang-format83a52072016-08-08 20:22:13 -0700812 unsigned int pad_before,
813 unsigned int pad_after);
John Koleszar0ea50ce2010-05-18 11:58:33 -0400814
clang-format83a52072016-08-08 20:22:13 -0700815/*!\brief Encoded data iterator
816 *
817 * Iterates over a list of data packets to be passed from the encoder to the
818 * application. The different kinds of packets available are enumerated in
Yaowu Xuf883b422016-08-30 14:01:10 -0700819 * #aom_codec_cx_pkt_kind.
clang-format83a52072016-08-08 20:22:13 -0700820 *
Yaowu Xuf883b422016-08-30 14:01:10 -0700821 * #AOM_CODEC_CX_FRAME_PKT packets should be passed to the application's
clang-format83a52072016-08-08 20:22:13 -0700822 * muxer. Multiple compressed frames may be in the list.
Yaowu Xuf883b422016-08-30 14:01:10 -0700823 * #AOM_CODEC_STATS_PKT packets should be appended to a global buffer.
clang-format83a52072016-08-08 20:22:13 -0700824 *
825 * The application \ref MUST silently ignore any packet kinds that it does
826 * not recognize or support.
827 *
828 * The data buffers returned from this function are only guaranteed to be
Yaowu Xuf883b422016-08-30 14:01:10 -0700829 * valid until the application makes another call to any aom_codec_* function.
clang-format83a52072016-08-08 20:22:13 -0700830 *
831 * \param[in] ctx Pointer to this instance's context
832 * \param[in,out] iter Iterator storage, initialized to NULL
833 *
834 * \return Returns a pointer to an output data packet (compressed frame data,
835 * two-pass statistics, etc.) or NULL to signal end-of-list.
836 *
837 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700838const aom_codec_cx_pkt_t *aom_codec_get_cx_data(aom_codec_ctx_t *ctx,
839 aom_codec_iter_t *iter);
John Koleszar0ea50ce2010-05-18 11:58:33 -0400840
clang-format83a52072016-08-08 20:22:13 -0700841/*!\brief Get Preview Frame
842 *
843 * Returns an image that can be used as a preview. Shows the image as it would
844 * exist at the decompressor. The application \ref MUST NOT write into this
845 * image buffer.
846 *
847 * \param[in] ctx Pointer to this instance's context
848 *
849 * \return Returns a pointer to a preview image, or NULL if no image is
850 * available.
851 *
852 */
Yaowu Xuf883b422016-08-30 14:01:10 -0700853const aom_image_t *aom_codec_get_preview_frame(aom_codec_ctx_t *ctx);
John Koleszar0ea50ce2010-05-18 11:58:33 -0400854
clang-format83a52072016-08-08 20:22:13 -0700855/*!@} - end defgroup encoder*/
John Koleszar0ea50ce2010-05-18 11:58:33 -0400856#ifdef __cplusplus
857}
858#endif
Yaowu Xuf883b422016-08-30 14:01:10 -0700859#endif // AOM_AOM_ENCODER_H_