Line data Source code
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 :
12 : #ifndef AOM_DSP_INV_TXFM_H_
13 : #define AOM_DSP_INV_TXFM_H_
14 :
15 : #include <assert.h>
16 :
17 : #include "./aom_config.h"
18 : #include "aom_dsp/txfm_common.h"
19 : #include "aom_ports/mem.h"
20 :
21 : #ifdef __cplusplus
22 : extern "C" {
23 : #endif
24 :
25 0 : static INLINE tran_high_t dct_const_round_shift(tran_high_t input) {
26 0 : tran_high_t rv = ROUND_POWER_OF_TWO(input, DCT_CONST_BITS);
27 0 : return rv;
28 : }
29 :
30 0 : static INLINE tran_high_t check_range(tran_high_t input, int bd) {
31 : #if CONFIG_COEFFICIENT_RANGE_CHECKING
32 : // For valid AV1 input streams, intermediate stage coefficients should always
33 : // stay within the range of a signed 16 bit integer. Coefficients can go out
34 : // of this range for invalid/corrupt AV1 streams. However, strictly checking
35 : // this range for every intermediate coefficient can burdensome for a decoder,
36 : // therefore the following assertion is only enabled when configured with
37 : // --enable-coefficient-range-checking.
38 : // For valid highbitdepth AV1 streams, intermediate stage coefficients will
39 : // stay within the ranges:
40 : // - 8 bit: signed 16 bit integer
41 : // - 10 bit: signed 18 bit integer
42 : // - 12 bit: signed 20 bit integer
43 : const int32_t int_max = (1 << (7 + bd)) - 1;
44 : const int32_t int_min = -int_max - 1;
45 : assert(int_min <= input);
46 : assert(input <= int_max);
47 : (void)int_min;
48 : #endif // CONFIG_COEFFICIENT_RANGE_CHECKING
49 : (void)bd;
50 0 : return input;
51 : }
52 :
53 : #define WRAPLOW(x) ((int32_t)check_range(x, 8))
54 : #if CONFIG_HIGHBITDEPTH
55 : #define HIGHBD_WRAPLOW(x, bd) ((int32_t)check_range((x), bd))
56 : #endif // CONFIG_HIGHBITDEPTH
57 :
58 : void aom_idct4_c(const tran_low_t *input, tran_low_t *output);
59 : void aom_idct8_c(const tran_low_t *input, tran_low_t *output);
60 : void aom_idct16_c(const tran_low_t *input, tran_low_t *output);
61 : void aom_idct32_c(const tran_low_t *input, tran_low_t *output);
62 : void aom_iadst4_c(const tran_low_t *input, tran_low_t *output);
63 : void aom_iadst8_c(const tran_low_t *input, tran_low_t *output);
64 : void aom_iadst16_c(const tran_low_t *input, tran_low_t *output);
65 :
66 : #if CONFIG_HIGHBITDEPTH
67 : void aom_highbd_idct4_c(const tran_low_t *input, tran_low_t *output, int bd);
68 : void aom_highbd_idct8_c(const tran_low_t *input, tran_low_t *output, int bd);
69 : void aom_highbd_idct16_c(const tran_low_t *input, tran_low_t *output, int bd);
70 : void aom_highbd_idct32_c(const tran_low_t *input, tran_low_t *output, int bd);
71 :
72 : void aom_highbd_iadst4_c(const tran_low_t *input, tran_low_t *output, int bd);
73 : void aom_highbd_iadst8_c(const tran_low_t *input, tran_low_t *output, int bd);
74 : void aom_highbd_iadst16_c(const tran_low_t *input, tran_low_t *output, int bd);
75 :
76 0 : static INLINE uint16_t highbd_clip_pixel_add(uint16_t dest, tran_high_t trans,
77 : int bd) {
78 0 : trans = HIGHBD_WRAPLOW(trans, bd);
79 0 : return clip_pixel_highbd(dest + (int)trans, bd);
80 : }
81 : #endif
82 :
83 0 : static INLINE uint8_t clip_pixel_add(uint8_t dest, tran_high_t trans) {
84 0 : trans = WRAPLOW(trans);
85 0 : return clip_pixel(dest + (int)trans);
86 : }
87 : #ifdef __cplusplus
88 : } // extern "C"
89 : #endif
90 :
91 : #endif // AOM_DSP_INV_TXFM_H_
|