Rename a vp9 only control with vp9e prefix
[aom.git] / vpx / vp8cx.h
blob586f08b081bb60d127d74d17dde178457abf566a
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10 #ifndef VPX_VP8CX_H_
11 #define VPX_VP8CX_H_
13 /*!\defgroup vp8_encoder WebM VP8/VP9 Encoder
14 * \ingroup vp8
16 * @{
18 #include "./vp8.h"
20 /*!\file
21 * \brief Provides definitions for using VP8 or VP9 encoder algorithm within the
22 * vpx Codec Interface.
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
29 /*!\name Algorithm interface for VP8
31 * This interface provides the capability to encode raw VP8 streams.
32 * @{
34 extern vpx_codec_iface_t vpx_codec_vp8_cx_algo;
35 extern vpx_codec_iface_t *vpx_codec_vp8_cx(void);
36 /*!@} - end algorithm interface member group*/
38 /*!\name Algorithm interface for VP9
40 * This interface provides the capability to encode raw VP9 streams.
41 * @{
43 extern vpx_codec_iface_t vpx_codec_vp9_cx_algo;
44 extern vpx_codec_iface_t *vpx_codec_vp9_cx(void);
45 /*!@} - end algorithm interface member group*/
49 * Algorithm Flags
52 /*!\brief Don't reference the last frame
54 * When this flag is set, the encoder will not use the last frame as a
55 * predictor. When not set, the encoder will choose whether to use the
56 * last frame or not automatically.
58 #define VP8_EFLAG_NO_REF_LAST (1<<16)
61 /*!\brief Don't reference the golden frame
63 * When this flag is set, the encoder will not use the golden frame as a
64 * predictor. When not set, the encoder will choose whether to use the
65 * golden frame or not automatically.
67 #define VP8_EFLAG_NO_REF_GF (1<<17)
70 /*!\brief Don't reference the alternate reference frame
72 * When this flag is set, the encoder will not use the alt ref frame as a
73 * predictor. When not set, the encoder will choose whether to use the
74 * alt ref frame or not automatically.
76 #define VP8_EFLAG_NO_REF_ARF (1<<21)
79 /*!\brief Don't update the last frame
81 * When this flag is set, the encoder will not update the last frame with
82 * the contents of the current frame.
84 #define VP8_EFLAG_NO_UPD_LAST (1<<18)
87 /*!\brief Don't update the golden frame
89 * When this flag is set, the encoder will not update the golden frame with
90 * the contents of the current frame.
92 #define VP8_EFLAG_NO_UPD_GF (1<<22)
95 /*!\brief Don't update the alternate reference frame
97 * When this flag is set, the encoder will not update the alt ref frame with
98 * the contents of the current frame.
100 #define VP8_EFLAG_NO_UPD_ARF (1<<23)
103 /*!\brief Force golden frame update
105 * When this flag is set, the encoder copy the contents of the current frame
106 * to the golden frame buffer.
108 #define VP8_EFLAG_FORCE_GF (1<<19)
111 /*!\brief Force alternate reference frame update
113 * When this flag is set, the encoder copy the contents of the current frame
114 * to the alternate reference frame buffer.
116 #define VP8_EFLAG_FORCE_ARF (1<<24)
119 /*!\brief Disable entropy update
121 * When this flag is set, the encoder will not update its internal entropy
122 * model based on the entropy of this frame.
124 #define VP8_EFLAG_NO_UPD_ENTROPY (1<<20)
127 /*!\brief VPx encoder control functions
129 * This set of macros define the control functions available for VPx
130 * encoder interface.
132 * \sa #vpx_codec_control
134 enum vp8e_enc_control_id {
135 VP8E_UPD_ENTROPY = 5, /**< control function to set mode of entropy update in encoder */
136 VP8E_UPD_REFERENCE, /**< control function to set reference update mode in encoder */
137 VP8E_USE_REFERENCE, /**< control function to set which reference frame encoder can use */
138 VP8E_SET_ROI_MAP, /**< control function to pass an ROI map to encoder */
139 VP8E_SET_ACTIVEMAP, /**< control function to pass an Active map to encoder */
140 VP8E_SET_SCALEMODE = 11, /**< control function to set encoder scaling mode */
141 /*!\brief control function to set vp8 encoder cpuused
143 * Changes in this value influences, among others, the encoder's selection
144 * of motion estimation methods. Values greater than 0 will increase encoder
145 * speed at the expense of quality.
146 * The full set of adjustments can be found in
147 * onyx_if.c:vp8_set_speed_features().
148 * \todo List highlights of the changes at various levels.
150 * \note Valid range: -16..16
152 VP8E_SET_CPUUSED = 13,
153 VP8E_SET_ENABLEAUTOALTREF, /**< control function to enable vp8 to automatic set and use altref frame */
154 /*!\brief control function to set noise sensitivity
156 * 0: off, 1: OnYOnly, 2: OnYUV,
157 * 3: OnYUVAggressive, 4: Adaptive
159 VP8E_SET_NOISE_SENSITIVITY,
160 VP8E_SET_SHARPNESS, /**< control function to set sharpness */
161 VP8E_SET_STATIC_THRESHOLD, /**< control function to set the threshold for macroblocks treated static */
162 VP8E_SET_TOKEN_PARTITIONS, /**< control function to set the number of token partitions */
163 VP8E_GET_LAST_QUANTIZER, /**< return the quantizer chosen by the
164 encoder for the last frame using the internal
165 scale */
166 VP8E_GET_LAST_QUANTIZER_64, /**< return the quantizer chosen by the
167 encoder for the last frame, using the 0..63
168 scale as used by the rc_*_quantizer config
169 parameters */
170 VP8E_SET_ARNR_MAXFRAMES, /**< control function to set the max number of frames blurred creating arf*/
171 VP8E_SET_ARNR_STRENGTH, //!< control function to set the filter
172 //!< strength for the arf
174 /*!\deprecated control function to set the filter type to use for the arf */
175 VP8E_SET_ARNR_TYPE,
177 VP8E_SET_TUNING, /**< control function to set visual tuning */
178 /*!\brief control function to set constrained quality level
180 * \attention For this value to be used vpx_codec_enc_cfg_t::g_usage must be
181 * set to #VPX_CQ.
182 * \note Valid range: 0..63
184 VP8E_SET_CQ_LEVEL,
186 /*!\brief Max data rate for Intra frames
188 * This value controls additional clamping on the maximum size of a
189 * keyframe. It is expressed as a percentage of the average
190 * per-frame bitrate, with the special (and default) value 0 meaning
191 * unlimited, or no additional clamping beyond the codec's built-in
192 * algorithm.
194 * For example, to allocate no more than 4.5 frames worth of bitrate
195 * to a keyframe, set this to 450.
198 VP8E_SET_MAX_INTRA_BITRATE_PCT,
199 VP8E_SET_FRAME_FLAGS, /**< control function to set reference and update frame flags */
201 /*!\brief Max data rate for Inter frames
203 * This value controls additional clamping on the maximum size of an
204 * inter frame. It is expressed as a percentage of the average
205 * per-frame bitrate, with the special (and default) value 0 meaning
206 * unlimited, or no additional clamping beyond the codec's built-in
207 * algorithm.
209 * For example, to allow no more than 4.5 frames worth of bitrate
210 * to an inter frame, set this to 450.
213 VP8E_SET_MAX_INTER_BITRATE_PCT,
215 /*!\brief Boost percentage for Golden Frame in CBR mode
217 * This value controls the amount of boost given to Golden Frame in
218 * CBR mode. It is expressed as a percentage of the average
219 * per-frame bitrate, with the special (and default) value 0 meaning
220 * the feature is off, i.e., no golden frame boost in CBR mode and
221 * average bitrate target is used.
223 * For example, to allow 100% more bits, i.e, 2X, in a golden frame
224 * than average frame, set this to 100.
226 * Supported in codecs: VP9
228 VP9E_SET_GF_CBR_BOOST_PCT,
230 /*!\brief Codec control function to set the temporal layer id
232 * For temporal scalability: this control allows the application to set the
233 * layer id for each frame to be encoded. Note that this control must be set
234 * for every frame prior to encoding. The usage of this control function
235 * supersedes the internal temporal pattern counter, which is now deprecated.
237 VP8E_SET_TEMPORAL_LAYER_ID,
239 VP8E_SET_SCREEN_CONTENT_MODE, /**<control function to set encoder screen content mode */
241 /*!\brief Codec control function to set lossless encoding mode
243 * VP9 can operate in lossless encoding mode, in which the bitstream
244 * produced will be able to decode and reconstruct a perfect copy of
245 * input source. This control function provides a mean to switch encoder
246 * into lossless coding mode(1) or normal coding mode(0) that may be lossy.
247 * 0 = lossy coding mode
248 * 1 = lossless coding mode
250 * By default, encoder operates in normal coding mode (maybe lossy).
252 VP9E_SET_LOSSLESS,
254 /*!\brief Codec control function to set number of tile columns
256 * In encoding and decoding, VP9 allows an input image frame be partitioned
257 * into separated vertical tile columns, which can be encoded or decoded
258 * independently. This enables easy implementation of parallel encoding and
259 * decoding. This control requests the encoder to use column tiles in
260 * encoding an input frame, with number of tile columns (in Log2 unit) as
261 * the parameter:
262 * 0 = 1 tile column
263 * 1 = 2 tile columns
264 * 2 = 4 tile columns
265 * .....
266 * n = 2**n tile columns
267 * The requested tile columns will be capped by encoder based on image size
268 * limitation (The minimum width of a tile column is 256 pixel, the maximum
269 * is 4096).
271 * By default, the value is 0, i.e. one single column tile for entire image.
273 VP9E_SET_TILE_COLUMNS,
275 /*!\brief Codec control function to set number of tile rows
277 * In encoding and decoding, VP9 allows an input image frame be partitioned
278 * into separated horizontal tile rows. Tile rows are encoded or decoded
279 * sequentially. Even though encoding/decoding of later tile rows depends on
280 * earlier ones, this allows the encoder to output data packets for tile rows
281 * prior to completely processing all tile rows in a frame, thereby reducing
282 * the latency in processing between input and output. The parameter
283 * for this control describes the number of tile rows, which has a valid
284 * range [0, 2]:
285 * 0 = 1 tile row
286 * 1 = 2 tile rows
287 * 2 = 4 tile rows
289 * By default, the value is 0, i.e. one single row tile for entire image.
291 VP9E_SET_TILE_ROWS,
293 /*!\brief Codec control function to enable frame parallel decoding feature
295 * VP9 has a bitstream feature to reduce decoding dependency between frames
296 * by turning off backward update of probability context used in encoding
297 * and decoding. This allows staged parallel processing of more than one
298 * video frames in the decoder. This control function provides a mean to
299 * turn this feature on or off for bitstreams produced by encoder.
301 * By default, this feature is off.
303 VP9E_SET_FRAME_PARALLEL_DECODING,
305 /*!\brief Codec control function to set adaptive quantization mode
307 * VP9 has a segment based feature that allows encoder to adaptively change
308 * quantization parameter for each segment within a frame to improve the
309 * subjective quality. This control makes encoder operate in one of the
310 * several AQ_modes supported.
312 * By default, encoder operates with AQ_Mode 0(adaptive quantization off).
314 VP9E_SET_AQ_MODE,
316 /*!\brief Codec control function to enable/disable periodic Q boost
318 * One VP9 encoder speed feature is to enable quality boost by lowering
319 * frame level Q periodically. This control function provides a mean to
320 * turn on/off this feature.
321 * 0 = off
322 * 1 = on
324 * By default, the encoder is allowed to use this feature for appropriate
325 * encoding modes.
327 VP9E_SET_FRAME_PERIODIC_BOOST,
329 /*!\brief control function to set noise sensitivity
331 * 0: off, 1: OnYOnly
333 VP9E_SET_NOISE_SENSITIVITY,
335 /*!\brief control function to turn on/off SVC in encoder.
336 * \note Return value is VPX_CODEC_INVALID_PARAM if the encoder does not
337 * support SVC in its current encoding mode
338 * 0: off, 1: on
340 VP9E_SET_SVC,
342 /*!\brief control function to set parameters for SVC.
343 * \note Parameters contain min_q, max_q, scaling factor for each of the
344 * SVC layers.
346 VP9E_SET_SVC_PARAMETERS,
348 /*!\brief control function to set svc layer for spatial and temporal.
349 * \note Valid ranges: 0..#vpx_codec_enc_cfg::ss_number_layers for spatial
350 * layer and 0..#vpx_codec_enc_cfg::ts_number_layers for
351 * temporal layer.
353 VP9E_SET_SVC_LAYER_ID,
355 /*!\brief control function to set content type.
356 * \note Valid parameter range:
357 * VP9E_CONTENT_DEFAULT = Regular video content (Default)
358 * VP9E_CONTENT_SCREEN = Screen capture content
360 VP9E_SET_TUNE_CONTENT,
362 /*!\brief control function to get svc layer ID.
363 * \note The layer ID returned is for the data packet from the registered
364 * callback function.
366 VP9E_GET_SVC_LAYER_ID,
368 /*!\brief control function to register callback for getting per layer packet.
369 * \note Parameter for this control function is a structure with a callback
370 * function and a pointer to private data used by the callback.
372 VP9E_REGISTER_CX_CALLBACK,
374 /*!\brief control function to set color space info.
375 * \note Valid ranges: 0..7, default is "UNKNOWN".
376 * 0 = UNKNOWN,
377 * 1 = BT_601
378 * 2 = BT_709
379 * 3 = SMPTE_170
380 * 4 = SMPTE_240
381 * 5 = BT_2020
382 * 6 = RESERVED
383 * 7 = SRGB
385 VP9E_SET_COLOR_SPACE,
388 /*!\brief vpx 1-D scaling mode
390 * This set of constants define 1-D vpx scaling modes
392 typedef enum vpx_scaling_mode_1d {
393 VP8E_NORMAL = 0,
394 VP8E_FOURFIVE = 1,
395 VP8E_THREEFIVE = 2,
396 VP8E_ONETWO = 3
397 } VPX_SCALING_MODE;
400 /*!\brief vpx region of interest map
402 * These defines the data structures for the region of interest map
406 typedef struct vpx_roi_map {
407 /*! An id between 0 and 3 for each 16x16 region within a frame. */
408 unsigned char *roi_map;
409 unsigned int rows; /**< Number of rows. */
410 unsigned int cols; /**< Number of columns. */
411 // TODO(paulwilkins): broken for VP9 which has 8 segments
412 // q and loop filter deltas for each segment
413 // (see MAX_MB_SEGMENTS)
414 int delta_q[4]; /**< Quantizer deltas. */
415 int delta_lf[4]; /**< Loop filter deltas. */
416 /*! Static breakout threshold for each segment. */
417 unsigned int static_threshold[4];
418 } vpx_roi_map_t;
420 /*!\brief vpx active region map
422 * These defines the data structures for active region map
427 typedef struct vpx_active_map {
428 unsigned char *active_map; /**< specify an on (1) or off (0) each 16x16 region within a frame */
429 unsigned int rows; /**< number of rows */
430 unsigned int cols; /**< number of cols */
431 } vpx_active_map_t;
433 /*!\brief vpx image scaling mode
435 * This defines the data structure for image scaling mode
438 typedef struct vpx_scaling_mode {
439 VPX_SCALING_MODE h_scaling_mode; /**< horizontal scaling mode */
440 VPX_SCALING_MODE v_scaling_mode; /**< vertical scaling mode */
441 } vpx_scaling_mode_t;
443 /*!\brief VP8 token partition mode
445 * This defines VP8 partitioning mode for compressed data, i.e., the number of
446 * sub-streams in the bitstream. Used for parallelized decoding.
450 typedef enum {
451 VP8_ONE_TOKENPARTITION = 0,
452 VP8_TWO_TOKENPARTITION = 1,
453 VP8_FOUR_TOKENPARTITION = 2,
454 VP8_EIGHT_TOKENPARTITION = 3
455 } vp8e_token_partitions;
457 /*!brief VP9 encoder content type */
458 typedef enum {
459 VP9E_CONTENT_DEFAULT,
460 VP9E_CONTENT_SCREEN,
461 VP9E_CONTENT_INVALID
462 } vp9e_tune_content;
464 /*!\brief VP8 model tuning parameters
466 * Changes the encoder to tune for certain types of input material.
469 typedef enum {
470 VP8_TUNE_PSNR,
471 VP8_TUNE_SSIM
472 } vp8e_tuning;
474 /*!\brief vp9 svc layer parameters
476 * This defines the spatial and temporal layer id numbers for svc encoding.
477 * This is used with the #VP9E_SET_SVC_LAYER_ID control to set the spatial and
478 * temporal layer id for the current frame.
481 typedef struct vpx_svc_layer_id {
482 int spatial_layer_id; /**< Spatial layer id number. */
483 int temporal_layer_id; /**< Temporal layer id number. */
484 } vpx_svc_layer_id_t;
486 /*!\brief VP8 encoder control function parameter type
488 * Defines the data types that VP8E control functions take. Note that
489 * additional common controls are defined in vp8.h
494 /* These controls have been deprecated in favor of the flags parameter to
495 * vpx_codec_encode(). See the definition of VP8_EFLAG_* above.
497 VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_UPD_ENTROPY, int)
498 VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_UPD_REFERENCE, int)
499 VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_USE_REFERENCE, int)
501 VPX_CTRL_USE_TYPE(VP8E_SET_FRAME_FLAGS, int)
502 VPX_CTRL_USE_TYPE(VP8E_SET_TEMPORAL_LAYER_ID, int)
503 VPX_CTRL_USE_TYPE(VP8E_SET_ROI_MAP, vpx_roi_map_t *)
504 VPX_CTRL_USE_TYPE(VP8E_SET_ACTIVEMAP, vpx_active_map_t *)
505 VPX_CTRL_USE_TYPE(VP8E_SET_SCALEMODE, vpx_scaling_mode_t *)
507 VPX_CTRL_USE_TYPE(VP9E_SET_SVC, int)
508 VPX_CTRL_USE_TYPE(VP9E_SET_SVC_PARAMETERS, void *)
509 VPX_CTRL_USE_TYPE(VP9E_REGISTER_CX_CALLBACK, void *)
510 VPX_CTRL_USE_TYPE(VP9E_SET_SVC_LAYER_ID, vpx_svc_layer_id_t *)
512 VPX_CTRL_USE_TYPE(VP8E_SET_CPUUSED, int)
513 VPX_CTRL_USE_TYPE(VP8E_SET_ENABLEAUTOALTREF, unsigned int)
514 VPX_CTRL_USE_TYPE(VP8E_SET_NOISE_SENSITIVITY, unsigned int)
515 VPX_CTRL_USE_TYPE(VP8E_SET_SHARPNESS, unsigned int)
516 VPX_CTRL_USE_TYPE(VP8E_SET_STATIC_THRESHOLD, unsigned int)
517 VPX_CTRL_USE_TYPE(VP8E_SET_TOKEN_PARTITIONS, int) /* vp8e_token_partitions */
519 VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_MAXFRAMES, unsigned int)
520 VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_STRENGTH, unsigned int)
521 VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_SET_ARNR_TYPE, unsigned int)
522 VPX_CTRL_USE_TYPE(VP8E_SET_TUNING, int) /* vp8e_tuning */
523 VPX_CTRL_USE_TYPE(VP8E_SET_CQ_LEVEL, unsigned int)
525 VPX_CTRL_USE_TYPE(VP9E_SET_TILE_COLUMNS, int)
526 VPX_CTRL_USE_TYPE(VP9E_SET_TILE_ROWS, int)
528 VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER, int *)
529 VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER_64, int *)
530 VPX_CTRL_USE_TYPE(VP9E_GET_SVC_LAYER_ID, vpx_svc_layer_id_t *)
532 VPX_CTRL_USE_TYPE(VP8E_SET_MAX_INTRA_BITRATE_PCT, unsigned int)
533 VPX_CTRL_USE_TYPE(VP8E_SET_MAX_INTER_BITRATE_PCT, unsigned int)
535 VPX_CTRL_USE_TYPE(VP8E_SET_SCREEN_CONTENT_MODE, unsigned int)
537 VPX_CTRL_USE_TYPE(VP9E_SET_GF_CBR_BOOST_PCT, unsigned int)
539 VPX_CTRL_USE_TYPE(VP9E_SET_LOSSLESS, unsigned int)
541 VPX_CTRL_USE_TYPE(VP9E_SET_FRAME_PARALLEL_DECODING, unsigned int)
543 VPX_CTRL_USE_TYPE(VP9E_SET_AQ_MODE, unsigned int)
545 VPX_CTRL_USE_TYPE(VP9E_SET_FRAME_PERIODIC_BOOST, unsigned int)
547 VPX_CTRL_USE_TYPE(VP9E_SET_NOISE_SENSITIVITY, unsigned int)
549 VPX_CTRL_USE_TYPE(VP9E_SET_TUNE_CONTENT, int) /* vp9e_tune_content */
551 VPX_CTRL_USE_TYPE(VP9E_SET_COLOR_SPACE, int)
552 /*! @} - end defgroup vp8_encoder */
553 #ifdef __cplusplus
554 } // extern "C"
555 #endif
557 #endif // VPX_VP8CX_H_