John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 10 | */ |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 11 | #ifndef AOM_AOM_AOM_ENCODER_H_ |
| 12 | #define AOM_AOM_AOM_ENCODER_H_ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 13 | |
| 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 Zern | f42d52e | 2011-02-16 17:54:49 -0800 | [diff] [blame] | 22 | /*!\file |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 23 | * \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 |
| 30 | extern "C" { |
| 31 | #endif |
| 32 | |
Tom Finegan | dd3e2a5 | 2018-05-23 14:33:09 -0700 | [diff] [blame] | 33 | #include "aom/aom_codec.h" |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 34 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 35 | /*!\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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 43 | #define AOM_ENCODER_ABI_VERSION \ |
| 44 | (5 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 45 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 46 | /*! \brief Encoder capabilities bitfield |
| 47 | * |
| 48 | * Each encoder advertises the capabilities it supports as part of its |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 49 | * ::aom_codec_iface_t interface structure. Capabilities are extra |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 50 | * interfaces or functionality, and are not required to be supported |
| 51 | * by an encoder. |
| 52 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 53 | * The available flags are specified by AOM_CODEC_CAP_* defines. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 54 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 55 | #define AOM_CODEC_CAP_PSNR 0x10000 /**< Can issue PSNR packets */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 56 | |
Deb Mukherjee | 5acfafb | 2014-08-26 12:35:15 -0700 | [diff] [blame] | 57 | /*! Can support input images at greater than 8 bitdepth. |
| 58 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 59 | #define AOM_CODEC_CAP_HIGHBITDEPTH 0x40000 |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 60 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 61 | /*! \brief Initialization-time Feature Enabling |
| 62 | * |
| 63 | * Certain codec features must be known at initialization time, to allow |
| 64 | * for proper memory allocation. |
| 65 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 66 | * The available flags are specified by AOM_CODEC_USE_* defines. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 67 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 68 | #define AOM_CODEC_USE_PSNR 0x10000 /**< Calculate PSNR on each frame */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 69 | /*!\brief Make the encoder output one partition at a time. */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 70 | #define AOM_CODEC_USE_HIGHBITDEPTH 0x40000 /**< Use high bitdepth */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 71 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 72 | /*!\brief Generic fixed size buffer structure |
| 73 | * |
| 74 | * This structure is able to hold a reference to any fixed size buffer. |
| 75 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 76 | typedef struct aom_fixed_buf { |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 77 | void *buf; /**< Pointer to the data */ |
| 78 | size_t sz; /**< Length of the buffer, in chars */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 79 | } aom_fixed_buf_t; /**< alias for struct aom_fixed_buf */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 80 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 81 | /*!\brief Time Stamp Type |
| 82 | * |
| 83 | * An integer, which when multiplied by the stream's time base, provides |
| 84 | * the absolute time of a sample. |
| 85 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 86 | typedef int64_t aom_codec_pts_t; |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 87 | |
| 88 | /*!\brief Compressed Frame Flags |
| 89 | * |
| 90 | * This type represents a bitfield containing information about a compressed |
| 91 | * frame that may be useful to an application. The most significant 16 bits |
| 92 | * can be used by an algorithm to provide additional detail, for example to |
| 93 | * support frame types that are codec specific (MPEG-1 D-frames for example) |
| 94 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 95 | typedef uint32_t aom_codec_frame_flags_t; |
| 96 | #define AOM_FRAME_IS_KEY 0x1 /**< frame is the start of a GOP */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 97 | /*!\brief frame can be dropped without affecting the stream (no future frame |
| 98 | * depends on this one) */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 99 | #define AOM_FRAME_IS_DROPPABLE 0x2 |
Debargha Mukherjee | 5737825 | 2018-09-21 18:29:37 -0700 | [diff] [blame] | 100 | /*!\brief this is an INTRA_ONLY frame */ |
| 101 | #define AOM_FRAME_IS_INTRAONLY 0x10 |
| 102 | /*!\brief this is an S-frame */ |
| 103 | #define AOM_FRAME_IS_SWITCH 0x20 |
| 104 | /*!\brief this is an error-resilient frame */ |
| 105 | #define AOM_FRAME_IS_ERROR_RESILIENT 0x40 |
Debargha Mukherjee | 9b21428 | 2018-10-05 13:47:56 -0700 | [diff] [blame] | 106 | /*!\brief this is a key-frame dependent recovery-point frame */ |
| 107 | #define AOM_FRAME_IS_DELAYED_RANDOM_ACCESS_POINT 0x80 |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 108 | |
| 109 | /*!\brief Error Resilient flags |
| 110 | * |
| 111 | * These flags define which error resilient features to enable in the |
| 112 | * encoder. The flags are specified through the |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 113 | * aom_codec_enc_cfg::g_error_resilient variable. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 114 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 115 | typedef uint32_t aom_codec_er_flags_t; |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 116 | /*!\brief Improve resiliency against losses of whole frames */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 117 | #define AOM_ERROR_RESILIENT_DEFAULT 0x1 |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 118 | |
| 119 | /*!\brief Encoder output packet variants |
| 120 | * |
| 121 | * This enumeration lists the different kinds of data packets that can be |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 122 | * returned by calls to aom_codec_get_cx_data(). Algorithms \ref MAY |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 123 | * extend this list to provide additional functionality. |
| 124 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 125 | enum aom_codec_cx_pkt_kind { |
| 126 | AOM_CODEC_CX_FRAME_PKT, /**< Compressed video frame */ |
| 127 | AOM_CODEC_STATS_PKT, /**< Two-pass statistics for this frame */ |
| 128 | AOM_CODEC_FPMB_STATS_PKT, /**< first pass mb statistics for this frame */ |
| 129 | AOM_CODEC_PSNR_PKT, /**< PSNR statistics for this frame */ |
| 130 | AOM_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | /*!\brief Encoder output packet |
| 134 | * |
| 135 | * This structure contains the different kinds of output data the encoder |
| 136 | * may produce while compressing a frame. |
| 137 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 138 | typedef struct aom_codec_cx_pkt { |
| 139 | enum aom_codec_cx_pkt_kind kind; /**< packet variant */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 140 | union { |
| 141 | struct { |
| 142 | void *buf; /**< compressed data buffer */ |
| 143 | size_t sz; /**< length of compressed data */ |
| 144 | /*!\brief time stamp to show frame (in timebase units) */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 145 | aom_codec_pts_t pts; |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 146 | /*!\brief duration to show frame (in timebase units) */ |
| 147 | unsigned long duration; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 148 | aom_codec_frame_flags_t flags; /**< flags for this frame */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 149 | /*!\brief the partition id defines the decoding order of the partitions. |
| 150 | * Only applicable when "output partition" mode is enabled. First |
| 151 | * partition has id 0.*/ |
| 152 | int partition_id; |
sarahparker | 48065fc | 2018-04-06 17:12:54 -0700 | [diff] [blame] | 153 | /*!\brief size of the visible frame in this packet */ |
| 154 | size_t vis_frame_size; |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 155 | } frame; /**< data for compressed frame packet */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 156 | aom_fixed_buf_t twopass_stats; /**< data for two-pass packet */ |
| 157 | aom_fixed_buf_t firstpass_mb_stats; /**< first pass mb packet */ |
| 158 | struct aom_psnr_pkt { |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 159 | unsigned int samples[4]; /**< Number of samples, total/y/u/v */ |
| 160 | uint64_t sse[4]; /**< sum squared error, total/y/u/v */ |
| 161 | double psnr[4]; /**< PSNR, total/y/u/v */ |
| 162 | } psnr; /**< data for PSNR packet */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 163 | aom_fixed_buf_t raw; /**< data for arbitrary packets */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 164 | |
| 165 | /* This packet size is fixed to allow codecs to extend this |
| 166 | * interface without having to manage storage for raw packets, |
| 167 | * i.e., if it's smaller than 128 bytes, you can store in the |
| 168 | * packet list directly. |
| 169 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 170 | char pad[128 - sizeof(enum aom_codec_cx_pkt_kind)]; /**< fixed sz */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 171 | } data; /**< packet data */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 172 | } aom_codec_cx_pkt_t; /**< alias for struct aom_codec_cx_pkt */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 173 | |
| 174 | /*!\brief Rational Number |
| 175 | * |
| 176 | * This structure holds a fractional value. |
| 177 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 178 | typedef struct aom_rational { |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 179 | int num; /**< fraction numerator */ |
| 180 | int den; /**< fraction denominator */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 181 | } aom_rational_t; /**< alias for struct aom_rational */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 182 | |
| 183 | /*!\brief Multi-pass Encoding Pass */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 184 | enum aom_enc_pass { |
| 185 | AOM_RC_ONE_PASS, /**< Single pass mode */ |
| 186 | AOM_RC_FIRST_PASS, /**< First pass of multi-pass mode */ |
| 187 | AOM_RC_LAST_PASS /**< Final pass of multi-pass mode */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 188 | }; |
| 189 | |
| 190 | /*!\brief Rate control mode */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 191 | enum aom_rc_mode { |
| 192 | AOM_VBR, /**< Variable Bit Rate (VBR) mode */ |
| 193 | AOM_CBR, /**< Constant Bit Rate (CBR) mode */ |
| 194 | AOM_CQ, /**< Constrained Quality (CQ) mode */ |
| 195 | AOM_Q, /**< Constant Quality (Q) mode */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 196 | }; |
| 197 | |
| 198 | /*!\brief Keyframe placement mode. |
| 199 | * |
| 200 | * This enumeration determines whether keyframes are placed automatically by |
| 201 | * the encoder or whether this behavior is disabled. Older releases of this |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 202 | * SDK were implemented such that AOM_KF_FIXED meant keyframes were disabled. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 203 | * This name is confusing for this behavior, so the new symbols to be used |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 204 | * are AOM_KF_AUTO and AOM_KF_DISABLED. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 205 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 206 | enum aom_kf_mode { |
| 207 | AOM_KF_FIXED, /**< deprecated, implies AOM_KF_DISABLED */ |
| 208 | AOM_KF_AUTO, /**< Encoder determines optimal placement automatically */ |
| 209 | AOM_KF_DISABLED = 0 /**< Encoder does not place keyframes. */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 210 | }; |
| 211 | |
| 212 | /*!\brief Encoded Frame Flags |
| 213 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 214 | * This type indicates a bitfield to be passed to aom_codec_encode(), defining |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 215 | * per-frame boolean values. By convention, bits common to all codecs will be |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 216 | * named AOM_EFLAG_*, and bits specific to an algorithm will be named |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 217 | * /algo/_eflag_*. The lower order 16 bits are reserved for common use. |
| 218 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 219 | typedef long aom_enc_frame_flags_t; |
| 220 | #define AOM_EFLAG_FORCE_KF (1 << 0) /**< Force this frame to be a keyframe */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 221 | |
| 222 | /*!\brief Encoder configuration structure |
| 223 | * |
| 224 | * This structure contains the encoder settings that have common representations |
| 225 | * across all codecs. This doesn't imply that all codecs support all features, |
| 226 | * however. |
| 227 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 228 | typedef struct aom_codec_enc_cfg { |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 229 | /* |
| 230 | * generic settings (g) |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 231 | */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 232 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 233 | /*!\brief Algorithm specific "usage" value |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 234 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 235 | * Algorithms may define multiple values for usage, which may convey the |
| 236 | * intent of how the application intends to use the stream. If this value |
| 237 | * is non-zero, consult the documentation for the codec to determine its |
| 238 | * meaning. |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 239 | */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 240 | unsigned int g_usage; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 241 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 242 | /*!\brief Maximum number of threads to use |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 243 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 244 | * For multi-threaded implementations, use no more than this number of |
| 245 | * threads. The codec may use fewer threads than allowed. The value |
| 246 | * 0 is equivalent to the value 1. |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 247 | */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 248 | unsigned int g_threads; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 249 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 250 | /*!\brief Bitstream profile to use |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 251 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 252 | * Some codecs support a notion of multiple bitstream profiles. Typically |
| 253 | * this maps to a set of features that are turned on or off. Often the |
| 254 | * profile to use is determined by the features of the intended decoder. |
| 255 | * Consult the documentation for the codec to determine the valid values |
| 256 | * for this parameter, or set to zero for a sane default. |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 257 | */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 258 | unsigned int g_profile; /**< profile of bitstream to use */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 259 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 260 | /*!\brief Width of the frame |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 261 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 262 | * This value identifies the presentation resolution of the frame, |
| 263 | * in pixels. Note that the frames passed as input to the encoder must |
| 264 | * have this resolution. Frames will be presented by the decoder in this |
| 265 | * resolution, independent of any spatial resampling the encoder may do. |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 266 | */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 267 | unsigned int g_w; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 268 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 269 | /*!\brief Height of the frame |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 270 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 271 | * This value identifies the presentation resolution of the frame, |
| 272 | * in pixels. Note that the frames passed as input to the encoder must |
| 273 | * have this resolution. Frames will be presented by the decoder in this |
| 274 | * resolution, independent of any spatial resampling the encoder may do. |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 275 | */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 276 | unsigned int g_h; |
Stefan Holmer | 7296b3f | 2011-06-13 16:42:27 +0200 | [diff] [blame] | 277 | |
Debargha Mukherjee | c6f24c2 | 2018-04-07 08:43:08 -0700 | [diff] [blame] | 278 | /*!\brief Max number of frames to encode |
| 279 | * |
| 280 | */ |
| 281 | unsigned int g_limit; |
| 282 | |
Imdad Sardharwalla | 102c865 | 2018-02-23 16:35:13 +0000 | [diff] [blame] | 283 | /*!\brief Forced maximum width of the frame |
| 284 | * |
| 285 | * If this value is non-zero then it is used to force the maximum frame |
| 286 | * width written in write_sequence_header(). |
| 287 | */ |
| 288 | unsigned int g_forced_max_frame_width; |
| 289 | |
| 290 | /*!\brief Forced maximum height of the frame |
| 291 | * |
| 292 | * If this value is non-zero then it is used to force the maximum frame |
| 293 | * height written in write_sequence_header(). |
| 294 | */ |
| 295 | unsigned int g_forced_max_frame_height; |
| 296 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 297 | /*!\brief Bit-depth of the codec |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 298 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 299 | * This value identifies the bit_depth of the codec, |
| 300 | * Only certain bit-depths are supported as identified in the |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 301 | * aom_bit_depth_t enum. |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 302 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 303 | aom_bit_depth_t g_bit_depth; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 304 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 305 | /*!\brief Bit-depth of the input frames |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 306 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 307 | * This value identifies the bit_depth of the input frames in bits. |
| 308 | * Note that the frames passed as input to the encoder must have |
| 309 | * this bit-depth. |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 310 | */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 311 | unsigned int g_input_bit_depth; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 312 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 313 | /*!\brief Stream timebase units |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 314 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 315 | * Indicates the smallest interval of time, in seconds, used by the stream. |
| 316 | * For fixed frame rate material, or variable frame rate material where |
| 317 | * frames are timed at a multiple of a given clock (ex: video capture), |
| 318 | * the \ref RECOMMENDED method is to set the timebase to the reciprocal |
| 319 | * of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the |
| 320 | * pts to correspond to the frame number, which can be handy. For |
| 321 | * re-encoding video from containers with absolute time timestamps, the |
| 322 | * \ref RECOMMENDED method is to set the timebase to that of the parent |
| 323 | * container or multimedia framework (ex: 1/1000 for ms, as in FLV). |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 324 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 325 | struct aom_rational g_timebase; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 326 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 327 | /*!\brief Enable error resilient modes. |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 328 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 329 | * The error resilient bitfield indicates to the encoder which features |
| 330 | * it should enable to take measures for streaming over lossy or noisy |
| 331 | * links. |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 332 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 333 | aom_codec_er_flags_t g_error_resilient; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 334 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 335 | /*!\brief Multi-pass Encoding Mode |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 336 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 337 | * This value should be set to the current phase for multi-pass encoding. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 338 | * For single pass, set to #AOM_RC_ONE_PASS. |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 339 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 340 | enum aom_enc_pass g_pass; |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 341 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 342 | /*!\brief Allow lagged encoding |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 343 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 344 | * If set, this value allows the encoder to consume a number of input |
| 345 | * frames before producing output frames. This allows the encoder to |
| 346 | * base decisions for the current frame on future frames. This does |
| 347 | * increase the latency of the encoding pipeline, so it is not appropriate |
| 348 | * in all situations (ex: realtime encoding). |
| 349 | * |
| 350 | * Note that this is a maximum value -- the encoder may produce frames |
| 351 | * sooner than the given limit. Set this value to 0 to disable this |
| 352 | * feature. |
John Koleszar | c6b9039 | 2012-07-13 15:21:29 -0700 | [diff] [blame] | 353 | */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 354 | unsigned int g_lag_in_frames; |
| 355 | |
| 356 | /* |
| 357 | * rate control settings (rc) |
| 358 | */ |
| 359 | |
| 360 | /*!\brief Temporal resampling configuration, if supported by the codec. |
| 361 | * |
| 362 | * Temporal resampling allows the codec to "drop" frames as a strategy to |
| 363 | * meet its target data rate. This can cause temporal discontinuities in |
| 364 | * the encoded video, which may appear as stuttering during playback. This |
| 365 | * trade-off is often acceptable, but for many applications is not. It can |
| 366 | * be disabled in these cases. |
| 367 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 368 | * Note that not all codecs support this feature. All aom AVx codecs do. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 369 | * For other codecs, consult the documentation for that algorithm. |
| 370 | * |
| 371 | * This threshold is described as a percentage of the target data buffer. |
| 372 | * When the data buffer falls below this percentage of fullness, a |
| 373 | * dropped frame is indicated. Set the threshold to zero (0) to disable |
| 374 | * this feature. |
| 375 | */ |
| 376 | unsigned int rc_dropframe_thresh; |
| 377 | |
Debargha Mukherjee | 29e40a6 | 2017-06-14 09:37:12 -0700 | [diff] [blame] | 378 | /*!\brief Mode for spatial resampling, if supported by the codec. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 379 | * |
| 380 | * Spatial resampling allows the codec to compress a lower resolution |
Debargha Mukherjee | 29e40a6 | 2017-06-14 09:37:12 -0700 | [diff] [blame] | 381 | * version of the frame, which is then upscaled by the decoder to the |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 382 | * correct presentation resolution. This increases visual quality at |
| 383 | * low data rates, at the expense of CPU time on the encoder/decoder. |
| 384 | */ |
Debargha Mukherjee | 29e40a6 | 2017-06-14 09:37:12 -0700 | [diff] [blame] | 385 | unsigned int rc_resize_mode; |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 386 | |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 387 | /*!\brief Frame resize denominator. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 388 | * |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 389 | * The denominator for resize to use, assuming 8 as the numerator. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 390 | * |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 391 | * Valid denominators are 8 - 16 for now. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 392 | */ |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 393 | unsigned int rc_resize_denominator; |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 394 | |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 395 | /*!\brief Keyframe resize denominator. |
Fergus Simpson | 87cf61b | 2017-06-15 00:50:34 -0700 | [diff] [blame] | 396 | * |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 397 | * The denominator for resize to use, assuming 8 as the numerator. |
Fergus Simpson | 87cf61b | 2017-06-15 00:50:34 -0700 | [diff] [blame] | 398 | * |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 399 | * Valid denominators are 8 - 16 for now. |
Fergus Simpson | 87cf61b | 2017-06-15 00:50:34 -0700 | [diff] [blame] | 400 | */ |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 401 | unsigned int rc_resize_kf_denominator; |
Fergus Simpson | 87cf61b | 2017-06-15 00:50:34 -0700 | [diff] [blame] | 402 | |
Fergus Simpson | c4e7894 | 2017-04-10 14:59:00 -0700 | [diff] [blame] | 403 | /*!\brief Frame super-resolution scaling mode. |
| 404 | * |
| 405 | * Similar to spatial resampling, frame super-resolution integrates |
| 406 | * upscaling after the encode/decode process. Taking control of upscaling and |
| 407 | * using restoration filters should allow it to outperform normal resizing. |
| 408 | * |
Urvang Joshi | 93b779b | 2017-09-26 12:03:51 -0700 | [diff] [blame] | 409 | * Mode 0 is SUPERRES_NONE, mode 1 is SUPERRES_FIXED, mode 2 is |
| 410 | * SUPERRES_RANDOM and mode 3 is SUPERRES_QTHRESH. |
Fergus Simpson | c4e7894 | 2017-04-10 14:59:00 -0700 | [diff] [blame] | 411 | */ |
| 412 | unsigned int rc_superres_mode; |
| 413 | |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 414 | /*!\brief Frame super-resolution denominator. |
Fergus Simpson | c4e7894 | 2017-04-10 14:59:00 -0700 | [diff] [blame] | 415 | * |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 416 | * The denominator for superres to use. If fixed it will only change if the |
Fergus Simpson | c4e7894 | 2017-04-10 14:59:00 -0700 | [diff] [blame] | 417 | * cumulative scale change over resizing and superres is greater than 1/2; |
| 418 | * this forces superres to reduce scaling. |
| 419 | * |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 420 | * Valid denominators are 8 to 16. |
Fergus Simpson | c4e7894 | 2017-04-10 14:59:00 -0700 | [diff] [blame] | 421 | * |
Debargha Mukherjee | 7166f22 | 2017-09-05 21:32:42 -0700 | [diff] [blame] | 422 | * Used only by SUPERRES_FIXED. |
Fergus Simpson | c4e7894 | 2017-04-10 14:59:00 -0700 | [diff] [blame] | 423 | */ |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 424 | unsigned int rc_superres_denominator; |
Fergus Simpson | c4e7894 | 2017-04-10 14:59:00 -0700 | [diff] [blame] | 425 | |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 426 | /*!\brief Keyframe super-resolution denominator. |
Fergus Simpson | 87cf61b | 2017-06-15 00:50:34 -0700 | [diff] [blame] | 427 | * |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 428 | * The denominator for superres to use. If fixed it will only change if the |
Fergus Simpson | 87cf61b | 2017-06-15 00:50:34 -0700 | [diff] [blame] | 429 | * cumulative scale change over resizing and superres is greater than 1/2; |
| 430 | * this forces superres to reduce scaling. |
| 431 | * |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 432 | * Valid denominators are 8 - 16 for now. |
Fergus Simpson | 87cf61b | 2017-06-15 00:50:34 -0700 | [diff] [blame] | 433 | */ |
Urvang Joshi | de71d14 | 2017-10-05 12:12:15 -0700 | [diff] [blame] | 434 | unsigned int rc_superres_kf_denominator; |
Fergus Simpson | 87cf61b | 2017-06-15 00:50:34 -0700 | [diff] [blame] | 435 | |
Debargha Mukherjee | 7166f22 | 2017-09-05 21:32:42 -0700 | [diff] [blame] | 436 | /*!\brief Frame super-resolution q threshold. |
| 437 | * |
| 438 | * The q level threshold after which superres is used. |
| 439 | * Valid values are 1 to 63. |
| 440 | * |
| 441 | * Used only by SUPERRES_QTHRESH |
| 442 | */ |
| 443 | unsigned int rc_superres_qthresh; |
| 444 | |
| 445 | /*!\brief Keyframe super-resolution q threshold. |
| 446 | * |
| 447 | * The q level threshold after which superres is used for key frames. |
| 448 | * Valid values are 1 to 63. |
| 449 | * |
| 450 | * Used only by SUPERRES_QTHRESH |
| 451 | */ |
| 452 | unsigned int rc_superres_kf_qthresh; |
| 453 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 454 | /*!\brief Rate control algorithm to use. |
| 455 | * |
| 456 | * Indicates whether the end usage of this stream is to be streamed over |
| 457 | * a bandwidth constrained link, indicating that Constant Bit Rate (CBR) |
| 458 | * mode should be used, or whether it will be played back on a high |
| 459 | * bandwidth link, as from a local disk, where higher variations in |
| 460 | * bitrate are acceptable. |
| 461 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 462 | enum aom_rc_mode rc_end_usage; |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 463 | |
| 464 | /*!\brief Two-pass stats buffer. |
| 465 | * |
| 466 | * A buffer containing all of the stats packets produced in the first |
| 467 | * pass, concatenated. |
| 468 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 469 | aom_fixed_buf_t rc_twopass_stats_in; |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 470 | |
| 471 | /*!\brief first pass mb stats buffer. |
| 472 | * |
| 473 | * A buffer containing all of the first pass mb stats packets produced |
| 474 | * in the first pass, concatenated. |
| 475 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 476 | aom_fixed_buf_t rc_firstpass_mb_stats_in; |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 477 | |
| 478 | /*!\brief Target data rate |
| 479 | * |
| 480 | * Target bandwidth to use for this stream, in kilobits per second. |
| 481 | */ |
| 482 | unsigned int rc_target_bitrate; |
| 483 | |
| 484 | /* |
| 485 | * quantizer settings |
| 486 | */ |
| 487 | |
| 488 | /*!\brief Minimum (Best Quality) Quantizer |
| 489 | * |
| 490 | * The quantizer is the most direct control over the quality of the |
| 491 | * encoded image. The range of valid values for the quantizer is codec |
| 492 | * specific. Consult the documentation for the codec to determine the |
| 493 | * values to use. To determine the range programmatically, call |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 494 | * aom_codec_enc_config_default() with a usage value of 0. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 495 | */ |
| 496 | unsigned int rc_min_quantizer; |
| 497 | |
| 498 | /*!\brief Maximum (Worst Quality) Quantizer |
| 499 | * |
| 500 | * The quantizer is the most direct control over the quality of the |
| 501 | * encoded image. The range of valid values for the quantizer is codec |
| 502 | * specific. Consult the documentation for the codec to determine the |
| 503 | * values to use. To determine the range programmatically, call |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 504 | * aom_codec_enc_config_default() with a usage value of 0. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 505 | */ |
| 506 | unsigned int rc_max_quantizer; |
| 507 | |
| 508 | /* |
| 509 | * bitrate tolerance |
| 510 | */ |
| 511 | |
| 512 | /*!\brief Rate control adaptation undershoot control |
| 513 | * |
| 514 | * This value, expressed as a percentage of the target bitrate, |
| 515 | * controls the maximum allowed adaptation speed of the codec. |
| 516 | * This factor controls the maximum amount of bits that can |
| 517 | * be subtracted from the target bitrate in order to compensate |
| 518 | * for prior overshoot. |
| 519 | * |
| 520 | * Valid values in the range 0-1000. |
| 521 | */ |
| 522 | unsigned int rc_undershoot_pct; |
| 523 | |
| 524 | /*!\brief Rate control adaptation overshoot control |
| 525 | * |
| 526 | * This value, expressed as a percentage of the target bitrate, |
| 527 | * controls the maximum allowed adaptation speed of the codec. |
| 528 | * This factor controls the maximum amount of bits that can |
| 529 | * be added to the target bitrate in order to compensate for |
| 530 | * prior undershoot. |
| 531 | * |
| 532 | * Valid values in the range 0-1000. |
| 533 | */ |
| 534 | unsigned int rc_overshoot_pct; |
| 535 | |
| 536 | /* |
| 537 | * decoder buffer model parameters |
| 538 | */ |
| 539 | |
| 540 | /*!\brief Decoder Buffer Size |
| 541 | * |
| 542 | * This value indicates the amount of data that may be buffered by the |
| 543 | * decoding application. Note that this value is expressed in units of |
| 544 | * time (milliseconds). For example, a value of 5000 indicates that the |
| 545 | * client will buffer (at least) 5000ms worth of encoded data. Use the |
| 546 | * target bitrate (#rc_target_bitrate) to convert to bits/bytes, if |
| 547 | * necessary. |
| 548 | */ |
| 549 | unsigned int rc_buf_sz; |
| 550 | |
| 551 | /*!\brief Decoder Buffer Initial Size |
| 552 | * |
| 553 | * This value indicates the amount of data that will be buffered by the |
| 554 | * decoding application prior to beginning playback. This value is |
| 555 | * expressed in units of time (milliseconds). Use the target bitrate |
| 556 | * (#rc_target_bitrate) to convert to bits/bytes, if necessary. |
| 557 | */ |
| 558 | unsigned int rc_buf_initial_sz; |
| 559 | |
| 560 | /*!\brief Decoder Buffer Optimal Size |
| 561 | * |
| 562 | * This value indicates the amount of data that the encoder should try |
| 563 | * to maintain in the decoder's buffer. This value is expressed in units |
| 564 | * of time (milliseconds). Use the target bitrate (#rc_target_bitrate) |
| 565 | * to convert to bits/bytes, if necessary. |
| 566 | */ |
| 567 | unsigned int rc_buf_optimal_sz; |
| 568 | |
| 569 | /* |
| 570 | * 2 pass rate control parameters |
| 571 | */ |
| 572 | |
| 573 | /*!\brief Two-pass mode CBR/VBR bias |
| 574 | * |
| 575 | * Bias, expressed on a scale of 0 to 100, for determining target size |
| 576 | * for the current frame. The value 0 indicates the optimal CBR mode |
| 577 | * value should be used. The value 100 indicates the optimal VBR mode |
| 578 | * value should be used. Values in between indicate which way the |
| 579 | * encoder should "lean." |
| 580 | */ |
| 581 | unsigned int rc_2pass_vbr_bias_pct; |
| 582 | |
| 583 | /*!\brief Two-pass mode per-GOP minimum bitrate |
| 584 | * |
| 585 | * This value, expressed as a percentage of the target bitrate, indicates |
| 586 | * the minimum bitrate to be used for a single GOP (aka "section") |
| 587 | */ |
| 588 | unsigned int rc_2pass_vbr_minsection_pct; |
| 589 | |
| 590 | /*!\brief Two-pass mode per-GOP maximum bitrate |
| 591 | * |
| 592 | * This value, expressed as a percentage of the target bitrate, indicates |
| 593 | * the maximum bitrate to be used for a single GOP (aka "section") |
| 594 | */ |
| 595 | unsigned int rc_2pass_vbr_maxsection_pct; |
| 596 | |
| 597 | /* |
| 598 | * keyframing settings (kf) |
| 599 | */ |
| 600 | |
Sarah Parker | 93c0314 | 2018-05-22 13:35:45 -0700 | [diff] [blame] | 601 | /*!\brief Option to enable forward reference key frame |
| 602 | * |
| 603 | */ |
| 604 | int fwd_kf_enabled; |
| 605 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 606 | /*!\brief Keyframe placement mode |
| 607 | * |
| 608 | * This value indicates whether the encoder should place keyframes at a |
| 609 | * fixed interval, or determine the optimal placement automatically |
| 610 | * (as governed by the #kf_min_dist and #kf_max_dist parameters) |
| 611 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 612 | enum aom_kf_mode kf_mode; |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 613 | |
| 614 | /*!\brief Keyframe minimum interval |
| 615 | * |
| 616 | * This value, expressed as a number of frames, prevents the encoder from |
| 617 | * placing a keyframe nearer than kf_min_dist to the previous keyframe. At |
| 618 | * least kf_min_dist frames non-keyframes will be coded before the next |
| 619 | * keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval. |
| 620 | */ |
| 621 | unsigned int kf_min_dist; |
| 622 | |
| 623 | /*!\brief Keyframe maximum interval |
| 624 | * |
| 625 | * This value, expressed as a number of frames, forces the encoder to code |
| 626 | * a keyframe if one has not been coded in the last kf_max_dist frames. |
| 627 | * A value of 0 implies all frames will be keyframes. Set kf_min_dist |
| 628 | * equal to kf_max_dist for a fixed interval. |
| 629 | */ |
| 630 | unsigned int kf_max_dist; |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 631 | |
Tarek AMARA | c981385 | 2018-03-05 18:40:18 -0500 | [diff] [blame] | 632 | /*!\brief sframe interval |
| 633 | * |
| 634 | * This value, expressed as a number of frames, forces the encoder to code |
| 635 | * an S-Frame every sframe_dist frames. |
| 636 | */ |
| 637 | unsigned int sframe_dist; |
| 638 | |
| 639 | /*!\brief sframe insertion mode |
| 640 | * |
| 641 | * This value must be set to 1 or 2, and tells the encoder how to insert |
| 642 | * S-Frames. It will only have an effect if sframe_dist != 0. |
| 643 | * |
| 644 | * If altref is enabled: |
| 645 | * - if sframe_mode == 1, the considered frame will be made into an |
| 646 | * S-Frame only if it is an altref frame |
| 647 | * - if sframe_mode == 2, the next altref frame will be made into an |
| 648 | * S-Frame. |
| 649 | * |
| 650 | * Otherwise: the considered frame will be made into an S-Frame. |
| 651 | */ |
| 652 | unsigned int sframe_mode; |
| 653 | |
Yunqing Wang | eeb08a9 | 2017-07-07 21:25:18 -0700 | [diff] [blame] | 654 | /*!\brief Tile coding mode |
| 655 | * |
| 656 | * This value indicates the tile coding mode. |
| 657 | * A value of 0 implies a normal non-large-scale tile coding. A value of 1 |
| 658 | * implies a large-scale tile coding. |
| 659 | */ |
| 660 | unsigned int large_scale_tile; |
Dominic Symes | 26ad0b2 | 2017-10-01 16:35:13 +0200 | [diff] [blame] | 661 | |
Debargha Mukherjee | f340fec | 2018-01-10 18:12:22 -0800 | [diff] [blame] | 662 | /*!\brief Monochrome mode |
| 663 | * |
| 664 | * If this is nonzero, the encoder will generate a monochrome stream |
| 665 | * with no chroma planes. |
| 666 | */ |
| 667 | unsigned int monochrome; |
| 668 | |
Debargha Mukherjee | 9713ccb | 2018-04-08 19:09:17 -0700 | [diff] [blame] | 669 | /*!\brief full_still_picture_hdr |
| 670 | * |
| 671 | * If this is nonzero, the encoder will generate a full header even for |
| 672 | * still picture encoding. if zero, a reduced header is used for still |
| 673 | * picture. This flag has no effect when a regular video with more than |
| 674 | * a single frame is encoded. |
| 675 | */ |
| 676 | unsigned int full_still_picture_hdr; |
| 677 | |
Soo-Chul Han | 29c46fb | 2018-03-23 16:02:00 -0400 | [diff] [blame] | 678 | /*!\brief Bitstream syntax mode |
| 679 | * |
| 680 | * This value indicates the bitstream syntax mode. |
| 681 | * A value of 0 indicates bitstream is saved as Section 5 bitstream. A value |
| 682 | * of 1 indicates the bitstream is saved in Annex-B format |
| 683 | */ |
| 684 | unsigned int save_as_annexb; |
| 685 | |
Dominic Symes | 26ad0b2 | 2017-10-01 16:35:13 +0200 | [diff] [blame] | 686 | /*!\brief Number of explicit tile widths specified |
| 687 | * |
| 688 | * This value indicates the number of tile widths specified |
| 689 | * A value of 0 implies no tile widths are specified. |
| 690 | * Tile widths are given in the array tile_widths[] |
| 691 | */ |
| 692 | int tile_width_count; |
| 693 | |
| 694 | /*!\brief Number of explicit tile heights specified |
| 695 | * |
| 696 | * This value indicates the number of tile heights specified |
| 697 | * A value of 0 implies no tile heights are specified. |
| 698 | * Tile heights are given in the array tile_heights[] |
| 699 | */ |
| 700 | int tile_height_count; |
| 701 | |
| 702 | /*!\brief Maximum number of tile widths in tile widths array |
| 703 | * |
| 704 | * This define gives the maximum number of elements in the tile_widths array. |
| 705 | */ |
| 706 | #define MAX_TILE_WIDTHS 64 // maximum tile width array length |
| 707 | |
| 708 | /*!\brief Array of specified tile widths |
| 709 | * |
| 710 | * This array specifies tile widths (and may be empty) |
| 711 | * The number of widths specified is given by tile_width_count |
| 712 | */ |
| 713 | int tile_widths[MAX_TILE_WIDTHS]; |
| 714 | |
| 715 | /*!\brief Maximum number of tile heights in tile heights array. |
| 716 | * |
| 717 | * This define gives the maximum number of elements in the tile_heights array. |
| 718 | */ |
| 719 | #define MAX_TILE_HEIGHTS 64 // maximum tile height array length |
| 720 | |
| 721 | /*!\brief Array of specified tile heights |
| 722 | * |
| 723 | * This array specifies tile heights (and may be empty) |
| 724 | * The number of heights specified is given by tile_height_count |
| 725 | */ |
| 726 | int tile_heights[MAX_TILE_HEIGHTS]; |
Maxym Dmytrychenko | cc6e0e1 | 2018-02-05 16:35:37 +0100 | [diff] [blame] | 727 | |
| 728 | /*!\brief Options defined per config file |
| 729 | * |
| 730 | */ |
| 731 | cfg_options_t cfg; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 732 | } aom_codec_enc_cfg_t; /**< alias for struct aom_codec_enc_cfg */ |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 733 | |
| 734 | /*!\brief Initialize an encoder instance |
| 735 | * |
| 736 | * Initializes a encoder context using the given interface. Applications |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 737 | * should call the aom_codec_enc_init convenience macro instead of this |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 738 | * function directly, to ensure that the ABI version number parameter |
| 739 | * is properly initialized. |
| 740 | * |
| 741 | * If the library was configured with --disable-multithread, this call |
| 742 | * is not thread safe and should be guarded with a lock if being used |
| 743 | * in a multithreaded context. |
| 744 | * |
| 745 | * \param[in] ctx Pointer to this instance's context. |
| 746 | * \param[in] iface Pointer to the algorithm interface to use. |
Yaowu Xu | 7d30b4a | 2017-08-02 15:43:19 -0700 | [diff] [blame] | 747 | * \param[in] cfg Configuration to use, if known. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 748 | * \param[in] flags Bitfield of AOM_CODEC_USE_* flags |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 749 | * \param[in] ver ABI version number. Must be set to |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 750 | * AOM_ENCODER_ABI_VERSION |
| 751 | * \retval #AOM_CODEC_OK |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 752 | * The decoder algorithm initialized. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 753 | * \retval #AOM_CODEC_MEM_ERROR |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 754 | * Memory allocation failed. |
| 755 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 756 | aom_codec_err_t aom_codec_enc_init_ver(aom_codec_ctx_t *ctx, |
| 757 | aom_codec_iface_t *iface, |
| 758 | const aom_codec_enc_cfg_t *cfg, |
| 759 | aom_codec_flags_t flags, int ver); |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 760 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 761 | /*!\brief Convenience macro for aom_codec_enc_init_ver() |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 762 | * |
| 763 | * Ensures the ABI version parameter is properly set. |
| 764 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 765 | #define aom_codec_enc_init(ctx, iface, cfg, flags) \ |
| 766 | aom_codec_enc_init_ver(ctx, iface, cfg, flags, AOM_ENCODER_ABI_VERSION) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 767 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 768 | /*!\brief Initialize multi-encoder instance |
| 769 | * |
| 770 | * Initializes multi-encoder context using the given interface. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 771 | * Applications should call the aom_codec_enc_init_multi convenience macro |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 772 | * instead of this function directly, to ensure that the ABI version number |
| 773 | * parameter is properly initialized. |
| 774 | * |
| 775 | * \param[in] ctx Pointer to this instance's context. |
| 776 | * \param[in] iface Pointer to the algorithm interface to use. |
Yaowu Xu | 7d30b4a | 2017-08-02 15:43:19 -0700 | [diff] [blame] | 777 | * \param[in] cfg Configuration to use, if known. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 778 | * \param[in] num_enc Total number of encoders. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 779 | * \param[in] flags Bitfield of AOM_CODEC_USE_* flags |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 780 | * \param[in] dsf Pointer to down-sampling factors. |
| 781 | * \param[in] ver ABI version number. Must be set to |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 782 | * AOM_ENCODER_ABI_VERSION |
| 783 | * \retval #AOM_CODEC_OK |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 784 | * The decoder algorithm initialized. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 785 | * \retval #AOM_CODEC_MEM_ERROR |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 786 | * Memory allocation failed. |
| 787 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 788 | aom_codec_err_t aom_codec_enc_init_multi_ver( |
| 789 | aom_codec_ctx_t *ctx, aom_codec_iface_t *iface, aom_codec_enc_cfg_t *cfg, |
| 790 | int num_enc, aom_codec_flags_t flags, aom_rational_t *dsf, int ver); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 791 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 792 | /*!\brief Convenience macro for aom_codec_enc_init_multi_ver() |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 793 | * |
| 794 | * Ensures the ABI version parameter is properly set. |
| 795 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 796 | #define aom_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \ |
| 797 | aom_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \ |
| 798 | AOM_ENCODER_ABI_VERSION) |
John Koleszar | 83b1d90 | 2012-11-05 12:37:14 -0800 | [diff] [blame] | 799 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 800 | /*!\brief Get a default configuration |
| 801 | * |
| 802 | * Initializes a encoder configuration structure with default values. Supports |
| 803 | * the notion of "usages" so that an algorithm may offer different default |
| 804 | * settings depending on the user's intended goal. This function \ref SHOULD |
| 805 | * be called by all applications to initialize the configuration structure |
| 806 | * before specializing the configuration with application specific values. |
| 807 | * |
| 808 | * \param[in] iface Pointer to the algorithm interface to use. |
| 809 | * \param[out] cfg Configuration buffer to populate. |
Alex Converse | 6e3c805 | 2016-12-16 09:48:56 -0800 | [diff] [blame] | 810 | * \param[in] reserved Must set to 0. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 811 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 812 | * \retval #AOM_CODEC_OK |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 813 | * The configuration was populated. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 814 | * \retval #AOM_CODEC_INCAPABLE |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 815 | * Interface is not an encoder interface. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 816 | * \retval #AOM_CODEC_INVALID_PARAM |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 817 | * A parameter was NULL, or the usage value was not recognized. |
| 818 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 819 | aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface, |
| 820 | aom_codec_enc_cfg_t *cfg, |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 821 | unsigned int reserved); |
John Koleszar | 83b1d90 | 2012-11-05 12:37:14 -0800 | [diff] [blame] | 822 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 823 | /*!\brief Set or change configuration |
| 824 | * |
| 825 | * Reconfigures an encoder instance according to the given configuration. |
| 826 | * |
| 827 | * \param[in] ctx Pointer to this instance's context |
| 828 | * \param[in] cfg Configuration buffer to use |
| 829 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 830 | * \retval #AOM_CODEC_OK |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 831 | * The configuration was populated. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 832 | * \retval #AOM_CODEC_INCAPABLE |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 833 | * Interface is not an encoder interface. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 834 | * \retval #AOM_CODEC_INVALID_PARAM |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 835 | * A parameter was NULL, or the usage value was not recognized. |
| 836 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 837 | aom_codec_err_t aom_codec_enc_config_set(aom_codec_ctx_t *ctx, |
| 838 | const aom_codec_enc_cfg_t *cfg); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 839 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 840 | /*!\brief Get global stream headers |
| 841 | * |
| 842 | * Retrieves a stream level global header packet, if supported by the codec. |
Tom Finegan | f8d6a16 | 2018-08-21 10:47:55 -0700 | [diff] [blame] | 843 | * Calls to this function should be deferred until all configuration information |
| 844 | * has been passed to libaom. Otherwise the global header data may be |
| 845 | * invalidated by additional configuration changes. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 846 | * |
Tom Finegan | ca1e28f | 2018-08-28 16:55:35 -0700 | [diff] [blame] | 847 | * The AV1 implementation of this function returns an OBU. The OBU returned is |
| 848 | * in Low Overhead Bitstream Format. Specifically, the obu_has_size_field bit is |
| 849 | * set, and the buffer contains the obu_size field for the returned OBU. |
| 850 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 851 | * \param[in] ctx Pointer to this instance's context |
| 852 | * |
| 853 | * \retval NULL |
Tom Finegan | f8d6a16 | 2018-08-21 10:47:55 -0700 | [diff] [blame] | 854 | * Encoder does not support global header, or an error occurred while |
| 855 | * generating the global header. |
Tom Finegan | ca1e28f | 2018-08-28 16:55:35 -0700 | [diff] [blame] | 856 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 857 | * \retval Non-NULL |
Tom Finegan | f8d6a16 | 2018-08-21 10:47:55 -0700 | [diff] [blame] | 858 | * Pointer to buffer containing global header packet. The caller owns the |
Tom Finegan | ca1e28f | 2018-08-28 16:55:35 -0700 | [diff] [blame] | 859 | * memory associated with this buffer, and must free the 'buf' member of the |
| 860 | * aom_fixed_buf_t as well as the aom_fixed_buf_t pointer. Memory returned |
| 861 | * must be freed via call to free(). |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 862 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 863 | aom_fixed_buf_t *aom_codec_get_global_headers(aom_codec_ctx_t *ctx); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 864 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 865 | /*!\brief Encode a frame |
| 866 | * |
| 867 | * Encodes a video frame at the given "presentation time." The presentation |
| 868 | * time stamp (PTS) \ref MUST be strictly increasing. |
| 869 | * |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 870 | * When the last frame has been passed to the encoder, this function should |
| 871 | * continue to be called, with the img parameter set to NULL. This will |
| 872 | * signal the end-of-stream condition to the encoder and allow it to encode |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 873 | * any held buffers. Encoding is complete when aom_codec_encode() is called |
| 874 | * and aom_codec_get_cx_data() returns no data. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 875 | * |
| 876 | * \param[in] ctx Pointer to this instance's context |
| 877 | * \param[in] img Image data to encode, NULL to flush. |
| 878 | * \param[in] pts Presentation time stamp, in timebase units. |
| 879 | * \param[in] duration Duration to show frame, in timebase units. |
| 880 | * \param[in] flags Flags to use for encoding this frame. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 881 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 882 | * \retval #AOM_CODEC_OK |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 883 | * The configuration was populated. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 884 | * \retval #AOM_CODEC_INCAPABLE |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 885 | * Interface is not an encoder interface. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 886 | * \retval #AOM_CODEC_INVALID_PARAM |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 887 | * A parameter was NULL, the image format is unsupported, etc. |
| 888 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 889 | aom_codec_err_t aom_codec_encode(aom_codec_ctx_t *ctx, const aom_image_t *img, |
| 890 | aom_codec_pts_t pts, unsigned long duration, |
Sean DuBois | 47cc255 | 2018-01-23 07:44:16 +0000 | [diff] [blame] | 891 | aom_enc_frame_flags_t flags); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 892 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 893 | /*!\brief Set compressed data output buffer |
| 894 | * |
| 895 | * Sets the buffer that the codec should output the compressed data |
| 896 | * into. This call effectively sets the buffer pointer returned in the |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 897 | * next AOM_CODEC_CX_FRAME_PKT packet. Subsequent packets will be |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 898 | * appended into this buffer. The buffer is preserved across frames, |
| 899 | * so applications must periodically call this function after flushing |
| 900 | * the accumulated compressed data to disk or to the network to reset |
| 901 | * the pointer to the buffer's head. |
| 902 | * |
| 903 | * `pad_before` bytes will be skipped before writing the compressed |
| 904 | * data, and `pad_after` bytes will be appended to the packet. The size |
| 905 | * of the packet will be the sum of the size of the actual compressed |
| 906 | * data, pad_before, and pad_after. The padding bytes will be preserved |
| 907 | * (not overwritten). |
| 908 | * |
| 909 | * Note that calling this function does not guarantee that the returned |
| 910 | * compressed data will be placed into the specified buffer. In the |
| 911 | * event that the encoded data will not fit into the buffer provided, |
| 912 | * the returned packet \ref MAY point to an internal buffer, as it would |
| 913 | * if this call were never used. In this event, the output packet will |
| 914 | * NOT have any padding, and the application must free space and copy it |
| 915 | * to the proper place. This is of particular note in configurations |
| 916 | * that may output multiple packets for a single encoded frame (e.g., lagged |
| 917 | * encoding) or if the application does not reset the buffer periodically. |
| 918 | * |
| 919 | * Applications may restore the default behavior of the codec providing |
| 920 | * the compressed data buffer by calling this function with a NULL |
| 921 | * buffer. |
| 922 | * |
| 923 | * Applications \ref MUSTNOT call this function during iteration of |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 924 | * aom_codec_get_cx_data(). |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 925 | * |
| 926 | * \param[in] ctx Pointer to this instance's context |
| 927 | * \param[in] buf Buffer to store compressed data into |
| 928 | * \param[in] pad_before Bytes to skip before writing compressed data |
| 929 | * \param[in] pad_after Bytes to skip after writing compressed data |
| 930 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 931 | * \retval #AOM_CODEC_OK |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 932 | * The buffer was set successfully. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 933 | * \retval #AOM_CODEC_INVALID_PARAM |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 934 | * A parameter was NULL, the image format is unsupported, etc. |
| 935 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 936 | aom_codec_err_t aom_codec_set_cx_data_buf(aom_codec_ctx_t *ctx, |
| 937 | const aom_fixed_buf_t *buf, |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 938 | unsigned int pad_before, |
| 939 | unsigned int pad_after); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 940 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 941 | /*!\brief Encoded data iterator |
| 942 | * |
| 943 | * Iterates over a list of data packets to be passed from the encoder to the |
| 944 | * application. The different kinds of packets available are enumerated in |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 945 | * #aom_codec_cx_pkt_kind. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 946 | * |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 947 | * #AOM_CODEC_CX_FRAME_PKT packets should be passed to the application's |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 948 | * muxer. Multiple compressed frames may be in the list. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 949 | * #AOM_CODEC_STATS_PKT packets should be appended to a global buffer. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 950 | * |
| 951 | * The application \ref MUST silently ignore any packet kinds that it does |
| 952 | * not recognize or support. |
| 953 | * |
| 954 | * The data buffers returned from this function are only guaranteed to be |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 955 | * valid until the application makes another call to any aom_codec_* function. |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 956 | * |
| 957 | * \param[in] ctx Pointer to this instance's context |
| 958 | * \param[in,out] iter Iterator storage, initialized to NULL |
| 959 | * |
| 960 | * \return Returns a pointer to an output data packet (compressed frame data, |
| 961 | * two-pass statistics, etc.) or NULL to signal end-of-list. |
| 962 | * |
| 963 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 964 | const aom_codec_cx_pkt_t *aom_codec_get_cx_data(aom_codec_ctx_t *ctx, |
| 965 | aom_codec_iter_t *iter); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 966 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 967 | /*!\brief Get Preview Frame |
| 968 | * |
| 969 | * Returns an image that can be used as a preview. Shows the image as it would |
| 970 | * exist at the decompressor. The application \ref MUST NOT write into this |
| 971 | * image buffer. |
| 972 | * |
| 973 | * \param[in] ctx Pointer to this instance's context |
| 974 | * |
| 975 | * \return Returns a pointer to a preview image, or NULL if no image is |
| 976 | * available. |
| 977 | * |
| 978 | */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 979 | const aom_image_t *aom_codec_get_preview_frame(aom_codec_ctx_t *ctx); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 980 | |
clang-format | 83a5207 | 2016-08-08 20:22:13 -0700 | [diff] [blame] | 981 | /*!@} - end defgroup encoder*/ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 982 | #ifdef __cplusplus |
| 983 | } |
| 984 | #endif |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 985 | #endif // AOM_AOM_AOM_ENCODER_H_ |