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 "vp9/common/vp9_filter.h"
15 #include "vp9/common/vp9_onyxc_int.h"
16 #include "vpx/vpx_integer.h"
17 #include "vpx_dsp/vpx_filter.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
inter_predictor(const uint8_t * src,int src_stride,uint8_t * dst,int dst_stride,const int subpel_x,const int subpel_y,const struct scale_factors * sf,int w,int h,int ref,const InterpKernel * kernel,int xs,int ys)23 static INLINE void inter_predictor(const uint8_t *src, int src_stride,
24                                    uint8_t *dst, int dst_stride,
25                                    const int subpel_x,
26                                    const int subpel_y,
27                                    const struct scale_factors *sf,
28                                    int w, int h, int ref,
29                                    const InterpKernel *kernel,
30                                    int xs, int ys) {
31   sf->predict[subpel_x != 0][subpel_y != 0][ref](
32       src, src_stride, dst, dst_stride,
33       kernel[subpel_x], xs, kernel[subpel_y], ys, w, h);
34 }
35 
36 #if CONFIG_VP9_HIGHBITDEPTH
37 void high_inter_predictor(const uint8_t *src, int src_stride,
38                                  uint8_t *dst, int dst_stride,
39                                  const int subpel_x,
40                                  const int subpel_y,
41                                  const struct scale_factors *sf,
42                                  int w, int h, int ref,
43                                  const InterpKernel *kernel,
44                                  int xs, int ys, int bd);
45 #endif  // CONFIG_VP9_HIGHBITDEPTH
46 
47 MV average_split_mvs(const struct macroblockd_plane *pd, const MODE_INFO *mi,
48                      int ref, int block);
49 
50 MV clamp_mv_to_umv_border_sb(const MACROBLOCKD *xd, const MV *src_mv,
51                              int bw, int bh, int ss_x, int ss_y);
52 
53 void vp9_build_inter_predictors_sby(MACROBLOCKD *xd, int mi_row, int mi_col,
54                                     BLOCK_SIZE bsize);
55 
56 void vp9_build_inter_predictors_sbp(MACROBLOCKD *xd, int mi_row, int mi_col,
57                                     BLOCK_SIZE bsize, int plane);
58 
59 void vp9_build_inter_predictors_sbuv(MACROBLOCKD *xd, int mi_row, int mi_col,
60                                      BLOCK_SIZE bsize);
61 
62 void vp9_build_inter_predictors_sb(MACROBLOCKD *xd, int mi_row, int mi_col,
63                                    BLOCK_SIZE bsize);
64 
65 void vp9_build_inter_predictor(const uint8_t *src, int src_stride,
66                                uint8_t *dst, int dst_stride,
67                                const MV *mv_q3,
68                                const struct scale_factors *sf,
69                                int w, int h, int do_avg,
70                                const InterpKernel *kernel,
71                                enum mv_precision precision,
72                                int x, int y);
73 
74 #if CONFIG_VP9_HIGHBITDEPTH
75 void vp9_highbd_build_inter_predictor(const uint8_t *src, int src_stride,
76                                       uint8_t *dst, int dst_stride,
77                                       const MV *mv_q3,
78                                       const struct scale_factors *sf,
79                                       int w, int h, int do_avg,
80                                       const InterpKernel *kernel,
81                                       enum mv_precision precision,
82                                       int x, int y, int bd);
83 #endif
84 
scaled_buffer_offset(int x_offset,int y_offset,int stride,const struct scale_factors * sf)85 static INLINE int scaled_buffer_offset(int x_offset, int y_offset, int stride,
86                                        const struct scale_factors *sf) {
87   const int x = sf ? sf->scale_value_x(x_offset, sf) : x_offset;
88   const int y = sf ? sf->scale_value_y(y_offset, sf) : y_offset;
89   return y * stride + x;
90 }
91 
setup_pred_plane(struct buf_2d * dst,uint8_t * src,int stride,int mi_row,int mi_col,const struct scale_factors * scale,int subsampling_x,int subsampling_y)92 static INLINE void setup_pred_plane(struct buf_2d *dst,
93                                     uint8_t *src, int stride,
94                                     int mi_row, int mi_col,
95                                     const struct scale_factors *scale,
96                                     int subsampling_x, int subsampling_y) {
97   const int x = (MI_SIZE * mi_col) >> subsampling_x;
98   const int y = (MI_SIZE * mi_row) >> subsampling_y;
99   dst->buf = src + scaled_buffer_offset(x, y, stride, scale);
100   dst->stride = stride;
101 }
102 
103 void vp9_setup_dst_planes(struct macroblockd_plane planes[MAX_MB_PLANE],
104                           const YV12_BUFFER_CONFIG *src,
105                           int mi_row, int mi_col);
106 
107 void vp9_setup_pre_planes(MACROBLOCKD *xd, int idx,
108                           const YV12_BUFFER_CONFIG *src, int mi_row, int mi_col,
109                           const struct scale_factors *sf);
110 
111 #ifdef __cplusplus
112 }  // extern "C"
113 #endif
114 
115 #endif  // VP9_COMMON_VP9_RECONINTER_H_
116