libjxl

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

enc_transform.cc (1585B)


      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 #include "lib/jxl/modular/transform/enc_transform.h"
      7 
      8 #include "lib/jxl/modular/transform/enc_palette.h"
      9 #include "lib/jxl/modular/transform/enc_rct.h"
     10 #include "lib/jxl/modular/transform/enc_squeeze.h"
     11 
     12 namespace jxl {
     13 
     14 Status TransformForward(Transform &t, Image &input,
     15                         const weighted::Header &wp_header, ThreadPool *pool) {
     16   switch (t.id) {
     17     case TransformId::kRCT:
     18       return FwdRCT(input, t.begin_c, t.rct_type, pool);
     19     case TransformId::kSqueeze:
     20       return FwdSqueeze(input, t.squeezes, pool);
     21     case TransformId::kPalette:
     22       return FwdPalette(input, t.begin_c, t.begin_c + t.num_c - 1, t.nb_colors,
     23                         t.nb_deltas, t.ordered_palette, t.lossy_palette,
     24                         t.predictor, wp_header);
     25     default:
     26       return JXL_FAILURE("Unknown transformation (ID=%u)",
     27                          static_cast<unsigned int>(t.id));
     28   }
     29 }
     30 
     31 void compute_minmax(const Channel &ch, pixel_type *min, pixel_type *max) {
     32   pixel_type realmin = std::numeric_limits<pixel_type>::max();
     33   pixel_type realmax = std::numeric_limits<pixel_type>::min();
     34   for (size_t y = 0; y < ch.h; y++) {
     35     const pixel_type *JXL_RESTRICT p = ch.Row(y);
     36     for (size_t x = 0; x < ch.w; x++) {
     37       if (p[x] < realmin) realmin = p[x];
     38       if (p[x] > realmax) realmax = p[x];
     39     }
     40   }
     41 
     42   if (min) *min = realmin;
     43   if (max) *max = realmax;
     44 }
     45 
     46 }  // namespace jxl