passes_state.h (2514B)
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_PASSES_STATE_H_ 7 #define LIB_JXL_PASSES_STATE_H_ 8 9 #include "lib/jxl/ac_context.h" 10 #include "lib/jxl/ac_strategy.h" 11 #include "lib/jxl/chroma_from_luma.h" 12 #include "lib/jxl/dec_patch_dictionary.h" 13 #include "lib/jxl/frame_header.h" 14 #include "lib/jxl/image.h" 15 #include "lib/jxl/image_bundle.h" 16 #include "lib/jxl/loop_filter.h" 17 #include "lib/jxl/noise.h" 18 #include "lib/jxl/quant_weights.h" 19 #include "lib/jxl/quantizer.h" 20 #include "lib/jxl/splines.h" 21 22 // Structures that hold the (en/de)coder state for a JPEG XL kVarDCT 23 // (en/de)coder. 24 25 namespace jxl { 26 27 struct ImageFeatures { 28 NoiseParams noise_params; 29 PatchDictionary patches; 30 Splines splines; 31 }; 32 33 // State common to both encoder and decoder. 34 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding) 35 struct PassesSharedState { 36 const CodecMetadata* metadata; 37 38 FrameDimensions frame_dim; 39 40 // Control fields and parameters. 41 AcStrategyImage ac_strategy; 42 43 // Dequant matrices + quantizer. 44 DequantMatrices matrices; 45 Quantizer quantizer{&matrices}; 46 ImageI raw_quant_field; 47 48 // Per-block side information for EPF detail preservation. 49 ImageB epf_sharpness; 50 51 ColorCorrelationMap cmap; 52 53 ImageFeatures image_features; 54 55 // Memory area for storing coefficient orders. 56 // `coeff_order_size` is the size used by *one* set of coefficient orders (at 57 // most kMaxCoeffOrderSize). A set of coefficient orders is present for each 58 // pass. 59 size_t coeff_order_size = 0; 60 std::vector<coeff_order_t> coeff_orders; 61 62 // Decoder-side DC and quantized DC. 63 ImageB quant_dc; 64 Image3F dc_storage; 65 const Image3F* JXL_RESTRICT dc = &dc_storage; 66 67 BlockCtxMap block_ctx_map; 68 69 Image3F dc_frames[4]; 70 71 struct { 72 ImageBundle frame; 73 // ImageBundle doesn't yet have a simple way to state it is in XYB. 74 bool ib_is_in_xyb = false; 75 } reference_frames[4] = {}; 76 77 // Number of pre-clustered set of histograms (with the same ctx map), per 78 // pass. Encoded as num_histograms_ - 1. 79 size_t num_histograms = 0; 80 }; 81 82 // Initialized the state information that is shared between encoder and decoder. 83 Status InitializePassesSharedState(const FrameHeader& frame_header, 84 PassesSharedState* JXL_RESTRICT shared, 85 bool encoder = false); 86 87 } // namespace jxl 88 89 #endif // LIB_JXL_PASSES_STATE_H_