libjxl

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

decode.h (1450B)


      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_EXTRAS_DEC_DECODE_H_
      7 #define LIB_EXTRAS_DEC_DECODE_H_
      8 
      9 // Facade for image decoders (PNG, PNM, ...).
     10 
     11 #include <stddef.h>
     12 #include <stdint.h>
     13 
     14 #include <string>
     15 #include <vector>
     16 
     17 #include "lib/extras/dec/color_hints.h"
     18 #include "lib/jxl/base/span.h"
     19 #include "lib/jxl/base/status.h"
     20 
     21 namespace jxl {
     22 
     23 struct SizeConstraints;
     24 
     25 namespace extras {
     26 
     27 // Codecs supported by DecodeBytes.
     28 enum class Codec : uint32_t {
     29   kUnknown,  // for CodecFromPath
     30   kPNG,
     31   kPNM,
     32   kPGX,
     33   kJPG,
     34   kGIF,
     35   kEXR,
     36   kJXL
     37 };
     38 
     39 bool CanDecode(Codec codec);
     40 
     41 // If and only if extension is ".pfm", *bits_per_sample is updated to 32 so
     42 // that Encode() would encode to PFM instead of PPM.
     43 Codec CodecFromPath(const std::string& path,
     44                     size_t* JXL_RESTRICT bits_per_sample = nullptr,
     45                     std::string* extension = nullptr);
     46 
     47 // Decodes "bytes" info *ppf.
     48 // color_space_hint may specify the color space, otherwise, defaults to sRGB.
     49 Status DecodeBytes(Span<const uint8_t> bytes, const ColorHints& color_hints,
     50                    extras::PackedPixelFile* ppf,
     51                    const SizeConstraints* constraints = nullptr,
     52                    Codec* orig_codec = nullptr);
     53 
     54 }  // namespace extras
     55 }  // namespace jxl
     56 
     57 #endif  // LIB_EXTRAS_DEC_DECODE_H_