/src/libjxl/lib/jxl/coeff_order_fwd.h
Line | Count | Source |
1 | | // Copyright (c) the JPEG XL Project Authors. All rights reserved. |
2 | | // |
3 | | // Use of this source code is governed by a BSD-style |
4 | | // license that can be found in the LICENSE file. |
5 | | |
6 | | #ifndef LIB_JXL_COEFF_ORDER_FWD_H_ |
7 | | #define LIB_JXL_COEFF_ORDER_FWD_H_ |
8 | | |
9 | | // Breaks circular dependency between ac_strategy and coeff_order. |
10 | | |
11 | | #include <cstddef> |
12 | | #include <cstdint> |
13 | | |
14 | | #include "lib/jxl/base/compiler_specific.h" |
15 | | |
16 | | namespace jxl { |
17 | | |
18 | | // Needs at least 16 bits. A 32-bit type speeds up DecodeAC by 2% at the cost of |
19 | | // more memory. |
20 | | using coeff_order_t = uint32_t; |
21 | | |
22 | | // Maximum number of orders to be used. Note that this needs to be multiplied by |
23 | | // the number of channels. One per "size class" (plus one extra for DCT8), |
24 | | // shared between transforms of size XxY and of size YxX. |
25 | | constexpr uint8_t kNumOrders = 13; |
26 | | |
27 | | // DCT coefficients are laid out in such a way that the number of rows of |
28 | | // coefficients is always the smaller coordinate. |
29 | 1.85M | JXL_INLINE constexpr size_t CoefficientRows(size_t rows, size_t columns) { |
30 | 1.85M | return rows < columns ? rows : columns; |
31 | 1.85M | } |
32 | | |
33 | 1.85M | JXL_INLINE constexpr size_t CoefficientColumns(size_t rows, size_t columns) { |
34 | 1.85M | return rows < columns ? columns : rows; |
35 | 1.85M | } |
36 | | |
37 | | JXL_INLINE void CoefficientLayout(size_t* JXL_RESTRICT rows, |
38 | 1.85M | size_t* JXL_RESTRICT columns) { |
39 | 1.85M | size_t r = *rows; |
40 | 1.85M | size_t c = *columns; |
41 | 1.85M | *rows = CoefficientRows(r, c); |
42 | 1.85M | *columns = CoefficientColumns(r, c); |
43 | 1.85M | } |
44 | | |
45 | | } // namespace jxl |
46 | | |
47 | | #endif // LIB_JXL_COEFF_ORDER_FWD_H_ |