blob: 14cc989ac19077ead7ea7708bb3ba90e46c0486f [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004 * 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.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
Yaowu Xuf883b422016-08-30 14:01:10 -070012#ifndef AOM_DSP_INV_TXFM_H_
13#define AOM_DSP_INV_TXFM_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
15#include <assert.h>
16
Yaowu Xuf883b422016-08-30 14:01:10 -070017#include "./aom_config.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070018#include "aom_dsp/txfm_common.h"
Monty Montgomery57f6bfd2017-11-03 10:32:37 -040019#include "av1/common/odintrin.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070020#include "aom_ports/mem.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
Sebastien Alaiwane5728a92017-04-14 15:44:10 +020026static INLINE tran_high_t dct_const_round_shift(tran_high_t input) {
Sebastien Alaiwan44309752017-07-04 10:43:34 +020027 return ROUND_POWER_OF_TWO(input, DCT_CONST_BITS);
Sebastien Alaiwane5728a92017-04-14 15:44:10 +020028}
29
30static INLINE tran_high_t check_range(tran_high_t input, int bd) {
Monty Montgomerya26262c2017-10-31 07:32:13 -040031 // AV1 TX case
Yaowu Xuc27fc142016-08-22 16:08:15 -070032 // - 8 bit: signed 16 bit integer
33 // - 10 bit: signed 18 bit integer
34 // - 12 bit: signed 20 bit integer
Yaowu Xuf0132052017-11-28 17:51:50 -080035 // - max quantization error = 1828 << (bd - 8)
36 const int32_t int_max = (1 << (7 + bd)) - 1 + (914 << (bd - 7));
Monty Montgomerya26262c2017-10-31 07:32:13 -040037 const int32_t int_min = -int_max - 1;
Monty Montgomerya26262c2017-10-31 07:32:13 -040038#if CONFIG_COEFFICIENT_RANGE_CHECKING
Yaowu Xuc27fc142016-08-22 16:08:15 -070039 assert(int_min <= input);
40 assert(input <= int_max);
Yaowu Xuc27fc142016-08-22 16:08:15 -070041#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
Yaowu Xubdc25872017-11-30 08:29:41 -080042 return (tran_high_t)clamp64(input, int_min, int_max);
Yaowu Xuc27fc142016-08-22 16:08:15 -070043}
44
Sebastien Alaiwane5728a92017-04-14 15:44:10 +020045#define WRAPLOW(x) ((int32_t)check_range(x, 8))
Sebastien Alaiwane5728a92017-04-14 15:44:10 +020046#define HIGHBD_WRAPLOW(x, bd) ((int32_t)check_range((x), bd))
Yaowu Xuc27fc142016-08-22 16:08:15 -070047
Luca Barbatof0f98572016-09-03 12:14:15 +020048void aom_idct4_c(const tran_low_t *input, tran_low_t *output);
49void aom_idct8_c(const tran_low_t *input, tran_low_t *output);
50void aom_idct16_c(const tran_low_t *input, tran_low_t *output);
51void aom_idct32_c(const tran_low_t *input, tran_low_t *output);
52void aom_iadst4_c(const tran_low_t *input, tran_low_t *output);
53void aom_iadst8_c(const tran_low_t *input, tran_low_t *output);
54void aom_iadst16_c(const tran_low_t *input, tran_low_t *output);
Yaowu Xuc27fc142016-08-22 16:08:15 -070055
Yaowu Xuf883b422016-08-30 14:01:10 -070056void aom_highbd_idct4_c(const tran_low_t *input, tran_low_t *output, int bd);
57void aom_highbd_idct8_c(const tran_low_t *input, tran_low_t *output, int bd);
58void aom_highbd_idct16_c(const tran_low_t *input, tran_low_t *output, int bd);
59void aom_highbd_idct32_c(const tran_low_t *input, tran_low_t *output, int bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -070060
Yaowu Xuf883b422016-08-30 14:01:10 -070061void aom_highbd_iadst4_c(const tran_low_t *input, tran_low_t *output, int bd);
62void aom_highbd_iadst8_c(const tran_low_t *input, tran_low_t *output, int bd);
63void aom_highbd_iadst16_c(const tran_low_t *input, tran_low_t *output, int bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -070064
65static INLINE uint16_t highbd_clip_pixel_add(uint16_t dest, tran_high_t trans,
66 int bd) {
67 trans = HIGHBD_WRAPLOW(trans, bd);
68 return clip_pixel_highbd(dest + (int)trans, bd);
69}
Yaowu Xuc27fc142016-08-22 16:08:15 -070070
71static INLINE uint8_t clip_pixel_add(uint8_t dest, tran_high_t trans) {
72 trans = WRAPLOW(trans);
73 return clip_pixel(dest + (int)trans);
74}
75#ifdef __cplusplus
76} // extern "C"
77#endif
78
Yaowu Xuf883b422016-08-30 14:01:10 -070079#endif // AOM_DSP_INV_TXFM_H_