| @@ -11,6 +11,7 @@ · 10 unmodified lines |
| 11 | 11 | |
| 12 | 12 | #include <new> |
| 13 | 13 | |
| 14 | +#include "vp9/common/vp9_common.h" |
| 14 | 15 | #include "vp9/encoder/vp9_encoder.h" |
| 15 | 16 | #include "vp9/encoder/vp9_picklpf.h" |
| 16 | 17 | #include "vpx/vp8cx.h" |
| @@ -28,6 +29,15 @@ std::unique_ptr<VP9RateControlRTC> VP9RateControlRTC::Create( · 11 unmodified lines |
| 28 | 29 | return nullptr; |
| 29 | 30 | } |
| 30 | 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 | 41 | return rc_api; |
| 32 | 42 | } |
| 33 | 43 | |
| @@ -42,13 +52,14 @@ void VP9RateControlRTC::InitRateControl(const VP9RateControlRtcConfig &rc_cfg) { · 8 unmodified lines |
| 42 | 52 | oxcf->bit_depth = cm->bit_depth; |
| 43 | 53 | oxcf->rc_mode = rc_cfg.rc_mode; |
| 44 | 54 | oxcf->pass = 0; |
| 45 | | − oxcf->aq_mode = NO_AQ; |
| 55 | + oxcf->aq_mode = rc_cfg.aq_mode ? CYCLIC_REFRESH_AQ : NO_AQ; |
| 46 | 56 | oxcf->content = VP9E_CONTENT_DEFAULT; |
| 47 | 57 | oxcf->drop_frames_water_mark = 0; |
| 48 | 58 | cm->current_video_frame = 0; |
| 49 | 59 | rc->kf_boost = DEFAULT_KF_BOOST; |
| 50 | 60 | |
| 51 | 61 | UpdateRateControl(rc_cfg); |
| 62 | + vp9_set_mb_mi(cm, cm->width, cm->height); |
| 52 | 63 | |
| 53 | 64 | cpi_->use_svc = (cpi_->svc.number_spatial_layers > 1 || |
| 54 | 65 | cpi_->svc.number_temporal_layers > 1) |
| @@ -146,6 +157,8 @@ void VP9RateControlRTC::ComputeQP(const VP9FrameParamsQpRTC &frame_params) { · 91 unmodified lines |
| 146 | 157 | cpi_->svc.number_temporal_layers == 1) { |
| 147 | 158 | int target = 0; |
| 148 | 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 | 162 | if (frame_is_intra_only(cm)) |
| 150 | 163 | target = vp9_calc_iframe_target_size_one_pass_cbr(cpi_); |
| 151 | 164 | else |
| @@ -156,6 +169,8 @@ void VP9RateControlRTC::ComputeQP(const VP9FrameParamsQpRTC &frame_params) { · 4 unmodified lines |
| 156 | 169 | cpi_->rc.frames_to_key = cpi_->oxcf.key_freq; |
| 157 | 170 | } |
| 158 | 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 | 174 | if (frame_is_intra_only(cm)) |
| 160 | 175 | target = vp9_calc_iframe_target_size_one_pass_vbr(cpi_); |
| 161 | 176 | else |
| @@ -171,6 +186,8 @@ void VP9RateControlRTC::ComputeQP(const VP9FrameParamsQpRTC &frame_params) { · 9 unmodified lines |
| 171 | 186 | int bottom_index, top_index; |
| 172 | 187 | cpi_->common.base_qindex = |
| 173 | 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 | 193 | int VP9RateControlRTC::GetQP() const { return cpi_->common.base_qindex; } |
| @@ -181,6 +198,14 @@ int VP9RateControlRTC::GetLoopfilterLevel() const { · 4 unmodified lines |
| 181 | 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 | 209 | void VP9RateControlRTC::PostEncodeUpdate(uint64_t encoded_frame_size) { |
| 185 | 210 | vp9_rc_postencode_update(cpi_, encoded_frame_size); |
| 186 | 211 | if (cpi_->svc.number_spatial_layers > 1 || |