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
205 // Make sure this function is floating point safe.205 // Make sure this function is floating point safe.
206 vpx_clear_system_state();206 vpx_clear_system_state();
207 207
208 rdc->rd_mult_key_high_qp_fac = 1.0; // Default: no Vizer values yet208 rdc->rd_mult_arf_qp_fac = 1.0; // Default: No Vizier values yet
209 209
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.
210 if (0) {212 if (0) {
211 unsigned int screen_area = (cpi->common.width * cpi->common.height);213 unsigned int screen_area = (cpi->common.width * cpi->common.height);
212 214
213 if (screen_area <= 176 * 144) {215 if (screen_area <= 176 * 144) {
214 rdc->rd_mult_inter_low_qp_fac = 1.018;216 rdc->rd_mult_inter_qp_fac = 0.896;
215 rdc->rd_mult_inter_mid_qp_fac = 0.896;217 rdc->rd_mult_key_qp_fac = 1.050;
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;
220 } else if (screen_area <= 320 * 240) {218 } else if (screen_area <= 320 * 240) {
221 rdc->rd_mult_inter_low_qp_fac = 1.127;219 rdc->rd_mult_inter_qp_fac = 0.998;
222 rdc->rd_mult_inter_mid_qp_fac = 0.998;220 rdc->rd_mult_key_qp_fac = 0.952;
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;
227 } else if (screen_area <= 640 * 360) {221 } else if (screen_area <= 640 * 360) {
228 rdc->rd_mult_inter_low_qp_fac = 1.183;222 rdc->rd_mult_inter_qp_fac = 0.959;
229 rdc->rd_mult_inter_mid_qp_fac = 0.959;223 rdc->rd_mult_key_qp_fac = 1.071;
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;
234 } else if (screen_area <= 854 * 480) {224 } else if (screen_area <= 854 * 480) {
235 rdc->rd_mult_inter_low_qp_fac = 1.203;225 rdc->rd_mult_inter_qp_fac = 1.027;
236 rdc->rd_mult_inter_mid_qp_fac = 1.027;226 rdc->rd_mult_key_qp_fac = 1.280;
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;
241 } else if (screen_area <= 1280 * 720) {227 } else if (screen_area <= 1280 * 720) {
242 rdc->rd_mult_inter_low_qp_fac = 1.280;228 rdc->rd_mult_inter_qp_fac = 1.004;
243 rdc->rd_mult_inter_mid_qp_fac = 1.004;229 rdc->rd_mult_key_qp_fac = 1.193;
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;
248 } else {230 } else {
249 rdc->rd_mult_inter_low_qp_fac = 1.50;231 rdc->rd_mult_inter_qp_fac = 0.874;
250 rdc->rd_mult_inter_mid_qp_fac = 0.874;232 rdc->rd_mult_key_qp_fac = 0.837;
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;
255 }233 }
256 } else {234 } else {
257 // For now force defaults unless testing235 // For now force defaults unless testing
258 rdc->rd_mult_inter_low_qp_fac = 1.0;236 rdc->rd_mult_inter_qp_fac = 1.0;
259 rdc->rd_mult_inter_mid_qp_fac = 1.0;237 rdc->rd_mult_key_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;
264 }238 }
265}239}
266 240
@@ -273,6 +247,27 @@ void vp9_init_rd_parameters(VP9_COMP *cpi) { · 6 unmodified lines
273#define KEY_MID_QP_RDM 4.5247#define KEY_MID_QP_RDM 4.5
274#define KEY_HIGH_QP_RDM 7.5248#define KEY_HIGH_QP_RDM 7.5
275 249
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
253static 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
260static 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
267static double def_kf_rd_multiplier(int qindex) {
268 return 4.35 + (0.001 * (double)qindex);
269}
270
276int vp9_compute_rd_mult_based_on_qindex(const VP9_COMP *cpi, int qindex) {271int vp9_compute_rd_mult_based_on_qindex(const VP9_COMP *cpi, int qindex) {
277 const RD_CONTROL *rdc = &cpi->rd_ctrl;272 const RD_CONTROL *rdc = &cpi->rd_ctrl;
278 const int q = vp9_dc_quant(qindex, 0, cpi->common.bit_depth);273 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
282 // Make sure this function is floating point safe.277 // Make sure this function is floating point safe.
283 vpx_clear_system_state();278 vpx_clear_system_state();
284 279
285 if (cpi->common.frame_type != KEY_FRAME) {280 if (cpi->common.frame_type == KEY_FRAME) {
286 if (qindex < 128) {281 double def_rd_q_mult = def_kf_rd_multiplier(qindex);
287 rdmult = (int)((double)rdmult * INTER_LOW_QP_RDM *282 rdmult = (int)((double)rdmult * def_rd_q_mult * rdc->rd_mult_key_qp_fac);
288 rdc->rd_mult_inter_low_qp_fac);283 } else if (!cpi->rc.is_src_frame_alt_ref &&
289 } else if (qindex < 190) {284 (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) {
290 rdmult = (int)((double)rdmult * INTER_MID_QP_RDM *285 double def_rd_q_mult = def_arf_rd_multiplier(qindex);
291 rdc->rd_mult_inter_mid_qp_fac);286 rdmult = (int)((double)rdmult * def_rd_q_mult * rdc->rd_mult_arf_qp_fac);
292 } else {
293 rdmult = (int)((double)rdmult * INTER_HIGH_QP_RDM *
294 rdc->rd_mult_inter_high_qp_fac);
295 }
296 } else {287 } else {
297 if (qindex < 64) {288 double def_rd_q_mult = def_inter_rd_multiplier(qindex);
298 rdmult = (int)((double)rdmult * KEY_ULOW_QP_RDM *289 rdmult = (int)((double)rdmult * def_rd_q_mult * rdc->rd_mult_inter_qp_fac);
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 }
310 }290 }
311 291
312#if CONFIG_VP9_HIGHBITDEPTH292#if CONFIG_VP9_HIGHBITDEPTH
vp9/encoder/vp9_rd.h+3−7
@@ -103,13 +103,9 @@ typedef enum { · 102 unmodified lines
103 103
104typedef struct {104typedef struct {
105 // RD multiplier control factors added for Vizier project.105 // RD multiplier control factors added for Vizier project.
106 double rd_mult_inter_low_qp_fac;106 double rd_mult_inter_qp_fac;
107 double rd_mult_inter_mid_qp_fac;107 double rd_mult_arf_qp_fac;
108 double rd_mult_inter_high_qp_fac;108 double rd_mult_key_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;
113} RD_CONTROL;109} RD_CONTROL;
114 110
115typedef struct RD_OPT {111typedef 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