blob: d95b103c9b75521057da1fc4eb3494629dc3939e [file] [log] [blame]
Steinar Midtskogena9d41e82017-03-17 12:48:15 +01001/*
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 */
Steinar Midtskogen94de0aa2017-08-02 10:30:12 +020011#ifndef AV1_COMMON_CDEF_H_
12#define AV1_COMMON_CDEF_H_
Steinar Midtskogena9d41e82017-03-17 12:48:15 +010013
Steinar Midtskogen6c24b022017-09-15 09:46:39 +020014#define CDEF_STRENGTH_BITS 6
Steinar Midtskogena9d41e82017-03-17 12:48:15 +010015
Steinar Midtskogen6c24b022017-09-15 09:46:39 +020016#define CDEF_PRI_STRENGTHS 16
Steinar Midtskogen94de0aa2017-08-02 10:30:12 +020017#define CDEF_SEC_STRENGTHS 4
Steinar Midtskogena9d41e82017-03-17 12:48:15 +010018
19#include "./aom_config.h"
20#include "aom/aom_integer.h"
21#include "aom_ports/mem.h"
Steinar Midtskogen94de0aa2017-08-02 10:30:12 +020022#include "av1/common/cdef_block.h"
Steinar Midtskogena9d41e82017-03-17 12:48:15 +010023#include "av1/common/onyxc_int.h"
Steinar Midtskogena9d41e82017-03-17 12:48:15 +010024
Steinar Midtskogen8ff52fc2017-04-04 12:29:19 +020025static INLINE int sign(int i) { return i < 0 ? -1 : 1; }
26
David Barker0123bc72017-09-06 15:22:59 +010027static INLINE int constrain(int diff, int threshold, int damping) {
28 if (!threshold) return 0;
29
30 const int shift = AOMMAX(0, damping - get_msb(threshold));
31 return sign(diff) *
32 AOMMIN(abs(diff), AOMMAX(0, threshold - (abs(diff) >> shift)));
Steinar Midtskogen8ff52fc2017-04-04 12:29:19 +020033}
34
Steinar Midtskogena9d41e82017-03-17 12:48:15 +010035#ifdef __cplusplus
36extern "C" {
37#endif
38
Steinar Midtskogena9d41e82017-03-17 12:48:15 +010039int sb_all_skip(const AV1_COMMON *const cm, int mi_row, int mi_col);
Steinar Midtskogen6c24b022017-09-15 09:46:39 +020040#if CONFIG_EXT_PARTITION
Steinar Midtskogen94de0aa2017-08-02 10:30:12 +020041int sb_compute_cdef_list(const AV1_COMMON *const cm, int mi_row, int mi_col,
Steinar Midtskogen6c24b022017-09-15 09:46:39 +020042 cdef_list *dlist, BLOCK_SIZE bsize);
43#else
44int sb_compute_cdef_list(const AV1_COMMON *const cm, int mi_row, int mi_col,
45 cdef_list *dlist);
46#endif
Jean-Marc Valine9f77422017-03-22 17:09:51 -040047void av1_cdef_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm, MACROBLOCKD *xd);
Steinar Midtskogena9d41e82017-03-17 12:48:15 +010048
49void av1_cdef_search(YV12_BUFFER_CONFIG *frame, const YV12_BUFFER_CONFIG *ref,
Steinar Midtskogenb1555c92017-06-07 13:26:31 +020050 AV1_COMMON *cm, MACROBLOCKD *xd, int fast);
Steinar Midtskogena9d41e82017-03-17 12:48:15 +010051
52#ifdef __cplusplus
53} // extern "C"
54#endif
Steinar Midtskogen94de0aa2017-08-02 10:30:12 +020055#endif // AV1_COMMON_CDEF_H_