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

Side by Side Diff: source/libvpx/vp9/common/vp9_reconinter.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, 1 month 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/common/vp9_reconinter.h ('k') | source/libvpx/vp9/common/vp9_reconintra.c » ('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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 #if CONFIG_VP9_HIGHBITDEPTH 147 #if CONFIG_VP9_HIGHBITDEPTH
148 static void high_inter_predictor(const uint8_t *src, int src_stride, 148 static void high_inter_predictor(const uint8_t *src, int src_stride,
149 uint8_t *dst, int dst_stride, 149 uint8_t *dst, int dst_stride,
150 const int subpel_x, 150 const int subpel_x,
151 const int subpel_y, 151 const int subpel_y,
152 const struct scale_factors *sf, 152 const struct scale_factors *sf,
153 int w, int h, int ref, 153 int w, int h, int ref,
154 const InterpKernel *kernel, 154 const InterpKernel *kernel,
155 int xs, int ys, int bd) { 155 int xs, int ys, int bd) {
156 sf->high_predict[subpel_x != 0][subpel_y != 0][ref]( 156 sf->highbd_predict[subpel_x != 0][subpel_y != 0][ref](
157 src, src_stride, dst, dst_stride, 157 src, src_stride, dst, dst_stride,
158 kernel[subpel_x], xs, kernel[subpel_y], ys, w, h, bd); 158 kernel[subpel_x], xs, kernel[subpel_y], ys, w, h, bd);
159 } 159 }
160 160
161 void vp9_high_build_inter_predictor(const uint8_t *src, int src_stride, 161 void vp9_highbd_build_inter_predictor(const uint8_t *src, int src_stride,
162 uint8_t *dst, int dst_stride, 162 uint8_t *dst, int dst_stride,
163 const MV *src_mv, 163 const MV *src_mv,
164 const struct scale_factors *sf, 164 const struct scale_factors *sf,
165 int w, int h, int ref, 165 int w, int h, int ref,
166 const InterpKernel *kernel, 166 const InterpKernel *kernel,
167 enum mv_precision precision, 167 enum mv_precision precision,
168 int x, int y, int bd) { 168 int x, int y, int bd) {
169 const int is_q4 = precision == MV_PRECISION_Q4; 169 const int is_q4 = precision == MV_PRECISION_Q4;
170 const MV mv_q4 = { is_q4 ? src_mv->row : src_mv->row * 2, 170 const MV mv_q4 = { is_q4 ? src_mv->row : src_mv->row * 2,
171 is_q4 ? src_mv->col : src_mv->col * 2 }; 171 is_q4 ? src_mv->col : src_mv->col * 2 };
172 MV32 mv = vp9_scale_mv(&mv_q4, x, y, sf); 172 MV32 mv = vp9_scale_mv(&mv_q4, x, y, sf);
173 const int subpel_x = mv.col & SUBPEL_MASK; 173 const int subpel_x = mv.col & SUBPEL_MASK;
174 const int subpel_y = mv.row & SUBPEL_MASK; 174 const int subpel_y = mv.row & SUBPEL_MASK;
175 175
176 src += (mv.row >> SUBPEL_BITS) * src_stride + (mv.col >> SUBPEL_BITS); 176 src += (mv.row >> SUBPEL_BITS) * src_stride + (mv.col >> SUBPEL_BITS);
177 177
178 high_inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y, 178 high_inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // MV. Note however that it performs the subsampling aware scaling so 281 // MV. Note however that it performs the subsampling aware scaling so
282 // that the result is always q4. 282 // that the result is always q4.
283 // mv_precision precision is MV_PRECISION_Q4. 283 // mv_precision precision is MV_PRECISION_Q4.
284 const MV mv_q4 = clamp_mv_to_umv_border_sb(xd, &mv, bw, bh, 284 const MV mv_q4 = clamp_mv_to_umv_border_sb(xd, &mv, bw, bh,
285 pd->subsampling_x, 285 pd->subsampling_x,
286 pd->subsampling_y); 286 pd->subsampling_y);
287 287
288 uint8_t *pre; 288 uint8_t *pre;
289 MV32 scaled_mv; 289 MV32 scaled_mv;
290 int xs, ys, subpel_x, subpel_y; 290 int xs, ys, subpel_x, subpel_y;
291 const int is_scaled = vp9_is_scaled(sf);
291 292
292 if (vp9_is_scaled(sf)) { 293 if (is_scaled) {
293 pre = pre_buf->buf + scaled_buffer_offset(x, y, pre_buf->stride, sf); 294 pre = pre_buf->buf + scaled_buffer_offset(x, y, pre_buf->stride, sf);
294 scaled_mv = vp9_scale_mv(&mv_q4, mi_x + x, mi_y + y, sf); 295 scaled_mv = vp9_scale_mv(&mv_q4, mi_x + x, mi_y + y, sf);
295 xs = sf->x_step_q4; 296 xs = sf->x_step_q4;
296 ys = sf->y_step_q4; 297 ys = sf->y_step_q4;
297 } else { 298 } else {
298 pre = pre_buf->buf + (y * pre_buf->stride + x); 299 pre = pre_buf->buf + (y * pre_buf->stride + x);
299 scaled_mv.row = mv_q4.row; 300 scaled_mv.row = mv_q4.row;
300 scaled_mv.col = mv_q4.col; 301 scaled_mv.col = mv_q4.col;
301 xs = ys = 16; 302 xs = ys = 16;
302 } 303 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 379
379 for (ref = 0; ref < 1 + is_compound; ++ref) { 380 for (ref = 0; ref < 1 + is_compound; ++ref) {
380 const struct scale_factors *const sf = &xd->block_refs[ref]->sf; 381 const struct scale_factors *const sf = &xd->block_refs[ref]->sf;
381 struct buf_2d *const pre_buf = &pd->pre[ref]; 382 struct buf_2d *const pre_buf = &pd->pre[ref];
382 struct buf_2d *const dst_buf = &pd->dst; 383 struct buf_2d *const dst_buf = &pd->dst;
383 uint8_t *const dst = dst_buf->buf + dst_buf->stride * y + x; 384 uint8_t *const dst = dst_buf->buf + dst_buf->stride * y + x;
384 const MV mv = mi->mbmi.sb_type < BLOCK_8X8 385 const MV mv = mi->mbmi.sb_type < BLOCK_8X8
385 ? average_split_mvs(pd, mi, ref, block) 386 ? average_split_mvs(pd, mi, ref, block)
386 : mi->mbmi.mv[ref].as_mv; 387 : mi->mbmi.mv[ref].as_mv;
387 388
388
389 // TODO(jkoleszar): This clamping is done in the incorrect place for the
390 // scaling case. It needs to be done on the scaled MV, not the pre-scaling
391 // MV. Note however that it performs the subsampling aware scaling so
392 // that the result is always q4.
393 // mv_precision precision is MV_PRECISION_Q4.
394 const MV mv_q4 = clamp_mv_to_umv_border_sb(xd, &mv, bw, bh, 389 const MV mv_q4 = clamp_mv_to_umv_border_sb(xd, &mv, bw, bh,
395 pd->subsampling_x, 390 pd->subsampling_x,
396 pd->subsampling_y); 391 pd->subsampling_y);
397 392
398 MV32 scaled_mv; 393 MV32 scaled_mv;
399 int xs, ys, x0, y0, x0_16, y0_16, frame_width, frame_height, buf_stride, 394 int xs, ys, x0, y0, x0_16, y0_16, frame_width, frame_height, buf_stride,
400 subpel_x, subpel_y; 395 subpel_x, subpel_y;
401 uint8_t *ref_frame, *buf_ptr; 396 uint8_t *ref_frame, *buf_ptr;
402 const YV12_BUFFER_CONFIG *ref_buf = xd->block_refs[ref]->buf; 397 const YV12_BUFFER_CONFIG *ref_buf = xd->block_refs[ref]->buf;
398 const int is_scaled = vp9_is_scaled(sf);
403 399
404 // Get reference frame pointer, width and height. 400 // Get reference frame pointer, width and height.
405 if (plane == 0) { 401 if (plane == 0) {
406 frame_width = ref_buf->y_crop_width; 402 frame_width = ref_buf->y_crop_width;
407 frame_height = ref_buf->y_crop_height; 403 frame_height = ref_buf->y_crop_height;
408 ref_frame = ref_buf->y_buffer; 404 ref_frame = ref_buf->y_buffer;
409 } else { 405 } else {
410 frame_width = ref_buf->uv_crop_width; 406 frame_width = ref_buf->uv_crop_width;
411 frame_height = ref_buf->uv_crop_height; 407 frame_height = ref_buf->uv_crop_height;
412 ref_frame = plane == 1 ? ref_buf->u_buffer : ref_buf->v_buffer; 408 ref_frame = plane == 1 ? ref_buf->u_buffer : ref_buf->v_buffer;
413 } 409 }
414 410
415 if (vp9_is_scaled(sf)) { 411 if (is_scaled) {
416 // Co-ordinate of containing block to pixel precision. 412 // Co-ordinate of containing block to pixel precision.
417 int x_start = (-xd->mb_to_left_edge >> (3 + pd->subsampling_x)); 413 int x_start = (-xd->mb_to_left_edge >> (3 + pd->subsampling_x));
418 int y_start = (-xd->mb_to_top_edge >> (3 + pd->subsampling_y)); 414 int y_start = (-xd->mb_to_top_edge >> (3 + pd->subsampling_y));
419 415
420 // Co-ordinate of the block to 1/16th pixel precision. 416 // Co-ordinate of the block to 1/16th pixel precision.
421 x0_16 = (x_start + x) << SUBPEL_BITS; 417 x0_16 = (x_start + x) << SUBPEL_BITS;
422 y0_16 = (y_start + y) << SUBPEL_BITS; 418 y0_16 = (y_start + y) << SUBPEL_BITS;
423 419
424 // Co-ordinate of current block in reference frame 420 // Co-ordinate of current block in reference frame
425 // to 1/16th pixel precision. 421 // to 1/16th pixel precision.
(...skipping 18 matching lines...) Expand all
444 x0_16 = x0 << SUBPEL_BITS; 440 x0_16 = x0 << SUBPEL_BITS;
445 y0_16 = y0 << SUBPEL_BITS; 441 y0_16 = y0 << SUBPEL_BITS;
446 442
447 scaled_mv.row = mv_q4.row; 443 scaled_mv.row = mv_q4.row;
448 scaled_mv.col = mv_q4.col; 444 scaled_mv.col = mv_q4.col;
449 xs = ys = 16; 445 xs = ys = 16;
450 } 446 }
451 subpel_x = scaled_mv.col & SUBPEL_MASK; 447 subpel_x = scaled_mv.col & SUBPEL_MASK;
452 subpel_y = scaled_mv.row & SUBPEL_MASK; 448 subpel_y = scaled_mv.row & SUBPEL_MASK;
453 449
454 // Calculate the top left corner of the best matching block in the reference frame. 450 // Calculate the top left corner of the best matching block in the
451 // reference frame.
455 x0 += scaled_mv.col >> SUBPEL_BITS; 452 x0 += scaled_mv.col >> SUBPEL_BITS;
456 y0 += scaled_mv.row >> SUBPEL_BITS; 453 y0 += scaled_mv.row >> SUBPEL_BITS;
457 x0_16 += scaled_mv.col; 454 x0_16 += scaled_mv.col;
458 y0_16 += scaled_mv.row; 455 y0_16 += scaled_mv.row;
459 456
460 // Get reference block pointer. 457 // Get reference block pointer.
461 buf_ptr = ref_frame + y0 * pre_buf->stride + x0; 458 buf_ptr = ref_frame + y0 * pre_buf->stride + x0;
462 buf_stride = pre_buf->stride; 459 buf_stride = pre_buf->stride;
463 460
464 // Do border extension if there is motion or the 461 // Do border extension if there is motion or the
465 // width/height is not a multiple of 8 pixels. 462 // width/height is not a multiple of 8 pixels.
466 if (scaled_mv.col || scaled_mv.row || 463 if (is_scaled || scaled_mv.col || scaled_mv.row ||
467 (frame_width & 0x7) || (frame_height & 0x7)) { 464 (frame_width & 0x7) || (frame_height & 0x7)) {
468 // Get reference block bottom right coordinate. 465 // Get reference block bottom right coordinate.
469 int x1 = ((x0_16 + (w - 1) * xs) >> SUBPEL_BITS) + 1; 466 int x1 = ((x0_16 + (w - 1) * xs) >> SUBPEL_BITS) + 1;
470 int y1 = ((y0_16 + (h - 1) * ys) >> SUBPEL_BITS) + 1; 467 int y1 = ((y0_16 + (h - 1) * ys) >> SUBPEL_BITS) + 1;
471 int x_pad = 0, y_pad = 0; 468 int x_pad = 0, y_pad = 0;
472 469
473 if (subpel_x || (sf->x_step_q4 & SUBPEL_MASK)) { 470 if (subpel_x || (sf->x_step_q4 != SUBPEL_SHIFTS)) {
474 x0 -= VP9_INTERP_EXTEND - 1; 471 x0 -= VP9_INTERP_EXTEND - 1;
475 x1 += VP9_INTERP_EXTEND; 472 x1 += VP9_INTERP_EXTEND;
476 x_pad = 1; 473 x_pad = 1;
477 } 474 }
478 475
479 if (subpel_y || (sf->y_step_q4 & SUBPEL_MASK)) { 476 if (subpel_y || (sf->y_step_q4 != SUBPEL_SHIFTS)) {
480 y0 -= VP9_INTERP_EXTEND - 1; 477 y0 -= VP9_INTERP_EXTEND - 1;
481 y1 += VP9_INTERP_EXTEND; 478 y1 += VP9_INTERP_EXTEND;
482 y_pad = 1; 479 y_pad = 1;
483 } 480 }
484 481
485 // Skip border extension if block is inside the frame. 482 // Skip border extension if block is inside the frame.
486 if (x0 < 0 || x0 > frame_width - 1 || x1 < 0 || x1 > frame_width - 1 || 483 if (x0 < 0 || x0 > frame_width - 1 || x1 < 0 || x1 > frame_width - 1 ||
487 y0 < 0 || y0 > frame_height - 1 || y1 < 0 || y1 > frame_height - 1) { 484 y0 < 0 || y0 > frame_height - 1 || y1 < 0 || y1 > frame_height - 1) {
488 uint8_t *buf_ptr1 = ref_frame + y0 * pre_buf->stride + x0; 485 uint8_t *buf_ptr1 = ref_frame + y0 * pre_buf->stride + x0;
489 // Extend the border. 486 // Extend the border.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 const int strides[4] = {src->y_stride, src->uv_stride, src->uv_stride, 599 const int strides[4] = {src->y_stride, src->uv_stride, src->uv_stride,
603 src->alpha_stride}; 600 src->alpha_stride};
604 601
605 for (i = 0; i < MAX_MB_PLANE; ++i) { 602 for (i = 0; i < MAX_MB_PLANE; ++i) {
606 struct macroblockd_plane *const pd = &xd->plane[i]; 603 struct macroblockd_plane *const pd = &xd->plane[i];
607 setup_pred_plane(&pd->pre[idx], buffers[i], strides[i], mi_row, mi_col, 604 setup_pred_plane(&pd->pre[idx], buffers[i], strides[i], mi_row, mi_col,
608 sf, pd->subsampling_x, pd->subsampling_y); 605 sf, pd->subsampling_x, pd->subsampling_y);
609 } 606 }
610 } 607 }
611 } 608 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/vp9_reconinter.h ('k') | source/libvpx/vp9/common/vp9_reconintra.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698