Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 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. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 12 | #ifndef AOM_DSP_INV_TXFM_H_ |
| 13 | #define AOM_DSP_INV_TXFM_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
| 15 | #include <assert.h> |
| 16 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 17 | #include "./aom_config.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 18 | #include "aom_dsp/txfm_common.h" |
Monty Montgomery | 57f6bfd | 2017-11-03 10:32:37 -0400 | [diff] [blame] | 19 | #include "av1/common/odintrin.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 20 | #include "aom_ports/mem.h" |
| 21 | |
| 22 | #ifdef __cplusplus |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
Sebastien Alaiwan | e5728a9 | 2017-04-14 15:44:10 +0200 | [diff] [blame] | 26 | static INLINE tran_high_t dct_const_round_shift(tran_high_t input) { |
Sebastien Alaiwan | 4430975 | 2017-07-04 10:43:34 +0200 | [diff] [blame] | 27 | return ROUND_POWER_OF_TWO(input, DCT_CONST_BITS); |
Sebastien Alaiwan | e5728a9 | 2017-04-14 15:44:10 +0200 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | static INLINE tran_high_t check_range(tran_high_t input, int bd) { |
Monty Montgomery | a26262c | 2017-10-31 07:32:13 -0400 | [diff] [blame] | 31 | // AV1 TX case |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 32 | // - 8 bit: signed 16 bit integer |
| 33 | // - 10 bit: signed 18 bit integer |
| 34 | // - 12 bit: signed 20 bit integer |
Yaowu Xu | f013205 | 2017-11-28 17:51:50 -0800 | [diff] [blame] | 35 | // - max quantization error = 1828 << (bd - 8) |
| 36 | const int32_t int_max = (1 << (7 + bd)) - 1 + (914 << (bd - 7)); |
Monty Montgomery | a26262c | 2017-10-31 07:32:13 -0400 | [diff] [blame] | 37 | const int32_t int_min = -int_max - 1; |
Monty Montgomery | a26262c | 2017-10-31 07:32:13 -0400 | [diff] [blame] | 38 | #if CONFIG_COEFFICIENT_RANGE_CHECKING |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 39 | assert(int_min <= input); |
| 40 | assert(input <= int_max); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 41 | #endif // CONFIG_COEFFICIENT_RANGE_CHECKING |
Yaowu Xu | bdc2587 | 2017-11-30 08:29:41 -0800 | [diff] [blame] | 42 | return (tran_high_t)clamp64(input, int_min, int_max); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Sebastien Alaiwan | e5728a9 | 2017-04-14 15:44:10 +0200 | [diff] [blame] | 45 | #define WRAPLOW(x) ((int32_t)check_range(x, 8)) |
Sebastien Alaiwan | e5728a9 | 2017-04-14 15:44:10 +0200 | [diff] [blame] | 46 | #define HIGHBD_WRAPLOW(x, bd) ((int32_t)check_range((x), bd)) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 47 | |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 48 | void aom_idct4_c(const tran_low_t *input, tran_low_t *output); |
| 49 | void aom_idct8_c(const tran_low_t *input, tran_low_t *output); |
| 50 | void aom_idct16_c(const tran_low_t *input, tran_low_t *output); |
| 51 | void aom_idct32_c(const tran_low_t *input, tran_low_t *output); |
| 52 | void aom_iadst4_c(const tran_low_t *input, tran_low_t *output); |
| 53 | void aom_iadst8_c(const tran_low_t *input, tran_low_t *output); |
| 54 | void aom_iadst16_c(const tran_low_t *input, tran_low_t *output); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 55 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 56 | void aom_highbd_idct4_c(const tran_low_t *input, tran_low_t *output, int bd); |
| 57 | void aom_highbd_idct8_c(const tran_low_t *input, tran_low_t *output, int bd); |
| 58 | void aom_highbd_idct16_c(const tran_low_t *input, tran_low_t *output, int bd); |
| 59 | void aom_highbd_idct32_c(const tran_low_t *input, tran_low_t *output, int bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 60 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 61 | void aom_highbd_iadst4_c(const tran_low_t *input, tran_low_t *output, int bd); |
| 62 | void aom_highbd_iadst8_c(const tran_low_t *input, tran_low_t *output, int bd); |
| 63 | void aom_highbd_iadst16_c(const tran_low_t *input, tran_low_t *output, int bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 64 | |
| 65 | static 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 Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 70 | |
| 71 | static 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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 79 | #endif // AOM_DSP_INV_TXFM_H_ |