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_JXL_ENC_FRAME_H_
7 #define LIB_JXL_ENC_FRAME_H_
8 
9 #include "lib/jxl/aux_out.h"
10 #include "lib/jxl/aux_out_fwd.h"
11 #include "lib/jxl/base/data_parallel.h"
12 #include "lib/jxl/base/status.h"
13 #include "lib/jxl/enc_bit_writer.h"
14 #include "lib/jxl/enc_cache.h"
15 #include "lib/jxl/enc_params.h"
16 #include "lib/jxl/frame_header.h"
17 #include "lib/jxl/image_bundle.h"
18 
19 namespace jxl {
20 
21 // Information needed for encoding a frame that is not contained elsewhere and
22 // does not belong to `cparams`.
23 struct FrameInfo {
24   // TODO(veluca): consider adding more parameters, such as custom patches.
25   bool save_before_color_transform = false;
26   // Whether or not the input image bundle is already in the codestream
27   // colorspace (as deduced by cparams).
28   // TODO(veluca): this is a hack - ImageBundle doesn't have a simple way to say
29   // "this is already in XYB".
30   bool ib_needs_color_transform = true;
31   FrameType frame_type = FrameType::kRegularFrame;
32   size_t dc_level = 0;
33   // Only used for kRegularFrame.
34   bool is_last = true;
35   bool is_preview = false;
36   // Information for storing this frame for future use (only for non-DC frames).
37   size_t save_as_reference = 0;
38 };
39 
40 // Encodes a single frame (including its header) into a byte stream.  Groups may
41 // be processed in parallel by `pool`. metadata is the ImageMetadata encoded in
42 // the codestream, and must be used for the FrameHeaders, do not use
43 // ib.metadata.
44 Status EncodeFrame(const CompressParams& cparams_orig,
45                    const FrameInfo& frame_info, const CodecMetadata* metadata,
46                    const ImageBundle& ib, PassesEncoderState* passes_enc_state,
47                    ThreadPool* pool, BitWriter* writer, AuxOut* aux_out);
48 
49 }  // namespace jxl
50 
51 #endif  // LIB_JXL_ENC_FRAME_H_
52