AOMedia AV1 Codec
|
Functions | |
aom_codec_err_t | av1_firstpass_info_init (FIRSTPASS_INFO *firstpass_info, FIRSTPASS_STATS *ext_stats_buf, int ext_stats_buf_size) |
Init firstpass_info. | |
aom_codec_err_t | av1_firstpass_info_move_cur_index (FIRSTPASS_INFO *firstpass_info) |
Move cur_index by 1. | |
aom_codec_err_t | av1_firstpass_info_pop (FIRSTPASS_INFO *firstpass_info) |
Pop a stats from firstpass_info. | |
aom_codec_err_t | av1_firstpass_info_move_cur_index_and_pop (FIRSTPASS_INFO *firstpass_info) |
Move cur_index by 1 and pop a stats from firstpass_info. | |
aom_codec_err_t | av1_firstpass_info_push (FIRSTPASS_INFO *firstpass_info, const FIRSTPASS_STATS *input_stats) |
Push a stats into firstpass_info. | |
const FIRSTPASS_STATS * | av1_firstpass_info_peek (const FIRSTPASS_INFO *firstpass_info, int offset_from_cur) |
Peek at a stats from firstpass_info. | |
int | av1_firstpass_info_future_count (const FIRSTPASS_INFO *firstpass_info, int offset_from_cur) |
Count the future stats from the target in firstpass_info Note that the target stats will be counted as well. The target index is as follows. (cur_index + offset_from_cur) % firstpass_info->stats_buf_size. | |
void | av1_first_pass (struct AV1_COMP *cpi, const int64_t ts_duration) |
AV1 first pass encoding. | |
void | av1_gop_setup_structure (struct AV1_COMP *cpi) |
Set up the Group-Of-Pictures structure for this GF_GROUP. | |
void | av1_gop_bit_allocation (const AV1_COMP *cpi, RATE_CONTROL *const rc, GF_GROUP *gf_group, int is_key_frame, int use_arf, int64_t gf_group_bits) |
Distributes bits to frames in a group. | |
int | av1_gop_check_forward_keyframe (const GF_GROUP *gf_group, int gf_frame_index) |
Check whether a frame in the GOP is a forward key frame. | |
int | av1_gop_is_second_arf (const GF_GROUP *gf_group, int gf_frame_index) |
Check whether a frame in the GOP is the second arf. | |
void | av1_get_second_pass_params (struct AV1_COMP *cpi, struct EncodeFrameParams *const frame_params, unsigned int frame_flags) |
Main per frame entry point for second pass of two pass encode. | |
void | av1_twopass_postencode_update (struct AV1_COMP *cpi) |
Adjustments to two pass and rate control after each frame. | |
static int | get_twopass_worst_quality (AV1_COMP *cpi, const double av_frame_err, double inactive_zone, int av_target_bandwidth) |
Choose a target maximum Q for a group of frames. | |
static int64_t | calculate_total_gf_group_bits (AV1_COMP *cpi, double gf_group_err) |
Calculates the bit target for this GF/ARF group. | |
static double | get_rate_correction_factor (const AV1_COMP *cpi, int width, int height) |
Gets a rate vs Q correction factor. | |
static void | set_rate_correction_factor (AV1_COMP *cpi, int is_encode_stage, double factor, int width, int height) |
Sets a rate vs Q correction factor. | |
static int | find_closest_qindex_by_rate (int desired_bits_per_mb, const AV1_COMP *cpi, double correction_factor, int best_qindex, int worst_qindex) |
Searches for a Q index value predicted to give an average macro block rate closest to the target value. | |
static int | rc_pick_q_and_bounds_no_stats_cbr (const AV1_COMP *cpi, int width, int height, int *bottom_index, int *top_index) |
Picks q and q bounds given CBR rate control parameters in cpi->rc . | |
static int | rc_pick_q_and_bounds_no_stats (const AV1_COMP *cpi, int width, int height, int *bottom_index, int *top_index) |
Picks q and q bounds given non-CBR rate control params in cpi->rc . | |
static int | get_q (const AV1_COMP *cpi, const int width, const int height, const int active_worst_quality, const int active_best_quality) |
Gets a Q value to use for the current frame. | |
static int | rc_pick_q_and_bounds (const AV1_COMP *cpi, int width, int height, int gf_index, int *bottom_index, int *top_index) |
Picks q and q bounds given rate control parameters in cpi->rc . | |
void | av1_set_rtc_reference_structure_one_layer (AV1_COMP *cpi, int gf_update) |
Setup the reference prediction structure for 1 pass real-time. | |
static void | rc_scene_detection_onepass_rt (AV1_COMP *cpi, const EncodeFrameInput *frame_input) |
Check for scene detection, for 1 pass real-time mode. | |
static void | rc_spatial_act_keyframe_onepass_rt (AV1_COMP *cpi, uint8_t *src_y, int src_ystride) |
Compute spatial activity for keyframe, 1 pass real-time mode. | |
static int | set_gf_interval_update_onepass_rt (AV1_COMP *cpi, FRAME_TYPE frame_type) |
Set the GF baseline interval for 1 pass real-time mode. | |
static void | dynamic_resize_one_pass_cbr (AV1_COMP *cpi) |
ChecK for resize based on Q, for 1 pass real-time mode. | |
void | av1_rc_update_rate_correction_factors (struct AV1_COMP *cpi, int is_encode_stage, int width, int height) |
Updates the rate correction factor linking Q to output bits. | |
int | av1_rc_pick_q_and_bounds (struct AV1_COMP *cpi, int width, int height, int gf_index, int *bottom_index, int *top_index) |
Picks q and q bounds given the rate control parameters in cpi->rc . | |
int | av1_rc_regulate_q (const struct AV1_COMP *cpi, int target_bits_per_frame, int active_best_quality, int active_worst_quality, int width, int height) |
Estimates q to achieve a target bits per frame. | |
int | av1_calc_pframe_target_size_one_pass_vbr (const struct AV1_COMP *const cpi, FRAME_UPDATE_TYPE frame_update_type) |
Calculates how many bits to use for a P frame in one pass vbr. | |
int | av1_calc_iframe_target_size_one_pass_vbr (const struct AV1_COMP *const cpi) |
Calculates how many bits to use for an i frame in one pass vbr. | |
int | av1_calc_pframe_target_size_one_pass_cbr (const struct AV1_COMP *cpi, FRAME_UPDATE_TYPE frame_update_type) |
Calculates how many bits to use for a P frame in one pass cbr. | |
int | av1_calc_iframe_target_size_one_pass_cbr (const struct AV1_COMP *cpi) |
Calculates how many bits to use for an i frame in one pass cbr. | |
void | av1_get_one_pass_rt_params (struct AV1_COMP *cpi, FRAME_TYPE *const frame_type, const struct EncodeFrameInput *frame_input, unsigned int frame_flags) |
Setup the rate control parameters for 1 pass real-time mode. | |
int | av1_encodedframe_overshoot_cbr (struct AV1_COMP *cpi, int *q) |
Increase q on expected encoder overshoot, for CBR mode. | |
int | av1_postencode_drop_cbr (struct AV1_COMP *cpi, size_t *size) |
Check if frame should be dropped, for RTC mode. | |
static int | recode_loop_test (AV1_COMP *cpi, int high_limit, int low_limit, int q, int maxq, int minq) |
Function to test for conditions that indicate we should loop back and recode a frame. | |
static void | recode_loop_update_q (AV1_COMP *const cpi, int *const loop, int *const q, int *const q_low, int *const q_high, const int top_index, const int bottom_index, int *const undershoot_seen, int *const overshoot_seen, int *const low_cr_seen, const int loop_count) |
Called after encode_with_recode_loop() has just encoded a frame. This function works out whether we undershot or overshot our bitrate target and adjusts q as appropriate. It also decides whether or not we need to recode the frame to get closer to the target rate. | |
static LAYER_CONTEXT * | get_layer_context (AV1_COMP *const cpi) |
Return layer context for current layer. | |
This module describes rate control algorithm in AV1. See also Rate Control
aom_codec_err_t av1_firstpass_info_init | ( | FIRSTPASS_INFO * | firstpass_info, |
FIRSTPASS_STATS * | ext_stats_buf, | ||
int | ext_stats_buf_size ) |
Init firstpass_info.
If using ext_stats_buf, the buffer needs to stay available during encoding process.
[out] | firstpass_info | struct of firstpass_info. |
[in] | ext_stats_buf | external stats buffer. Pass in NULL if choose to use internal static_stats_buf. |
[in] | ext_stats_buf_size | external stats buffer size. Pass in 0 if choose to use internal static_stats_buf. |
aom_codec_err_t av1_firstpass_info_move_cur_index | ( | FIRSTPASS_INFO * | firstpass_info | ) |
Move cur_index by 1.
[out] | firstpass_info | struct of firstpass_info. |
aom_codec_err_t av1_firstpass_info_pop | ( | FIRSTPASS_INFO * | firstpass_info | ) |
Pop a stats from firstpass_info.
[out] | firstpass_info | struct of firstpass_info. |
aom_codec_err_t av1_firstpass_info_move_cur_index_and_pop | ( | FIRSTPASS_INFO * | firstpass_info | ) |
Move cur_index by 1 and pop a stats from firstpass_info.
[out] | firstpass_info | struct of firstpass_info. |
aom_codec_err_t av1_firstpass_info_push | ( | FIRSTPASS_INFO * | firstpass_info, |
const FIRSTPASS_STATS * | input_stats ) |
Push a stats into firstpass_info.
Note that the input stats will be copied into firstpass_info.
[out] | firstpass_info | struct of firstpass_info. |
[in] | input_stats | input stats |
const FIRSTPASS_STATS * av1_firstpass_info_peek | ( | const FIRSTPASS_INFO * | firstpass_info, |
int | offset_from_cur ) |
Peek at a stats from firstpass_info.
The target index is as follows. (cur_index + offset_from_cur) % firstpass_info->stats_buf_size
[in] | firstpass_info | struct of firstpass_info. |
[in] | offset_from_cur | index offset from cur_index. |
Referenced by define_kf_interval(), and find_next_key_frame().
int av1_firstpass_info_future_count | ( | const FIRSTPASS_INFO * | firstpass_info, |
int | offset_from_cur ) |
Count the future stats from the target in firstpass_info Note that the target stats will be counted as well. The target index is as follows. (cur_index + offset_from_cur) % firstpass_info->stats_buf_size.
[in] | firstpass_info | struct of firstpass_info. |
[in] | offset_from_cur | target stats's inffset from cur_index. |
Referenced by define_kf_interval().
void av1_first_pass | ( | struct AV1_COMP * | cpi, |
const int64_t | ts_duration ) |
AV1 first pass encoding.
This function is the first encoding pass for the two pass encoding mode. It encodes the whole video and collect essential information. Two pass encoding is an encoding mode in the reference software (libaom) of AV1 for high performance encoding. The first pass is a fast encoding process to collect essential information to help the second pass make encoding decisions and improve coding quality. The collected stats is used in rate control, for example, to determine frame cut, the position of alternative reference frame (ARF), etc.
[in] | cpi | Top-level encoder structure |
[in] | ts_duration | Duration of the frame / collection of frames |
Referenced by av1_encode().
void av1_gop_setup_structure | ( | struct AV1_COMP * | cpi | ) |
Set up the Group-Of-Pictures structure for this GF_GROUP.
This function defines the Group-Of-Pictures structure for this GF_GROUP. This involves deciding where to place the various FRAME_UPDATE_TYPEs in the group. It does this primarily by updateing entries in cpi->twopass.gf_group.update_type[].
[in] | cpi | Top - level encoder instance structure |
Referenced by define_gf_group(), define_gf_group_pass0(), and define_gf_group_pass3().
void av1_gop_bit_allocation | ( | const AV1_COMP * | cpi, |
RATE_CONTROL *const | rc, | ||
GF_GROUP * | gf_group, | ||
int | is_key_frame, | ||
int | use_arf, | ||
int64_t | gf_group_bits ) |
Distributes bits to frames in a group.
This function decides on the allocation of bits between the different frames and types of frame in a GF/ARF group.
[in] | cpi | Top - level encoder instance structure |
[in] | rc | Rate control data |
[in] | gf_group | GF/ARF group data structure |
[in] | is_key_frame | Indicates if the first frame in the group is also a key frame. |
[in] | use_arf | Are ARF frames enabled or is this a GF only uni-directional group. |
[in] | gf_group_bits | Bits available to be allocated. |
References PRIMARY_RATE_CONTROL::gfu_boost, AV1_PRIMARY::p_rc, and AV1_COMP::ppi.
int av1_gop_check_forward_keyframe | ( | const GF_GROUP * | gf_group, |
int | gf_frame_index ) |
Check whether a frame in the GOP is a forward key frame.
[in] | gf_group | GF/ARF group data structure |
[in] | gf_frame_index | GOP index |
Referenced by tf_setup_filtering_buffer().
int av1_gop_is_second_arf | ( | const GF_GROUP * | gf_group, |
int | gf_frame_index ) |
Check whether a frame in the GOP is the second arf.
[in] | gf_group | GF/ARF group data structure |
[in] | gf_frame_index | GOP index |
void av1_get_second_pass_params | ( | struct AV1_COMP * | cpi, |
struct EncodeFrameParams *const | frame_params, | ||
unsigned int | frame_flags ) |
Main per frame entry point for second pass of two pass encode.
This function is called for each frame in the second pass of a two pass encode. It checks the frame type and if a new KF or GF/ARF is due. When a KF is due it calls find_next_key_frame() to work out how long this key frame group will be and assign bits to the key frame. At the start of a new GF/ARF group it calls calculate_gf_length() and define_gf_group() which are the main functions responsible for defining the size and structure of the new GF/ARF group.
[in] | cpi | Top - level encoder instance structure |
[in] | frame_params | Per frame encoding parameters |
[in] | frame_flags | Frame type and coding flags |
References RATE_CONTROL::active_worst_quality, AV1EncoderConfig::algo_cfg, AOM_CODEC_MEM_ERROR, AOM_Q, AOM_RC_THIRD_PASS, AlgoCfg::arnr_max_frames, calculate_gf_length(), AV1_COMP::common, RateControlCfg::cq_level, PRIMARY_RATE_CONTROL::cur_gf_index, AV1Common::current_frame, define_gf_group(), define_kf_interval(), AV1_COMP::ducky_encode_info, AlgoCfg::enable_tpl_model, AV1Common::error, find_next_key_frame(), EncodeFrameParams::frame_type, RATE_CONTROL::frames_till_gf_update_due, RATE_CONTROL::frames_to_key, KeyFrameCfg::fwd_kf_dist, AV1_COMP::gf_frame_index, AV1_PRIMARY::gf_group, PRIMARY_RATE_CONTROL::gf_intervals, AV1_PRIMARY::gf_state, PRIMARY_RATE_CONTROL::gfu_boost, RATE_CONTROL::intervals_till_gf_calculate_due, PRIMARY_RATE_CONTROL::kf_boost, AV1EncoderConfig::kf_cfg, AV1_PRIMARY::lap_enabled, RateControlCfg::mode, AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1EncoderConfig::pass, AV1_COMP::ppi, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, AV1_COMP::second_pass_log_stream, AV1_COMP::sf, EncodeFrameParams::show_frame, AV1_PRIMARY::tf_info, AV1_COMP::third_pass_ctx, SPEED_FEATURES::tpl_sf, AV1_PRIMARY::twopass, AV1_COMP::twopass_frame, and AV1_COMP::use_ducky_encode.
Referenced by av1_encode_strategy().
void av1_twopass_postencode_update | ( | struct AV1_COMP * | cpi | ) |
Adjustments to two pass and rate control after each frame.
This function is called after each frame to make adjustments to heuristics and data structures that relate to rate control.
[in] | cpi | Top - level encoder instance structure |
References PRIMARY_RATE_CONTROL::active_best_quality, RATE_CONTROL::active_worst_quality, AOM_CQ, AOM_Q, RATE_CONTROL::base_frame_target, CommonQuantParams::base_qindex, AV1_COMP::common, AV1Common::current_frame, AV1_COMP::do_frame_data_update, AV1_COMP::do_update_frame_probs_interpfilter, AV1_COMP::do_update_frame_probs_obmc, AV1_COMP::do_update_frame_probs_txtype, AV1_COMP::do_update_frame_probs_warp, AV1_COMP::do_update_vbr_bits_off_target_fast, AV1_COMP::ducky_encode_info, AV1_COMP::frame_new_probs, AV1_PRIMARY::frame_probs, AV1_COMP::framerate, RATE_CONTROL::frames_to_key, AV1_COMP::gf_frame_index, AV1_PRIMARY::gf_group, AV1_PRIMARY::lap_enabled, RateControlCfg::mode, AV1_COMP::new_framerate, AV1_COMP::num_frame_recode, FrameProbInfo::obmc_probs, RateControlCfg::over_shoot_pct, AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1_COMP::ppi, RATE_CONTROL::projected_frame_size, AV1Common::quant_params, PRIMARY_RATE_CONTROL::rate_error_estimate, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, PRIMARY_RATE_CONTROL::rolling_actual_bits, PRIMARY_RATE_CONTROL::rolling_target_bits, AV1Common::seq_params, AV1Common::show_frame, FrameProbInfo::switchable_interp_probs, PRIMARY_RATE_CONTROL::total_actual_bits, AV1_PRIMARY::twopass, AV1_COMP::twopass_frame, FrameProbInfo::tx_type_probs, RateControlCfg::under_shoot_pct, AV1_COMP::use_ducky_encode, PRIMARY_RATE_CONTROL::vbr_bits_off_target, PRIMARY_RATE_CONTROL::vbr_bits_off_target_fast, FrameProbInfo::warped_probs, and RATE_CONTROL::worst_quality.
|
static |
Choose a target maximum Q for a group of frames.
This function is used to estimate a suitable maximum Q for a group of frames. Inititally it is called to get a crude estimate for the whole clip. It is then called for each ARF/GF group to get a revised estimate for that group.
[in] | cpi | Top-level encoder structure |
[in] | av_frame_err | The average per frame coded error score for frames making up this section/group. |
[in] | inactive_zone | Used to mask off /ignore part of the frame. The most common use case is where a wide format video (e.g. 16:9) is letter-boxed into a more square format. Here we want to ignore the bands at the top and bottom. |
[in] | av_target_bandwidth | The target bits per frame |
References AOM_CQ, RATE_CONTROL::best_quality, AV1_COMP::common, RateControlCfg::cq_level, AV1_COMP::initial_mbs, CommonModeInfoParams::MBs, AV1Common::mi_params, RateControlCfg::mode, RateControlCfg::over_shoot_pct, AV1_COMP::oxcf, AV1_COMP::ppi, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, AV1Common::seq_params, AV1_PRIMARY::twopass, RateControlCfg::under_shoot_pct, and RATE_CONTROL::worst_quality.
|
static |
Calculates the bit target for this GF/ARF group.
Calculates the total bits to allocate in this GF/ARF group.
[in] | cpi | Top-level encoder structure |
[in] | gf_group_err | Cumulative coded error score for the frames making up this group. |
References AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1_COMP::ppi, AV1_COMP::rc, and AV1_PRIMARY::twopass.
|
static |
Gets a rate vs Q correction factor.
This function returns the current value of a correction factor used to dynamilcally adjust the relationship between Q and the expected number of bits for the frame.
[in] | cpi | Top level encoder instance structure |
[in] | width | Frame width |
[in] | height | Frame height |
References RefreshFrameInfo::alt_ref_frame, AOM_CBR, AV1_COMP::common, AV1Common::current_frame, RateControlCfg::gf_cbr_boost_pct, AV1_COMP::gf_frame_index, AV1_PRIMARY::gf_group, RefreshFrameInfo::golden_frame, RateControlCfg::mode, AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1_COMP::ppi, PRIMARY_RATE_CONTROL::rate_correction_factors, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, AV1_COMP::refresh_frame, and AV1_PRIMARY::use_svc.
Referenced by av1_rc_update_rate_correction_factors().
|
static |
Sets a rate vs Q correction factor.
This function updates the current value of a correction factor used to dynamilcally adjust the relationship between Q and the expected number of bits for the frame.
[in] | cpi | Top level encoder instance structure |
[in] | is_encode_stage | Indicates if recode loop or post-encode |
[in] | factor | New correction factor |
[in] | width | Frame width |
[in] | height | Frame height |
References RefreshFrameInfo::alt_ref_frame, AOM_CBR, AV1_COMP::common, AV1Common::current_frame, RateControlCfg::gf_cbr_boost_pct, AV1_COMP::gf_frame_index, AV1_PRIMARY::gf_group, RefreshFrameInfo::golden_frame, RateControlCfg::mode, AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1_COMP::ppi, PRIMARY_RATE_CONTROL::rate_correction_factors, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, AV1_COMP::refresh_frame, and AV1_PRIMARY::use_svc.
Referenced by av1_rc_update_rate_correction_factors().
|
static |
Searches for a Q index value predicted to give an average macro block rate closest to the target value.
Similar to find_qindex_by_rate() function, but returns a q index with a rate just above or below the desired rate, depending on which of the two rates is closer to the desired rate. Also, respects the selected aq_mode when computing the rate.
[in] | desired_bits_per_mb | Target bits per mb |
[in] | cpi | Top level encoder instance structure |
[in] | correction_factor | Current Q to rate correction factor |
[in] | best_qindex | Min allowed Q value. |
[in] | worst_qindex | Max allowed Q value. |
References AV1_COMP::cyclic_refresh, and AV1_COMP::oxcf.
|
static |
Picks q and q bounds given CBR rate control parameters in cpi->rc
.
Handles the special case when using:
cpi->oxcf.rc_cfg.mode
== AOM_CBR, and[in] | cpi | Top level encoder structure |
[in] | width | Coded frame width |
[in] | height | Coded frame height |
[out] | bottom_index | Bottom bound for q index (best quality) |
[out] | top_index | Top bound for q index (worst quality) |
References AOM_CBR, RATE_CONTROL::best_quality, AV1_COMP::common, AV1Common::current_frame, has_no_stats_stage(), RateControlCfg::mode, AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1_COMP::ppi, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, RATE_CONTROL::this_frame_target, and RATE_CONTROL::worst_quality.
Referenced by av1_rc_pick_q_and_bounds().
|
static |
Picks q and q bounds given non-CBR rate control params in cpi->rc
.
Handles the special case when using:
cpi->oxcf.rc_cfg.mode
!= AOM_CBR, and[in] | cpi | Top level encoder structure |
[in] | width | Coded frame width |
[in] | height | Coded frame height |
[out] | bottom_index | Bottom bound for q index (best quality) |
[out] | top_index | Top bound for q index (worst quality) |
References RefreshFrameInfo::alt_ref_frame, AOM_CQ, AOM_Q, AOM_VBR, PRIMARY_RATE_CONTROL::avg_frame_qindex, RATE_CONTROL::best_quality, AV1_COMP::common, AV1Common::current_frame, AV1_COMP::gf_frame_index, AV1_PRIMARY::gf_group, RefreshFrameInfo::golden_frame, has_no_stats_stage(), PRIMARY_RATE_CONTROL::last_boosted_qindex, RateControlCfg::mode, AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1_COMP::ppi, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, AV1_COMP::refresh_frame, AV1Common::seq_params, AV1_COMP::superres_mode, AV1Common::superres_scale_denominator, RATE_CONTROL::this_frame_target, and RATE_CONTROL::worst_quality.
Referenced by av1_rc_pick_q_and_bounds().
|
static |
Gets a Q value to use for the current frame.
Selects a Q value from a permitted range that we estimate will result in approximately the target number of bits.
[in] | cpi | Top level encoder instance structure |
[in] | width | Width of frame |
[in] | height | Height of frame |
[in] | active_worst_quality | Max Q allowed |
[in] | active_best_quality | Min Q allowed |
References AOM_Q, AV1_COMP::common, RATE_CONTROL::frames_to_key, AV1_COMP::gf_frame_index, AV1_PRIMARY::gf_group, PRIMARY_RATE_CONTROL::last_boosted_qindex, PRIMARY_RATE_CONTROL::last_kf_qindex, RateControlCfg::mode, AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1_COMP::ppi, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, RATE_CONTROL::this_frame_target, and AV1_PRIMARY::twopass.
Referenced by rc_pick_q_and_bounds(), tf_motion_search(), and tf_setup_filtering_buffer().
|
static |
Picks q and q bounds given rate control parameters in cpi->rc
.
Handles the the general cases not covered by rc_pick_q_and_bounds_no_stats_cbr() and rc_pick_q_and_bounds_no_stats()
[in] | cpi | Top level encoder structure |
[in] | width | Coded frame width |
[in] | height | Coded frame height |
[in] | gf_index | Index of this frame in the golden frame group |
[out] | bottom_index | Bottom bound for q index (best quality) |
[out] | top_index | Top bound for q index (worst quality) |
References PRIMARY_RATE_CONTROL::active_best_quality, RATE_CONTROL::active_worst_quality, RefreshFrameInfo::alt_ref_frame, AOM_Q, RATE_CONTROL::best_quality, AV1_COMP::common, get_q(), AV1_COMP::gf_frame_index, AV1_PRIMARY::gf_group, RefreshFrameInfo::golden_frame, has_no_stats_stage(), RateControlCfg::mode, AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1_COMP::ppi, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, AV1_COMP::refresh_frame, AV1_COMP::superres_mode, AV1Common::superres_scale_denominator, and RATE_CONTROL::this_frame_target.
Referenced by av1_rc_pick_q_and_bounds().
void av1_set_rtc_reference_structure_one_layer | ( | AV1_COMP * | cpi, |
int | gf_update ) |
Setup the reference prediction structure for 1 pass real-time.
Set the reference prediction structure for 1 layer. Current structue is to use 3 references (LAST, GOLDEN, ALTREF), where ALT_REF always behind current by lag_alt frames, and GOLDEN is either updated on LAST with period baseline_gf_interval (fixed slot) or always behind current by lag_gld (gld_fixed_slot = 0, lag_gld <= 7).
[in] | cpi | Top level encoder structure |
[in] | gf_update | Flag to indicate if GF is updated |
cpi-ext_flags
; and the buffer slot index (for each of 7 references) and refresh flags (for each of the 8 slots) are set in cpi->svc.ref_idx
[] and cpi->svc.refresh
[]. References ExtRefreshFrameFlagsInfo::alt_ref_frame, AV1_COMP::common, AV1Common::current_frame, RateControlCfg::drop_frames_water_mark, AV1_COMP::ext_flags, ExtRefreshFrameFlagsInfo::golden_frame, ExtRefreshFrameFlagsInfo::last_frame, AV1_COMP::oxcf, AV1_COMP::ppi, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, ExternalFlags::ref_frame_flags, ExternalFlags::refresh_frame, AV1_COMP::rt_reduce_num_ref_buffers, SPEED_FEATURES::rt_sf, AV1_PRIMARY::rtc_ref, AV1_COMP::sf, and ExtRefreshFrameFlagsInfo::update_pending.
Referenced by av1_encode_strategy().
|
static |
Check for scene detection, for 1 pass real-time mode.
Compute average source sad (temporal sad: between current source and previous source) over a subset of superblocks. Use this is detect big changes in content and set the cpi->rc.high_source_sad
flag.
[in] | cpi | Top level encoder structure |
[in] | frame_input | Current and last input source frames |
cpi->rc.high_source_sad
is set if scene change is detected, and cpi->rc.avg_source_sad
is updated. References AV1_COMP::active_map, AV1_COMP::common, AV1_PRIMARY::fn_ptr, AV1_COMP::framerate, AV1Common::height, SVC::layer_context, CommonModeInfoParams::mi_cols, AV1Common::mi_params, CommonModeInfoParams::mi_rows, AV1_COMP::oxcf, AV1_COMP::ppi, AV1_COMP::rc, AV1Common::render_height, AV1Common::render_width, SPEED_FEATURES::rt_sf, AV1Common::seq_params, AV1_COMP::sf, AV1_COMP::src_sad_blk_64x64, AV1_COMP::svc, and AV1Common::width.
|
static |
Compute spatial activity for keyframe, 1 pass real-time mode.
Compute average spatial activity/variance for source frame over a subset of superblocks.
[in] | cpi | Top level encoder structure |
[in] | src_y | Input source buffer for y channel. |
[in] | src_ystride | Input source stride for y channel. |
cpi->rc.spatial_variance_keyframe
. References AV1_COMP::common, AV1_PRIMARY::fn_ptr, CommonModeInfoParams::mi_cols, AV1Common::mi_params, CommonModeInfoParams::mi_rows, AV1_COMP::ppi, AV1_COMP::rc, and AV1Common::seq_params.
|
static |
Set the GF baseline interval for 1 pass real-time mode.
[in] | cpi | Top level encoder structure |
[in] | frame_type | frame type |
cpi->rc
with the next GF interval settings. References RATE_CONTROL::frames_till_gf_update_due, AV1_COMP::rc, and AV1_COMP::svc.
|
static |
ChecK for resize based on Q, for 1 pass real-time mode.
Check if we should resize, based on average QP from past x frames. Only allow for resize at most 1/2 scale down for now, Scaling factor for each step may be 3/4 or 1/2.
[in] | cpi | Top level encoder structure |
cpi->resize_pending_params
, and update some resize counters in rc
. References PRIMARY_RATE_CONTROL::buffer_level, AV1_COMP::common, AV1Common::current_frame, AV1_COMP::framerate, AV1Common::height, PRIMARY_RATE_CONTROL::last_q, PRIMARY_RATE_CONTROL::optimal_buffer_level, AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1_COMP::ppi, AV1_COMP::rc, AV1Common::width, and RATE_CONTROL::worst_quality.
void av1_rc_update_rate_correction_factors | ( | struct AV1_COMP * | cpi, |
int | is_encode_stage, | ||
int | width, | ||
int | height ) |
Updates the rate correction factor linking Q to output bits.
This function updates the Q rate correction factor after an encode cycle depending on whether we overshot or undershot the target rate.
[in] | cpi | Top level encoder instance structure |
[in] | is_encode_stage | Indicates if recode loop or post-encode |
[in] | width | Frame width |
[in] | height | Frame height |
References av1_cyclic_refresh_estimate_bits_at_q(), CommonQuantParams::base_qindex, AV1_COMP::common, AV1_COMP::cyclic_refresh, get_rate_correction_factor(), AV1_COMP::is_screen_content_type, AV1_COMP::oxcf, CYCLIC_REFRESH::percent_refresh_adjustment, AV1_COMP::ppi, RATE_CONTROL::projected_frame_size, AV1Common::quant_params, CYCLIC_REFRESH::rate_ratio_qdelta_adjustment, AV1_COMP::rc, AV1Common::seg, set_rate_correction_factor(), RATE_CONTROL::this_frame_target, and AV1_PRIMARY::use_svc.
Referenced by recode_loop_update_q().
int av1_rc_pick_q_and_bounds | ( | struct AV1_COMP * | cpi, |
int | width, | ||
int | height, | ||
int | gf_index, | ||
int * | bottom_index, | ||
int * | top_index ) |
Picks q and q bounds given the rate control parameters in cpi->rc
.
[in] | cpi | Top level encoder structure |
[in] | width | Coded frame width |
[in] | height | Coded frame height |
[in] | gf_index | Index of this frame in the golden frame group |
[out] | bottom_index | Bottom bound for q index (best quality) |
[out] | top_index | Top bound for q index (worst quality) |
rc->arf_q
. References HIGH_LEVEL_SPEED_FEATURES::accurate_bit_estimate, RATE_CONTROL::active_worst_quality, AOM_CBR, AOM_CQ, AOM_Q, PRIMARY_RATE_CONTROL::arf_q, AV1_COMP::common, AV1Common::current_frame, AV1_PRIMARY::gf_group, has_no_stats_stage(), SPEED_FEATURES::hl_sf, RateControlCfg::mode, AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1_COMP::ppi, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, rc_pick_q_and_bounds(), rc_pick_q_and_bounds_no_stats(), rc_pick_q_and_bounds_no_stats_cbr(), AV1_COMP::rec_sse, and AV1_COMP::sf.
int av1_rc_regulate_q | ( | const struct AV1_COMP * | cpi, |
int | target_bits_per_frame, | ||
int | active_best_quality, | ||
int | active_worst_quality, | ||
int | width, | ||
int | height ) |
Estimates q to achieve a target bits per frame.
[in] | cpi | Top level encoder instance structure |
[in] | target_bits_per_frame | Frame rate target |
[in] | active_worst_quality | Max Q allowed |
[in] | active_best_quality | Min Q allowed |
[in] | width | Frame width |
[in] | height | Frame height |
int av1_calc_pframe_target_size_one_pass_vbr | ( | const struct AV1_COMP *const | cpi, |
FRAME_UPDATE_TYPE | frame_update_type ) |
Calculates how many bits to use for a P frame in one pass vbr.
[in] | cpi | Top level encoder structure |
[in] | frame_update_type | Type of frame |
int av1_calc_iframe_target_size_one_pass_vbr | ( | const struct AV1_COMP *const | cpi | ) |
Calculates how many bits to use for an i frame in one pass vbr.
[in] | cpi | Top level encoder structure |
int av1_calc_pframe_target_size_one_pass_cbr | ( | const struct AV1_COMP * | cpi, |
FRAME_UPDATE_TYPE | frame_update_type ) |
Calculates how many bits to use for a P frame in one pass cbr.
[in] | cpi | Top level encoder structure |
[in] | frame_update_type | Type of frame |
int av1_calc_iframe_target_size_one_pass_cbr | ( | const struct AV1_COMP * | cpi | ) |
Calculates how many bits to use for an i frame in one pass cbr.
[in] | cpi | Top level encoder structure |
void av1_get_one_pass_rt_params | ( | struct AV1_COMP * | cpi, |
FRAME_TYPE *const | frame_type, | ||
const struct EncodeFrameInput * | frame_input, | ||
unsigned int | frame_flags ) |
Setup the rate control parameters for 1 pass real-time mode.
[in] | cpi | Top level encoder structure |
[in] | frame_type | Encoder frame type |
[in] | frame_input | Current and last input source frames |
[in] | frame_flags | Encoder frame flags |
frame_params
, cpi->common
, cpi->rc
, cpi->svc
. int av1_encodedframe_overshoot_cbr | ( | struct AV1_COMP * | cpi, |
int * | q ) |
Increase q on expected encoder overshoot, for CBR mode.
Handles the case when encoder is expected to create a large frame:
cpi->rc.worst_quality
[in] | cpi | Top level encoder structure |
[in] | q | Current q index |
cpi->rc
. References PRIMARY_RATE_CONTROL::avg_frame_qindex, PRIMARY_RATE_CONTROL::bits_off_target, PRIMARY_RATE_CONTROL::buffer_level, AV1_COMP::common, AV1_COMP::cyclic_refresh, SVC::layer_context, CommonModeInfoParams::MBs, AV1Common::mi_params, PRIMARY_RATE_CONTROL::optimal_buffer_level, AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1_COMP::ppi, PRIMARY_RATE_CONTROL::rate_correction_factors, AV1_COMP::rc, AV1Common::seq_params, AV1_COMP::svc, and RATE_CONTROL::worst_quality.
Referenced by encode_without_recode().
int av1_postencode_drop_cbr | ( | struct AV1_COMP * | cpi, |
size_t * | size ) |
Check if frame should be dropped, for RTC mode.
[in] | cpi | Top level encoder structure |
[in,out] | size | Size of encoded frame |
References PRIMARY_RATE_CONTROL::avg_frame_qindex, CommonQuantParams::base_qindex, PRIMARY_RATE_CONTROL::bits_off_target, PRIMARY_RATE_CONTROL::buffer_level, AV1_COMP::common, AV1_COMP::is_dropped_frame, SVC::layer_context, PRIMARY_RATE_CONTROL::optimal_buffer_level, AV1_PRIMARY::p_rc, AV1_COMP::ppi, AV1Common::quant_params, AV1_COMP::rc, AV1_COMP::svc, and RATE_CONTROL::worst_quality.
Referenced by encode_with_recode_loop_and_filter().
|
inlinestatic |
Function to test for conditions that indicate we should loop back and recode a frame.
[in] | cpi | Top-level encoder structure |
[in] | high_limit | Upper rate threshold |
[in] | low_limit | Lower rate threshold |
[in] | q | Current q index |
[in] | maxq | Maximum allowed q index |
[in] | minq | Minimum allowed q index |
1 | Recode Required |
0 | No Recode required |
References AOM_CQ, RateControlCfg::cq_level, SPEED_FEATURES::hl_sf, RateControlCfg::mode, AV1_COMP::oxcf, RATE_CONTROL::projected_frame_size, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, HIGH_LEVEL_SPEED_FEATURES::recode_loop, AV1_COMP::sf, and RATE_CONTROL::this_frame_target.
Referenced by recode_loop_update_q().
|
inlinestatic |
Called after encode_with_recode_loop() has just encoded a frame. This function works out whether we undershot or overshot our bitrate target and adjusts q as appropriate. It also decides whether or not we need to recode the frame to get closer to the target rate.
[in] | cpi | Top-level encoder structure |
[out] | loop | Should we go around the recode loop again |
[in,out] | q | New q index value |
[in,out] | q_low | Low q index limit for this loop itteration |
[in,out] | q_high | High q index limit for this loop itteration |
[in] | top_index | Max permited new value for q index |
[in] | bottom_index | Min permited new value for q index |
[in,out] | undershoot_seen | Have we seen undershoot on this frame |
[in,out] | overshoot_seen | Have we seen overshoot on this frame |
[in,out] | low_cr_seen | Have we previously trriggered recode because the compression ration was less than a given minimum threshold. |
[in] | loop_count | Loop itterations so far. |
References AV1_COMP::ambient_err, AOM_CQ, AOM_Q, av1_rc_update_rate_correction_factors(), RATE_CONTROL::best_quality, AV1_COMP::common, AV1Common::cur_frame, AV1Common::current_frame, AV1_COMP::gf_frame_index, AV1_PRIMARY::gf_group, AV1Common::height, AV1_PRIMARY::level_params, RateControlCfg::min_cr, RateControlCfg::mode, AV1_COMP::oxcf, AV1_PRIMARY::p_rc, AV1_COMP::ppi, RATE_CONTROL::projected_frame_size, AV1_COMP::rc, AV1EncoderConfig::rc_cfg, recode_loop_test(), AV1Common::seq_params, AV1_COMP::source, RATE_CONTROL::this_frame_target, AV1Common::width, and RATE_CONTROL::worst_quality.
Referenced by encode_with_recode_loop().
|
static |
Return layer context for current layer.
[in] | cpi | Top level encoder structure |
References SVC::layer_context, and AV1_COMP::svc.
Referenced by av1_restore_layer_context(), av1_save_layer_context(), and av1_update_temporal_layer_framerate().