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

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

Issue 668403002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
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 const int *ref_sign_bias = cm->ref_frame_sign_bias; 21 const int *ref_sign_bias = cm->ref_frame_sign_bias;
22 int i, refmv_count = 0; 22 int i, refmv_count = 0;
23 const MODE_INFO *prev_mi = !cm->error_resilient_mode && cm->prev_mi 23 const MODE_INFO *prev_mi = !cm->error_resilient_mode && cm->prev_mi
24 ? cm->prev_mi[mi_row * xd->mi_stride + mi_col].src_mi 24 ? cm->prev_mi[mi_row * xd->mi_stride + mi_col].src_mi
25 : NULL; 25 : NULL;
26 const MB_MODE_INFO *const prev_mbmi = prev_mi ? &prev_mi->src_mi->mbmi : NULL; 26 const MB_MODE_INFO *const prev_mbmi = prev_mi ? &prev_mi->src_mi->mbmi : NULL;
27
28
29 const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type]; 27 const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type];
30
31 int different_ref_found = 0; 28 int different_ref_found = 0;
32 int context_counter = 0; 29 int context_counter = 0;
33 30
34 // Blank the reference vector list 31 // Blank the reference vector list
35 vpx_memset(mv_ref_list, 0, sizeof(*mv_ref_list) * MAX_MV_REF_CANDIDATES); 32 vpx_memset(mv_ref_list, 0, sizeof(*mv_ref_list) * MAX_MV_REF_CANDIDATES);
36 33
37 // The nearest 2 blocks are treated differently 34 // The nearest 2 blocks are treated differently
38 // if the size < 8x8 we get the mv from the bmi substructure, 35 // if the size < 8x8 we get the mv from the bmi substructure,
39 // and we also need to keep a mode count. 36 // and we also need to keep a mode count.
40 for (i = 0; i < 2; ++i) { 37 for (i = 0; i < 2; ++i) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 Done: 99 Done:
103 100
104 mi->mbmi.mode_context[ref_frame] = counter_to_context[context_counter]; 101 mi->mbmi.mode_context[ref_frame] = counter_to_context[context_counter];
105 102
106 // Clamp vectors 103 // Clamp vectors
107 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) 104 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i)
108 clamp_mv_ref(&mv_ref_list[i].as_mv, xd); 105 clamp_mv_ref(&mv_ref_list[i].as_mv, xd);
109 } 106 }
110 107
111 void vp9_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd, 108 void vp9_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd,
112 const TileInfo *const tile, 109 const TileInfo *const tile,
113 MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame, 110 MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
114 int_mv *mv_ref_list, 111 int_mv *mv_ref_list,
115 int mi_row, int mi_col) { 112 int mi_row, int mi_col) {
116 find_mv_refs_idx(cm, xd, tile, mi, ref_frame, mv_ref_list, -1, 113 find_mv_refs_idx(cm, xd, tile, mi, ref_frame, mv_ref_list, -1,
117 mi_row, mi_col); 114 mi_row, mi_col);
118 } 115 }
119 116
120 static void lower_mv_precision(MV *mv, int allow_hp) { 117 static void lower_mv_precision(MV *mv, int allow_hp) {
121 const int use_hp = allow_hp && vp9_use_mv_hp(mv); 118 const int use_hp = allow_hp && vp9_use_mv_hp(mv);
122 if (!use_hp) { 119 if (!use_hp) {
123 if (mv->row & 1) 120 if (mv->row & 1)
124 mv->row += (mv->row > 0 ? -1 : 1); 121 mv->row += (mv->row > 0 ? -1 : 1);
125 if (mv->col & 1) 122 if (mv->col & 1)
126 mv->col += (mv->col > 0 ? -1 : 1); 123 mv->col += (mv->col > 0 ? -1 : 1);
127 } 124 }
128 } 125 }
129 126
130
131 void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp, 127 void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp,
132 int_mv *mvlist, int_mv *nearest, int_mv *near) { 128 int_mv *mvlist, int_mv *nearest, int_mv *near) {
133 int i; 129 int i;
134 // Make sure all the candidates are properly clamped etc 130 // Make sure all the candidates are properly clamped etc
135 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) { 131 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
136 lower_mv_precision(&mvlist[i].as_mv, allow_hp); 132 lower_mv_precision(&mvlist[i].as_mv, allow_hp);
137 clamp_mv2(&mvlist[i].as_mv, xd); 133 clamp_mv2(&mvlist[i].as_mv, xd);
138 } 134 }
139 *nearest = mvlist[0]; 135 *nearest = mvlist[0];
140 *near = mvlist[1]; 136 *near = mvlist[1];
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 if (nearest->as_int != candidates[n].as_int) { 177 if (nearest->as_int != candidates[n].as_int) {
182 near->as_int = candidates[n].as_int; 178 near->as_int = candidates[n].as_int;
183 break; 179 break;
184 } 180 }
185 break; 181 break;
186 } 182 }
187 default: 183 default:
188 assert("Invalid block index."); 184 assert("Invalid block index.");
189 } 185 }
190 } 186 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/vp9_loopfilter_filters.c ('k') | source/libvpx/vp9/common/vp9_onyxc_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698