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

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

Issue 897063002: Revert "libvpx: Pull from upstream" (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 10 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) {
22 const int *ref_sign_bias = cm->ref_frame_sign_bias; 21 const int *ref_sign_bias = cm->ref_frame_sign_bias;
23 int i, refmv_count = 0; 22 int i, refmv_count = 0;
24 const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type]; 23 const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type];
25 int different_ref_found = 0; 24 int different_ref_found = 0;
26 int context_counter = 0; 25 int context_counter = 0;
27 const MV_REF *const prev_frame_mvs = cm->use_prev_frame_mvs ? 26 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; 27 cm->prev_frame->mvs + mi_row * cm->mi_cols + mi_col : NULL;
29 28
30 // Blank the reference vector list 29 // Blank the reference vector list
31 vpx_memset(mv_ref_list, 0, sizeof(*mv_ref_list) * MAX_MV_REF_CANDIDATES); 30 vpx_memset(mv_ref_list, 0, sizeof(*mv_ref_list) * MAX_MV_REF_CANDIDATES);
(...skipping 30 matching lines...) Expand all
62 xd->mi_stride].src_mi->mbmi; 61 xd->mi_stride].src_mi->mbmi;
63 different_ref_found = 1; 62 different_ref_found = 1;
64 63
65 if (candidate->ref_frame[0] == ref_frame) 64 if (candidate->ref_frame[0] == ref_frame)
66 ADD_MV_REF_LIST(candidate->mv[0], refmv_count, mv_ref_list, Done); 65 ADD_MV_REF_LIST(candidate->mv[0], refmv_count, mv_ref_list, Done);
67 else if (candidate->ref_frame[1] == ref_frame) 66 else if (candidate->ref_frame[1] == ref_frame)
68 ADD_MV_REF_LIST(candidate->mv[1], refmv_count, mv_ref_list, Done); 67 ADD_MV_REF_LIST(candidate->mv[1], refmv_count, mv_ref_list, Done);
69 } 68 }
70 } 69 }
71 70
72 // Synchronize here for frame parallel decode if sync function is provided.
73 if (sync != NULL) {
74 sync(data, mi_row);
75 }
76
77 // Check the last frame's mode and mv info. 71 // Check the last frame's mode and mv info.
78 if (cm->use_prev_frame_mvs) { 72 if (cm->use_prev_frame_mvs) {
79 if (prev_frame_mvs->ref_frame[0] == ref_frame) { 73 if (prev_frame_mvs->ref_frame[0] == ref_frame) {
80 ADD_MV_REF_LIST(prev_frame_mvs->mv[0], refmv_count, mv_ref_list, Done); 74 ADD_MV_REF_LIST(prev_frame_mvs->mv[0], refmv_count, mv_ref_list, Done);
81 } else if (prev_frame_mvs->ref_frame[1] == ref_frame) { 75 } else if (prev_frame_mvs->ref_frame[1] == ref_frame) {
82 ADD_MV_REF_LIST(prev_frame_mvs->mv[1], refmv_count, mv_ref_list, Done); 76 ADD_MV_REF_LIST(prev_frame_mvs->mv[1], refmv_count, mv_ref_list, Done);
83 } 77 }
84 } 78 }
85 79
86 // Since we couldn't find 2 mvs from the same reference frame 80 // Since we couldn't find 2 mvs from the same reference frame
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 126
133 // Clamp vectors 127 // Clamp vectors
134 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) 128 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i)
135 clamp_mv_ref(&mv_ref_list[i].as_mv, xd); 129 clamp_mv_ref(&mv_ref_list[i].as_mv, xd);
136 } 130 }
137 131
138 void vp9_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd, 132 void vp9_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd,
139 const TileInfo *const tile, 133 const TileInfo *const tile,
140 MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame, 134 MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
141 int_mv *mv_ref_list, 135 int_mv *mv_ref_list,
142 int mi_row, int mi_col, 136 int mi_row, int mi_col) {
143 find_mv_refs_sync sync, void *const data) {
144 find_mv_refs_idx(cm, xd, tile, mi, ref_frame, mv_ref_list, -1, 137 find_mv_refs_idx(cm, xd, tile, mi, ref_frame, mv_ref_list, -1,
145 mi_row, mi_col, sync, data); 138 mi_row, mi_col);
146 } 139 }
147 140
148 static void lower_mv_precision(MV *mv, int allow_hp) { 141 static void lower_mv_precision(MV *mv, int allow_hp) {
149 const int use_hp = allow_hp && vp9_use_mv_hp(mv); 142 const int use_hp = allow_hp && vp9_use_mv_hp(mv);
150 if (!use_hp) { 143 if (!use_hp) {
151 if (mv->row & 1) 144 if (mv->row & 1)
152 mv->row += (mv->row > 0 ? -1 : 1); 145 mv->row += (mv->row > 0 ? -1 : 1);
153 if (mv->col & 1) 146 if (mv->col & 1)
154 mv->col += (mv->col > 0 ? -1 : 1); 147 mv->col += (mv->col > 0 ? -1 : 1);
155 } 148 }
156 } 149 }
157 150
158 void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp, 151 void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp,
159 int_mv *mvlist, int_mv *nearest_mv, 152 int_mv *mvlist, int_mv *nearest, int_mv *near) {
160 int_mv *near_mv) {
161 int i; 153 int i;
162 // Make sure all the candidates are properly clamped etc 154 // Make sure all the candidates are properly clamped etc
163 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) { 155 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
164 lower_mv_precision(&mvlist[i].as_mv, allow_hp); 156 lower_mv_precision(&mvlist[i].as_mv, allow_hp);
165 clamp_mv2(&mvlist[i].as_mv, xd); 157 clamp_mv2(&mvlist[i].as_mv, xd);
166 } 158 }
167 *nearest_mv = mvlist[0]; 159 *nearest = mvlist[0];
168 *near_mv = mvlist[1]; 160 *near = mvlist[1];
169 } 161 }
170 162
171 void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd, 163 void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
172 const TileInfo *const tile, 164 const TileInfo *const tile,
173 int block, int ref, int mi_row, int mi_col, 165 int block, int ref, int mi_row, int mi_col,
174 int_mv *nearest_mv, int_mv *near_mv) { 166 int_mv *nearest, int_mv *near) {
175 int_mv mv_list[MAX_MV_REF_CANDIDATES]; 167 int_mv mv_list[MAX_MV_REF_CANDIDATES];
176 MODE_INFO *const mi = xd->mi[0].src_mi; 168 MODE_INFO *const mi = xd->mi[0].src_mi;
177 b_mode_info *bmi = mi->bmi; 169 b_mode_info *bmi = mi->bmi;
178 int n; 170 int n;
179 171
180 assert(MAX_MV_REF_CANDIDATES == 2); 172 assert(MAX_MV_REF_CANDIDATES == 2);
181 173
182 find_mv_refs_idx(cm, xd, tile, mi, mi->mbmi.ref_frame[ref], mv_list, block, 174 find_mv_refs_idx(cm, xd, tile, mi, mi->mbmi.ref_frame[ref], mv_list, block,
183 mi_row, mi_col, NULL, NULL); 175 mi_row, mi_col);
184 176
185 near_mv->as_int = 0; 177 near->as_int = 0;
186 switch (block) { 178 switch (block) {
187 case 0: 179 case 0:
188 nearest_mv->as_int = mv_list[0].as_int; 180 nearest->as_int = mv_list[0].as_int;
189 near_mv->as_int = mv_list[1].as_int; 181 near->as_int = mv_list[1].as_int;
190 break; 182 break;
191 case 1: 183 case 1:
192 case 2: 184 case 2:
193 nearest_mv->as_int = bmi[0].as_mv[ref].as_int; 185 nearest->as_int = bmi[0].as_mv[ref].as_int;
194 for (n = 0; n < MAX_MV_REF_CANDIDATES; ++n) 186 for (n = 0; n < MAX_MV_REF_CANDIDATES; ++n)
195 if (nearest_mv->as_int != mv_list[n].as_int) { 187 if (nearest->as_int != mv_list[n].as_int) {
196 near_mv->as_int = mv_list[n].as_int; 188 near->as_int = mv_list[n].as_int;
197 break; 189 break;
198 } 190 }
199 break; 191 break;
200 case 3: { 192 case 3: {
201 int_mv candidates[2 + MAX_MV_REF_CANDIDATES]; 193 int_mv candidates[2 + MAX_MV_REF_CANDIDATES];
202 candidates[0] = bmi[1].as_mv[ref]; 194 candidates[0] = bmi[1].as_mv[ref];
203 candidates[1] = bmi[0].as_mv[ref]; 195 candidates[1] = bmi[0].as_mv[ref];
204 candidates[2] = mv_list[0]; 196 candidates[2] = mv_list[0];
205 candidates[3] = mv_list[1]; 197 candidates[3] = mv_list[1];
206 198
207 nearest_mv->as_int = bmi[2].as_mv[ref].as_int; 199 nearest->as_int = bmi[2].as_mv[ref].as_int;
208 for (n = 0; n < 2 + MAX_MV_REF_CANDIDATES; ++n) 200 for (n = 0; n < 2 + MAX_MV_REF_CANDIDATES; ++n)
209 if (nearest_mv->as_int != candidates[n].as_int) { 201 if (nearest->as_int != candidates[n].as_int) {
210 near_mv->as_int = candidates[n].as_int; 202 near->as_int = candidates[n].as_int;
211 break; 203 break;
212 } 204 }
213 break; 205 break;
214 } 206 }
215 default: 207 default:
216 assert("Invalid block index."); 208 assert("Invalid block index.");
217 } 209 }
218 } 210 }
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