| @@ -842,20 +842,16 @@ static void accumulate_fp_mb_row_stat(TileDataEnc *this_tile, · 841 unmodified lines |
| 842 | #if CONFIG_RATE_CTRL | 842 | #if CONFIG_RATE_CTRL |
| 843 | static void store_fp_motion_vector(VP9_COMP *cpi, const MV *mv, | 843 | static void store_fp_motion_vector(VP9_COMP *cpi, const MV *mv, |
| 844 | const int mb_row, const int mb_col, | 844 | const int mb_row, const int mb_col, |
| 845 | const int is_second_mv) { | 845 | MV_REFERENCE_FRAME frame_type, |
| | 846 | const int mv_idx) { |
| 846 | VP9_COMMON *const cm = &cpi->common; | 847 | VP9_COMMON *const cm = &cpi->common; |
| 847 | const int mb_index = mb_row * cm->mb_cols + mb_col; | 848 | const int mb_index = mb_row * cm->mb_cols + mb_col; |
| 848 | MOTION_VECTOR_INFO *this_motion_vector_info = | 849 | MOTION_VECTOR_INFO *this_motion_vector_info = |
| 849 | &cpi->fp_motion_vector_info[mb_index]; | 850 | &cpi->fp_motion_vector_info[mb_index]; |
| 850 | if (!is_second_mv) { | 851 | this_motion_vector_info->ref_frame[mv_idx] = frame_type; |
| 851 | this_motion_vector_info->ref_frame[0] = LAST_FRAME; | 852 | if (frame_type != INTRA_FRAME) { |
| 852 | this_motion_vector_info->mv[0].as_mv.row = mv->row; | 853 | this_motion_vector_info->mv[mv_idx].as_mv = *mv; |
| 853 | this_motion_vector_info->mv[0].as_mv.col = mv->col; | | |
| 854 | return; | | |
| 855 | } | 854 | } |
| 856 | this_motion_vector_info->ref_frame[1] = GOLDEN_FRAME; | | |
| 857 | this_motion_vector_info->mv[1].as_mv.row = mv->row; | | |
| 858 | this_motion_vector_info->mv[1].as_mv.col = mv->col; | | |
| 859 | } | 855 | } |
| 860 | #endif // CONFIG_RATE_CTRL | 856 | #endif // CONFIG_RATE_CTRL |
| 861 | | 857 | |
| @@ -1093,6 +1089,11 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td, · 231 unmodified lines |
| 1093 | struct buf_2d unscaled_last_source_buf_2d; | 1089 | struct buf_2d unscaled_last_source_buf_2d; |
| 1094 | vp9_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[bsize]; | 1090 | vp9_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[bsize]; |
| 1095 | | 1091 | |
| | 1092 | #if CONFIG_RATE_CTRL |
| | 1093 | // Store zero mv as default |
| | 1094 | store_fp_motion_vector(cpi, &mv, mb_row, mb_col, LAST_FRAME, 0); |
| | 1095 | #endif // CONFIG_RAGE_CTRL |
| | 1096 | |
| 1096 | xd->plane[0].pre[0].buf = first_ref_buf->y_buffer + recon_yoffset; | 1097 | xd->plane[0].pre[0].buf = first_ref_buf->y_buffer + recon_yoffset; |
| 1097 | #if CONFIG_VP9_HIGHBITDEPTH | 1098 | #if CONFIG_VP9_HIGHBITDEPTH |
| 1098 | if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { | 1099 | if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
| @@ -1158,7 +1159,7 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td, · 59 unmodified lines |
| 1158 | } | 1159 | } |
| 1159 | } | 1160 | } |
| 1160 | #if CONFIG_RATE_CTRL | 1161 | #if CONFIG_RATE_CTRL |
| 1161 | store_fp_motion_vector(cpi, &mv, mb_row, mb_col, /*is_second_mv=*/0); | 1162 | store_fp_motion_vector(cpi, &mv, mb_row, mb_col, LAST_FRAME, 0); |
| 1162 | #endif // CONFIG_RAGE_CTRL | 1163 | #endif // CONFIG_RAGE_CTRL |
| 1163 | | 1164 | |
| 1164 | // Search in an older reference frame. | 1165 | // Search in an older reference frame. |
| @@ -1182,8 +1183,7 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td, · 17 unmodified lines |
| 1182 | | 1183 | |
| 1183 | first_pass_motion_search(cpi, x, &zero_mv, &tmp_mv, &gf_motion_error); | 1184 | first_pass_motion_search(cpi, x, &zero_mv, &tmp_mv, &gf_motion_error); |
| 1184 | #if CONFIG_RATE_CTRL | 1185 | #if CONFIG_RATE_CTRL |
| 1185 | store_fp_motion_vector(cpi, &tmp_mv, mb_row, mb_col, | 1186 | store_fp_motion_vector(cpi, &tmp_mv, mb_row, mb_col, GOLDEN_FRAME, 1); |
| 1186 | /*is_second_mv=*/1); | | |
| 1187 | #endif // CONFIG_RAGE_CTRL | 1187 | #endif // CONFIG_RAGE_CTRL |
| 1188 | | 1188 | |
| 1189 | if (gf_motion_error < motion_error && gf_motion_error < this_error) | 1189 | if (gf_motion_error < motion_error && gf_motion_error < this_error) |
| @@ -1358,6 +1358,9 @@ void vp9_first_pass_encode_tile_mb_row(VP9_COMP *cpi, ThreadData *td, · 168 unmodified lines |
| 1358 | } | 1358 | } |
| 1359 | } else { | 1359 | } else { |
| 1360 | fp_acc_data->sr_coded_error += (int64_t)this_error; | 1360 | fp_acc_data->sr_coded_error += (int64_t)this_error; |
| | 1361 | #if CONFIG_RATE_CTRL |
| | 1362 | store_fp_motion_vector(cpi, NULL, mb_row, mb_col, INTRA_FRAME, 0); |
| | 1363 | #endif // CONFIG_RAGE_CTRL |
| 1361 | } | 1364 | } |
| 1362 | fp_acc_data->coded_error += (int64_t)this_error; | 1365 | fp_acc_data->coded_error += (int64_t)this_error; |
| 1363 | | 1366 | |
| @@ -1384,6 +1387,10 @@ static void first_pass_encode(VP9_COMP *cpi, FIRSTPASS_DATA *fp_acc_data) { · 20 unmodified lines |
| 1384 | // Tiling is ignored in the first pass. | 1387 | // Tiling is ignored in the first pass. |
| 1385 | vp9_tile_init(tile, cm, 0, 0); | 1388 | vp9_tile_init(tile, cm, 0, 0); |
| 1386 | | 1389 | |
| | 1390 | #if CONFIG_RATE_CTRL |
| | 1391 | fp_motion_vector_info_init(cpi); |
| | 1392 | #endif |
| | 1393 | |
| 1387 | for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) { | 1394 | for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) { |
| 1388 | best_ref_mv = zero_mv; | 1395 | best_ref_mv = zero_mv; |
| 1389 | vp9_first_pass_encode_tile_mb_row(cpi, &cpi->td, fp_acc_data, &tile_data, | 1396 | vp9_first_pass_encode_tile_mb_row(cpi, &cpi->td, fp_acc_data, &tile_data, |