OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 MACROBLOCK *x, MACROBLOCKD *xd, | 164 MACROBLOCK *x, MACROBLOCKD *xd, |
165 int *out_rate_sum, int64_t *out_dist_sum) { | 165 int *out_rate_sum, int64_t *out_dist_sum) { |
166 // Note our transform coeffs are 8 times an orthogonal transform. | 166 // Note our transform coeffs are 8 times an orthogonal transform. |
167 // Hence quantizer step is also 8 times. To get effective quantizer | 167 // Hence quantizer step is also 8 times. To get effective quantizer |
168 // we need to divide by 8 before sending to modeling function. | 168 // we need to divide by 8 before sending to modeling function. |
169 int i; | 169 int i; |
170 int64_t rate_sum = 0; | 170 int64_t rate_sum = 0; |
171 int64_t dist_sum = 0; | 171 int64_t dist_sum = 0; |
172 const int ref = xd->mi[0]->mbmi.ref_frame[0]; | 172 const int ref = xd->mi[0]->mbmi.ref_frame[0]; |
173 unsigned int sse; | 173 unsigned int sse; |
| 174 unsigned int var = 0; |
| 175 unsigned int sum_sse = 0; |
174 const int shift = 8; | 176 const int shift = 8; |
| 177 int rate; |
| 178 int64_t dist; |
| 179 |
| 180 x->pred_sse[ref] = 0; |
175 | 181 |
176 for (i = 0; i < MAX_MB_PLANE; ++i) { | 182 for (i = 0; i < MAX_MB_PLANE; ++i) { |
177 struct macroblock_plane *const p = &x->plane[i]; | 183 struct macroblock_plane *const p = &x->plane[i]; |
178 struct macroblockd_plane *const pd = &xd->plane[i]; | 184 struct macroblockd_plane *const pd = &xd->plane[i]; |
179 const BLOCK_SIZE bs = get_plane_block_size(bsize, pd); | 185 const BLOCK_SIZE bs = get_plane_block_size(bsize, pd); |
| 186 const TX_SIZE max_tx_size = max_txsize_lookup[bs]; |
| 187 const BLOCK_SIZE unit_size = txsize_to_bsize[max_tx_size]; |
| 188 int bw = 1 << (b_width_log2_lookup[bs] - b_width_log2_lookup[unit_size]); |
| 189 int bh = 1 << (b_height_log2_lookup[bs] - b_width_log2_lookup[unit_size]); |
| 190 int idx, idy; |
| 191 int lw = b_width_log2_lookup[unit_size] + 2; |
| 192 int lh = b_height_log2_lookup[unit_size] + 2; |
180 | 193 |
181 const unsigned int var = cpi->fn_ptr[bs].vf(p->src.buf, p->src.stride, | 194 sum_sse = 0; |
182 pd->dst.buf, pd->dst.stride, | |
183 &sse); | |
184 | 195 |
185 if (!x->select_tx_size) { | 196 for (idy = 0; idy < bh; ++idy) { |
186 if (sse < p->quant_thred[0] >> shift) | 197 for (idx = 0; idx < bw; ++idx) { |
187 x->skip_txfm[i] = 1; | 198 uint8_t *src = p->src.buf + (idy * p->src.stride << lh) + (idx << lw); |
188 else if (var < p->quant_thred[1] >> shift) | 199 uint8_t *dst = pd->dst.buf + (idy * pd->dst.stride << lh) + (idx << lh); |
189 x->skip_txfm[i] = 2; | 200 int block_idx = (idy << 1) + idx; |
190 else | 201 |
191 x->skip_txfm[i] = 0; | 202 var = cpi->fn_ptr[unit_size].vf(src, p->src.stride, |
| 203 dst, pd->dst.stride, &sse); |
| 204 x->bsse[(i << 2) + block_idx] = sse; |
| 205 sum_sse += sse; |
| 206 |
| 207 if (!x->select_tx_size) { |
| 208 if (x->bsse[(i << 2) + block_idx] < p->quant_thred[0] >> shift) |
| 209 x->skip_txfm[(i << 2) + block_idx] = 1; |
| 210 else if (var < p->quant_thred[1] >> shift) |
| 211 x->skip_txfm[(i << 2) + block_idx] = 2; |
| 212 else |
| 213 x->skip_txfm[(i << 2) + block_idx] = 0; |
| 214 } |
| 215 |
| 216 if (i == 0) |
| 217 x->pred_sse[ref] += sse; |
| 218 } |
192 } | 219 } |
193 | 220 |
194 x->bsse[i] = sse; | |
195 if (i == 0) | |
196 x->pred_sse[ref] = sse; | |
197 | |
198 // Fast approximate the modelling function. | 221 // Fast approximate the modelling function. |
199 if (cpi->oxcf.speed > 4) { | 222 if (cpi->oxcf.speed > 4) { |
200 int64_t rate; | 223 int64_t rate; |
201 int64_t dist; | 224 int64_t dist; |
202 int64_t square_error = sse; | 225 int64_t square_error = sse; |
203 int quantizer = (pd->dequant[1] >> 3); | 226 int quantizer = (pd->dequant[1] >> 3); |
204 | 227 |
205 if (quantizer < 120) | 228 if (quantizer < 120) |
206 rate = (square_error * (280 - quantizer)) >> 8; | 229 rate = (square_error * (280 - quantizer)) >> 8; |
207 else | 230 else |
208 rate = 0; | 231 rate = 0; |
209 dist = (square_error * quantizer) >> 8; | 232 dist = (square_error * quantizer) >> 8; |
210 rate_sum += rate; | 233 rate_sum += rate; |
211 dist_sum += dist; | 234 dist_sum += dist; |
212 } else { | 235 } else { |
213 int rate; | 236 vp9_model_rd_from_var_lapndz(sum_sse, 1 << num_pels_log2_lookup[bs], |
214 int64_t dist; | |
215 vp9_model_rd_from_var_lapndz(sse, 1 << num_pels_log2_lookup[bs], | |
216 pd->dequant[1] >> 3, &rate, &dist); | 237 pd->dequant[1] >> 3, &rate, &dist); |
217 rate_sum += rate; | 238 rate_sum += rate; |
218 dist_sum += dist; | 239 dist_sum += dist; |
219 } | 240 } |
220 } | 241 } |
221 | 242 |
222 *out_rate_sum = (int)rate_sum; | 243 *out_rate_sum = (int)rate_sum; |
223 *out_dist_sum = dist_sum << 4; | 244 *out_dist_sum = dist_sum << 4; |
224 } | 245 } |
225 | 246 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 MACROBLOCKD *const xd = &x->e_mbd; | 386 MACROBLOCKD *const xd = &x->e_mbd; |
366 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; | 387 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; |
367 int64_t rd1, rd2, rd; | 388 int64_t rd1, rd2, rd; |
368 | 389 |
369 if (args->skip) | 390 if (args->skip) |
370 return; | 391 return; |
371 | 392 |
372 if (!is_inter_block(mbmi)) { | 393 if (!is_inter_block(mbmi)) { |
373 vp9_encode_block_intra(x, plane, block, plane_bsize, tx_size, &mbmi->skip); | 394 vp9_encode_block_intra(x, plane, block, plane_bsize, tx_size, &mbmi->skip); |
374 dist_block(plane, block, tx_size, args); | 395 dist_block(plane, block, tx_size, args); |
375 } else { | 396 } else if (max_txsize_lookup[plane_bsize] == tx_size) { |
376 if (x->skip_txfm[plane] == 0) { | 397 if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == 0) { |
377 // full forward transform and quantization | 398 // full forward transform and quantization |
378 vp9_xform_quant(x, plane, block, plane_bsize, tx_size); | 399 vp9_xform_quant(x, plane, block, plane_bsize, tx_size); |
379 dist_block(plane, block, tx_size, args); | 400 dist_block(plane, block, tx_size, args); |
380 } else if (x->skip_txfm[plane] == 2) { | 401 } else if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == 2) { |
381 // compute DC coefficient | 402 // compute DC coefficient |
382 int16_t *const coeff = BLOCK_OFFSET(x->plane[plane].coeff, block); | 403 int16_t *const coeff = BLOCK_OFFSET(x->plane[plane].coeff, block); |
383 int16_t *const dqcoeff = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block); | 404 int16_t *const dqcoeff = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block); |
384 vp9_xform_quant_dc(x, plane, block, plane_bsize, tx_size); | 405 vp9_xform_quant_dc(x, plane, block, plane_bsize, tx_size); |
385 args->sse = x->bsse[plane] << 4; | 406 args->sse = x->bsse[(plane << 2) + (block >> (tx_size << 1))] << 4; |
386 args->dist = args->sse; | 407 args->dist = args->sse; |
387 if (!x->plane[plane].eobs[block]) | 408 if (!x->plane[plane].eobs[block]) |
388 args->dist = args->sse - ((coeff[0] * coeff[0] - | 409 args->dist = args->sse - ((coeff[0] * coeff[0] - |
389 (coeff[0] - dqcoeff[0]) * (coeff[0] - dqcoeff[0])) >> 2); | 410 (coeff[0] - dqcoeff[0]) * (coeff[0] - dqcoeff[0])) >> 2); |
390 } else { | 411 } else { |
391 // skip forward transform | 412 // skip forward transform |
392 x->plane[plane].eobs[block] = 0; | 413 x->plane[plane].eobs[block] = 0; |
393 args->sse = x->bsse[plane] << 4; | 414 args->sse = x->bsse[(plane << 2) + (block >> (tx_size << 1))] << 4; |
394 args->dist = args->sse; | 415 args->dist = args->sse; |
395 } | 416 } |
| 417 } else { |
| 418 // full forward transform and quantization |
| 419 vp9_xform_quant(x, plane, block, plane_bsize, tx_size); |
| 420 dist_block(plane, block, tx_size, args); |
396 } | 421 } |
397 | 422 |
398 rate_block(plane, block, plane_bsize, tx_size, args); | 423 rate_block(plane, block, plane_bsize, tx_size, args); |
399 rd1 = RDCOST(x->rdmult, x->rddiv, args->rate, args->dist); | 424 rd1 = RDCOST(x->rdmult, x->rddiv, args->rate, args->dist); |
400 rd2 = RDCOST(x->rdmult, x->rddiv, 0, args->sse); | 425 rd2 = RDCOST(x->rdmult, x->rddiv, 0, args->sse); |
401 | 426 |
402 // TODO(jingning): temporarily enabled only for luma component | 427 // TODO(jingning): temporarily enabled only for luma component |
403 rd = MIN(rd1, rd2); | 428 rd = MIN(rd1, rd2); |
404 if (plane == 0) | 429 if (plane == 0) |
405 x->zcoeff_blk[tx_size][block] = !x->plane[plane].eobs[block] || | 430 x->zcoeff_blk[tx_size][block] = !x->plane[plane].eobs[block] || |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 VP9_COMMON *const cm = &cpi->common; | 486 VP9_COMMON *const cm = &cpi->common; |
462 const TX_SIZE largest_tx_size = tx_mode_to_biggest_tx_size[cm->tx_mode]; | 487 const TX_SIZE largest_tx_size = tx_mode_to_biggest_tx_size[cm->tx_mode]; |
463 MACROBLOCKD *const xd = &x->e_mbd; | 488 MACROBLOCKD *const xd = &x->e_mbd; |
464 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; | 489 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; |
465 | 490 |
466 mbmi->tx_size = MIN(max_tx_size, largest_tx_size); | 491 mbmi->tx_size = MIN(max_tx_size, largest_tx_size); |
467 | 492 |
468 txfm_rd_in_plane(x, rate, distortion, skip, | 493 txfm_rd_in_plane(x, rate, distortion, skip, |
469 sse, ref_best_rd, 0, bs, | 494 sse, ref_best_rd, 0, bs, |
470 mbmi->tx_size, cpi->sf.use_fast_coef_costing); | 495 mbmi->tx_size, cpi->sf.use_fast_coef_costing); |
471 cpi->tx_stepdown_count[0]++; | |
472 } | 496 } |
473 | 497 |
474 static void choose_tx_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x, | 498 static void choose_tx_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x, |
475 int *rate, | 499 int *rate, |
476 int64_t *distortion, | 500 int64_t *distortion, |
477 int *skip, | 501 int *skip, |
478 int64_t *psse, | 502 int64_t *psse, |
479 int64_t tx_cache[TX_MODES], | 503 int64_t tx_cache[TX_MODES], |
480 int64_t ref_best_rd, | 504 int64_t ref_best_rd, |
481 BLOCK_SIZE bs) { | 505 BLOCK_SIZE bs) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 *skip = s[mbmi->tx_size]; | 568 *skip = s[mbmi->tx_size]; |
545 *psse = sse[mbmi->tx_size]; | 569 *psse = sse[mbmi->tx_size]; |
546 | 570 |
547 tx_cache[ONLY_4X4] = rd[TX_4X4][0]; | 571 tx_cache[ONLY_4X4] = rd[TX_4X4][0]; |
548 tx_cache[ALLOW_8X8] = rd[TX_8X8][0]; | 572 tx_cache[ALLOW_8X8] = rd[TX_8X8][0]; |
549 tx_cache[ALLOW_16X16] = rd[MIN(max_tx_size, TX_16X16)][0]; | 573 tx_cache[ALLOW_16X16] = rd[MIN(max_tx_size, TX_16X16)][0]; |
550 tx_cache[ALLOW_32X32] = rd[MIN(max_tx_size, TX_32X32)][0]; | 574 tx_cache[ALLOW_32X32] = rd[MIN(max_tx_size, TX_32X32)][0]; |
551 | 575 |
552 if (max_tx_size == TX_32X32 && best_tx == TX_32X32) { | 576 if (max_tx_size == TX_32X32 && best_tx == TX_32X32) { |
553 tx_cache[TX_MODE_SELECT] = rd[TX_32X32][1]; | 577 tx_cache[TX_MODE_SELECT] = rd[TX_32X32][1]; |
554 cpi->tx_stepdown_count[0]++; | |
555 } else if (max_tx_size >= TX_16X16 && best_tx == TX_16X16) { | 578 } else if (max_tx_size >= TX_16X16 && best_tx == TX_16X16) { |
556 tx_cache[TX_MODE_SELECT] = rd[TX_16X16][1]; | 579 tx_cache[TX_MODE_SELECT] = rd[TX_16X16][1]; |
557 cpi->tx_stepdown_count[max_tx_size - TX_16X16]++; | |
558 } else if (rd[TX_8X8][1] < rd[TX_4X4][1]) { | 580 } else if (rd[TX_8X8][1] < rd[TX_4X4][1]) { |
559 tx_cache[TX_MODE_SELECT] = rd[TX_8X8][1]; | 581 tx_cache[TX_MODE_SELECT] = rd[TX_8X8][1]; |
560 cpi->tx_stepdown_count[max_tx_size - TX_8X8]++; | |
561 } else { | 582 } else { |
562 tx_cache[TX_MODE_SELECT] = rd[TX_4X4][1]; | 583 tx_cache[TX_MODE_SELECT] = rd[TX_4X4][1]; |
563 cpi->tx_stepdown_count[max_tx_size - TX_4X4]++; | |
564 } | 584 } |
565 } | 585 } |
566 | 586 |
567 static void inter_super_block_yrd(VP9_COMP *cpi, MACROBLOCK *x, int *rate, | 587 static void super_block_yrd(VP9_COMP *cpi, MACROBLOCK *x, int *rate, |
568 int64_t *distortion, int *skip, | 588 int64_t *distortion, int *skip, |
569 int64_t *psse, BLOCK_SIZE bs, | 589 int64_t *psse, BLOCK_SIZE bs, |
570 int64_t txfm_cache[TX_MODES], | 590 int64_t txfm_cache[TX_MODES], |
571 int64_t ref_best_rd) { | 591 int64_t ref_best_rd) { |
572 MACROBLOCKD *xd = &x->e_mbd; | 592 MACROBLOCKD *xd = &x->e_mbd; |
| 593 int64_t sse; |
| 594 int64_t *ret_sse = psse ? psse : &sse; |
573 | 595 |
574 assert(bs == xd->mi[0]->mbmi.sb_type); | 596 assert(bs == xd->mi[0]->mbmi.sb_type); |
575 | 597 |
576 vp9_subtract_plane(x, bs, 0); | |
577 | |
578 if (cpi->sf.tx_size_search_method == USE_LARGESTALL || xd->lossless) { | 598 if (cpi->sf.tx_size_search_method == USE_LARGESTALL || xd->lossless) { |
579 vpx_memset(txfm_cache, 0, TX_MODES * sizeof(int64_t)); | 599 vpx_memset(txfm_cache, 0, TX_MODES * sizeof(int64_t)); |
580 choose_largest_tx_size(cpi, x, rate, distortion, skip, psse, ref_best_rd, | 600 choose_largest_tx_size(cpi, x, rate, distortion, skip, ret_sse, ref_best_rd, |
581 bs); | 601 bs); |
582 } else { | 602 } else { |
583 choose_tx_size_from_rd(cpi, x, rate, distortion, skip, psse, | 603 choose_tx_size_from_rd(cpi, x, rate, distortion, skip, ret_sse, |
584 txfm_cache, ref_best_rd, bs); | 604 txfm_cache, ref_best_rd, bs); |
585 } | 605 } |
586 } | 606 } |
587 | 607 |
588 static void intra_super_block_yrd(VP9_COMP *cpi, MACROBLOCK *x, int *rate, | |
589 int64_t *distortion, int *skip, | |
590 BLOCK_SIZE bs, | |
591 int64_t txfm_cache[TX_MODES], | |
592 int64_t ref_best_rd) { | |
593 MACROBLOCKD *xd = &x->e_mbd; | |
594 int64_t sse; | |
595 | |
596 assert(bs == xd->mi[0]->mbmi.sb_type); | |
597 if (cpi->sf.tx_size_search_method != USE_FULL_RD || xd->lossless) { | |
598 vpx_memset(txfm_cache, 0, TX_MODES * sizeof(int64_t)); | |
599 choose_largest_tx_size(cpi, x, rate, distortion, skip, &sse, ref_best_rd, | |
600 bs); | |
601 } else { | |
602 choose_tx_size_from_rd(cpi, x, rate, distortion, skip, &sse, | |
603 txfm_cache, ref_best_rd, bs); | |
604 } | |
605 } | |
606 | |
607 | |
608 static int conditional_skipintra(PREDICTION_MODE mode, | 608 static int conditional_skipintra(PREDICTION_MODE mode, |
609 PREDICTION_MODE best_intra_mode) { | 609 PREDICTION_MODE best_intra_mode) { |
610 if (mode == D117_PRED && | 610 if (mode == D117_PRED && |
611 best_intra_mode != V_PRED && | 611 best_intra_mode != V_PRED && |
612 best_intra_mode != D135_PRED) | 612 best_intra_mode != D135_PRED) |
613 return 1; | 613 return 1; |
614 if (mode == D63_PRED && | 614 if (mode == D63_PRED && |
615 best_intra_mode != V_PRED && | 615 best_intra_mode != V_PRED && |
616 best_intra_mode != D45_PRED) | 616 best_intra_mode != D45_PRED) |
617 return 1; | 617 return 1; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 MODE_INFO *left_mi = xd->left_available ? xd->mi[-1] : NULL; | 847 MODE_INFO *left_mi = xd->left_available ? xd->mi[-1] : NULL; |
848 | 848 |
849 if (cpi->common.frame_type == KEY_FRAME) { | 849 if (cpi->common.frame_type == KEY_FRAME) { |
850 const PREDICTION_MODE A = vp9_above_block_mode(mic, above_mi, 0); | 850 const PREDICTION_MODE A = vp9_above_block_mode(mic, above_mi, 0); |
851 const PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, 0); | 851 const PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, 0); |
852 | 852 |
853 bmode_costs = cpi->y_mode_costs[A][L]; | 853 bmode_costs = cpi->y_mode_costs[A][L]; |
854 } | 854 } |
855 mic->mbmi.mode = mode; | 855 mic->mbmi.mode = mode; |
856 | 856 |
857 intra_super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, | 857 super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion, |
858 &s, bsize, local_tx_cache, best_rd); | 858 &s, NULL, bsize, local_tx_cache, best_rd); |
859 | 859 |
860 if (this_rate_tokenonly == INT_MAX) | 860 if (this_rate_tokenonly == INT_MAX) |
861 continue; | 861 continue; |
862 | 862 |
863 this_rate = this_rate_tokenonly + bmode_costs[mode]; | 863 this_rate = this_rate_tokenonly + bmode_costs[mode]; |
864 this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); | 864 this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); |
865 | 865 |
866 if (this_rd < best_rd) { | 866 if (this_rd < best_rd) { |
867 mode_selected = mode; | 867 mode_selected = mode; |
868 best_rd = this_rd; | 868 best_rd = this_rd; |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 | 1358 |
1359 // motion search for newmv (single predictor case only) | 1359 // motion search for newmv (single predictor case only) |
1360 if (!has_second_rf && this_mode == NEWMV && | 1360 if (!has_second_rf && this_mode == NEWMV && |
1361 seg_mvs[i][mbmi->ref_frame[0]].as_int == INVALID_MV) { | 1361 seg_mvs[i][mbmi->ref_frame[0]].as_int == INVALID_MV) { |
1362 MV *const new_mv = &mode_mv[NEWMV][0].as_mv; | 1362 MV *const new_mv = &mode_mv[NEWMV][0].as_mv; |
1363 int step_param = 0; | 1363 int step_param = 0; |
1364 int thissme, bestsme = INT_MAX; | 1364 int thissme, bestsme = INT_MAX; |
1365 int sadpb = x->sadperbit4; | 1365 int sadpb = x->sadperbit4; |
1366 MV mvp_full; | 1366 MV mvp_full; |
1367 int max_mv; | 1367 int max_mv; |
| 1368 int sad_list[5]; |
1368 | 1369 |
1369 /* Is the best so far sufficiently good that we cant justify doing | 1370 /* Is the best so far sufficiently good that we cant justify doing |
1370 * and new motion search. */ | 1371 * and new motion search. */ |
1371 if (best_rd < label_mv_thresh) | 1372 if (best_rd < label_mv_thresh) |
1372 break; | 1373 break; |
1373 | 1374 |
1374 if (!is_best_mode(cpi->oxcf.mode)) { | 1375 if (cpi->oxcf.mode != BEST) { |
1375 // use previous block's result as next block's MV predictor. | 1376 // use previous block's result as next block's MV predictor. |
1376 if (i > 0) { | 1377 if (i > 0) { |
1377 bsi->mvp.as_int = mi->bmi[i - 1].as_mv[0].as_int; | 1378 bsi->mvp.as_int = mi->bmi[i - 1].as_mv[0].as_int; |
1378 if (i == 2) | 1379 if (i == 2) |
1379 bsi->mvp.as_int = mi->bmi[i - 2].as_mv[0].as_int; | 1380 bsi->mvp.as_int = mi->bmi[i - 2].as_mv[0].as_int; |
1380 } | 1381 } |
1381 } | 1382 } |
1382 if (i == 0) | 1383 if (i == 0) |
1383 max_mv = x->max_mv_context[mbmi->ref_frame[0]]; | 1384 max_mv = x->max_mv_context[mbmi->ref_frame[0]]; |
1384 else | 1385 else |
1385 max_mv = MAX(abs(bsi->mvp.as_mv.row), abs(bsi->mvp.as_mv.col)) >> 3; | 1386 max_mv = MAX(abs(bsi->mvp.as_mv.row), abs(bsi->mvp.as_mv.col)) >> 3; |
1386 | 1387 |
1387 if (cpi->sf.mv.auto_mv_step_size && cm->show_frame) { | 1388 if (cpi->sf.mv.auto_mv_step_size && cm->show_frame) { |
1388 // Take wtd average of the step_params based on the last frame's | 1389 // Take wtd average of the step_params based on the last frame's |
1389 // max mv magnitude and the best ref mvs of the current block for | 1390 // max mv magnitude and the best ref mvs of the current block for |
1390 // the given reference. | 1391 // the given reference. |
1391 step_param = (vp9_init_search_range(max_mv) + | 1392 step_param = (vp9_init_search_range(max_mv) + |
1392 cpi->mv_step_param) / 2; | 1393 cpi->mv_step_param) / 2; |
1393 } else { | 1394 } else { |
1394 step_param = cpi->mv_step_param; | 1395 step_param = cpi->mv_step_param; |
1395 } | 1396 } |
1396 | 1397 |
1397 mvp_full.row = bsi->mvp.as_mv.row >> 3; | 1398 mvp_full.row = bsi->mvp.as_mv.row >> 3; |
1398 mvp_full.col = bsi->mvp.as_mv.col >> 3; | 1399 mvp_full.col = bsi->mvp.as_mv.col >> 3; |
1399 | 1400 |
1400 if (cpi->sf.adaptive_motion_search && cm->show_frame) { | 1401 if (cpi->sf.adaptive_motion_search) { |
1401 mvp_full.row = x->pred_mv[mbmi->ref_frame[0]].row >> 3; | 1402 mvp_full.row = x->pred_mv[mbmi->ref_frame[0]].row >> 3; |
1402 mvp_full.col = x->pred_mv[mbmi->ref_frame[0]].col >> 3; | 1403 mvp_full.col = x->pred_mv[mbmi->ref_frame[0]].col >> 3; |
1403 step_param = MAX(step_param, 8); | 1404 step_param = MAX(step_param, 8); |
1404 } | 1405 } |
1405 | 1406 |
1406 // adjust src pointer for this block | 1407 // adjust src pointer for this block |
1407 mi_buf_shift(x, i); | 1408 mi_buf_shift(x, i); |
1408 | 1409 |
1409 vp9_set_mv_search_range(x, &bsi->ref_mv[0]->as_mv); | 1410 vp9_set_mv_search_range(x, &bsi->ref_mv[0]->as_mv); |
1410 | 1411 |
1411 bestsme = vp9_full_pixel_search(cpi, x, bsize, &mvp_full, step_param, | 1412 bestsme = vp9_full_pixel_search( |
1412 sadpb, &bsi->ref_mv[0]->as_mv, new_mv, | 1413 cpi, x, bsize, &mvp_full, step_param, sadpb, |
1413 INT_MAX, 1); | 1414 cpi->sf.mv.subpel_search_method != SUBPEL_TREE ? sad_list : NULL, |
| 1415 &bsi->ref_mv[0]->as_mv, new_mv, |
| 1416 INT_MAX, 1); |
1414 | 1417 |
1415 // Should we do a full search (best quality only) | 1418 // Should we do a full search (best quality only) |
1416 if (is_best_mode(cpi->oxcf.mode)) { | 1419 if (cpi->oxcf.mode == BEST) { |
1417 int_mv *const best_mv = &mi->bmi[i].as_mv[0]; | 1420 int_mv *const best_mv = &mi->bmi[i].as_mv[0]; |
1418 /* Check if mvp_full is within the range. */ | 1421 /* Check if mvp_full is within the range. */ |
1419 clamp_mv(&mvp_full, x->mv_col_min, x->mv_col_max, | 1422 clamp_mv(&mvp_full, x->mv_col_min, x->mv_col_max, |
1420 x->mv_row_min, x->mv_row_max); | 1423 x->mv_row_min, x->mv_row_max); |
1421 thissme = cpi->full_search_sad(x, &mvp_full, | 1424 thissme = cpi->full_search_sad(x, &mvp_full, |
1422 sadpb, 16, &cpi->fn_ptr[bsize], | 1425 sadpb, 16, &cpi->fn_ptr[bsize], |
1423 &bsi->ref_mv[0]->as_mv, | 1426 &bsi->ref_mv[0]->as_mv, |
1424 &best_mv->as_mv); | 1427 &best_mv->as_mv); |
| 1428 sad_list[1] = sad_list[2] = sad_list[3] = sad_list[4] = INT_MAX; |
1425 if (thissme < bestsme) { | 1429 if (thissme < bestsme) { |
1426 bestsme = thissme; | 1430 bestsme = thissme; |
1427 *new_mv = best_mv->as_mv; | 1431 *new_mv = best_mv->as_mv; |
1428 } else { | 1432 } else { |
1429 // The full search result is actually worse so re-instate the | 1433 // The full search result is actually worse so re-instate the |
1430 // previous best vector | 1434 // previous best vector |
1431 best_mv->as_mv = *new_mv; | 1435 best_mv->as_mv = *new_mv; |
1432 } | 1436 } |
1433 } | 1437 } |
1434 | 1438 |
1435 if (bestsme < INT_MAX) { | 1439 if (bestsme < INT_MAX) { |
1436 int distortion; | 1440 int distortion; |
1437 cpi->find_fractional_mv_step(x, | 1441 cpi->find_fractional_mv_step( |
1438 new_mv, | 1442 x, |
1439 &bsi->ref_mv[0]->as_mv, | 1443 new_mv, |
1440 cm->allow_high_precision_mv, | 1444 &bsi->ref_mv[0]->as_mv, |
1441 x->errorperbit, &cpi->fn_ptr[bsize], | 1445 cm->allow_high_precision_mv, |
1442 cpi->sf.mv.subpel_force_stop, | 1446 x->errorperbit, &cpi->fn_ptr[bsize], |
1443 cpi->sf.mv.subpel_iters_per_step, | 1447 cpi->sf.mv.subpel_force_stop, |
1444 x->nmvjointcost, x->mvcost, | 1448 cpi->sf.mv.subpel_iters_per_step, |
1445 &distortion, | 1449 cond_sad_list(cpi, sad_list), |
1446 &x->pred_sse[mbmi->ref_frame[0]], | 1450 x->nmvjointcost, x->mvcost, |
1447 NULL, 0, 0); | 1451 &distortion, |
| 1452 &x->pred_sse[mbmi->ref_frame[0]], |
| 1453 NULL, 0, 0); |
1448 | 1454 |
1449 // save motion search result for use in compound prediction | 1455 // save motion search result for use in compound prediction |
1450 seg_mvs[i][mbmi->ref_frame[0]].as_mv = *new_mv; | 1456 seg_mvs[i][mbmi->ref_frame[0]].as_mv = *new_mv; |
1451 } | 1457 } |
1452 | 1458 |
1453 if (cpi->sf.adaptive_motion_search) | 1459 if (cpi->sf.adaptive_motion_search) |
1454 x->pred_mv[mbmi->ref_frame[0]] = *new_mv; | 1460 x->pred_mv[mbmi->ref_frame[0]] = *new_mv; |
1455 | 1461 |
1456 // restore src pointers | 1462 // restore src pointers |
1457 mi_buf_restore(x, orig_src, orig_pre); | 1463 mi_buf_restore(x, orig_src, orig_pre); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1694 ref_costs_comp[LAST_FRAME] = 512; | 1700 ref_costs_comp[LAST_FRAME] = 512; |
1695 ref_costs_comp[GOLDEN_FRAME] = 512; | 1701 ref_costs_comp[GOLDEN_FRAME] = 512; |
1696 } | 1702 } |
1697 } | 1703 } |
1698 } | 1704 } |
1699 | 1705 |
1700 static void store_coding_context(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx, | 1706 static void store_coding_context(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx, |
1701 int mode_index, | 1707 int mode_index, |
1702 int64_t comp_pred_diff[REFERENCE_MODES], | 1708 int64_t comp_pred_diff[REFERENCE_MODES], |
1703 const int64_t tx_size_diff[TX_MODES], | 1709 const int64_t tx_size_diff[TX_MODES], |
1704 int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]) { | 1710 int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS], |
| 1711 int skippable) { |
1705 MACROBLOCKD *const xd = &x->e_mbd; | 1712 MACROBLOCKD *const xd = &x->e_mbd; |
1706 | 1713 |
1707 // Take a snapshot of the coding context so it can be | 1714 // Take a snapshot of the coding context so it can be |
1708 // restored if we decide to encode this way | 1715 // restored if we decide to encode this way |
1709 ctx->skip = x->skip; | 1716 ctx->skip = x->skip; |
| 1717 ctx->skippable = skippable; |
1710 ctx->best_mode_index = mode_index; | 1718 ctx->best_mode_index = mode_index; |
1711 ctx->mic = *xd->mi[0]; | 1719 ctx->mic = *xd->mi[0]; |
1712 ctx->single_pred_diff = (int)comp_pred_diff[SINGLE_REFERENCE]; | 1720 ctx->single_pred_diff = (int)comp_pred_diff[SINGLE_REFERENCE]; |
1713 ctx->comp_pred_diff = (int)comp_pred_diff[COMPOUND_REFERENCE]; | 1721 ctx->comp_pred_diff = (int)comp_pred_diff[COMPOUND_REFERENCE]; |
1714 ctx->hybrid_pred_diff = (int)comp_pred_diff[REFERENCE_MODE_SELECT]; | 1722 ctx->hybrid_pred_diff = (int)comp_pred_diff[REFERENCE_MODE_SELECT]; |
1715 | 1723 |
1716 vpx_memcpy(ctx->tx_rd_diff, tx_size_diff, sizeof(ctx->tx_rd_diff)); | 1724 vpx_memcpy(ctx->tx_rd_diff, tx_size_diff, sizeof(ctx->tx_rd_diff)); |
1717 vpx_memcpy(ctx->best_filter_diff, best_filter_diff, | 1725 vpx_memcpy(ctx->best_filter_diff, best_filter_diff, |
1718 sizeof(*best_filter_diff) * SWITCHABLE_FILTER_CONTEXTS); | 1726 sizeof(*best_filter_diff) * SWITCHABLE_FILTER_CONTEXTS); |
1719 } | 1727 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 int step_param; | 1773 int step_param; |
1766 int sadpb = x->sadperbit16; | 1774 int sadpb = x->sadperbit16; |
1767 MV mvp_full; | 1775 MV mvp_full; |
1768 int ref = mbmi->ref_frame[0]; | 1776 int ref = mbmi->ref_frame[0]; |
1769 MV ref_mv = mbmi->ref_mvs[ref][0].as_mv; | 1777 MV ref_mv = mbmi->ref_mvs[ref][0].as_mv; |
1770 | 1778 |
1771 int tmp_col_min = x->mv_col_min; | 1779 int tmp_col_min = x->mv_col_min; |
1772 int tmp_col_max = x->mv_col_max; | 1780 int tmp_col_max = x->mv_col_max; |
1773 int tmp_row_min = x->mv_row_min; | 1781 int tmp_row_min = x->mv_row_min; |
1774 int tmp_row_max = x->mv_row_max; | 1782 int tmp_row_max = x->mv_row_max; |
| 1783 int sad_list[5]; |
1775 | 1784 |
1776 const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi, | 1785 const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi, |
1777 ref); | 1786 ref); |
1778 | 1787 |
1779 MV pred_mv[3]; | 1788 MV pred_mv[3]; |
1780 pred_mv[0] = mbmi->ref_mvs[ref][0].as_mv; | 1789 pred_mv[0] = mbmi->ref_mvs[ref][0].as_mv; |
1781 pred_mv[1] = mbmi->ref_mvs[ref][1].as_mv; | 1790 pred_mv[1] = mbmi->ref_mvs[ref][1].as_mv; |
1782 pred_mv[2] = x->pred_mv[ref]; | 1791 pred_mv[2] = x->pred_mv[ref]; |
1783 | 1792 |
1784 if (scaled_ref_frame) { | 1793 if (scaled_ref_frame) { |
(...skipping 14 matching lines...) Expand all Loading... |
1799 if (cpi->sf.mv.auto_mv_step_size && cm->show_frame) { | 1808 if (cpi->sf.mv.auto_mv_step_size && cm->show_frame) { |
1800 // Take wtd average of the step_params based on the last frame's | 1809 // Take wtd average of the step_params based on the last frame's |
1801 // max mv magnitude and that based on the best ref mvs of the current | 1810 // max mv magnitude and that based on the best ref mvs of the current |
1802 // block for the given reference. | 1811 // block for the given reference. |
1803 step_param = (vp9_init_search_range(x->max_mv_context[ref]) + | 1812 step_param = (vp9_init_search_range(x->max_mv_context[ref]) + |
1804 cpi->mv_step_param) / 2; | 1813 cpi->mv_step_param) / 2; |
1805 } else { | 1814 } else { |
1806 step_param = cpi->mv_step_param; | 1815 step_param = cpi->mv_step_param; |
1807 } | 1816 } |
1808 | 1817 |
1809 if (cpi->sf.adaptive_motion_search && bsize < BLOCK_64X64 && | 1818 if (cpi->sf.adaptive_motion_search && bsize < BLOCK_64X64) { |
1810 cm->show_frame) { | |
1811 int boffset = 2 * (b_width_log2(BLOCK_64X64) - MIN(b_height_log2(bsize), | 1819 int boffset = 2 * (b_width_log2(BLOCK_64X64) - MIN(b_height_log2(bsize), |
1812 b_width_log2(bsize))); | 1820 b_width_log2(bsize))); |
1813 step_param = MAX(step_param, boffset); | 1821 step_param = MAX(step_param, boffset); |
1814 } | 1822 } |
1815 | 1823 |
1816 if (cpi->sf.adaptive_motion_search) { | 1824 if (cpi->sf.adaptive_motion_search) { |
1817 int bwl = b_width_log2(bsize); | 1825 int bwl = b_width_log2(bsize); |
1818 int bhl = b_height_log2(bsize); | 1826 int bhl = b_height_log2(bsize); |
1819 int i; | 1827 int i; |
1820 int tlevel = x->pred_mv_sad[ref] >> (bwl + bhl + 4); | 1828 int tlevel = x->pred_mv_sad[ref] >> (bwl + bhl + 4); |
(...skipping 16 matching lines...) Expand all Loading... |
1837 } | 1845 } |
1838 } | 1846 } |
1839 } | 1847 } |
1840 | 1848 |
1841 mvp_full = pred_mv[x->mv_best_ref_index[ref]]; | 1849 mvp_full = pred_mv[x->mv_best_ref_index[ref]]; |
1842 | 1850 |
1843 mvp_full.col >>= 3; | 1851 mvp_full.col >>= 3; |
1844 mvp_full.row >>= 3; | 1852 mvp_full.row >>= 3; |
1845 | 1853 |
1846 bestsme = vp9_full_pixel_search(cpi, x, bsize, &mvp_full, step_param, sadpb, | 1854 bestsme = vp9_full_pixel_search(cpi, x, bsize, &mvp_full, step_param, sadpb, |
| 1855 cond_sad_list(cpi, sad_list), |
1847 &ref_mv, &tmp_mv->as_mv, INT_MAX, 1); | 1856 &ref_mv, &tmp_mv->as_mv, INT_MAX, 1); |
1848 | 1857 |
1849 x->mv_col_min = tmp_col_min; | 1858 x->mv_col_min = tmp_col_min; |
1850 x->mv_col_max = tmp_col_max; | 1859 x->mv_col_max = tmp_col_max; |
1851 x->mv_row_min = tmp_row_min; | 1860 x->mv_row_min = tmp_row_min; |
1852 x->mv_row_max = tmp_row_max; | 1861 x->mv_row_max = tmp_row_max; |
1853 | 1862 |
1854 if (bestsme < INT_MAX) { | 1863 if (bestsme < INT_MAX) { |
1855 int dis; /* TODO: use dis in distortion calculation later. */ | 1864 int dis; /* TODO: use dis in distortion calculation later. */ |
1856 cpi->find_fractional_mv_step(x, &tmp_mv->as_mv, &ref_mv, | 1865 cpi->find_fractional_mv_step(x, &tmp_mv->as_mv, &ref_mv, |
1857 cm->allow_high_precision_mv, | 1866 cm->allow_high_precision_mv, |
1858 x->errorperbit, | 1867 x->errorperbit, |
1859 &cpi->fn_ptr[bsize], | 1868 &cpi->fn_ptr[bsize], |
1860 cpi->sf.mv.subpel_force_stop, | 1869 cpi->sf.mv.subpel_force_stop, |
1861 cpi->sf.mv.subpel_iters_per_step, | 1870 cpi->sf.mv.subpel_iters_per_step, |
| 1871 cond_sad_list(cpi, sad_list), |
1862 x->nmvjointcost, x->mvcost, | 1872 x->nmvjointcost, x->mvcost, |
1863 &dis, &x->pred_sse[ref], NULL, 0, 0); | 1873 &dis, &x->pred_sse[ref], NULL, 0, 0); |
1864 } | 1874 } |
1865 *rate_mv = vp9_mv_bit_cost(&tmp_mv->as_mv, &ref_mv, | 1875 *rate_mv = vp9_mv_bit_cost(&tmp_mv->as_mv, &ref_mv, |
1866 x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); | 1876 x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); |
1867 | 1877 |
1868 if (cpi->sf.adaptive_motion_search && cm->show_frame) | 1878 if (cpi->sf.adaptive_motion_search) |
1869 x->pred_mv[ref] = tmp_mv->as_mv; | 1879 x->pred_mv[ref] = tmp_mv->as_mv; |
1870 | 1880 |
1871 if (scaled_ref_frame) { | 1881 if (scaled_ref_frame) { |
1872 int i; | 1882 int i; |
1873 for (i = 0; i < MAX_MB_PLANE; i++) | 1883 for (i = 0; i < MAX_MB_PLANE; i++) |
1874 xd->plane[i].pre[0] = backup_yv12[i]; | 1884 xd->plane[i].pre[0] = backup_yv12[i]; |
1875 } | 1885 } |
1876 } | 1886 } |
1877 | 1887 |
1878 static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, | 1888 static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1976 if (bestsme < INT_MAX) { | 1986 if (bestsme < INT_MAX) { |
1977 int dis; /* TODO: use dis in distortion calculation later. */ | 1987 int dis; /* TODO: use dis in distortion calculation later. */ |
1978 unsigned int sse; | 1988 unsigned int sse; |
1979 bestsme = cpi->find_fractional_mv_step( | 1989 bestsme = cpi->find_fractional_mv_step( |
1980 x, &tmp_mv, | 1990 x, &tmp_mv, |
1981 &ref_mv[id].as_mv, | 1991 &ref_mv[id].as_mv, |
1982 cpi->common.allow_high_precision_mv, | 1992 cpi->common.allow_high_precision_mv, |
1983 x->errorperbit, | 1993 x->errorperbit, |
1984 &cpi->fn_ptr[bsize], | 1994 &cpi->fn_ptr[bsize], |
1985 0, cpi->sf.mv.subpel_iters_per_step, | 1995 0, cpi->sf.mv.subpel_iters_per_step, |
| 1996 NULL, |
1986 x->nmvjointcost, x->mvcost, | 1997 x->nmvjointcost, x->mvcost, |
1987 &dis, &sse, second_pred, | 1998 &dis, &sse, second_pred, |
1988 pw, ph); | 1999 pw, ph); |
1989 } | 2000 } |
1990 | 2001 |
1991 if (id) | 2002 if (id) |
1992 xd->plane[0].pre[0] = scaled_first_yv12; | 2003 xd->plane[0].pre[0] = scaled_first_yv12; |
1993 | 2004 |
1994 if (bestsme < last_besterr[id]) { | 2005 if (bestsme < last_besterr[id]) { |
1995 frame_mv[refs[id]].as_mv = tmp_mv; | 2006 frame_mv[refs[id]].as_mv = tmp_mv; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2111 BLOCK_SIZE bsize, | 2122 BLOCK_SIZE bsize, |
2112 int64_t txfm_cache[], | 2123 int64_t txfm_cache[], |
2113 int *rate2, int64_t *distortion, | 2124 int *rate2, int64_t *distortion, |
2114 int *skippable, | 2125 int *skippable, |
2115 int *rate_y, int64_t *distortion_y, | 2126 int *rate_y, int64_t *distortion_y, |
2116 int *rate_uv, int64_t *distortion_uv, | 2127 int *rate_uv, int64_t *distortion_uv, |
2117 int *disable_skip, | 2128 int *disable_skip, |
2118 int_mv (*mode_mv)[MAX_REF_FRAMES], | 2129 int_mv (*mode_mv)[MAX_REF_FRAMES], |
2119 int mi_row, int mi_col, | 2130 int mi_row, int mi_col, |
2120 int_mv single_newmv[MAX_REF_FRAMES], | 2131 int_mv single_newmv[MAX_REF_FRAMES], |
| 2132 INTERP_FILTER (*single_filter)[MAX_REF_FRAMES], |
| 2133 int (*single_skippable)[MAX_REF_FRAMES], |
2121 int64_t *psse, | 2134 int64_t *psse, |
2122 const int64_t ref_best_rd) { | 2135 const int64_t ref_best_rd) { |
2123 VP9_COMMON *cm = &cpi->common; | 2136 VP9_COMMON *cm = &cpi->common; |
2124 RD_OPT *rd_opt = &cpi->rd; | 2137 RD_OPT *rd_opt = &cpi->rd; |
2125 MACROBLOCKD *xd = &x->e_mbd; | 2138 MACROBLOCKD *xd = &x->e_mbd; |
2126 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; | 2139 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; |
2127 const int is_comp_pred = has_second_ref(mbmi); | 2140 const int is_comp_pred = has_second_ref(mbmi); |
2128 const int this_mode = mbmi->mode; | 2141 const int this_mode = mbmi->mode; |
2129 int_mv *frame_mv = mode_mv[this_mode]; | 2142 int_mv *frame_mv = mode_mv[this_mode]; |
2130 int i; | 2143 int i; |
2131 int refs[2] = { mbmi->ref_frame[0], | 2144 int refs[2] = { mbmi->ref_frame[0], |
2132 (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) }; | 2145 (mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]) }; |
2133 int_mv cur_mv[2]; | 2146 int_mv cur_mv[2]; |
2134 int64_t this_rd = 0; | 2147 int64_t this_rd = 0; |
2135 DECLARE_ALIGNED_ARRAY(16, uint8_t, tmp_buf, MAX_MB_PLANE * 64 * 64); | 2148 DECLARE_ALIGNED_ARRAY(16, uint8_t, tmp_buf, MAX_MB_PLANE * 64 * 64); |
2136 int pred_exists = 0; | 2149 int pred_exists = 0; |
2137 int intpel_mv; | 2150 int intpel_mv; |
2138 int64_t rd, best_rd = INT64_MAX; | 2151 int64_t rd, tmp_rd, best_rd = INT64_MAX; |
2139 int best_needs_copy = 0; | 2152 int best_needs_copy = 0; |
2140 uint8_t *orig_dst[MAX_MB_PLANE]; | 2153 uint8_t *orig_dst[MAX_MB_PLANE]; |
2141 int orig_dst_stride[MAX_MB_PLANE]; | 2154 int orig_dst_stride[MAX_MB_PLANE]; |
2142 int rs = 0; | 2155 int rs = 0; |
2143 INTERP_FILTER best_filter = SWITCHABLE; | 2156 INTERP_FILTER best_filter = SWITCHABLE; |
2144 int skip_txfm[MAX_MB_PLANE] = {0}; | 2157 uint8_t skip_txfm[MAX_MB_PLANE << 2] = {0}; |
2145 int64_t bsse[MAX_MB_PLANE] = {0}; | 2158 int64_t bsse[MAX_MB_PLANE << 2] = {0}; |
2146 | 2159 |
2147 int bsl = mi_width_log2_lookup[bsize]; | 2160 int bsl = mi_width_log2_lookup[bsize]; |
2148 int pred_filter_search = cpi->sf.cb_pred_filter_search ? | 2161 int pred_filter_search = cpi->sf.cb_pred_filter_search ? |
2149 (((mi_row + mi_col) >> bsl) + | 2162 (((mi_row + mi_col) >> bsl) + |
2150 get_chessboard_index(cm->current_video_frame)) & 0x1 : 0; | 2163 get_chessboard_index(cm->current_video_frame)) & 0x1 : 0; |
2151 | 2164 |
2152 if (pred_filter_search) { | 2165 if (pred_filter_search) { |
2153 INTERP_FILTER af = SWITCHABLE, lf = SWITCHABLE; | 2166 INTERP_FILTER af = SWITCHABLE, lf = SWITCHABLE; |
2154 if (xd->up_available) | 2167 if (xd->up_available) |
2155 af = xd->mi[-xd->mi_stride]->mbmi.interp_filter; | 2168 af = xd->mi[-xd->mi_stride]->mbmi.interp_filter; |
2156 if (xd->left_available) | 2169 if (xd->left_available) |
2157 lf = xd->mi[-1]->mbmi.interp_filter; | 2170 lf = xd->mi[-1]->mbmi.interp_filter; |
2158 | 2171 |
2159 if ((this_mode != NEWMV) || (af == lf)) | 2172 if ((this_mode != NEWMV) || (af == lf)) |
2160 best_filter = af; | 2173 best_filter = af; |
2161 } | 2174 } |
2162 | 2175 |
2163 if (is_comp_pred) { | 2176 if (is_comp_pred) { |
2164 if (frame_mv[refs[0]].as_int == INVALID_MV || | 2177 if (frame_mv[refs[0]].as_int == INVALID_MV || |
2165 frame_mv[refs[1]].as_int == INVALID_MV) | 2178 frame_mv[refs[1]].as_int == INVALID_MV) |
2166 return INT64_MAX; | 2179 return INT64_MAX; |
| 2180 |
| 2181 if (cpi->sf.adaptive_mode_search) { |
| 2182 if (single_filter[this_mode][refs[0]] == |
| 2183 single_filter[this_mode][refs[1]]) |
| 2184 best_filter = single_filter[this_mode][refs[0]]; |
| 2185 } |
2167 } | 2186 } |
2168 | 2187 |
2169 if (this_mode == NEWMV) { | 2188 if (this_mode == NEWMV) { |
2170 int rate_mv; | 2189 int rate_mv; |
2171 if (is_comp_pred) { | 2190 if (is_comp_pred) { |
2172 // Initialize mv using single prediction mode result. | 2191 // Initialize mv using single prediction mode result. |
2173 frame_mv[refs[0]].as_int = single_newmv[refs[0]].as_int; | 2192 frame_mv[refs[0]].as_int = single_newmv[refs[0]].as_int; |
2174 frame_mv[refs[1]].as_int = single_newmv[refs[1]].as_int; | 2193 frame_mv[refs[1]].as_int = single_newmv[refs[1]].as_int; |
2175 | 2194 |
2176 if (cpi->sf.comp_inter_joint_search_thresh <= bsize) { | 2195 if (cpi->sf.comp_inter_joint_search_thresh <= bsize) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2218 orig_dst[i] = xd->plane[i].dst.buf; | 2237 orig_dst[i] = xd->plane[i].dst.buf; |
2219 orig_dst_stride[i] = xd->plane[i].dst.stride; | 2238 orig_dst_stride[i] = xd->plane[i].dst.stride; |
2220 } | 2239 } |
2221 | 2240 |
2222 /* We don't include the cost of the second reference here, because there | 2241 /* We don't include the cost of the second reference here, because there |
2223 * are only three options: Last/Golden, ARF/Last or Golden/ARF, or in other | 2242 * are only three options: Last/Golden, ARF/Last or Golden/ARF, or in other |
2224 * words if you present them in that order, the second one is always known | 2243 * words if you present them in that order, the second one is always known |
2225 * if the first is known */ | 2244 * if the first is known */ |
2226 *rate2 += cost_mv_ref(cpi, this_mode, mbmi->mode_context[refs[0]]); | 2245 *rate2 += cost_mv_ref(cpi, this_mode, mbmi->mode_context[refs[0]]); |
2227 | 2246 |
| 2247 if (RDCOST(x->rdmult, x->rddiv, *rate2, 0) > ref_best_rd && |
| 2248 mbmi->mode != NEARESTMV) |
| 2249 return INT64_MAX; |
| 2250 |
2228 pred_exists = 0; | 2251 pred_exists = 0; |
2229 // Are all MVs integer pel for Y and UV | 2252 // Are all MVs integer pel for Y and UV |
2230 intpel_mv = !mv_has_subpel(&mbmi->mv[0].as_mv); | 2253 intpel_mv = !mv_has_subpel(&mbmi->mv[0].as_mv); |
2231 if (is_comp_pred) | 2254 if (is_comp_pred) |
2232 intpel_mv &= !mv_has_subpel(&mbmi->mv[1].as_mv); | 2255 intpel_mv &= !mv_has_subpel(&mbmi->mv[1].as_mv); |
2233 | 2256 |
2234 // Search for best switchable filter by checking the variance of | 2257 // Search for best switchable filter by checking the variance of |
2235 // pred error irrespective of whether the filter will be used | 2258 // pred error irrespective of whether the filter will be used |
2236 rd_opt->mask_filter = 0; | 2259 rd_opt->mask_filter = 0; |
2237 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) | 2260 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; ++i) |
(...skipping 18 matching lines...) Expand all Loading... |
2256 rd = RDCOST(x->rdmult, x->rddiv, tmp_rate_sum, tmp_dist_sum); | 2279 rd = RDCOST(x->rdmult, x->rddiv, tmp_rate_sum, tmp_dist_sum); |
2257 rd_opt->filter_cache[i] = rd; | 2280 rd_opt->filter_cache[i] = rd; |
2258 rd_opt->filter_cache[SWITCHABLE_FILTERS] = | 2281 rd_opt->filter_cache[SWITCHABLE_FILTERS] = |
2259 MIN(rd_opt->filter_cache[SWITCHABLE_FILTERS], rd + rs_rd); | 2282 MIN(rd_opt->filter_cache[SWITCHABLE_FILTERS], rd + rs_rd); |
2260 if (cm->interp_filter == SWITCHABLE) | 2283 if (cm->interp_filter == SWITCHABLE) |
2261 rd += rs_rd; | 2284 rd += rs_rd; |
2262 rd_opt->mask_filter = MAX(rd_opt->mask_filter, rd); | 2285 rd_opt->mask_filter = MAX(rd_opt->mask_filter, rd); |
2263 } else { | 2286 } else { |
2264 int rate_sum = 0; | 2287 int rate_sum = 0; |
2265 int64_t dist_sum = 0; | 2288 int64_t dist_sum = 0; |
| 2289 if (i > 0 && cpi->sf.adaptive_interp_filter_search && |
| 2290 (cpi->sf.interp_filter_search_mask & (1 << i))) { |
| 2291 rate_sum = INT_MAX; |
| 2292 dist_sum = INT64_MAX; |
| 2293 continue; |
| 2294 } |
| 2295 |
2266 if ((cm->interp_filter == SWITCHABLE && | 2296 if ((cm->interp_filter == SWITCHABLE && |
2267 (!i || best_needs_copy)) || | 2297 (!i || best_needs_copy)) || |
2268 (cm->interp_filter != SWITCHABLE && | 2298 (cm->interp_filter != SWITCHABLE && |
2269 (cm->interp_filter == mbmi->interp_filter || | 2299 (cm->interp_filter == mbmi->interp_filter || |
2270 (i == 0 && intpel_mv)))) { | 2300 (i == 0 && intpel_mv)))) { |
2271 restore_dst_buf(xd, orig_dst, orig_dst_stride); | 2301 restore_dst_buf(xd, orig_dst, orig_dst_stride); |
2272 } else { | 2302 } else { |
2273 for (j = 0; j < MAX_MB_PLANE; j++) { | 2303 for (j = 0; j < MAX_MB_PLANE; j++) { |
2274 xd->plane[j].dst.buf = tmp_buf + j * 64 * 64; | 2304 xd->plane[j].dst.buf = tmp_buf + j * 64 * 64; |
2275 xd->plane[j].dst.stride = 64; | 2305 xd->plane[j].dst.stride = 64; |
(...skipping 30 matching lines...) Expand all Loading... |
2306 if (cm->interp_filter == SWITCHABLE && i && !intpel_mv) | 2336 if (cm->interp_filter == SWITCHABLE && i && !intpel_mv) |
2307 best_needs_copy = !best_needs_copy; | 2337 best_needs_copy = !best_needs_copy; |
2308 vpx_memcpy(skip_txfm, x->skip_txfm, sizeof(skip_txfm)); | 2338 vpx_memcpy(skip_txfm, x->skip_txfm, sizeof(skip_txfm)); |
2309 vpx_memcpy(bsse, x->bsse, sizeof(bsse)); | 2339 vpx_memcpy(bsse, x->bsse, sizeof(bsse)); |
2310 } | 2340 } |
2311 | 2341 |
2312 if ((cm->interp_filter == SWITCHABLE && newbest) || | 2342 if ((cm->interp_filter == SWITCHABLE && newbest) || |
2313 (cm->interp_filter != SWITCHABLE && | 2343 (cm->interp_filter != SWITCHABLE && |
2314 cm->interp_filter == mbmi->interp_filter)) { | 2344 cm->interp_filter == mbmi->interp_filter)) { |
2315 pred_exists = 1; | 2345 pred_exists = 1; |
| 2346 tmp_rd = best_rd; |
2316 } | 2347 } |
2317 } | 2348 } |
2318 restore_dst_buf(xd, orig_dst, orig_dst_stride); | 2349 restore_dst_buf(xd, orig_dst, orig_dst_stride); |
2319 } | 2350 } |
2320 } | 2351 } |
2321 // Set the appropriate filter | 2352 // Set the appropriate filter |
2322 mbmi->interp_filter = cm->interp_filter != SWITCHABLE ? | 2353 mbmi->interp_filter = cm->interp_filter != SWITCHABLE ? |
2323 cm->interp_filter : best_filter; | 2354 cm->interp_filter : best_filter; |
2324 rs = cm->interp_filter == SWITCHABLE ? vp9_get_switchable_rate(cpi) : 0; | 2355 rs = cm->interp_filter == SWITCHABLE ? vp9_get_switchable_rate(cpi) : 0; |
2325 | 2356 |
2326 if (pred_exists) { | 2357 if (pred_exists) { |
2327 if (best_needs_copy) { | 2358 if (best_needs_copy) { |
2328 // again temporarily set the buffers to local memory to prevent a memcpy | 2359 // again temporarily set the buffers to local memory to prevent a memcpy |
2329 for (i = 0; i < MAX_MB_PLANE; i++) { | 2360 for (i = 0; i < MAX_MB_PLANE; i++) { |
2330 xd->plane[i].dst.buf = tmp_buf + i * 64 * 64; | 2361 xd->plane[i].dst.buf = tmp_buf + i * 64 * 64; |
2331 xd->plane[i].dst.stride = 64; | 2362 xd->plane[i].dst.stride = 64; |
2332 } | 2363 } |
2333 } | 2364 } |
| 2365 rd = tmp_rd + RDCOST(x->rdmult, x->rddiv, rs, 0); |
2334 } else { | 2366 } else { |
| 2367 int tmp_rate; |
| 2368 int64_t tmp_dist; |
2335 // Handles the special case when a filter that is not in the | 2369 // Handles the special case when a filter that is not in the |
2336 // switchable list (ex. bilinear, 6-tap) is indicated at the frame level | 2370 // switchable list (ex. bilinear) is indicated at the frame level, or |
| 2371 // skip condition holds. |
2337 vp9_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); | 2372 vp9_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); |
| 2373 model_rd_for_sb(cpi, bsize, x, xd, &tmp_rate, &tmp_dist); |
| 2374 rd = RDCOST(x->rdmult, x->rddiv, rs + tmp_rate, tmp_dist); |
| 2375 vpx_memcpy(skip_txfm, x->skip_txfm, sizeof(skip_txfm)); |
| 2376 vpx_memcpy(bsse, x->bsse, sizeof(bsse)); |
2338 } | 2377 } |
2339 | 2378 |
| 2379 if (!is_comp_pred) |
| 2380 single_filter[this_mode][refs[0]] = mbmi->interp_filter; |
| 2381 |
| 2382 if (cpi->sf.adaptive_mode_search) |
| 2383 if (is_comp_pred) |
| 2384 if (single_skippable[this_mode][refs[0]] && |
| 2385 single_skippable[this_mode][refs[1]]) |
| 2386 vpx_memset(skip_txfm, 1, sizeof(skip_txfm)); |
| 2387 |
2340 if (cpi->sf.use_rd_breakout && ref_best_rd < INT64_MAX) { | 2388 if (cpi->sf.use_rd_breakout && ref_best_rd < INT64_MAX) { |
2341 int tmp_rate; | |
2342 int64_t tmp_dist; | |
2343 model_rd_for_sb(cpi, bsize, x, xd, &tmp_rate, &tmp_dist); | |
2344 rd = RDCOST(x->rdmult, x->rddiv, rs + tmp_rate, tmp_dist); | |
2345 // if current pred_error modeled rd is substantially more than the best | 2389 // if current pred_error modeled rd is substantially more than the best |
2346 // so far, do not bother doing full rd | 2390 // so far, do not bother doing full rd |
2347 if (rd / 2 > ref_best_rd) { | 2391 if (rd / 2 > ref_best_rd) { |
2348 restore_dst_buf(xd, orig_dst, orig_dst_stride); | 2392 restore_dst_buf(xd, orig_dst, orig_dst_stride); |
2349 return INT64_MAX; | 2393 return INT64_MAX; |
2350 } | 2394 } |
2351 } | 2395 } |
2352 | 2396 |
2353 if (cm->interp_filter == SWITCHABLE) | 2397 if (cm->interp_filter == SWITCHABLE) |
2354 *rate2 += vp9_get_switchable_rate(cpi); | 2398 *rate2 += rs; |
2355 | 2399 |
2356 if (!is_comp_pred) { | 2400 if (!is_comp_pred) { |
2357 if (cpi->allow_encode_breakout) | 2401 if (cpi->allow_encode_breakout) |
2358 rd_encode_breakout_test(cpi, x, bsize, rate2, distortion, distortion_uv, | 2402 rd_encode_breakout_test(cpi, x, bsize, rate2, distortion, distortion_uv, |
2359 disable_skip); | 2403 disable_skip); |
2360 } | 2404 } |
2361 | 2405 |
2362 vpx_memcpy(x->skip_txfm, skip_txfm, sizeof(skip_txfm)); | 2406 vpx_memcpy(x->skip_txfm, skip_txfm, sizeof(skip_txfm)); |
2363 vpx_memcpy(x->bsse, bsse, sizeof(bsse)); | 2407 vpx_memcpy(x->bsse, bsse, sizeof(bsse)); |
2364 | 2408 |
2365 if (!x->skip) { | 2409 if (!x->skip) { |
2366 int skippable_y, skippable_uv; | 2410 int skippable_y, skippable_uv; |
2367 int64_t sseuv = INT64_MAX; | 2411 int64_t sseuv = INT64_MAX; |
2368 int64_t rdcosty = INT64_MAX; | 2412 int64_t rdcosty = INT64_MAX; |
2369 | 2413 |
2370 // Y cost and distortion | 2414 // Y cost and distortion |
2371 inter_super_block_yrd(cpi, x, rate_y, distortion_y, &skippable_y, psse, | 2415 vp9_subtract_plane(x, bsize, 0); |
2372 bsize, txfm_cache, ref_best_rd); | 2416 super_block_yrd(cpi, x, rate_y, distortion_y, &skippable_y, psse, |
| 2417 bsize, txfm_cache, ref_best_rd); |
2373 | 2418 |
2374 if (*rate_y == INT_MAX) { | 2419 if (*rate_y == INT_MAX) { |
2375 *rate2 = INT_MAX; | 2420 *rate2 = INT_MAX; |
2376 *distortion = INT64_MAX; | 2421 *distortion = INT64_MAX; |
2377 restore_dst_buf(xd, orig_dst, orig_dst_stride); | 2422 restore_dst_buf(xd, orig_dst, orig_dst_stride); |
2378 return INT64_MAX; | 2423 return INT64_MAX; |
2379 } | 2424 } |
2380 | 2425 |
2381 *rate2 += *rate_y; | 2426 *rate2 += *rate_y; |
2382 *distortion += *distortion_y; | 2427 *distortion += *distortion_y; |
2383 | 2428 |
2384 rdcosty = RDCOST(x->rdmult, x->rddiv, *rate2, *distortion); | 2429 rdcosty = RDCOST(x->rdmult, x->rddiv, *rate2, *distortion); |
2385 rdcosty = MIN(rdcosty, RDCOST(x->rdmult, x->rddiv, 0, *psse)); | 2430 rdcosty = MIN(rdcosty, RDCOST(x->rdmult, x->rddiv, 0, *psse)); |
2386 | 2431 |
2387 super_block_uvrd(cpi, x, rate_uv, distortion_uv, &skippable_uv, &sseuv, | 2432 super_block_uvrd(cpi, x, rate_uv, distortion_uv, &skippable_uv, &sseuv, |
2388 bsize, ref_best_rd - rdcosty); | 2433 bsize, ref_best_rd - rdcosty); |
2389 if (*rate_uv == INT_MAX) { | 2434 if (*rate_uv == INT_MAX) { |
2390 *rate2 = INT_MAX; | 2435 *rate2 = INT_MAX; |
2391 *distortion = INT64_MAX; | 2436 *distortion = INT64_MAX; |
2392 restore_dst_buf(xd, orig_dst, orig_dst_stride); | 2437 restore_dst_buf(xd, orig_dst, orig_dst_stride); |
2393 return INT64_MAX; | 2438 return INT64_MAX; |
2394 } | 2439 } |
2395 | 2440 |
2396 *psse += sseuv; | 2441 *psse += sseuv; |
2397 *rate2 += *rate_uv; | 2442 *rate2 += *rate_uv; |
2398 *distortion += *distortion_uv; | 2443 *distortion += *distortion_uv; |
2399 *skippable = skippable_y && skippable_uv; | 2444 *skippable = skippable_y && skippable_uv; |
2400 } | 2445 } |
2401 | 2446 |
| 2447 if (!is_comp_pred) |
| 2448 single_skippable[this_mode][refs[0]] = *skippable; |
| 2449 |
2402 restore_dst_buf(xd, orig_dst, orig_dst_stride); | 2450 restore_dst_buf(xd, orig_dst, orig_dst_stride); |
2403 return this_rd; // if 0, this will be re-calculated by caller | 2451 return this_rd; // if 0, this will be re-calculated by caller |
2404 } | 2452 } |
2405 | 2453 |
2406 void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, | 2454 void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, |
2407 int *returnrate, int64_t *returndist, | 2455 int *returnrate, int64_t *returndist, |
2408 BLOCK_SIZE bsize, | 2456 BLOCK_SIZE bsize, |
2409 PICK_MODE_CONTEXT *ctx, int64_t best_rd) { | 2457 PICK_MODE_CONTEXT *ctx, int64_t best_rd) { |
2410 VP9_COMMON *const cm = &cpi->common; | 2458 VP9_COMMON *const cm = &cpi->common; |
2411 MACROBLOCKD *const xd = &x->e_mbd; | 2459 MACROBLOCKD *const xd = &x->e_mbd; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2498 int64_t best_rd_so_far) { | 2546 int64_t best_rd_so_far) { |
2499 VP9_COMMON *const cm = &cpi->common; | 2547 VP9_COMMON *const cm = &cpi->common; |
2500 RD_OPT *const rd_opt = &cpi->rd; | 2548 RD_OPT *const rd_opt = &cpi->rd; |
2501 MACROBLOCKD *const xd = &x->e_mbd; | 2549 MACROBLOCKD *const xd = &x->e_mbd; |
2502 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; | 2550 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; |
2503 const struct segmentation *const seg = &cm->seg; | 2551 const struct segmentation *const seg = &cm->seg; |
2504 struct macroblockd_plane *const pd = xd->plane; | 2552 struct macroblockd_plane *const pd = xd->plane; |
2505 PREDICTION_MODE this_mode; | 2553 PREDICTION_MODE this_mode; |
2506 MV_REFERENCE_FRAME ref_frame, second_ref_frame; | 2554 MV_REFERENCE_FRAME ref_frame, second_ref_frame; |
2507 unsigned char segment_id = mbmi->segment_id; | 2555 unsigned char segment_id = mbmi->segment_id; |
2508 int comp_pred, i; | 2556 int comp_pred, i, k; |
2509 int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES]; | 2557 int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES]; |
2510 struct buf_2d yv12_mb[4][MAX_MB_PLANE]; | 2558 struct buf_2d yv12_mb[4][MAX_MB_PLANE]; |
2511 int_mv single_newmv[MAX_REF_FRAMES] = { { 0 } }; | 2559 int_mv single_newmv[MAX_REF_FRAMES] = { { 0 } }; |
| 2560 INTERP_FILTER single_inter_filter[MB_MODE_COUNT][MAX_REF_FRAMES]; |
| 2561 int single_skippable[MB_MODE_COUNT][MAX_REF_FRAMES]; |
2512 static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG, | 2562 static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG, |
2513 VP9_ALT_FLAG }; | 2563 VP9_ALT_FLAG }; |
2514 int64_t best_rd = best_rd_so_far; | 2564 int64_t best_rd = best_rd_so_far; |
2515 int64_t best_tx_rd[TX_MODES]; | 2565 int64_t best_tx_rd[TX_MODES]; |
2516 int64_t best_tx_diff[TX_MODES]; | 2566 int64_t best_tx_diff[TX_MODES]; |
2517 int64_t best_pred_diff[REFERENCE_MODES]; | 2567 int64_t best_pred_diff[REFERENCE_MODES]; |
2518 int64_t best_pred_rd[REFERENCE_MODES]; | 2568 int64_t best_pred_rd[REFERENCE_MODES]; |
2519 int64_t best_filter_rd[SWITCHABLE_FILTER_CONTEXTS]; | 2569 int64_t best_filter_rd[SWITCHABLE_FILTER_CONTEXTS]; |
2520 int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; | 2570 int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; |
2521 MB_MODE_INFO best_mbmode; | 2571 MB_MODE_INFO best_mbmode; |
| 2572 int best_mode_skippable = 0; |
2522 int mode_index, best_mode_index = -1; | 2573 int mode_index, best_mode_index = -1; |
2523 unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES]; | 2574 unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES]; |
2524 vp9_prob comp_mode_p; | 2575 vp9_prob comp_mode_p; |
2525 int64_t best_intra_rd = INT64_MAX; | 2576 int64_t best_intra_rd = INT64_MAX; |
2526 int64_t best_inter_rd = INT64_MAX; | 2577 int64_t best_inter_rd = INT64_MAX; |
2527 PREDICTION_MODE best_intra_mode = DC_PRED; | 2578 PREDICTION_MODE best_intra_mode = DC_PRED; |
2528 MV_REFERENCE_FRAME best_inter_ref_frame = LAST_FRAME; | 2579 MV_REFERENCE_FRAME best_inter_ref_frame = LAST_FRAME; |
2529 int rate_uv_intra[TX_SIZES], rate_uv_tokenonly[TX_SIZES]; | 2580 int rate_uv_intra[TX_SIZES], rate_uv_tokenonly[TX_SIZES]; |
2530 int64_t dist_uv[TX_SIZES]; | 2581 int64_t dist_uv[TX_SIZES]; |
2531 int skip_uv[TX_SIZES]; | 2582 int skip_uv[TX_SIZES]; |
(...skipping 17 matching lines...) Expand all Loading... |
2549 for (i = 0; i < REFERENCE_MODES; ++i) | 2600 for (i = 0; i < REFERENCE_MODES; ++i) |
2550 best_pred_rd[i] = INT64_MAX; | 2601 best_pred_rd[i] = INT64_MAX; |
2551 for (i = 0; i < TX_MODES; i++) | 2602 for (i = 0; i < TX_MODES; i++) |
2552 best_tx_rd[i] = INT64_MAX; | 2603 best_tx_rd[i] = INT64_MAX; |
2553 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) | 2604 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) |
2554 best_filter_rd[i] = INT64_MAX; | 2605 best_filter_rd[i] = INT64_MAX; |
2555 for (i = 0; i < TX_SIZES; i++) | 2606 for (i = 0; i < TX_SIZES; i++) |
2556 rate_uv_intra[i] = INT_MAX; | 2607 rate_uv_intra[i] = INT_MAX; |
2557 for (i = 0; i < MAX_REF_FRAMES; ++i) | 2608 for (i = 0; i < MAX_REF_FRAMES; ++i) |
2558 x->pred_sse[i] = INT_MAX; | 2609 x->pred_sse[i] = INT_MAX; |
| 2610 for (i = 0; i < MB_MODE_COUNT; ++i) { |
| 2611 for (k = 0; k < MAX_REF_FRAMES; ++k) { |
| 2612 single_inter_filter[i][k] = SWITCHABLE; |
| 2613 single_skippable[i][k] = 0; |
| 2614 } |
| 2615 } |
2559 | 2616 |
2560 *returnrate = INT_MAX; | 2617 *returnrate = INT_MAX; |
2561 | 2618 |
2562 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { | 2619 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { |
2563 x->pred_mv_sad[ref_frame] = INT_MAX; | 2620 x->pred_mv_sad[ref_frame] = INT_MAX; |
2564 if (cpi->ref_frame_flags & flag_list[ref_frame]) { | 2621 if (cpi->ref_frame_flags & flag_list[ref_frame]) { |
2565 setup_buffer_inter(cpi, x, tile, ref_frame, bsize, mi_row, mi_col, | 2622 setup_buffer_inter(cpi, x, tile, ref_frame, bsize, mi_row, mi_col, |
2566 frame_mv[NEARESTMV], frame_mv[NEARMV], yv12_mb); | 2623 frame_mv[NEARESTMV], frame_mv[NEARMV], yv12_mb); |
2567 } | 2624 } |
2568 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV; | 2625 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2725 if (ref_frame != rf) | 2782 if (ref_frame != rf) |
2726 continue; | 2783 continue; |
2727 | 2784 |
2728 if (const_motion) | 2785 if (const_motion) |
2729 if (this_mode == NEARMV || this_mode == ZEROMV) | 2786 if (this_mode == NEARMV || this_mode == ZEROMV) |
2730 continue; | 2787 continue; |
2731 } | 2788 } |
2732 | 2789 |
2733 comp_pred = second_ref_frame > INTRA_FRAME; | 2790 comp_pred = second_ref_frame > INTRA_FRAME; |
2734 if (comp_pred) { | 2791 if (comp_pred) { |
| 2792 if (!cm->allow_comp_inter_inter) |
| 2793 continue; |
| 2794 |
2735 if ((mode_search_skip_flags & FLAG_SKIP_COMP_BESTINTRA) && | 2795 if ((mode_search_skip_flags & FLAG_SKIP_COMP_BESTINTRA) && |
2736 best_mode_index >=0 && | 2796 best_mode_index >=0 && |
2737 vp9_mode_order[best_mode_index].ref_frame[0] == INTRA_FRAME) | 2797 vp9_mode_order[best_mode_index].ref_frame[0] == INTRA_FRAME) |
2738 continue; | 2798 continue; |
2739 if ((mode_search_skip_flags & FLAG_SKIP_COMP_REFMISMATCH) && | 2799 if ((mode_search_skip_flags & FLAG_SKIP_COMP_REFMISMATCH) && |
2740 ref_frame != best_inter_ref_frame && | 2800 ref_frame != best_inter_ref_frame && |
2741 second_ref_frame != best_inter_ref_frame) | 2801 second_ref_frame != best_inter_ref_frame) |
2742 continue; | 2802 continue; |
2743 mode_excluded = cm->reference_mode == SINGLE_REFERENCE; | 2803 mode_excluded = cm->reference_mode == SINGLE_REFERENCE; |
2744 } else { | 2804 } else { |
2745 if (ref_frame != INTRA_FRAME) | 2805 if (ref_frame != INTRA_FRAME) |
2746 mode_excluded = cm->reference_mode == COMPOUND_REFERENCE; | 2806 mode_excluded = cm->reference_mode == COMPOUND_REFERENCE; |
2747 } | 2807 } |
2748 | 2808 |
2749 if (ref_frame == INTRA_FRAME) { | 2809 if (ref_frame == INTRA_FRAME) { |
| 2810 if (cpi->sf.adaptive_mode_search) |
| 2811 if ((x->source_variance << num_pels_log2_lookup[bsize]) > best_intra_rd) |
| 2812 continue; |
| 2813 |
2750 if (!(intra_y_mode_mask & (1 << this_mode))) | 2814 if (!(intra_y_mode_mask & (1 << this_mode))) |
2751 continue; | 2815 continue; |
2752 if (this_mode != DC_PRED) { | 2816 if (this_mode != DC_PRED) { |
2753 // Disable intra modes other than DC_PRED for blocks with low variance | 2817 // Disable intra modes other than DC_PRED for blocks with low variance |
2754 // Threshold for intra skipping based on source variance | 2818 // Threshold for intra skipping based on source variance |
2755 // TODO(debargha): Specialize the threshold for super block sizes | 2819 // TODO(debargha): Specialize the threshold for super block sizes |
2756 const unsigned int skip_intra_var_thresh = 64; | 2820 const unsigned int skip_intra_var_thresh = 64; |
2757 if ((mode_search_skip_flags & FLAG_SKIP_INTRA_LOWVAR) && | 2821 if ((mode_search_skip_flags & FLAG_SKIP_INTRA_LOWVAR) && |
2758 x->source_variance < skip_intra_var_thresh) | 2822 x->source_variance < skip_intra_var_thresh) |
2759 continue; | 2823 continue; |
(...skipping 18 matching lines...) Expand all Loading... |
2778 } | 2842 } |
2779 | 2843 |
2780 mbmi->mode = this_mode; | 2844 mbmi->mode = this_mode; |
2781 mbmi->uv_mode = DC_PRED; | 2845 mbmi->uv_mode = DC_PRED; |
2782 mbmi->ref_frame[0] = ref_frame; | 2846 mbmi->ref_frame[0] = ref_frame; |
2783 mbmi->ref_frame[1] = second_ref_frame; | 2847 mbmi->ref_frame[1] = second_ref_frame; |
2784 // Evaluate all sub-pel filters irrespective of whether we can use | 2848 // Evaluate all sub-pel filters irrespective of whether we can use |
2785 // them for this frame. | 2849 // them for this frame. |
2786 mbmi->interp_filter = cm->interp_filter == SWITCHABLE ? EIGHTTAP | 2850 mbmi->interp_filter = cm->interp_filter == SWITCHABLE ? EIGHTTAP |
2787 : cm->interp_filter; | 2851 : cm->interp_filter; |
| 2852 mbmi->mv[0].as_int = mbmi->mv[1].as_int = 0; |
| 2853 |
2788 x->skip = 0; | 2854 x->skip = 0; |
2789 set_ref_ptrs(cm, xd, ref_frame, second_ref_frame); | 2855 set_ref_ptrs(cm, xd, ref_frame, second_ref_frame); |
2790 | 2856 |
2791 // Select prediction reference frames. | 2857 // Select prediction reference frames. |
2792 for (i = 0; i < MAX_MB_PLANE; i++) { | 2858 for (i = 0; i < MAX_MB_PLANE; i++) { |
2793 xd->plane[i].pre[0] = yv12_mb[ref_frame][i]; | 2859 xd->plane[i].pre[0] = yv12_mb[ref_frame][i]; |
2794 if (comp_pred) | 2860 if (comp_pred) |
2795 xd->plane[i].pre[1] = yv12_mb[second_ref_frame][i]; | 2861 xd->plane[i].pre[1] = yv12_mb[second_ref_frame][i]; |
2796 } | 2862 } |
2797 | 2863 |
2798 for (i = 0; i < TX_MODES; ++i) | 2864 for (i = 0; i < TX_MODES; ++i) |
2799 tx_cache[i] = INT64_MAX; | 2865 tx_cache[i] = INT64_MAX; |
2800 | 2866 |
2801 if (ref_frame == INTRA_FRAME) { | 2867 if (ref_frame == INTRA_FRAME) { |
2802 TX_SIZE uv_tx; | 2868 TX_SIZE uv_tx; |
2803 intra_super_block_yrd(cpi, x, &rate_y, &distortion_y, &skippable, | 2869 super_block_yrd(cpi, x, &rate_y, &distortion_y, &skippable, |
2804 bsize, tx_cache, best_rd); | 2870 NULL, bsize, tx_cache, best_rd); |
2805 | 2871 |
2806 if (rate_y == INT_MAX) | 2872 if (rate_y == INT_MAX) |
2807 continue; | 2873 continue; |
2808 | 2874 |
2809 uv_tx = get_uv_tx_size_impl(mbmi->tx_size, bsize, pd[1].subsampling_x, | 2875 uv_tx = get_uv_tx_size_impl(mbmi->tx_size, bsize, pd[1].subsampling_x, |
2810 pd[1].subsampling_y); | 2876 pd[1].subsampling_y); |
2811 if (rate_uv_intra[uv_tx] == INT_MAX) { | 2877 if (rate_uv_intra[uv_tx] == INT_MAX) { |
2812 choose_intra_uv_mode(cpi, ctx, bsize, uv_tx, | 2878 choose_intra_uv_mode(cpi, ctx, bsize, uv_tx, |
2813 &rate_uv_intra[uv_tx], &rate_uv_tokenonly[uv_tx], | 2879 &rate_uv_intra[uv_tx], &rate_uv_tokenonly[uv_tx], |
2814 &dist_uv[uv_tx], &skip_uv[uv_tx], &mode_uv[uv_tx]); | 2880 &dist_uv[uv_tx], &skip_uv[uv_tx], &mode_uv[uv_tx]); |
2815 } | 2881 } |
2816 | 2882 |
2817 rate_uv = rate_uv_tokenonly[uv_tx]; | 2883 rate_uv = rate_uv_tokenonly[uv_tx]; |
2818 distortion_uv = dist_uv[uv_tx]; | 2884 distortion_uv = dist_uv[uv_tx]; |
2819 skippable = skippable && skip_uv[uv_tx]; | 2885 skippable = skippable && skip_uv[uv_tx]; |
2820 mbmi->uv_mode = mode_uv[uv_tx]; | 2886 mbmi->uv_mode = mode_uv[uv_tx]; |
2821 | 2887 |
2822 rate2 = rate_y + cpi->mbmode_cost[mbmi->mode] + rate_uv_intra[uv_tx]; | 2888 rate2 = rate_y + cpi->mbmode_cost[mbmi->mode] + rate_uv_intra[uv_tx]; |
2823 if (this_mode != DC_PRED && this_mode != TM_PRED) | 2889 if (this_mode != DC_PRED && this_mode != TM_PRED) |
2824 rate2 += intra_cost_penalty; | 2890 rate2 += intra_cost_penalty; |
2825 distortion2 = distortion_y + distortion_uv; | 2891 distortion2 = distortion_y + distortion_uv; |
2826 } else { | 2892 } else { |
2827 this_rd = handle_inter_mode(cpi, x, bsize, | 2893 this_rd = handle_inter_mode(cpi, x, bsize, |
2828 tx_cache, | 2894 tx_cache, |
2829 &rate2, &distortion2, &skippable, | 2895 &rate2, &distortion2, &skippable, |
2830 &rate_y, &distortion_y, | 2896 &rate_y, &distortion_y, |
2831 &rate_uv, &distortion_uv, | 2897 &rate_uv, &distortion_uv, |
2832 &disable_skip, frame_mv, | 2898 &disable_skip, frame_mv, |
2833 mi_row, mi_col, | 2899 mi_row, mi_col, |
2834 single_newmv, &total_sse, best_rd); | 2900 single_newmv, single_inter_filter, |
| 2901 single_skippable, &total_sse, best_rd); |
2835 if (this_rd == INT64_MAX) | 2902 if (this_rd == INT64_MAX) |
2836 continue; | 2903 continue; |
2837 | 2904 |
2838 compmode_cost = vp9_cost_bit(comp_mode_p, comp_pred); | 2905 compmode_cost = vp9_cost_bit(comp_mode_p, comp_pred); |
2839 | 2906 |
2840 if (cm->reference_mode == REFERENCE_MODE_SELECT) | 2907 if (cm->reference_mode == REFERENCE_MODE_SELECT) |
2841 rate2 += compmode_cost; | 2908 rate2 += compmode_cost; |
2842 } | 2909 } |
2843 | 2910 |
2844 // Estimate the reference frame signaling cost and add it | 2911 // Estimate the reference frame signaling cost and add it |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2912 if (this_rd < best_rd || x->skip) { | 2979 if (this_rd < best_rd || x->skip) { |
2913 int max_plane = MAX_MB_PLANE; | 2980 int max_plane = MAX_MB_PLANE; |
2914 if (!mode_excluded) { | 2981 if (!mode_excluded) { |
2915 // Note index of best mode so far | 2982 // Note index of best mode so far |
2916 best_mode_index = mode_index; | 2983 best_mode_index = mode_index; |
2917 | 2984 |
2918 if (ref_frame == INTRA_FRAME) { | 2985 if (ref_frame == INTRA_FRAME) { |
2919 /* required for left and above block mv */ | 2986 /* required for left and above block mv */ |
2920 mbmi->mv[0].as_int = 0; | 2987 mbmi->mv[0].as_int = 0; |
2921 max_plane = 1; | 2988 max_plane = 1; |
| 2989 } else { |
| 2990 best_intra_rd = x->pred_sse[ref_frame]; |
2922 } | 2991 } |
2923 | 2992 |
2924 *returnrate = rate2; | 2993 *returnrate = rate2; |
2925 *returndistortion = distortion2; | 2994 *returndistortion = distortion2; |
2926 best_rd = this_rd; | 2995 best_rd = this_rd; |
2927 best_mbmode = *mbmi; | 2996 best_mbmode = *mbmi; |
2928 best_skip2 = this_skip2; | 2997 best_skip2 = this_skip2; |
| 2998 best_mode_skippable = skippable; |
| 2999 |
2929 if (!x->select_tx_size) | 3000 if (!x->select_tx_size) |
2930 swap_block_ptr(x, ctx, 1, 0, 0, max_plane); | 3001 swap_block_ptr(x, ctx, 1, 0, 0, max_plane); |
2931 vpx_memcpy(ctx->zcoeff_blk, x->zcoeff_blk[mbmi->tx_size], | 3002 vpx_memcpy(ctx->zcoeff_blk, x->zcoeff_blk[mbmi->tx_size], |
2932 sizeof(uint8_t) * ctx->num_4x4_blk); | 3003 sizeof(uint8_t) * ctx->num_4x4_blk); |
2933 | 3004 |
2934 // TODO(debargha): enhance this test with a better distortion prediction | 3005 // TODO(debargha): enhance this test with a better distortion prediction |
2935 // based on qp, activity mask and history | 3006 // based on qp, activity mask and history |
2936 if ((mode_search_skip_flags & FLAG_EARLY_TERMINATE) && | 3007 if ((mode_search_skip_flags & FLAG_EARLY_TERMINATE) && |
2937 (mode_index > MIN_EARLY_TERM_INDEX)) { | 3008 (mode_index > MIN_EARLY_TERM_INDEX)) { |
2938 const int qstep = xd->plane[0].dequant[1]; | 3009 const int qstep = xd->plane[0].dequant[1]; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3018 } | 3089 } |
3019 } | 3090 } |
3020 | 3091 |
3021 if (early_term) | 3092 if (early_term) |
3022 break; | 3093 break; |
3023 | 3094 |
3024 if (x->skip && !comp_pred) | 3095 if (x->skip && !comp_pred) |
3025 break; | 3096 break; |
3026 } | 3097 } |
3027 | 3098 |
| 3099 // The inter modes' rate costs are not calculated precisely in some cases. |
| 3100 // Therefore, sometimes, NEWMV is chosen instead of NEARESTMV, NEARMV, and |
| 3101 // ZEROMV. Here, checks are added for those cases, and the mode decisions |
| 3102 // are corrected. |
| 3103 if (best_mbmode.mode == NEWMV) { |
| 3104 const MV_REFERENCE_FRAME refs[2] = {best_mbmode.ref_frame[0], |
| 3105 best_mbmode.ref_frame[1]}; |
| 3106 int comp_pred_mode = refs[1] > INTRA_FRAME; |
| 3107 |
| 3108 if (frame_mv[NEARESTMV][refs[0]].as_int == best_mbmode.mv[0].as_int && |
| 3109 ((comp_pred_mode && frame_mv[NEARESTMV][refs[1]].as_int == |
| 3110 best_mbmode.mv[1].as_int) || !comp_pred_mode)) |
| 3111 best_mbmode.mode = NEARESTMV; |
| 3112 else if (frame_mv[NEARMV][refs[0]].as_int == best_mbmode.mv[0].as_int && |
| 3113 ((comp_pred_mode && frame_mv[NEARMV][refs[1]].as_int == |
| 3114 best_mbmode.mv[1].as_int) || !comp_pred_mode)) |
| 3115 best_mbmode.mode = NEARMV; |
| 3116 else if (best_mbmode.mv[0].as_int == 0 && |
| 3117 ((comp_pred_mode && best_mbmode.mv[1].as_int == 0) || !comp_pred_mode)) |
| 3118 best_mbmode.mode = ZEROMV; |
| 3119 } |
| 3120 |
3028 if (best_mode_index < 0 || best_rd >= best_rd_so_far) | 3121 if (best_mode_index < 0 || best_rd >= best_rd_so_far) |
3029 return INT64_MAX; | 3122 return INT64_MAX; |
3030 | 3123 |
3031 // If we used an estimate for the uv intra rd in the loop above... | 3124 // If we used an estimate for the uv intra rd in the loop above... |
3032 if (cpi->sf.use_uv_intra_rd_estimate) { | 3125 if (cpi->sf.use_uv_intra_rd_estimate) { |
3033 // Do Intra UV best rd mode selection if best mode choice above was intra. | 3126 // Do Intra UV best rd mode selection if best mode choice above was intra. |
3034 if (vp9_mode_order[best_mode_index].ref_frame[0] == INTRA_FRAME) { | 3127 if (vp9_mode_order[best_mode_index].ref_frame[0] == INTRA_FRAME) { |
3035 TX_SIZE uv_tx_size; | 3128 TX_SIZE uv_tx_size; |
3036 *mbmi = best_mbmode; | 3129 *mbmi = best_mbmode; |
3037 uv_tx_size = get_uv_tx_size(mbmi, &xd->plane[1]); | 3130 uv_tx_size = get_uv_tx_size(mbmi, &xd->plane[1]); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3075 best_tx_diff[i] = 0; | 3168 best_tx_diff[i] = 0; |
3076 else | 3169 else |
3077 best_tx_diff[i] = best_rd - best_tx_rd[i]; | 3170 best_tx_diff[i] = best_rd - best_tx_rd[i]; |
3078 } | 3171 } |
3079 } else { | 3172 } else { |
3080 vp9_zero(best_filter_diff); | 3173 vp9_zero(best_filter_diff); |
3081 vp9_zero(best_tx_diff); | 3174 vp9_zero(best_tx_diff); |
3082 } | 3175 } |
3083 | 3176 |
3084 set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]); | 3177 set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]); |
3085 store_coding_context(x, ctx, best_mode_index, | 3178 store_coding_context(x, ctx, best_mode_index, best_pred_diff, |
3086 best_pred_diff, best_tx_diff, best_filter_diff); | 3179 best_tx_diff, best_filter_diff, best_mode_skippable); |
3087 | 3180 |
3088 return best_rd; | 3181 return best_rd; |
3089 } | 3182 } |
3090 | 3183 |
3091 int64_t vp9_rd_pick_inter_mode_sb_seg_skip(VP9_COMP *cpi, MACROBLOCK *x, | 3184 int64_t vp9_rd_pick_inter_mode_sb_seg_skip(VP9_COMP *cpi, MACROBLOCK *x, |
3092 int *returnrate, | 3185 int *returnrate, |
3093 int64_t *returndistortion, | 3186 int64_t *returndistortion, |
3094 BLOCK_SIZE bsize, | 3187 BLOCK_SIZE bsize, |
3095 PICK_MODE_CONTEXT *ctx, | 3188 PICK_MODE_CONTEXT *ctx, |
3096 int64_t best_rd_so_far) { | 3189 int64_t best_rd_so_far) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3181 | 3274 |
3182 update_rd_thresh_fact(cpi, bsize, THR_ZEROMV); | 3275 update_rd_thresh_fact(cpi, bsize, THR_ZEROMV); |
3183 | 3276 |
3184 vp9_zero(best_pred_diff); | 3277 vp9_zero(best_pred_diff); |
3185 vp9_zero(best_filter_diff); | 3278 vp9_zero(best_filter_diff); |
3186 vp9_zero(best_tx_diff); | 3279 vp9_zero(best_tx_diff); |
3187 | 3280 |
3188 if (!x->select_tx_size) | 3281 if (!x->select_tx_size) |
3189 swap_block_ptr(x, ctx, 1, 0, 0, MAX_MB_PLANE); | 3282 swap_block_ptr(x, ctx, 1, 0, 0, MAX_MB_PLANE); |
3190 store_coding_context(x, ctx, THR_ZEROMV, | 3283 store_coding_context(x, ctx, THR_ZEROMV, |
3191 best_pred_diff, best_tx_diff, best_filter_diff); | 3284 best_pred_diff, best_tx_diff, best_filter_diff, 0); |
3192 | 3285 |
3193 return this_rd; | 3286 return this_rd; |
3194 } | 3287 } |
3195 | 3288 |
3196 int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, | 3289 int64_t vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, |
3197 const TileInfo *const tile, | 3290 const TileInfo *const tile, |
3198 int mi_row, int mi_col, | 3291 int mi_row, int mi_col, |
3199 int *returnrate, | 3292 int *returnrate, |
3200 int64_t *returndistortion, | 3293 int64_t *returndistortion, |
3201 BLOCK_SIZE bsize, | 3294 BLOCK_SIZE bsize, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3318 rd_opt->thresh_freq_fact[bsize][ref_index])) | 3411 rd_opt->thresh_freq_fact[bsize][ref_index])) |
3319 continue; | 3412 continue; |
3320 | 3413 |
3321 if (ref_frame > INTRA_FRAME && | 3414 if (ref_frame > INTRA_FRAME && |
3322 !(cpi->ref_frame_flags & flag_list[ref_frame])) { | 3415 !(cpi->ref_frame_flags & flag_list[ref_frame])) { |
3323 continue; | 3416 continue; |
3324 } | 3417 } |
3325 | 3418 |
3326 comp_pred = second_ref_frame > INTRA_FRAME; | 3419 comp_pred = second_ref_frame > INTRA_FRAME; |
3327 if (comp_pred) { | 3420 if (comp_pred) { |
| 3421 if (!cm->allow_comp_inter_inter) |
| 3422 continue; |
| 3423 |
3328 if (!(cpi->ref_frame_flags & flag_list[second_ref_frame])) | 3424 if (!(cpi->ref_frame_flags & flag_list[second_ref_frame])) |
3329 continue; | 3425 continue; |
3330 // Do not allow compound prediction if the segment level reference frame | 3426 // Do not allow compound prediction if the segment level reference frame |
3331 // feature is in use as in this case there can only be one reference. | 3427 // feature is in use as in this case there can only be one reference. |
3332 if (vp9_segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME)) | 3428 if (vp9_segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME)) |
3333 continue; | 3429 continue; |
3334 if ((cpi->sf.mode_search_skip_flags & FLAG_SKIP_COMP_BESTINTRA) && | 3430 if ((cpi->sf.mode_search_skip_flags & FLAG_SKIP_COMP_BESTINTRA) && |
3335 vp9_ref_order[best_ref_index].ref_frame[0] == INTRA_FRAME) | 3431 vp9_ref_order[best_ref_index].ref_frame[0] == INTRA_FRAME) |
3336 continue; | 3432 continue; |
3337 if ((cpi->sf.mode_search_skip_flags & FLAG_SKIP_COMP_REFMISMATCH) && | 3433 if ((cpi->sf.mode_search_skip_flags & FLAG_SKIP_COMP_REFMISMATCH) && |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3786 best_filter_diff[i] = best_rd - best_filter_rd[i]; | 3882 best_filter_diff[i] = best_rd - best_filter_rd[i]; |
3787 } | 3883 } |
3788 if (cm->interp_filter == SWITCHABLE) | 3884 if (cm->interp_filter == SWITCHABLE) |
3789 assert(best_filter_diff[SWITCHABLE_FILTERS] == 0); | 3885 assert(best_filter_diff[SWITCHABLE_FILTERS] == 0); |
3790 } else { | 3886 } else { |
3791 vp9_zero(best_filter_diff); | 3887 vp9_zero(best_filter_diff); |
3792 } | 3888 } |
3793 | 3889 |
3794 set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]); | 3890 set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]); |
3795 store_coding_context(x, ctx, best_ref_index, | 3891 store_coding_context(x, ctx, best_ref_index, |
3796 best_pred_diff, best_tx_diff, best_filter_diff); | 3892 best_pred_diff, best_tx_diff, best_filter_diff, 0); |
3797 | 3893 |
3798 return best_rd; | 3894 return best_rd; |
3799 } | 3895 } |
OLD | NEW |