libjxl

FORK: libjxl patches used on blog
git clone https://git.neptards.moe/blog/libjxl.git
Log | Files | Refs | Submodules | README | LICENSE

enc_coeff_order.h (2155B)


      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_ENC_COEFF_ORDER_H_
      7 #define LIB_JXL_ENC_COEFF_ORDER_H_
      8 
      9 #include <stddef.h>
     10 #include <stdint.h>
     11 
     12 #include "lib/jxl/ac_strategy.h"
     13 #include "lib/jxl/base/compiler_specific.h"
     14 #include "lib/jxl/base/status.h"
     15 #include "lib/jxl/coeff_order.h"
     16 #include "lib/jxl/coeff_order_fwd.h"
     17 #include "lib/jxl/dct_util.h"
     18 #include "lib/jxl/dec_bit_reader.h"
     19 #include "lib/jxl/enc_bit_writer.h"
     20 #include "lib/jxl/enc_params.h"
     21 #include "lib/jxl/frame_dimensions.h"
     22 
     23 namespace jxl {
     24 
     25 struct AuxOut;
     26 
     27 // Orders that are actually used in part of image. `rect` is in block units.
     28 // Returns {orders that are used, orders that might be made non-default}.
     29 std::pair<uint32_t, uint32_t> ComputeUsedOrders(
     30     SpeedTier speed, const AcStrategyImage& ac_strategy, const Rect& rect);
     31 
     32 // Modify zig-zag order, so that DCT bands with more zeros go later.
     33 // Order of DCT bands with same number of zeros is untouched, so
     34 // permutation will be cheaper to encode.
     35 void ComputeCoeffOrder(SpeedTier speed, const ACImage& acs,
     36                        const AcStrategyImage& ac_strategy,
     37                        const FrameDimensions& frame_dim,
     38                        uint32_t& all_used_orders, uint32_t prev_used_acs,
     39                        uint32_t current_used_acs, uint32_t current_used_orders,
     40                        coeff_order_t* JXL_RESTRICT order);
     41 
     42 void EncodeCoeffOrders(uint16_t used_orders,
     43                        const coeff_order_t* JXL_RESTRICT order,
     44                        BitWriter* writer, size_t layer,
     45                        AuxOut* JXL_RESTRICT aux_out);
     46 
     47 // Encoding/decoding of a single permutation. `size`: number of elements in the
     48 // permutation. `skip`: number of elements to skip from the *beginning* of the
     49 // permutation.
     50 void EncodePermutation(const coeff_order_t* JXL_RESTRICT order, size_t skip,
     51                        size_t size, BitWriter* writer, int layer,
     52                        AuxOut* aux_out);
     53 
     54 }  // namespace jxl
     55 
     56 #endif  // LIB_JXL_ENC_COEFF_ORDER_H_