convolve.h 5.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
 *
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */

Yaowu Xu's avatar
Yaowu Xu committed
12 13 14 15 16 17 18 19
#ifndef AV1_COMMON_AV1_CONVOLVE_H_
#define AV1_COMMON_AV1_CONVOLVE_H_
#include "av1/common/filter.h"

#ifdef __cplusplus
extern "C" {
#endif

20 21 22 23 24 25
typedef enum CONVOLVE_OPT {
  // indicate the results in dst buf is rounded by FILTER_BITS or not
  CONVOLVE_OPT_ROUND,
  CONVOLVE_OPT_NO_ROUND,
} CONVOLVE_OPT;

Angie Chiang's avatar
Angie Chiang committed
26 27
typedef int32_t CONV_BUF_TYPE;

28 29
typedef struct ConvolveParams {
  int ref;
30
  CONVOLVE_OPT round;
Angie Chiang's avatar
Angie Chiang committed
31
  CONV_BUF_TYPE *dst;
32
  int dst_stride;
Angie Chiang's avatar
Angie Chiang committed
33 34
  int round_0;
  int round_1;
35
  int plane;
36 37
} ConvolveParams;

38
static INLINE ConvolveParams get_conv_params(int ref, int plane) {
39 40 41
  ConvolveParams conv_params;
  conv_params.ref = ref;
  conv_params.round = CONVOLVE_OPT_ROUND;
42
  conv_params.plane = plane;
43 44
  return conv_params;
}
Angie Chiang's avatar
Angie Chiang committed
45 46
struct AV1Common;
void av1_convolve_init(struct AV1Common *cm);
Angie Chiang's avatar
Angie Chiang committed
47
#if CONFIG_CONVOLVE_ROUND
Angie Chiang's avatar
Angie Chiang committed
48 49 50 51 52 53 54 55 56 57 58 59 60
void av1_convolve_2d(const uint8_t *src, int src_stride, CONV_BUF_TYPE *dst,
                     int dst_stride, int w, int h,
                     InterpFilterParams *filter_params_x,
                     InterpFilterParams *filter_params_y, const int subpel_x_q4,
                     const int subpel_y_q4, ConvolveParams *conv_params);

void av1_convolve_2d_facade(const uint8_t *src, int src_stride, uint8_t *dst,
                            int dst_stride, int w, int h,
                            const InterpFilter *interp_filter,
                            const int subpel_x_q4, int x_step_q4,
                            const int subpel_y_q4, int y_step_q4,
                            ConvolveParams *conv_params);

61 62
static INLINE ConvolveParams get_conv_params_no_round(int ref, int plane,
                                                      int32_t *dst,
Angie Chiang's avatar
Angie Chiang committed
63 64 65 66
                                                      int dst_stride) {
  ConvolveParams conv_params;
  conv_params.ref = ref;
  conv_params.round = CONVOLVE_OPT_NO_ROUND;
Angie Chiang's avatar
Angie Chiang committed
67 68 69
#if CONFIG_COMPOUND_ROUND
  conv_params.round_0 = FILTER_BITS;
#else
Angie Chiang's avatar
Angie Chiang committed
70
  conv_params.round_0 = 5;
Angie Chiang's avatar
Angie Chiang committed
71
#endif
72
  conv_params.round_1 = 0;
Angie Chiang's avatar
Angie Chiang committed
73 74
  conv_params.dst = dst;
  conv_params.dst_stride = dst_stride;
75
  conv_params.plane = plane;
Angie Chiang's avatar
Angie Chiang committed
76 77 78 79
  return conv_params;
}

void av1_convolve_rounding(const int32_t *src, int src_stride, uint8_t *dst,
Angie Chiang's avatar
Angie Chiang committed
80
                           int dst_stride, int w, int h, int bits);
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

#if CONFIG_HIGHBITDEPTH
void av1_highbd_convolve_rounding(const int32_t *src, int src_stride,
                                  uint8_t *dst8, int dst_stride, int w, int h,
                                  int bits, int bd);

void av1_highbd_convolve_2d(const uint16_t *src, int src_stride,
                            CONV_BUF_TYPE *dst, int dst_stride, int w, int h,
                            InterpFilterParams *filter_params_x,
                            InterpFilterParams *filter_params_y,
                            const int subpel_x_q4, const int subpel_y_q4,
                            ConvolveParams *conv_params, int bd);

void av1_highbd_convolve_2d_facade(const uint8_t *src8, int src_stride,
                                   uint8_t *dst, int dst_stride, int w, int h,
                                   const InterpFilter *interp_filter,
                                   const int subpel_x_q4, int x_step_q4,
                                   const int subpel_y_q4, int y_step_q4,
                                   ConvolveParams *conv_params, int bd);
#endif
Angie Chiang's avatar
Angie Chiang committed
101
#endif  // CONFIG_CONVOLVE_ROUND
Angie Chiang's avatar
Angie Chiang committed
102

Yaowu Xu's avatar
Yaowu Xu committed
103 104 105
void av1_convolve(const uint8_t *src, int src_stride, uint8_t *dst,
                  int dst_stride, int w, int h,
#if CONFIG_DUAL_FILTER
James Zern's avatar
James Zern committed
106
                  const InterpFilter *interp_filter,
Yaowu Xu's avatar
Yaowu Xu committed
107
#else
James Zern's avatar
James Zern committed
108
                  const InterpFilter interp_filter,
Yaowu Xu's avatar
Yaowu Xu committed
109 110
#endif
                  const int subpel_x, int xstep, const int subpel_y, int ystep,
111
                  ConvolveParams *conv_params);
Yaowu Xu's avatar
Yaowu Xu committed
112

113 114 115 116 117 118 119 120 121 122
void av1_convolve_c(const uint8_t *src, int src_stride, uint8_t *dst,
                    int dst_stride, int w, int h,
#if CONFIG_DUAL_FILTER
                    const InterpFilter *interp_filter,
#else
                    const InterpFilter interp_filter,
#endif
                    const int subpel_x, int xstep, const int subpel_y,
                    int ystep, ConvolveParams *conv_params);

123
#if CONFIG_HIGHBITDEPTH
Yaowu Xu's avatar
Yaowu Xu committed
124 125 126
void av1_highbd_convolve(const uint8_t *src, int src_stride, uint8_t *dst,
                         int dst_stride, int w, int h,
#if CONFIG_DUAL_FILTER
James Zern's avatar
James Zern committed
127
                         const InterpFilter *interp_filter,
Yaowu Xu's avatar
Yaowu Xu committed
128
#else
James Zern's avatar
James Zern committed
129
                         const InterpFilter interp_filter,
Yaowu Xu's avatar
Yaowu Xu committed
130 131 132
#endif
                         const int subpel_x, int xstep, const int subpel_y,
                         int ystep, int avg, int bd);
133
#endif  // CONFIG_HIGHBITDEPTH
Yaowu Xu's avatar
Yaowu Xu committed
134 135 136 137 138 139

#ifdef __cplusplus
}  // extern "C"
#endif

#endif  // AV1_COMMON_AV1_CONVOLVE_H_