| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 assert(0 && "Invalid transform size."); | 357 assert(0 && "Invalid transform size."); |
| 358 break; | 358 break; |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 | 361 |
| 362 void vp9_mv_pred(VP9_COMP *cpi, MACROBLOCK *x, | 362 void vp9_mv_pred(VP9_COMP *cpi, MACROBLOCK *x, |
| 363 uint8_t *ref_y_buffer, int ref_y_stride, | 363 uint8_t *ref_y_buffer, int ref_y_stride, |
| 364 int ref_frame, BLOCK_SIZE block_size) { | 364 int ref_frame, BLOCK_SIZE block_size) { |
| 365 MACROBLOCKD *xd = &x->e_mbd; | 365 MACROBLOCKD *xd = &x->e_mbd; |
| 366 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; | 366 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; |
| 367 int_mv this_mv; | |
| 368 int i; | 367 int i; |
| 369 int zero_seen = 0; | 368 int zero_seen = 0; |
| 370 int best_index = 0; | 369 int best_index = 0; |
| 371 int best_sad = INT_MAX; | 370 int best_sad = INT_MAX; |
| 372 int this_sad = INT_MAX; | 371 int this_sad = INT_MAX; |
| 373 int max_mv = 0; | 372 int max_mv = 0; |
| 374 | |
| 375 uint8_t *src_y_ptr = x->plane[0].src.buf; | 373 uint8_t *src_y_ptr = x->plane[0].src.buf; |
| 376 uint8_t *ref_y_ptr; | 374 uint8_t *ref_y_ptr; |
| 377 int row_offset, col_offset; | 375 const int num_mv_refs = MAX_MV_REF_CANDIDATES + |
| 378 int num_mv_refs = MAX_MV_REF_CANDIDATES + | |
| 379 (cpi->sf.adaptive_motion_search && | 376 (cpi->sf.adaptive_motion_search && |
| 380 cpi->common.show_frame && | |
| 381 block_size < cpi->sf.max_partition_size); | 377 block_size < cpi->sf.max_partition_size); |
| 382 | 378 |
| 383 MV pred_mv[3]; | 379 MV pred_mv[3]; |
| 384 pred_mv[0] = mbmi->ref_mvs[ref_frame][0].as_mv; | 380 pred_mv[0] = mbmi->ref_mvs[ref_frame][0].as_mv; |
| 385 pred_mv[1] = mbmi->ref_mvs[ref_frame][1].as_mv; | 381 pred_mv[1] = mbmi->ref_mvs[ref_frame][1].as_mv; |
| 386 pred_mv[2] = x->pred_mv[ref_frame]; | 382 pred_mv[2] = x->pred_mv[ref_frame]; |
| 387 | 383 |
| 388 // Get the sad for each candidate reference mv. | 384 // Get the sad for each candidate reference mv. |
| 389 for (i = 0; i < num_mv_refs; ++i) { | 385 for (i = 0; i < num_mv_refs; ++i) { |
| 390 this_mv.as_mv = pred_mv[i]; | 386 const MV *this_mv = &pred_mv[i]; |
| 391 | 387 |
| 392 max_mv = MAX(max_mv, | 388 max_mv = MAX(max_mv, MAX(abs(this_mv->row), abs(this_mv->col)) >> 3); |
| 393 MAX(abs(this_mv.as_mv.row), abs(this_mv.as_mv.col)) >> 3); | 389 if (is_zero_mv(this_mv) && zero_seen) |
| 394 // Only need to check zero mv once. | |
| 395 if (!this_mv.as_int && zero_seen) | |
| 396 continue; | 390 continue; |
| 397 | 391 |
| 398 zero_seen = zero_seen || !this_mv.as_int; | 392 zero_seen |= is_zero_mv(this_mv); |
| 399 | 393 |
| 400 row_offset = this_mv.as_mv.row >> 3; | 394 ref_y_ptr = |
| 401 col_offset = this_mv.as_mv.col >> 3; | 395 &ref_y_buffer[ref_y_stride * (this_mv->row >> 3) + (this_mv->col >> 3)]; |
| 402 ref_y_ptr = ref_y_buffer + (ref_y_stride * row_offset) + col_offset; | |
| 403 | 396 |
| 404 // Find sad for current vector. | 397 // Find sad for current vector. |
| 405 this_sad = cpi->fn_ptr[block_size].sdf(src_y_ptr, x->plane[0].src.stride, | 398 this_sad = cpi->fn_ptr[block_size].sdf(src_y_ptr, x->plane[0].src.stride, |
| 406 ref_y_ptr, ref_y_stride); | 399 ref_y_ptr, ref_y_stride); |
| 407 | 400 |
| 408 // Note if it is the best so far. | 401 // Note if it is the best so far. |
| 409 if (this_sad < best_sad) { | 402 if (this_sad < best_sad) { |
| 410 best_sad = this_sad; | 403 best_sad = this_sad; |
| 411 best_index = i; | 404 best_index = i; |
| 412 } | 405 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 cpi->switchable_interp_costs[ctx][mbmi->interp_filter]; | 448 cpi->switchable_interp_costs[ctx][mbmi->interp_filter]; |
| 456 } | 449 } |
| 457 | 450 |
| 458 void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) { | 451 void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) { |
| 459 int i; | 452 int i; |
| 460 RD_OPT *const rd = &cpi->rd; | 453 RD_OPT *const rd = &cpi->rd; |
| 461 SPEED_FEATURES *const sf = &cpi->sf; | 454 SPEED_FEATURES *const sf = &cpi->sf; |
| 462 | 455 |
| 463 // Set baseline threshold values. | 456 // Set baseline threshold values. |
| 464 for (i = 0; i < MAX_MODES; ++i) | 457 for (i = 0; i < MAX_MODES; ++i) |
| 465 rd->thresh_mult[i] = is_best_mode(cpi->oxcf.mode) ? -500 : 0; | 458 rd->thresh_mult[i] = cpi->oxcf.mode == BEST ? -500 : 0; |
| 466 | 459 |
| 467 rd->thresh_mult[THR_NEARESTMV] = 0; | 460 rd->thresh_mult[THR_NEARESTMV] = 0; |
| 468 rd->thresh_mult[THR_NEARESTG] = 0; | 461 rd->thresh_mult[THR_NEARESTG] = 0; |
| 469 rd->thresh_mult[THR_NEARESTA] = 0; | 462 rd->thresh_mult[THR_NEARESTA] = 0; |
| 470 | 463 |
| 471 rd->thresh_mult[THR_DC] += 1000; | 464 rd->thresh_mult[THR_DC] += 1000; |
| 472 | 465 |
| 473 rd->thresh_mult[THR_NEWMV] += 1000; | 466 rd->thresh_mult[THR_NEWMV] += 1000; |
| 474 rd->thresh_mult[THR_NEWA] += 1000; | 467 rd->thresh_mult[THR_NEWA] += 1000; |
| 475 rd->thresh_mult[THR_NEWG] += 1000; | 468 rd->thresh_mult[THR_NEWG] += 1000; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 rd->thresh_mult[THR_COMP_NEWGA ] = INT_MAX; | 534 rd->thresh_mult[THR_COMP_NEWGA ] = INT_MAX; |
| 542 } | 535 } |
| 543 } | 536 } |
| 544 | 537 |
| 545 void vp9_set_rd_speed_thresholds_sub8x8(VP9_COMP *cpi) { | 538 void vp9_set_rd_speed_thresholds_sub8x8(VP9_COMP *cpi) { |
| 546 const SPEED_FEATURES *const sf = &cpi->sf; | 539 const SPEED_FEATURES *const sf = &cpi->sf; |
| 547 RD_OPT *const rd = &cpi->rd; | 540 RD_OPT *const rd = &cpi->rd; |
| 548 int i; | 541 int i; |
| 549 | 542 |
| 550 for (i = 0; i < MAX_REFS; ++i) | 543 for (i = 0; i < MAX_REFS; ++i) |
| 551 rd->thresh_mult_sub8x8[i] = is_best_mode(cpi->oxcf.mode) ? -500 : 0; | 544 rd->thresh_mult_sub8x8[i] = cpi->oxcf.mode == BEST ? -500 : 0; |
| 552 | 545 |
| 553 rd->thresh_mult_sub8x8[THR_LAST] += 2500; | 546 rd->thresh_mult_sub8x8[THR_LAST] += 2500; |
| 554 rd->thresh_mult_sub8x8[THR_GOLD] += 2500; | 547 rd->thresh_mult_sub8x8[THR_GOLD] += 2500; |
| 555 rd->thresh_mult_sub8x8[THR_ALTR] += 2500; | 548 rd->thresh_mult_sub8x8[THR_ALTR] += 2500; |
| 556 rd->thresh_mult_sub8x8[THR_INTRA] += 2500; | 549 rd->thresh_mult_sub8x8[THR_INTRA] += 2500; |
| 557 rd->thresh_mult_sub8x8[THR_COMP_LA] += 4500; | 550 rd->thresh_mult_sub8x8[THR_COMP_LA] += 4500; |
| 558 rd->thresh_mult_sub8x8[THR_COMP_GA] += 4500; | 551 rd->thresh_mult_sub8x8[THR_COMP_GA] += 4500; |
| 559 | 552 |
| 560 // Check for masked out split cases. | 553 // Check for masked out split cases. |
| 561 for (i = 0; i < MAX_REFS; ++i) | 554 for (i = 0; i < MAX_REFS; ++i) |
| 562 if (sf->disable_split_mask & (1 << i)) | 555 if (sf->disable_split_mask & (1 << i)) |
| 563 rd->thresh_mult_sub8x8[i] = INT_MAX; | 556 rd->thresh_mult_sub8x8[i] = INT_MAX; |
| 564 | 557 |
| 565 // Disable mode test if frame flag is not set. | 558 // Disable mode test if frame flag is not set. |
| 566 if (!(cpi->ref_frame_flags & VP9_LAST_FLAG)) | 559 if (!(cpi->ref_frame_flags & VP9_LAST_FLAG)) |
| 567 rd->thresh_mult_sub8x8[THR_LAST] = INT_MAX; | 560 rd->thresh_mult_sub8x8[THR_LAST] = INT_MAX; |
| 568 if (!(cpi->ref_frame_flags & VP9_GOLD_FLAG)) | 561 if (!(cpi->ref_frame_flags & VP9_GOLD_FLAG)) |
| 569 rd->thresh_mult_sub8x8[THR_GOLD] = INT_MAX; | 562 rd->thresh_mult_sub8x8[THR_GOLD] = INT_MAX; |
| 570 if (!(cpi->ref_frame_flags & VP9_ALT_FLAG)) | 563 if (!(cpi->ref_frame_flags & VP9_ALT_FLAG)) |
| 571 rd->thresh_mult_sub8x8[THR_ALTR] = INT_MAX; | 564 rd->thresh_mult_sub8x8[THR_ALTR] = INT_MAX; |
| 572 if ((cpi->ref_frame_flags & (VP9_LAST_FLAG | VP9_ALT_FLAG)) != | 565 if ((cpi->ref_frame_flags & (VP9_LAST_FLAG | VP9_ALT_FLAG)) != |
| 573 (VP9_LAST_FLAG | VP9_ALT_FLAG)) | 566 (VP9_LAST_FLAG | VP9_ALT_FLAG)) |
| 574 rd->thresh_mult_sub8x8[THR_COMP_LA] = INT_MAX; | 567 rd->thresh_mult_sub8x8[THR_COMP_LA] = INT_MAX; |
| 575 if ((cpi->ref_frame_flags & (VP9_GOLD_FLAG | VP9_ALT_FLAG)) != | 568 if ((cpi->ref_frame_flags & (VP9_GOLD_FLAG | VP9_ALT_FLAG)) != |
| 576 (VP9_GOLD_FLAG | VP9_ALT_FLAG)) | 569 (VP9_GOLD_FLAG | VP9_ALT_FLAG)) |
| 577 rd->thresh_mult_sub8x8[THR_COMP_GA] = INT_MAX; | 570 rd->thresh_mult_sub8x8[THR_COMP_GA] = INT_MAX; |
| 578 } | 571 } |
| OLD | NEW |