tor-browser

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

decode.h (1464B)


      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 <cstddef>
     12 #include <cstdint>
     13 #include <string>
     14 
     15 #include "lib/extras/dec/color_hints.h"
     16 #include "lib/jxl/base/span.h"
     17 #include "lib/jxl/base/status.h"
     18 
     19 namespace jxl {
     20 
     21 struct SizeConstraints;
     22 
     23 namespace extras {
     24 
     25 // Codecs supported by DecodeBytes.
     26 enum class Codec : uint32_t {
     27  kUnknown,  // for CodecFromPath
     28  kPNG,
     29  kPNM,
     30  kPGX,
     31  kJPG,
     32  kGIF,
     33  kEXR,
     34  kJXL
     35 };
     36 
     37 bool CanDecode(Codec codec);
     38 
     39 std::string ListOfDecodeCodecs();
     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_