1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_AV1_COMMON_CDEF_BLOCK_H_
13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_COMMON_CDEF_BLOCK_H_
14*77c1e3ccSAndroid Build Coastguard Worker
15*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/odintrin.h"
16*77c1e3ccSAndroid Build Coastguard Worker
17*77c1e3ccSAndroid Build Coastguard Worker #define CDEF_BLOCKSIZE 64
18*77c1e3ccSAndroid Build Coastguard Worker #define CDEF_BLOCKSIZE_LOG2 6
19*77c1e3ccSAndroid Build Coastguard Worker #define CDEF_NBLOCKS ((1 << MAX_SB_SIZE_LOG2) / 8)
20*77c1e3ccSAndroid Build Coastguard Worker #define CDEF_SB_SHIFT (MAX_SB_SIZE_LOG2 - CDEF_BLOCKSIZE_LOG2)
21*77c1e3ccSAndroid Build Coastguard Worker
22*77c1e3ccSAndroid Build Coastguard Worker /* We need to buffer two vertical lines. */
23*77c1e3ccSAndroid Build Coastguard Worker #define CDEF_VBORDER (2)
24*77c1e3ccSAndroid Build Coastguard Worker /* We only need to buffer three horizontal pixels too, but let's align to
25*77c1e3ccSAndroid Build Coastguard Worker 16 bytes (8 x 16 bits) to make vectorization easier. */
26*77c1e3ccSAndroid Build Coastguard Worker #define CDEF_HBORDER (8)
27*77c1e3ccSAndroid Build Coastguard Worker #define CDEF_BSTRIDE \
28*77c1e3ccSAndroid Build Coastguard Worker ALIGN_POWER_OF_TWO((1 << MAX_SB_SIZE_LOG2) + 2 * CDEF_HBORDER, 3)
29*77c1e3ccSAndroid Build Coastguard Worker
30*77c1e3ccSAndroid Build Coastguard Worker #define CDEF_VERY_LARGE (0x4000)
31*77c1e3ccSAndroid Build Coastguard Worker #define CDEF_INBUF_SIZE \
32*77c1e3ccSAndroid Build Coastguard Worker (CDEF_BSTRIDE * ((1 << MAX_SB_SIZE_LOG2) + 2 * CDEF_VBORDER))
33*77c1e3ccSAndroid Build Coastguard Worker
34*77c1e3ccSAndroid Build Coastguard Worker extern const int cdef_pri_taps[2][2];
35*77c1e3ccSAndroid Build Coastguard Worker extern const int cdef_sec_taps[2];
36*77c1e3ccSAndroid Build Coastguard Worker extern const int (*const cdef_directions)[2];
37*77c1e3ccSAndroid Build Coastguard Worker
38*77c1e3ccSAndroid Build Coastguard Worker typedef struct {
39*77c1e3ccSAndroid Build Coastguard Worker uint8_t by;
40*77c1e3ccSAndroid Build Coastguard Worker uint8_t bx;
41*77c1e3ccSAndroid Build Coastguard Worker } cdef_list;
42*77c1e3ccSAndroid Build Coastguard Worker
43*77c1e3ccSAndroid Build Coastguard Worker typedef void (*cdef_filter_block_func)(void *dest, int dstride,
44*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *in, int pri_strength,
45*77c1e3ccSAndroid Build Coastguard Worker int sec_strength, int dir,
46*77c1e3ccSAndroid Build Coastguard Worker int pri_damping, int sec_damping,
47*77c1e3ccSAndroid Build Coastguard Worker int coeff_shift, int block_width,
48*77c1e3ccSAndroid Build Coastguard Worker int block_height);
49*77c1e3ccSAndroid Build Coastguard Worker
50*77c1e3ccSAndroid Build Coastguard Worker void av1_cdef_filter_fb(uint8_t *dst8, uint16_t *dst16, int dstride,
51*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *in, int xdec, int ydec,
52*77c1e3ccSAndroid Build Coastguard Worker int dir[CDEF_NBLOCKS][CDEF_NBLOCKS], int *dirinit,
53*77c1e3ccSAndroid Build Coastguard Worker int var[CDEF_NBLOCKS][CDEF_NBLOCKS], int pli,
54*77c1e3ccSAndroid Build Coastguard Worker cdef_list *dlist, int cdef_count, int level,
55*77c1e3ccSAndroid Build Coastguard Worker int sec_strength, int damping, int coeff_shift);
56*77c1e3ccSAndroid Build Coastguard Worker
fill_rect(uint16_t * dst,int dstride,int v,int h,uint16_t x)57*77c1e3ccSAndroid Build Coastguard Worker static inline void fill_rect(uint16_t *dst, int dstride, int v, int h,
58*77c1e3ccSAndroid Build Coastguard Worker uint16_t x) {
59*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < v; i++) {
60*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < h; j++) {
61*77c1e3ccSAndroid Build Coastguard Worker dst[i * dstride + j] = x;
62*77c1e3ccSAndroid Build Coastguard Worker }
63*77c1e3ccSAndroid Build Coastguard Worker }
64*77c1e3ccSAndroid Build Coastguard Worker }
65*77c1e3ccSAndroid Build Coastguard Worker #endif // AOM_AV1_COMMON_CDEF_BLOCK_H_
66