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