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                               INTERPOLATIONFILTERTYPE 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->scale_value_x(x_offset, scale) : x_offset;
     42   const int y = scale ? scale->scale_value_y(y_offset, scale) : y_offset;
     43   return y * stride + x;
     44 }
     45 
     46 static void setup_pred_plane(struct buf_2d *dst,
     47                              uint8_t *src, int stride,
     48                              int mi_row, int mi_col,
     49                              const struct scale_factors *scale,
     50                              int subsampling_x, int subsampling_y) {
     51   const int x = (MI_SIZE * mi_col) >> subsampling_x;
     52   const int y = (MI_SIZE * mi_row) >> subsampling_y;
     53   dst->buf = src + scaled_buffer_offset(x, y, stride, scale);
     54   dst->stride = stride;
     55 }
     56 
     57 // TODO(jkoleszar): audit all uses of this that don't set mb_row, mb_col
     58 static void setup_dst_planes(MACROBLOCKD *xd,
     59                              const YV12_BUFFER_CONFIG *src,
     60                              int mi_row, int mi_col) {
     61   uint8_t *buffers[4] = {src->y_buffer, src->u_buffer, src->v_buffer,
     62                          src->alpha_buffer};
     63   int strides[4] = {src->y_stride, src->uv_stride, src->uv_stride,
     64                     src->alpha_stride};
     65   int i;
     66 
     67   for (i = 0; i < MAX_MB_PLANE; ++i) {
     68     struct macroblockd_plane *pd = &xd->plane[i];
     69     setup_pred_plane(&pd->dst, buffers[i], strides[i], mi_row, mi_col, NULL,
     70                      pd->subsampling_x, pd->subsampling_y);
     71   }
     72 }
     73 
     74 static void setup_pre_planes(MACROBLOCKD *xd, int i,
     75                              const YV12_BUFFER_CONFIG *src,
     76                              int mi_row, int mi_col,
     77                              const struct scale_factors *sf) {
     78   if (src) {
     79     int j;
     80     uint8_t* buffers[4] = {src->y_buffer, src->u_buffer, src->v_buffer,
     81                            src->alpha_buffer};
     82     int strides[4] = {src->y_stride, src->uv_stride, src->uv_stride,
     83                       src->alpha_stride};
     84 
     85     for (j = 0; j < MAX_MB_PLANE; ++j) {
     86       struct macroblockd_plane *pd = &xd->plane[j];
     87       setup_pred_plane(&pd->pre[i], buffers[j], strides[j],
     88                      mi_row, mi_col, sf, pd->subsampling_x, pd->subsampling_y);
     89     }
     90   }
     91 }
     92 
     93 static void set_scale_factors(MACROBLOCKD *xd, int ref0, int ref1,
     94                               struct scale_factors sf[MAX_REF_FRAMES]) {
     95   xd->scale_factor[0] = sf[ref0 >= 0 ? ref0 : 0];
     96   xd->scale_factor[1] = sf[ref1 >= 0 ? ref1 : 0];
     97 }
     98 
     99 void vp9_setup_scale_factors(VP9_COMMON *cm, int i);
    100 
    101 #endif  // VP9_COMMON_VP9_RECONINTER_H_
    102