libjxl

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

entropy_coder.h (1392B)


      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_ENTROPY_CODER_H_
      7 #define LIB_JXL_ENTROPY_CODER_H_
      8 
      9 #include <stddef.h>
     10 #include <stdint.h>
     11 
     12 #include "lib/jxl/ac_context.h"
     13 #include "lib/jxl/base/compiler_specific.h"
     14 #include "lib/jxl/dec_bit_reader.h"
     15 #include "lib/jxl/field_encodings.h"
     16 
     17 // Entropy coding and context modeling of DC and AC coefficients, as well as AC
     18 // strategy and quantization field.
     19 
     20 namespace jxl {
     21 
     22 static JXL_INLINE int32_t PredictFromTopAndLeft(
     23     const int32_t* const JXL_RESTRICT row_top,
     24     const int32_t* const JXL_RESTRICT row, size_t x, int32_t default_val) {
     25   if (x == 0) {
     26     return row_top == nullptr ? default_val : row_top[x];
     27   }
     28   if (row_top == nullptr) {
     29     return row[x - 1];
     30   }
     31   return (row_top[x] + row[x - 1] + 1) / 2;
     32 }
     33 
     34 static constexpr U32Enc kDCThresholdDist(Bits(4), BitsOffset(8, 16),
     35                                          BitsOffset(16, 272),
     36                                          BitsOffset(32, 65808));
     37 
     38 static constexpr U32Enc kQFThresholdDist(Bits(2), BitsOffset(3, 4),
     39                                          BitsOffset(5, 12), BitsOffset(8, 44));
     40 
     41 Status DecodeBlockCtxMap(BitReader* br, BlockCtxMap* block_ctx_map);
     42 
     43 }  // namespace jxl
     44 
     45 #endif  // LIB_JXL_ENTROPY_CODER_H_