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 #ifndef AOM_AV1_COMMON_CDEF_H_
12 #define AOM_AV1_COMMON_CDEF_H_
13
14 #define CDEF_STRENGTH_BITS 6
15
16 #define CDEF_PRI_STRENGTHS 16
17 #define CDEF_SEC_STRENGTHS 4
18
19 #include "config/aom_config.h"
20
21 #include "aom/aom_integer.h"
22 #include "aom_ports/mem.h"
23 #include "av1/common/av1_common_int.h"
24 #include "av1/common/cdef_block.h"
25
sign(int i)26 static INLINE int sign(int i) { return i < 0 ? -1 : 1; }
27
constrain(int diff,int threshold,int damping)28 static INLINE int constrain(int diff, int threshold, int damping) {
29 if (!threshold) return 0;
30
31 const int shift = AOMMAX(0, damping - get_msb(threshold));
32 return sign(diff) *
33 AOMMIN(abs(diff), AOMMAX(0, threshold - (abs(diff) >> shift)));
34 }
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 int av1_cdef_compute_sb_list(const CommonModeInfoParams *const mi_params,
41 int mi_row, int mi_col, cdef_list *dlist,
42 BLOCK_SIZE bsize);
43 void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm, MACROBLOCKD *xd);
44
45 void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
46 AV1_COMMON *cm, MACROBLOCKD *xd, int pick_method,
47 int rdmult);
48
49 #ifdef __cplusplus
50 } // extern "C"
51 #endif
52 #endif // AOM_AV1_COMMON_CDEF_H_
53