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 |
11 #include <assert.h> | 11 #include <assert.h> |
12 #include <limits.h> | 12 #include <limits.h> |
13 #include <math.h> | 13 #include <math.h> |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 | 15 |
16 #include "./vp9_rtcd.h" | 16 #include "./vp9_rtcd.h" |
17 | 17 |
18 #include "vpx_mem/vpx_mem.h" | 18 #include "vpx_mem/vpx_mem.h" |
19 | 19 |
20 #include "vp9/common/vp9_common.h" | 20 #include "vp9/common/vp9_common.h" |
21 #include "vp9/common/vp9_mvref_common.h" | 21 #include "vp9/common/vp9_mvref_common.h" |
22 #include "vp9/common/vp9_reconinter.h" | 22 #include "vp9/common/vp9_reconinter.h" |
23 #include "vp9/common/vp9_reconintra.h" | 23 #include "vp9/common/vp9_reconintra.h" |
24 | 24 |
25 #include "vp9/encoder/vp9_encoder.h" | 25 #include "vp9/encoder/vp9_encoder.h" |
26 #include "vp9/encoder/vp9_ratectrl.h" | 26 #include "vp9/encoder/vp9_ratectrl.h" |
27 #include "vp9/encoder/vp9_rdopt.h" | 27 #include "vp9/encoder/vp9_rdopt.h" |
28 | 28 |
29 static void full_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x, | 29 static void full_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x, |
30 const TileInfo *const tile, | |
31 BLOCK_SIZE bsize, int mi_row, int mi_col, | 30 BLOCK_SIZE bsize, int mi_row, int mi_col, |
32 int_mv *tmp_mv, int *rate_mv) { | 31 int_mv *tmp_mv, int *rate_mv) { |
33 MACROBLOCKD *xd = &x->e_mbd; | 32 MACROBLOCKD *xd = &x->e_mbd; |
34 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; | 33 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; |
35 struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0}}; | 34 struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0}}; |
36 int step_param; | 35 int step_param; |
37 int sadpb = x->sadperbit16; | 36 int sadpb = x->sadperbit16; |
38 MV mvp_full; | 37 MV mvp_full; |
39 int ref = mbmi->ref_frame[0]; | 38 int ref = mbmi->ref_frame[0]; |
40 const MV ref_mv = mbmi->ref_mvs[ref][0].as_mv; | 39 const MV ref_mv = mbmi->ref_mvs[ref][0].as_mv; |
41 int i; | 40 int i; |
42 | 41 |
43 int tmp_col_min = x->mv_col_min; | 42 int tmp_col_min = x->mv_col_min; |
44 int tmp_col_max = x->mv_col_max; | 43 int tmp_col_max = x->mv_col_max; |
45 int tmp_row_min = x->mv_row_min; | 44 int tmp_row_min = x->mv_row_min; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 99 } |
101 | 100 |
102 // calculate the bit cost on motion vector | 101 // calculate the bit cost on motion vector |
103 mvp_full.row = tmp_mv->as_mv.row * 8; | 102 mvp_full.row = tmp_mv->as_mv.row * 8; |
104 mvp_full.col = tmp_mv->as_mv.col * 8; | 103 mvp_full.col = tmp_mv->as_mv.col * 8; |
105 *rate_mv = vp9_mv_bit_cost(&mvp_full, &ref_mv, | 104 *rate_mv = vp9_mv_bit_cost(&mvp_full, &ref_mv, |
106 x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); | 105 x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); |
107 } | 106 } |
108 | 107 |
109 static void sub_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x, | 108 static void sub_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x, |
110 const TileInfo *const tile, | |
111 BLOCK_SIZE bsize, int mi_row, int mi_col, | 109 BLOCK_SIZE bsize, int mi_row, int mi_col, |
112 MV *tmp_mv) { | 110 MV *tmp_mv) { |
113 MACROBLOCKD *xd = &x->e_mbd; | 111 MACROBLOCKD *xd = &x->e_mbd; |
114 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; | 112 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; |
115 struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0}}; | 113 struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0}}; |
116 int ref = mbmi->ref_frame[0]; | 114 int ref = mbmi->ref_frame[0]; |
117 MV ref_mv = mbmi->ref_mvs[ref][0].as_mv; | 115 MV ref_mv = mbmi->ref_mvs[ref][0].as_mv; |
118 int dis; | 116 int dis; |
119 | 117 |
120 const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi, | 118 const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi, |
121 ref); | 119 ref); |
122 if (scaled_ref_frame) { | 120 if (scaled_ref_frame) { |
123 int i; | 121 int i; |
124 // Swap out the reference frame for a version that's been scaled to | 122 // Swap out the reference frame for a version that's been scaled to |
125 // match the resolution of the current frame, allowing the existing | 123 // match the resolution of the current frame, allowing the existing |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 if (best_rd < ((int64_t)rd_threshes[mode_idx[this_mode]] * | 281 if (best_rd < ((int64_t)rd_threshes[mode_idx[this_mode]] * |
284 rd_thresh_freq_fact[this_mode] >> 5) || | 282 rd_thresh_freq_fact[this_mode] >> 5) || |
285 rd_threshes[mode_idx[this_mode]] == INT_MAX) | 283 rd_threshes[mode_idx[this_mode]] == INT_MAX) |
286 continue; | 284 continue; |
287 | 285 |
288 if (this_mode == NEWMV) { | 286 if (this_mode == NEWMV) { |
289 int rate_mode = 0; | 287 int rate_mode = 0; |
290 if (this_rd < (int64_t)(1 << num_pels_log2_lookup[bsize])) | 288 if (this_rd < (int64_t)(1 << num_pels_log2_lookup[bsize])) |
291 continue; | 289 continue; |
292 | 290 |
293 full_pixel_motion_search(cpi, x, tile, bsize, mi_row, mi_col, | 291 full_pixel_motion_search(cpi, x, bsize, mi_row, mi_col, |
294 &frame_mv[NEWMV][ref_frame], &rate_mv); | 292 &frame_mv[NEWMV][ref_frame], &rate_mv); |
295 | 293 |
296 if (frame_mv[NEWMV][ref_frame].as_int == INVALID_MV) | 294 if (frame_mv[NEWMV][ref_frame].as_int == INVALID_MV) |
297 continue; | 295 continue; |
298 | 296 |
299 rate_mode = cpi->inter_mode_cost[mbmi->mode_context[ref_frame]] | 297 rate_mode = cpi->inter_mode_cost[mbmi->mode_context[ref_frame]] |
300 [INTER_OFFSET(this_mode)]; | 298 [INTER_OFFSET(this_mode)]; |
301 if (RDCOST(x->rdmult, x->rddiv, rate_mv + rate_mode, 0) > best_rd) | 299 if (RDCOST(x->rdmult, x->rddiv, rate_mv + rate_mode, 0) > best_rd) |
302 continue; | 300 continue; |
303 | 301 |
304 sub_pixel_motion_search(cpi, x, tile, bsize, mi_row, mi_col, | 302 sub_pixel_motion_search(cpi, x, bsize, mi_row, mi_col, |
305 &frame_mv[NEWMV][ref_frame].as_mv); | 303 &frame_mv[NEWMV][ref_frame].as_mv); |
306 } | 304 } |
307 | 305 |
308 if (this_mode != NEARESTMV) | 306 if (this_mode != NEARESTMV) |
309 if (frame_mv[this_mode][ref_frame].as_int == | 307 if (frame_mv[this_mode][ref_frame].as_int == |
310 frame_mv[NEARESTMV][ref_frame].as_int) | 308 frame_mv[NEARESTMV][ref_frame].as_int) |
311 continue; | 309 continue; |
312 | 310 |
313 mbmi->mode = this_mode; | 311 mbmi->mode = this_mode; |
314 mbmi->mv[0].as_int = frame_mv[this_mode][ref_frame].as_int; | 312 mbmi->mv[0].as_int = frame_mv[this_mode][ref_frame].as_int; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 mbmi->mode = this_mode; | 411 mbmi->mode = this_mode; |
414 mbmi->ref_frame[0] = INTRA_FRAME; | 412 mbmi->ref_frame[0] = INTRA_FRAME; |
415 mbmi->uv_mode = this_mode; | 413 mbmi->uv_mode = this_mode; |
416 mbmi->mv[0].as_int = INVALID_MV; | 414 mbmi->mv[0].as_int = INVALID_MV; |
417 } | 415 } |
418 } | 416 } |
419 } | 417 } |
420 | 418 |
421 return INT64_MAX; | 419 return INT64_MAX; |
422 } | 420 } |
OLD | NEW |