michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: #ifndef VP9_COMMON_VP9_RECONINTER_H_ michael@0: #define VP9_COMMON_VP9_RECONINTER_H_ michael@0: michael@0: #include "vpx/vpx_integer.h" michael@0: #include "vp9/common/vp9_onyxc_int.h" michael@0: michael@0: struct subpix_fn_table; michael@0: void vp9_build_inter_predictors_sby(MACROBLOCKD *xd, int mi_row, int mi_col, michael@0: BLOCK_SIZE bsize); michael@0: michael@0: void vp9_build_inter_predictors_sbuv(MACROBLOCKD *xd, int mi_row, int mi_col, michael@0: BLOCK_SIZE bsize); michael@0: michael@0: void vp9_build_inter_predictors_sb(MACROBLOCKD *xd, int mi_row, int mi_col, michael@0: BLOCK_SIZE bsize); michael@0: michael@0: void vp9_setup_interp_filters(MACROBLOCKD *xd, michael@0: INTERPOLATION_TYPE filter, michael@0: VP9_COMMON *cm); michael@0: michael@0: void vp9_build_inter_predictor(const uint8_t *src, int src_stride, michael@0: uint8_t *dst, int dst_stride, michael@0: const MV *mv_q3, michael@0: const struct scale_factors *scale, michael@0: int w, int h, int do_avg, michael@0: const struct subpix_fn_table *subpix, michael@0: enum mv_precision precision); michael@0: michael@0: static int scaled_buffer_offset(int x_offset, int y_offset, int stride, michael@0: const struct scale_factors *scale) { michael@0: const int x = scale ? scale->sfc->scale_value_x(x_offset, scale->sfc) : michael@0: x_offset; michael@0: const int y = scale ? scale->sfc->scale_value_y(y_offset, scale->sfc) : michael@0: y_offset; michael@0: return y * stride + x; michael@0: } michael@0: michael@0: static void setup_pred_plane(struct buf_2d *dst, michael@0: uint8_t *src, int stride, michael@0: int mi_row, int mi_col, michael@0: const struct scale_factors *scale, michael@0: int subsampling_x, int subsampling_y) { michael@0: const int x = (MI_SIZE * mi_col) >> subsampling_x; michael@0: const int y = (MI_SIZE * mi_row) >> subsampling_y; michael@0: dst->buf = src + scaled_buffer_offset(x, y, stride, scale); michael@0: dst->stride = stride; michael@0: } michael@0: michael@0: // TODO(jkoleszar): audit all uses of this that don't set mb_row, mb_col michael@0: static void setup_dst_planes(MACROBLOCKD *xd, michael@0: const YV12_BUFFER_CONFIG *src, michael@0: int mi_row, int mi_col) { michael@0: uint8_t *buffers[4] = {src->y_buffer, src->u_buffer, src->v_buffer, michael@0: src->alpha_buffer}; michael@0: int strides[4] = {src->y_stride, src->uv_stride, src->uv_stride, michael@0: src->alpha_stride}; michael@0: int i; michael@0: michael@0: for (i = 0; i < MAX_MB_PLANE; ++i) { michael@0: struct macroblockd_plane *pd = &xd->plane[i]; michael@0: setup_pred_plane(&pd->dst, buffers[i], strides[i], mi_row, mi_col, NULL, michael@0: pd->subsampling_x, pd->subsampling_y); michael@0: } michael@0: } michael@0: michael@0: static void setup_pre_planes(MACROBLOCKD *xd, int i, michael@0: const YV12_BUFFER_CONFIG *src, michael@0: int mi_row, int mi_col, michael@0: const struct scale_factors *sf) { michael@0: if (src) { michael@0: int j; michael@0: uint8_t* buffers[4] = {src->y_buffer, src->u_buffer, src->v_buffer, michael@0: src->alpha_buffer}; michael@0: int strides[4] = {src->y_stride, src->uv_stride, src->uv_stride, michael@0: src->alpha_stride}; michael@0: michael@0: for (j = 0; j < MAX_MB_PLANE; ++j) { michael@0: struct macroblockd_plane *pd = &xd->plane[j]; michael@0: setup_pred_plane(&pd->pre[i], buffers[j], strides[j], michael@0: mi_row, mi_col, sf, pd->subsampling_x, pd->subsampling_y); michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void set_scale_factors(MACROBLOCKD *xd, int ref0, int ref1, michael@0: struct scale_factors sf[MAX_REF_FRAMES]) { michael@0: xd->scale_factor[0] = sf[ref0 >= 0 ? ref0 : 0]; michael@0: xd->scale_factor[1] = sf[ref1 >= 0 ? ref1 : 0]; michael@0: } michael@0: michael@0: void vp9_setup_scale_factors(VP9_COMMON *cm, int i); michael@0: michael@0: #endif // VP9_COMMON_VP9_RECONINTER_H_