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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 ENTROPY_CONTEXT t_left[16]) { | 412 ENTROPY_CONTEXT t_left[16]) { |
413 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); | 413 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); |
414 const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize]; | 414 const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize]; |
415 const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize]; | 415 const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize]; |
416 const ENTROPY_CONTEXT *const above = pd->above_context; | 416 const ENTROPY_CONTEXT *const above = pd->above_context; |
417 const ENTROPY_CONTEXT *const left = pd->left_context; | 417 const ENTROPY_CONTEXT *const left = pd->left_context; |
418 | 418 |
419 int i; | 419 int i; |
420 switch (tx_size) { | 420 switch (tx_size) { |
421 case TX_4X4: | 421 case TX_4X4: |
422 vpx_memcpy(t_above, above, sizeof(ENTROPY_CONTEXT) * num_4x4_w); | 422 memcpy(t_above, above, sizeof(ENTROPY_CONTEXT) * num_4x4_w); |
423 vpx_memcpy(t_left, left, sizeof(ENTROPY_CONTEXT) * num_4x4_h); | 423 memcpy(t_left, left, sizeof(ENTROPY_CONTEXT) * num_4x4_h); |
424 break; | 424 break; |
425 case TX_8X8: | 425 case TX_8X8: |
426 for (i = 0; i < num_4x4_w; i += 2) | 426 for (i = 0; i < num_4x4_w; i += 2) |
427 t_above[i] = !!*(const uint16_t *)&above[i]; | 427 t_above[i] = !!*(const uint16_t *)&above[i]; |
428 for (i = 0; i < num_4x4_h; i += 2) | 428 for (i = 0; i < num_4x4_h; i += 2) |
429 t_left[i] = !!*(const uint16_t *)&left[i]; | 429 t_left[i] = !!*(const uint16_t *)&left[i]; |
430 break; | 430 break; |
431 case TX_16X16: | 431 case TX_16X16: |
432 for (i = 0; i < num_4x4_w; i += 4) | 432 for (i = 0; i < num_4x4_w; i += 4) |
433 t_above[i] = !!*(const uint32_t *)&above[i]; | 433 t_above[i] = !!*(const uint32_t *)&above[i]; |
434 for (i = 0; i < num_4x4_h; i += 4) | 434 for (i = 0; i < num_4x4_h; i += 4) |
435 t_left[i] = !!*(const uint32_t *)&left[i]; | 435 t_left[i] = !!*(const uint32_t *)&left[i]; |
436 break; | 436 break; |
437 case TX_32X32: | 437 case TX_32X32: |
438 for (i = 0; i < num_4x4_w; i += 8) | 438 for (i = 0; i < num_4x4_w; i += 8) |
439 t_above[i] = !!*(const uint64_t *)&above[i]; | 439 t_above[i] = !!*(const uint64_t *)&above[i]; |
440 for (i = 0; i < num_4x4_h; i += 8) | 440 for (i = 0; i < num_4x4_h; i += 8) |
441 t_left[i] = !!*(const uint64_t *)&left[i]; | 441 t_left[i] = !!*(const uint64_t *)&left[i]; |
442 break; | 442 break; |
443 default: | 443 default: |
444 assert(0 && "Invalid transform size."); | 444 assert(0 && "Invalid transform size."); |
445 break; | 445 break; |
446 } | 446 } |
447 } | 447 } |
448 | 448 |
449 void vp9_mv_pred(VP9_COMP *cpi, MACROBLOCK *x, | 449 void vp9_mv_pred(VP9_COMP *cpi, MACROBLOCK *x, |
450 uint8_t *ref_y_buffer, int ref_y_stride, | 450 uint8_t *ref_y_buffer, int ref_y_stride, |
451 int ref_frame, BLOCK_SIZE block_size) { | 451 int ref_frame, BLOCK_SIZE block_size) { |
452 MACROBLOCKD *xd = &x->e_mbd; | 452 MACROBLOCKD *xd = &x->e_mbd; |
453 MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; | 453 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; |
454 int i; | 454 int i; |
455 int zero_seen = 0; | 455 int zero_seen = 0; |
456 int best_index = 0; | 456 int best_index = 0; |
457 int best_sad = INT_MAX; | 457 int best_sad = INT_MAX; |
458 int this_sad = INT_MAX; | 458 int this_sad = INT_MAX; |
459 int max_mv = 0; | 459 int max_mv = 0; |
| 460 int near_same_nearest; |
460 uint8_t *src_y_ptr = x->plane[0].src.buf; | 461 uint8_t *src_y_ptr = x->plane[0].src.buf; |
461 uint8_t *ref_y_ptr; | 462 uint8_t *ref_y_ptr; |
462 const int num_mv_refs = MAX_MV_REF_CANDIDATES + | 463 const int num_mv_refs = MAX_MV_REF_CANDIDATES + |
463 (cpi->sf.adaptive_motion_search && | 464 (cpi->sf.adaptive_motion_search && |
464 block_size < x->max_partition_size); | 465 block_size < x->max_partition_size); |
465 | 466 |
466 MV pred_mv[3]; | 467 MV pred_mv[3]; |
467 pred_mv[0] = mbmi->ref_mvs[ref_frame][0].as_mv; | 468 pred_mv[0] = mbmi->ref_mvs[ref_frame][0].as_mv; |
468 pred_mv[1] = mbmi->ref_mvs[ref_frame][1].as_mv; | 469 pred_mv[1] = mbmi->ref_mvs[ref_frame][1].as_mv; |
469 pred_mv[2] = x->pred_mv[ref_frame]; | 470 pred_mv[2] = x->pred_mv[ref_frame]; |
470 assert(num_mv_refs <= (int)(sizeof(pred_mv) / sizeof(pred_mv[0]))); | 471 assert(num_mv_refs <= (int)(sizeof(pred_mv) / sizeof(pred_mv[0]))); |
471 | 472 |
| 473 near_same_nearest = |
| 474 mbmi->ref_mvs[ref_frame][0].as_int == mbmi->ref_mvs[ref_frame][1].as_int; |
472 // Get the sad for each candidate reference mv. | 475 // Get the sad for each candidate reference mv. |
473 for (i = 0; i < num_mv_refs; ++i) { | 476 for (i = 0; i < num_mv_refs; ++i) { |
474 const MV *this_mv = &pred_mv[i]; | 477 const MV *this_mv = &pred_mv[i]; |
| 478 int fp_row, fp_col; |
475 | 479 |
| 480 if (i == 1 && near_same_nearest) |
| 481 continue; |
| 482 fp_row = (this_mv->row + 3 + (this_mv->row >= 0)) >> 3; |
| 483 fp_col = (this_mv->col + 3 + (this_mv->col >= 0)) >> 3; |
476 max_mv = MAX(max_mv, MAX(abs(this_mv->row), abs(this_mv->col)) >> 3); | 484 max_mv = MAX(max_mv, MAX(abs(this_mv->row), abs(this_mv->col)) >> 3); |
477 if (is_zero_mv(this_mv) && zero_seen) | 485 |
| 486 if (fp_row ==0 && fp_col == 0 && zero_seen) |
478 continue; | 487 continue; |
| 488 zero_seen |= (fp_row ==0 && fp_col == 0); |
479 | 489 |
480 zero_seen |= is_zero_mv(this_mv); | 490 ref_y_ptr =&ref_y_buffer[ref_y_stride * fp_row + fp_col]; |
481 | |
482 ref_y_ptr = | |
483 &ref_y_buffer[ref_y_stride * (this_mv->row >> 3) + (this_mv->col >> 3)]; | |
484 | |
485 // Find sad for current vector. | 491 // Find sad for current vector. |
486 this_sad = cpi->fn_ptr[block_size].sdf(src_y_ptr, x->plane[0].src.stride, | 492 this_sad = cpi->fn_ptr[block_size].sdf(src_y_ptr, x->plane[0].src.stride, |
487 ref_y_ptr, ref_y_stride); | 493 ref_y_ptr, ref_y_stride); |
488 | |
489 // Note if it is the best so far. | 494 // Note if it is the best so far. |
490 if (this_sad < best_sad) { | 495 if (this_sad < best_sad) { |
491 best_sad = this_sad; | 496 best_sad = this_sad; |
492 best_index = i; | 497 best_index = i; |
493 } | 498 } |
494 } | 499 } |
495 | 500 |
496 // Note the index of the mv that worked best in the reference list. | 501 // Note the index of the mv that worked best in the reference list. |
497 x->mv_best_ref_index[ref_frame] = best_index; | 502 x->mv_best_ref_index[ref_frame] = best_index; |
498 x->max_mv_context[ref_frame] = max_mv; | 503 x->max_mv_context[ref_frame] = max_mv; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 int ref_frame) { | 543 int ref_frame) { |
539 const VP9_COMMON *const cm = &cpi->common; | 544 const VP9_COMMON *const cm = &cpi->common; |
540 const int scaled_idx = cpi->scaled_ref_idx[ref_frame - 1]; | 545 const int scaled_idx = cpi->scaled_ref_idx[ref_frame - 1]; |
541 const int ref_idx = get_ref_frame_buf_idx(cpi, ref_frame); | 546 const int ref_idx = get_ref_frame_buf_idx(cpi, ref_frame); |
542 return | 547 return |
543 (scaled_idx != ref_idx && scaled_idx != INVALID_IDX) ? | 548 (scaled_idx != ref_idx && scaled_idx != INVALID_IDX) ? |
544 &cm->buffer_pool->frame_bufs[scaled_idx].buf : NULL; | 549 &cm->buffer_pool->frame_bufs[scaled_idx].buf : NULL; |
545 } | 550 } |
546 | 551 |
547 int vp9_get_switchable_rate(const VP9_COMP *cpi, const MACROBLOCKD *const xd) { | 552 int vp9_get_switchable_rate(const VP9_COMP *cpi, const MACROBLOCKD *const xd) { |
548 const MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; | 553 const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; |
549 const int ctx = vp9_get_pred_context_switchable_interp(xd); | 554 const int ctx = vp9_get_pred_context_switchable_interp(xd); |
550 return SWITCHABLE_INTERP_RATE_FACTOR * | 555 return SWITCHABLE_INTERP_RATE_FACTOR * |
551 cpi->switchable_interp_costs[ctx][mbmi->interp_filter]; | 556 cpi->switchable_interp_costs[ctx][mbmi->interp_filter]; |
552 } | 557 } |
553 | 558 |
554 void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) { | 559 void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) { |
555 int i; | 560 int i; |
556 RD_OPT *const rd = &cpi->rd; | 561 RD_OPT *const rd = &cpi->rd; |
557 SPEED_FEATURES *const sf = &cpi->sf; | 562 SPEED_FEATURES *const sf = &cpi->sf; |
558 | 563 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 rd->thresh_mult[THR_D207_PRED] += 2500; | 609 rd->thresh_mult[THR_D207_PRED] += 2500; |
605 rd->thresh_mult[THR_D63_PRED] += 2500; | 610 rd->thresh_mult[THR_D63_PRED] += 2500; |
606 } | 611 } |
607 | 612 |
608 void vp9_set_rd_speed_thresholds_sub8x8(VP9_COMP *cpi) { | 613 void vp9_set_rd_speed_thresholds_sub8x8(VP9_COMP *cpi) { |
609 static const int thresh_mult[2][MAX_REFS] = | 614 static const int thresh_mult[2][MAX_REFS] = |
610 {{2500, 2500, 2500, 4500, 4500, 2500}, | 615 {{2500, 2500, 2500, 4500, 4500, 2500}, |
611 {2000, 2000, 2000, 4000, 4000, 2000}}; | 616 {2000, 2000, 2000, 4000, 4000, 2000}}; |
612 RD_OPT *const rd = &cpi->rd; | 617 RD_OPT *const rd = &cpi->rd; |
613 const int idx = cpi->oxcf.mode == BEST; | 618 const int idx = cpi->oxcf.mode == BEST; |
614 vpx_memcpy(rd->thresh_mult_sub8x8, thresh_mult[idx], | 619 memcpy(rd->thresh_mult_sub8x8, thresh_mult[idx], sizeof(thresh_mult[idx])); |
615 sizeof(thresh_mult[idx])); | |
616 } | 620 } |
617 | 621 |
618 void vp9_update_rd_thresh_fact(int (*factor_buf)[MAX_MODES], int rd_thresh, | 622 void vp9_update_rd_thresh_fact(int (*factor_buf)[MAX_MODES], int rd_thresh, |
619 int bsize, int best_mode_index) { | 623 int bsize, int best_mode_index) { |
620 if (rd_thresh > 0) { | 624 if (rd_thresh > 0) { |
621 const int top_mode = bsize < BLOCK_8X8 ? MAX_REFS : MAX_MODES; | 625 const int top_mode = bsize < BLOCK_8X8 ? MAX_REFS : MAX_MODES; |
622 int mode; | 626 int mode; |
623 for (mode = 0; mode < top_mode; ++mode) { | 627 for (mode = 0; mode < top_mode; ++mode) { |
624 const BLOCK_SIZE min_size = MAX(bsize - 1, BLOCK_4X4); | 628 const BLOCK_SIZE min_size = MAX(bsize - 1, BLOCK_4X4); |
625 const BLOCK_SIZE max_size = MIN(bsize + 2, BLOCK_64X64); | 629 const BLOCK_SIZE max_size = MIN(bsize + 2, BLOCK_64X64); |
(...skipping 24 matching lines...) Expand all Loading... |
650 return ROUND_POWER_OF_TWO(5 * q, 2); | 654 return ROUND_POWER_OF_TWO(5 * q, 2); |
651 default: | 655 default: |
652 assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12"); | 656 assert(0 && "bit_depth should be VPX_BITS_8, VPX_BITS_10 or VPX_BITS_12"); |
653 return -1; | 657 return -1; |
654 } | 658 } |
655 #else | 659 #else |
656 return 20 * q; | 660 return 20 * q; |
657 #endif // CONFIG_VP9_HIGHBITDEPTH | 661 #endif // CONFIG_VP9_HIGHBITDEPTH |
658 } | 662 } |
659 | 663 |
OLD | NEW |