enc_xyb.h (2009B)
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_XYB_H_ 7 #define LIB_JXL_ENC_XYB_H_ 8 9 // Converts to XYB color space. 10 11 #include <jxl/cms_interface.h> 12 13 #include <cstddef> 14 15 #include "lib/jxl/base/compiler_specific.h" 16 #include "lib/jxl/base/data_parallel.h" 17 #include "lib/jxl/base/status.h" 18 #include "lib/jxl/color_encoding_internal.h" 19 #include "lib/jxl/image.h" 20 #include "lib/jxl/image_bundle.h" 21 22 namespace jxl { 23 24 // Converts any color space to XYB in-place. If `linear` is not null, fills it 25 // with a linear sRGB copy of `image`. 26 void ToXYB(const ColorEncoding& c_current, float intensity_target, 27 const ImageF* black, ThreadPool* pool, Image3F* JXL_RESTRICT image, 28 const JxlCmsInterface& cms, Image3F* JXL_RESTRICT linear); 29 30 Status ToXYB(const ImageBundle& in, ThreadPool* pool, Image3F* JXL_RESTRICT xyb, 31 const JxlCmsInterface& cms, 32 Image3F* JXL_RESTRICT linear = nullptr); 33 34 void LinearRGBRowToXYB(float* JXL_RESTRICT row0, float* JXL_RESTRICT row1, 35 float* JXL_RESTRICT row2, 36 const float* JXL_RESTRICT premul_absorb, size_t xsize); 37 38 void ComputePremulAbsorb(float intensity_target, float* premul_absorb); 39 40 // Transforms each color component of the given XYB image into the [0.0, 1.0] 41 // interval with an affine transform. 42 void ScaleXYB(Image3F* opsin); 43 void ScaleXYBRow(float* row0, float* row1, float* row2, size_t xsize); 44 45 // Bt.601 to match JPEG/JFIF. Outputs _signed_ YCbCr values suitable for DCT, 46 // see F.1.1.3 of T.81 (because our data type is float, there is no need to add 47 // a bias to make the values unsigned). 48 Status RgbToYcbcr(const ImageF& r_plane, const ImageF& g_plane, 49 const ImageF& b_plane, ImageF* y_plane, ImageF* cb_plane, 50 ImageF* cr_plane, ThreadPool* pool); 51 52 } // namespace jxl 53 54 #endif // LIB_JXL_ENC_XYB_H_