michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: #ifndef VP8CX_H michael@0: #define VP8CX_H michael@0: michael@0: /*!\defgroup vp8_encoder WebM VP8 Encoder michael@0: * \ingroup vp8 michael@0: * michael@0: * @{ michael@0: */ michael@0: #include "vp8.h" michael@0: michael@0: /*!\file michael@0: * \brief Provides definitions for using the VP8 encoder algorithm within the michael@0: * vpx Codec Interface. michael@0: */ michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: /*!\name Algorithm interface for VP8 michael@0: * michael@0: * This interface provides the capability to encode raw VP8 streams, as would michael@0: * be found in AVI files. michael@0: * @{ michael@0: */ michael@0: extern vpx_codec_iface_t vpx_codec_vp8_cx_algo; michael@0: extern vpx_codec_iface_t *vpx_codec_vp8_cx(void); michael@0: michael@0: /* TODO(jkoleszar): These move to VP9 in a later patch set. */ michael@0: extern vpx_codec_iface_t vpx_codec_vp9_cx_algo; michael@0: extern vpx_codec_iface_t *vpx_codec_vp9_cx(void); michael@0: extern vpx_codec_iface_t vpx_codec_vp9x_cx_algo; michael@0: extern vpx_codec_iface_t *vpx_codec_vp9x_cx(void); michael@0: michael@0: /*!@} - end algorithm interface member group*/ michael@0: michael@0: michael@0: /* michael@0: * Algorithm Flags michael@0: */ michael@0: michael@0: /*!\brief Don't reference the last frame michael@0: * michael@0: * When this flag is set, the encoder will not use the last frame as a michael@0: * predictor. When not set, the encoder will choose whether to use the michael@0: * last frame or not automatically. michael@0: */ michael@0: #define VP8_EFLAG_NO_REF_LAST (1<<16) michael@0: michael@0: michael@0: /*!\brief Don't reference the golden frame michael@0: * michael@0: * When this flag is set, the encoder will not use the golden frame as a michael@0: * predictor. When not set, the encoder will choose whether to use the michael@0: * golden frame or not automatically. michael@0: */ michael@0: #define VP8_EFLAG_NO_REF_GF (1<<17) michael@0: michael@0: michael@0: /*!\brief Don't reference the alternate reference frame michael@0: * michael@0: * When this flag is set, the encoder will not use the alt ref frame as a michael@0: * predictor. When not set, the encoder will choose whether to use the michael@0: * alt ref frame or not automatically. michael@0: */ michael@0: #define VP8_EFLAG_NO_REF_ARF (1<<21) michael@0: michael@0: michael@0: /*!\brief Don't update the last frame michael@0: * michael@0: * When this flag is set, the encoder will not update the last frame with michael@0: * the contents of the current frame. michael@0: */ michael@0: #define VP8_EFLAG_NO_UPD_LAST (1<<18) michael@0: michael@0: michael@0: /*!\brief Don't update the golden frame michael@0: * michael@0: * When this flag is set, the encoder will not update the golden frame with michael@0: * the contents of the current frame. michael@0: */ michael@0: #define VP8_EFLAG_NO_UPD_GF (1<<22) michael@0: michael@0: michael@0: /*!\brief Don't update the alternate reference frame michael@0: * michael@0: * When this flag is set, the encoder will not update the alt ref frame with michael@0: * the contents of the current frame. michael@0: */ michael@0: #define VP8_EFLAG_NO_UPD_ARF (1<<23) michael@0: michael@0: michael@0: /*!\brief Force golden frame update michael@0: * michael@0: * When this flag is set, the encoder copy the contents of the current frame michael@0: * to the golden frame buffer. michael@0: */ michael@0: #define VP8_EFLAG_FORCE_GF (1<<19) michael@0: michael@0: michael@0: /*!\brief Force alternate reference frame update michael@0: * michael@0: * When this flag is set, the encoder copy the contents of the current frame michael@0: * to the alternate reference frame buffer. michael@0: */ michael@0: #define VP8_EFLAG_FORCE_ARF (1<<24) michael@0: michael@0: michael@0: /*!\brief Disable entropy update michael@0: * michael@0: * When this flag is set, the encoder will not update its internal entropy michael@0: * model based on the entropy of this frame. michael@0: */ michael@0: #define VP8_EFLAG_NO_UPD_ENTROPY (1<<20) michael@0: michael@0: michael@0: /*!\brief VP8 encoder control functions michael@0: * michael@0: * This set of macros define the control functions available for the VP8 michael@0: * encoder interface. michael@0: * michael@0: * \sa #vpx_codec_control michael@0: */ michael@0: enum vp8e_enc_control_id { michael@0: VP8E_UPD_ENTROPY = 5, /**< control function to set mode of entropy update in encoder */ michael@0: VP8E_UPD_REFERENCE, /**< control function to set reference update mode in encoder */ michael@0: VP8E_USE_REFERENCE, /**< control function to set which reference frame encoder can use */ michael@0: VP8E_SET_ROI_MAP, /**< control function to pass an ROI map to encoder */ michael@0: VP8E_SET_ACTIVEMAP, /**< control function to pass an Active map to encoder */ michael@0: VP8E_SET_SCALEMODE = 11, /**< control function to set encoder scaling mode */ michael@0: /*!\brief control function to set vp8 encoder cpuused michael@0: * michael@0: * Changes in this value influences, among others, the encoder's selection michael@0: * of motion estimation methods. Values greater than 0 will increase encoder michael@0: * speed at the expense of quality. michael@0: * The full set of adjustments can be found in michael@0: * onyx_if.c:vp8_set_speed_features(). michael@0: * \todo List highlights of the changes at various levels. michael@0: * michael@0: * \note Valid range: -16..16 michael@0: */ michael@0: VP8E_SET_CPUUSED = 13, michael@0: VP8E_SET_ENABLEAUTOALTREF, /**< control function to enable vp8 to automatic set and use altref frame */ michael@0: VP8E_SET_NOISE_SENSITIVITY, /**< control function to set noise sensitivity */ michael@0: VP8E_SET_SHARPNESS, /**< control function to set sharpness */ michael@0: VP8E_SET_STATIC_THRESHOLD, /**< control function to set the threshold for macroblocks treated static */ michael@0: VP8E_SET_TOKEN_PARTITIONS, /**< control function to set the number of token partitions */ michael@0: VP8E_GET_LAST_QUANTIZER, /**< return the quantizer chosen by the michael@0: encoder for the last frame using the internal michael@0: scale */ michael@0: VP8E_GET_LAST_QUANTIZER_64, /**< return the quantizer chosen by the michael@0: encoder for the last frame, using the 0..63 michael@0: scale as used by the rc_*_quantizer config michael@0: parameters */ michael@0: VP8E_SET_ARNR_MAXFRAMES, /**< control function to set the max number of frames blurred creating arf*/ michael@0: VP8E_SET_ARNR_STRENGTH, /**< control function to set the filter strength for the arf */ michael@0: VP8E_SET_ARNR_TYPE, /**< control function to set the type of filter to use for the arf*/ michael@0: VP8E_SET_TUNING, /**< control function to set visual tuning */ michael@0: /*!\brief control function to set constrained quality level michael@0: * michael@0: * \attention For this value to be used vpx_codec_enc_cfg_t::g_usage must be michael@0: * set to #VPX_CQ. michael@0: * \note Valid range: 0..63 michael@0: */ michael@0: VP8E_SET_CQ_LEVEL, michael@0: michael@0: /*!\brief Max data rate for Intra frames michael@0: * michael@0: * This value controls additional clamping on the maximum size of a michael@0: * keyframe. It is expressed as a percentage of the average michael@0: * per-frame bitrate, with the special (and default) value 0 meaning michael@0: * unlimited, or no additional clamping beyond the codec's built-in michael@0: * algorithm. michael@0: * michael@0: * For example, to allocate no more than 4.5 frames worth of bitrate michael@0: * to a keyframe, set this to 450. michael@0: * michael@0: */ michael@0: VP8E_SET_MAX_INTRA_BITRATE_PCT, michael@0: michael@0: michael@0: /* TODO(jkoleszar): Move to vp9cx.h */ michael@0: VP9E_SET_LOSSLESS, michael@0: VP9E_SET_TILE_COLUMNS, michael@0: VP9E_SET_TILE_ROWS, michael@0: VP9E_SET_FRAME_PARALLEL_DECODING, michael@0: VP9E_SET_AQ_MODE, michael@0: michael@0: VP9E_SET_SVC, michael@0: VP9E_SET_SVC_PARAMETERS michael@0: }; michael@0: michael@0: /*!\brief vpx 1-D scaling mode michael@0: * michael@0: * This set of constants define 1-D vpx scaling modes michael@0: */ michael@0: typedef enum vpx_scaling_mode_1d { michael@0: VP8E_NORMAL = 0, michael@0: VP8E_FOURFIVE = 1, michael@0: VP8E_THREEFIVE = 2, michael@0: VP8E_ONETWO = 3 michael@0: } VPX_SCALING_MODE; michael@0: michael@0: michael@0: /*!\brief vpx region of interest map michael@0: * michael@0: * These defines the data structures for the region of interest map michael@0: * michael@0: */ michael@0: michael@0: typedef struct vpx_roi_map { michael@0: /*! An id between 0 and 3 for each 16x16 region within a frame. */ michael@0: unsigned char *roi_map; michael@0: unsigned int rows; /**< Number of rows. */ michael@0: unsigned int cols; /**< Number of columns. */ michael@0: // TODO(paulwilkins): broken for VP9 which has 8 segments michael@0: // q and loop filter deltas for each segment michael@0: // (see MAX_MB_SEGMENTS) michael@0: int delta_q[4]; /**< Quantizer deltas. */ michael@0: int delta_lf[4]; /**< Loop filter deltas. */ michael@0: /*! Static breakout threshold for each segment. */ michael@0: unsigned int static_threshold[4]; michael@0: } vpx_roi_map_t; michael@0: michael@0: /*!\brief vpx active region map michael@0: * michael@0: * These defines the data structures for active region map michael@0: * michael@0: */ michael@0: michael@0: michael@0: typedef struct vpx_active_map { michael@0: unsigned char *active_map; /**< specify an on (1) or off (0) each 16x16 region within a frame */ michael@0: unsigned int rows; /**< number of rows */ michael@0: unsigned int cols; /**< number of cols */ michael@0: } vpx_active_map_t; michael@0: michael@0: /*!\brief vpx image scaling mode michael@0: * michael@0: * This defines the data structure for image scaling mode michael@0: * michael@0: */ michael@0: typedef struct vpx_scaling_mode { michael@0: VPX_SCALING_MODE h_scaling_mode; /**< horizontal scaling mode */ michael@0: VPX_SCALING_MODE v_scaling_mode; /**< vertical scaling mode */ michael@0: } vpx_scaling_mode_t; michael@0: michael@0: /*!\brief VP8 token partition mode michael@0: * michael@0: * This defines VP8 partitioning mode for compressed data, i.e., the number of michael@0: * sub-streams in the bitstream. Used for parallelized decoding. michael@0: * michael@0: */ michael@0: michael@0: typedef enum { michael@0: VP8_ONE_TOKENPARTITION = 0, michael@0: VP8_TWO_TOKENPARTITION = 1, michael@0: VP8_FOUR_TOKENPARTITION = 2, michael@0: VP8_EIGHT_TOKENPARTITION = 3 michael@0: } vp8e_token_partitions; michael@0: michael@0: michael@0: /*!\brief VP8 model tuning parameters michael@0: * michael@0: * Changes the encoder to tune for certain types of input material. michael@0: * michael@0: */ michael@0: typedef enum { michael@0: VP8_TUNE_PSNR, michael@0: VP8_TUNE_SSIM michael@0: } vp8e_tuning; michael@0: michael@0: /*!\brief vp9 svc parameters michael@0: * michael@0: * This defines parameters for svc encoding. michael@0: * michael@0: */ michael@0: typedef struct vpx_svc_parameters { michael@0: unsigned int width; /**< width of current spatial layer */ michael@0: unsigned int height; /**< height of current spatial layer */ michael@0: int layer; /**< current layer number - 0 = base */ michael@0: int flags; /**< encode frame flags */ michael@0: int max_quantizer; /**< max quantizer for current layer */ michael@0: int min_quantizer; /**< min quantizer for current layer */ michael@0: int distance_from_i_frame; /**< frame number within current gop */ michael@0: int lst_fb_idx; /**< last frame frame buffer index */ michael@0: int gld_fb_idx; /**< golden frame frame buffer index */ michael@0: int alt_fb_idx; /**< alt reference frame frame buffer index */ michael@0: } vpx_svc_parameters_t; michael@0: michael@0: /*!\brief VP8 encoder control function parameter type michael@0: * michael@0: * Defines the data types that VP8E control functions take. Note that michael@0: * additional common controls are defined in vp8.h michael@0: * michael@0: */ michael@0: michael@0: michael@0: /* These controls have been deprecated in favor of the flags parameter to michael@0: * vpx_codec_encode(). See the definition of VP8_EFLAG_* above. michael@0: */ michael@0: VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_UPD_ENTROPY, int) michael@0: VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_UPD_REFERENCE, int) michael@0: VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_USE_REFERENCE, int) michael@0: michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_ROI_MAP, vpx_roi_map_t *) michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_ACTIVEMAP, vpx_active_map_t *) michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_SCALEMODE, vpx_scaling_mode_t *) michael@0: michael@0: VPX_CTRL_USE_TYPE(VP9E_SET_SVC, int) michael@0: VPX_CTRL_USE_TYPE(VP9E_SET_SVC_PARAMETERS, vpx_svc_parameters_t *) michael@0: michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_CPUUSED, int) michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_ENABLEAUTOALTREF, unsigned int) michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_NOISE_SENSITIVITY, unsigned int) michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_SHARPNESS, unsigned int) michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_STATIC_THRESHOLD, unsigned int) michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_TOKEN_PARTITIONS, int) /* vp8e_token_partitions */ michael@0: michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_MAXFRAMES, unsigned int) michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_STRENGTH, unsigned int) michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_TYPE, unsigned int) michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_TUNING, int) /* vp8e_tuning */ michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_CQ_LEVEL, unsigned int) michael@0: michael@0: VPX_CTRL_USE_TYPE(VP9E_SET_TILE_COLUMNS, int) michael@0: VPX_CTRL_USE_TYPE(VP9E_SET_TILE_ROWS, int) michael@0: michael@0: VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER, int *) michael@0: VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER_64, int *) michael@0: michael@0: VPX_CTRL_USE_TYPE(VP8E_SET_MAX_INTRA_BITRATE_PCT, unsigned int) michael@0: michael@0: VPX_CTRL_USE_TYPE(VP9E_SET_LOSSLESS, unsigned int) michael@0: michael@0: VPX_CTRL_USE_TYPE(VP9E_SET_FRAME_PARALLEL_DECODING, unsigned int) michael@0: michael@0: VPX_CTRL_USE_TYPE(VP9E_SET_AQ_MODE, unsigned int) michael@0: michael@0: /*! @} - end defgroup vp8_encoder */ michael@0: #ifdef __cplusplus michael@0: } // extern "C" michael@0: #endif michael@0: michael@0: #endif