tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

enc_adaptive_quantization.h (2540B)


      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_ADAPTIVE_QUANTIZATION_H_
      7 #define LIB_JXL_ENC_ADAPTIVE_QUANTIZATION_H_
      8 
      9 #include <jxl/cms_interface.h>
     10 
     11 #include "lib/jxl/base/data_parallel.h"
     12 #include "lib/jxl/base/rect.h"
     13 #include "lib/jxl/base/status.h"
     14 #include "lib/jxl/enc_cache.h"
     15 #include "lib/jxl/frame_header.h"
     16 #include "lib/jxl/image.h"
     17 
     18 // Heuristics to find a good quantizer for a given image. InitialQuantField
     19 // produces a quantization field (i.e. relative quantization amounts for each
     20 // block) out of an opsin-space image. `InitialQuantField` uses heuristics,
     21 // `FindBestQuantizer` (in non-fast mode) will run multiple encoding-decoding
     22 // steps and try to improve the given quant field.
     23 
     24 namespace jxl {
     25 
     26 struct AuxOut;
     27 class AcStrategyImage;
     28 
     29 // Returns an image subsampled by kBlockDim in each direction. If the value
     30 // at pixel (x,y) in the returned image is greater than 1.0, it means that
     31 // more fine-grained quantization should be used in the corresponding block
     32 // of the input image, while a value less than 1.0 indicates that less
     33 // fine-grained quantization should be enough. Returns a mask, too, which
     34 // can later be used to make better decisions about ac strategy.
     35 StatusOr<ImageF> InitialQuantField(float butteraugli_target,
     36                                   const Image3F& opsin, const Rect& rect,
     37                                   ThreadPool* pool, float rescale,
     38                                   ImageF* initial_quant_mask,
     39                                   ImageF* initial_quant_mask1x1);
     40 
     41 float InitialQuantDC(float butteraugli_target);
     42 
     43 Status AdjustQuantField(const AcStrategyImage& ac_strategy, const Rect& rect,
     44                        float butteraugli_target, ImageF* quant_field);
     45 
     46 // Returns a quantizer that uses an adjusted version of the provided
     47 // quant_field. Also computes the dequant_map corresponding to the given
     48 // dequant_float_map and chosen quantization levels.
     49 // `linear` is only used in Kitten mode or slower.
     50 Status FindBestQuantizer(const FrameHeader& frame_header, const Image3F* linear,
     51                         const Image3F& opsin, ImageF& quant_field,
     52                         PassesEncoderState* enc_state,
     53                         const JxlCmsInterface& cms, ThreadPool* pool,
     54                         AuxOut* aux_out, double rescale = 1.0);
     55 
     56 }  // namespace jxl
     57 
     58 #endif  // LIB_JXL_ENC_ADAPTIVE_QUANTIZATION_H_