| @@ -11,6 +11,7 @@ · 10 unmodified lines |
| 11 | | 11 | |
| 12 | #include <new> | 12 | #include <new> |
| 13 | | 13 | |
| | 14 | #include "vp9/common/vp9_common.h" |
| 14 | #include "vp9/encoder/vp9_encoder.h" | 15 | #include "vp9/encoder/vp9_encoder.h" |
| 15 | #include "vp9/encoder/vp9_picklpf.h" | 16 | #include "vp9/encoder/vp9_picklpf.h" |
| 16 | #include "vpx/vp8cx.h" | 17 | #include "vpx/vp8cx.h" |
| @@ -28,6 +29,15 @@ std::unique_ptr<VP9RateControlRTC> VP9RateControlRTC::Create( · 11 unmodified lines |
| 28 | return nullptr; | 29 | return nullptr; |
| 29 | } | 30 | } |
| 30 | rc_api->InitRateControl(cfg); | 31 | rc_api->InitRateControl(cfg); |
| | 32 | if (cfg.aq_mode) { |
| | 33 | VP9_COMP *const cpi = rc_api->cpi_; |
| | 34 | cpi->segmentation_map = static_cast<uint8_t *>( |
| | 35 | vpx_calloc(cpi->common.mi_rows * cpi->common.mi_cols, |
| | 36 | sizeof(*cpi->segmentation_map))); |
| | 37 | cpi->cyclic_refresh = |
| | 38 | vp9_cyclic_refresh_alloc(cpi->common.mi_rows, cpi->common.mi_cols); |
| | 39 | cpi->cyclic_refresh->content_mode = 0; |
| | 40 | } |
| 31 | return rc_api; | 41 | return rc_api; |
| 32 | } | 42 | } |
| 33 | | 43 | |
| @@ -42,13 +52,14 @@ void VP9RateControlRTC::InitRateControl(const VP9RateControlRtcConfig &rc_cfg) { · 8 unmodified lines |
| 42 | oxcf->bit_depth = cm->bit_depth; | 52 | oxcf->bit_depth = cm->bit_depth; |
| 43 | oxcf->rc_mode = rc_cfg.rc_mode; | 53 | oxcf->rc_mode = rc_cfg.rc_mode; |
| 44 | oxcf->pass = 0; | 54 | oxcf->pass = 0; |
| 45 | oxcf->aq_mode = NO_AQ; | 55 | oxcf->aq_mode = rc_cfg.aq_mode ? CYCLIC_REFRESH_AQ : NO_AQ; |
| 46 | oxcf->content = VP9E_CONTENT_DEFAULT; | 56 | oxcf->content = VP9E_CONTENT_DEFAULT; |
| 47 | oxcf->drop_frames_water_mark = 0; | 57 | oxcf->drop_frames_water_mark = 0; |
| 48 | cm->current_video_frame = 0; | 58 | cm->current_video_frame = 0; |
| 49 | rc->kf_boost = DEFAULT_KF_BOOST; | 59 | rc->kf_boost = DEFAULT_KF_BOOST; |
| 50 | | 60 | |
| 51 | UpdateRateControl(rc_cfg); | 61 | UpdateRateControl(rc_cfg); |
| | 62 | vp9_set_mb_mi(cm, cm->width, cm->height); |
| 52 | | 63 | |
| 53 | cpi_->use_svc = (cpi_->svc.number_spatial_layers > 1 || | 64 | cpi_->use_svc = (cpi_->svc.number_spatial_layers > 1 || |
| 54 | cpi_->svc.number_temporal_layers > 1) | 65 | cpi_->svc.number_temporal_layers > 1) |
| @@ -146,6 +157,8 @@ void VP9RateControlRTC::ComputeQP(const VP9FrameParamsQpRTC &frame_params) { · 91 unmodified lines |
| 146 | cpi_->svc.number_temporal_layers == 1) { | 157 | cpi_->svc.number_temporal_layers == 1) { |
| 147 | int target = 0; | 158 | int target = 0; |
| 148 | if (cpi_->oxcf.rc_mode == VPX_CBR) { | 159 | if (cpi_->oxcf.rc_mode == VPX_CBR) { |
| | 160 | if (cpi_->oxcf.aq_mode == CYCLIC_REFRESH_AQ) |
| | 161 | vp9_cyclic_refresh_update_parameters(cpi_); |
| 149 | if (frame_is_intra_only(cm)) | 162 | if (frame_is_intra_only(cm)) |
| 150 | target = vp9_calc_iframe_target_size_one_pass_cbr(cpi_); | 163 | target = vp9_calc_iframe_target_size_one_pass_cbr(cpi_); |
| 151 | else | 164 | else |
| @@ -156,6 +169,8 @@ void VP9RateControlRTC::ComputeQP(const VP9FrameParamsQpRTC &frame_params) { · 4 unmodified lines |
| 156 | cpi_->rc.frames_to_key = cpi_->oxcf.key_freq; | 169 | cpi_->rc.frames_to_key = cpi_->oxcf.key_freq; |
| 157 | } | 170 | } |
| 158 | vp9_set_gf_update_one_pass_vbr(cpi_); | 171 | vp9_set_gf_update_one_pass_vbr(cpi_); |
| | 172 | if (cpi_->oxcf.aq_mode == CYCLIC_REFRESH_AQ) |
| | 173 | vp9_cyclic_refresh_update_parameters(cpi_); |
| 159 | if (frame_is_intra_only(cm)) | 174 | if (frame_is_intra_only(cm)) |
| 160 | target = vp9_calc_iframe_target_size_one_pass_vbr(cpi_); | 175 | target = vp9_calc_iframe_target_size_one_pass_vbr(cpi_); |
| 161 | else | 176 | else |
| @@ -171,6 +186,8 @@ void VP9RateControlRTC::ComputeQP(const VP9FrameParamsQpRTC &frame_params) { · 9 unmodified lines |
| 171 | int bottom_index, top_index; | 186 | int bottom_index, top_index; |
| 172 | cpi_->common.base_qindex = | 187 | cpi_->common.base_qindex = |
| 173 | vp9_rc_pick_q_and_bounds(cpi_, &bottom_index, &top_index); | 188 | vp9_rc_pick_q_and_bounds(cpi_, &bottom_index, &top_index); |
| | 189 | |
| | 190 | if (cpi_->oxcf.aq_mode == CYCLIC_REFRESH_AQ) vp9_cyclic_refresh_setup(cpi_); |
| 174 | } | 191 | } |
| 175 | | 192 | |
| 176 | int VP9RateControlRTC::GetQP() const { return cpi_->common.base_qindex; } | 193 | int VP9RateControlRTC::GetQP() const { return cpi_->common.base_qindex; } |
| @@ -181,6 +198,14 @@ int VP9RateControlRTC::GetLoopfilterLevel() const { · 4 unmodified lines |
| 181 | return lf->filter_level; | 198 | return lf->filter_level; |
| 182 | } | 199 | } |
| 183 | | 200 | |
| | 201 | signed char *VP9RateControlRTC::GetCyclicRefreshMap() const { |
| | 202 | return cpi_->cyclic_refresh->map; |
| | 203 | } |
| | 204 | |
| | 205 | int *VP9RateControlRTC::GetDeltaQ() const { |
| | 206 | return cpi_->cyclic_refresh->qindex_delta; |
| | 207 | } |
| | 208 | |
| 184 | void VP9RateControlRTC::PostEncodeUpdate(uint64_t encoded_frame_size) { | 209 | void VP9RateControlRTC::PostEncodeUpdate(uint64_t encoded_frame_size) { |
| 185 | vp9_rc_postencode_update(cpi_, encoded_frame_size); | 210 | vp9_rc_postencode_update(cpi_, encoded_frame_size); |
| 186 | if (cpi_->svc.number_spatial_layers > 1 || | 211 | if (cpi_->svc.number_spatial_layers > 1 || |