| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 3 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license | 5 * Use of this source code is governed by a BSD-style license |
| 6 * that can be found in the LICENSE file in the root of the source | 6 * that can be found in the LICENSE file in the root of the source |
| 7 * tree. An additional intellectual property rights grant can be found | 7 * tree. An additional intellectual property rights grant can be found |
| 8 * in the file PATENTS. All contributing project authors may | 8 * in the file PATENTS. All contributing project authors may |
| 9 * be found in the AUTHORS file in the root of the source tree. | 9 * be found in the AUTHORS file in the root of the source tree. |
| 10 */ | 10 */ |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 int mi_col, int mi_row, int mi_rows, | 179 int mi_col, int mi_row, int mi_rows, |
| 180 const POSITION *mi_pos) { | 180 const POSITION *mi_pos) { |
| 181 return !(mi_row + mi_pos->row < 0 || | 181 return !(mi_row + mi_pos->row < 0 || |
| 182 mi_col + mi_pos->col < tile->mi_col_start || | 182 mi_col + mi_pos->col < tile->mi_col_start || |
| 183 mi_row + mi_pos->row >= mi_rows || | 183 mi_row + mi_pos->row >= mi_rows || |
| 184 mi_col + mi_pos->col >= tile->mi_col_end); | 184 mi_col + mi_pos->col >= tile->mi_col_end); |
| 185 } | 185 } |
| 186 | 186 |
| 187 // This function searches the neighbourhood of a given MB/SB | 187 // This function searches the neighbourhood of a given MB/SB |
| 188 // to try and find candidate reference vectors. | 188 // to try and find candidate reference vectors. |
| 189 void vp9_find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd, | 189 static void find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd, |
| 190 const TileInfo *const tile, | 190 const TileInfo *const tile, |
| 191 MODE_INFO *mi, const MODE_INFO *prev_mi, | 191 MODE_INFO *mi, const MODE_INFO *prev_mi, |
| 192 MV_REFERENCE_FRAME ref_frame, | 192 MV_REFERENCE_FRAME ref_frame, |
| 193 int_mv *mv_ref_list, | 193 int_mv *mv_ref_list, |
| 194 int block_idx, | 194 int block_idx, int mi_row, int mi_col) { |
| 195 int mi_row, int mi_col) { | |
| 196 const int *ref_sign_bias = cm->ref_frame_sign_bias; | 195 const int *ref_sign_bias = cm->ref_frame_sign_bias; |
| 197 int i, refmv_count = 0; | 196 int i, refmv_count = 0; |
| 198 const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type]; | 197 const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type]; |
| 199 const MB_MODE_INFO *const prev_mbmi = prev_mi ? &prev_mi->mbmi : NULL; | 198 const MB_MODE_INFO *const prev_mbmi = cm->coding_use_prev_mi && prev_mi ? |
| 199 &prev_mi->mbmi : NULL; |
| 200 int different_ref_found = 0; | 200 int different_ref_found = 0; |
| 201 int context_counter = 0; | 201 int context_counter = 0; |
| 202 | 202 |
| 203 // Blank the reference vector list | 203 // Blank the reference vector list |
| 204 vpx_memset(mv_ref_list, 0, sizeof(*mv_ref_list) * MAX_MV_REF_CANDIDATES); | 204 vpx_memset(mv_ref_list, 0, sizeof(*mv_ref_list) * MAX_MV_REF_CANDIDATES); |
| 205 | 205 |
| 206 // The nearest 2 blocks are treated differently | 206 // The nearest 2 blocks are treated differently |
| 207 // if the size < 8x8 we get the mv from the bmi substructure, | 207 // if the size < 8x8 we get the mv from the bmi substructure, |
| 208 // and we also need to keep a mode count. | 208 // and we also need to keep a mode count. |
| 209 for (i = 0; i < 2; ++i) { | 209 for (i = 0; i < 2; ++i) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 283 |
| 284 Done: | 284 Done: |
| 285 | 285 |
| 286 mi->mbmi.mode_context[ref_frame] = counter_to_context[context_counter]; | 286 mi->mbmi.mode_context[ref_frame] = counter_to_context[context_counter]; |
| 287 | 287 |
| 288 // Clamp vectors | 288 // Clamp vectors |
| 289 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) | 289 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) |
| 290 clamp_mv_ref(&mv_ref_list[i].as_mv, xd); | 290 clamp_mv_ref(&mv_ref_list[i].as_mv, xd); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void vp9_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd, |
| 294 const TileInfo *const tile, |
| 295 MODE_INFO *mi, const MODE_INFO *prev_mi, |
| 296 MV_REFERENCE_FRAME ref_frame, |
| 297 int_mv *mv_ref_list, |
| 298 int mi_row, int mi_col) { |
| 299 find_mv_refs_idx(cm, xd, tile, mi, prev_mi, ref_frame, mv_ref_list, -1, |
| 300 mi_row, mi_col); |
| 301 } |
| 302 |
| 293 static void lower_mv_precision(MV *mv, int allow_hp) { | 303 static void lower_mv_precision(MV *mv, int allow_hp) { |
| 294 const int use_hp = allow_hp && vp9_use_mv_hp(mv); | 304 const int use_hp = allow_hp && vp9_use_mv_hp(mv); |
| 295 if (!use_hp) { | 305 if (!use_hp) { |
| 296 if (mv->row & 1) | 306 if (mv->row & 1) |
| 297 mv->row += (mv->row > 0 ? -1 : 1); | 307 mv->row += (mv->row > 0 ? -1 : 1); |
| 298 if (mv->col & 1) | 308 if (mv->col & 1) |
| 299 mv->col += (mv->col > 0 ? -1 : 1); | 309 mv->col += (mv->col > 0 ? -1 : 1); |
| 300 } | 310 } |
| 301 } | 311 } |
| 302 | 312 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 317 const TileInfo *const tile, | 327 const TileInfo *const tile, |
| 318 int block, int ref, int mi_row, int mi_col, | 328 int block, int ref, int mi_row, int mi_col, |
| 319 int_mv *nearest, int_mv *near) { | 329 int_mv *nearest, int_mv *near) { |
| 320 int_mv mv_list[MAX_MV_REF_CANDIDATES]; | 330 int_mv mv_list[MAX_MV_REF_CANDIDATES]; |
| 321 MODE_INFO *const mi = xd->mi_8x8[0]; | 331 MODE_INFO *const mi = xd->mi_8x8[0]; |
| 322 b_mode_info *bmi = mi->bmi; | 332 b_mode_info *bmi = mi->bmi; |
| 323 int n; | 333 int n; |
| 324 | 334 |
| 325 assert(MAX_MV_REF_CANDIDATES == 2); | 335 assert(MAX_MV_REF_CANDIDATES == 2); |
| 326 | 336 |
| 327 vp9_find_mv_refs_idx(cm, xd, tile, mi, xd->last_mi, mi->mbmi.ref_frame[ref], | 337 find_mv_refs_idx(cm, xd, tile, mi, xd->last_mi, mi->mbmi.ref_frame[ref], |
| 328 mv_list, block, mi_row, mi_col); | 338 mv_list, block, mi_row, mi_col); |
| 329 | 339 |
| 330 near->as_int = 0; | 340 near->as_int = 0; |
| 331 switch (block) { | 341 switch (block) { |
| 332 case 0: | 342 case 0: |
| 333 nearest->as_int = mv_list[0].as_int; | 343 nearest->as_int = mv_list[0].as_int; |
| 334 near->as_int = mv_list[1].as_int; | 344 near->as_int = mv_list[1].as_int; |
| 335 break; | 345 break; |
| 336 case 1: | 346 case 1: |
| 337 case 2: | 347 case 2: |
| 338 nearest->as_int = bmi[0].as_mv[ref].as_int; | 348 nearest->as_int = bmi[0].as_mv[ref].as_int; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 354 if (nearest->as_int != candidates[n].as_int) { | 364 if (nearest->as_int != candidates[n].as_int) { |
| 355 near->as_int = candidates[n].as_int; | 365 near->as_int = candidates[n].as_int; |
| 356 break; | 366 break; |
| 357 } | 367 } |
| 358 break; | 368 break; |
| 359 } | 369 } |
| 360 default: | 370 default: |
| 361 assert("Invalid block index."); | 371 assert("Invalid block index."); |
| 362 } | 372 } |
| 363 } | 373 } |
| OLD | NEW |