| 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 |
| 11 | /*!\file |
| 12 | * \brief Defines structs and callbacks needed for external rate control. |
| 13 | * |
| 14 | */ |
| 15 | #ifndef VPX_VPX_VPX_EXT_RATECTRL_H_ |
| 16 | #define VPX_VPX_VPX_EXT_RATECTRL_H_ |
| 17 |
| 18 | #ifdef __cplusplus |
| 19 | extern "C" { |
| 20 | #endif |
| 21 |
| 22 | #include "./vpx_integer.h" |
| 23 | #include "./vpx_tpl.h" |
| 24 |
| 25 | /*!\brief Current ABI version number |
| 26 | * |
| 27 | * \internal |
| 28 | * If this file is altered in any way that changes the ABI, this value |
| 29 | * must be bumped. Examples include, but are not limited to, changing |
| 30 | * types, removing or reassigning enums, adding/removing/rearranging |
| 31 | * fields to structures. |
| 32 | */ |
| 33 | #define VPX_EXT_RATECTRL_ABI_VERSION (7 + VPX_TPL_ABI_VERSION) |
| 34 |
| 35 | /*!\brief Corresponds to MAX_STATIC_GF_GROUP_LENGTH defined in vp9_ratectrl.h |
| 36 | */ |
| 37 | #define VPX_RC_MAX_STATIC_GF_GROUP_LENGTH 250 |
| 38 |
| 39 | /*!\brief Max number of ref frames returned by the external RC. |
| 40 | * |
| 41 | * Corresponds to MAX_REF_FRAMES defined in vp9_blockd.h. |
| 42 | */ |
| 43 | #define VPX_RC_MAX_REF_FRAMES 4 |
| 44 |
| 45 | /*!\brief The type of the external rate control. |
| 46 | * |
| 47 | * This controls what encoder parameters are determined by the external rate |
| 48 | * control. |
| 49 | */ |
| 50 | typedef enum vpx_rc_type { |
| 51 | /*! |
| 52 | * The external rate control doesn't determine anything. |
| 53 | * This mode is used as baseline. |
| 54 | */ |
| 55 | VPX_RC_NONE = 0, |
| 56 | /*! |
| 57 | * The external rate control model determines the quantization parameter (QP) |
| 58 | * for each frame. |
| 59 | */ |
| 60 | VPX_RC_QP = 1 << 0, |
| 61 | /*! |
| 62 | * The external rate control model determines the group of picture (GOP) of |
| 63 | * the video sequence. |
| 64 | */ |
| 65 | VPX_RC_GOP = 1 << 1, |
| 66 | /*! |
| 67 | * The external rate control model determines the rate-distortion multiplier |
| 68 | * (rdmult) for the current frame. |
| 69 | */ |
| 70 | VPX_RC_RDMULT = 1 << 2, |
| 71 | /*! |
| 72 | * The external rate control model determines both QP and GOP. |
| 73 | */ |
| 74 | VPX_RC_GOP_QP = VPX_RC_QP | VPX_RC_GOP, |
| 75 | /*! |
| 76 | * The external rate control model determines the QP, GOP and the rdmult. |
| 77 | */ |
| 78 | VPX_RC_GOP_QP_RDMULT = VPX_RC_QP | VPX_RC_GOP | VPX_RC_RDMULT |
| 79 | } vpx_rc_type_t; |
| 80 |
| 81 | /*!\brief The rate control mode for the external rate control model. |
| 82 | */ |
| 83 | typedef enum vpx_ext_rc_mode { |
| 84 | VPX_RC_QMODE = 0, |
| 85 | VPX_RC_VBR = 1, |
| 86 | VPX_RC_CQ = 2, |
| 87 | } vpx_ext_rc_mode_t; |
| 88 |
| 89 | /*!\brief Corresponds to FRAME_UPDATE_TYPE defined in vp9_firstpass.h. |
| 90 | */ |
| 91 | typedef enum vpx_rc_frame_update_type { |
| 92 | VPX_RC_INVALID_UPDATE_TYPE = -1, |
| 93 | VPX_RC_KF_UPDATE = 0, |
| 94 | VPX_RC_LF_UPDATE = 1, |
| 95 | VPX_RC_GF_UPDATE = 2, |
| 96 | VPX_RC_ARF_UPDATE = 3, |
| 97 | VPX_RC_OVERLAY_UPDATE = 4, |
| 98 | VPX_RC_MID_OVERLAY_UPDATE = 5, |
| 99 | VPX_RC_USE_BUF_FRAME = 6, |
| 100 | } vpx_rc_frame_update_type_t; |
| 101 |
| 102 | /*!\brief Name for the ref frames returned by the external RC. |
| 103 | * |
| 104 | * Corresponds to the ref frames defined in vp9_blockd.h. |
| 105 | */ |
| 106 | typedef enum vpx_rc_ref_name { |
| 107 | VPX_RC_INVALID_REF_FRAME = -1, |
| 108 | VPX_RC_INTRA_FRAME = 0, |
| 109 | VPX_RC_LAST_FRAME = 1, |
| 110 | VPX_RC_GOLDEN_FRAME = 2, |
| 111 | VPX_RC_ALTREF_FRAME = 3, |
| 112 | } vpx_rc_ref_name_t; |
| 113 |
| 114 | /*!\brief Abstract rate control model handler |
| 115 | * |
| 116 | * The encoder will receive the model handler from |
| 117 | * vpx_rc_funcs_t::create_model(). |
| 118 | */ |
| 119 | typedef void *vpx_rc_model_t; |
| 120 |
| 121 | /*!\brief A reserved value for the q index. |
| 122 | * If the external rate control model returns this value, |
| 123 | * the encoder will use the default q selected by libvpx's rate control |
| 124 | * system. |
| 125 | */ |
| 126 | #define VPX_DEFAULT_Q -1 |
| 127 |
| 128 | /*!\brief A reserved value for the rdmult. |
| 129 | * If the external rate control model returns this value, |
| 130 | * the encoder will use the default rdmult selected by libvpx's rate control |
| 131 | * system. |
| 132 | */ |
| 133 | #define VPX_DEFAULT_RDMULT -1 |
| 134 |
| 135 | /*!\brief Superblock quantization parameters |
| 136 | * Store the superblock quantization parameters |
| 137 | */ |
| 138 | typedef struct sb_parameters { |
| 139 | int q_index; /**< Quantizer step index [0..255]*/ |
| 140 | int rdmult; /**< Superblock level Lagrangian multiplier*/ |
| 141 | } sb_params; |
| 142 |
| 143 | /*!\brief Encode frame decision made by the external rate control model |
| 144 | * |
| 145 | * The encoder will receive the decision from the external rate control model |
| 146 | * through vpx_rc_funcs_t::get_encodeframe_decision(). |
| 147 | */ |
| 148 | typedef struct vpx_rc_encodeframe_decision { |
| 149 | int q_index; /**< Required: Quantizer step index [0..255]*/ |
| 150 | int rdmult; /**< Required: Frame level Lagrangian multiplier*/ |
| 151 | int delta_q_uv; /**< Required: Delta QP for UV */ |
| 152 | /*! |
| 153 | * Optional: Superblock quantization parameters |
| 154 | * It is zero initialized by default. It will be set for key and ARF frames |
| 155 | * but not leaf frames. |
| 156 | */ |
| 157 | sb_params *sb_params_list; |
| 158 | } vpx_rc_encodeframe_decision_t; |
| 159 |
| 160 | /*!\brief Information for the frame to be encoded. |
| 161 | * |
| 162 | * The encoder will send the information to external rate control model through |
| 163 | * vpx_rc_funcs_t::get_encodeframe_decision(). |
| 164 | * |
| 165 | */ |
| 166 | typedef struct vpx_rc_encodeframe_info { |
| 167 | /*! |
| 168 | * 0: Key frame |
| 169 | * 1: Inter frame |
| 170 | * 2: Alternate reference frame |
| 171 | * 3: Overlay frame |
| 172 | * 4: Golden frame |
| 173 | */ |
| 174 | int frame_type; |
| 175 | int show_index; /**< display index, starts from zero*/ |
| 176 | int coding_index; /**< coding index, starts from zero*/ |
| 177 | /*! |
| 178 | * index of the current frame in this group of picture, starts from zero. |
| 179 | */ |
| 180 | int gop_index; |
| 181 | int ref_frame_coding_indexes[3]; /**< three reference frames' coding indices*/ |
| 182 | /*! |
| 183 | * The validity of the three reference frames. |
| 184 | * 0: Invalid |
| 185 | * 1: Valid |
| 186 | */ |
| 187 | int ref_frame_valid_list[3]; |
| 188 | /*! |
| 189 | * The length of the current GOP. |
| 190 | */ |
| 191 | int gop_size; |
| 192 | /*! |
| 193 | * Whether the current GOP uses an alt ref. |
| 194 | */ |
| 195 | int use_alt_ref; |
| 196 | } vpx_rc_encodeframe_info_t; |
| 197 |
| 198 | /*!\brief Frame coding result |
| 199 | * |
| 200 | * The encoder will send the result to the external rate control model through |
| 201 | * vpx_rc_funcs_t::update_encodeframe_result(). |
| 202 | */ |
| 203 | typedef struct vpx_rc_encodeframe_result { |
| 204 | int64_t bit_count; /**< number of bits spent on coding the frame*/ |
| 205 | int actual_encoding_qindex; /**< the actual qindex used to encode the frame*/ |
| 206 | } vpx_rc_encodeframe_result_t; |
| 207 |
| 208 | /*!\brief Status returned by rate control callback functions. |
| 209 | */ |
| 210 | typedef enum vpx_rc_status { |
| 211 | VPX_RC_OK = 0, |
| 212 | VPX_RC_ERROR = 1, |
| 213 | } vpx_rc_status_t; |
| 214 |
| 215 | /*!\brief First pass frame stats |
| 216 | * This is a mirror of vp9's FIRSTPASS_STATS except that spatial_layer_id is |
| 217 | * omitted |
| 218 | */ |
| 219 | typedef struct vpx_rc_frame_stats { |
| 220 | /*! |
| 221 | * Frame number in display order, if stats are for a single frame. |
| 222 | * No real meaning for a collection of frames. |
| 223 | */ |
| 224 | double frame; |
| 225 | /*! |
| 226 | * Weight assigned to this frame (or total weight for the collection of |
| 227 | * frames) currently based on intra factor and brightness factor. This is used |
| 228 | * to distribute bits between easier and harder frames. |
| 229 | */ |
| 230 | double weight; |
| 231 | /*! |
| 232 | * Intra prediction error. |
| 233 | */ |
| 234 | double intra_error; |
| 235 | /*! |
| 236 | * Best of intra pred error and inter pred error using last frame as ref. |
| 237 | */ |
| 238 | double coded_error; |
| 239 | /*! |
| 240 | * Best of intra pred error and inter pred error using golden frame as ref. |
| 241 | */ |
| 242 | double sr_coded_error; |
| 243 | /*! |
| 244 | * Estimate the noise energy of the current frame. |
| 245 | */ |
| 246 | double frame_noise_energy; |
| 247 | /*! |
| 248 | * Percentage of blocks with inter pred error < intra pred error. |
| 249 | */ |
| 250 | double pcnt_inter; |
| 251 | /*! |
| 252 | * Percentage of blocks using (inter prediction and) non-zero motion vectors. |
| 253 | */ |
| 254 | double pcnt_motion; |
| 255 | /*! |
| 256 | * Percentage of blocks where golden frame was better than last or intra: |
| 257 | * inter pred error using golden frame < inter pred error using last frame and |
| 258 | * inter pred error using golden frame < intra pred error |
| 259 | */ |
| 260 | double pcnt_second_ref; |
| 261 | /*! |
| 262 | * Percentage of blocks where intra and inter prediction errors were very |
| 263 | * close. |
| 264 | */ |
| 265 | double pcnt_neutral; |
| 266 | /*! |
| 267 | * Percentage of blocks that have intra error < inter error and inter error < |
| 268 | * LOW_I_THRESH |
| 269 | * - bit_depth 8: LOW_I_THRESH = 24000 |
| 270 | * - bit_depth 10: LOW_I_THRESH = 24000 << 4 |
| 271 | * - bit_depth 12: LOW_I_THRESH = 24000 << 8 |
| 272 | */ |
| 273 | double pcnt_intra_low; |
| 274 | /*! |
| 275 | * Percentage of blocks that have intra error < inter error and intra error < |
| 276 | * LOW_I_THRESH but inter error >= LOW_I_THRESH LOW_I_THRESH |
| 277 | * - bit_depth 8: LOW_I_THRESH = 24000 |
| 278 | * - bit_depth 10: LOW_I_THRESH = 24000 << 4 |
| 279 | * - bit_depth 12: LOW_I_THRESH = 24000 << 8 |
| 280 | */ |
| 281 | double pcnt_intra_high; |
| 282 | /*! |
| 283 | * Percentage of blocks that have almost no intra error residual |
| 284 | * (i.e. are in effect completely flat and untextured in the intra |
| 285 | * domain). In natural videos this is uncommon, but it is much more |
| 286 | * common in animations, graphics and screen content, so may be used |
| 287 | * as a signal to detect these types of content. |
| 288 | */ |
| 289 | double intra_skip_pct; |
| 290 | /*! |
| 291 | * Percentage of blocks that have intra error < SMOOTH_INTRA_THRESH |
| 292 | * - bit_depth 8: SMOOTH_INTRA_THRESH = 4000 |
| 293 | * - bit_depth 10: SMOOTH_INTRA_THRESH = 4000 << 4 |
| 294 | * - bit_depth 12: SMOOTH_INTRA_THRESH = 4000 << 8 |
| 295 | */ |
| 296 | double intra_smooth_pct; |
| 297 | /*! |
| 298 | * Image mask rows top and bottom. |
| 299 | */ |
| 300 | double inactive_zone_rows; |
| 301 | /*! |
| 302 | * Image mask columns at left and right edges. |
| 303 | */ |
| 304 | double inactive_zone_cols; |
| 305 | /*! |
| 306 | * Mean of row motion vectors. |
| 307 | */ |
| 308 | double MVr; |
| 309 | /*! |
| 310 | * Mean of absolute value of row motion vectors. |
| 311 | */ |
| 312 | double mvr_abs; |
| 313 | /*! |
| 314 | * Mean of column motion vectors. |
| 315 | */ |
| 316 | double MVc; |
| 317 | /*! |
| 318 | * Mean of absolute value of column motion vectors. |
| 319 | */ |
| 320 | double mvc_abs; |
| 321 | /*! |
| 322 | * Variance of row motion vectors. |
| 323 | */ |
| 324 | double MVrv; |
| 325 | /*! |
| 326 | * Variance of column motion vectors. |
| 327 | */ |
| 328 | double MVcv; |
| 329 | /*! |
| 330 | * Value in range [-1,1] indicating fraction of row and column motion vectors |
| 331 | * that point inwards (negative MV value) or outwards (positive MV value). |
| 332 | * For example, value of 1 indicates, all row/column MVs are inwards. |
| 333 | */ |
| 334 | double mv_in_out_count; |
| 335 | /*! |
| 336 | * Duration of the frame / collection of frames. |
| 337 | */ |
| 338 | double duration; |
| 339 | /*! |
| 340 | * 1.0 if stats are for a single frame, or |
| 341 | * number of frames whose stats are accumulated. |
| 342 | */ |
| 343 | double count; |
| 344 | /*! |
| 345 | * Number of new mv in a frame. |
| 346 | */ |
| 347 | double new_mv_count; |
| 348 | } vpx_rc_frame_stats_t; |
| 349 |
| 350 | /*!\brief Collection of first pass frame stats |
| 351 | */ |
| 352 | typedef struct vpx_rc_firstpass_stats { |
| 353 | /*! |
| 354 | * Pointer to first pass frame stats. |
| 355 | * The pointed array of vpx_rc_frame_stats_t should have length equal to |
| 356 | * number of show frames in the video. |
| 357 | */ |
| 358 | vpx_rc_frame_stats_t *frame_stats; |
| 359 | /*! |
| 360 | * Number of show frames in the video. |
| 361 | */ |
| 362 | int num_frames; |
| 363 | } vpx_rc_firstpass_stats_t; |
| 364 |
| 365 | /*!\brief Encode config sent to external rate control model |
| 366 | */ |
| 367 | typedef struct vpx_rc_config { |
| 368 | int frame_width; /**< frame width */ |
| 369 | int frame_height; /**< frame height */ |
| 370 | int show_frame_count; /**< number of visible frames in the video */ |
| 371 | int max_gf_interval; /**< max GOP size in number of show frames */ |
| 372 | int min_gf_interval; /**< min GOP size in number of show frames */ |
| 373 | /*! |
| 374 | * Target bitrate in kilobytes per second |
| 375 | */ |
| 376 | int target_bitrate_kbps; |
| 377 | int frame_rate_num; /**< numerator of frame rate */ |
| 378 | int frame_rate_den; /**< denominator of frame rate */ |
| 379 | /*! |
| 380 | * The following fields are only for external rate control models that support |
| 381 | * different rate control modes. |
| 382 | */ |
| 383 | vpx_ext_rc_mode_t rc_mode; /**< Q mode or VBR mode */ |
| 384 | int overshoot_percent; /**< for VBR mode only */ |
| 385 | int undershoot_percent; /**< for VBR mode only */ |
| 386 | int min_base_q_index; /**< for VBR mode only */ |
| 387 | int max_base_q_index; /**< for VBR mode only */ |
| 388 | int base_qp; /**< base QP for leaf frames, 0-255 */ |
| 389 | } vpx_rc_config_t; |
| 390 |
| 391 | /*!\brief Control what ref frame to use and its index. |
| 392 | */ |
| 393 | typedef struct vpx_rc_ref_frame { |
| 394 | /*! |
| 395 | * Ref frame index. Corresponding to |lst_fb_idx|, |gld_fb_idx| or |
| 396 | * |alt_fb_idx| in VP9_COMP depending on the ref frame #name. |
| 397 | */ |
| 398 | int index[VPX_RC_MAX_REF_FRAMES]; |
| 399 | /*! |
| 400 | * Ref frame name. This decides whether the #index is used as |
| 401 | * |lst_fb_idx|, |gld_fb_idx| or |alt_fb_idx| in VP9_COMP. |
| 402 | * |
| 403 | */ |
| 404 | vpx_rc_ref_name_t name[VPX_RC_MAX_REF_FRAMES]; |
| 405 | } vpx_rc_ref_frame_t; |
| 406 |
| 407 | /*!\brief The decision made by the external rate control model to set the |
| 408 | * group of picture. |
| 409 | */ |
| 410 | typedef struct vpx_rc_gop_decision { |
| 411 | int gop_coding_frames; /**< The number of frames of this GOP */ |
| 412 | int use_alt_ref; /**< Whether to use alt ref for this GOP */ |
| 413 | int use_key_frame; /**< Whether to set key frame for this GOP */ |
| 414 | /*! |
| 415 | * Frame type for each frame in this GOP. |
| 416 | * This will be populated to |update_type| in GF_GROUP defined in |
| 417 | * vp9_firstpass.h |
| 418 | */ |
| 419 | vpx_rc_frame_update_type_t update_type[VPX_RC_MAX_STATIC_GF_GROUP_LENGTH + 2]; |
| 420 | /*! Ref frame buffer index to be updated for each frame in this GOP. */ |
| 421 | int update_ref_index[VPX_RC_MAX_STATIC_GF_GROUP_LENGTH + 2]; |
| 422 | /*! Ref frame list to be used for each frame in this GOP. */ |
| 423 | vpx_rc_ref_frame_t ref_frame_list[VPX_RC_MAX_STATIC_GF_GROUP_LENGTH + 2]; |
| 424 | } vpx_rc_gop_decision_t; |
| 425 |
| 426 | /*!\brief The decision made by the external rate control model to set the |
| 427 | * key frame location and the show frame count in the key frame group |
| 428 | */ |
| 429 | typedef struct vpx_rc_key_frame_decision { |
| 430 | int key_frame_show_index; /**< This key frame's show index in the video */ |
| 431 | int key_frame_group_size; /**< Show frame count of this key frame group */ |
| 432 | } vpx_rc_key_frame_decision_t; |
| 433 |
| 434 | /*!\brief Create an external rate control model callback prototype |
| 435 | * |
| 436 | * This callback is invoked by the encoder to create an external rate control |
| 437 | * model. |
| 438 | * |
| 439 | * \param[in] priv Callback's private data |
| 440 | * \param[in] ratectrl_config Pointer to vpx_rc_config_t |
| 441 | * \param[out] rate_ctrl_model_ptr Pointer to vpx_rc_model_t |
| 442 | */ |
| 443 | typedef vpx_rc_status_t (*vpx_rc_create_model_cb_fn_t)( |
| 444 | void *priv, const vpx_rc_config_t *ratectrl_config, |
| 445 | vpx_rc_model_t *rate_ctrl_model_ptr); |
| 446 |
| 447 | /*!\brief Send first pass stats to the external rate control model callback |
| 448 | * prototype |
| 449 | * |
| 450 | * This callback is invoked by the encoder to send first pass stats to the |
| 451 | * external rate control model. |
| 452 | * |
| 453 | * \param[in] rate_ctrl_model rate control model |
| 454 | * \param[in] first_pass_stats first pass stats |
| 455 | */ |
| 456 | typedef vpx_rc_status_t (*vpx_rc_send_firstpass_stats_cb_fn_t)( |
| 457 | vpx_rc_model_t rate_ctrl_model, |
| 458 | const vpx_rc_firstpass_stats_t *first_pass_stats); |
| 459 |
| 460 | /*!\brief Send TPL stats for the current GOP to the external rate control model |
| 461 | * callback prototype |
| 462 | * |
| 463 | * This callback is invoked by the encoder to send TPL stats for the GOP to the |
| 464 | * external rate control model. |
| 465 | * |
| 466 | * \param[in] rate_ctrl_model rate control model |
| 467 | * \param[in] tpl_gop_stats TPL stats for current GOP |
| 468 | */ |
| 469 | typedef vpx_rc_status_t (*vpx_rc_send_tpl_gop_stats_cb_fn_t)( |
| 470 | vpx_rc_model_t rate_ctrl_model, const VpxTplGopStats *tpl_gop_stats); |
| 471 |
| 472 | /*!\brief Receive encode frame decision callback prototype |
| 473 | * |
| 474 | * This callback is invoked by the encoder to receive encode frame decision from |
| 475 | * the external rate control model. |
| 476 | * |
| 477 | * \param[in] rate_ctrl_model rate control model |
| 478 | * \param[in] frame_gop_index index of the frame in current gop |
| 479 | * \param[out] frame_decision encode decision of the coding frame |
| 480 | */ |
| 481 | typedef vpx_rc_status_t (*vpx_rc_get_encodeframe_decision_cb_fn_t)( |
| 482 | vpx_rc_model_t rate_ctrl_model, const int frame_gop_index, |
| 483 | vpx_rc_encodeframe_decision_t *frame_decision); |
| 484 |
| 485 | /*!\brief Update encode frame result callback prototype |
| 486 | * |
| 487 | * This callback is invoked by the encoder to update encode frame result to the |
| 488 | * external rate control model. |
| 489 | * |
| 490 | * \param[in] rate_ctrl_model rate control model |
| 491 | * \param[out] encode_frame_result encode result of the coding frame |
| 492 | */ |
| 493 | typedef vpx_rc_status_t (*vpx_rc_update_encodeframe_result_cb_fn_t)( |
| 494 | vpx_rc_model_t rate_ctrl_model, |
| 495 | const vpx_rc_encodeframe_result_t *encode_frame_result); |
| 496 |
| 497 | /*!\brief Get the key frame decision from the external rate control model. |
| 498 | * |
| 499 | * This callback is invoked by the encoder to get key frame decision from |
| 500 | * the external rate control model. |
| 501 | * |
| 502 | * \param[in] rate_ctrl_model rate control model |
| 503 | * \param[out] key_frame_decision key frame decision from the model |
| 504 | */ |
| 505 | typedef vpx_rc_status_t (*vpx_rc_get_key_frame_decision_cb_fn_t)( |
| 506 | vpx_rc_model_t rate_ctrl_model, |
| 507 | vpx_rc_key_frame_decision_t *key_frame_decision); |
| 508 |
| 509 | /*!\brief Get the GOP structure from the external rate control model. |
| 510 | * |
| 511 | * This callback is invoked by the encoder to get GOP decisions from |
| 512 | * the external rate control model. |
| 513 | * |
| 514 | * \param[in] rate_ctrl_model rate control model |
| 515 | * \param[out] gop_decision GOP decision from the model |
| 516 | */ |
| 517 | typedef vpx_rc_status_t (*vpx_rc_get_gop_decision_cb_fn_t)( |
| 518 | vpx_rc_model_t rate_ctrl_model, vpx_rc_gop_decision_t *gop_decision); |
| 519 |
| 520 | /*!\brief Get the frame rdmult from the external rate control model. |
| 521 | * |
| 522 | * This callback is invoked by the encoder to get rdmult from |
| 523 | * the external rate control model. |
| 524 | * |
| 525 | * \param[in] rate_ctrl_model rate control model |
| 526 | * \param[in] frame_info information collected from the encoder |
| 527 | * \param[out] rdmult frame rate-distortion multiplier from the model |
| 528 | */ |
| 529 | typedef vpx_rc_status_t (*vpx_rc_get_frame_rdmult_cb_fn_t)( |
| 530 | vpx_rc_model_t rate_ctrl_model, const vpx_rc_encodeframe_info_t *frame_info, |
| 531 | int *rdmult); |
| 532 |
| 533 | /*!\brief Delete the external rate control model callback prototype |
| 534 | * |
| 535 | * This callback is invoked by the encoder to delete the external rate control |
| 536 | * model. |
| 537 | * |
| 538 | * \param[in] rate_ctrl_model rate control model |
| 539 | */ |
| 540 | typedef vpx_rc_status_t (*vpx_rc_delete_model_cb_fn_t)( |
| 541 | vpx_rc_model_t rate_ctrl_model); |
| 542 |
| 543 | /*!\brief Callback function set for external rate control. |
| 544 | * |
| 545 | * The user can enable external rate control by registering |
| 546 | * a set of callback functions with the codec control flag |
| 547 | * #VP9E_SET_EXTERNAL_RATE_CONTROL. |
| 548 | */ |
| 549 | typedef struct vpx_rc_funcs { |
| 550 | /*! |
| 551 | * The rate control type of this API. |
| 552 | */ |
| 553 | vpx_rc_type_t rc_type; |
| 554 | /*! |
| 555 | * Create an external rate control model. |
| 556 | */ |
| 557 | vpx_rc_create_model_cb_fn_t create_model; |
| 558 | /*! |
| 559 | * Send first pass stats to the external rate control model. |
| 560 | */ |
| 561 | vpx_rc_send_firstpass_stats_cb_fn_t send_firstpass_stats; |
| 562 | /*! |
| 563 | * Send TPL stats for current GOP to the external rate control model. |
| 564 | */ |
| 565 | vpx_rc_send_tpl_gop_stats_cb_fn_t send_tpl_gop_stats; |
| 566 | /*! |
| 567 | * Get encodeframe decision from the external rate control model. |
| 568 | */ |
| 569 | vpx_rc_get_encodeframe_decision_cb_fn_t get_encodeframe_decision; |
| 570 | /*! |
| 571 | * Update encodeframe result to the external rate control model. |
| 572 | */ |
| 573 | vpx_rc_update_encodeframe_result_cb_fn_t update_encodeframe_result; |
| 574 | /*! |
| 575 | * Get key frame decision from the external rate control model. |
| 576 | */ |
| 577 | vpx_rc_get_key_frame_decision_cb_fn_t get_key_frame_decision; |
| 578 | /*! |
| 579 | * Get GOP decisions from the external rate control model. |
| 580 | */ |
| 581 | vpx_rc_get_gop_decision_cb_fn_t get_gop_decision; |
| 582 | /*! |
| 583 | * Get rdmult for the frame from the external rate control model. |
| 584 | */ |
| 585 | vpx_rc_get_frame_rdmult_cb_fn_t get_frame_rdmult; |
| 586 | /*! |
| 587 | * Delete the external rate control model. |
| 588 | */ |
| 589 | vpx_rc_delete_model_cb_fn_t delete_model; |
| 590 |
| 591 | /*! |
| 592 | * Rate control log path. |
| 593 | */ |
| 594 | const char *rate_ctrl_log_path; |
| 595 | /*! |
| 596 | * Private data for the external rate control model. |
| 597 | */ |
| 598 | void *priv; |
| 599 | } vpx_rc_funcs_t; |
| 600 |
| 601 | #ifdef __cplusplus |
| 602 | } // extern "C" |
| 603 | #endif |
| 604 |
| 605 | #endif // VPX_VPX_VPX_EXT_RATECTRL_H_ |
| 606 |