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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 #ifdef SPEEDSTATS | 34 #ifdef SPEEDSTATS |
35 extern unsigned int cnt_pm; | 35 extern unsigned int cnt_pm; |
36 #endif | 36 #endif |
37 | 37 |
38 extern const int vp8_ref_frame_order[MAX_MODES]; | 38 extern const int vp8_ref_frame_order[MAX_MODES]; |
39 extern const MB_PREDICTION_MODE vp8_mode_order[MAX_MODES]; | 39 extern const MB_PREDICTION_MODE vp8_mode_order[MAX_MODES]; |
40 | 40 |
41 extern int vp8_cost_mv_ref(MB_PREDICTION_MODE m, const int near_mv_ref_ct[4]); | 41 extern int vp8_cost_mv_ref(MB_PREDICTION_MODE m, const int near_mv_ref_ct[4]); |
42 | 42 |
43 | |
44 int vp8_skip_fractional_mv_step(MACROBLOCK *mb, BLOCK *b, BLOCKD *d, | 43 int vp8_skip_fractional_mv_step(MACROBLOCK *mb, BLOCK *b, BLOCKD *d, |
45 int_mv *bestmv, int_mv *ref_mv, | 44 int_mv *bestmv, int_mv *ref_mv, |
46 int error_per_bit, | 45 int error_per_bit, |
47 const vp8_variance_fn_ptr_t *vfp, | 46 const vp8_variance_fn_ptr_t *vfp, |
48 int *mvcost[2], int *distortion, | 47 int *mvcost[2], int *distortion, |
49 unsigned int *sse) | 48 unsigned int *sse) |
50 { | 49 { |
51 (void) b; | 50 (void) b; |
52 (void) d; | 51 (void) d; |
53 (void) ref_mv; | 52 (void) ref_mv; |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 } | 498 } |
500 | 499 |
501 if((this_mode != NEWMV) || | 500 if((this_mode != NEWMV) || |
502 !(cpi->sf.half_pixel_search) || cpi->common.full_pixel==1) | 501 !(cpi->sf.half_pixel_search) || cpi->common.full_pixel==1) |
503 *distortion2 = vp8_get_inter_mbpred_error(x, | 502 *distortion2 = vp8_get_inter_mbpred_error(x, |
504 &cpi->fn_ptr[BLOCK_16X16], | 503 &cpi->fn_ptr[BLOCK_16X16], |
505 sse, mv); | 504 sse, mv); |
506 | 505 |
507 this_rd = RDCOST(x->rdmult, x->rddiv, rate2, *distortion2); | 506 this_rd = RDCOST(x->rdmult, x->rddiv, rate2, *distortion2); |
508 | 507 |
509 /* Adjust rd to bias to ZEROMV */ | 508 // Adjust rd for ZEROMV and LAST, if LAST is the closest reference frame. |
510 if(this_mode == ZEROMV) | 509 if (this_mode == ZEROMV && |
| 510 x->e_mbd.mode_info_context->mbmi.ref_frame == LAST_FRAME && |
| 511 cpi->closest_reference_frame == LAST_FRAME) |
511 { | 512 { |
512 /* Bias to ZEROMV on LAST_FRAME reference when it is available. */ | |
513 if ((cpi->ref_frame_flags & VP8_LAST_FRAME & | |
514 cpi->common.refresh_last_frame) | |
515 && x->e_mbd.mode_info_context->mbmi.ref_frame != LAST_FRAME) | |
516 rd_adj = 100; | |
517 | |
518 // rd_adj <= 100 | |
519 this_rd = ((int64_t)this_rd) * rd_adj / 100; | 513 this_rd = ((int64_t)this_rd) * rd_adj / 100; |
520 } | 514 } |
521 | 515 |
522 check_for_encode_breakout(*sse, x); | 516 check_for_encode_breakout(*sse, x); |
523 return this_rd; | 517 return this_rd; |
524 } | 518 } |
525 | 519 |
526 static void calculate_zeromv_rd_adjustment(VP8_COMP *cpi, MACROBLOCK *x, | 520 static void calculate_zeromv_rd_adjustment(VP8_COMP *cpi, MACROBLOCK *x, |
527 int *rd_adjustment) | 521 int *rd_adjustment) |
528 { | 522 { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 *returnintra = INT_MAX; | 681 *returnintra = INT_MAX; |
688 x->skip = 0; | 682 x->skip = 0; |
689 | 683 |
690 x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME; | 684 x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME; |
691 | 685 |
692 /* If the frame has big static background and current MB is in low | 686 /* If the frame has big static background and current MB is in low |
693 * motion area, its mode decision is biased to ZEROMV mode. | 687 * motion area, its mode decision is biased to ZEROMV mode. |
694 */ | 688 */ |
695 calculate_zeromv_rd_adjustment(cpi, x, &rd_adjustment); | 689 calculate_zeromv_rd_adjustment(cpi, x, &rd_adjustment); |
696 | 690 |
| 691 #if CONFIG_TEMPORAL_DENOISING |
| 692 if (cpi->oxcf.noise_sensitivity) { |
| 693 rd_adjustment = (int)(rd_adjustment * |
| 694 cpi->denoiser.denoise_pars.pickmode_mv_bias / 100); |
| 695 } |
| 696 #endif |
| 697 |
697 /* if we encode a new mv this is important | 698 /* if we encode a new mv this is important |
698 * find the best new motion vector | 699 * find the best new motion vector |
699 */ | 700 */ |
700 for (mode_index = 0; mode_index < MAX_MODES; mode_index++) | 701 for (mode_index = 0; mode_index < MAX_MODES; mode_index++) |
701 { | 702 { |
702 int frame_cost; | 703 int frame_cost; |
703 int this_rd = INT_MAX; | 704 int this_rd = INT_MAX; |
704 int this_ref_frame = ref_frame_map[vp8_ref_frame_order[mode_index]]; | 705 int this_ref_frame = ref_frame_map[vp8_ref_frame_order[mode_index]]; |
705 | 706 |
706 if (best_rd <= x->rd_threshes[mode_index]) | 707 if (best_rd <= x->rd_threshes[mode_index]) |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 { | 1162 { |
1162 this_rdbin = 1023; | 1163 this_rdbin = 1023; |
1163 } | 1164 } |
1164 | 1165 |
1165 x->error_bins[this_rdbin] ++; | 1166 x->error_bins[this_rdbin] ++; |
1166 } | 1167 } |
1167 | 1168 |
1168 #if CONFIG_TEMPORAL_DENOISING | 1169 #if CONFIG_TEMPORAL_DENOISING |
1169 if (cpi->oxcf.noise_sensitivity) | 1170 if (cpi->oxcf.noise_sensitivity) |
1170 { | 1171 { |
1171 int uv_denoise = (cpi->oxcf.noise_sensitivity == 2) ? 1 : 0; | |
1172 int block_index = mb_row * cpi->common.mb_cols + mb_col; | 1172 int block_index = mb_row * cpi->common.mb_cols + mb_col; |
1173 if (x->best_sse_inter_mode == DC_PRED) | 1173 if (x->best_sse_inter_mode == DC_PRED) |
1174 { | 1174 { |
1175 /* No best MV found. */ | 1175 /* No best MV found. */ |
1176 x->best_sse_inter_mode = best_mbmode.mode; | 1176 x->best_sse_inter_mode = best_mbmode.mode; |
1177 x->best_sse_mv = best_mbmode.mv; | 1177 x->best_sse_mv = best_mbmode.mv; |
1178 x->need_to_clamp_best_mvs = best_mbmode.need_to_clamp_mvs; | 1178 x->need_to_clamp_best_mvs = best_mbmode.need_to_clamp_mvs; |
1179 x->best_reference_frame = best_mbmode.ref_frame; | 1179 x->best_reference_frame = best_mbmode.ref_frame; |
1180 best_sse = best_rd_sse; | 1180 best_sse = best_rd_sse; |
1181 } | 1181 } |
1182 x->increase_denoising = 0; | 1182 x->increase_denoising = 0; |
1183 vp8_denoiser_denoise_mb(&cpi->denoiser, x, best_sse, zero_mv_sse, | 1183 vp8_denoiser_denoise_mb(&cpi->denoiser, x, best_sse, zero_mv_sse, |
1184 recon_yoffset, recon_uvoffset, | 1184 recon_yoffset, recon_uvoffset, |
1185 &cpi->common.lf_info, mb_row, mb_col, | 1185 &cpi->common.lf_info, mb_row, mb_col, |
1186 block_index, uv_denoise); | 1186 block_index); |
1187 | |
1188 | 1187 |
1189 /* Reevaluate ZEROMV after denoising. */ | 1188 /* Reevaluate ZEROMV after denoising. */ |
1190 if (best_mbmode.ref_frame == INTRA_FRAME && | 1189 if (best_mbmode.ref_frame == INTRA_FRAME && |
1191 x->best_zeromv_reference_frame != INTRA_FRAME) | 1190 x->best_zeromv_reference_frame != INTRA_FRAME) |
1192 { | 1191 { |
1193 int this_rd = 0; | 1192 int this_rd = 0; |
1194 int this_ref_frame = x->best_zeromv_reference_frame; | 1193 int this_ref_frame = x->best_zeromv_reference_frame; |
1195 rate2 = x->ref_frame_cost[this_ref_frame] + | 1194 rate2 = x->ref_frame_cost[this_ref_frame] + |
1196 vp8_cost_mv_ref(ZEROMV, mdcounts); | 1195 vp8_cost_mv_ref(ZEROMV, mdcounts); |
1197 distortion2 = 0; | 1196 distortion2 = 0; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 error4x4 = pick_intra4x4mby_modes(x, &rate, | 1292 error4x4 = pick_intra4x4mby_modes(x, &rate, |
1294 &best_sse); | 1293 &best_sse); |
1295 if (error4x4 < error16x16) | 1294 if (error4x4 < error16x16) |
1296 { | 1295 { |
1297 xd->mode_info_context->mbmi.mode = B_PRED; | 1296 xd->mode_info_context->mbmi.mode = B_PRED; |
1298 best_rate = rate; | 1297 best_rate = rate; |
1299 } | 1298 } |
1300 | 1299 |
1301 *rate_ = best_rate; | 1300 *rate_ = best_rate; |
1302 } | 1301 } |
OLD | NEW |