coeff_order_fwd.h (1468B)
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 <stddef.h> 12 #include <stdint.h> 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 JXL_INLINE constexpr size_t CoefficientRows(size_t rows, size_t columns) { 30 return rows < columns ? rows : columns; 31 } 32 33 JXL_INLINE constexpr size_t CoefficientColumns(size_t rows, size_t columns) { 34 return rows < columns ? columns : rows; 35 } 36 37 JXL_INLINE void CoefficientLayout(size_t* JXL_RESTRICT rows, 38 size_t* JXL_RESTRICT columns) { 39 size_t r = *rows; 40 size_t c = *columns; 41 *rows = CoefficientRows(r, c); 42 *columns = CoefficientColumns(r, c); 43 } 44 45 } // namespace jxl 46 47 #endif // LIB_JXL_COEFF_ORDER_FWD_H_