History

Change calculation of rd multiplier.

Change the way the rd multiplier is adjusted for Q and frame type. Previously in VP9 the rd multiplier was adjusted based on crude Q bins and whether the frame was a key frame or inter frame. The Q bins create some problems as they potentially introduce discontinuities in the RD curve. For example, rate rising with a stepwise increase in Q instead of falling. As such, in AV1 they have been removed. A further issue was identified when examining the first round of results from from the Vizier project. Here the multiplier for each Q bin and each frame type was optimized for a training set, for various video formats, using single point encodes at the appropriate YT rates. These initial results appeared to show a trend for increased rd multiplier at higher Q for key frames. This fits with intuition as in this encoding context a higher Q indicates that a clip is harder to encode and frames less well predicted. However, the situation appeared to reverse for inter frames with higher rd multipliers chosen at low Q. My initial suspicion was that this was a result of over fitting, but on closer analysis I realized that this may be more related to frame type within the broader inter frame classification. Specifically frames coded at low Q are predominantly ARF frames, for the mid Q bin there will likely be a mix of ARF and normal inter frames, and for the high Q bin the frames will almost exclusively be normal inter frames from difficult content. ARF frames are inherently less well predicted than other inter frames being further apart and not having access to as many prediction modes. We also know from previous work that ARF frames have a higher incidence of INTRA coding and may well behave more like key frames in this context. This patch replaces the bin based approach with a linear function that applies a small but smooth Q based adjustment. It also splits ARF frames and normal inter frames into separate categories. With this done number of parameters that will be exposed for the next round of Vizier training is reduced from 7 to 3 (one adjustment factor each for inter, ARF and key frames) This patch gives net BDATE gains for our test sets even with the baseline / default factors as follows: (% BDRATE change in overall PSNR and SSIM, -ve is better) LowRes -0.231, -0.050 ugc360p 0.160, -0.315 midres2 -0.348, -1.170 hdres2 -0.407, -0.691

Paul Wilkins committed 5 years ago

Commit d3aaac31 parent e37ee402 files · +50 −74Browse files

Unified · Split

2 files
  1. vp9/encoder/vp9_rd.c +47 −67
  2. vp9/encoder/vp9_rd.h +3 −7
vp9/encoder/vp9_rd.c+47−67
@@ -205,62 +205,36 @@ void vp9_init_rd_parameters(VP9_COMP *cpi) { · 204 unmodified lines
205205 // Make sure this function is floating point safe.
206206 vpx_clear_system_state();
207207
208− rdc->rd_mult_key_high_qp_fac = 1.0; // Default: no Vizer values yet
208+ rdc->rd_mult_arf_qp_fac = 1.0; // Default: No Vizier values yet
209209
210+ // These hard wired estimates for the Vizier values will be removed later
211+ // as the per format factors will be set on the command line.
210212 if (0) {
211213 unsigned int screen_area = (cpi->common.width * cpi->common.height);
212214
213215 if (screen_area <= 176 * 144) {
214− rdc->rd_mult_inter_low_qp_fac = 1.018;
215− rdc->rd_mult_inter_mid_qp_fac = 0.896;
216− rdc->rd_mult_inter_high_qp_fac = 1.432;
217− rdc->rd_mult_key_ultralow_qp_fac = 1.073;
218− rdc->rd_mult_key_low_qp_fac = 1.630;
219− rdc->rd_mult_key_mid_qp_fac = 1.050;
216+ rdc->rd_mult_inter_qp_fac = 0.896;
217+ rdc->rd_mult_key_qp_fac = 1.050;
220218 } else if (screen_area <= 320 * 240) {
221− rdc->rd_mult_inter_low_qp_fac = 1.127;
222− rdc->rd_mult_inter_mid_qp_fac = 0.998;
223− rdc->rd_mult_inter_high_qp_fac = 1.463;
224− rdc->rd_mult_key_ultralow_qp_fac = 1.054;
225− rdc->rd_mult_key_low_qp_fac = 1.285;
226− rdc->rd_mult_key_mid_qp_fac = 0.952;
219+ rdc->rd_mult_inter_qp_fac = 0.998;
220+ rdc->rd_mult_key_qp_fac = 0.952;
227221 } else if (screen_area <= 640 * 360) {
228− rdc->rd_mult_inter_low_qp_fac = 1.183;
229− rdc->rd_mult_inter_mid_qp_fac = 0.959;
230− rdc->rd_mult_inter_high_qp_fac = 1.457;
231− rdc->rd_mult_key_ultralow_qp_fac = 1.144;
232− rdc->rd_mult_key_low_qp_fac = 1.734;
233− rdc->rd_mult_key_mid_qp_fac = 1.071;
222+ rdc->rd_mult_inter_qp_fac = 0.959;
223+ rdc->rd_mult_key_qp_fac = 1.071;
234224 } else if (screen_area <= 854 * 480) {
235− rdc->rd_mult_inter_low_qp_fac = 1.203;
236− rdc->rd_mult_inter_mid_qp_fac = 1.027;
237− rdc->rd_mult_inter_high_qp_fac = 1.027;
238− rdc->rd_mult_key_ultralow_qp_fac = 1.246;
239− rdc->rd_mult_key_low_qp_fac = 1.246;
240− rdc->rd_mult_key_mid_qp_fac = 1.280;
225+ rdc->rd_mult_inter_qp_fac = 1.027;
226+ rdc->rd_mult_key_qp_fac = 1.280;
241227 } else if (screen_area <= 1280 * 720) {
242− rdc->rd_mult_inter_low_qp_fac = 1.280;
243− rdc->rd_mult_inter_mid_qp_fac = 1.004;
244− rdc->rd_mult_inter_high_qp_fac = 1.470;
245− rdc->rd_mult_key_ultralow_qp_fac = 0.987;
246− rdc->rd_mult_key_low_qp_fac = 1.671;
247− rdc->rd_mult_key_mid_qp_fac = 1.193;
228+ rdc->rd_mult_inter_qp_fac = 1.004;
229+ rdc->rd_mult_key_qp_fac = 1.193;
248230 } else {
249− rdc->rd_mult_inter_low_qp_fac = 1.50;
250− rdc->rd_mult_inter_mid_qp_fac = 0.874;
251− rdc->rd_mult_inter_high_qp_fac = 1.07;
252− rdc->rd_mult_key_ultralow_qp_fac = 1.1;
253− rdc->rd_mult_key_low_qp_fac = 2.35;
254− rdc->rd_mult_key_mid_qp_fac = 0.837;
231+ rdc->rd_mult_inter_qp_fac = 0.874;
232+ rdc->rd_mult_key_qp_fac = 0.837;
255233 }
256234 } else {
257235 // For now force defaults unless testing
258− rdc->rd_mult_inter_low_qp_fac = 1.0;
259− rdc->rd_mult_inter_mid_qp_fac = 1.0;
260− rdc->rd_mult_inter_high_qp_fac = 1.0;
261− rdc->rd_mult_key_ultralow_qp_fac = 1.0;
262− rdc->rd_mult_key_low_qp_fac = 1.0;
263− rdc->rd_mult_key_mid_qp_fac = 1.0;
236+ rdc->rd_mult_inter_qp_fac = 1.0;
237+ rdc->rd_mult_key_qp_fac = 1.0;
264238 }
265239 }
266240
@@ -273,6 +247,27 @@ void vp9_init_rd_parameters(VP9_COMP *cpi) { · 6 unmodified lines
273247 #define KEY_MID_QP_RDM 4.5
274248 #define KEY_HIGH_QP_RDM 7.5
275249
250+// Returns the default rd multiplier for inter frames for a given qindex.
251+// The function here is a first pass estimate based on data from
252+// a previous Vizer run
253+static double def_inter_rd_multiplier(int qindex) {
254+ return 4.15 + (0.001 * (double)qindex);
255+}
256+
257+// Returns the default rd multiplier for ARF/Golden Frames for a given qindex.
258+// The function here is a first pass estimate based on data from
259+// a previous Vizer run
260+static double def_arf_rd_multiplier(int qindex) {
261+ return 4.25 + (0.001 * (double)qindex);
262+}
263+
264+// Returns the default rd multiplier for key frames for a given qindex.
265+// The function here is a first pass estimate based on data from
266+// a previous Vizer run
267+static double def_kf_rd_multiplier(int qindex) {
268+ return 4.35 + (0.001 * (double)qindex);
269+}
270+
276271 int vp9_compute_rd_mult_based_on_qindex(const VP9_COMP *cpi, int qindex) {
277272 const RD_CONTROL *rdc = &cpi->rd_ctrl;
278273 const int q = vp9_dc_quant(qindex, 0, cpi->common.bit_depth);
@@ -282,31 +277,16 @@ int vp9_compute_rd_mult_based_on_qindex(const VP9_COMP *cpi, int qindex) { · 3 unmodified lines
282277 // Make sure this function is floating point safe.
283278 vpx_clear_system_state();
284279
285− if (cpi->common.frame_type != KEY_FRAME) {
286− if (qindex < 128) {
287− rdmult = (int)((double)rdmult * INTER_LOW_QP_RDM *
288− rdc->rd_mult_inter_low_qp_fac);
289− } else if (qindex < 190) {
290− rdmult = (int)((double)rdmult * INTER_MID_QP_RDM *
291− rdc->rd_mult_inter_mid_qp_fac);
292− } else {
293− rdmult = (int)((double)rdmult * INTER_HIGH_QP_RDM *
294− rdc->rd_mult_inter_high_qp_fac);
295− }
280+ if (cpi->common.frame_type == KEY_FRAME) {
281+ double def_rd_q_mult = def_kf_rd_multiplier(qindex);
282+ rdmult = (int)((double)rdmult * def_rd_q_mult * rdc->rd_mult_key_qp_fac);
283+ } else if (!cpi->rc.is_src_frame_alt_ref &&
284+ (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) {
285+ double def_rd_q_mult = def_arf_rd_multiplier(qindex);
286+ rdmult = (int)((double)rdmult * def_rd_q_mult * rdc->rd_mult_arf_qp_fac);
296287 } else {
297− if (qindex < 64) {
298− rdmult = (int)((double)rdmult * KEY_ULOW_QP_RDM *
299− rdc->rd_mult_key_ultralow_qp_fac);
300− } else if (qindex <= 128) {
301− rdmult =
302− (int)((double)rdmult * KEY_LOW_QP_RDM * rdc->rd_mult_key_low_qp_fac);
303− } else if (qindex < 190) {
304− rdmult =
305− (int)((double)rdmult * KEY_MID_QP_RDM * rdc->rd_mult_key_mid_qp_fac);
306− } else {
307− rdmult = (int)((double)rdmult * KEY_HIGH_QP_RDM *
308− rdc->rd_mult_key_high_qp_fac);
309− }
288+ double def_rd_q_mult = def_inter_rd_multiplier(qindex);
289+ rdmult = (int)((double)rdmult * def_rd_q_mult * rdc->rd_mult_inter_qp_fac);
310290 }
311291
312292 #if CONFIG_VP9_HIGHBITDEPTH
vp9/encoder/vp9_rd.h+3−7
@@ -103,13 +103,9 @@ typedef enum { · 102 unmodified lines
103103
104104 typedef struct {
105105 // RD multiplier control factors added for Vizier project.
106− double rd_mult_inter_low_qp_fac;
107− double rd_mult_inter_mid_qp_fac;
108− double rd_mult_inter_high_qp_fac;
109− double rd_mult_key_ultralow_qp_fac;
110− double rd_mult_key_low_qp_fac;
111− double rd_mult_key_mid_qp_fac;
112− double rd_mult_key_high_qp_fac;
106+ double rd_mult_inter_qp_fac;
107+ double rd_mult_arf_qp_fac;
108+ double rd_mult_key_qp_fac;
113109 } RD_CONTROL;
114110
115111 typedef struct RD_OPT {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t