Home | History | Annotate | Download | only in common
      1 /*
      2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
      3  *
      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
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #ifndef VP9_COMMON_VP9_RECONINTER_H_
     12 #define VP9_COMMON_VP9_RECONINTER_H_
     13 
     14 #include "vpx/vpx_integer.h"
     15 #include "vp9/common/vp9_onyxc_int.h"
     16 
     17 struct subpix_fn_table;
     18 void vp9_build_inter_predictors_sby(MACROBLOCKD *xd, int mi_row, int mi_col,
     19                                     BLOCK_SIZE bsize);
     20 
     21 void vp9_build_inter_predictors_sbuv(MACROBLOCKD *xd, int mi_row, int mi_col,
     22                                      BLOCK_SIZE bsize);
     23 
     24 void vp9_build_inter_predictors_sb(MACROBLOCKD *xd, int mi_row, int mi_col,
     25                                    BLOCK_SIZE bsize);
     26 
     27 void vp9_setup_interp_filters(MACROBLOCKD *xd,
     28                               INTERPOLATION_TYPE filter,
     29                               VP9_COMMON *cm);
     30 
     31 void vp9_build_inter_predictor(const uint8_t *src, int src_stride,
     32                                uint8_t *dst, int dst_stride,
     33                                const MV *mv_q3,
     34                                const struct scale_factors *scale,
     35                                int w, int h, int do_avg,
     36                                const struct subpix_fn_table *subpix,
     37                                enum mv_precision precision);
     38 
     39 static int scaled_buffer_offset(int x_offset, int y_offset, int stride,
     40                                 const struct scale_factors *scale) {
     41   const int x = scale ? scale->sfc->scale_value_x(x_offset, scale->sfc) :
     42       x_offset;
     43   const int y = scale ? scale->sfc->scale_value_y(y_offset, scale->sfc) :
     44       y_offset;
     45   return y * stride + x;
     46 }
     47 
     48 static void setup_pred_plane(struct buf_2d *dst,
     49                              uint8_t *src, int stride,
     50                              int mi_row, int mi_col,
     51                              const struct scale_factors *scale,
     52                              int subsampling_x, int subsampling_y) {
     53   const int x = (MI_SIZE * mi_col) >> subsampling_x;
     54   const int y = (MI_SIZE * mi_row) >> subsampling_y;
     55   dst->buf = src + scaled_buffer_offset(x, y, stride, scale);
     56   dst->stride = stride;
     57 }
     58 
     59 // TODO(jkoleszar): audit all uses of this that don't set mb_row, mb_col
     60 static void setup_dst_planes(MACROBLOCKD *xd,
     61                              const YV12_BUFFER_CONFIG *src,
     62                              int mi_row, int mi_col) {
     63   uint8_t *buffers[4] = {src->y_buffer, src->u_buffer, src->v_buffer,
     64                          src->alpha_buffer};
     65   int strides[4] = {src->y_stride, src->uv_stride, src->uv_stride,
     66                     src->alpha_stride};
     67   int i;
     68 
     69   for (i = 0; i < MAX_MB_PLANE; ++i) {
     70     struct macroblockd_plane *pd = &xd->plane[i];
     71     setup_pred_plane(&pd->dst, buffers[i], strides[i], mi_row, mi_col, NULL,
     72                      pd->subsampling_x, pd->subsampling_y);
     73   }
     74 }
     75 
     76 static void setup_pre_planes(MACROBLOCKD *xd, int i,
     77                              const YV12_BUFFER_CONFIG *src,
     78                              int mi_row, int mi_col,
     79                              const struct scale_factors *sf) {
     80   if (src) {
     81     int j;
     82     uint8_t* buffers[4] = {src->y_buffer, src->u_buffer, src->v_buffer,
     83                            src->alpha_buffer};
     84     int strides[4] = {src->y_stride, src->uv_stride, src->uv_stride,
     85                       src->alpha_stride};
     86 
     87     for (j = 0; j < MAX_MB_PLANE; ++j) {
     88       struct macroblockd_plane *pd = &xd->plane[j];
     89       setup_pred_plane(&pd->pre[i], buffers[j], strides[j],
     90                      mi_row, mi_col, sf, pd->subsampling_x, pd->subsampling_y);
     91     }
     92   }
     93 }
     94 
     95 static void set_scale_factors(MACROBLOCKD *xd, int ref0, int ref1,
     96                               struct scale_factors sf[MAX_REF_FRAMES]) {
     97   xd->scale_factor[0] = sf[ref0 >= 0 ? ref0 : 0];
     98   xd->scale_factor[1] = sf[ref1 >= 0 ? ref1 : 0];
     99 }
    100 
    101 void vp9_setup_scale_factors(VP9_COMMON *cm, int i);
    102 
    103 #endif  // VP9_COMMON_VP9_RECONINTER_H_
    104