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

Side by Side Diff: source/libvpx/vp9/encoder/vp9_encodemv.c

Issue 181493009: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 9 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
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_encodemv.h ('k') | source/libvpx/vp9/encoder/vp9_firstpass.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 * 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
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 encode_mv_component(w, diff.col, &mvctx->comps[1], usehp); 217 encode_mv_component(w, diff.col, &mvctx->comps[1], usehp);
218 218
219 // If auto_mv_step_size is enabled then keep track of the largest 219 // If auto_mv_step_size is enabled then keep track of the largest
220 // motion vector component used. 220 // motion vector component used.
221 if (!cpi->dummy_packing && cpi->sf.auto_mv_step_size) { 221 if (!cpi->dummy_packing && cpi->sf.auto_mv_step_size) {
222 unsigned int maxv = MAX(abs(mv->row), abs(mv->col)) >> 3; 222 unsigned int maxv = MAX(abs(mv->row), abs(mv->col)) >> 3;
223 cpi->max_mv_magnitude = MAX(maxv, cpi->max_mv_magnitude); 223 cpi->max_mv_magnitude = MAX(maxv, cpi->max_mv_magnitude);
224 } 224 }
225 } 225 }
226 226
227 void vp9_build_nmv_cost_table(int *mvjoint, 227 void vp9_build_nmv_cost_table(int *mvjoint, int *mvcost[2],
228 int *mvcost[2], 228 const nmv_context* ctx, int usehp) {
229 const nmv_context* const mvctx, 229 vp9_cost_tokens(mvjoint, ctx->joints, vp9_mv_joint_tree);
230 int usehp, 230 build_nmv_component_cost_table(mvcost[0], &ctx->comps[0], usehp);
231 int mvc_flag_v, 231 build_nmv_component_cost_table(mvcost[1], &ctx->comps[1], usehp);
232 int mvc_flag_h) {
233 vp9_clear_system_state();
234 vp9_cost_tokens(mvjoint, mvctx->joints, vp9_mv_joint_tree);
235 if (mvc_flag_v)
236 build_nmv_component_cost_table(mvcost[0], &mvctx->comps[0], usehp);
237 if (mvc_flag_h)
238 build_nmv_component_cost_table(mvcost[1], &mvctx->comps[1], usehp);
239 } 232 }
240 233
241 static void inc_mvs(int_mv mv[2], int_mv ref[2], int is_compound, 234 static void inc_mvs(const int_mv mv[2], const MV ref[2], int is_compound,
242 nmv_context_counts *counts) { 235 nmv_context_counts *counts) {
243 int i; 236 int i;
244 for (i = 0; i < 1 + is_compound; ++i) { 237 for (i = 0; i < 1 + is_compound; ++i) {
245 const MV diff = { mv[i].as_mv.row - ref[i].as_mv.row, 238 const MV diff = { mv[i].as_mv.row - ref[i].row,
246 mv[i].as_mv.col - ref[i].as_mv.col }; 239 mv[i].as_mv.col - ref[i].col };
247 vp9_inc_mv(&diff, counts); 240 vp9_inc_mv(&diff, counts);
248 } 241 }
249 } 242 }
250 243
251 void vp9_update_mv_count(VP9_COMP *cpi, MACROBLOCK *x, int_mv best_ref_mv[2]) { 244 void vp9_update_mv_count(VP9_COMMON *cm, const MACROBLOCKD *xd,
252 MODE_INFO *mi = x->e_mbd.mi_8x8[0]; 245 const MV best_ref_mv[2]) {
253 MB_MODE_INFO *const mbmi = &mi->mbmi; 246 const MODE_INFO *mi = xd->mi_8x8[0];
247 const MB_MODE_INFO *const mbmi = &mi->mbmi;
254 const int is_compound = has_second_ref(mbmi); 248 const int is_compound = has_second_ref(mbmi);
255 nmv_context_counts *counts = &cpi->common.counts.mv; 249 nmv_context_counts *counts = &cm->counts.mv;
256 250
257 if (mbmi->sb_type < BLOCK_8X8) { 251 if (mbmi->sb_type < BLOCK_8X8) {
258 const int num_4x4_w = num_4x4_blocks_wide_lookup[mbmi->sb_type]; 252 const int num_4x4_w = num_4x4_blocks_wide_lookup[mbmi->sb_type];
259 const int num_4x4_h = num_4x4_blocks_high_lookup[mbmi->sb_type]; 253 const int num_4x4_h = num_4x4_blocks_high_lookup[mbmi->sb_type];
260 int idx, idy; 254 int idx, idy;
261 255
262 for (idy = 0; idy < 2; idy += num_4x4_h) { 256 for (idy = 0; idy < 2; idy += num_4x4_h) {
263 for (idx = 0; idx < 2; idx += num_4x4_w) { 257 for (idx = 0; idx < 2; idx += num_4x4_w) {
264 const int i = idy * 2 + idx; 258 const int i = idy * 2 + idx;
265 if (mi->bmi[i].as_mode == NEWMV) 259 if (mi->bmi[i].as_mode == NEWMV)
266 inc_mvs(mi->bmi[i].as_mv, best_ref_mv, is_compound, counts); 260 inc_mvs(mi->bmi[i].as_mv, best_ref_mv, is_compound, counts);
267 } 261 }
268 } 262 }
269 } else if (mbmi->mode == NEWMV) { 263 } else if (mbmi->mode == NEWMV) {
270 inc_mvs(mbmi->mv, best_ref_mv, is_compound, counts); 264 inc_mvs(mbmi->mv, best_ref_mv, is_compound, counts);
271 } 265 }
272 } 266 }
273 267
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_encodemv.h ('k') | source/libvpx/vp9/encoder/vp9_firstpass.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698