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