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 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 ref_row += src_stride; | 62 ref_row += src_stride; |
63 } while (--b_h); | 63 } while (--b_h); |
64 } | 64 } |
65 | 65 |
66 static void inter_predictor(const uint8_t *src, int src_stride, | 66 static void inter_predictor(const uint8_t *src, int src_stride, |
67 uint8_t *dst, int dst_stride, | 67 uint8_t *dst, int dst_stride, |
68 const int subpel_x, | 68 const int subpel_x, |
69 const int subpel_y, | 69 const int subpel_y, |
70 const struct scale_factors *sf, | 70 const struct scale_factors *sf, |
71 int w, int h, int ref, | 71 int w, int h, int ref, |
72 const interp_kernel *kernel, | 72 const InterpKernel *kernel, |
73 int xs, int ys) { | 73 int xs, int ys) { |
74 sf->predict[subpel_x != 0][subpel_y != 0][ref]( | 74 sf->predict[subpel_x != 0][subpel_y != 0][ref]( |
75 src, src_stride, dst, dst_stride, | 75 src, src_stride, dst, dst_stride, |
76 kernel[subpel_x], xs, kernel[subpel_y], ys, w, h); | 76 kernel[subpel_x], xs, kernel[subpel_y], ys, w, h); |
77 } | 77 } |
78 | 78 |
79 void vp9_build_inter_predictor(const uint8_t *src, int src_stride, | 79 void vp9_build_inter_predictor(const uint8_t *src, int src_stride, |
80 uint8_t *dst, int dst_stride, | 80 uint8_t *dst, int dst_stride, |
81 const MV *src_mv, | 81 const MV *src_mv, |
82 const struct scale_factors *sf, | 82 const struct scale_factors *sf, |
83 int w, int h, int ref, | 83 int w, int h, int ref, |
84 const interp_kernel *kernel, | 84 const InterpKernel *kernel, |
85 enum mv_precision precision, | 85 enum mv_precision precision, |
86 int x, int y) { | 86 int x, int y) { |
87 const int is_q4 = precision == MV_PRECISION_Q4; | 87 const int is_q4 = precision == MV_PRECISION_Q4; |
88 const MV mv_q4 = { is_q4 ? src_mv->row : src_mv->row * 2, | 88 const MV mv_q4 = { is_q4 ? src_mv->row : src_mv->row * 2, |
89 is_q4 ? src_mv->col : src_mv->col * 2 }; | 89 is_q4 ? src_mv->col : src_mv->col * 2 }; |
90 MV32 mv = vp9_scale_mv(&mv_q4, x, y, sf); | 90 MV32 mv = vp9_scale_mv(&mv_q4, x, y, sf); |
91 const int subpel_x = mv.col & SUBPEL_MASK; | 91 const int subpel_x = mv.col & SUBPEL_MASK; |
92 const int subpel_y = mv.row & SUBPEL_MASK; | 92 const int subpel_y = mv.row & SUBPEL_MASK; |
93 | 93 |
94 src += (mv.row >> SUBPEL_BITS) * src_stride + (mv.col >> SUBPEL_BITS); | 94 src += (mv.row >> SUBPEL_BITS) * src_stride + (mv.col >> SUBPEL_BITS); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 uint8_t *const dst = dst_buf->buf + dst_buf->stride * y + x; | 262 uint8_t *const dst = dst_buf->buf + dst_buf->stride * y + x; |
263 | 263 |
264 // TODO(jkoleszar): All chroma MVs in SPLITMV mode are taken as the | 264 // TODO(jkoleszar): All chroma MVs in SPLITMV mode are taken as the |
265 // same MV (the average of the 4 luma MVs) but we could do something | 265 // same MV (the average of the 4 luma MVs) but we could do something |
266 // smarter for non-4:2:0. Just punt for now, pending the changes to get | 266 // smarter for non-4:2:0. Just punt for now, pending the changes to get |
267 // rid of SPLITMV mode entirely. | 267 // rid of SPLITMV mode entirely. |
268 const MV mv = mi->mbmi.sb_type < BLOCK_8X8 | 268 const MV mv = mi->mbmi.sb_type < BLOCK_8X8 |
269 ? (plane == 0 ? mi->bmi[block].as_mv[ref].as_mv | 269 ? (plane == 0 ? mi->bmi[block].as_mv[ref].as_mv |
270 : mi_mv_pred_q4(mi, ref)) | 270 : mi_mv_pred_q4(mi, ref)) |
271 : mi->mbmi.mv[ref].as_mv; | 271 : mi->mbmi.mv[ref].as_mv; |
272 | |
273 // TODO(jkoleszar): This clamping is done in the incorrect place for the | |
274 // scaling case. It needs to be done on the scaled MV, not the pre-scaling | |
275 // MV. Note however that it performs the subsampling aware scaling so | |
276 // that the result is always q4. | |
277 // mv_precision precision is MV_PRECISION_Q4. | |
278 const MV mv_q4 = clamp_mv_to_umv_border_sb(xd, &mv, bw, bh, | |
279 pd->subsampling_x, | |
280 pd->subsampling_y); | |
281 | |
282 MV32 scaled_mv; | 272 MV32 scaled_mv; |
283 int xs, ys, x0, y0, x0_16, y0_16, x1, y1, frame_width, | 273 int xs, ys, x0, y0, x0_16, y0_16, frame_width, frame_height, buf_stride, |
284 frame_height, subpel_x, subpel_y, buf_stride; | 274 subpel_x, subpel_y; |
285 uint8_t *ref_frame, *buf_ptr; | 275 uint8_t *ref_frame, *buf_ptr; |
286 const YV12_BUFFER_CONFIG *ref_buf = xd->block_refs[ref]->buf; | 276 const YV12_BUFFER_CONFIG *ref_buf = xd->block_refs[ref]->buf; |
| 277 const MV mv_q4 = { |
| 278 mv.row * (1 << (1 - pd->subsampling_y)), |
| 279 mv.col * (1 << (1 - pd->subsampling_x)) |
| 280 }; |
287 | 281 |
288 // Get reference frame pointer, width and height. | 282 // Get reference frame pointer, width and height. |
289 if (plane == 0) { | 283 if (plane == 0) { |
290 frame_width = ref_buf->y_crop_width; | 284 frame_width = ref_buf->y_crop_width; |
291 frame_height = ref_buf->y_crop_height; | 285 frame_height = ref_buf->y_crop_height; |
292 ref_frame = ref_buf->y_buffer; | 286 ref_frame = ref_buf->y_buffer; |
293 } else { | 287 } else { |
294 frame_width = ref_buf->uv_crop_width; | 288 frame_width = ref_buf->uv_crop_width; |
295 frame_height = ref_buf->uv_crop_height; | 289 frame_height = ref_buf->uv_crop_height; |
296 ref_frame = plane == 1 ? ref_buf->u_buffer : ref_buf->v_buffer; | 290 ref_frame = plane == 1 ? ref_buf->u_buffer : ref_buf->v_buffer; |
(...skipping 23 matching lines...) Expand all Loading... |
320 } | 314 } |
321 subpel_x = scaled_mv.col & SUBPEL_MASK; | 315 subpel_x = scaled_mv.col & SUBPEL_MASK; |
322 subpel_y = scaled_mv.row & SUBPEL_MASK; | 316 subpel_y = scaled_mv.row & SUBPEL_MASK; |
323 | 317 |
324 // Calculate the top left corner of the best matching block in the reference
frame. | 318 // Calculate the top left corner of the best matching block in the reference
frame. |
325 x0 += scaled_mv.col >> SUBPEL_BITS; | 319 x0 += scaled_mv.col >> SUBPEL_BITS; |
326 y0 += scaled_mv.row >> SUBPEL_BITS; | 320 y0 += scaled_mv.row >> SUBPEL_BITS; |
327 x0_16 += scaled_mv.col; | 321 x0_16 += scaled_mv.col; |
328 y0_16 += scaled_mv.row; | 322 y0_16 += scaled_mv.row; |
329 | 323 |
330 // Get reference block bottom right coordinate. | |
331 x1 = ((x0_16 + (w - 1) * xs) >> SUBPEL_BITS) + 1; | |
332 y1 = ((y0_16 + (h - 1) * ys) >> SUBPEL_BITS) + 1; | |
333 | |
334 // Get reference block pointer. | 324 // Get reference block pointer. |
335 buf_ptr = ref_frame + y0 * pre_buf->stride + x0; | 325 buf_ptr = ref_frame + y0 * pre_buf->stride + x0; |
336 buf_stride = pre_buf->stride; | 326 buf_stride = pre_buf->stride; |
337 | 327 |
338 // Do border extension if there is motion or the | 328 // Do border extension if there is motion or the |
339 // width/height is not a multiple of 8 pixels. | 329 // width/height is not a multiple of 8 pixels. |
340 if (scaled_mv.col || scaled_mv.row || | 330 if (scaled_mv.col || scaled_mv.row || |
341 (frame_width & 0x7) || (frame_height & 0x7)) { | 331 (frame_width & 0x7) || (frame_height & 0x7)) { |
| 332 // Get reference block bottom right coordinate. |
| 333 int x1 = ((x0_16 + (w - 1) * xs) >> SUBPEL_BITS) + 1; |
| 334 int y1 = ((y0_16 + (h - 1) * ys) >> SUBPEL_BITS) + 1; |
342 int x_pad = 0, y_pad = 0; | 335 int x_pad = 0, y_pad = 0; |
343 | 336 |
344 if (subpel_x || (sf->x_step_q4 & SUBPEL_MASK)) { | 337 if (subpel_x || (sf->x_step_q4 & SUBPEL_MASK)) { |
345 x0 -= VP9_INTERP_EXTEND - 1; | 338 x0 -= VP9_INTERP_EXTEND - 1; |
346 x1 += VP9_INTERP_EXTEND; | 339 x1 += VP9_INTERP_EXTEND; |
347 x_pad = 1; | 340 x_pad = 1; |
348 } | 341 } |
349 | 342 |
350 if (subpel_y || (sf->y_step_q4 & SUBPEL_MASK)) { | 343 if (subpel_y || (sf->y_step_q4 & SUBPEL_MASK)) { |
351 y0 -= VP9_INTERP_EXTEND - 1; | 344 y0 -= VP9_INTERP_EXTEND - 1; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 for (y = 0; y < num_4x4_h; ++y) | 382 for (y = 0; y < num_4x4_h; ++y) |
390 for (x = 0; x < num_4x4_w; ++x) | 383 for (x = 0; x < num_4x4_w; ++x) |
391 dec_build_inter_predictors(xd, plane, i++, bw, bh, | 384 dec_build_inter_predictors(xd, plane, i++, bw, bh, |
392 4 * x, 4 * y, 4, 4, mi_x, mi_y); | 385 4 * x, 4 * y, 4, 4, mi_x, mi_y); |
393 } else { | 386 } else { |
394 dec_build_inter_predictors(xd, plane, 0, bw, bh, | 387 dec_build_inter_predictors(xd, plane, 0, bw, bh, |
395 0, 0, bw, bh, mi_x, mi_y); | 388 0, 0, bw, bh, mi_x, mi_y); |
396 } | 389 } |
397 } | 390 } |
398 } | 391 } |
OLD | NEW |