OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "vp9/common/vp9_onyxc_int.h" | 11 #include "vp9/common/vp9_onyxc_int.h" |
12 #include "vp9/common/vp9_entropymv.h" | 12 #include "vp9/common/vp9_entropymv.h" |
13 | 13 |
14 #define MV_COUNT_SAT 20 | |
15 #define MV_MAX_UPDATE_FACTOR 128 | |
16 | |
17 // Integer pel reference mv threshold for use of high-precision 1/8 mv | 14 // Integer pel reference mv threshold for use of high-precision 1/8 mv |
18 #define COMPANDED_MVREF_THRESH 8 | 15 #define COMPANDED_MVREF_THRESH 8 |
19 | 16 |
20 const vp9_tree_index vp9_mv_joint_tree[TREE_SIZE(MV_JOINTS)] = { | 17 const vp9_tree_index vp9_mv_joint_tree[TREE_SIZE(MV_JOINTS)] = { |
21 -MV_JOINT_ZERO, 2, | 18 -MV_JOINT_ZERO, 2, |
22 -MV_JOINT_HNZVZ, 4, | 19 -MV_JOINT_HNZVZ, 4, |
23 -MV_JOINT_HZVNZ, -MV_JOINT_HNZVNZ | 20 -MV_JOINT_HZVNZ, -MV_JOINT_HNZVNZ |
24 }; | 21 }; |
25 | 22 |
26 const vp9_tree_index vp9_mv_class_tree[TREE_SIZE(MV_CLASSES)] = { | 23 const vp9_tree_index vp9_mv_class_tree[TREE_SIZE(MV_CLASSES)] = { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 if (mv_joint_vertical(j)) { | 173 if (mv_joint_vertical(j)) { |
177 inc_mv_component(mv->row, &counts->comps[0], 1, 1); | 174 inc_mv_component(mv->row, &counts->comps[0], 1, 1); |
178 } | 175 } |
179 | 176 |
180 if (mv_joint_horizontal(j)) { | 177 if (mv_joint_horizontal(j)) { |
181 inc_mv_component(mv->col, &counts->comps[1], 1, 1); | 178 inc_mv_component(mv->col, &counts->comps[1], 1, 1); |
182 } | 179 } |
183 } | 180 } |
184 } | 181 } |
185 | 182 |
186 static vp9_prob adapt_prob(vp9_prob prep, const unsigned int ct[2]) { | |
187 return merge_probs(prep, ct, MV_COUNT_SAT, MV_MAX_UPDATE_FACTOR); | |
188 } | |
189 | |
190 static void adapt_probs(const vp9_tree_index *tree, const vp9_prob *pre_probs, | |
191 const unsigned int *counts, vp9_prob *probs) { | |
192 vp9_tree_merge_probs(tree, pre_probs, counts, MV_COUNT_SAT, | |
193 MV_MAX_UPDATE_FACTOR, probs); | |
194 } | |
195 | |
196 void vp9_adapt_mv_probs(VP9_COMMON *cm, int allow_hp) { | 183 void vp9_adapt_mv_probs(VP9_COMMON *cm, int allow_hp) { |
197 int i, j; | 184 int i, j; |
198 | 185 |
199 nmv_context *fc = &cm->fc->nmvc; | 186 nmv_context *fc = &cm->fc->nmvc; |
200 const nmv_context *pre_fc = &cm->frame_contexts[cm->frame_context_idx].nmvc; | 187 const nmv_context *pre_fc = &cm->frame_contexts[cm->frame_context_idx].nmvc; |
201 const nmv_context_counts *counts = &cm->counts.mv; | 188 const nmv_context_counts *counts = &cm->counts.mv; |
202 | 189 |
203 adapt_probs(vp9_mv_joint_tree, pre_fc->joints, counts->joints, fc->joints); | 190 vp9_tree_merge_probs(vp9_mv_joint_tree, pre_fc->joints, counts->joints, |
| 191 fc->joints); |
204 | 192 |
205 for (i = 0; i < 2; ++i) { | 193 for (i = 0; i < 2; ++i) { |
206 nmv_component *comp = &fc->comps[i]; | 194 nmv_component *comp = &fc->comps[i]; |
207 const nmv_component *pre_comp = &pre_fc->comps[i]; | 195 const nmv_component *pre_comp = &pre_fc->comps[i]; |
208 const nmv_component_counts *c = &counts->comps[i]; | 196 const nmv_component_counts *c = &counts->comps[i]; |
209 | 197 |
210 comp->sign = adapt_prob(pre_comp->sign, c->sign); | 198 comp->sign = mode_mv_merge_probs(pre_comp->sign, c->sign); |
211 adapt_probs(vp9_mv_class_tree, pre_comp->classes, c->classes, | 199 vp9_tree_merge_probs(vp9_mv_class_tree, pre_comp->classes, c->classes, |
212 comp->classes); | 200 comp->classes); |
213 adapt_probs(vp9_mv_class0_tree, pre_comp->class0, c->class0, comp->class0); | 201 vp9_tree_merge_probs(vp9_mv_class0_tree, pre_comp->class0, c->class0, |
| 202 comp->class0); |
214 | 203 |
215 for (j = 0; j < MV_OFFSET_BITS; ++j) | 204 for (j = 0; j < MV_OFFSET_BITS; ++j) |
216 comp->bits[j] = adapt_prob(pre_comp->bits[j], c->bits[j]); | 205 comp->bits[j] = mode_mv_merge_probs(pre_comp->bits[j], c->bits[j]); |
217 | 206 |
218 for (j = 0; j < CLASS0_SIZE; ++j) | 207 for (j = 0; j < CLASS0_SIZE; ++j) |
219 adapt_probs(vp9_mv_fp_tree, pre_comp->class0_fp[j], c->class0_fp[j], | 208 vp9_tree_merge_probs(vp9_mv_fp_tree, pre_comp->class0_fp[j], |
220 comp->class0_fp[j]); | 209 c->class0_fp[j], comp->class0_fp[j]); |
221 | 210 |
222 adapt_probs(vp9_mv_fp_tree, pre_comp->fp, c->fp, comp->fp); | 211 vp9_tree_merge_probs(vp9_mv_fp_tree, pre_comp->fp, c->fp, comp->fp); |
223 | 212 |
224 if (allow_hp) { | 213 if (allow_hp) { |
225 comp->class0_hp = adapt_prob(pre_comp->class0_hp, c->class0_hp); | 214 comp->class0_hp = mode_mv_merge_probs(pre_comp->class0_hp, c->class0_hp); |
226 comp->hp = adapt_prob(pre_comp->hp, c->hp); | 215 comp->hp = mode_mv_merge_probs(pre_comp->hp, c->hp); |
227 } | 216 } |
228 } | 217 } |
229 } | 218 } |
230 | 219 |
231 void vp9_init_mv_probs(VP9_COMMON *cm) { | 220 void vp9_init_mv_probs(VP9_COMMON *cm) { |
232 cm->fc->nmvc = default_nmv_context; | 221 cm->fc->nmvc = default_nmv_context; |
233 } | 222 } |
OLD | NEW |