libjxl

FORK: libjxl patches used on blog
git clone https://git.neptards.moe/blog/libjxl.git
Log | Files | Refs | Submodules | README | LICENSE

dec_external_image.h (2875B)


      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_DEC_EXTERNAL_IMAGE_H_
      7 #define LIB_JXL_DEC_EXTERNAL_IMAGE_H_
      8 
      9 // Interleaved image for color transforms and Codec.
     10 
     11 #include <jxl/types.h>
     12 #include <stddef.h>
     13 
     14 #include "lib/jxl/base/data_parallel.h"
     15 #include "lib/jxl/base/status.h"
     16 #include "lib/jxl/dec_cache.h"
     17 #include "lib/jxl/image.h"
     18 #include "lib/jxl/image_bundle.h"
     19 #include "lib/jxl/image_metadata.h"
     20 
     21 namespace jxl {
     22 
     23 // Maximum number of channels for the ConvertChannelsToExternal function.
     24 const size_t kConvertMaxChannels = 4;
     25 
     26 // Converts a list of channels to an interleaved image, applying transformations
     27 // when needed.
     28 // The input channels are given as a (non-const!) array of channel pointers and
     29 // interleaved in that order.
     30 //
     31 // Note: if a pointer in channels[] is nullptr, a 1.0 value will be used
     32 // instead. This is useful for handling when a user requests an alpha channel
     33 // from an image that doesn't have one. The first channel in the list may not
     34 // be nullptr, since it is used to determine the image size.
     35 Status ConvertChannelsToExternal(const ImageF* in_channels[],
     36                                  size_t num_channels, size_t bits_per_sample,
     37                                  bool float_out, JxlEndianness endianness,
     38                                  size_t stride, jxl::ThreadPool* pool,
     39                                  void* out_image, size_t out_size,
     40                                  const PixelCallback& out_callback,
     41                                  jxl::Orientation undo_orientation);
     42 
     43 // Converts ib to interleaved void* pixel buffer with the given format.
     44 // bits_per_sample: must be 16 or 32 if float_out is true, and at most 16
     45 // if it is false. No bit packing is done.
     46 // num_channels: must be 1, 2, 3 or 4 for gray, gray+alpha, RGB, RGB+alpha.
     47 // This supports the features needed for the C API and does not perform
     48 // color space conversion.
     49 // TODO(lode): support rectangle crop.
     50 // stride_out is output scanline size in bytes, must be >=
     51 // output_xsize * output_bytes_per_pixel.
     52 // undo_orientation is an EXIF orientation to undo. Depending on the
     53 // orientation, the output xsize and ysize are swapped compared to input
     54 // xsize and ysize.
     55 Status ConvertToExternal(const jxl::ImageBundle& ib, size_t bits_per_sample,
     56                          bool float_out, size_t num_channels,
     57                          JxlEndianness endianness, size_t stride_out,
     58                          jxl::ThreadPool* thread_pool, void* out_image,
     59                          size_t out_size, const PixelCallback& out_callback,
     60                          jxl::Orientation undo_orientation,
     61                          bool unpremul_alpha = false);
     62 
     63 }  // namespace jxl
     64 
     65 #endif  // LIB_JXL_DEC_EXTERNAL_IMAGE_H_