1 // Copyright (c) the JPEG XL Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file.
6 #ifndef LIB_JXL_ENC_FILE_H_
7 #define LIB_JXL_ENC_FILE_H_
9 // Facade for JXL encoding.
11 #include "lib/jxl/aux_out.h"
12 #include "lib/jxl/aux_out_fwd.h"
13 #include "lib/jxl/base/data_parallel.h"
14 #include "lib/jxl/base/padded_bytes.h"
15 #include "lib/jxl/base/status.h"
16 #include "lib/jxl/codec_in_out.h"
17 #include "lib/jxl/enc_cache.h"
18 #include "lib/jxl/enc_params.h"
22 // Write preview from `io`.
23 Status EncodePreview(const CompressParams& cparams, const ImageBundle& ib,
24 const CodecMetadata* metadata, const JxlCmsInterface& cms,
25 ThreadPool* pool, BitWriter* JXL_RESTRICT writer);
27 // Write headers from the CodecMetadata. Also may modify nonserialized_...
28 // fields of the metadata.
29 Status WriteHeaders(CodecMetadata* metadata, BitWriter* writer,
32 // Compresses pixels from `io` (given in any ColorEncoding).
33 // `io->metadata.m.original` must be set.
34 Status EncodeFile(const CompressParams& params, const CodecInOut* io,
35 PassesEncoderState* passes_enc_state, PaddedBytes* compressed,
36 const JxlCmsInterface& cms, AuxOut* aux_out = nullptr,
37 ThreadPool* pool = nullptr);
39 // Backwards-compatible interface. Don't use in new code.
40 // TODO(deymo): Remove this function once we migrate users to C encoder API.
41 struct FrameEncCache {};
42 JXL_INLINE Status EncodeFile(const CompressParams& params, const CodecInOut* io,
43 FrameEncCache* /* unused */,
44 PaddedBytes* compressed,
45 const JxlCmsInterface& cms,
46 AuxOut* aux_out = nullptr,
47 ThreadPool* pool = nullptr) {
48 PassesEncoderState passes_enc_state;
49 return EncodeFile(params, io, &passes_enc_state, compressed, cms, aux_out,
55 #endif // LIB_JXL_ENC_FILE_H_