Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: source/libvpx/vp9/common/vp9_mvref_common.c

Issue 1217053002: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/libvpx/vp9/common/vp9_mvref_common.h ('k') | source/libvpx/vp9/common/vp9_onyxc_int.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 */
11 11
12 #include "vp9/common/vp9_mvref_common.h" 12 #include "vp9/common/vp9_mvref_common.h"
13 13
14 // This function searches the neighbourhood of a given MB/SB 14 // This function searches the neighbourhood of a given MB/SB
15 // to try and find candidate reference vectors. 15 // to try and find candidate reference vectors.
16 static void find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd, 16 static void find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd,
17 const TileInfo *const tile, 17 const TileInfo *const tile,
18 MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame, 18 MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
19 int_mv *mv_ref_list, 19 int_mv *mv_ref_list,
20 int block, int mi_row, int mi_col, 20 int block, int mi_row, int mi_col,
21 find_mv_refs_sync sync, void *const data) { 21 find_mv_refs_sync sync, void *const data,
22 uint8_t *mode_context) {
22 const int *ref_sign_bias = cm->ref_frame_sign_bias; 23 const int *ref_sign_bias = cm->ref_frame_sign_bias;
23 int i, refmv_count = 0; 24 int i, refmv_count = 0;
24 const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type]; 25 const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type];
25 int different_ref_found = 0; 26 int different_ref_found = 0;
26 int context_counter = 0; 27 int context_counter = 0;
27 const MV_REF *const prev_frame_mvs = cm->use_prev_frame_mvs ? 28 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; 29 cm->prev_frame->mvs + mi_row * cm->mi_cols + mi_col : NULL;
29 30
30 // Blank the reference vector list 31 // Blank the reference vector list
31 memset(mv_ref_list, 0, sizeof(*mv_ref_list) * MAX_MV_REF_CANDIDATES); 32 memset(mv_ref_list, 0, sizeof(*mv_ref_list) * MAX_MV_REF_CANDIDATES);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 ref_sign_bias[ref_frame]) { 132 ref_sign_bias[ref_frame]) {
132 mv.as_mv.row *= -1; 133 mv.as_mv.row *= -1;
133 mv.as_mv.col *= -1; 134 mv.as_mv.col *= -1;
134 } 135 }
135 ADD_MV_REF_LIST(mv, refmv_count, mv_ref_list, Done); 136 ADD_MV_REF_LIST(mv, refmv_count, mv_ref_list, Done);
136 } 137 }
137 } 138 }
138 139
139 Done: 140 Done:
140 141
141 mi->mbmi.mode_context[ref_frame] = counter_to_context[context_counter]; 142 mode_context[ref_frame] = counter_to_context[context_counter];
142 143
143 // Clamp vectors 144 // Clamp vectors
144 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) 145 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i)
145 clamp_mv_ref(&mv_ref_list[i].as_mv, xd); 146 clamp_mv_ref(&mv_ref_list[i].as_mv, xd);
146 } 147 }
147 148
148 void vp9_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd, 149 void vp9_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd,
149 const TileInfo *const tile, 150 const TileInfo *const tile,
150 MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame, 151 MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
151 int_mv *mv_ref_list, 152 int_mv *mv_ref_list,
152 int mi_row, int mi_col, 153 int mi_row, int mi_col,
153 find_mv_refs_sync sync, void *const data) { 154 find_mv_refs_sync sync, void *const data,
155 uint8_t *mode_context) {
154 find_mv_refs_idx(cm, xd, tile, mi, ref_frame, mv_ref_list, -1, 156 find_mv_refs_idx(cm, xd, tile, mi, ref_frame, mv_ref_list, -1,
155 mi_row, mi_col, sync, data); 157 mi_row, mi_col, sync, data, mode_context);
156 } 158 }
157 159
158 static void lower_mv_precision(MV *mv, int allow_hp) { 160 static void lower_mv_precision(MV *mv, int allow_hp) {
159 const int use_hp = allow_hp && vp9_use_mv_hp(mv); 161 const int use_hp = allow_hp && vp9_use_mv_hp(mv);
160 if (!use_hp) { 162 if (!use_hp) {
161 if (mv->row & 1) 163 if (mv->row & 1)
162 mv->row += (mv->row > 0 ? -1 : 1); 164 mv->row += (mv->row > 0 ? -1 : 1);
163 if (mv->col & 1) 165 if (mv->col & 1)
164 mv->col += (mv->col > 0 ? -1 : 1); 166 mv->col += (mv->col > 0 ? -1 : 1);
165 } 167 }
166 } 168 }
167 169
168 void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp, 170 void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp,
169 int_mv *mvlist, int_mv *nearest_mv, 171 int_mv *mvlist, int_mv *nearest_mv,
170 int_mv *near_mv) { 172 int_mv *near_mv) {
171 int i; 173 int i;
172 // Make sure all the candidates are properly clamped etc 174 // Make sure all the candidates are properly clamped etc
173 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) { 175 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
174 lower_mv_precision(&mvlist[i].as_mv, allow_hp); 176 lower_mv_precision(&mvlist[i].as_mv, allow_hp);
175 clamp_mv2(&mvlist[i].as_mv, xd); 177 clamp_mv2(&mvlist[i].as_mv, xd);
176 } 178 }
177 *nearest_mv = mvlist[0]; 179 *nearest_mv = mvlist[0];
178 *near_mv = mvlist[1]; 180 *near_mv = mvlist[1];
179 } 181 }
180 182
181 void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd, 183 void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
182 const TileInfo *const tile, 184 const TileInfo *const tile,
183 int block, int ref, int mi_row, int mi_col, 185 int block, int ref, int mi_row, int mi_col,
184 int_mv *nearest_mv, int_mv *near_mv) { 186 int_mv *nearest_mv, int_mv *near_mv,
187 uint8_t *mode_context) {
185 int_mv mv_list[MAX_MV_REF_CANDIDATES]; 188 int_mv mv_list[MAX_MV_REF_CANDIDATES];
186 MODE_INFO *const mi = xd->mi[0]; 189 MODE_INFO *const mi = xd->mi[0];
187 b_mode_info *bmi = mi->bmi; 190 b_mode_info *bmi = mi->bmi;
188 int n; 191 int n;
189 192
190 assert(MAX_MV_REF_CANDIDATES == 2); 193 assert(MAX_MV_REF_CANDIDATES == 2);
191 194
192 find_mv_refs_idx(cm, xd, tile, mi, mi->mbmi.ref_frame[ref], mv_list, block, 195 find_mv_refs_idx(cm, xd, tile, mi, mi->mbmi.ref_frame[ref], mv_list, block,
193 mi_row, mi_col, NULL, NULL); 196 mi_row, mi_col, NULL, NULL, mode_context);
194 197
195 near_mv->as_int = 0; 198 near_mv->as_int = 0;
196 switch (block) { 199 switch (block) {
197 case 0: 200 case 0:
198 nearest_mv->as_int = mv_list[0].as_int; 201 nearest_mv->as_int = mv_list[0].as_int;
199 near_mv->as_int = mv_list[1].as_int; 202 near_mv->as_int = mv_list[1].as_int;
200 break; 203 break;
201 case 1: 204 case 1:
202 case 2: 205 case 2:
203 nearest_mv->as_int = bmi[0].as_mv[ref].as_int; 206 nearest_mv->as_int = bmi[0].as_mv[ref].as_int;
(...skipping 15 matching lines...) Expand all
219 if (nearest_mv->as_int != candidates[n].as_int) { 222 if (nearest_mv->as_int != candidates[n].as_int) {
220 near_mv->as_int = candidates[n].as_int; 223 near_mv->as_int = candidates[n].as_int;
221 break; 224 break;
222 } 225 }
223 break; 226 break;
224 } 227 }
225 default: 228 default:
226 assert(0 && "Invalid block index."); 229 assert(0 && "Invalid block index.");
227 } 230 }
228 } 231 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/vp9_mvref_common.h ('k') | source/libvpx/vp9/common/vp9_onyxc_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698