Home | History | Annotate | Download | only in encoder
      1 /*
      2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
      3  *
      4  * This source code is subject to the terms of the BSD 2 Clause License and
      5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
      6  * was not distributed with this source code in the LICENSE file, you can
      7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
      8  * Media Patent License 1.0 was not distributed with this source code in the
      9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
     10  */
     11 
     12 #ifndef AOM_AV1_ENCODER_RECONINTER_ENC_H_
     13 #define AOM_AV1_ENCODER_RECONINTER_ENC_H_
     14 
     15 #include "aom/aom_integer.h"
     16 #include "av1/common/filter.h"
     17 #include "av1/common/blockd.h"
     18 #include "av1/common/onyxc_int.h"
     19 #include "av1/common/convolve.h"
     20 #include "av1/common/warped_motion.h"
     21 
     22 #ifdef __cplusplus
     23 extern "C" {
     24 #endif
     25 
     26 void av1_enc_build_inter_predictor(const AV1_COMMON *cm, MACROBLOCKD *xd,
     27                                    int mi_row, int mi_col,
     28                                    const BUFFER_SET *ctx, BLOCK_SIZE bsize,
     29                                    int plane_from, int plane_to);
     30 
     31 void av1_build_inter_predictor(const uint8_t *src, int src_stride, uint8_t *dst,
     32                                int dst_stride, const MV *src_mv,
     33                                const struct scale_factors *sf, int w, int h,
     34                                ConvolveParams *conv_params,
     35                                InterpFilters interp_filters,
     36                                const WarpTypesAllowed *warp_types, int p_col,
     37                                int p_row, int plane, int ref,
     38                                mv_precision precision, int x, int y,
     39                                const MACROBLOCKD *xd, int can_use_previous);
     40 
     41 // Detect if the block have sub-pixel level motion vectors
     42 // per component.
     43 #define CHECK_SUBPEL 0
     44 static INLINE int has_subpel_mv_component(const MB_MODE_INFO *const mbmi,
     45                                           const MACROBLOCKD *const xd,
     46                                           int dir) {
     47 #if CHECK_SUBPEL
     48   const BLOCK_SIZE bsize = mbmi->sb_type;
     49   int plane;
     50   int ref = (dir >> 1);
     51 
     52   if (dir & 0x01) {
     53     if (mbmi->mv[ref].as_mv.col & SUBPEL_MASK) return 1;
     54   } else {
     55     if (mbmi->mv[ref].as_mv.row & SUBPEL_MASK) return 1;
     56   }
     57 
     58   return 0;
     59 #else
     60   (void)mbmi;
     61   (void)xd;
     62   (void)dir;
     63   return 1;
     64 #endif
     65 }
     66 
     67 static INLINE int av1_is_interp_search_needed(const MACROBLOCKD *const xd) {
     68   MB_MODE_INFO *const mi = xd->mi[0];
     69   const int is_compound = has_second_ref(mi);
     70   int ref;
     71   for (ref = 0; ref < 1 + is_compound; ++ref) {
     72     int row_col;
     73     for (row_col = 0; row_col < 2; ++row_col) {
     74       const int dir = (ref << 1) + row_col;
     75       if (has_subpel_mv_component(mi, xd, dir)) {
     76         return 1;
     77       }
     78     }
     79   }
     80   return 0;
     81 }
     82 
     83 void av1_build_prediction_by_above_preds(const AV1_COMMON *cm, MACROBLOCKD *xd,
     84                                          int mi_row, int mi_col,
     85                                          uint8_t *tmp_buf[MAX_MB_PLANE],
     86                                          int tmp_width[MAX_MB_PLANE],
     87                                          int tmp_height[MAX_MB_PLANE],
     88                                          int tmp_stride[MAX_MB_PLANE]);
     89 
     90 void av1_build_prediction_by_left_preds(const AV1_COMMON *cm, MACROBLOCKD *xd,
     91                                         int mi_row, int mi_col,
     92                                         uint8_t *tmp_buf[MAX_MB_PLANE],
     93                                         int tmp_width[MAX_MB_PLANE],
     94                                         int tmp_height[MAX_MB_PLANE],
     95                                         int tmp_stride[MAX_MB_PLANE]);
     96 
     97 void av1_build_obmc_inter_predictors_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
     98                                         int mi_row, int mi_col);
     99 
    100 void av1_build_inter_predictors_for_planes_single_buf(
    101     MACROBLOCKD *xd, BLOCK_SIZE bsize, int plane_from, int plane_to, int mi_row,
    102     int mi_col, int ref, uint8_t *ext_dst[3], int ext_dst_stride[3],
    103     int can_use_previous);
    104 
    105 void av1_build_wedge_inter_predictor_from_buf(MACROBLOCKD *xd, BLOCK_SIZE bsize,
    106                                               int plane_from, int plane_to,
    107                                               uint8_t *ext_dst0[3],
    108                                               int ext_dst_stride0[3],
    109                                               uint8_t *ext_dst1[3],
    110                                               int ext_dst_stride1[3]);
    111 
    112 #ifdef __cplusplus
    113 }  // extern "C"
    114 #endif
    115 
    116 #endif  // AOM_AV1_ENCODER_RECONINTER_ENC_H_
    117