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 10 matching lines...) Expand all Loading... |
21 find_mv_refs_sync sync, void *const data) { | 21 find_mv_refs_sync sync, void *const data) { |
22 const int *ref_sign_bias = cm->ref_frame_sign_bias; | 22 const int *ref_sign_bias = cm->ref_frame_sign_bias; |
23 int i, refmv_count = 0; | 23 int i, refmv_count = 0; |
24 const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type]; | 24 const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type]; |
25 int different_ref_found = 0; | 25 int different_ref_found = 0; |
26 int context_counter = 0; | 26 int context_counter = 0; |
27 const MV_REF *const prev_frame_mvs = cm->use_prev_frame_mvs ? | 27 const MV_REF *const prev_frame_mvs = cm->use_prev_frame_mvs ? |
28 cm->prev_frame->mvs + mi_row * cm->mi_cols + mi_col : NULL; | 28 cm->prev_frame->mvs + mi_row * cm->mi_cols + mi_col : NULL; |
29 | 29 |
30 // Blank the reference vector list | 30 // Blank the reference vector list |
31 vpx_memset(mv_ref_list, 0, sizeof(*mv_ref_list) * MAX_MV_REF_CANDIDATES); | 31 memset(mv_ref_list, 0, sizeof(*mv_ref_list) * MAX_MV_REF_CANDIDATES); |
32 | 32 |
33 // The nearest 2 blocks are treated differently | 33 // The nearest 2 blocks are treated differently |
34 // if the size < 8x8 we get the mv from the bmi substructure, | 34 // if the size < 8x8 we get the mv from the bmi substructure, |
35 // and we also need to keep a mode count. | 35 // and we also need to keep a mode count. |
36 for (i = 0; i < 2; ++i) { | 36 for (i = 0; i < 2; ++i) { |
37 const POSITION *const mv_ref = &mv_ref_search[i]; | 37 const POSITION *const mv_ref = &mv_ref_search[i]; |
38 if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { | 38 if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { |
39 const MODE_INFO *const candidate_mi = xd->mi[mv_ref->col + mv_ref->row * | 39 const MODE_INFO *const candidate_mi = xd->mi[mv_ref->col + mv_ref->row * |
40 xd->mi_stride].src_mi; | 40 xd->mi_stride]; |
41 const MB_MODE_INFO *const candidate = &candidate_mi->mbmi; | 41 const MB_MODE_INFO *const candidate = &candidate_mi->mbmi; |
42 // Keep counts for entropy encoding. | 42 // Keep counts for entropy encoding. |
43 context_counter += mode_2_counter[candidate->mode]; | 43 context_counter += mode_2_counter[candidate->mode]; |
44 different_ref_found = 1; | 44 different_ref_found = 1; |
45 | 45 |
46 if (candidate->ref_frame[0] == ref_frame) | 46 if (candidate->ref_frame[0] == ref_frame) |
47 ADD_MV_REF_LIST(get_sub_block_mv(candidate_mi, 0, mv_ref->col, block), | 47 ADD_MV_REF_LIST(get_sub_block_mv(candidate_mi, 0, mv_ref->col, block), |
48 refmv_count, mv_ref_list, Done); | 48 refmv_count, mv_ref_list, Done); |
49 else if (candidate->ref_frame[1] == ref_frame) | 49 else if (candidate->ref_frame[1] == ref_frame) |
50 ADD_MV_REF_LIST(get_sub_block_mv(candidate_mi, 1, mv_ref->col, block), | 50 ADD_MV_REF_LIST(get_sub_block_mv(candidate_mi, 1, mv_ref->col, block), |
51 refmv_count, mv_ref_list, Done); | 51 refmv_count, mv_ref_list, Done); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 // Check the rest of the neighbors in much the same way | 55 // Check the rest of the neighbors in much the same way |
56 // as before except we don't need to keep track of sub blocks or | 56 // as before except we don't need to keep track of sub blocks or |
57 // mode counts. | 57 // mode counts. |
58 for (; i < MVREF_NEIGHBOURS; ++i) { | 58 for (; i < MVREF_NEIGHBOURS; ++i) { |
59 const POSITION *const mv_ref = &mv_ref_search[i]; | 59 const POSITION *const mv_ref = &mv_ref_search[i]; |
60 if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { | 60 if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { |
61 const MB_MODE_INFO *const candidate = &xd->mi[mv_ref->col + mv_ref->row * | 61 const MB_MODE_INFO *const candidate = &xd->mi[mv_ref->col + mv_ref->row * |
62 xd->mi_stride].src_mi->mbmi; | 62 xd->mi_stride]->mbmi; |
63 different_ref_found = 1; | 63 different_ref_found = 1; |
64 | 64 |
65 if (candidate->ref_frame[0] == ref_frame) | 65 if (candidate->ref_frame[0] == ref_frame) |
66 ADD_MV_REF_LIST(candidate->mv[0], refmv_count, mv_ref_list, Done); | 66 ADD_MV_REF_LIST(candidate->mv[0], refmv_count, mv_ref_list, Done); |
67 else if (candidate->ref_frame[1] == ref_frame) | 67 else if (candidate->ref_frame[1] == ref_frame) |
68 ADD_MV_REF_LIST(candidate->mv[1], refmv_count, mv_ref_list, Done); | 68 ADD_MV_REF_LIST(candidate->mv[1], refmv_count, mv_ref_list, Done); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 // TODO(hkuang): Remove this sync after fixing pthread_cond_broadcast | 72 // TODO(hkuang): Remove this sync after fixing pthread_cond_broadcast |
(...skipping 21 matching lines...) Expand all Loading... |
94 } | 94 } |
95 | 95 |
96 // Since we couldn't find 2 mvs from the same reference frame | 96 // Since we couldn't find 2 mvs from the same reference frame |
97 // go back through the neighbors and find motion vectors from | 97 // go back through the neighbors and find motion vectors from |
98 // different reference frames. | 98 // different reference frames. |
99 if (different_ref_found) { | 99 if (different_ref_found) { |
100 for (i = 0; i < MVREF_NEIGHBOURS; ++i) { | 100 for (i = 0; i < MVREF_NEIGHBOURS; ++i) { |
101 const POSITION *mv_ref = &mv_ref_search[i]; | 101 const POSITION *mv_ref = &mv_ref_search[i]; |
102 if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { | 102 if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { |
103 const MB_MODE_INFO *const candidate = &xd->mi[mv_ref->col + mv_ref->row | 103 const MB_MODE_INFO *const candidate = &xd->mi[mv_ref->col + mv_ref->row |
104 * xd->mi_stride].src_mi->mbmi; | 104 * xd->mi_stride]->mbmi; |
105 | 105 |
106 // If the candidate is INTRA we don't want to consider its mv. | 106 // If the candidate is INTRA we don't want to consider its mv. |
107 IF_DIFF_REF_FRAME_ADD_MV(candidate, ref_frame, ref_sign_bias, | 107 IF_DIFF_REF_FRAME_ADD_MV(candidate, ref_frame, ref_sign_bias, |
108 refmv_count, mv_ref_list, Done); | 108 refmv_count, mv_ref_list, Done); |
109 } | 109 } |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 // Since we still don't have a candidate we'll try the last frame. | 113 // Since we still don't have a candidate we'll try the last frame. |
114 if (cm->use_prev_frame_mvs) { | 114 if (cm->use_prev_frame_mvs) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 176 } |
177 *nearest_mv = mvlist[0]; | 177 *nearest_mv = mvlist[0]; |
178 *near_mv = mvlist[1]; | 178 *near_mv = mvlist[1]; |
179 } | 179 } |
180 | 180 |
181 void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd, | 181 void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd, |
182 const TileInfo *const tile, | 182 const TileInfo *const tile, |
183 int block, int ref, int mi_row, int mi_col, | 183 int block, int ref, int mi_row, int mi_col, |
184 int_mv *nearest_mv, int_mv *near_mv) { | 184 int_mv *nearest_mv, int_mv *near_mv) { |
185 int_mv mv_list[MAX_MV_REF_CANDIDATES]; | 185 int_mv mv_list[MAX_MV_REF_CANDIDATES]; |
186 MODE_INFO *const mi = xd->mi[0].src_mi; | 186 MODE_INFO *const mi = xd->mi[0]; |
187 b_mode_info *bmi = mi->bmi; | 187 b_mode_info *bmi = mi->bmi; |
188 int n; | 188 int n; |
189 | 189 |
190 assert(MAX_MV_REF_CANDIDATES == 2); | 190 assert(MAX_MV_REF_CANDIDATES == 2); |
191 | 191 |
192 find_mv_refs_idx(cm, xd, tile, mi, mi->mbmi.ref_frame[ref], mv_list, block, | 192 find_mv_refs_idx(cm, xd, tile, mi, mi->mbmi.ref_frame[ref], mv_list, block, |
193 mi_row, mi_col, NULL, NULL); | 193 mi_row, mi_col, NULL, NULL); |
194 | 194 |
195 near_mv->as_int = 0; | 195 near_mv->as_int = 0; |
196 switch (block) { | 196 switch (block) { |
(...skipping 22 matching lines...) Expand all Loading... |
219 if (nearest_mv->as_int != candidates[n].as_int) { | 219 if (nearest_mv->as_int != candidates[n].as_int) { |
220 near_mv->as_int = candidates[n].as_int; | 220 near_mv->as_int = candidates[n].as_int; |
221 break; | 221 break; |
222 } | 222 } |
223 break; | 223 break; |
224 } | 224 } |
225 default: | 225 default: |
226 assert("Invalid block index."); | 226 assert("Invalid block index."); |
227 } | 227 } |
228 } | 228 } |
OLD | NEW |