/src/libjxl/lib/extras/codec.h
Line | Count | Source (jump to first uncovered line) |
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_CODEC_H_ |
7 | | #define LIB_EXTRAS_CODEC_H_ |
8 | | |
9 | | // Facade for image encoders/decoders (PNG, PNM, ...). |
10 | | |
11 | | #include <stddef.h> |
12 | | #include <stdint.h> |
13 | | |
14 | | #include <string> |
15 | | |
16 | | #include "lib/extras/dec/color_hints.h" |
17 | | #include "lib/extras/dec/decode.h" |
18 | | #include "lib/jxl/base/compiler_specific.h" |
19 | | #include "lib/jxl/base/data_parallel.h" |
20 | | #include "lib/jxl/base/span.h" |
21 | | #include "lib/jxl/base/status.h" |
22 | | #include "lib/jxl/codec_in_out.h" |
23 | | #include "lib/jxl/color_encoding_internal.h" |
24 | | #include "lib/jxl/field_encodings.h" // MakeBit |
25 | | |
26 | | namespace jxl { |
27 | | |
28 | | struct SizeConstraints; |
29 | | |
30 | | // Decodes "bytes" and sets io->metadata.m. |
31 | | // color_space_hint may specify the color space, otherwise, defaults to sRGB. |
32 | | Status SetFromBytes(Span<const uint8_t> bytes, |
33 | | const extras::ColorHints& color_hints, CodecInOut* io, |
34 | | ThreadPool* pool = nullptr, |
35 | | const SizeConstraints* constraints = nullptr, |
36 | | extras::Codec* orig_codec = nullptr); |
37 | | // Helper function to use no color_space_hint. |
38 | | JXL_INLINE Status SetFromBytes(const Span<const uint8_t> bytes, CodecInOut* io, |
39 | | ThreadPool* pool = nullptr, |
40 | | const SizeConstraints* constraints = nullptr, |
41 | 0 | extras::Codec* orig_codec = nullptr) { |
42 | 0 | return SetFromBytes(bytes, extras::ColorHints(), io, pool, constraints, |
43 | 0 | orig_codec); |
44 | 0 | } |
45 | | |
46 | | Status Encode(const extras::PackedPixelFile& ppf, extras::Codec codec, |
47 | | std::vector<uint8_t>* bytes, ThreadPool* pool); |
48 | | |
49 | | Status Encode(const extras::PackedPixelFile& ppf, const std::string& pathname, |
50 | | std::vector<uint8_t>* bytes, ThreadPool* pool = nullptr); |
51 | | |
52 | | } // namespace jxl |
53 | | |
54 | | #endif // LIB_EXTRAS_CODEC_H_ |