1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vpx/vp8cx.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,354 @@ 1.4 +/* 1.5 + * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 +#ifndef VP8CX_H 1.14 +#define VP8CX_H 1.15 + 1.16 +/*!\defgroup vp8_encoder WebM VP8 Encoder 1.17 + * \ingroup vp8 1.18 + * 1.19 + * @{ 1.20 + */ 1.21 +#include "vp8.h" 1.22 + 1.23 +/*!\file 1.24 + * \brief Provides definitions for using the VP8 encoder algorithm within the 1.25 + * vpx Codec Interface. 1.26 + */ 1.27 + 1.28 +#ifdef __cplusplus 1.29 +extern "C" { 1.30 +#endif 1.31 + 1.32 +/*!\name Algorithm interface for VP8 1.33 + * 1.34 + * This interface provides the capability to encode raw VP8 streams, as would 1.35 + * be found in AVI files. 1.36 + * @{ 1.37 + */ 1.38 +extern vpx_codec_iface_t vpx_codec_vp8_cx_algo; 1.39 +extern vpx_codec_iface_t *vpx_codec_vp8_cx(void); 1.40 + 1.41 +/* TODO(jkoleszar): These move to VP9 in a later patch set. */ 1.42 +extern vpx_codec_iface_t vpx_codec_vp9_cx_algo; 1.43 +extern vpx_codec_iface_t *vpx_codec_vp9_cx(void); 1.44 +extern vpx_codec_iface_t vpx_codec_vp9x_cx_algo; 1.45 +extern vpx_codec_iface_t *vpx_codec_vp9x_cx(void); 1.46 + 1.47 +/*!@} - end algorithm interface member group*/ 1.48 + 1.49 + 1.50 +/* 1.51 + * Algorithm Flags 1.52 + */ 1.53 + 1.54 +/*!\brief Don't reference the last frame 1.55 + * 1.56 + * When this flag is set, the encoder will not use the last frame as a 1.57 + * predictor. When not set, the encoder will choose whether to use the 1.58 + * last frame or not automatically. 1.59 + */ 1.60 +#define VP8_EFLAG_NO_REF_LAST (1<<16) 1.61 + 1.62 + 1.63 +/*!\brief Don't reference the golden frame 1.64 + * 1.65 + * When this flag is set, the encoder will not use the golden frame as a 1.66 + * predictor. When not set, the encoder will choose whether to use the 1.67 + * golden frame or not automatically. 1.68 + */ 1.69 +#define VP8_EFLAG_NO_REF_GF (1<<17) 1.70 + 1.71 + 1.72 +/*!\brief Don't reference the alternate reference frame 1.73 + * 1.74 + * When this flag is set, the encoder will not use the alt ref frame as a 1.75 + * predictor. When not set, the encoder will choose whether to use the 1.76 + * alt ref frame or not automatically. 1.77 + */ 1.78 +#define VP8_EFLAG_NO_REF_ARF (1<<21) 1.79 + 1.80 + 1.81 +/*!\brief Don't update the last frame 1.82 + * 1.83 + * When this flag is set, the encoder will not update the last frame with 1.84 + * the contents of the current frame. 1.85 + */ 1.86 +#define VP8_EFLAG_NO_UPD_LAST (1<<18) 1.87 + 1.88 + 1.89 +/*!\brief Don't update the golden frame 1.90 + * 1.91 + * When this flag is set, the encoder will not update the golden frame with 1.92 + * the contents of the current frame. 1.93 + */ 1.94 +#define VP8_EFLAG_NO_UPD_GF (1<<22) 1.95 + 1.96 + 1.97 +/*!\brief Don't update the alternate reference frame 1.98 + * 1.99 + * When this flag is set, the encoder will not update the alt ref frame with 1.100 + * the contents of the current frame. 1.101 + */ 1.102 +#define VP8_EFLAG_NO_UPD_ARF (1<<23) 1.103 + 1.104 + 1.105 +/*!\brief Force golden frame update 1.106 + * 1.107 + * When this flag is set, the encoder copy the contents of the current frame 1.108 + * to the golden frame buffer. 1.109 + */ 1.110 +#define VP8_EFLAG_FORCE_GF (1<<19) 1.111 + 1.112 + 1.113 +/*!\brief Force alternate reference frame update 1.114 + * 1.115 + * When this flag is set, the encoder copy the contents of the current frame 1.116 + * to the alternate reference frame buffer. 1.117 + */ 1.118 +#define VP8_EFLAG_FORCE_ARF (1<<24) 1.119 + 1.120 + 1.121 +/*!\brief Disable entropy update 1.122 + * 1.123 + * When this flag is set, the encoder will not update its internal entropy 1.124 + * model based on the entropy of this frame. 1.125 + */ 1.126 +#define VP8_EFLAG_NO_UPD_ENTROPY (1<<20) 1.127 + 1.128 + 1.129 +/*!\brief VP8 encoder control functions 1.130 + * 1.131 + * This set of macros define the control functions available for the VP8 1.132 + * encoder interface. 1.133 + * 1.134 + * \sa #vpx_codec_control 1.135 + */ 1.136 +enum vp8e_enc_control_id { 1.137 + VP8E_UPD_ENTROPY = 5, /**< control function to set mode of entropy update in encoder */ 1.138 + VP8E_UPD_REFERENCE, /**< control function to set reference update mode in encoder */ 1.139 + VP8E_USE_REFERENCE, /**< control function to set which reference frame encoder can use */ 1.140 + VP8E_SET_ROI_MAP, /**< control function to pass an ROI map to encoder */ 1.141 + VP8E_SET_ACTIVEMAP, /**< control function to pass an Active map to encoder */ 1.142 + VP8E_SET_SCALEMODE = 11, /**< control function to set encoder scaling mode */ 1.143 + /*!\brief control function to set vp8 encoder cpuused 1.144 + * 1.145 + * Changes in this value influences, among others, the encoder's selection 1.146 + * of motion estimation methods. Values greater than 0 will increase encoder 1.147 + * speed at the expense of quality. 1.148 + * The full set of adjustments can be found in 1.149 + * onyx_if.c:vp8_set_speed_features(). 1.150 + * \todo List highlights of the changes at various levels. 1.151 + * 1.152 + * \note Valid range: -16..16 1.153 + */ 1.154 + VP8E_SET_CPUUSED = 13, 1.155 + VP8E_SET_ENABLEAUTOALTREF, /**< control function to enable vp8 to automatic set and use altref frame */ 1.156 + VP8E_SET_NOISE_SENSITIVITY, /**< control function to set noise sensitivity */ 1.157 + VP8E_SET_SHARPNESS, /**< control function to set sharpness */ 1.158 + VP8E_SET_STATIC_THRESHOLD, /**< control function to set the threshold for macroblocks treated static */ 1.159 + VP8E_SET_TOKEN_PARTITIONS, /**< control function to set the number of token partitions */ 1.160 + VP8E_GET_LAST_QUANTIZER, /**< return the quantizer chosen by the 1.161 + encoder for the last frame using the internal 1.162 + scale */ 1.163 + VP8E_GET_LAST_QUANTIZER_64, /**< return the quantizer chosen by the 1.164 + encoder for the last frame, using the 0..63 1.165 + scale as used by the rc_*_quantizer config 1.166 + parameters */ 1.167 + VP8E_SET_ARNR_MAXFRAMES, /**< control function to set the max number of frames blurred creating arf*/ 1.168 + VP8E_SET_ARNR_STRENGTH, /**< control function to set the filter strength for the arf */ 1.169 + VP8E_SET_ARNR_TYPE, /**< control function to set the type of filter to use for the arf*/ 1.170 + VP8E_SET_TUNING, /**< control function to set visual tuning */ 1.171 + /*!\brief control function to set constrained quality level 1.172 + * 1.173 + * \attention For this value to be used vpx_codec_enc_cfg_t::g_usage must be 1.174 + * set to #VPX_CQ. 1.175 + * \note Valid range: 0..63 1.176 + */ 1.177 + VP8E_SET_CQ_LEVEL, 1.178 + 1.179 + /*!\brief Max data rate for Intra frames 1.180 + * 1.181 + * This value controls additional clamping on the maximum size of a 1.182 + * keyframe. It is expressed as a percentage of the average 1.183 + * per-frame bitrate, with the special (and default) value 0 meaning 1.184 + * unlimited, or no additional clamping beyond the codec's built-in 1.185 + * algorithm. 1.186 + * 1.187 + * For example, to allocate no more than 4.5 frames worth of bitrate 1.188 + * to a keyframe, set this to 450. 1.189 + * 1.190 + */ 1.191 + VP8E_SET_MAX_INTRA_BITRATE_PCT, 1.192 + 1.193 + 1.194 + /* TODO(jkoleszar): Move to vp9cx.h */ 1.195 + VP9E_SET_LOSSLESS, 1.196 + VP9E_SET_TILE_COLUMNS, 1.197 + VP9E_SET_TILE_ROWS, 1.198 + VP9E_SET_FRAME_PARALLEL_DECODING, 1.199 + VP9E_SET_AQ_MODE, 1.200 + 1.201 + VP9E_SET_SVC, 1.202 + VP9E_SET_SVC_PARAMETERS 1.203 +}; 1.204 + 1.205 +/*!\brief vpx 1-D scaling mode 1.206 + * 1.207 + * This set of constants define 1-D vpx scaling modes 1.208 + */ 1.209 +typedef enum vpx_scaling_mode_1d { 1.210 + VP8E_NORMAL = 0, 1.211 + VP8E_FOURFIVE = 1, 1.212 + VP8E_THREEFIVE = 2, 1.213 + VP8E_ONETWO = 3 1.214 +} VPX_SCALING_MODE; 1.215 + 1.216 + 1.217 +/*!\brief vpx region of interest map 1.218 + * 1.219 + * These defines the data structures for the region of interest map 1.220 + * 1.221 + */ 1.222 + 1.223 +typedef struct vpx_roi_map { 1.224 + /*! An id between 0 and 3 for each 16x16 region within a frame. */ 1.225 + unsigned char *roi_map; 1.226 + unsigned int rows; /**< Number of rows. */ 1.227 + unsigned int cols; /**< Number of columns. */ 1.228 + // TODO(paulwilkins): broken for VP9 which has 8 segments 1.229 + // q and loop filter deltas for each segment 1.230 + // (see MAX_MB_SEGMENTS) 1.231 + int delta_q[4]; /**< Quantizer deltas. */ 1.232 + int delta_lf[4]; /**< Loop filter deltas. */ 1.233 + /*! Static breakout threshold for each segment. */ 1.234 + unsigned int static_threshold[4]; 1.235 +} vpx_roi_map_t; 1.236 + 1.237 +/*!\brief vpx active region map 1.238 + * 1.239 + * These defines the data structures for active region map 1.240 + * 1.241 + */ 1.242 + 1.243 + 1.244 +typedef struct vpx_active_map { 1.245 + unsigned char *active_map; /**< specify an on (1) or off (0) each 16x16 region within a frame */ 1.246 + unsigned int rows; /**< number of rows */ 1.247 + unsigned int cols; /**< number of cols */ 1.248 +} vpx_active_map_t; 1.249 + 1.250 +/*!\brief vpx image scaling mode 1.251 + * 1.252 + * This defines the data structure for image scaling mode 1.253 + * 1.254 + */ 1.255 +typedef struct vpx_scaling_mode { 1.256 + VPX_SCALING_MODE h_scaling_mode; /**< horizontal scaling mode */ 1.257 + VPX_SCALING_MODE v_scaling_mode; /**< vertical scaling mode */ 1.258 +} vpx_scaling_mode_t; 1.259 + 1.260 +/*!\brief VP8 token partition mode 1.261 + * 1.262 + * This defines VP8 partitioning mode for compressed data, i.e., the number of 1.263 + * sub-streams in the bitstream. Used for parallelized decoding. 1.264 + * 1.265 + */ 1.266 + 1.267 +typedef enum { 1.268 + VP8_ONE_TOKENPARTITION = 0, 1.269 + VP8_TWO_TOKENPARTITION = 1, 1.270 + VP8_FOUR_TOKENPARTITION = 2, 1.271 + VP8_EIGHT_TOKENPARTITION = 3 1.272 +} vp8e_token_partitions; 1.273 + 1.274 + 1.275 +/*!\brief VP8 model tuning parameters 1.276 + * 1.277 + * Changes the encoder to tune for certain types of input material. 1.278 + * 1.279 + */ 1.280 +typedef enum { 1.281 + VP8_TUNE_PSNR, 1.282 + VP8_TUNE_SSIM 1.283 +} vp8e_tuning; 1.284 + 1.285 +/*!\brief vp9 svc parameters 1.286 + * 1.287 + * This defines parameters for svc encoding. 1.288 + * 1.289 + */ 1.290 +typedef struct vpx_svc_parameters { 1.291 + unsigned int width; /**< width of current spatial layer */ 1.292 + unsigned int height; /**< height of current spatial layer */ 1.293 + int layer; /**< current layer number - 0 = base */ 1.294 + int flags; /**< encode frame flags */ 1.295 + int max_quantizer; /**< max quantizer for current layer */ 1.296 + int min_quantizer; /**< min quantizer for current layer */ 1.297 + int distance_from_i_frame; /**< frame number within current gop */ 1.298 + int lst_fb_idx; /**< last frame frame buffer index */ 1.299 + int gld_fb_idx; /**< golden frame frame buffer index */ 1.300 + int alt_fb_idx; /**< alt reference frame frame buffer index */ 1.301 +} vpx_svc_parameters_t; 1.302 + 1.303 +/*!\brief VP8 encoder control function parameter type 1.304 + * 1.305 + * Defines the data types that VP8E control functions take. Note that 1.306 + * additional common controls are defined in vp8.h 1.307 + * 1.308 + */ 1.309 + 1.310 + 1.311 +/* These controls have been deprecated in favor of the flags parameter to 1.312 + * vpx_codec_encode(). See the definition of VP8_EFLAG_* above. 1.313 + */ 1.314 +VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_UPD_ENTROPY, int) 1.315 +VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_UPD_REFERENCE, int) 1.316 +VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_USE_REFERENCE, int) 1.317 + 1.318 +VPX_CTRL_USE_TYPE(VP8E_SET_ROI_MAP, vpx_roi_map_t *) 1.319 +VPX_CTRL_USE_TYPE(VP8E_SET_ACTIVEMAP, vpx_active_map_t *) 1.320 +VPX_CTRL_USE_TYPE(VP8E_SET_SCALEMODE, vpx_scaling_mode_t *) 1.321 + 1.322 +VPX_CTRL_USE_TYPE(VP9E_SET_SVC, int) 1.323 +VPX_CTRL_USE_TYPE(VP9E_SET_SVC_PARAMETERS, vpx_svc_parameters_t *) 1.324 + 1.325 +VPX_CTRL_USE_TYPE(VP8E_SET_CPUUSED, int) 1.326 +VPX_CTRL_USE_TYPE(VP8E_SET_ENABLEAUTOALTREF, unsigned int) 1.327 +VPX_CTRL_USE_TYPE(VP8E_SET_NOISE_SENSITIVITY, unsigned int) 1.328 +VPX_CTRL_USE_TYPE(VP8E_SET_SHARPNESS, unsigned int) 1.329 +VPX_CTRL_USE_TYPE(VP8E_SET_STATIC_THRESHOLD, unsigned int) 1.330 +VPX_CTRL_USE_TYPE(VP8E_SET_TOKEN_PARTITIONS, int) /* vp8e_token_partitions */ 1.331 + 1.332 +VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_MAXFRAMES, unsigned int) 1.333 +VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_STRENGTH, unsigned int) 1.334 +VPX_CTRL_USE_TYPE(VP8E_SET_ARNR_TYPE, unsigned int) 1.335 +VPX_CTRL_USE_TYPE(VP8E_SET_TUNING, int) /* vp8e_tuning */ 1.336 +VPX_CTRL_USE_TYPE(VP8E_SET_CQ_LEVEL, unsigned int) 1.337 + 1.338 +VPX_CTRL_USE_TYPE(VP9E_SET_TILE_COLUMNS, int) 1.339 +VPX_CTRL_USE_TYPE(VP9E_SET_TILE_ROWS, int) 1.340 + 1.341 +VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER, int *) 1.342 +VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER_64, int *) 1.343 + 1.344 +VPX_CTRL_USE_TYPE(VP8E_SET_MAX_INTRA_BITRATE_PCT, unsigned int) 1.345 + 1.346 +VPX_CTRL_USE_TYPE(VP9E_SET_LOSSLESS, unsigned int) 1.347 + 1.348 +VPX_CTRL_USE_TYPE(VP9E_SET_FRAME_PARALLEL_DECODING, unsigned int) 1.349 + 1.350 +VPX_CTRL_USE_TYPE(VP9E_SET_AQ_MODE, unsigned int) 1.351 + 1.352 +/*! @} - end defgroup vp8_encoder */ 1.353 +#ifdef __cplusplus 1.354 +} // extern "C" 1.355 +#endif 1.356 + 1.357 +#endif