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

Side by Side Diff: source/libvpx/vp9/decoder/vp9_decodemv.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/decoder/vp9_decodeframe.c ('k') | source/libvpx/vp9/decoder/vp9_onyxd.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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 250
251 if (mv_joint_horizontal(j)) 251 if (mv_joint_horizontal(j))
252 diff.col = read_mv_component(r, &ctx->comps[1], use_hp); 252 diff.col = read_mv_component(r, &ctx->comps[1], use_hp);
253 253
254 vp9_inc_mv(&diff, counts); 254 vp9_inc_mv(&diff, counts);
255 255
256 mv->row = ref->row + diff.row; 256 mv->row = ref->row + diff.row;
257 mv->col = ref->col + diff.col; 257 mv->col = ref->col + diff.col;
258 } 258 }
259 259
260 static REFERENCE_MODE read_reference_mode(VP9_COMMON *cm, const MACROBLOCKD *xd, 260 static REFERENCE_MODE read_block_reference_mode(VP9_COMMON *cm,
261 vp9_reader *r) { 261 const MACROBLOCKD *xd,
262 const int ctx = vp9_get_reference_mode_context(cm, xd); 262 vp9_reader *r) {
263 const int mode = vp9_read(r, cm->fc.comp_inter_prob[ctx]); 263 if (cm->reference_mode == REFERENCE_MODE_SELECT) {
264 if (!cm->frame_parallel_decoding_mode) 264 const int ctx = vp9_get_reference_mode_context(cm, xd);
265 ++cm->counts.comp_inter[ctx][mode]; 265 const int mode = vp9_read(r, cm->fc.comp_inter_prob[ctx]);
266 return mode; // SINGLE_REFERENCE or COMPOUND_REFERENCE 266 if (!cm->frame_parallel_decoding_mode)
267 ++cm->counts.comp_inter[ctx][mode];
268 return mode; // SINGLE_REFERENCE or COMPOUND_REFERENCE
269 } else {
270 return cm->reference_mode;
271 }
267 } 272 }
268 273
269 // Read the referncence frame 274 // Read the referncence frame
270 static void read_ref_frames(VP9_COMMON *const cm, MACROBLOCKD *const xd, 275 static void read_ref_frames(VP9_COMMON *const cm, MACROBLOCKD *const xd,
271 vp9_reader *r, 276 vp9_reader *r,
272 int segment_id, MV_REFERENCE_FRAME ref_frame[2]) { 277 int segment_id, MV_REFERENCE_FRAME ref_frame[2]) {
273 FRAME_CONTEXT *const fc = &cm->fc; 278 FRAME_CONTEXT *const fc = &cm->fc;
274 FRAME_COUNTS *const counts = &cm->counts; 279 FRAME_COUNTS *const counts = &cm->counts;
275 280
276 if (vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) { 281 if (vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
277 ref_frame[0] = vp9_get_segdata(&cm->seg, segment_id, SEG_LVL_REF_FRAME); 282 ref_frame[0] = vp9_get_segdata(&cm->seg, segment_id, SEG_LVL_REF_FRAME);
278 ref_frame[1] = NONE; 283 ref_frame[1] = NONE;
279 } else { 284 } else {
280 const REFERENCE_MODE mode = (cm->reference_mode == REFERENCE_MODE_SELECT) 285 const REFERENCE_MODE mode = read_block_reference_mode(cm, xd, r);
281 ? read_reference_mode(cm, xd, r)
282 : cm->reference_mode;
283
284 // FIXME(rbultje) I'm pretty sure this breaks segmentation ref frame coding 286 // FIXME(rbultje) I'm pretty sure this breaks segmentation ref frame coding
285 if (mode == COMPOUND_REFERENCE) { 287 if (mode == COMPOUND_REFERENCE) {
286 const int idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref]; 288 const int idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref];
287 const int ctx = vp9_get_pred_context_comp_ref_p(cm, xd); 289 const int ctx = vp9_get_pred_context_comp_ref_p(cm, xd);
288 const int bit = vp9_read(r, fc->comp_ref_prob[ctx]); 290 const int bit = vp9_read(r, fc->comp_ref_prob[ctx]);
289 if (!cm->frame_parallel_decoding_mode) 291 if (!cm->frame_parallel_decoding_mode)
290 ++counts->comp_ref[ctx][bit]; 292 ++counts->comp_ref[ctx][bit];
291 ref_frame[idx] = cm->comp_fixed_ref; 293 ref_frame[idx] = cm->comp_fixed_ref;
292 ref_frame[!idx] = cm->comp_var_ref[bit]; 294 ref_frame[!idx] = cm->comp_var_ref[bit];
293 } else if (mode == SINGLE_REFERENCE) { 295 } else if (mode == SINGLE_REFERENCE) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (num_4x4_w == 2) 351 if (num_4x4_w == 2)
350 mi->bmi[ib + 1].as_mode = b_mode; 352 mi->bmi[ib + 1].as_mode = b_mode;
351 } 353 }
352 } 354 }
353 mbmi->mode = mi->bmi[3].as_mode; 355 mbmi->mode = mi->bmi[3].as_mode;
354 } 356 }
355 357
356 mbmi->uv_mode = read_intra_mode_uv(cm, r, mbmi->mode); 358 mbmi->uv_mode = read_intra_mode_uv(cm, r, mbmi->mode);
357 } 359 }
358 360
361 static INLINE int is_mv_valid(const MV *mv) {
362 return mv->row > MV_LOW && mv->row < MV_UPP &&
363 mv->col > MV_LOW && mv->col < MV_UPP;
364 }
365
359 static INLINE int assign_mv(VP9_COMMON *cm, MB_PREDICTION_MODE mode, 366 static INLINE int assign_mv(VP9_COMMON *cm, MB_PREDICTION_MODE mode,
360 int_mv mv[2], int_mv ref_mv[2], 367 int_mv mv[2], int_mv ref_mv[2],
361 int_mv nearest_mv[2], int_mv near_mv[2], 368 int_mv nearest_mv[2], int_mv near_mv[2],
362 int is_compound, int allow_hp, vp9_reader *r) { 369 int is_compound, int allow_hp, vp9_reader *r) {
363 int i; 370 int i;
364 int ret = 1; 371 int ret = 1;
365 372
366 switch (mode) { 373 switch (mode) {
367 case NEWMV: { 374 case NEWMV: {
368 nmv_context_counts *const mv_counts = cm->frame_parallel_decoding_mode ? 375 nmv_context_counts *const mv_counts = cm->frame_parallel_decoding_mode ?
369 NULL : &cm->counts.mv; 376 NULL : &cm->counts.mv;
370 read_mv(r, &mv[0].as_mv, &ref_mv[0].as_mv,
371 &cm->fc.nmvc, mv_counts, allow_hp);
372 if (is_compound)
373 read_mv(r, &mv[1].as_mv, &ref_mv[1].as_mv,
374 &cm->fc.nmvc, mv_counts, allow_hp);
375 for (i = 0; i < 1 + is_compound; ++i) { 377 for (i = 0; i < 1 + is_compound; ++i) {
376 ret = ret && mv[i].as_mv.row < MV_UPP && mv[i].as_mv.row > MV_LOW; 378 read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, &cm->fc.nmvc, mv_counts,
377 ret = ret && mv[i].as_mv.col < MV_UPP && mv[i].as_mv.col > MV_LOW; 379 allow_hp);
380 ret = ret && is_mv_valid(&mv[i].as_mv);
378 } 381 }
379 break; 382 break;
380 } 383 }
381 case NEARESTMV: { 384 case NEARESTMV: {
382 mv[0].as_int = nearest_mv[0].as_int; 385 mv[0].as_int = nearest_mv[0].as_int;
383 if (is_compound) 386 if (is_compound)
384 mv[1].as_int = nearest_mv[1].as_int; 387 mv[1].as_int = nearest_mv[1].as_int;
385 break; 388 break;
386 } 389 }
387 case NEARMV: { 390 case NEARMV: {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 } 535 }
533 536
534 void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd, 537 void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd,
535 const TileInfo *const tile, 538 const TileInfo *const tile,
536 int mi_row, int mi_col, vp9_reader *r) { 539 int mi_row, int mi_col, vp9_reader *r) {
537 if (frame_is_intra_only(cm)) 540 if (frame_is_intra_only(cm))
538 read_intra_frame_mode_info(cm, xd, mi_row, mi_col, r); 541 read_intra_frame_mode_info(cm, xd, mi_row, mi_col, r);
539 else 542 else
540 read_inter_frame_mode_info(cm, xd, tile, mi_row, mi_col, r); 543 read_inter_frame_mode_info(cm, xd, tile, mi_row, mi_col, r);
541 } 544 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_decodeframe.c ('k') | source/libvpx/vp9/decoder/vp9_onyxd.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698