vpx_ext_ratectrl.h
/*
* Copyright (c) 2020 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VPX_VPX_VPX_EXT_RATECTRL_H_
#define VPX_VPX_VPX_EXT_RATECTRL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "./vpx_integer.h"
#include "./vpx_tpl.h"
#define VPX_EXT_RATECTRL_ABI_VERSION (7)
typedef enum vpx_rc_type {
VPX_RC_QP = 1 << 0,
VPX_RC_GOP = 1 << 1,
VPX_RC_RDMULT = 1 << 2,
VPX_RC_GOP_QP = VPX_RC_QP | VPX_RC_GOP,
VPX_RC_GOP_QP_RDMULT = VPX_RC_QP | VPX_RC_GOP | VPX_RC_RDMULT
} vpx_rc_type_t;
typedef enum vpx_ext_rc_mode {
VPX_RC_QMODE = 0,
VPX_RC_VBR = 1,
VPX_RC_CQ = 2,
} vpx_ext_rc_mode_t;
typedef void *vpx_rc_model_t;
#define VPX_DEFAULT_Q -1
#define VPX_DEFAULT_RDMULT -1
typedef struct vpx_rc_encodeframe_decision {
int q_index;
int max_frame_size;
} vpx_rc_encodeframe_decision_t;
typedef struct vpx_rc_encodeframe_info {
int frame_type;
int show_index;
int coding_index;
int gop_index;
int ref_frame_coding_indexes[3];
int ref_frame_valid_list[3];
int gop_size;
int use_alt_ref;
} vpx_rc_encodeframe_info_t;
typedef struct vpx_rc_encodeframe_result {
int64_t sse;
int64_t bit_count;
int64_t pixel_count;
int actual_encoding_qindex;
} vpx_rc_encodeframe_result_t;
typedef enum vpx_rc_status {
VPX_RC_OK = 0,
VPX_RC_ERROR = 1,
} vpx_rc_status_t;
typedef struct vpx_rc_frame_stats {
double frame;
double weight;
double intra_error;
double coded_error;
double sr_coded_error;
double frame_noise_energy;
double pcnt_inter;
double pcnt_motion;
double pcnt_second_ref;
double pcnt_neutral;
double pcnt_intra_low;
double pcnt_intra_high;
double intra_skip_pct;
double intra_smooth_pct;
double inactive_zone_rows;
double inactive_zone_cols;
double MVr;
double mvr_abs;
double MVc;
double mvc_abs;
double MVrv;
double MVcv;
double mv_in_out_count;
double duration;
double count;
double new_mv_count;
} vpx_rc_frame_stats_t;
typedef struct vpx_rc_firstpass_stats {
vpx_rc_frame_stats_t *frame_stats;
int num_frames;
} vpx_rc_firstpass_stats_t;
typedef struct vpx_rc_config {
int frame_width;
int frame_height;
int show_frame_count;
int max_gf_interval;
int min_gf_interval;
int target_bitrate_kbps;
int frame_rate_num;
int frame_rate_den;
vpx_ext_rc_mode_t rc_mode;
int overshoot_percent;
int undershoot_percent;
} vpx_rc_config_t;
typedef struct vpx_rc_gop_info {
int min_gf_interval;
int max_gf_interval;
int active_min_gf_interval;
int active_max_gf_interval;
int allow_alt_ref;
int is_key_frame;
int last_gop_use_alt_ref;
int frames_since_key;
int frames_to_key;
int lag_in_frames;
int show_index;
int coding_index;
int gop_global_index;
} vpx_rc_gop_info_t;
typedef struct vpx_rc_gop_decision {
int gop_coding_frames;
int use_alt_ref;
} vpx_rc_gop_decision_t;
typedef vpx_rc_status_t (*vpx_rc_create_model_cb_fn_t)(
void *priv, const vpx_rc_config_t *ratectrl_config,
vpx_rc_model_t *rate_ctrl_model_ptr);
typedef vpx_rc_status_t (*vpx_rc_send_firstpass_stats_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model,
const vpx_rc_firstpass_stats_t *first_pass_stats);
typedef vpx_rc_status_t (*vpx_rc_send_tpl_gop_stats_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model, const VpxTplGopStats *tpl_gop_stats);
typedef vpx_rc_status_t (*vpx_rc_get_encodeframe_decision_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model,
const vpx_rc_encodeframe_info_t *encode_frame_info,
vpx_rc_encodeframe_decision_t *frame_decision);
typedef vpx_rc_status_t (*vpx_rc_update_encodeframe_result_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model,
const vpx_rc_encodeframe_result_t *encode_frame_result);
typedef vpx_rc_status_t (*vpx_rc_get_gop_decision_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model, const vpx_rc_gop_info_t *gop_info,
vpx_rc_gop_decision_t *gop_decision);
typedef vpx_rc_status_t (*vpx_rc_get_frame_rdmult_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model, const vpx_rc_encodeframe_info_t *frame_info,
int *rdmult);
typedef vpx_rc_status_t (*vpx_rc_delete_model_cb_fn_t)(
vpx_rc_model_t rate_ctrl_model);
typedef struct vpx_rc_funcs {
vpx_rc_type_t rc_type;
vpx_rc_create_model_cb_fn_t create_model;
vpx_rc_send_firstpass_stats_cb_fn_t send_firstpass_stats;
vpx_rc_send_tpl_gop_stats_cb_fn_t send_tpl_gop_stats;
vpx_rc_get_encodeframe_decision_cb_fn_t get_encodeframe_decision;
vpx_rc_update_encodeframe_result_cb_fn_t update_encodeframe_result;
vpx_rc_get_gop_decision_cb_fn_t get_gop_decision;
vpx_rc_get_frame_rdmult_cb_fn_t get_frame_rdmult;
vpx_rc_delete_model_cb_fn_t delete_model;
void *priv;
} vpx_rc_funcs_t;
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VPX_VPX_VPX_EXT_RATECTRL_H_
VpxTplGopStats
Temporal dependency model stats for each GOP before propagation.
Definition vpx_tpl.h:59
vpx_rc_config
Encode config sent to external rate control model.
Definition vpx_ext_ratectrl.h:306
vpx_rc_config::frame_height
int frame_height
Definition vpx_ext_ratectrl.h:308
vpx_rc_config::frame_width
int frame_width
Definition vpx_ext_ratectrl.h:307
vpx_rc_config::show_frame_count
int show_frame_count
Definition vpx_ext_ratectrl.h:309
vpx_rc_config::overshoot_percent
int overshoot_percent
Definition vpx_ext_ratectrl.h:323
vpx_rc_config::max_gf_interval
int max_gf_interval
Definition vpx_ext_ratectrl.h:310
vpx_rc_config::undershoot_percent
int undershoot_percent
Definition vpx_ext_ratectrl.h:324
vpx_rc_config::target_bitrate_kbps
int target_bitrate_kbps
Definition vpx_ext_ratectrl.h:315
vpx_rc_config::rc_mode
vpx_ext_rc_mode_t rc_mode
Definition vpx_ext_ratectrl.h:322
vpx_rc_config::frame_rate_num
int frame_rate_num
Definition vpx_ext_ratectrl.h:316
vpx_rc_config::min_gf_interval
int min_gf_interval
Definition vpx_ext_ratectrl.h:311
vpx_rc_config::frame_rate_den
int frame_rate_den
Definition vpx_ext_ratectrl.h:317
vpx_rc_encodeframe_decision
Encode frame decision made by the external rate control model.
Definition vpx_ext_ratectrl.h:92
vpx_rc_encodeframe_decision::q_index
int q_index
Definition vpx_ext_ratectrl.h:93
vpx_rc_encodeframe_decision::max_frame_size
int max_frame_size
Definition vpx_ext_ratectrl.h:94
vpx_rc_encodeframe_info
Information for the frame to be encoded.
Definition vpx_ext_ratectrl.h:103
vpx_rc_encodeframe_info::show_index
int show_index
Definition vpx_ext_ratectrl.h:112
vpx_rc_encodeframe_info::coding_index
int coding_index
Definition vpx_ext_ratectrl.h:113
vpx_rc_encodeframe_info::ref_frame_coding_indexes
int ref_frame_coding_indexes[3]
Definition vpx_ext_ratectrl.h:118
vpx_rc_encodeframe_info::ref_frame_valid_list
int ref_frame_valid_list[3]
Definition vpx_ext_ratectrl.h:124
vpx_rc_encodeframe_info::gop_index
int gop_index
Definition vpx_ext_ratectrl.h:117
vpx_rc_encodeframe_info::frame_type
int frame_type
Definition vpx_ext_ratectrl.h:111
vpx_rc_encodeframe_info::use_alt_ref
int use_alt_ref
Definition vpx_ext_ratectrl.h:132
vpx_rc_encodeframe_info::gop_size
int gop_size
Definition vpx_ext_ratectrl.h:128
vpx_rc_encodeframe_result
Frame coding result.
Definition vpx_ext_ratectrl.h:140
vpx_rc_encodeframe_result::actual_encoding_qindex
int actual_encoding_qindex
Definition vpx_ext_ratectrl.h:144
vpx_rc_encodeframe_result::sse
int64_t sse
Definition vpx_ext_ratectrl.h:141
vpx_rc_encodeframe_result::pixel_count
int64_t pixel_count
Definition vpx_ext_ratectrl.h:143
vpx_rc_encodeframe_result::bit_count
int64_t bit_count
Definition vpx_ext_ratectrl.h:142
vpx_rc_firstpass_stats
Collection of first pass frame stats.
Definition vpx_ext_ratectrl.h:291
vpx_rc_firstpass_stats::frame_stats
vpx_rc_frame_stats_t * frame_stats
Definition vpx_ext_ratectrl.h:297
vpx_rc_firstpass_stats::num_frames
int num_frames
Definition vpx_ext_ratectrl.h:301
vpx_rc_frame_stats
First pass frame stats This is a mirror of vp9's FIRSTPASS_STATS except that spatial_layer_id is omit...
Definition vpx_ext_ratectrl.h:158
vpx_rc_frame_stats::mvr_abs
double mvr_abs
Definition vpx_ext_ratectrl.h:251
vpx_rc_frame_stats::duration
double duration
Definition vpx_ext_ratectrl.h:277
vpx_rc_frame_stats::pcnt_intra_low
double pcnt_intra_low
Definition vpx_ext_ratectrl.h:212
vpx_rc_frame_stats::inactive_zone_cols
double inactive_zone_cols
Definition vpx_ext_ratectrl.h:243
vpx_rc_frame_stats::weight
double weight
Definition vpx_ext_ratectrl.h:169
vpx_rc_frame_stats::MVr
double MVr
Definition vpx_ext_ratectrl.h:247
vpx_rc_frame_stats::mv_in_out_count
double mv_in_out_count
Definition vpx_ext_ratectrl.h:273
vpx_rc_frame_stats::inactive_zone_rows
double inactive_zone_rows
Definition vpx_ext_ratectrl.h:239
vpx_rc_frame_stats::frame
double frame
Definition vpx_ext_ratectrl.h:163
vpx_rc_frame_stats::new_mv_count
double new_mv_count
Definition vpx_ext_ratectrl.h:286
vpx_rc_frame_stats::intra_error
double intra_error
Definition vpx_ext_ratectrl.h:173
vpx_rc_frame_stats::frame_noise_energy
double frame_noise_energy
Definition vpx_ext_ratectrl.h:185
vpx_rc_frame_stats::pcnt_neutral
double pcnt_neutral
Definition vpx_ext_ratectrl.h:204
vpx_rc_frame_stats::MVc
double MVc
Definition vpx_ext_ratectrl.h:255
vpx_rc_frame_stats::mvc_abs
double mvc_abs
Definition vpx_ext_ratectrl.h:259
vpx_rc_frame_stats::intra_smooth_pct
double intra_smooth_pct
Definition vpx_ext_ratectrl.h:235
vpx_rc_frame_stats::MVrv
double MVrv
Definition vpx_ext_ratectrl.h:263
vpx_rc_frame_stats::pcnt_motion
double pcnt_motion
Definition vpx_ext_ratectrl.h:193
vpx_rc_frame_stats::MVcv
double MVcv
Definition vpx_ext_ratectrl.h:267
vpx_rc_frame_stats::pcnt_intra_high
double pcnt_intra_high
Definition vpx_ext_ratectrl.h:220
vpx_rc_frame_stats::count
double count
Definition vpx_ext_ratectrl.h:282
vpx_rc_frame_stats::pcnt_inter
double pcnt_inter
Definition vpx_ext_ratectrl.h:189
vpx_rc_frame_stats::intra_skip_pct
double intra_skip_pct
Definition vpx_ext_ratectrl.h:228
vpx_rc_frame_stats::sr_coded_error
double sr_coded_error
Definition vpx_ext_ratectrl.h:181
vpx_rc_frame_stats::pcnt_second_ref
double pcnt_second_ref
Definition vpx_ext_ratectrl.h:199
vpx_rc_frame_stats::coded_error
double coded_error
Definition vpx_ext_ratectrl.h:177
vpx_rc_funcs
Callback function set for external rate control.
Definition vpx_ext_ratectrl.h:511
vpx_rc_funcs::send_firstpass_stats
vpx_rc_send_firstpass_stats_cb_fn_t send_firstpass_stats
Definition vpx_ext_ratectrl.h:523
vpx_rc_funcs::get_encodeframe_decision
vpx_rc_get_encodeframe_decision_cb_fn_t get_encodeframe_decision
Definition vpx_ext_ratectrl.h:531
vpx_rc_funcs::create_model
vpx_rc_create_model_cb_fn_t create_model
Definition vpx_ext_ratectrl.h:519
vpx_rc_funcs::send_tpl_gop_stats
vpx_rc_send_tpl_gop_stats_cb_fn_t send_tpl_gop_stats
Definition vpx_ext_ratectrl.h:527
vpx_rc_funcs::get_gop_decision
vpx_rc_get_gop_decision_cb_fn_t get_gop_decision
Definition vpx_ext_ratectrl.h:539
vpx_rc_funcs::rc_type
vpx_rc_type_t rc_type
Definition vpx_ext_ratectrl.h:515
vpx_rc_funcs::priv
void * priv
Definition vpx_ext_ratectrl.h:551
vpx_rc_funcs::update_encodeframe_result
vpx_rc_update_encodeframe_result_cb_fn_t update_encodeframe_result
Definition vpx_ext_ratectrl.h:535
vpx_rc_funcs::delete_model
vpx_rc_delete_model_cb_fn_t delete_model
Definition vpx_ext_ratectrl.h:547
vpx_rc_funcs::get_frame_rdmult
vpx_rc_get_frame_rdmult_cb_fn_t get_frame_rdmult
Definition vpx_ext_ratectrl.h:543
vpx_rc_gop_decision
The decision made by the external rate control model to set the group of picture.
Definition vpx_ext_ratectrl.h:400
vpx_rc_gop_decision::use_alt_ref
int use_alt_ref
Definition vpx_ext_ratectrl.h:402
vpx_rc_gop_decision::gop_coding_frames
int gop_coding_frames
Definition vpx_ext_ratectrl.h:401
vpx_rc_gop_info
Information passed to the external rate control model to help make GOP decisions.
Definition vpx_ext_ratectrl.h:330
vpx_rc_gop_info::active_min_gf_interval
int active_min_gf_interval
Definition vpx_ext_ratectrl.h:347
vpx_rc_gop_info::show_index
int show_index
Definition vpx_ext_ratectrl.h:385
vpx_rc_gop_info::frames_since_key
int frames_since_key
Definition vpx_ext_ratectrl.h:371
vpx_rc_gop_info::allow_alt_ref
int allow_alt_ref
Definition vpx_ext_ratectrl.h:358
vpx_rc_gop_info::is_key_frame
int is_key_frame
Definition vpx_ext_ratectrl.h:362
vpx_rc_gop_info::active_max_gf_interval
int active_max_gf_interval
Definition vpx_ext_ratectrl.h:352
vpx_rc_gop_info::max_gf_interval
int max_gf_interval
Definition vpx_ext_ratectrl.h:342
vpx_rc_gop_info::min_gf_interval
int min_gf_interval
Definition vpx_ext_ratectrl.h:338
vpx_rc_gop_info::last_gop_use_alt_ref
int last_gop_use_alt_ref
Definition vpx_ext_ratectrl.h:366
vpx_rc_gop_info::frames_to_key
int frames_to_key
Definition vpx_ext_ratectrl.h:376
vpx_rc_gop_info::coding_index
int coding_index
Definition vpx_ext_ratectrl.h:389
vpx_rc_gop_info::lag_in_frames
int lag_in_frames
Definition vpx_ext_ratectrl.h:380
vpx_rc_gop_info::gop_global_index
int gop_global_index
Definition vpx_ext_ratectrl.h:394
vpx_tpl.h
Describes the TPL stats descriptor and associated operations.