OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 #if CONFIG_VP9_HIGHBITDEPTH | 674 #if CONFIG_VP9_HIGHBITDEPTH |
675 DECLARE_ALIGNED_ARRAY(16, uint16_t, pred_buf_16, 3 * 64 * 64); | 675 DECLARE_ALIGNED_ARRAY(16, uint16_t, pred_buf_16, 3 * 64 * 64); |
676 #endif | 676 #endif |
677 struct buf_2d orig_dst = pd->dst; | 677 struct buf_2d orig_dst = pd->dst; |
678 PRED_BUFFER *best_pred = NULL; | 678 PRED_BUFFER *best_pred = NULL; |
679 PRED_BUFFER *this_mode_pred = NULL; | 679 PRED_BUFFER *this_mode_pred = NULL; |
680 const int pixels_in_block = bh * bw; | 680 const int pixels_in_block = bh * bw; |
681 int reuse_inter_pred = cpi->sf.reuse_inter_pred_sby && ctx->pred_pixel_ready; | 681 int reuse_inter_pred = cpi->sf.reuse_inter_pred_sby && ctx->pred_pixel_ready; |
682 int ref_frame_skip_mask = 0; | 682 int ref_frame_skip_mask = 0; |
683 int idx; | 683 int idx; |
| 684 int best_pred_sad = INT_MAX; |
684 | 685 |
685 if (reuse_inter_pred) { | 686 if (reuse_inter_pred) { |
686 int i; | 687 int i; |
687 for (i = 0; i < 3; i++) { | 688 for (i = 0; i < 3; i++) { |
688 #if CONFIG_VP9_HIGHBITDEPTH | 689 #if CONFIG_VP9_HIGHBITDEPTH |
689 if (cm->use_highbitdepth) | 690 if (cm->use_highbitdepth) |
690 tmp[i].data = CONVERT_TO_BYTEPTR(&pred_buf_16[pixels_in_block * i]); | 691 tmp[i].data = CONVERT_TO_BYTEPTR(&pred_buf_16[pixels_in_block * i]); |
691 else | 692 else |
692 tmp[i].data = &pred_buf[pixels_in_block * i]; | 693 tmp[i].data = &pred_buf[pixels_in_block * i]; |
693 #else | 694 #else |
(...skipping 22 matching lines...) Expand all Loading... |
716 vp9_rd_cost_reset(rd_cost); | 717 vp9_rd_cost_reset(rd_cost); |
717 mbmi->sb_type = bsize; | 718 mbmi->sb_type = bsize; |
718 mbmi->ref_frame[0] = NONE; | 719 mbmi->ref_frame[0] = NONE; |
719 mbmi->ref_frame[1] = NONE; | 720 mbmi->ref_frame[1] = NONE; |
720 mbmi->tx_size = MIN(max_txsize_lookup[bsize], | 721 mbmi->tx_size = MIN(max_txsize_lookup[bsize], |
721 tx_mode_to_biggest_tx_size[cm->tx_mode]); | 722 tx_mode_to_biggest_tx_size[cm->tx_mode]); |
722 | 723 |
723 #if CONFIG_VP9_TEMPORAL_DENOISING | 724 #if CONFIG_VP9_TEMPORAL_DENOISING |
724 vp9_denoiser_reset_frame_stats(ctx); | 725 vp9_denoiser_reset_frame_stats(ctx); |
725 #endif | 726 #endif |
| 727 |
726 if (cpi->rc.frames_since_golden == 0) { | 728 if (cpi->rc.frames_since_golden == 0) { |
727 ref_frame_skip_mask |= (1 << GOLDEN_FRAME); | 729 cpi->ref_frame_flags &= (~VP9_GOLD_FLAG); |
728 usable_ref_frame = LAST_FRAME; | 730 usable_ref_frame = LAST_FRAME; |
729 } else { | 731 } else { |
730 usable_ref_frame = GOLDEN_FRAME; | 732 usable_ref_frame = GOLDEN_FRAME; |
731 } | 733 } |
| 734 |
732 for (ref_frame = LAST_FRAME; ref_frame <= usable_ref_frame; ++ref_frame) { | 735 for (ref_frame = LAST_FRAME; ref_frame <= usable_ref_frame; ++ref_frame) { |
733 const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, ref_frame); | 736 const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, ref_frame); |
734 | 737 |
735 x->pred_mv_sad[ref_frame] = INT_MAX; | 738 x->pred_mv_sad[ref_frame] = INT_MAX; |
736 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV; | 739 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV; |
737 frame_mv[ZEROMV][ref_frame].as_int = 0; | 740 frame_mv[ZEROMV][ref_frame].as_int = 0; |
738 | 741 |
739 if ((cpi->ref_frame_flags & flag_list[ref_frame]) && (yv12 != NULL)) { | 742 if ((cpi->ref_frame_flags & flag_list[ref_frame]) && (yv12 != NULL)) { |
740 int_mv *const candidates = mbmi->ref_mvs[ref_frame]; | 743 int_mv *const candidates = mbmi->ref_mvs[ref_frame]; |
741 const struct scale_factors *const sf = &cm->frame_refs[ref_frame - 1].sf; | 744 const struct scale_factors *const sf = &cm->frame_refs[ref_frame - 1].sf; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 | 805 |
803 if (this_mode == NEWMV) { | 806 if (this_mode == NEWMV) { |
804 if (ref_frame > LAST_FRAME) { | 807 if (ref_frame > LAST_FRAME) { |
805 int tmp_sad; | 808 int tmp_sad; |
806 int dis, cost_list[5]; | 809 int dis, cost_list[5]; |
807 | 810 |
808 if (bsize < BLOCK_16X16) | 811 if (bsize < BLOCK_16X16) |
809 continue; | 812 continue; |
810 | 813 |
811 tmp_sad = vp9_int_pro_motion_estimation(cpi, x, bsize); | 814 tmp_sad = vp9_int_pro_motion_estimation(cpi, x, bsize); |
| 815 |
812 if (tmp_sad > x->pred_mv_sad[LAST_FRAME]) | 816 if (tmp_sad > x->pred_mv_sad[LAST_FRAME]) |
813 continue; | 817 continue; |
| 818 if (tmp_sad + (num_pels_log2_lookup[bsize] << 4) > best_pred_sad) |
| 819 continue; |
814 | 820 |
815 frame_mv[NEWMV][ref_frame].as_int = mbmi->mv[0].as_int; | 821 frame_mv[NEWMV][ref_frame].as_int = mbmi->mv[0].as_int; |
816 rate_mv = vp9_mv_bit_cost(&frame_mv[NEWMV][ref_frame].as_mv, | 822 rate_mv = vp9_mv_bit_cost(&frame_mv[NEWMV][ref_frame].as_mv, |
817 &mbmi->ref_mvs[ref_frame][0].as_mv, | 823 &mbmi->ref_mvs[ref_frame][0].as_mv, |
818 x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); | 824 x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); |
819 frame_mv[NEWMV][ref_frame].as_mv.row >>= 3; | 825 frame_mv[NEWMV][ref_frame].as_mv.row >>= 3; |
820 frame_mv[NEWMV][ref_frame].as_mv.col >>= 3; | 826 frame_mv[NEWMV][ref_frame].as_mv.col >>= 3; |
821 | 827 |
822 cpi->find_fractional_mv_step(x, &frame_mv[NEWMV][ref_frame].as_mv, | 828 cpi->find_fractional_mv_step(x, &frame_mv[NEWMV][ref_frame].as_mv, |
823 &mbmi->ref_mvs[ref_frame][0].as_mv, | 829 &mbmi->ref_mvs[ref_frame][0].as_mv, |
824 cpi->common.allow_high_precision_mv, | 830 cpi->common.allow_high_precision_mv, |
825 x->errorperbit, | 831 x->errorperbit, |
826 &cpi->fn_ptr[bsize], | 832 &cpi->fn_ptr[bsize], |
827 cpi->sf.mv.subpel_force_stop, | 833 cpi->sf.mv.subpel_force_stop, |
828 cpi->sf.mv.subpel_iters_per_step, | 834 cpi->sf.mv.subpel_iters_per_step, |
829 cond_cost_list(cpi, cost_list), | 835 cond_cost_list(cpi, cost_list), |
830 x->nmvjointcost, x->mvcost, &dis, | 836 x->nmvjointcost, x->mvcost, &dis, |
831 &x->pred_sse[ref_frame], NULL, 0, 0); | 837 &x->pred_sse[ref_frame], NULL, 0, 0); |
832 } else if (!combined_motion_search(cpi, x, bsize, mi_row, mi_col, | 838 } else if (!combined_motion_search(cpi, x, bsize, mi_row, mi_col, |
833 &frame_mv[NEWMV][ref_frame], &rate_mv, best_rdc.rdcost)) { | 839 &frame_mv[NEWMV][ref_frame], &rate_mv, best_rdc.rdcost)) { |
834 continue; | 840 continue; |
835 } | 841 } |
836 } | 842 } |
837 | 843 |
| 844 if (this_mode == NEWMV && ref_frame == LAST_FRAME && |
| 845 frame_mv[NEWMV][LAST_FRAME].as_int != INVALID_MV) { |
| 846 const int pre_stride = xd->plane[0].pre[0].stride; |
| 847 const uint8_t * const pre_buf = xd->plane[0].pre[0].buf + |
| 848 (frame_mv[NEWMV][LAST_FRAME].as_mv.row >> 3) * pre_stride + |
| 849 (frame_mv[NEWMV][LAST_FRAME].as_mv.col >> 3); |
| 850 best_pred_sad = cpi->fn_ptr[bsize].sdf(x->plane[0].src.buf, |
| 851 x->plane[0].src.stride, |
| 852 pre_buf, pre_stride); |
| 853 } |
| 854 |
838 if (this_mode != NEARESTMV && | 855 if (this_mode != NEARESTMV && |
839 frame_mv[this_mode][ref_frame].as_int == | 856 frame_mv[this_mode][ref_frame].as_int == |
840 frame_mv[NEARESTMV][ref_frame].as_int) | 857 frame_mv[NEARESTMV][ref_frame].as_int) |
841 continue; | 858 continue; |
842 | 859 |
843 mbmi->mode = this_mode; | 860 mbmi->mode = this_mode; |
844 mbmi->mv[0].as_int = frame_mv[this_mode][ref_frame].as_int; | 861 mbmi->mv[0].as_int = frame_mv[this_mode][ref_frame].as_int; |
845 | 862 |
846 // Search for the best prediction filter type, when the resulting | 863 // Search for the best prediction filter type, when the resulting |
847 // motion vector is at sub-pixel accuracy level for luma component, i.e., | 864 // motion vector is at sub-pixel accuracy level for luma component, i.e., |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 xd->mi[0].bmi[block + 2] = bsi[best_ref_frame][block]; | 1373 xd->mi[0].bmi[block + 2] = bsi[best_ref_frame][block]; |
1357 } | 1374 } |
1358 } | 1375 } |
1359 mbmi->mode = xd->mi[0].bmi[3].as_mode; | 1376 mbmi->mode = xd->mi[0].bmi[3].as_mode; |
1360 ctx->mic = *(xd->mi[0].src_mi); | 1377 ctx->mic = *(xd->mi[0].src_mi); |
1361 ctx->skip_txfm[0] = 0; | 1378 ctx->skip_txfm[0] = 0; |
1362 ctx->skip = 0; | 1379 ctx->skip = 0; |
1363 // Dummy assignment for speed -5. No effect in speed -6. | 1380 // Dummy assignment for speed -5. No effect in speed -6. |
1364 rd_cost->rdcost = best_rd; | 1381 rd_cost->rdcost = best_rd; |
1365 } | 1382 } |
OLD | NEW |