diff --git a/media/libjxl/moz.build b/media/libjxl/moz.build index 7c55bd73bbef..0754ad99779f 100644 --- a/media/libjxl/moz.build +++ b/media/libjxl/moz.build @@ -207,22 +207,6 @@ lib / jxl / -convolve_separable7 -. -cc -" -" -/ -third_party -/ -jpeg -- -xl -/ -lib -/ -jxl -/ convolve_slow . cc @@ -575,22 +559,6 @@ lib / jxl / -gauss_blur -. -cc -" -" -/ -third_party -/ -jpeg -- -xl -/ -lib -/ -jxl -/ headers . cc diff --git a/media/libjxl/moz.yaml b/media/libjxl/moz.yaml index a6a728017abd..8727c5bf3d3b 100644 --- a/media/libjxl/moz.yaml +++ b/media/libjxl/moz.yaml @@ -41,22 +41,22 @@ libjxl libjxl release : -b26041c708d523ac53bb7d95d4f5c4a5d3b1ce30 +07203da045f6b41f9b3b5b86023fd70b075137f6 ( 2024 - 01 - -08T13 +29T17 : -55 +41 : -50Z +05Z ) . revision : -b26041c708d523ac53bb7d95d4f5c4a5d3b1ce30 +07203da045f6b41f9b3b5b86023fd70b075137f6 license : Apache diff --git a/third_party/jpeg-xl/AUTHORS b/third_party/jpeg-xl/AUTHORS index 14ebd6f773db..857bfbec48c9 100644 --- a/third_party/jpeg-xl/AUTHORS +++ b/third_party/jpeg-xl/AUTHORS @@ -587,6 +587,7 @@ gmail . com > +sandstrom Sergey Fedorov < @@ -658,6 +659,14 @@ gmail . com > +Wonwoo +Choi +< +chwo9843 +gmail +. +com +> xiota Yonatan Nebenzhal @@ -691,3 +700,10 @@ github . com > +oupson +< +oupson1er +gmail +. +com +> diff --git a/third_party/jpeg-xl/CMakeLists.txt b/third_party/jpeg-xl/CMakeLists.txt index cb1804dcc16f..666c8a24598b 100644 --- a/third_party/jpeg-xl/CMakeLists.txt +++ b/third_party/jpeg-xl/CMakeLists.txt @@ -1242,6 +1242,21 @@ size . " ) +set +( +JPEGXL_ENABLE_WASM_TRHEADS +true +CACHE +BOOL +" +Builds +WASM +modules +with +threads +suppurt +" +) # Force system @@ -2126,6 +2141,8 @@ JPEGXL_STATIC if ( EMSCRIPTEN +AND +JPEGXL_ENABLE_WASM_TRHEADS ) set ( diff --git a/third_party/jpeg-xl/deps.sh b/third_party/jpeg-xl/deps.sh index d9461de8a27c..d773817a7295 100644 --- a/third_party/jpeg-xl/deps.sh +++ b/third_party/jpeg-xl/deps.sh @@ -132,8 +132,14 @@ e5ab13008bb214deb66d5f3e17ca2f8dbff150bf THIRD_PARTY_ZLIB = " -cacf7f1d4e3d44d871b605da3b647f07d718623f +51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf " +# +v1 +. +3 +. +1 THIRD_PARTY_LIBPNG = " diff --git a/third_party/jpeg-xl/examples/decode_oneshot.cc b/third_party/jpeg-xl/examples/decode_oneshot.cc index 06d169de6e95..1257aece6732 100644 --- a/third_party/jpeg-xl/examples/decode_oneshot.cc +++ b/third_party/jpeg-xl/examples/decode_oneshot.cc @@ -18,6 +18,15 @@ include < jxl / +codestream_header +. +h +> +# +include +< +jxl +/ decode . h @@ -52,6 +61,15 @@ h # include < +jxl +/ +types +. +h +> +# +include +< limits . h diff --git a/third_party/jpeg-xl/examples/encode_oneshot.cc b/third_party/jpeg-xl/examples/encode_oneshot.cc index ca93204ca0fa..eff1308c4aba 100644 --- a/third_party/jpeg-xl/examples/encode_oneshot.cc +++ b/third_party/jpeg-xl/examples/encode_oneshot.cc @@ -3,6 +3,24 @@ include < jxl / +codestream_header +. +h +> +# +include +< +jxl +/ +color_encoding +. +h +> +# +include +< +jxl +/ encode . h @@ -37,6 +55,15 @@ h # include < +jxl +/ +types +. +h +> +# +include +< limits . h @@ -51,6 +78,16 @@ h # include < +cstdint +> +# +include +< +cstdio +> +# +include +< sstream > # diff --git a/third_party/jpeg-xl/lib/BUILD b/third_party/jpeg-xl/lib/BUILD index d9eda8046a24..e1fa014df838 100644 --- a/third_party/jpeg-xl/lib/BUILD +++ b/third_party/jpeg-xl/lib/BUILD @@ -807,33 +807,6 @@ JPEGXL_ENABLE_SKCMS = 1 " -" -JPEGXL_MAJOR_VERSION -= -" -+ -str -( -libjxl_major_version -) -" -JPEGXL_MINOR_VERSION -= -" -+ -str -( -libjxl_minor_version -) -" -JPEGXL_PATCH_VERSION -= -" -+ -str -( -libjxl_patch_version -) ] deps = diff --git a/third_party/jpeg-xl/lib/CMakeLists.txt b/third_party/jpeg-xl/lib/CMakeLists.txt index 8ad1b972a7c4..a834a00f6222 100644 --- a/third_party/jpeg-xl/lib/CMakeLists.txt +++ b/third_party/jpeg-xl/lib/CMakeLists.txt @@ -936,21 +936,26 @@ endif ( ) # -Install +For +simplicity all the library headers -from -the +both source and -the generated ones +are +# +gathered +in +the +binary +folder . There -# is no distinction @@ -958,19 +963,20 @@ on which libraries use +# which header since it is expected -# that all developer libraries are available +# together at build @@ -980,23 +986,6 @@ install ( DIRECTORY { -CMAKE_CURRENT_SOURCE_DIR -} -/ -include -/ -jxl -DESTINATION -" -{ -CMAKE_INSTALL_INCLUDEDIR -} -" -) -install -( -DIRECTORY -{ CMAKE_CURRENT_BINARY_DIR } / diff --git a/third_party/jpeg-xl/lib/extras/codec.cc b/third_party/jpeg-xl/lib/extras/codec.cc index 3a7cfd4003e9..0be9e8b8a17b 100644 --- a/third_party/jpeg-xl/lib/extras/codec.cc +++ b/third_party/jpeg-xl/lib/extras/codec.cc @@ -265,21 +265,18 @@ Status Encode ( const -CodecInOut +extras +: +: +PackedPixelFile & -io +ppf const extras : : Codec codec -const -ColorEncoding -& -c_desired -size_t -bits_per_sample std : : @@ -301,98 +298,6 @@ clear ( ) ; -JXL_CHECK -( -! -io -. -Main -( -) -. -c_current -( -) -. -ICC -( -) -. -empty -( -) -) -; -JXL_CHECK -( -! -c_desired -. -ICC -( -) -. -empty -( -) -) -; -io -. -CheckMetadata -( -) -; -if -( -io -. -Main -( -) -. -IsJPEG -( -) -) -{ -JXL_WARNING -( -" -Writing -JPEG -data -as -pixels -" -) -; -} -JxlPixelFormat -format -= -{ -0 -bits_per_sample -< -= -8 -? -JXL_TYPE_UINT8 -: -JXL_TYPE_UINT16 -JXL_BIG_ENDIAN -0 -} -; -const -bool -floating_point -= -bits_per_sample -> -16 -; std : : @@ -405,12 +310,6 @@ Encoder > encoder ; -std -: -: -ostringstream -os -; switch ( codec @@ -471,12 +370,6 @@ Codec : kJPG : -format -. -data_type -= -JXL_TYPE_UINT8 -; encoder = extras @@ -491,28 +384,6 @@ if encoder ) { -os -< -< -io -. -jpeg_quality -; -encoder -- -> -SetOption -( -" -q -" -os -. -str -( -) -) -; break ; } @@ -544,15 +415,13 @@ kPNM : if ( -io +ppf . -Main -( -) +info . -HasAlpha -( -) +alpha_bits +> +0 ) { encoder @@ -568,15 +437,14 @@ GetPAMEncoder else if ( -io +ppf . -Main -( -) +info . -IsGray -( -) +num_color_channels += += +1 ) { encoder @@ -592,8 +460,14 @@ GetPGMEncoder else if ( -! -floating_point +ppf +. +info +. +bits_per_sample +< += +16 ) { encoder @@ -608,18 +482,6 @@ GetPPMEncoder } else { -format -. -data_type -= -JXL_TYPE_FLOAT -; -format -. -endianness -= -JXL_LITTLE_ENDIAN -; encoder = extras @@ -683,12 +545,6 @@ Codec : kEXR : -format -. -data_type -= -JXL_TYPE_FLOAT -; encoder = extras @@ -791,60 +647,6 @@ codec extras : : -PackedPixelFile -ppf -; -JXL_RETURN_IF_ERROR -( -ConvertCodecInOutToPackedPixelFile -( -io -format -c_desired -pool -& -ppf -) -) -; -ppf -. -info -. -bits_per_sample -= -bits_per_sample -; -if -( -format -. -data_type -= -= -JXL_TYPE_FLOAT -) -{ -ppf -. -info -. -bits_per_sample -= -32 -; -ppf -. -info -. -exponent_bits_per_sample -= -8 -; -} -extras -: -: EncodedImage encoded_image ; @@ -894,15 +696,12 @@ Status Encode ( const -CodecInOut -& -io -const -ColorEncoding +extras +: +: +PackedPixelFile & -c_desired -size_t -bits_per_sample +ppf const std : @@ -943,342 +742,16 @@ extras CodecFromPath ( pathname -& -bits_per_sample +nullptr & extension ) ; -if -( -codec -= -= -extras -: -: -Codec -: -: -kPNM -& -& -extension -! -= -" -. -pfm -" -) -{ -if -( -io -. -Main -( -) -. -HasAlpha -( -) -& -& -extension -! -= -" -. -pam -" -) -{ -JXL_WARNING -( -" -For -images -with -alpha -the -filename -should -end -with -. -pam -. -\ -n -" -) -; -} -else -if -( -! -io -. -Main -( -) -. -IsGray -( -) -& -& -extension -= -= -" -. -pgm -" -) -{ -JXL_WARNING -( -" -For -color -images -the -filename -should -end -with -. -ppm -. -\ -n -" -) -; -} -else -if -( -io -. -Main -( -) -. -IsGray -( -) -& -& -extension -= -= -" -. -ppm -" -) -{ -JXL_WARNING -( -" -For -grayscale -images -the -filename -should -not -end -with -. -ppm -. -\ -n -" -) -; -} -if -( -bits_per_sample -> -16 -) -{ -JXL_WARNING -( -" -PPM -only -supports -up -to -16 -bits -per -sample -" -) -; -bits_per_sample -= -16 -; -} -} -else -if -( -codec -= -= -extras -: -: -Codec -: -: -kPGX -& -& -! -io -. -Main -( -) -. -IsGray -( -) -) -{ -JXL_WARNING -( -" -Storing -color -image -to -PGX -- -use -. -ppm -extension -instead -. -\ -n -" -) -; -} -if -( -bits_per_sample -> -16 -& -& -codec -= -= -extras -: -: -Codec -: -: -kPNG -) -{ -JXL_WARNING -( -" -PNG -only -supports -up -to -16 -bits -per -sample -" -) -; -bits_per_sample -= -16 -; -} return Encode ( -io +ppf codec -c_desired -bits_per_sample -bytes -pool -) -; -} -Status -Encode -( -const -CodecInOut -& -io -const -std -: -: -string -& -pathname -std -: -: -vector -< -uint8_t -> -* -bytes -ThreadPool -* -pool -) -{ -return -Encode -( -io -io -. -metadata -. -m -. -color_encoding -io -. -metadata -. -m -. -bit_depth -. -bits_per_sample -pathname bytes pool ) diff --git a/third_party/jpeg-xl/lib/extras/codec.h b/third_party/jpeg-xl/lib/extras/codec.h index 90567c65ac3e..78fec42a5910 100644 --- a/third_party/jpeg-xl/lib/extras/codec.h +++ b/third_party/jpeg-xl/lib/extras/codec.h @@ -236,20 +236,18 @@ Status Encode ( const -CodecInOut +extras +: +: +PackedPixelFile & -io +ppf +const extras : : Codec codec -const -ColorEncoding -& -c_desired -size_t -bits_per_sample std : : @@ -262,53 +260,18 @@ bytes ThreadPool * pool -= -nullptr ) ; Status Encode ( const -CodecInOut -& -io -const -ColorEncoding -& -c_desired -size_t -bits_per_sample -const -std -: -: -string -& -pathname -std +extras : : -vector -< -uint8_t -> -* -bytes -ThreadPool -* -pool -= -nullptr -) -; -Status -Encode -( -const -CodecInOut +PackedPixelFile & -io +ppf const std : diff --git a/third_party/jpeg-xl/lib/extras/codec_test.cc b/third_party/jpeg-xl/lib/extras/codec_test.cc index 6a88f2754724..dc20fbd381a0 100644 --- a/third_party/jpeg-xl/lib/extras/codec_test.cc +++ b/third_party/jpeg-xl/lib/extras/codec_test.cc @@ -1,14 +1,39 @@ # include -" -lib +< +jxl / -extras +codestream_header +. +h +> +# +include +< +jxl / -codec +color_encoding . h -" +> +# +include +< +jxl +/ +encode +. +h +> +# +include +< +jxl +/ +types +. +h +> # include < @@ -29,6 +54,21 @@ cstdint # include < +cstdio +> +# +include +< +cstring +> +# +include +< +memory +> +# +include +< sstream > # @@ -66,6 +106,19 @@ extras / dec / +color_hints +. +h +" +# +include +" +lib +/ +extras +/ +dec +/ decode . h @@ -101,6 +154,30 @@ include " lib / +extras +/ +packed_image +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +byte_order +. +h +" +# +include +" +lib +/ jxl / base @@ -142,6 +219,17 @@ lib / jxl / +color_encoding_internal +. +h +" +# +include +" +lib +/ +jxl +/ test_utils . h diff --git a/third_party/jpeg-xl/lib/extras/dec/decode.cc b/third_party/jpeg-xl/lib/extras/dec/decode.cc index f5826cef821e..50127f32bb5d 100644 --- a/third_party/jpeg-xl/lib/extras/dec/decode.cc +++ b/third_party/jpeg-xl/lib/extras/dec/decode.cc @@ -201,12 +201,6 @@ std : : string -base -; -std -: -: -string ext = GetExtension diff --git a/third_party/jpeg-xl/lib/extras/dec/pnm.cc b/third_party/jpeg-xl/lib/extras/dec/pnm.cc index 584cf6bef5ad..e331526d06a6 100644 --- a/third_party/jpeg-xl/lib/extras/dec/pnm.cc +++ b/third_party/jpeg-xl/lib/extras/dec/pnm.cc @@ -2736,13 +2736,7 @@ ppm ; } return -std -: -: -move -( dec -) ; } jxl diff --git a/third_party/jpeg-xl/lib/extras/enc/apng.cc b/third_party/jpeg-xl/lib/extras/enc/apng.cc index bdac38c061e7..2ce9d4b861e4 100644 --- a/third_party/jpeg-xl/lib/extras/enc/apng.cc +++ b/third_party/jpeg-xl/lib/extras/enc/apng.cc @@ -2128,28 +2128,6 @@ count if ( ! -MaybeAddSRGB -( -ppf -. -color_encoding -png_ptr -info_ptr -) -) -{ -MaybeAddCICP -( -ppf -. -color_encoding -png_ptr -info_ptr -) -; -if -( -! ppf . icc @@ -2190,6 +2168,29 @@ size ) ; } +else +if +( +! +MaybeAddSRGB +( +ppf +. +color_encoding +png_ptr +info_ptr +) +) +{ +MaybeAddCICP +( +ppf +. +color_encoding +png_ptr +info_ptr +) +; MaybeAddCHRM ( ppf diff --git a/third_party/jpeg-xl/lib/extras/enc/jpegli.cc b/third_party/jpeg-xl/lib/extras/enc/jpegli.cc index d881434dc76a..aa5a823bda6e 100644 --- a/third_party/jpeg-xl/lib/extras/enc/jpegli.cc +++ b/third_party/jpeg-xl/lib/extras/enc/jpegli.cc @@ -32,6 +32,15 @@ h # include < +jxl +/ +types +. +h +> +# +include +< setjmp . h @@ -45,6 +54,60 @@ h > # include +< +algorithm +> +# +include +< +cmath +> +# +include +< +cstddef +> +# +include +< +cstdlib +> +# +include +< +cstring +> +# +include +< +hwy +/ +aligned_allocator +. +h +> +# +include +< +limits +> +# +include +< +string +> +# +include +< +utility +> +# +include +< +vector +> +# +include " lib / @@ -61,6 +124,28 @@ include " lib / +extras +/ +packed_image +. +h +" +# +include +" +lib +/ +jpegli +/ +common +. +h +" +# +include +" +lib +/ jpegli / encode @@ -72,12 +157,97 @@ include " lib / +jpegli +/ +types +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +byte_order +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +common +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +data_parallel +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +status +. +h +" +# +include +" +lib +/ +jxl +/ +color_encoding_internal +. +h +" +# +include +" +lib +/ jxl / enc_xyb . h " +# +include +" +lib +/ +jxl +/ +image +. +h +" namespace jxl { diff --git a/third_party/jpeg-xl/lib/extras/enc/jpg.cc b/third_party/jpeg-xl/lib/extras/enc/jpg.cc index a3f6cabe2afc..82a1325e8d02 100644 --- a/third_party/jpeg-xl/lib/extras/enc/jpg.cc +++ b/third_party/jpeg-xl/lib/extras/enc/jpg.cc @@ -1276,60 +1276,6 @@ return true ; } -bool -IsSRGBEncoding -( -const -JxlColorEncoding -& -c -) -{ -return -( -( -c -. -color_space -= -= -JXL_COLOR_SPACE_RGB -| -| -c -. -color_space -= -= -JXL_COLOR_SPACE_GRAY -) -& -& -c -. -primaries -= -= -JXL_PRIMARIES_SRGB -& -& -c -. -white_point -= -= -JXL_WHITE_POINT_D65 -& -& -c -. -transfer_function -= -= -JXL_TRANSFER_FUNCTION_SRGB -) -; -} void WriteICCProfile ( @@ -4777,33 +4723,6 @@ color_space JXL_COLOR_SPACE_XYB ) ; -std -: -: -vector -< -uint8_t -> -icc -; -if -( -! -IsSRGBEncoding -( -ppf -. -color_encoding -) -) -{ -icc -= -ppf -. -icc -; -} encoded_image - > @@ -4873,6 +4792,8 @@ color ppf . info +ppf +. icc ppf . diff --git a/third_party/jpeg-xl/lib/extras/jpegli_test.cc b/third_party/jpeg-xl/lib/extras/jpegli_test.cc index d157d73358ff..b43896c31a47 100644 --- a/third_party/jpeg-xl/lib/extras/jpegli_test.cc +++ b/third_party/jpeg-xl/lib/extras/jpegli_test.cc @@ -26,6 +26,15 @@ h # include < +jxl +/ +types +. +h +> +# +include +< stdint . h @@ -33,21 +42,51 @@ h # include < +cstddef +> +# +include +< cstdint > # include < +cstdio +> +# +include +< +cstring +> +# +include +< memory > # include < +ostream +> +# +include +< +sstream +> +# +include +< string > # include < +utility +> +# +include +< vector > # diff --git a/third_party/jpeg-xl/lib/extras/packed_image.h b/third_party/jpeg-xl/lib/extras/packed_image.h index a0cab4ed9d8c..350eca155432 100644 --- a/third_party/jpeg-xl/lib/extras/packed_image.h +++ b/third_party/jpeg-xl/lib/extras/packed_image.h @@ -1305,6 +1305,30 @@ size ) ; } +size_t +xsize +( +) +const +{ +return +info +. +xsize +; +} +size_t +ysize +( +) +const +{ +return +info +. +ysize +; +} } ; } diff --git a/third_party/jpeg-xl/lib/extras/packed_image_convert.cc b/third_party/jpeg-xl/lib/extras/packed_image_convert.cc index 12e8ed88e131..ad4360b3dd27 100644 --- a/third_party/jpeg-xl/lib/extras/packed_image_convert.cc +++ b/third_party/jpeg-xl/lib/extras/packed_image_convert.cc @@ -819,6 +819,43 @@ info alpha_premultiplied ) ; +ExtraChannelInfo +* +alpha += +io +- +> +metadata +. +m +. +Find +( +ExtraChannel +: +: +kAlpha +) +; +if +( +alpha +) +alpha +- +> +bit_depth += +io +- +> +metadata +. +m +. +bit_depth +; io - > @@ -1647,6 +1684,249 @@ return true ; } +PackedPixelFile +ConvertImage3FToPackedPixelFile +( +const +Image3F +& +image +const +ColorEncoding +& +c_enc +JxlPixelFormat +format +ThreadPool +* +pool +) +{ +PackedPixelFile +ppf +; +ppf +. +info +. +xsize += +image +. +xsize +( +) +; +ppf +. +info +. +ysize += +image +. +ysize +( +) +; +ppf +. +info +. +num_color_channels += +3 +; +ppf +. +info +. +bits_per_sample += +PackedImage +: +: +BitsPerChannel +( +format +. +data_type +) +; +ppf +. +info +. +exponent_bits_per_sample += +format +. +data_type += += +JXL_TYPE_FLOAT +? +8 +: +format +. +data_type += += +JXL_TYPE_FLOAT16 +? +5 +: +0 +; +ppf +. +color_encoding += +c_enc +. +ToExternal +( +) +; +ppf +. +frames +. +clear +( +) +; +PackedFrame +frame +( +image +. +xsize +( +) +image +. +ysize +( +) +format +) +; +const +ImageF +* +channels +[ +3 +] +; +for +( +int +c += +0 +; +c +< +3 +; ++ ++ +c +) +{ +channels +[ +c +] += +& +image +. +Plane +( +c +) +; +} +bool +float_samples += +ppf +. +info +. +exponent_bits_per_sample +> +0 +; +JXL_CHECK +( +ConvertChannelsToExternal +( +channels +3 +ppf +. +info +. +bits_per_sample +float_samples +format +. +endianness +frame +. +color +. +stride +pool +frame +. +color +. +pixels +( +0 +0 +0 +) +frame +. +color +. +pixels_size +PixelCallback +( +) +Orientation +: +: +kIdentity +) +) +; +ppf +. +frames +. +emplace_back +( +std +: +: +move +( +frame +) +) +; +return +ppf +; +} Status ConvertCodecInOutToPackedPixelFile ( @@ -1684,11 +1964,6 @@ HasAlpha ( ) ; -bool -alpha_premultiplied -= -false -; JXL_ASSERT ( ! @@ -1770,6 +2045,39 @@ bit_depth exponent_bits_per_sample ) ; +ppf +- +> +info +. +alpha_bits += +alpha_channel +- +> +bit_depth +. +bits_per_sample +; +ppf +- +> +info +. +alpha_exponent_bits += +alpha_channel +- +> +bit_depth +. +exponent_bits_per_sample +; +ppf +- +> +info +. alpha_premultiplied = alpha_channel @@ -1938,32 +2246,6 @@ ppf > info . -alpha_bits -= -io -. -metadata -. -m -. -GetAlphaBits -( -) -; -ppf -- -> -info -. -alpha_premultiplied -= -alpha_premultiplied -; -ppf -- -> -info -. uses_original_profile = ! diff --git a/third_party/jpeg-xl/lib/extras/packed_image_convert.h b/third_party/jpeg-xl/lib/extras/packed_image_convert.h index 7cf79907f922..9018df46aa63 100644 --- a/third_party/jpeg-xl/lib/extras/packed_image_convert.h +++ b/third_party/jpeg-xl/lib/extras/packed_image_convert.h @@ -92,6 +92,24 @@ PackedPixelFile ppf ) ; +PackedPixelFile +ConvertImage3FToPackedPixelFile +( +const +Image3F +& +image +const +ColorEncoding +& +c_enc +JxlPixelFormat +format +ThreadPool +* +pool +) +; } } # diff --git a/third_party/jpeg-xl/lib/include/jxl/cms_interface.h b/third_party/jpeg-xl/lib/include/jxl/cms_interface.h index cbff477dd99c..eab85c9945cf 100644 --- a/third_party/jpeg-xl/lib/include/jxl/cms_interface.h +++ b/third_party/jpeg-xl/lib/include/jxl/cms_interface.h @@ -23,6 +23,20 @@ types h > # +include +< +stddef +. +h +> +# +include +< +stdint +. +h +> +# if defined ( diff --git a/third_party/jpeg-xl/lib/include/jxl/decode_cxx.h b/third_party/jpeg-xl/lib/include/jxl/decode_cxx.h index ea3b5a6a369f..bea491114ae9 100644 --- a/third_party/jpeg-xl/lib/include/jxl/decode_cxx.h +++ b/third_party/jpeg-xl/lib/include/jxl/decode_cxx.h @@ -16,6 +16,15 @@ h # include < +jxl +/ +memory_manager +. +h +> +# +include +< memory > # diff --git a/third_party/jpeg-xl/lib/include/jxl/encode.h b/third_party/jpeg-xl/lib/include/jxl/encode.h index 126c6514de71..bc92ccf0f0b1 100644 --- a/third_party/jpeg-xl/lib/include/jxl/encode.h +++ b/third_party/jpeg-xl/lib/include/jxl/encode.h @@ -27,6 +27,15 @@ include < jxl / +color_encoding +. +h +> +# +include +< +jxl +/ jxl_export . h @@ -63,6 +72,15 @@ include < jxl / +types +. +h +> +# +include +< +jxl +/ version . h @@ -70,19 +88,17 @@ h # include < -stdint +stddef . h > # include -" -jxl -/ -types +< +stdint . h -" +> # if defined @@ -278,6 +294,9 @@ JXL_ENC_FRAME_SETTING_JPEG_KEEP_XMP JXL_ENC_FRAME_SETTING_JPEG_KEEP_JUMBF = 37 +JXL_ENC_FRAME_SETTING_USE_FULL_IMAGE_HEURISTICS += +38 JXL_ENC_FRAME_SETTING_FILL_ENUM = 65535 @@ -809,10 +828,8 @@ JxlEncoderSetUpsamplingMode JxlEncoder * enc -const int64_t factor -const int64_t mode ) diff --git a/third_party/jpeg-xl/lib/include/jxl/encode_cxx.h b/third_party/jpeg-xl/lib/include/jxl/encode_cxx.h index d32db4565e45..cd1d10e145ed 100644 --- a/third_party/jpeg-xl/lib/include/jxl/encode_cxx.h +++ b/third_party/jpeg-xl/lib/include/jxl/encode_cxx.h @@ -16,6 +16,15 @@ h # include < +jxl +/ +memory_manager +. +h +> +# +include +< memory > # diff --git a/third_party/jpeg-xl/lib/include/jxl/resizable_parallel_runner_cxx.h b/third_party/jpeg-xl/lib/include/jxl/resizable_parallel_runner_cxx.h index 40d9b9f82e09..718001077e92 100644 --- a/third_party/jpeg-xl/lib/include/jxl/resizable_parallel_runner_cxx.h +++ b/third_party/jpeg-xl/lib/include/jxl/resizable_parallel_runner_cxx.h @@ -9,6 +9,15 @@ include < jxl / +memory_manager +. +h +> +# +include +< +jxl +/ resizable_parallel_runner . h diff --git a/third_party/jpeg-xl/lib/include/jxl/thread_parallel_runner_cxx.h b/third_party/jpeg-xl/lib/include/jxl/thread_parallel_runner_cxx.h index b147b8e5e459..cc6689cea9bd 100644 --- a/third_party/jpeg-xl/lib/include/jxl/thread_parallel_runner_cxx.h +++ b/third_party/jpeg-xl/lib/include/jxl/thread_parallel_runner_cxx.h @@ -9,6 +9,15 @@ include < jxl / +memory_manager +. +h +> +# +include +< +jxl +/ thread_parallel_runner . h @@ -16,6 +25,11 @@ h # include < +cstddef +> +# +include +< memory > # diff --git a/third_party/jpeg-xl/lib/jxl.cmake b/third_party/jpeg-xl/lib/jxl.cmake index 9d62446494ed..094dbdc8a6c6 100644 --- a/third_party/jpeg-xl/lib/jxl.cmake +++ b/third_party/jpeg-xl/lib/jxl.cmake @@ -189,21 +189,6 @@ endif set ( OBJ_COMPILE_DEFINITIONS -JPEGXL_MAJOR_VERSION -= -{ -JPEGXL_MAJOR_VERSION -} -JPEGXL_MINOR_VERSION -= -{ -JPEGXL_MINOR_VERSION -} -JPEGXL_PATCH_VERSION -= -{ -JPEGXL_PATCH_VERSION -} # Used to @@ -267,6 +252,22 @@ version h " ) +list +( +APPEND +JPEGXL_INTERNAL_PUBLIC_HEADERS +{ +CMAKE_CURRENT_BINARY_DIR +} +/ +include +/ +jxl +/ +version +. +h +) # Headers for @@ -398,6 +399,63 @@ PROJECT_SOURCE_DIR JXL_HWY_INCLUDE_DIRS } ) +# +On +android +link +with +log +to +use +android +- +related +log +functions +. +if +( +CMAKE_SYSTEM_NAME +STREQUAL +" +Android +" +) +find_library +( +log +- +lib +log +) +if +( +log +- +lib +) +target_link_libraries +( +jxl_base +INTERFACE +{ +log +- +lib +} +) +target_compile_definitions +( +jxl_base +INTERFACE +USE_ANDROID_LOGGER +) +endif +( +) +endif +( +) add_dependencies ( jxl_base diff --git a/third_party/jpeg-xl/lib/jxl/base/data_parallel.h b/third_party/jpeg-xl/lib/jxl/base/data_parallel.h index dca3e59fbcd9..165536da2ad6 100644 --- a/third_party/jpeg-xl/lib/jxl/base/data_parallel.h +++ b/third_party/jpeg-xl/lib/jxl/base/data_parallel.h @@ -36,7 +36,7 @@ jxl / base / -bits +compiler_specific . h " diff --git a/third_party/jpeg-xl/lib/jxl/base/float.h b/third_party/jpeg-xl/lib/jxl/base/float.h index 92faf0539998..c3b6e3fdeb2f 100644 --- a/third_party/jpeg-xl/lib/jxl/base/float.h +++ b/third_party/jpeg-xl/lib/jxl/base/float.h @@ -56,6 +56,19 @@ jxl / base / +compiler_specific +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ status . h @@ -341,6 +354,7 @@ i callback ( i +( src [ stride @@ -348,6 +362,9 @@ stride i ] * +257 +) +* scale ) ; diff --git a/third_party/jpeg-xl/lib/jxl/base/status.h b/third_party/jpeg-xl/lib/jxl/base/status.h index d1c2bba46ee3..1120755440c9 100644 --- a/third_party/jpeg-xl/lib/jxl/base/status.h +++ b/third_party/jpeg-xl/lib/jxl/base/status.h @@ -193,6 +193,80 @@ JXL_DEBUG_ON_ABORT JXL_DEBUG_ON_ERROR # endif +# +ifdef +USE_ANDROID_LOGGER +# +include +< +android +/ +log +. +h +> +# +define +LIBJXL_ANDROID_LOG_TAG +( +" +libjxl +" +) +inline +void +android_vprintf +( +const +char +* +format +va_list +args +) +{ +char +* +message += +nullptr +; +int +res += +vasprintf +( +& +message +format +args +) +; +if +( +res +! += +- +1 +) +{ +__android_log_write +( +ANDROID_LOG_DEBUG +LIBJXL_ANDROID_LOG_TAG +message +) +; +free +( +message +) +; +} +} +# +endif JXL_FORMAT ( 1 @@ -221,6 +295,17 @@ args format ) ; +# +ifdef +USE_ANDROID_LOGGER +android_vprintf +( +format +args +) +; +# +else vfprintf ( stderr @@ -228,6 +313,8 @@ format args ) ; +# +endif va_end ( args @@ -312,6 +399,11 @@ while 0 ) # +if +JXL_DEBUG_V_LEVEL +> +0 +# define JXL_DEBUG_V ( @@ -334,6 +426,20 @@ format __VA_ARGS__ ) # +else +# +define +JXL_DEBUG_V +( +level +format +. +. +. +) +# +endif +# ifdef JXL_DEBUG_WARNING # @@ -1281,6 +1387,17 @@ args format ) ; +# +ifdef +USE_ANDROID_LOGGER +android_vprintf +( +format +args +) +; +# +else vfprintf ( stderr @@ -1288,6 +1405,8 @@ format args ) ; +# +endif va_end ( args diff --git a/third_party/jpeg-xl/lib/jxl/blending_test.cc b/third_party/jpeg-xl/lib/jxl/blending_test.cc index 2570ceaecb12..5637da47535d 100644 --- a/third_party/jpeg-xl/lib/jxl/blending_test.cc +++ b/third_party/jpeg-xl/lib/jxl/blending_test.cc @@ -1,11 +1,30 @@ # include < +jxl +/ +types +. +h +> +# +include +< cstdint > # include < +sstream +> +# +include +< +utility +> +# +include +< vector > # @@ -15,7 +34,9 @@ lib / extras / -codec +dec +/ +decode . h " @@ -24,9 +45,35 @@ include " lib / +extras +/ +dec +/ jxl +. +h +" +# +include +" +lib +/ +extras / -image_test_utils +packed_image +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +span . h " @@ -100,22 +147,47 @@ jxl " ) ; -CodecInOut +extras +: +: +JXLDecompressParams +dparams +; +dparams +. +accepted_formats += +{ +{ +3 +JXL_TYPE_UINT16 +JXL_LITTLE_ENDIAN +0 +} +} +; +extras +: +: +PackedPixelFile decoded ; ASSERT_TRUE ( -test -: -: -DecodeFile +DecodeImageJXL ( -{ -} -Bytes +compressed +. +data ( +) compressed +. +size +( ) +dparams +nullptr & decoded ) @@ -139,10 +211,10 @@ i ; for ( -const -ImageBundle +auto & -ib +& +decoded_frame : decoded . @@ -201,42 +273,99 @@ str ) ) ; -CodecInOut -frame +extras +: +: +PackedPixelFile +decoded_frame_ppf +; +decoded_frame_ppf +. +info += +decoded +. +info +; +decoded_frame_ppf +. +icc += +decoded +. +icc +; +decoded_frame_ppf +. +color_encoding += +decoded +. +color_encoding +; +decoded_frame_ppf +. +extra_channels_info += +decoded +. +extra_channels_info +; +decoded_frame_ppf +. +frames +. +emplace_back +( +std +: +: +move +( +decoded_frame +) +) +; +extras +: +: +PackedPixelFile +expected_frame_ppf ; ASSERT_TRUE ( -SetFromBytes +extras +: +: +DecodeBytes ( Bytes ( compressed_frame ) +extras +: +: +ColorHints +( +) & -frame +expected_frame_ppf ) ) ; -JXL_EXPECT_OK -( -SamePixels +EXPECT_EQ ( -ib -. -color -( -) -* -frame -. -Main -( -) +0 . -color +0f +test +: +: +ComputeDistance2 ( -) -_ +decoded_frame_ppf +expected_frame_ppf ) ) ; diff --git a/third_party/jpeg-xl/lib/jxl/box_content_decoder.h b/third_party/jpeg-xl/lib/jxl/box_content_decoder.h index 7b115e82501c..96b9570be738 100644 --- a/third_party/jpeg-xl/lib/jxl/box_content_decoder.h +++ b/third_party/jpeg-xl/lib/jxl/box_content_decoder.h @@ -36,16 +36,6 @@ stdlib . h > -# -include -< -memory -> -# -include -< -vector -> namespace jxl { diff --git a/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc b/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc index 6e77392910e3..65d25def3310 100644 --- a/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc +++ b/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli.cc @@ -149,17 +149,6 @@ lib / jxl / -gauss_blur -. -h -" -# -include -" -lib -/ -jxl -/ image_ops . h diff --git a/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli_test.cc b/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli_test.cc index e7845a715b2a..ac5a87f26027 100644 --- a/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli_test.cc +++ b/third_party/jpeg-xl/lib/jxl/butteraugli/butteraugli_test.cc @@ -35,6 +35,11 @@ algorithm # include < +cstdint +> +# +include +< utility > # @@ -81,19 +86,6 @@ jxl / base / -span -. -h -" -# -include -" -lib -/ -jxl -/ -base -/ status . h @@ -882,9 +874,9 @@ EXPECT_NEAR ( diffval diffval2 -1e +5e - -10 +7 ) ; EXPECT_NEAR diff --git a/third_party/jpeg-xl/lib/jxl/cms/color_encoding_cms.h b/third_party/jpeg-xl/lib/jxl/cms/color_encoding_cms.h index e651d8e6f1f3..9c3773f5e521 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/color_encoding_cms.h +++ b/third_party/jpeg-xl/lib/jxl/cms/color_encoding_cms.h @@ -49,11 +49,6 @@ cstring # include < -string -> -# -include -< utility > # @@ -70,19 +65,6 @@ jxl / base / -common -. -h -" -# -include -" -lib -/ -jxl -/ -base -/ status . h diff --git a/third_party/jpeg-xl/lib/jxl/color_encoding_internal_test.cc b/third_party/jpeg-xl/lib/jxl/color_encoding_internal_test.cc index ab5c7bbbfa65..49e1156e1c31 100644 --- a/third_party/jpeg-xl/lib/jxl/color_encoding_internal_test.cc +++ b/third_party/jpeg-xl/lib/jxl/color_encoding_internal_test.cc @@ -43,17 +43,6 @@ lib / jxl / -encode_internal -. -h -" -# -include -" -lib -/ -jxl -/ test_utils . h diff --git a/third_party/jpeg-xl/lib/jxl/color_management_test.cc b/third_party/jpeg-xl/lib/jxl/color_management_test.cc index 20c0864c8d61..e6db8319db2d 100644 --- a/third_party/jpeg-xl/lib/jxl/color_management_test.cc +++ b/third_party/jpeg-xl/lib/jxl/color_management_test.cc @@ -31,12 +31,27 @@ algorithm # include < +cstddef +> +# +include +< cstdint > # include < -new +cstdio +> +# +include +< +cstdlib +> +# +include +< +ostream > # include @@ -50,6 +65,11 @@ utility > # include +< +vector +> +# +include " lib / @@ -83,7 +103,7 @@ jxl / base / -data_parallel +span . h " @@ -94,9 +114,9 @@ lib / jxl / -base +cms / -random +color_encoding_cms . h " @@ -107,9 +127,9 @@ lib / jxl / -base +cms / -span +opsin_params . h " @@ -120,9 +140,18 @@ lib / jxl / -cms +color_encoding_internal +. +h +" +# +include +" +lib / -color_encoding_cms +jxl +/ +enc_xyb . h " @@ -133,9 +162,18 @@ lib / jxl / -cms +image +. +h +" +# +include +" +lib / -opsin_params +jxl +/ +image_bundle . h " @@ -146,7 +184,7 @@ lib / jxl / -color_encoding_internal +image_metadata . h " @@ -157,7 +195,7 @@ lib / jxl / -enc_xyb +image_ops . h " diff --git a/third_party/jpeg-xl/lib/jxl/convolve.h b/third_party/jpeg-xl/lib/jxl/convolve.h index eecb08e867d4..c1e843159a18 100644 --- a/third_party/jpeg-xl/lib/jxl/convolve.h +++ b/third_party/jpeg-xl/lib/jxl/convolve.h @@ -13,11 +13,17 @@ h > # include -< -stdint +" +lib +/ +jxl +/ +base +/ +compiler_specific . h -> +" # include " @@ -137,27 +143,6 @@ vert ; } ; -struct -WeightsSeparable7 -{ -float -horz -[ -4 -* -4 -] -; -float -vert -[ -4 -* -4 -] -; -} -; const WeightsSymmetric3 & @@ -231,33 +216,6 @@ out_rect ) ; void -SlowSeparable7 -( -const -ImageF -& -in -const -Rect -& -in_rect -const -WeightsSeparable7 -& -weights -ThreadPool -* -pool -ImageF -* -out -const -Rect -& -out_rect -) -; -void Symmetric3 ( const @@ -355,29 +313,6 @@ ImageF out ) ; -void -Separable7 -( -const -ImageF -& -in -const -Rect -& -rect -const -WeightsSeparable7 -& -weights -ThreadPool -* -pool -ImageF -* -out -) -; } # endif diff --git a/third_party/jpeg-xl/lib/jxl/convolve_separable7.cc b/third_party/jpeg-xl/lib/jxl/convolve_separable7.cc deleted file mode 100644 index 10bb451a15e5..000000000000 --- a/third_party/jpeg-xl/lib/jxl/convolve_separable7.cc +++ /dev/null @@ -1,2149 +0,0 @@ -# -include -" -lib -/ -jxl -/ -convolve -. -h -" -# -undef -HWY_TARGET_INCLUDE -# -define -HWY_TARGET_INCLUDE -" -lib -/ -jxl -/ -convolve_separable7 -. -cc -" -# -include -< -hwy -/ -foreach_target -. -h -> -# -include -< -hwy -/ -highway -. -h -> -# -include -" -lib -/ -jxl -/ -convolve -- -inl -. -h -" -HWY_BEFORE_NAMESPACE -( -) -; -namespace -jxl -{ -namespace -HWY_NAMESPACE -{ -using -hwy -: -: -HWY_NAMESPACE -: -: -Add -; -using -hwy -: -: -HWY_NAMESPACE -: -: -Mul -; -using -hwy -: -: -HWY_NAMESPACE -: -: -MulAdd -; -using -hwy -: -: -HWY_NAMESPACE -: -: -Vec -; -class -Separable7Strategy -{ -using -D -= -HWY_CAPPED -( -float -16 -) -; -using -V -= -Vec -< -D -> -; -public -: -static -constexpr -int64_t -kRadius -= -3 -; -template -< -size_t -kSizeModN -class -WrapRow -> -static -JXL_MAYBE_INLINE -void -ConvolveRow -( -const -float -* -const -JXL_RESTRICT -row_m -const -size_t -xsize -const -int64_t -stride -const -WrapRow -& -wrap_row -const -WeightsSeparable7 -& -weights -float -* -const -JXL_RESTRICT -row_out -) -{ -const -D -d -; -const -int64_t -neg_stride -= -- -stride -; -const -float -* -const -JXL_RESTRICT -row_t3 -= -wrap_row -( -row_m -+ -3 -* -neg_stride -stride -) -; -const -float -* -const -JXL_RESTRICT -row_t2 -= -wrap_row -( -row_m -+ -2 -* -neg_stride -stride -) -; -const -float -* -const -JXL_RESTRICT -row_t1 -= -wrap_row -( -row_m -+ -1 -* -neg_stride -stride -) -; -const -float -* -const -JXL_RESTRICT -row_b1 -= -wrap_row -( -row_m -+ -1 -* -stride -stride -) -; -const -float -* -const -JXL_RESTRICT -row_b2 -= -wrap_row -( -row_m -+ -2 -* -stride -stride -) -; -const -float -* -const -JXL_RESTRICT -row_b3 -= -wrap_row -( -row_m -+ -3 -* -stride -stride -) -; -const -V -wh0 -= -LoadDup128 -( -d -weights -. -horz -+ -0 -* -4 -) -; -const -V -wh1 -= -LoadDup128 -( -d -weights -. -horz -+ -1 -* -4 -) -; -const -V -wh2 -= -LoadDup128 -( -d -weights -. -horz -+ -2 -* -4 -) -; -const -V -wh3 -= -LoadDup128 -( -d -weights -. -horz -+ -3 -* -4 -) -; -const -V -wv0 -= -LoadDup128 -( -d -weights -. -vert -+ -0 -* -4 -) -; -const -V -wv1 -= -LoadDup128 -( -d -weights -. -vert -+ -1 -* -4 -) -; -const -V -wv2 -= -LoadDup128 -( -d -weights -. -vert -+ -2 -* -4 -) -; -const -V -wv3 -= -LoadDup128 -( -d -weights -. -vert -+ -3 -* -4 -) -; -size_t -x -= -0 -; -for -( -; -x -< -kRadius -; -x -+ -= -Lanes -( -d -) -) -{ -const -V -conv0 -= -Mul -( -HorzConvolveFirst -( -row_m -x -xsize -wh0 -wh1 -wh2 -wh3 -) -wv0 -) -; -const -V -conv1t -= -HorzConvolveFirst -( -row_t1 -x -xsize -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv1b -= -HorzConvolveFirst -( -row_b1 -x -xsize -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv1 -= -MulAdd -( -Add -( -conv1t -conv1b -) -wv1 -conv0 -) -; -const -V -conv2t -= -HorzConvolveFirst -( -row_t2 -x -xsize -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv2b -= -HorzConvolveFirst -( -row_b2 -x -xsize -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv2 -= -MulAdd -( -Add -( -conv2t -conv2b -) -wv2 -conv1 -) -; -const -V -conv3t -= -HorzConvolveFirst -( -row_t3 -x -xsize -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv3b -= -HorzConvolveFirst -( -row_b3 -x -xsize -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv3 -= -MulAdd -( -Add -( -conv3t -conv3b -) -wv3 -conv2 -) -; -Store -( -conv3 -d -row_out -+ -x -) -; -} -for -( -; -x -+ -Lanes -( -d -) -+ -kRadius -< -= -xsize -; -x -+ -= -Lanes -( -d -) -) -{ -const -V -conv0 -= -Mul -( -HorzConvolve -( -row_m -+ -x -wh0 -wh1 -wh2 -wh3 -) -wv0 -) -; -const -V -conv1t -= -HorzConvolve -( -row_t1 -+ -x -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv1b -= -HorzConvolve -( -row_b1 -+ -x -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv1 -= -MulAdd -( -Add -( -conv1t -conv1b -) -wv1 -conv0 -) -; -const -V -conv2t -= -HorzConvolve -( -row_t2 -+ -x -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv2b -= -HorzConvolve -( -row_b2 -+ -x -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv2 -= -MulAdd -( -Add -( -conv2t -conv2b -) -wv2 -conv1 -) -; -const -V -conv3t -= -HorzConvolve -( -row_t3 -+ -x -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv3b -= -HorzConvolve -( -row_b3 -+ -x -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv3 -= -MulAdd -( -Add -( -conv3t -conv3b -) -wv3 -conv2 -) -; -Store -( -conv3 -d -row_out -+ -x -) -; -} -# -if -HWY_TARGET -= -= -HWY_SCALAR -while -( -x -< -xsize -) -{ -# -else -if -( -kSizeModN -< -kRadius -) -{ -# -endif -const -V -conv0 -= -Mul -( -HorzConvolveLast -< -kSizeModN -> -( -row_m -x -xsize -wh0 -wh1 -wh2 -wh3 -) -wv0 -) -; -const -V -conv1t -= -HorzConvolveLast -< -kSizeModN -> -( -row_t1 -x -xsize -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv1b -= -HorzConvolveLast -< -kSizeModN -> -( -row_b1 -x -xsize -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv1 -= -MulAdd -( -Add -( -conv1t -conv1b -) -wv1 -conv0 -) -; -const -V -conv2t -= -HorzConvolveLast -< -kSizeModN -> -( -row_t2 -x -xsize -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv2b -= -HorzConvolveLast -< -kSizeModN -> -( -row_b2 -x -xsize -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv2 -= -MulAdd -( -Add -( -conv2t -conv2b -) -wv2 -conv1 -) -; -const -V -conv3t -= -HorzConvolveLast -< -kSizeModN -> -( -row_t3 -x -xsize -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv3b -= -HorzConvolveLast -< -kSizeModN -> -( -row_b3 -x -xsize -wh0 -wh1 -wh2 -wh3 -) -; -const -V -conv3 -= -MulAdd -( -Add -( -conv3t -conv3b -) -wv3 -conv2 -) -; -Store -( -conv3 -d -row_out -+ -x -) -; -x -+ -= -Lanes -( -d -) -; -} -if -( -kSizeModN -! -= -0 -) -{ -for -( -; -x -< -xsize -; -+ -+ -x -) -{ -float -mul -= -0 -. -0f -; -for -( -int64_t -dy -= -- -kRadius -; -dy -< -= -kRadius -; -+ -+ -dy -) -{ -const -float -wy -= -weights -. -vert -[ -std -: -: -abs -( -dy -) -* -4 -] -; -const -float -* -clamped_row -= -wrap_row -( -row_m -+ -dy -* -stride -stride -) -; -for -( -int64_t -dx -= -- -kRadius -; -dx -< -= -kRadius -; -+ -+ -dx -) -{ -const -float -wx -= -weights -. -horz -[ -std -: -: -abs -( -dx -) -* -4 -] -; -const -int64_t -clamped_x -= -Mirror -( -x -+ -dx -xsize -) -; -mul -+ -= -clamped_row -[ -clamped_x -] -* -wx -* -wy -; -} -} -row_out -[ -x -] -= -mul -; -} -} -} -private -: -static -JXL_MAYBE_INLINE -V -HorzConvolveFirst -( -const -float -* -const -JXL_RESTRICT -row -const -int64_t -x -const -int64_t -xsize -const -V -wh0 -const -V -wh1 -const -V -wh2 -const -V -wh3 -) -{ -const -D -d -; -const -V -c -= -LoadU -( -d -row -+ -x -) -; -const -V -mul0 -= -Mul -( -c -wh0 -) -; -# -if -HWY_TARGET -= -= -HWY_SCALAR -const -V -l1 -= -LoadU -( -d -row -+ -Mirror -( -x -- -1 -xsize -) -) -; -const -V -l2 -= -LoadU -( -d -row -+ -Mirror -( -x -- -2 -xsize -) -) -; -const -V -l3 -= -LoadU -( -d -row -+ -Mirror -( -x -- -3 -xsize -) -) -; -# -else -( -void -) -xsize -; -const -V -l1 -= -Neighbors -: -: -FirstL1 -( -c -) -; -const -V -l2 -= -Neighbors -: -: -FirstL2 -( -c -) -; -const -V -l3 -= -Neighbors -: -: -FirstL3 -( -c -) -; -# -endif -const -V -r1 -= -LoadU -( -d -row -+ -x -+ -1 -) -; -const -V -r2 -= -LoadU -( -d -row -+ -x -+ -2 -) -; -const -V -r3 -= -LoadU -( -d -row -+ -x -+ -3 -) -; -const -V -mul1 -= -MulAdd -( -Add -( -l1 -r1 -) -wh1 -mul0 -) -; -const -V -mul2 -= -MulAdd -( -Add -( -l2 -r2 -) -wh2 -mul1 -) -; -const -V -mul3 -= -MulAdd -( -Add -( -l3 -r3 -) -wh3 -mul2 -) -; -return -mul3 -; -} -template -< -size_t -kSizeModN -> -static -JXL_MAYBE_INLINE -V -HorzConvolveLast -( -const -float -* -const -JXL_RESTRICT -row -const -int64_t -x -const -int64_t -xsize -const -V -wh0 -const -V -wh1 -const -V -wh2 -const -V -wh3 -) -{ -const -D -d -; -const -V -c -= -LoadU -( -d -row -+ -x -) -; -const -V -mul0 -= -Mul -( -c -wh0 -) -; -const -V -l1 -= -LoadU -( -d -row -+ -x -- -1 -) -; -const -V -l2 -= -LoadU -( -d -row -+ -x -- -2 -) -; -const -V -l3 -= -LoadU -( -d -row -+ -x -- -3 -) -; -V -r1 -r2 -r3 -; -# -if -HWY_TARGET -= -= -HWY_SCALAR -r1 -= -LoadU -( -d -row -+ -Mirror -( -x -+ -1 -xsize -) -) -; -r2 -= -LoadU -( -d -row -+ -Mirror -( -x -+ -2 -xsize -) -) -; -r3 -= -LoadU -( -d -row -+ -Mirror -( -x -+ -3 -xsize -) -) -; -# -else -const -size_t -N -= -Lanes -( -d -) -; -if -( -kSizeModN -= -= -0 -) -{ -r3 -= -TableLookupLanes -( -c -SetTableIndices -( -d -MirrorLanes -( -N -- -3 -) -) -) -; -r2 -= -TableLookupLanes -( -c -SetTableIndices -( -d -MirrorLanes -( -N -- -2 -) -) -) -; -r1 -= -TableLookupLanes -( -c -SetTableIndices -( -d -MirrorLanes -( -N -- -1 -) -) -) -; -} -else -if -( -kSizeModN -= -= -1 -) -{ -const -auto -last -= -LoadU -( -d -row -+ -xsize -- -N -) -; -r3 -= -TableLookupLanes -( -last -SetTableIndices -( -d -MirrorLanes -( -N -- -2 -) -) -) -; -r2 -= -TableLookupLanes -( -last -SetTableIndices -( -d -MirrorLanes -( -N -- -1 -) -) -) -; -r1 -= -last -; -} -else -{ -const -auto -last -= -LoadU -( -d -row -+ -xsize -- -N -) -; -r3 -= -TableLookupLanes -( -last -SetTableIndices -( -d -MirrorLanes -( -N -- -1 -) -) -) -; -r2 -= -last -; -r1 -= -LoadU -( -d -row -+ -x -+ -1 -) -; -} -# -endif -const -V -sum1 -= -Add -( -l1 -r1 -) -; -const -V -mul1 -= -MulAdd -( -sum1 -wh1 -mul0 -) -; -const -V -sum2 -= -Add -( -l2 -r2 -) -; -const -V -mul2 -= -MulAdd -( -sum2 -wh2 -mul1 -) -; -const -V -sum3 -= -Add -( -l3 -r3 -) -; -const -V -mul3 -= -MulAdd -( -sum3 -wh3 -mul2 -) -; -return -mul3 -; -} -static -JXL_MAYBE_INLINE -V -HorzConvolve -( -const -float -* -const -JXL_RESTRICT -pos -const -V -wh0 -const -V -wh1 -const -V -wh2 -const -V -wh3 -) -{ -const -D -d -; -const -V -c -= -LoadU -( -d -pos -) -; -const -V -mul0 -= -Mul -( -c -wh0 -) -; -const -V -l1 -= -LoadU -( -d -pos -- -1 -) -; -const -V -r1 -= -LoadU -( -d -pos -+ -1 -) -; -const -V -l2 -= -LoadU -( -d -pos -- -2 -) -; -const -V -r2 -= -LoadU -( -d -pos -+ -2 -) -; -const -V -l3 -= -LoadU -( -d -pos -- -3 -) -; -const -V -r3 -= -LoadU -( -d -pos -+ -3 -) -; -const -V -sum1 -= -Add -( -l1 -r1 -) -; -const -V -mul1 -= -MulAdd -( -sum1 -wh1 -mul0 -) -; -const -V -sum2 -= -Add -( -l2 -r2 -) -; -const -V -mul2 -= -MulAdd -( -sum2 -wh2 -mul1 -) -; -const -V -sum3 -= -Add -( -l3 -r3 -) -; -const -V -mul3 -= -MulAdd -( -sum3 -wh3 -mul2 -) -; -return -mul3 -; -} -} -; -void -Separable7 -( -const -ImageF -& -in -const -Rect -& -rect -const -WeightsSeparable7 -& -weights -ThreadPool -* -pool -ImageF -* -out -) -{ -using -Conv -= -ConvolveT -< -Separable7Strategy -> -; -if -( -rect -. -xsize -( -) -> -= -Conv -: -: -MinWidth -( -) -) -{ -return -Conv -: -: -Run -( -in -rect -weights -pool -out -) -; -} -return -SlowSeparable7 -( -in -rect -weights -pool -out -Rect -( -* -out -) -) -; -} -} -} -HWY_AFTER_NAMESPACE -( -) -; -# -if -HWY_ONCE -namespace -jxl -{ -HWY_EXPORT -( -Separable7 -) -; -void -Separable7 -( -const -ImageF -& -in -const -Rect -& -rect -const -WeightsSeparable7 -& -weights -ThreadPool -* -pool -ImageF -* -out -) -{ -return -HWY_DYNAMIC_DISPATCH -( -Separable7 -) -( -in -rect -weights -pool -out -) -; -} -} -# -endif diff --git a/third_party/jpeg-xl/lib/jxl/convolve_slow.cc b/third_party/jpeg-xl/lib/jxl/convolve_slow.cc index 60e9868f462f..51fc2fe52b8b 100644 --- a/third_party/jpeg-xl/lib/jxl/convolve_slow.cc +++ b/third_party/jpeg-xl/lib/jxl/convolve_slow.cc @@ -1340,45 +1340,4 @@ out_rect ) ; } -void -SlowSeparable7 -( -const -ImageF -& -in -const -Rect -& -in_rect -const -WeightsSeparable7 -& -weights -ThreadPool -* -pool -ImageF -* -out -const -Rect -& -out_rect -) -{ -SlowSeparable -< -3 -> -( -in -in_rect -weights -pool -out -out_rect -) -; -} } diff --git a/third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc b/third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc index ff7ace87876c..38327675c3ea 100644 --- a/third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc +++ b/third_party/jpeg-xl/lib/jxl/convolve_symmetric5.cc @@ -269,9 +269,11 @@ in_00 return sum_2 + +( sum_1 + sum_0 +) ; } template diff --git a/third_party/jpeg-xl/lib/jxl/convolve_test.cc b/third_party/jpeg-xl/lib/jxl/convolve_test.cc index 0818c34142e3..e0c3bc669523 100644 --- a/third_party/jpeg-xl/lib/jxl/convolve_test.cc +++ b/third_party/jpeg-xl/lib/jxl/convolve_test.cc @@ -1070,165 +1070,6 @@ _ ; } void -VerifySeparable7 -( -const -size_t -xsize -const -size_t -ysize -ThreadPool -* -pool -Rng -* -rng -) -{ -const -Rect -rect -( -0 -0 -xsize -ysize -) -; -ImageF -in -( -xsize -ysize -) -; -GenerateImage -( -* -rng -& -in -0 -. -0f -1 -. -0f -) -; -ImageF -out_expected -( -xsize -ysize -) -; -ImageF -out_actual -( -xsize -ysize -) -; -const -WeightsSeparable7 -weights -= -{ -{ -HWY_REP4 -( -0 -. -383103f -) -HWY_REP4 -( -0 -. -241843f -) -HWY_REP4 -( -0 -. -060626f -) -HWY_REP4 -( -0 -. -00598f -) -} -{ -HWY_REP4 -( -0 -. -383103f -) -HWY_REP4 -( -0 -. -241843f -) -HWY_REP4 -( -0 -. -060626f -) -HWY_REP4 -( -0 -. -00598f -) -} -} -; -SlowSeparable7 -( -in -rect -weights -pool -& -out_expected -rect -) -; -Separable7 -( -in -rect -weights -pool -& -out_actual -) -; -JXL_ASSERT_OK -( -VerifyRelativeError -( -out_expected -out_actual -1E -- -5f -1E -- -5f -_ -) -) -; -} -void TestConvolve ( ) @@ -1513,51 +1354,6 @@ pool3 rng ) ; -JXL_DEBUG -( -JXL_DEBUG_CONVOLVE -" -Sep7 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -" -) -; -VerifySeparable7 -( -xsize -ysize -null_pool -& -rng -) -; -VerifySeparable7 -( -xsize -ysize -& -pool3 -& -rng -) -; } } " diff --git a/third_party/jpeg-xl/lib/jxl/dec_cache.h b/third_party/jpeg-xl/lib/jxl/dec_cache.h index 7de31d57b288..0668cff77907 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_cache.h +++ b/third_party/jpeg-xl/lib/jxl/dec_cache.h @@ -16,6 +16,15 @@ h # include < +jxl +/ +types +. +h +> +# +include +< stdint . h @@ -23,6 +32,11 @@ h # include < +algorithm +> +# +include +< atomic > # @@ -41,6 +55,25 @@ h > # include +< +memory +> +# +include +< +vector +> +# +include +" +hwy +/ +aligned_allocator +. +h +" +# +include " lib / @@ -72,6 +105,19 @@ jxl / base / +compiler_specific +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ data_parallel . h @@ -107,7 +153,18 @@ lib / jxl / -convolve +common +. +h +" +# +include +" +lib +/ +jxl +/ +dct_util . h " @@ -129,7 +186,7 @@ lib / jxl / -dec_group_border +dec_xyb . h " @@ -140,7 +197,7 @@ lib / jxl / -dec_noise +frame_dimensions . h " @@ -173,7 +230,7 @@ lib / jxl / -passes_state +image_bundle . h " @@ -184,7 +241,18 @@ lib / jxl / -quant_weights +image_metadata +. +h +" +# +include +" +lib +/ +jxl +/ +passes_state . h " @@ -210,7 +278,7 @@ jxl / render_pipeline / -stage_upsampling +render_pipeline_stage . h " @@ -221,7 +289,9 @@ lib / jxl / -sanitizers +render_pipeline +/ +stage_upsampling . h " diff --git a/third_party/jpeg-xl/lib/jxl/dec_external_image.h b/third_party/jpeg-xl/lib/jxl/dec_external_image.h index 0f0f12c1db84..796d782859a6 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_external_image.h +++ b/third_party/jpeg-xl/lib/jxl/dec_external_image.h @@ -9,15 +9,6 @@ include < jxl / -decode -. -h -> -# -include -< -jxl -/ types . h @@ -31,13 +22,6 @@ h > # include -< -stdint -. -h -> -# -include " lib / @@ -69,7 +53,7 @@ lib / jxl / -color_encoding_internal +dec_cache . h " @@ -80,7 +64,7 @@ lib / jxl / -dec_cache +image . h " @@ -91,7 +75,7 @@ lib / jxl / -image +image_bundle . h " @@ -102,7 +86,7 @@ lib / jxl / -image_bundle +image_metadata . h " diff --git a/third_party/jpeg-xl/lib/jxl/dec_frame.cc b/third_party/jpeg-xl/lib/jxl/dec_frame.cc index fdd2c4f53359..caa4ddaaca12 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_frame.cc +++ b/third_party/jpeg-xl/lib/jxl/dec_frame.cc @@ -14,7 +14,7 @@ include < jxl / -types +decode . h > @@ -45,16 +45,12 @@ atomic # include < -hwy -/ -aligned_allocator -. -h +cstdlib > # include < -numeric +memory > # include @@ -95,17 +91,6 @@ lib / jxl / -ans_params -. -h -" -# -include -" -lib -/ -jxl -/ base / bits @@ -239,6 +224,17 @@ lib / jxl / +dct_util +. +h +" +# +include +" +lib +/ +jxl +/ dec_ans . h @@ -294,6 +290,17 @@ lib / jxl / +dec_noise +. +h +" +# +include +" +lib +/ +jxl +/ dec_patch_dictionary . h @@ -305,7 +312,7 @@ lib / jxl / -dec_xyb +entropy_coder . h " @@ -382,6 +389,17 @@ lib / jxl / +image_metadata +. +h +" +# +include +" +lib +/ +jxl +/ image_ops . h @@ -450,7 +468,9 @@ lib / jxl / -sanitizers +render_pipeline +/ +render_pipeline . h " diff --git a/third_party/jpeg-xl/lib/jxl/dec_frame.h b/third_party/jpeg-xl/lib/jxl/dec_frame.h index 59eb21a5f60e..6043c03c5ecb 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_frame.h +++ b/third_party/jpeg-xl/lib/jxl/dec_frame.h @@ -31,6 +31,31 @@ h > # include +< +algorithm +> +# +include +< +cstddef +> +# +include +< +limits +> +# +include +< +utility +> +# +include +< +vector +> +# +include " lib / @@ -38,7 +63,7 @@ jxl / base / -compiler_specific +common . h " @@ -51,7 +76,7 @@ jxl / base / -data_parallel +compiler_specific . h " @@ -64,7 +89,7 @@ jxl / base / -span +data_parallel . h " @@ -88,17 +113,6 @@ lib / jxl / -blending -. -h -" -# -include -" -lib -/ -jxl -/ common . h @@ -154,17 +168,6 @@ lib / jxl / -headers -. -h -" -# -include -" -lib -/ -jxl -/ image_bundle . h diff --git a/third_party/jpeg-xl/lib/jxl/dec_xyb.h b/third_party/jpeg-xl/lib/jxl/dec_xyb.h index 63127c0eccb1..25d9deb18391 100644 --- a/third_party/jpeg-xl/lib/jxl/dec_xyb.h +++ b/third_party/jpeg-xl/lib/jxl/dec_xyb.h @@ -15,6 +15,16 @@ h > # include +< +cstddef +> +# +include +< +cstdint +> +# +include " lib / @@ -70,17 +80,6 @@ lib / jxl / -dec_bit_reader -. -h -" -# -include -" -lib -/ -jxl -/ image . h diff --git a/third_party/jpeg-xl/lib/jxl/decode.cc b/third_party/jpeg-xl/lib/jxl/decode.cc index f9560195355a..76006cd86a9a 100644 --- a/third_party/jpeg-xl/lib/jxl/decode.cc +++ b/third_party/jpeg-xl/lib/jxl/decode.cc @@ -19,6 +19,15 @@ h # include < +jxl +/ +version +. +h +> +# +include +< algorithm > # diff --git a/third_party/jpeg-xl/lib/jxl/decode_test.cc b/third_party/jpeg-xl/lib/jxl/decode_test.cc index f63135bb25f4..e0413b0849a8 100644 --- a/third_party/jpeg-xl/lib/jxl/decode_test.cc +++ b/third_party/jpeg-xl/lib/jxl/decode_test.cc @@ -1,5 +1,18 @@ # include +" +lib +/ +extras +/ +dec +/ +decode +. +h +" +# +include < jxl / @@ -12,6 +25,15 @@ include < jxl / +codestream_header +. +h +> +# +include +< +jxl +/ color_encoding . h @@ -39,6 +61,33 @@ include < jxl / +memory_manager +. +h +> +# +include +< +jxl +/ +parallel_runner +. +h +> +# +include +< +jxl +/ +resizable_parallel_runner +. +h +> +# +include +< +jxl +/ resizable_parallel_runner_cxx . h @@ -48,6 +97,15 @@ include < jxl / +thread_parallel_runner +. +h +> +# +include +< +jxl +/ thread_parallel_runner_cxx . h @@ -64,6 +122,11 @@ h # include < +algorithm +> +# +include +< cstdint > # @@ -79,6 +142,21 @@ cstdlib # include < +cstring +> +# +include +< +ostream +> +# +include +< +set +> +# +include +< sstream > # @@ -108,7 +186,9 @@ lib / extras / -codec +dec +/ +color_description . h " @@ -119,9 +199,33 @@ lib / extras / -dec +enc / -color_description +encode +. +h +" +# +include +" +lib +/ +extras +/ +enc +/ +jpg +. +h +" +# +include +" +lib +/ +extras +/ +packed_image . h " @@ -147,6 +251,45 @@ jxl / base / +common +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +compiler_specific +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +override +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ span . h @@ -171,6 +314,19 @@ lib / jxl / +butteraugli +/ +butteraugli +. +h +" +# +include +" +lib +/ +jxl +/ cms / color_encoding_cms @@ -283,6 +439,17 @@ lib / jxl / +enc_params +. +h +" +# +include +" +lib +/ +jxl +/ enc_progressive_split . h @@ -349,7 +516,18 @@ lib / jxl / -icc_codec +image +. +h +" +# +include +" +lib +/ +jxl +/ +image_bundle . h " @@ -371,6 +549,17 @@ lib / jxl / +image_ops +. +h +" +# +include +" +lib +/ +jxl +/ jpeg / enc_jpeg_data @@ -3057,37 +3246,165 @@ uint8_t > jpeg_bytes ; -io +extras +: +: +PackedPixelFile +ppf +; +extras +: +: +PackedFrame +frame +( +xsize +ysize +format +) +; +JXL_ASSERT +( +frame +. +color . -jpeg_quality +pixels_size = -70 += +pixels +. +size +( +) +) ; -EXPECT_TRUE +memcpy ( -Encode +frame +. +color +. +pixels ( -io -extras -: -: -Codec +0 +0 +0 +) +pixels +. +data +( +) +pixels +. +size +( +) +) +; +ppf +. +frames +. +emplace_back +( +std : : -kJPG -io +move +( +frame +) +) +; +ppf . -metadata +info . -m +xsize += +xsize +; +ppf . -color_encoding -8 +info +. +ysize += +ysize +; +ppf +. +info +. +num_color_channels += +grayscale +? +1 +: +3 +; +ppf +. +info +. +bits_per_sample += +16 +; +auto +encoder += +extras +: +: +GetJPEGEncoder +( +) +; +encoder +- +> +SetOption +( +" +quality +" +" +70 +" +) +; +extras +: +: +EncodedImage +encoded +; +EXPECT_TRUE +( +encoder +- +> +Encode +( +ppf & -jpeg_bytes +encoded ) ) ; +jpeg_bytes += +encoded +. +bitstreams +[ +0 +] +; Bytes ( jpeg_bytes @@ -11153,7 +11470,7 @@ IsSlightlyBelow ( 0 . -55f +56f ) ) ; @@ -14599,7 +14916,7 @@ IsSlightlyBelow ( 1 . -2222f +3f ) ) ; diff --git a/third_party/jpeg-xl/lib/jxl/decode_to_jpeg.cc b/third_party/jpeg-xl/lib/jxl/decode_to_jpeg.cc index ff37a174e68b..e00e528f85ac 100644 --- a/third_party/jpeg-xl/lib/jxl/decode_to_jpeg.cc +++ b/third_party/jpeg-xl/lib/jxl/decode_to_jpeg.cc @@ -11,6 +11,61 @@ h " # include +< +jxl +/ +decode +. +h +> +# +include +< +algorithm +> +# +include +< +cstddef +> +# +include +< +cstdint +> +# +include +< +cstring +> +# +include +" +lib +/ +jxl +/ +base +/ +span +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +status +. +h +" +# +include " lib / @@ -20,6 +75,32 @@ common . h " +# +include +" +lib +/ +jxl +/ +jpeg +/ +dec_jpeg_data +. +h +" +# +include +" +lib +/ +jxl +/ +jpeg +/ +jpeg_data +. +h +" namespace jxl { diff --git a/third_party/jpeg-xl/lib/jxl/decode_to_jpeg.h b/third_party/jpeg-xl/lib/jxl/decode_to_jpeg.h index 38ad1c5b8be4..6f9d1564a873 100644 --- a/third_party/jpeg-xl/lib/jxl/decode_to_jpeg.h +++ b/third_party/jpeg-xl/lib/jxl/decode_to_jpeg.h @@ -30,11 +30,26 @@ h # include < +algorithm +> +# +include +< +cstring +> +# +include +< memory > # include < +utility +> +# +include +< vector > # @@ -81,7 +96,7 @@ jxl / jpeg / -dec_jpeg_data +jpeg_data . h " @@ -407,14 +422,13 @@ ib - > jpeg_data -. -reset += +std +: +: +move ( jpeg_data_ -. -release -( -) ) ; } diff --git a/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h b/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h index a0c7d5e9e8a3..914a2ef19d85 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h +++ b/third_party/jpeg-xl/lib/jxl/enc_ac_strategy.h @@ -16,6 +16,17 @@ lib / jxl / +ac_strategy +. +h +" +# +include +" +lib +/ +jxl +/ base / compiler_specific @@ -42,6 +53,17 @@ lib / jxl / +chroma_from_luma +. +h +" +# +include +" +lib +/ +jxl +/ enc_cache . h @@ -53,6 +75,28 @@ lib / jxl / +enc_params +. +h +" +# +include +" +lib +/ +jxl +/ +frame_dimensions +. +h +" +# +include +" +lib +/ +jxl +/ image . h diff --git a/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc b/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc index d586e6b94e1a..a05bb28d5998 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.cc @@ -354,17 +354,6 @@ lib / jxl / -gauss_blur -. -h -" -# -include -" -lib -/ -jxl -/ image . h @@ -3017,11 +3006,39 @@ ImageF mask1x1 ) { +JXL_ASSERT +( +rect_in +. +x0 +( +) +% +8 += += +0 +) +; +JXL_ASSERT +( +rect_in +. +y0 +( +) +% +8 += += +0 +) +; const size_t xsize = -rect_in +xyb . xsize ( @@ -3031,7 +3048,7 @@ const size_t ysize = -rect_in +xyb . ysize ( @@ -3053,8 +3070,14 @@ float df ; size_t -y_start +y_start_1x1 = +rect_in +. +y0 +( +) ++ rect_out . y0 @@ -3064,9 +3087,9 @@ y0 8 ; size_t -y_end +y_end_1x1 = -y_start +y_start_1x1 + rect_out . @@ -3077,8 +3100,14 @@ ysize 8 ; size_t -x_start +x_start_1x1 = +rect_in +. +x0 +( +) ++ rect_out . x0 @@ -3088,9 +3117,9 @@ x0 8 ; size_t -x_end +x_end_1x1 = -x_start +x_start_1x1 + rect_out . @@ -3100,16 +3129,134 @@ xsize * 8 ; +if +( +rect_in +. +x0 +( +) +! += +0 +& +& +rect_out +. +x0 +( +) += += +0 +) +x_start_1x1 +- += +2 +; +if +( +rect_in +. +x1 +( +) +< +xsize +& +& +rect_out +. +x1 +( +) +* +8 += += +rect_in +. +xsize +( +) +) +{ +x_end_1x1 ++ += +2 +; +} +if +( +rect_in +. +y0 +( +) +! += +0 +& +& +rect_out +. +y0 +( +) += += +0 +) +y_start_1x1 +- += +2 +; +if +( +rect_in +. +y1 +( +) +< +ysize +& +& +rect_out +. +y1 +( +) +* +8 += += +rect_in +. +ysize +( +) +) +{ +y_end_1x1 ++ += +2 +; +} for ( size_t y = -y_start +y_start_1x1 ; y < -y_end +y_end_1x1 ; + + @@ -3151,11 +3298,10 @@ float * row_in = -rect_in +xyb . ConstPlaneRow ( -xyb 1 y ) @@ -3165,11 +3311,10 @@ float * row_in1 = -rect_in +xyb . ConstPlaneRow ( -xyb 1 y1 ) @@ -3179,11 +3324,10 @@ float * row_in2 = -rect_in +xyb . ConstPlaneRow ( -xyb 1 y2 ) @@ -3361,11 +3505,11 @@ for size_t x = -x_start +x_start_1x1 ; x < -x_end +x_end_1x1 ; + + @@ -3379,6 +3523,66 @@ x ; } } +size_t +y_start += +rect_in +. +y0 +( +) ++ +rect_out +. +y0 +( +) +* +8 +; +size_t +y_end += +y_start ++ +rect_out +. +ysize +( +) +* +8 +; +size_t +x_start += +rect_in +. +x0 +( +) ++ +rect_out +. +x0 +( +) +* +8 +; +size_t +x_end += +x_start ++ +rect_out +. +xsize +( +) +* +8 +; if ( x_start @@ -3396,11 +3600,7 @@ if x_end ! = -rect_in -. xsize -( -) ) x_end + @@ -3424,11 +3624,7 @@ if y_end ! = -rect_in -. ysize -( -) ) y_end + @@ -3516,11 +3712,10 @@ float * row_in = -rect_in +xyb . ConstPlaneRow ( -xyb 1 y ) @@ -3530,11 +3725,10 @@ float * row_in1 = -rect_in +xyb . ConstPlaneRow ( -xyb 1 y1 ) @@ -3544,11 +3738,10 @@ float * row_in2 = -rect_in +xyb . ConstPlaneRow ( -xyb 1 y2 ) @@ -4283,6 +4476,10 @@ pool ImageF * mask1x1 +const +Rect +& +rect ) { static @@ -4485,37 +4682,16 @@ kFilterMask1x1 } } ; -Rect -from_rect -( -0 -0 -mask1x1 -- -> -xsize -( -) -mask1x1 -- -> -ysize -( -) -) -; ImageF temp ( -mask1x1 -- -> +rect +. xsize ( ) -mask1x1 -- -> +rect +. ysize ( ) @@ -4525,17 +4701,22 @@ Symmetric5 ( * mask1x1 -from_rect +rect weights pool & temp ) ; -CopyImageTo +* +mask1x1 += +std +: +: +move ( temp -mask1x1 ) ; } @@ -4645,12 +4826,12 @@ mask1x1 = ImageF ( -rect +xyb . xsize ( ) -rect +xyb . ysize ( @@ -4818,6 +4999,7 @@ Blur1x1Masking ( pool mask1x1 +rect ) ; return diff --git a/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h b/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h index 37b7182e8815..514a488373f9 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h +++ b/third_party/jpeg-xl/lib/jxl/enc_adaptive_quantization.h @@ -7,6 +7,15 @@ LIB_JXL_ENC_ADAPTIVE_QUANTIZATION_H_ # include < +jxl +/ +cms_interface +. +h +> +# +include +< stddef . h @@ -53,17 +62,6 @@ lib / jxl / -enc_params -. -h -" -# -include -" -lib -/ -jxl -/ frame_header . h @@ -79,61 +77,6 @@ image . h " -# -include -" -lib -/ -jxl -/ -image_bundle -. -h -" -# -include -" -lib -/ -jxl -/ -loop_filter -. -h -" -# -include -" -lib -/ -jxl -/ -quant_weights -. -h -" -# -include -" -lib -/ -jxl -/ -quantizer -. -h -" -# -include -" -lib -/ -jxl -/ -splines -. -h -" namespace jxl { diff --git a/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc b/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc index 18d64408a5a8..218d48b525c3 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.cc @@ -298,6 +298,62 @@ TempImages temp_image ) { +JXL_ASSERT +( +opsin_rect +. +x0 +( +) +% +8 += += +0 +) +; +JXL_ASSERT +( +opsin_rect +. +y0 +( +) +% +8 += += +0 +) +; +JXL_ASSERT +( +opsin_rect +. +xsize +( +) +% +8 += += +0 +) +; +JXL_ASSERT +( +opsin_rect +. +ysize +( +) +% +8 += += +0 +) +; constexpr size_t N @@ -425,20 +481,24 @@ PixelsPerRow size_t by0 = -rect +opsin_rect . y0 ( ) -; -size_t -by1 -= +/ +8 ++ rect . y0 ( ) +; +size_t +by1 += +by0 + rect . @@ -449,20 +509,24 @@ ysize size_t bx0 = -rect +opsin_rect . x0 ( ) -; -size_t -bx1 -= +/ +8 ++ rect . x0 ( ) +; +size_t +bx1 += +bx0 + rect . @@ -494,9 +558,13 @@ by0 = 0 ? -2 -: 0 +: +by0 +* +N +- +2 ; size_t y1 @@ -504,39 +572,23 @@ y1 by1 * N -+ -4 -< = -opsin_rect += +opsin . ysize ( ) -+ -2 ? -( by1 -- -by0 -) * N -+ -4 : -opsin_rect -. -ysize -( -) -+ -2 -- -by0 +by1 * N ++ +2 ; size_t x0 @@ -546,9 +598,13 @@ bx0 = 0 ? -2 -: 0 +: +bx0 +* +N +- +2 ; size_t x1 @@ -556,39 +612,23 @@ x1 bx1 * N -+ -4 -< = -opsin_rect += +opsin . xsize ( ) -+ -2 ? -( bx1 -- -bx0 -) * N -+ -4 : -opsin_rect -. -xsize -( -) -+ -2 -- -bx0 +bx1 * N ++ +2 ; HWY_FULL ( @@ -622,18 +662,13 @@ laplacian_sqrsum Row ( y -) -; -size_t -cy -= -y + +2 +- by0 * N -- -2 +) ; const float @@ -683,21 +718,20 @@ in_row_t c ] = -opsin_rect +opsin . ConstPlaneRow ( -opsin c -cy +y > 0 ? -cy +y - 1 : -cy +y ) ; in_row @@ -705,13 +739,12 @@ in_row c ] = -opsin_rect +opsin . ConstPlaneRow ( -opsin c -cy +y ) ; in_row_b @@ -719,27 +752,26 @@ in_row_b c ] = -opsin_rect +opsin . ConstPlaneRow ( -opsin c -cy +y + 1 < -opsin_rect +opsin . ysize ( ) ? -cy +y + 1 : -cy +y ) ; } @@ -754,51 +786,40 @@ size_t x ) { -size_t -cx -= -x -+ -bx0 -* -N -- -2 -; const size_t prevX = -cx +x > = 1 ? -cx +x - 1 : -cx +x ; const size_t nextX = -cx +x + 1 < -opsin_rect +opsin . xsize ( ) ? -cx +x + 1 : -cx +x ; float sumsqr @@ -834,7 +855,7 @@ in_row c ] [ -cx +x ] + kChannelWeightsLapNeg @@ -872,7 +893,7 @@ in_row_b c ] [ -cx +x ] + in_row_b @@ -896,7 +917,7 @@ in_row_t c ] [ -cx +x ] + in_row_t @@ -919,6 +940,12 @@ laplacian laplacian_sqrsum_row [ x ++ +2 +- +bx0 +* +N ] = sumsqr @@ -934,12 +961,8 @@ for ( ; x -+ -bx0 -* -N < -3 +1 ; x + @@ -973,14 +996,10 @@ Lanes df ) + -bx0 -* -N -- 1 < = -opsin_rect +opsin . xsize ( @@ -995,17 +1014,6 @@ df ) ) { -size_t -cx -= -x -+ -bx0 -* -N -- -2 -; auto sumsqr = @@ -1043,7 +1051,7 @@ in_row c ] + -cx +x ) Set ( @@ -1066,7 +1074,7 @@ in_row c ] + -cx +x - 1 ) @@ -1082,7 +1090,7 @@ in_row c ] + -cx +x + 1 ) @@ -1098,7 +1106,7 @@ in_row_t c ] + -cx +x - 1 ) @@ -1114,7 +1122,7 @@ in_row_t c ] + -cx +x ) ; sum_oth0 @@ -1130,7 +1138,7 @@ in_row_t c ] + -cx +x + 1 ) @@ -1149,7 +1157,7 @@ in_row_b c ] + -cx +x - 1 ) @@ -1168,7 +1176,7 @@ in_row_b c ] + -cx +x ) ) ; @@ -1185,7 +1193,7 @@ in_row_b c ] + -cx +x + 1 ) @@ -1248,6 +1256,12 @@ df laplacian_sqrsum_row + x ++ +2 +- +bx0 +* +N ) ; } @@ -1316,10 +1330,10 @@ y ; y < +rect +. +ysize ( -by1 -- -by0 ) * 2 @@ -1393,10 +1407,10 @@ x ; x < +rect +. +xsize ( -bx1 -- -bx0 ) * 2 @@ -1543,10 +1557,10 @@ y ; y < +rect +. +ysize ( -by1 -- -by0 ) * 2 @@ -1639,20 +1653,18 @@ by0 * 8 + -4 +2 < = -opsin_rect +opsin . ysize ( ) -+ -2 ? 4 : -opsin_rect +opsin . ysize ( @@ -1677,10 +1689,10 @@ x ; x < +rect +. +xsize ( -bx1 -- -bx0 ) * 2 @@ -1726,16 +1738,14 @@ bx0 * 8 + -4 +2 < = -opsin_rect +opsin . xsize ( ) -+ -2 ? x * @@ -1743,7 +1753,7 @@ x + 4 : -opsin_rect +opsin . xsize ( @@ -1786,11 +1796,11 @@ for size_t iy = -0 +sy ; iy < -4 +ey ; iy + @@ -1802,11 +1812,11 @@ for size_t ix = -0 +sx ; ix < -4 +ex ; ix + @@ -1830,8 +1840,6 @@ rows_in iy ] + -sx -+ ix ) ) @@ -1953,11 +1961,19 @@ for size_t by = -by0 +rect +. +y0 +( +) ; by < -by1 +rect +. +y1 +( +) ; by + @@ -2005,11 +2021,19 @@ for size_t bx = -bx0 +rect +. +x0 +( +) ; bx < -bx1 +rect +. +x1 +( +) ; bx + @@ -2068,7 +2092,11 @@ sqrsum_00_row ( by - -by0 +rect +. +y0 +( +) ) * 2 @@ -2081,7 +2109,11 @@ sqrsum_00_stride ( bx - -bx0 +rect +. +x0 +( +) ) * 2 @@ -2112,7 +2144,11 @@ sqrsum_22_row ( by - -by0 +rect +. +y0 +( +) ) * 2 @@ -2125,7 +2161,11 @@ sqrsum_22_stride ( bx - -bx0 +rect +. +x0 +( +) ) * 2 diff --git a/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h b/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h index e5efef4becee..e9ff39eb2389 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h +++ b/third_party/jpeg-xl/lib/jxl/enc_ar_control_field.h @@ -23,6 +23,17 @@ lib / jxl / +ac_strategy +. +h +" +# +include +" +lib +/ +jxl +/ enc_params . h diff --git a/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.h b/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.h index b8c451c82218..3aa32924a3a9 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.h +++ b/third_party/jpeg-xl/lib/jxl/enc_butteraugli_comparator.h @@ -27,6 +27,11 @@ memory > # include +< +vector +> +# +include " lib / diff --git a/third_party/jpeg-xl/lib/jxl/enc_cache.h b/third_party/jpeg-xl/lib/jxl/enc_cache.h index 6249d6f1808a..637df6e54db6 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_cache.h +++ b/third_party/jpeg-xl/lib/jxl/enc_cache.h @@ -30,19 +30,13 @@ h # include < -vector +memory > # include -" -lib -/ -jxl -/ -ac_strategy -. -h -" +< +vector +> # include " @@ -76,18 +70,7 @@ lib / jxl / -coeff_order -. -h -" -# -include -" -lib -/ -jxl -/ -coeff_order_fwd +dct_util . h " @@ -98,7 +81,7 @@ lib / jxl / -dct_util +enc_ans . h " @@ -109,7 +92,7 @@ lib / jxl / -enc_ans +enc_bit_writer . h " @@ -164,17 +147,6 @@ lib / jxl / -image_bundle -. -h -" -# -include -" -lib -/ -jxl -/ passes_state . h @@ -190,17 +162,6 @@ quant_weights . h " -# -include -" -lib -/ -jxl -/ -quantizer -. -h -" namespace jxl { diff --git a/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc b/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc index 3d3f34ce3815..453b6c62c15c 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.cc @@ -1430,126 +1430,6 @@ x } } void -ComputeDC -( -const -ImageF -& -dc_values -bool -fast -int32_t -* -dc_x -int32_t -* -dc_b -) -{ -constexpr -float -kDistanceMultiplierDC -= -1e -- -5f -; -const -float -* -JXL_RESTRICT -dc_values_yx -= -dc_values -. -Row -( -0 -) -; -const -float -* -JXL_RESTRICT -dc_values_x -= -dc_values -. -Row -( -1 -) -; -const -float -* -JXL_RESTRICT -dc_values_yb -= -dc_values -. -Row -( -2 -) -; -const -float -* -JXL_RESTRICT -dc_values_b -= -dc_values -. -Row -( -3 -) -; -* -dc_x -= -FindBestMultiplier -( -dc_values_yx -dc_values_x -dc_values -. -xsize -( -) -0 -. -0f -kDistanceMultiplierDC -fast -) -; -* -dc_b -= -FindBestMultiplier -( -dc_values_yb -dc_values_b -dc_values -. -xsize -( -) -jxl -: -: -cms -: -: -kYToBRatio -kDistanceMultiplierDC -fast -) -; -} -void ComputeTile ( const @@ -2837,11 +2717,6 @@ InitDCStorage ; HWY_EXPORT ( -ComputeDC -) -; -HWY_EXPORT -( ComputeTile ) ; @@ -2984,59 +2859,6 @@ ItemsPerThread ; } void -CfLHeuristics -: -: -ComputeDC -( -bool -fast -ColorCorrelationMap -* -cmap -) -{ -int32_t -ytob_dc -= -0 -; -int32_t -ytox_dc -= -0 -; -HWY_DYNAMIC_DISPATCH -( -ComputeDC -) -( -dc_values -fast -& -ytox_dc -& -ytob_dc -) -; -cmap -- -> -SetYToBDC -( -ytob_dc -) -; -cmap -- -> -SetYToXDC -( -ytox_dc -) -; -} -void ColorCorrelationMapEncodeDC ( const diff --git a/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h b/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h index c1b2cce13c27..89f69f90b3dc 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h +++ b/third_party/jpeg-xl/lib/jxl/enc_chroma_from_luma.h @@ -187,16 +187,6 @@ ColorCorrelationMap cmap ) ; -void -ComputeDC -( -bool -fast -ColorCorrelationMap -* -cmap -) -; ImageF dc_values ; diff --git a/third_party/jpeg-xl/lib/jxl/enc_external_image.cc b/third_party/jpeg-xl/lib/jxl/enc_external_image.cc index ef2d3462d071..b2268234c6d2 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_external_image.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_external_image.cc @@ -336,8 +336,28 @@ scale = 1 . +0f +; +if +( +format +. +data_type += += +JXL_TYPE_UINT8 +) +{ +scale += +1 +. +0f / ( +257 +* +( ( 1ull < @@ -347,7 +367,29 @@ bits_per_sample - 1 ) +) ; +} +else +{ +scale += +1 +. +0f +/ +( +( +1ull +< +< +bits_per_sample +) +- +1 +) +; +} const bool little_endian diff --git a/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc b/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc index 2b722f86677e..f855f1692af4 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.cc @@ -28228,15 +28228,15 @@ kMaxLocalGroups : total_groups ; +# +if +! +FJXL_STANDALONE size_t start_pos = 0 ; -# -if -! -FJXL_STANDALONE if ( streaming diff --git a/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.h b/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.h index a96baa353de4..aa248faa6477 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.h +++ b/third_party/jpeg-xl/lib/jxl/enc_fast_lossless.h @@ -15,21 +15,10 @@ h ifndef FJXL_STANDALONE # -ifdef -JPEGXL_MAJOR_VERSION -# define FJXL_STANDALONE 0 # -else -# -define -FJXL_STANDALONE -1 -# -endif -# endif # if diff --git a/third_party/jpeg-xl/lib/jxl/enc_frame.cc b/third_party/jpeg-xl/lib/jxl/enc_frame.cc index fbea050048fa..57db1a094f6a 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_frame.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_frame.cc @@ -1197,23 +1197,6 @@ num_channels ) ; } -* -color -= -Image3F -( -rect -. -xsize -( -) -rect -. -ysize -( -) -) -; const uint8_t * @@ -1679,6 +1662,28 @@ progressive_passes_dc_quant_ac_full_ac } } ; +bool +progressive_mode += +ApplyOverride +( +cparams +. +progressive_mode +false +) +; +bool +qprogressive_mode += +ApplyOverride +( +cparams +. +qprogressive_mode +false +) +; if ( cparams @@ -1701,8 +1706,6 @@ custom_progressive_mode else if ( -cparams -. qprogressive_mode ) { @@ -1721,8 +1724,6 @@ progressive_passes_dc_quant_ac_full_ac else if ( -cparams -. progressive_mode ) { @@ -4570,7 +4571,7 @@ speed_tier SpeedTier : : -kWombat +kSquirrel ) { pixel_stats @@ -4631,6 +4632,8 @@ CompressParams & cparams bool +streaming_mode +bool color_is_jpeg const Image3F @@ -4756,6 +4759,10 @@ kNoise & ! color_is_jpeg +& +& +! +streaming_mode ) { static @@ -10174,6 +10181,40 @@ frame_rect ; Image3F color +( +RoundUpToBlockDim +( +patch_rect +. +xsize +( +) +) +RoundUpToBlockDim +( +patch_rect +. +ysize +( +) +) +) +; +color +. +ShrinkTo +( +patch_rect +. +xsize +( +) +patch_rect +. +ysize +( +) +) ; std : @@ -10203,8 +10244,16 @@ jxl : ImageF ( +patch_rect +. xsize +( +) +patch_rect +. ysize +( +) ) ; } @@ -10326,53 +10375,12 @@ linear = nullptr ; -Image3F -opsin -; if ( ! jpeg_data ) { -opsin -= -Image3F -( -RoundUpToBlockDim -( -color -. -xsize -( -) -) -RoundUpToBlockDim -( -color -. -ysize -( -) -) -) -; -opsin -. -ShrinkTo -( -color -. -xsize -( -) -color -. -ysize -( -) -) -; if ( frame_header @@ -10419,12 +10427,12 @@ linear_storage = Image3F ( -color +patch_rect . xsize ( ) -color +patch_rect . ysize ( @@ -10439,7 +10447,6 @@ linear_storage } ToXYB ( -color c_enc metadata - @@ -10452,7 +10459,7 @@ IntensityTarget black pool & -opsin +color cms linear ) @@ -10460,13 +10467,6 @@ linear } else { -CopyImageTo -( -color -& -opsin -) -; } bool lossless @@ -10523,7 +10523,7 @@ resampling SimplifyInvisible ( & -opsin +color * alpha lossless @@ -10547,18 +10547,12 @@ lossless PadImageToBlockMultipleInPlace ( & -opsin -) -; -} color -= -Image3F -( ) ; +} Rect -opsin_rect +group_rect ( x0 - @@ -10598,28 +10592,23 @@ jpeg_data ComputeChromacityAdjustments ( cparams -opsin -opsin_rect +color +group_rect & mutable_frame_header ) ; } -if +ComputeNoiseParams ( -! +cparams enc_state . streaming_mode -) -{ -ComputeNoiseParams -( -cparams ! ! jpeg_data -opsin +color frame_dim & mutable_frame_header @@ -10631,7 +10620,6 @@ image_features noise_params ) ; -} DownsampleColorChannels ( cparams @@ -10640,7 +10628,7 @@ frame_header ! jpeg_data & -opsin +color ) ; if @@ -10687,11 +10675,11 @@ enc_state streaming_mode ) { -opsin_rect +group_rect = Rect ( -opsin +color ) ; } @@ -10781,8 +10769,8 @@ ComputeVarDCTEncodingData frame_header linear & -opsin -opsin_rect +color +group_rect cms pool & @@ -10838,6 +10826,29 @@ enc_state ) ; } +if +( +! +enc_state +. +streaming_mode +) +{ +if +( +cparams +. +modular_mode +| +| +! +extra_channels +. +empty +( +) +) +{ JXL_RETURN_IF_ERROR ( enc_modular @@ -10850,32 +10861,20 @@ metadata > m & -opsin +color extra_channels & enc_state cms pool aux_out -frame_header +cparams . -encoding -= -= -FrameEncoding -: -: -kModular +modular_mode ) ) ; -if -( -enc_state -. -initialize_global_state -) -{ +} JXL_RETURN_IF_ERROR ( enc_modular @@ -10886,7 +10885,6 @@ pool ) ) ; -} JXL_RETURN_IF_ERROR ( enc_modular @@ -10897,14 +10895,6 @@ pool ) ) ; -if -( -! -enc_state -. -streaming_mode -) -{ mutable_frame_header . UpdateFlag @@ -12121,6 +12111,22 @@ kBlockDim for ( size_t +pass += +0 +; +pass +< +num_passes +; ++ ++ +pass +) +{ +for +( +size_t ac_y = ac_y0 @@ -12159,22 +12165,6 @@ group_xsize + ac_x ; -for -( -size_t -pass -= -0 -; -pass -< -num_passes -; -+ -+ -pass -) -{ size_t old_ix = diff --git a/third_party/jpeg-xl/lib/jxl/enc_frame.h b/third_party/jpeg-xl/lib/jxl/enc_frame.h index ab5238b3bb73..4f4c39f79c77 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_frame.h +++ b/third_party/jpeg-xl/lib/jxl/enc_frame.h @@ -9,6 +9,15 @@ include < jxl / +cms_interface +. +h +> +# +include +< +jxl +/ types . h @@ -16,10 +25,25 @@ h # include < +cstddef +> +# +include +< +cstdint +> +# +include +< string > # include +< +vector +> +# +include " lib / @@ -110,6 +134,17 @@ image_bundle . h " +# +include +" +lib +/ +jxl +/ +image_metadata +. +h +" namespace jxl { diff --git a/third_party/jpeg-xl/lib/jxl/enc_gaborish.cc b/third_party/jpeg-xl/lib/jxl/enc_gaborish.cc index bfb4b2103863..fa32c66ce7b8 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_gaborish.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_gaborish.cc @@ -330,6 +330,21 @@ Plane temp ) ; +Rect +xrect += +rect +. +Extend +( +3 +Rect +( +* +in_out +) +) +; Symmetric5 ( in_out @@ -339,7 +354,7 @@ Plane ( 0 ) -rect +xrect weights [ 0 @@ -353,7 +368,7 @@ Plane ( 2 ) -rect +xrect ) ; Symmetric5 @@ -365,7 +380,7 @@ Plane ( 1 ) -rect +xrect weights [ 1 @@ -379,13 +394,13 @@ Plane ( 0 ) -rect +xrect ) ; Symmetric5 ( temp -rect +xrect weights [ 2 @@ -399,7 +414,7 @@ Plane ( 1 ) -rect +xrect ) ; in_out diff --git a/third_party/jpeg-xl/lib/jxl/enc_gaborish.h b/third_party/jpeg-xl/lib/jxl/enc_gaborish.h index f166c857dda4..1563ca1ac4d7 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_gaborish.h +++ b/third_party/jpeg-xl/lib/jxl/enc_gaborish.h @@ -6,26 +6,6 @@ define LIB_JXL_GABORISH_H_ # include -< -stdint -. -h -> -# -include -" -lib -/ -jxl -/ -base -/ -compiler_specific -. -h -" -# -include " lib / diff --git a/third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc b/third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc index cd6c4f270698..28860c4e67ef 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_gaborish_test.cc @@ -25,6 +25,45 @@ lib / jxl / +base +/ +compiler_specific +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +data_parallel +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +status +. +h +" +# +include +" +lib +/ +jxl +/ convolve . h @@ -36,6 +75,17 @@ lib / jxl / +image +. +h +" +# +include +" +lib +/ +jxl +/ image_ops . h diff --git a/third_party/jpeg-xl/lib/jxl/enc_group.h b/third_party/jpeg-xl/lib/jxl/enc_group.h index 7115afa09bea..9fadf8c6bb54 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_group.h +++ b/third_party/jpeg-xl/lib/jxl/enc_group.h @@ -13,13 +13,6 @@ h > # include -< -stdint -. -h -> -# -include " lib / diff --git a/third_party/jpeg-xl/lib/jxl/enc_heuristics.cc b/third_party/jpeg-xl/lib/jxl/enc_heuristics.cc index 5a3f81532a0f..8179d802bd69 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_heuristics.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_heuristics.cc @@ -12,6 +12,15 @@ h # include < +jxl +/ +cms_interface +. +h +> +# +include +< stddef . h @@ -31,6 +40,21 @@ algorithm # include < +cstdlib +> +# +include +< +limits +> +# +include +< +memory +> +# +include +< numeric > # @@ -40,6 +64,160 @@ string > # include +< +utility +> +# +include +< +vector +> +# +include +" +lib +/ +jxl +/ +ac_context +. +h +" +# +include +" +lib +/ +jxl +/ +ac_strategy +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +common +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +compiler_specific +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +data_parallel +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +override +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +status +. +h +" +# +include +" +lib +/ +jxl +/ +butteraugli +/ +butteraugli +. +h +" +# +include +" +lib +/ +jxl +/ +chroma_from_luma +. +h +" +# +include +" +lib +/ +jxl +/ +coeff_order +. +h +" +# +include +" +lib +/ +jxl +/ +coeff_order_fwd +. +h +" +# +include +" +lib +/ +jxl +/ +dec_xyb +. +h +" +# +include " lib / @@ -133,7 +311,7 @@ lib / jxl / -enc_patch_dictionary +enc_params . h " @@ -144,7 +322,7 @@ lib / jxl / -enc_photon_noise +enc_patch_dictionary . h " @@ -177,7 +355,62 @@ lib / jxl / -enc_xyb +frame_dimensions +. +h +" +# +include +" +lib +/ +jxl +/ +frame_header +. +h +" +# +include +" +lib +/ +jxl +/ +image +. +h +" +# +include +" +lib +/ +jxl +/ +image_ops +. +h +" +# +include +" +lib +/ +jxl +/ +passes_state +. +h +" +# +include +" +lib +/ +jxl +/ +quant_weights . h " @@ -6038,15 +6271,6 @@ opsin ) ; } -static -const -float -kAcQuant -= -0 -. -79f -; const float quant_dc @@ -6058,25 +6282,6 @@ cparams butteraugli_distance ) ; -if -( -initialize_global_state -) -{ -quantizer -. -ComputeGlobalScaleAndQuant -( -quant_dc -kAcQuant -/ -cparams -. -butteraugli_distance -0 -) -; -} ArControlFieldHeuristics ar_heuristics ; @@ -6137,7 +6342,9 @@ ysize_blocks float q = -kAcQuant +0 +. +79 / cparams . @@ -6167,6 +6374,15 @@ q initial_quant_masking ) ; +quantizer +. +ComputeGlobalScaleAndQuant +( +quant_dc +q +0 +) +; } else { @@ -6213,22 +6429,27 @@ initial_quant_masking initial_quant_masking1x1 ) ; -if -( -initialize_global_state -) -{ +float +q += +0 +. +39 +/ +cparams +. +butteraugli_distance +; quantizer . -SetQuantField +ComputeGlobalScaleAndQuant ( quant_dc -initial_quant_field -nullptr +q +0 ) ; } -} if ( frame_header @@ -6599,40 +6820,6 @@ aux_out ; if ( -cparams -. -speed_tier -< -= -SpeedTier -: -: -kHare -& -& -initialize_global_state -) -{ -cfl_heuristics -. -ComputeDC -( -cparams -. -speed_tier -> -= -SpeedTier -: -: -kWombat -& -cmap -) -; -} -if -( ! streaming_mode ) diff --git a/third_party/jpeg-xl/lib/jxl/enc_heuristics.h b/third_party/jpeg-xl/lib/jxl/enc_heuristics.h index cb2bfcbb347a..a698eb0b5808 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_heuristics.h +++ b/third_party/jpeg-xl/lib/jxl/enc_heuristics.h @@ -22,18 +22,6 @@ h > # include -< -stdint -. -h -> -# -include -< -string -> -# -include " lib / @@ -80,21 +68,6 @@ image . h " -# -include -" -lib -/ -jxl -/ -modular -/ -encoding -/ -enc_ma -. -h -" namespace jxl { diff --git a/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc b/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc index 7ef654f8afdc..7bf488bfe4d0 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_icc_codec.cc @@ -19,6 +19,11 @@ h # include < +limits +> +# +include +< map > # @@ -523,6 +528,26 @@ pos ) ; } +constexpr +size_t +kSizeLimit += +std +: +: +numeric_limits +< +uint32_t +> +: +: +max +( +) +> +> +2 +; } Status PredictICC @@ -544,6 +569,43 @@ commands PaddedBytes data ; +static_assert +( +sizeof +( +size_t +) +> += +4 +" +size_t +is +too +short +" +) +; +if +( +size +> +kSizeLimit +) +{ +return +JXL_FAILURE +( +" +ICC +profile +is +too +large +" +) +; +} EncodeVarInt ( size @@ -1394,6 +1456,33 @@ clutstart = 0 ; +const +auto +tag_sane += +[ +& +tagsize +] +( +) +{ +return +( +tagsize +> +8 +) +& +& +( +tagsize +< +kSizeLimit +) +; +} +; size_t last0 = @@ -1420,12 +1509,21 @@ data_add ; if ( +( pos > tagstart + tagsize ) +& +& +( +tagsize +< +kSizeLimit +) +) { tag = @@ -1510,6 +1608,11 @@ tag kMlucTag & & +tag_sane +( +) +& +& pos + tagsize @@ -1518,11 +1621,6 @@ tagsize size & & -tagsize -> -8 -& -& icc [ pos @@ -1664,6 +1762,11 @@ tag kCurvTag & & +tag_sane +( +) +& +& pos + tagsize @@ -1672,11 +1775,6 @@ tagsize size & & -tagsize -> -8 -& -& icc [ pos @@ -2283,6 +2381,11 @@ tag kGbd_Tag & & +tag_sane +( +) +& +& pos = = @@ -2304,11 +2407,6 @@ size pos > 16 -& -& -tagsize -> -8 ) { size_t diff --git a/third_party/jpeg-xl/lib/jxl/enc_modular.cc b/third_party/jpeg-xl/lib/jxl/enc_modular.cc index 8d91485e1314..4532daf433c3 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_modular.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_modular.cc @@ -597,989 +597,6 @@ squeeze_chroma_qtable 5 } ; -Tree -MakeFixedTree -( -int -property -const -std -: -: -vector -< -int32_t -> -& -cutoffs -Predictor -pred -size_t -num_pixels -) -{ -size_t -log_px -= -CeilLog2Nonzero -( -num_pixels -) -; -size_t -min_gap -= -0 -; -if -( -log_px -< -14 -) -{ -min_gap -= -8 -* -( -14 -- -log_px -) -; -} -Tree -tree -; -struct -NodeInfo -{ -size_t -begin -end -pos -; -} -; -std -: -: -queue -< -NodeInfo -> -q -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -pred -) -) -; -q -. -push -( -NodeInfo -{ -0 -cutoffs -. -size -( -) -0 -} -) -; -while -( -! -q -. -empty -( -) -) -{ -NodeInfo -info -= -q -. -front -( -) -; -q -. -pop -( -) -; -if -( -info -. -begin -+ -min_gap -> -= -info -. -end -) -continue -; -uint32_t -split -= -( -info -. -begin -+ -info -. -end -) -/ -2 -; -tree -[ -info -. -pos -] -= -PropertyDecisionNode -: -: -Split -( -property -cutoffs -[ -split -] -tree -. -size -( -) -) -; -q -. -push -( -NodeInfo -{ -split -+ -1 -info -. -end -tree -. -size -( -) -} -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -pred -) -) -; -q -. -push -( -NodeInfo -{ -info -. -begin -split -tree -. -size -( -) -} -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -pred -) -) -; -} -return -tree -; -} -Tree -PredefinedTree -( -ModularOptions -: -: -TreeKind -tree_kind -size_t -total_pixels -) -{ -if -( -tree_kind -= -= -ModularOptions -: -: -TreeKind -: -: -kJpegTranscodeACMeta -| -| -tree_kind -= -= -ModularOptions -: -: -TreeKind -: -: -kTrivialTreeNoPredictor -) -{ -return -{ -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Zero -) -} -; -} -if -( -tree_kind -= -= -ModularOptions -: -: -TreeKind -: -: -kFalconACMeta -) -{ -return -{ -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Left -) -} -; -} -if -( -tree_kind -= -= -ModularOptions -: -: -TreeKind -: -: -kACMeta -) -{ -if -( -total_pixels -< -1024 -) -{ -return -{ -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Left -) -} -; -} -Tree -tree -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -0 -1 -1 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -0 -2 -3 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -0 -0 -5 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -6 -0 -21 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -2 -0 -7 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Gradient -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Gradient -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -7 -5 -9 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -7 -5 -15 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -7 -11 -11 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -7 -3 -13 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Left -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Left -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Left -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Left -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -7 -11 -17 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -7 -3 -19 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Zero -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Zero -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Zero -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Zero -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -7 -0 -23 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Split -( -7 -0 -25 -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Zero -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Zero -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Zero -) -) -; -tree -. -push_back -( -PropertyDecisionNode -: -: -Leaf -( -Predictor -: -: -Zero -) -) -; -return -tree -; -} -if -( -tree_kind -= -= -ModularOptions -: -: -TreeKind -: -: -kWPFixedDC -) -{ -std -: -: -vector -< -int32_t -> -cutoffs -= -{ -- -500 -- -392 -- -255 -- -191 -- -127 -- -95 -- -63 -- -47 -- -31 -- -23 -- -15 -- -11 -- -7 -- -4 -- -3 -- -1 -0 -1 -3 -5 -7 -11 -15 -23 -31 -47 -63 -95 -127 -191 -255 -392 -500 -} -; -return -MakeFixedTree -( -kWPProp -cutoffs -Predictor -: -: -Weighted -total_pixels -) -; -} -if -( -tree_kind -= -= -ModularOptions -: -: -TreeKind -: -: -kGradientFixedDC -) -{ -std -: -: -vector -< -int32_t -> -cutoffs -= -{ -- -500 -- -392 -- -255 -- -191 -- -127 -- -95 -- -63 -- -47 -- -31 -- -23 -- -15 -- -11 -- -7 -- -4 -- -3 -- -1 -0 -1 -3 -5 -7 -11 -15 -23 -31 -47 -63 -95 -127 -191 -255 -392 -500 -} -; -return -MakeFixedTree -( -kGradientProp -cutoffs -Predictor -: -: -Gradient -total_pixels -) -; -} -JXL_UNREACHABLE -( -" -Unreachable -" -) -; -return -{ -} -; -} void MergeTrees ( @@ -6132,14 +5149,6 @@ TransformId kSqueeze ) ; -t -. -squeezes -= -cparams_ -. -squeezes -; do_transform ( gi @@ -9265,6 +8274,37 @@ return true ; } +if +( +tokens_ +. +empty +( +) +) +{ +JXL_RETURN_IF_ERROR +( +ModularGenericCompress +( +stream_images_ +[ +stream_id +] +stream_options_ +[ +stream_id +] +writer +aux_out +layer +stream_id +) +) +; +} +else +{ JXL_RETURN_IF_ERROR ( Bundle @@ -9296,6 +8336,7 @@ layer aux_out ) ; +} return true ; @@ -9328,15 +8369,6 @@ empty_image std : : -vector -< -Token -> -empty_tokens -; -std -: -: swap ( stream_images_ @@ -9346,18 +8378,6 @@ stream_id empty_image ) ; -std -: -: -swap -( -tokens_ -[ -stream_id -] -empty_tokens -) -; } namespace { diff --git a/third_party/jpeg-xl/lib/jxl/enc_params.h b/third_party/jpeg-xl/lib/jxl/enc_params.h index c627761fa7c3..dec90700e2b9 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_params.h +++ b/third_party/jpeg-xl/lib/jxl/enc_params.h @@ -9,28 +9,30 @@ include < jxl / -encode +cms_interface . h > # include < -stddef +jxl +/ +encode . h > # include < -stdint +stddef . h > # include < -string +vector > # include @@ -52,9 +54,7 @@ lib / jxl / -butteraugli -/ -butteraugli +enc_progressive_split . h " @@ -65,7 +65,7 @@ lib / jxl / -enc_progressive_split +frame_dimensions . h " @@ -115,21 +115,6 @@ lib / jxl / -modular -/ -transform -/ -transform -. -h -" -# -include -" -lib -/ -jxl -/ splines . h @@ -299,15 +284,21 @@ epf - 1 ; -bool +Override progressive_mode = -false +Override +: +: +kDefault ; -bool +Override qprogressive_mode = -false +Override +: +: +kDefault ; bool centerfirst @@ -420,15 +411,6 @@ responsive - 1 ; -std -: -: -vector -< -SqueezeParams -> -squeezes -; int colorspace = @@ -646,6 +628,11 @@ buffering = 0 ; +bool +use_full_image_heuristics += +true +; std : : diff --git a/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc b/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc index 6fa12072cfac..4317794bfcc1 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_patch_dictionary.cc @@ -5739,13 +5739,19 @@ cparams . progressive_mode = -false +Override +: +: +kOff ; cparams . qprogressive_mode = -false +Override +: +: +kOff ; cparams . diff --git a/third_party/jpeg-xl/lib/jxl/enc_transforms-inl.h b/third_party/jpeg-xl/lib/jxl/enc_transforms-inl.h index 25a3572340cf..868202011305 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_transforms-inl.h +++ b/third_party/jpeg-xl/lib/jxl/enc_transforms-inl.h @@ -1757,6 +1757,9 @@ block * 8 ] += +{ +} ; for ( diff --git a/third_party/jpeg-xl/lib/jxl/enc_xyb.cc b/third_party/jpeg-xl/lib/jxl/enc_xyb.cc index e914da5e7e07..88919ad3163c 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_xyb.cc +++ b/third_party/jpeg-xl/lib/jxl/enc_xyb.cc @@ -909,10 +909,6 @@ Status LinearSRGBToXYB ( const -Image3F -& -linear -const float * JXL_RESTRICT @@ -923,15 +919,16 @@ pool Image3F * JXL_RESTRICT -xyb +image ) { const size_t xsize = -linear -. +image +- +> xsize ( ) @@ -953,8 +950,9 @@ static_cast uint32_t > ( -linear -. +image +- +> ysize ( ) @@ -985,54 +983,12 @@ size_t task ) ; -const -float -* -JXL_RESTRICT -row_in0 -= -linear -. -ConstPlaneRow -( -0 -y -) -; -const -float -* -JXL_RESTRICT -row_in1 -= -linear -. -ConstPlaneRow -( -1 -y -) -; -const -float -* -JXL_RESTRICT -row_in2 -= -linear -. -ConstPlaneRow -( -2 -y -) -; float * JXL_RESTRICT -row_xyb0 +row0 = -xyb +image - > PlaneRow @@ -1044,9 +1000,9 @@ y float * JXL_RESTRICT -row_xyb1 +row1 = -xyb +image - > PlaneRow @@ -1058,9 +1014,9 @@ y float * JXL_RESTRICT -row_xyb2 +row2 = -xyb +image - > PlaneRow @@ -1096,7 +1052,7 @@ in_r Load ( d -row_in0 +row0 + x ) @@ -1108,7 +1064,7 @@ in_g Load ( d -row_in1 +row1 + x ) @@ -1120,7 +1076,7 @@ in_b Load ( d -row_in2 +row2 + x ) @@ -1131,13 +1087,13 @@ in_r in_g in_b premul_absorb -row_xyb0 +row0 + x -row_xyb1 +row1 + x -row_xyb2 +row2 + x ) @@ -1154,10 +1110,6 @@ Status SRGBToXYB ( const -Image3F -& -srgb -const float * JXL_RESTRICT @@ -1168,15 +1120,16 @@ pool Image3F * JXL_RESTRICT -xyb +image ) { const size_t xsize = -srgb -. +image +- +> xsize ( ) @@ -1198,8 +1151,9 @@ static_cast uint32_t > ( -srgb -. +image +- +> ysize ( ) @@ -1230,54 +1184,12 @@ size_t task ) ; -const -float -* -JXL_RESTRICT -row_srgb0 -= -srgb -. -ConstPlaneRow -( -0 -y -) -; -const -float -* -JXL_RESTRICT -row_srgb1 -= -srgb -. -ConstPlaneRow -( -1 -y -) -; -const -float -* -JXL_RESTRICT -row_srgb2 -= -srgb -. -ConstPlaneRow -( -2 -y -) -; float * JXL_RESTRICT -row_xyb0 +row0 = -xyb +image - > PlaneRow @@ -1289,9 +1201,9 @@ y float * JXL_RESTRICT -row_xyb1 +row1 = -xyb +image - > PlaneRow @@ -1303,9 +1215,9 @@ y float * JXL_RESTRICT -row_xyb2 +row2 = -xyb +image - > PlaneRow @@ -1343,7 +1255,7 @@ LinearFromSRGB Load ( d -row_srgb0 +row0 + x ) @@ -1358,7 +1270,7 @@ LinearFromSRGB Load ( d -row_srgb1 +row1 + x ) @@ -1373,7 +1285,7 @@ LinearFromSRGB Load ( d -row_srgb2 +row2 + x ) @@ -1385,13 +1297,13 @@ in_r in_g in_b premul_absorb -row_xyb0 +row0 + x -row_xyb1 +row1 + x -row_xyb2 +row2 + x ) @@ -1408,10 +1320,6 @@ Status SRGBToXYBAndLinear ( const -Image3F -& -srgb -const float * JXL_RESTRICT @@ -1422,7 +1330,7 @@ pool Image3F * JXL_RESTRICT -xyb +image Image3F * JXL_RESTRICT @@ -1433,8 +1341,9 @@ const size_t xsize = -srgb -. +image +- +> xsize ( ) @@ -1456,8 +1365,9 @@ static_cast uint32_t > ( -srgb -. +image +- +> ysize ( ) @@ -1488,54 +1398,12 @@ size_t task ) ; -const -float -* -JXL_RESTRICT -row_srgb0 -= -srgb -. -ConstPlaneRow -( -0 -y -) -; -const -float -* -JXL_RESTRICT -row_srgb1 -= -srgb -. -ConstPlaneRow -( -1 -y -) -; -const -float -* -JXL_RESTRICT -row_srgb2 -= -srgb -. -ConstPlaneRow -( -2 -y -) -; float * JXL_RESTRICT -row_linear0 +row_image0 = -linear +image - > PlaneRow @@ -1547,9 +1415,9 @@ y float * JXL_RESTRICT -row_linear1 +row_image1 = -linear +image - > PlaneRow @@ -1561,9 +1429,9 @@ y float * JXL_RESTRICT -row_linear2 +row_image2 = -linear +image - > PlaneRow @@ -1575,9 +1443,9 @@ y float * JXL_RESTRICT -row_xyb0 +row_linear0 = -xyb +linear - > PlaneRow @@ -1589,9 +1457,9 @@ y float * JXL_RESTRICT -row_xyb1 +row_linear1 = -xyb +linear - > PlaneRow @@ -1603,9 +1471,9 @@ y float * JXL_RESTRICT -row_xyb2 +row_linear2 = -xyb +linear - > PlaneRow @@ -1643,7 +1511,7 @@ LinearFromSRGB Load ( d -row_srgb0 +row_image0 + x ) @@ -1658,7 +1526,7 @@ LinearFromSRGB Load ( d -row_srgb1 +row_image1 + x ) @@ -1673,7 +1541,7 @@ LinearFromSRGB Load ( d -row_srgb2 +row_image2 + x ) @@ -1712,13 +1580,13 @@ in_r in_g in_b premul_absorb -row_xyb0 +row_image0 + x -row_xyb1 +row_image1 + x -row_xyb2 +row_image2 + x ) @@ -2359,38 +2227,63 @@ out ; } void -Image3FToXYB +ToXYB ( const -Image3F -& -in -const ColorEncoding & -color_encoding +c_current float intensity_target +const +ImageF +* +black ThreadPool * pool Image3F * JXL_RESTRICT -xyb +image const JxlCmsInterface & cms +Image3F +* +const +JXL_RESTRICT +linear ) { +if +( +black +) JXL_ASSERT ( SameSize ( -in * -xyb +image +* +black +) +) +; +if +( +linear +) +JXL_ASSERT +( +SameSize +( +* +image +* +linear ) ) ; @@ -2419,14 +2312,14 @@ intensity_target premul_absorb ) ; +const bool -is_gray +want_linear = -color_encoding -. -IsGray -( -) +linear +! += +nullptr ; const ColorEncoding @@ -2438,7 +2331,11 @@ ColorEncoding : LinearSRGB ( -is_gray +c_current +. +IsGray +( +) ) ; if @@ -2447,228 +2344,33 @@ c_linear_srgb . SameColorEncoding ( -color_encoding +c_current ) ) { -JXL_CHECK +if ( -LinearSRGBToXYB +want_linear +) +{ +CopyImageTo ( -in -premul_absorb -pool -xyb -) -) -; -} -else -if -( -color_encoding -. -IsSRGB -( -) -) -{ -JXL_CHECK -( -SRGBToXYB -( -in -premul_absorb -pool -xyb -) -) -; -} -else -{ -Image3F -linear -= -TransformToLinearRGB -( -in -color_encoding -intensity_target -cms -pool -) -; -JXL_CHECK -( -LinearSRGBToXYB -( -linear -premul_absorb -pool -xyb -) -) -; -} -} -void -ToXYB -( -const -Image3F -& -color -const -ColorEncoding -& -c_current -float -intensity_target -const -ImageF -* -black -ThreadPool -* -pool -Image3F -* -JXL_RESTRICT -xyb -const -JxlCmsInterface -& -cms -Image3F -* -const -JXL_RESTRICT -linear -) -{ -JXL_ASSERT -( -SameSize -( -color -* -xyb -) -) -; -if -( -black -) -JXL_ASSERT -( -SameSize -( -color -* -black -) -) -; -if -( -linear -) -JXL_ASSERT -( -SameSize -( -color -* -linear -) -) -; -const -HWY_FULL -( -float -) -d -; -HWY_ALIGN -float -premul_absorb -[ -MaxLanes -( -d -) * -12 -] -; -ComputePremulAbsorb -( -intensity_target -premul_absorb -) -; -const -bool -want_linear -= +image linear -! -= -nullptr -; -const -ColorEncoding -& -c_linear_srgb -= -ColorEncoding -: -: -LinearSRGB -( -c_current -. -IsGray -( -) ) ; -if -( -c_linear_srgb -. -SameColorEncoding -( -c_current -) -) -{ +} JXL_CHECK ( LinearSRGBToXYB ( -color premul_absorb pool -xyb +image ) ) ; -if -( -want_linear -) -{ -CopyImageTo -( -color -linear -) -; -} return ; } @@ -2690,10 +2392,9 @@ JXL_CHECK ( SRGBToXYBAndLinear ( -color premul_absorb pool -xyb +image linear ) ) @@ -2705,10 +2406,9 @@ JXL_CHECK ( SRGBToXYB ( -color premul_absorb pool -xyb +image ) ) ; @@ -2716,75 +2416,51 @@ xyb return ; } -Image3F -linear_storage -; -Image3F -* -linear_storage_ptr -; -if -( -want_linear -) -{ -linear_storage_ptr -= -linear -; -} -else -{ -linear_storage -= -Image3F -( -color -. -xsize -( -) -color -. -ysize -( -) -) -; -linear_storage_ptr -= -& -linear_storage -; -} JXL_CHECK ( ApplyColorTransform ( c_current intensity_target -color +* +image black Rect ( -color +* +image ) c_linear_srgb cms pool -linear_storage_ptr +want_linear +? +linear +: +image +) +) +; +if +( +want_linear ) +{ +CopyImageTo +( +* +linear +image ) ; +} JXL_CHECK ( LinearSRGBToXYB ( -* -linear_storage_ptr premul_absorb pool -xyb +image ) ) ; @@ -3405,10 +3081,6 @@ void ToXYB ( const -Image3F -& -color -const ColorEncoding & c_current @@ -3424,7 +3096,7 @@ pool Image3F * JXL_RESTRICT -xyb +image const JxlCmsInterface & @@ -3441,12 +3113,11 @@ HWY_DYNAMIC_DISPATCH ToXYB ) ( -color c_current intensity_target black pool -xyb +image cms linear ) @@ -3476,13 +3147,35 @@ JXL_RESTRICT linear ) { -ToXYB +* +xyb += +Image3F +( +in +. +xsize +( +) +in +. +ysize +( +) +) +; +CopyImageTo ( in . color ( ) +xyb +) +; +ToXYB +( in . c_current @@ -3815,52 +3508,6 @@ xsize } HWY_EXPORT ( -Image3FToXYB -) -; -void -Image3FToXYB -( -const -Image3F -& -in -const -ColorEncoding -& -color_encoding -float -intensity_target -ThreadPool -* -pool -Image3F -* -JXL_RESTRICT -xyb -const -JxlCmsInterface -& -cms -) -{ -return -HWY_DYNAMIC_DISPATCH -( -Image3FToXYB -) -( -in -color_encoding -intensity_target -pool -xyb -cms -) -; -} -HWY_EXPORT -( RgbToYcbcr ) ; diff --git a/third_party/jpeg-xl/lib/jxl/enc_xyb.h b/third_party/jpeg-xl/lib/jxl/enc_xyb.h index 3c440fb07477..10491e57edf3 100644 --- a/third_party/jpeg-xl/lib/jxl/enc_xyb.h +++ b/third_party/jpeg-xl/lib/jxl/enc_xyb.h @@ -15,6 +15,11 @@ h > # include +< +cstddef +> +# +include " lib / @@ -59,7 +64,7 @@ lib / jxl / -enc_bit_writer +color_encoding_internal . h " @@ -92,10 +97,6 @@ void ToXYB ( const -Image3F -& -color -const ColorEncoding & c_current @@ -111,14 +112,13 @@ pool Image3F * JXL_RESTRICT -xyb +image const JxlCmsInterface & cms Image3F * -const JXL_RESTRICT linear ) @@ -150,32 +150,6 @@ nullptr ) ; void -Image3FToXYB -( -const -Image3F -& -in -const -ColorEncoding -& -color_encoding -float -intensity_target -ThreadPool -* -pool -Image3F -* -JXL_RESTRICT -xyb -const -JxlCmsInterface -& -cms -) -; -void LinearRGBRowToXYB ( float diff --git a/third_party/jpeg-xl/lib/jxl/encode.cc b/third_party/jpeg-xl/lib/jxl/encode.cc index 2ee4f0bf0c8a..897f6eda6dcf 100644 --- a/third_party/jpeg-xl/lib/jxl/encode.cc +++ b/third_party/jpeg-xl/lib/jxl/encode.cc @@ -46,6 +46,15 @@ h # include < +jxl +/ +version +. +h +> +# +include +< algorithm > # @@ -10639,7 +10648,16 @@ cparams . progressive_mode = +static_cast +< +jxl +: +: +Override +> +( value +) ; break ; @@ -10655,7 +10673,16 @@ cparams . qprogressive_mode = +static_cast +< +jxl +: +: +Override +> +( value +) ; break ; @@ -10817,9 +10844,6 @@ value ; break ; -return -JXL_ENC_SUCCESS -; case JXL_ENC_FRAME_SETTING_COLOR_TRANSFORM : @@ -11400,6 +11424,55 @@ value ; break ; +case +JXL_ENC_FRAME_SETTING_USE_FULL_IMAGE_HEURISTICS +: +if +( +value +< +0 +| +| +value +> +1 +) +{ +return +JXL_API_ERROR +( +frame_settings +- +> +enc +JXL_ENC_ERR_NOT_SUPPORTED +" +Option +value +has +to +be +0 +or +1 +" +) +; +} +frame_settings +- +> +values +. +cparams +. +use_full_image_heuristics += +value +; +break +; default : return @@ -11855,6 +11928,9 @@ JXL_ENC_FRAME_SETTING_JPEG_KEEP_XMP case JXL_ENC_FRAME_SETTING_JPEG_KEEP_JUMBF : +case +JXL_ENC_FRAME_SETTING_USE_FULL_IMAGE_HEURISTICS +: return JXL_API_ERROR ( diff --git a/third_party/jpeg-xl/lib/jxl/encode_internal.h b/third_party/jpeg-xl/lib/jxl/encode_internal.h index 61ef3f93aa43..85cc4c6c41ac 100644 --- a/third_party/jpeg-xl/lib/jxl/encode_internal.h +++ b/third_party/jpeg-xl/lib/jxl/encode_internal.h @@ -9,7 +9,7 @@ include < jxl / -encode +cms_interface . h > @@ -18,7 +18,7 @@ include < jxl / -memory_manager +codestream_header . h > @@ -27,7 +27,7 @@ include < jxl / -parallel_runner +encode . h > @@ -36,14 +36,14 @@ include < jxl / -types +memory_manager . h > # include < -sys +jxl / types . @@ -52,6 +52,16 @@ h # include < +algorithm +> +# +include +< +array +> +# +include +< cstddef > # @@ -62,6 +72,11 @@ cstdint # include < +cstring +> +# +include +< functional > # @@ -77,6 +92,11 @@ memory # include < +string +> +# +include +< utility > # @@ -189,6 +209,17 @@ lib / jxl / +image_metadata +. +h +" +# +include +" +lib +/ +jxl +/ jpeg / jpeg_data diff --git a/third_party/jpeg-xl/lib/jxl/encode_test.cc b/third_party/jpeg-xl/lib/jxl/encode_test.cc index 773f8ef0664e..dba571b0fd8c 100644 --- a/third_party/jpeg-xl/lib/jxl/encode_test.cc +++ b/third_party/jpeg-xl/lib/jxl/encode_test.cc @@ -30,6 +30,15 @@ include < jxl / +color_encoding +. +h +> +# +include +< +jxl +/ decode . h @@ -64,6 +73,24 @@ h # include < +jxl +/ +memory_manager +. +h +> +# +include +< +jxl +/ +types +. +h +> +# +include +< cstddef > # @@ -79,6 +106,11 @@ cstdio # include < +cstdlib +> +# +include +< cstring > # @@ -119,15 +151,6 @@ vector # include " -jxl -/ -types -. -h -" -# -include -" lib / extras @@ -180,6 +203,19 @@ jxl / base / +byte_order +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ c_callback_support . h @@ -191,7 +227,9 @@ lib / jxl / -common +base +/ +span . h " @@ -202,7 +240,9 @@ lib / jxl / -encode_internal +base +/ +status . h " @@ -213,9 +253,18 @@ lib / jxl / -jpeg +common +. +h +" +# +include +" +lib / -dec_jpeg_data +jxl +/ +enc_params . h " @@ -226,9 +275,20 @@ lib / jxl / -jpeg +encode_internal +. +h +" +# +include +" +lib / -dec_jpeg_data_writer +jxl +/ +modular +/ +options . h " @@ -2985,7 +3045,13 @@ responsive ; EXPECT_EQ ( -true +jxl +: +: +Override +: +: +kOn enc - > @@ -6101,7 +6167,13 @@ cparams . progressive_mode = -true +jxl +: +: +Override +: +: +kOn ; EXPECT_EQ ( @@ -11450,6 +11522,8 @@ JxlBasicInfo basic_info size_t number_extra_channels +bool +streaming ) { JxlEncoderStruct @@ -11531,7 +11605,22 @@ JxlEncoderFrameSettingsSetOption ( frame_settings JXL_ENC_FRAME_SETTING_BUFFERING +streaming +? 3 +: +0 +) +) +; +EXPECT_EQ +( +JXL_ENC_SUCCESS +JxlEncoderFrameSettingsSetOption +( +frame_settings +JXL_ENC_FRAME_SETTING_USE_FULL_IMAGE_HEURISTICS +0 ) ) ; @@ -12152,6 +12241,7 @@ frame_settings p basic_info number_extra_channels +false ) ; SetupInputNonStreaming @@ -12243,6 +12333,7 @@ frame_settings p basic_info number_extra_channels +true ) ; SetupInputNonStreaming @@ -12330,7 +12421,7 @@ size ( ) + -16 +1024 ) ; } @@ -12585,6 +12676,7 @@ frame_settings p basic_info number_extra_channels +false ) ; SetupInputNonStreaming @@ -12667,6 +12759,7 @@ frame_settings p basic_info number_extra_channels +true ) ; SetupInputStreaming @@ -12732,7 +12825,7 @@ size ( ) + -16 +1024 ) ; } @@ -12967,6 +13060,7 @@ frame_settings p basic_info number_extra_channels +false ) ; SetupInputNonStreaming @@ -13058,6 +13152,7 @@ frame_settings p basic_info number_extra_channels +true ) ; JxlStreamingAdapter @@ -13134,7 +13229,7 @@ size ( ) + -16 +1024 ) ; } diff --git a/third_party/jpeg-xl/lib/jxl/frame_header.cc b/third_party/jpeg-xl/lib/jxl/frame_header.cc index e746dabe2528..ef5374fd5e2f 100644 --- a/third_party/jpeg-xl/lib/jxl/frame_header.cc +++ b/third_party/jpeg-xl/lib/jxl/frame_header.cc @@ -2847,16 +2847,7 @@ is_last ) ; } -if -( -frame_type -! -= -FrameType -: -: -kRegularFrame -) +else { is_last = diff --git a/third_party/jpeg-xl/lib/jxl/gauss_blur.cc b/third_party/jpeg-xl/lib/jxl/gauss_blur.cc deleted file mode 100644 index 02df719685f8..000000000000 --- a/third_party/jpeg-xl/lib/jxl/gauss_blur.cc +++ /dev/null @@ -1,4943 +0,0 @@ -# -include -" -lib -/ -jxl -/ -gauss_blur -. -h -" -# -include -< -string -. -h -> -# -include -< -algorithm -> -# -include -< -cmath -> -# -undef -HWY_TARGET_INCLUDE -# -define -HWY_TARGET_INCLUDE -" -lib -/ -jxl -/ -gauss_blur -. -cc -" -# -include -< -hwy -/ -cache_control -. -h -> -# -include -< -hwy -/ -foreach_target -. -h -> -# -include -< -hwy -/ -highway -. -h -> -# -include -" -lib -/ -jxl -/ -base -/ -common -. -h -" -# -include -" -lib -/ -jxl -/ -base -/ -compiler_specific -. -h -" -# -include -" -lib -/ -jxl -/ -base -/ -matrix_ops -. -h -" -# -include -" -lib -/ -jxl -/ -image_ops -. -h -" -HWY_BEFORE_NAMESPACE -( -) -; -namespace -jxl -{ -namespace -HWY_NAMESPACE -{ -using -hwy -: -: -HWY_NAMESPACE -: -: -Add -; -using -hwy -: -: -HWY_NAMESPACE -: -: -Broadcast -; -using -hwy -: -: -HWY_NAMESPACE -: -: -GetLane -; -using -hwy -: -: -HWY_NAMESPACE -: -: -Mul -; -using -hwy -: -: -HWY_NAMESPACE -: -: -MulAdd -; -using -hwy -: -: -HWY_NAMESPACE -: -: -NegMulSub -; -# -if -HWY_TARGET -! -= -HWY_SCALAR -using -hwy -: -: -HWY_NAMESPACE -: -: -ShiftLeftLanes -; -# -endif -using -hwy -: -: -HWY_NAMESPACE -: -: -Vec -; -void -FastGaussian1D -( -const -hwy -: -: -AlignedUniquePtr -< -RecursiveGaussian -> -& -rg -const -float -* -JXL_RESTRICT -in -intptr_t -width -float -* -JXL_RESTRICT -out -) -{ -# -define -JXL_GAUSS_MAX_LANES -4 -using -D -= -HWY_CAPPED -( -float -JXL_GAUSS_MAX_LANES -) -; -using -V -= -Vec -< -D -> -; -const -D -d -; -const -V -mul_in_1 -= -Load -( -d -rg -- -> -mul_in -+ -0 -* -4 -) -; -const -V -mul_in_3 -= -Load -( -d -rg -- -> -mul_in -+ -1 -* -4 -) -; -const -V -mul_in_5 -= -Load -( -d -rg -- -> -mul_in -+ -2 -* -4 -) -; -const -V -mul_prev_1 -= -Load -( -d -rg -- -> -mul_prev -+ -0 -* -4 -) -; -const -V -mul_prev_3 -= -Load -( -d -rg -- -> -mul_prev -+ -1 -* -4 -) -; -const -V -mul_prev_5 -= -Load -( -d -rg -- -> -mul_prev -+ -2 -* -4 -) -; -const -V -mul_prev2_1 -= -Load -( -d -rg -- -> -mul_prev2 -+ -0 -* -4 -) -; -const -V -mul_prev2_3 -= -Load -( -d -rg -- -> -mul_prev2 -+ -1 -* -4 -) -; -const -V -mul_prev2_5 -= -Load -( -d -rg -- -> -mul_prev2 -+ -2 -* -4 -) -; -V -prev_1 -= -Zero -( -d -) -; -V -prev_3 -= -Zero -( -d -) -; -V -prev_5 -= -Zero -( -d -) -; -V -prev2_1 -= -Zero -( -d -) -; -V -prev2_3 -= -Zero -( -d -) -; -V -prev2_5 -= -Zero -( -d -) -; -const -intptr_t -N -= -rg -- -> -radius -; -intptr_t -n -= -- -N -+ -1 -; -const -intptr_t -first_aligned -= -RoundUpTo -( -N -+ -1 -Lanes -( -d -) -) -; -for -( -; -n -< -std -: -: -min -( -first_aligned -width -) -; -+ -+ -n -) -{ -const -intptr_t -left -= -n -- -N -- -1 -; -const -intptr_t -right -= -n -+ -N -- -1 -; -const -float -left_val -= -left -> -= -0 -? -in -[ -left -] -: -0 -. -0f -; -const -float -right_val -= -right -< -width -? -in -[ -right -] -: -0 -. -0f -; -const -V -sum -= -Set -( -d -left_val -+ -right_val -) -; -V -out_1 -= -Mul -( -sum -mul_in_1 -) -; -V -out_3 -= -Mul -( -sum -mul_in_3 -) -; -V -out_5 -= -Mul -( -sum -mul_in_5 -) -; -out_1 -= -MulAdd -( -mul_prev2_1 -prev2_1 -out_1 -) -; -out_3 -= -MulAdd -( -mul_prev2_3 -prev2_3 -out_3 -) -; -out_5 -= -MulAdd -( -mul_prev2_5 -prev2_5 -out_5 -) -; -prev2_1 -= -prev_1 -; -prev2_3 -= -prev_3 -; -prev2_5 -= -prev_5 -; -out_1 -= -MulAdd -( -mul_prev_1 -prev_1 -out_1 -) -; -out_3 -= -MulAdd -( -mul_prev_3 -prev_3 -out_3 -) -; -out_5 -= -MulAdd -( -mul_prev_5 -prev_5 -out_5 -) -; -prev_1 -= -out_1 -; -prev_3 -= -out_3 -; -prev_5 -= -out_5 -; -if -( -n -> -= -0 -) -{ -out -[ -n -] -= -GetLane -( -Add -( -out_1 -Add -( -out_3 -out_5 -) -) -) -; -} -} -# -if -HWY_TARGET -! -= -HWY_SCALAR -& -& -JXL_GAUSS_MAX_LANES -> -1 -prev2_1 -= -Broadcast -< -0 -> -( -prev2_1 -) -; -prev2_3 -= -Broadcast -< -0 -> -( -prev2_3 -) -; -prev2_5 -= -Broadcast -< -0 -> -( -prev2_5 -) -; -prev_1 -= -Broadcast -< -0 -> -( -prev_1 -) -; -prev_3 -= -Broadcast -< -0 -> -( -prev_3 -) -; -prev_5 -= -Broadcast -< -0 -> -( -prev_5 -) -; -# -endif -for -( -; -n -< -width -- -N -+ -1 -- -( -JXL_GAUSS_MAX_LANES -- -1 -) -; -n -+ -= -Lanes -( -d -) -) -{ -const -V -sum -= -Add -( -LoadU -( -d -in -+ -n -- -N -- -1 -) -LoadU -( -d -in -+ -n -+ -N -- -1 -) -) -; -const -V -in0 -= -Broadcast -< -0 -> -( -sum -) -; -V -out_1 -= -Mul -( -in0 -mul_in_1 -) -; -V -out_3 -= -Mul -( -in0 -mul_in_3 -) -; -V -out_5 -= -Mul -( -in0 -mul_in_5 -) -; -# -if -HWY_TARGET -! -= -HWY_SCALAR -& -& -JXL_GAUSS_MAX_LANES -> -= -2 -const -V -in1 -= -Broadcast -< -1 -> -( -sum -) -; -out_1 -= -MulAdd -( -ShiftLeftLanes -< -1 -> -( -mul_in_1 -) -in1 -out_1 -) -; -out_3 -= -MulAdd -( -ShiftLeftLanes -< -1 -> -( -mul_in_3 -) -in1 -out_3 -) -; -out_5 -= -MulAdd -( -ShiftLeftLanes -< -1 -> -( -mul_in_5 -) -in1 -out_5 -) -; -# -if -JXL_GAUSS_MAX_LANES -> -= -4 -const -V -in2 -= -Broadcast -< -2 -> -( -sum -) -; -out_1 -= -MulAdd -( -ShiftLeftLanes -< -2 -> -( -mul_in_1 -) -in2 -out_1 -) -; -out_3 -= -MulAdd -( -ShiftLeftLanes -< -2 -> -( -mul_in_3 -) -in2 -out_3 -) -; -out_5 -= -MulAdd -( -ShiftLeftLanes -< -2 -> -( -mul_in_5 -) -in2 -out_5 -) -; -const -V -in3 -= -Broadcast -< -3 -> -( -sum -) -; -out_1 -= -MulAdd -( -ShiftLeftLanes -< -3 -> -( -mul_in_1 -) -in3 -out_1 -) -; -out_3 -= -MulAdd -( -ShiftLeftLanes -< -3 -> -( -mul_in_3 -) -in3 -out_3 -) -; -out_5 -= -MulAdd -( -ShiftLeftLanes -< -3 -> -( -mul_in_5 -) -in3 -out_5 -) -; -# -endif -# -endif -out_1 -= -MulAdd -( -mul_prev2_1 -prev2_1 -out_1 -) -; -out_3 -= -MulAdd -( -mul_prev2_3 -prev2_3 -out_3 -) -; -out_5 -= -MulAdd -( -mul_prev2_5 -prev2_5 -out_5 -) -; -out_1 -= -MulAdd -( -mul_prev_1 -prev_1 -out_1 -) -; -out_3 -= -MulAdd -( -mul_prev_3 -prev_3 -out_3 -) -; -out_5 -= -MulAdd -( -mul_prev_5 -prev_5 -out_5 -) -; -# -if -HWY_TARGET -= -= -HWY_SCALAR -| -| -JXL_GAUSS_MAX_LANES -= -= -1 -prev2_1 -= -prev_1 -; -prev2_3 -= -prev_3 -; -prev2_5 -= -prev_5 -; -prev_1 -= -out_1 -; -prev_3 -= -out_3 -; -prev_5 -= -out_5 -; -# -else -prev2_1 -= -Broadcast -< -JXL_GAUSS_MAX_LANES -- -2 -> -( -out_1 -) -; -prev2_3 -= -Broadcast -< -JXL_GAUSS_MAX_LANES -- -2 -> -( -out_3 -) -; -prev2_5 -= -Broadcast -< -JXL_GAUSS_MAX_LANES -- -2 -> -( -out_5 -) -; -prev_1 -= -Broadcast -< -JXL_GAUSS_MAX_LANES -- -1 -> -( -out_1 -) -; -prev_3 -= -Broadcast -< -JXL_GAUSS_MAX_LANES -- -1 -> -( -out_3 -) -; -prev_5 -= -Broadcast -< -JXL_GAUSS_MAX_LANES -- -1 -> -( -out_5 -) -; -# -endif -Store -( -Add -( -out_1 -Add -( -out_3 -out_5 -) -) -d -out -+ -n -) -; -} -for -( -; -n -< -width -; -+ -+ -n -) -{ -const -intptr_t -left -= -n -- -N -- -1 -; -const -intptr_t -right -= -n -+ -N -- -1 -; -const -float -left_val -= -left -> -= -0 -? -in -[ -left -] -: -0 -. -0f -; -const -float -right_val -= -right -< -width -? -in -[ -right -] -: -0 -. -0f -; -const -V -sum -= -Set -( -d -left_val -+ -right_val -) -; -V -out_1 -= -Mul -( -sum -mul_in_1 -) -; -V -out_3 -= -Mul -( -sum -mul_in_3 -) -; -V -out_5 -= -Mul -( -sum -mul_in_5 -) -; -out_1 -= -MulAdd -( -mul_prev2_1 -prev2_1 -out_1 -) -; -out_3 -= -MulAdd -( -mul_prev2_3 -prev2_3 -out_3 -) -; -out_5 -= -MulAdd -( -mul_prev2_5 -prev2_5 -out_5 -) -; -prev2_1 -= -prev_1 -; -prev2_3 -= -prev_3 -; -prev2_5 -= -prev_5 -; -out_1 -= -MulAdd -( -mul_prev_1 -prev_1 -out_1 -) -; -out_3 -= -MulAdd -( -mul_prev_3 -prev_3 -out_3 -) -; -out_5 -= -MulAdd -( -mul_prev_5 -prev_5 -out_5 -) -; -prev_1 -= -out_1 -; -prev_3 -= -out_3 -; -prev_5 -= -out_5 -; -out -[ -n -] -= -GetLane -( -Add -( -out_1 -Add -( -out_3 -out_5 -) -) -) -; -} -} -constexpr -size_t -kMod -= -4 -; -struct -OutputNone -{ -template -< -class -V -> -void -operator -( -) -( -const -V -& -float -* -JXL_RESTRICT -ptrdiff_t -) -const -{ -} -} -; -struct -OutputStore -{ -template -< -class -V -> -void -operator -( -) -( -const -V -& -out -float -* -JXL_RESTRICT -pos -ptrdiff_t -offset -) -const -{ -const -HWY_FULL -( -float -) -df -; -Store -( -out -df -pos -+ -offset -) -; -} -} -; -class -SingleInput -{ -public -: -explicit -SingleInput -( -const -float -* -pos -) -: -pos_ -( -pos -) -{ -} -Vec -< -HWY_FULL -( -float -) -> -operator -( -) -( -const -size_t -offset -) -const -{ -const -HWY_FULL -( -float -) -df -; -return -Load -( -df -pos_ -+ -offset -) -; -} -const -float -* -pos_ -; -} -; -class -TwoInputs -{ -public -: -TwoInputs -( -const -float -* -pos1 -const -float -* -pos2 -) -: -pos1_ -( -pos1 -) -pos2_ -( -pos2 -) -{ -} -Vec -< -HWY_FULL -( -float -) -> -operator -( -) -( -const -size_t -offset -) -const -{ -const -HWY_FULL -( -float -) -df -; -const -auto -in1 -= -Load -( -df -pos1_ -+ -offset -) -; -const -auto -in2 -= -Load -( -df -pos2_ -+ -offset -) -; -return -Add -( -in1 -in2 -) -; -} -private -: -const -float -* -pos1_ -; -const -float -* -pos2_ -; -} -; -template -< -size_t -kVectors -class -V -class -Input -class -Output -> -void -VerticalBlock -( -const -V -& -d1_1 -const -V -& -d1_3 -const -V -& -d1_5 -const -V -& -n2_1 -const -V -& -n2_3 -const -V -& -n2_5 -const -Input -& -input -size_t -& -ctr -float -* -ring_buffer -const -Output -output -float -* -JXL_RESTRICT -out_pos -) -{ -const -HWY_FULL -( -float -) -d -; -constexpr -size_t -kVN -= -MaxLanes -( -d -) -; -constexpr -size_t -kLanes -= -kVectors -* -kVN -; -float -* -JXL_RESTRICT -y_1 -= -ring_buffer -+ -0 -* -kLanes -* -kMod -; -float -* -JXL_RESTRICT -y_3 -= -ring_buffer -+ -1 -* -kLanes -* -kMod -; -float -* -JXL_RESTRICT -y_5 -= -ring_buffer -+ -2 -* -kLanes -* -kMod -; -const -size_t -n_0 -= -( -+ -+ -ctr -) -% -kMod -; -const -size_t -n_1 -= -( -ctr -- -1 -) -% -kMod -; -const -size_t -n_2 -= -( -ctr -- -2 -) -% -kMod -; -for -( -size_t -idx_vec -= -0 -; -idx_vec -< -kVectors -; -+ -+ -idx_vec -) -{ -const -V -sum -= -input -( -idx_vec -* -kVN -) -; -const -V -y_n1_1 -= -Load -( -d -y_1 -+ -kLanes -* -n_1 -+ -idx_vec -* -kVN -) -; -const -V -y_n1_3 -= -Load -( -d -y_3 -+ -kLanes -* -n_1 -+ -idx_vec -* -kVN -) -; -const -V -y_n1_5 -= -Load -( -d -y_5 -+ -kLanes -* -n_1 -+ -idx_vec -* -kVN -) -; -const -V -y_n2_1 -= -Load -( -d -y_1 -+ -kLanes -* -n_2 -+ -idx_vec -* -kVN -) -; -const -V -y_n2_3 -= -Load -( -d -y_3 -+ -kLanes -* -n_2 -+ -idx_vec -* -kVN -) -; -const -V -y_n2_5 -= -Load -( -d -y_5 -+ -kLanes -* -n_2 -+ -idx_vec -* -kVN -) -; -const -V -y1 -= -MulAdd -( -n2_1 -sum -NegMulSub -( -d1_1 -y_n1_1 -y_n2_1 -) -) -; -const -V -y3 -= -MulAdd -( -n2_3 -sum -NegMulSub -( -d1_3 -y_n1_3 -y_n2_3 -) -) -; -const -V -y5 -= -MulAdd -( -n2_5 -sum -NegMulSub -( -d1_5 -y_n1_5 -y_n2_5 -) -) -; -Store -( -y1 -d -y_1 -+ -kLanes -* -n_0 -+ -idx_vec -* -kVN -) -; -Store -( -y3 -d -y_3 -+ -kLanes -* -n_0 -+ -idx_vec -* -kVN -) -; -Store -( -y5 -d -y_5 -+ -kLanes -* -n_0 -+ -idx_vec -* -kVN -) -; -output -( -Add -( -y1 -Add -( -y3 -y5 -) -) -out_pos -idx_vec -* -kVN -) -; -} -} -template -< -size_t -kVectors -> -void -VerticalStrip -( -const -hwy -: -: -AlignedUniquePtr -< -RecursiveGaussian -> -& -rg -const -ImageF -& -in -const -size_t -x -ImageF -* -JXL_RESTRICT -out -) -{ -using -D -= -HWY_FULL -( -float -) -; -using -V -= -Vec -< -D -> -; -const -D -d -; -constexpr -size_t -kVN -= -MaxLanes -( -d -) -; -constexpr -size_t -kLanes -= -kVectors -* -kVN -; -# -if -HWY_TARGET -= -= -HWY_SCALAR -const -V -d1_1 -= -Set -( -d -rg -- -> -d1 -[ -0 -* -4 -] -) -; -const -V -d1_3 -= -Set -( -d -rg -- -> -d1 -[ -1 -* -4 -] -) -; -const -V -d1_5 -= -Set -( -d -rg -- -> -d1 -[ -2 -* -4 -] -) -; -const -V -n2_1 -= -Set -( -d -rg -- -> -n2 -[ -0 -* -4 -] -) -; -const -V -n2_3 -= -Set -( -d -rg -- -> -n2 -[ -1 -* -4 -] -) -; -const -V -n2_5 -= -Set -( -d -rg -- -> -n2 -[ -2 -* -4 -] -) -; -# -else -const -V -d1_1 -= -LoadDup128 -( -d -rg -- -> -d1 -+ -0 -* -4 -) -; -const -V -d1_3 -= -LoadDup128 -( -d -rg -- -> -d1 -+ -1 -* -4 -) -; -const -V -d1_5 -= -LoadDup128 -( -d -rg -- -> -d1 -+ -2 -* -4 -) -; -const -V -n2_1 -= -LoadDup128 -( -d -rg -- -> -n2 -+ -0 -* -4 -) -; -const -V -n2_3 -= -LoadDup128 -( -d -rg -- -> -n2 -+ -1 -* -4 -) -; -const -V -n2_5 -= -LoadDup128 -( -d -rg -- -> -n2 -+ -2 -* -4 -) -; -# -endif -const -size_t -N -= -rg -- -> -radius -; -const -size_t -ysize -= -in -. -ysize -( -) -; -size_t -ctr -= -0 -; -HWY_ALIGN -float -ring_buffer -[ -3 -* -kLanes -* -kMod -] -= -{ -0 -} -; -HWY_ALIGN -static -constexpr -float -zero -[ -kLanes -] -= -{ -0 -} -; -ssize_t -n -= -- -static_cast -< -ssize_t -> -( -N -) -+ -1 -; -for -( -; -n -< -0 -; -+ -+ -n -) -{ -const -size_t -bottom -= -n -+ -N -- -1 -; -VerticalBlock -< -kVectors -> -( -d1_1 -d1_3 -d1_5 -n2_1 -n2_3 -n2_5 -SingleInput -( -bottom -< -ysize -? -in -. -ConstRow -( -bottom -) -+ -x -: -zero -) -ctr -ring_buffer -OutputNone -( -) -nullptr -) -; -} -JXL_DASSERT -( -n -> -= -0 -) -; -for -( -; -static_cast -< -size_t -> -( -n -) -< -std -: -: -min -( -N -+ -1 -ysize -) -; -+ -+ -n -) -{ -const -size_t -bottom -= -n -+ -N -- -1 -; -VerticalBlock -< -kVectors -> -( -d1_1 -d1_3 -d1_5 -n2_1 -n2_3 -n2_5 -SingleInput -( -bottom -< -ysize -? -in -. -ConstRow -( -bottom -) -+ -x -: -zero -) -ctr -ring_buffer -OutputStore -( -) -out -- -> -Row -( -n -) -+ -x -) -; -} -constexpr -size_t -kPrefetchRows -= -8 -; -for -( -; -n -< -static_cast -< -ssize_t -> -( -ysize -- -N -+ -1 -- -kPrefetchRows -) -; -+ -+ -n -) -{ -const -size_t -top -= -n -- -N -- -1 -; -const -size_t -bottom -= -n -+ -N -- -1 -; -VerticalBlock -< -kVectors -> -( -d1_1 -d1_3 -d1_5 -n2_1 -n2_3 -n2_5 -TwoInputs -( -in -. -ConstRow -( -top -) -+ -x -in -. -ConstRow -( -bottom -) -+ -x -) -ctr -ring_buffer -OutputStore -( -) -out -- -> -Row -( -n -) -+ -x -) -; -hwy -: -: -Prefetch -( -in -. -ConstRow -( -top -+ -kPrefetchRows -) -+ -x -) -; -hwy -: -: -Prefetch -( -in -. -ConstRow -( -bottom -+ -kPrefetchRows -) -+ -x -) -; -} -for -( -; -static_cast -< -size_t -> -( -n -) -< -ysize -; -+ -+ -n -) -{ -const -size_t -top -= -n -- -N -- -1 -; -const -size_t -bottom -= -n -+ -N -- -1 -; -VerticalBlock -< -kVectors -> -( -d1_1 -d1_3 -d1_5 -n2_1 -n2_3 -n2_5 -TwoInputs -( -in -. -ConstRow -( -top -) -+ -x -bottom -< -ysize -? -in -. -ConstRow -( -bottom -) -+ -x -: -zero -) -ctr -ring_buffer -OutputStore -( -) -out -- -> -Row -( -n -) -+ -x -) -; -} -} -void -FastGaussianVertical -( -const -hwy -: -: -AlignedUniquePtr -< -RecursiveGaussian -> -& -rg -const -ImageF -& -in -ThreadPool -* -ImageF -* -JXL_RESTRICT -out -) -{ -JXL_CHECK -( -SameSize -( -in -* -out -) -) -; -const -HWY_FULL -( -float -) -df -; -constexpr -size_t -kCacheLineLanes -= -64 -/ -sizeof -( -float -) -; -constexpr -size_t -kVN -= -MaxLanes -( -df -) -; -constexpr -size_t -kCacheLineVectors -= -( -kVN -< -kCacheLineLanes -) -? -( -kCacheLineLanes -/ -kVN -) -: -4 -; -constexpr -size_t -kFastPace -= -kCacheLineVectors -* -kVN -; -size_t -x -= -0 -; -for -( -; -x -+ -kFastPace -< -= -in -. -xsize -( -) -; -x -+ -= -kFastPace -) -{ -VerticalStrip -< -kCacheLineVectors -> -( -rg -in -x -out -) -; -} -for -( -; -x -< -in -. -xsize -( -) -; -x -+ -= -kVN -) -{ -VerticalStrip -< -1 -> -( -rg -in -x -out -) -; -} -} -ImageF -ConvolveXSampleAndTranspose -( -const -ImageF -& -in -const -std -: -: -vector -< -float -> -& -kernel -const -size_t -res -) -{ -JXL_ASSERT -( -kernel -. -size -( -) -% -2 -= -= -1 -) -; -JXL_ASSERT -( -in -. -xsize -( -) -% -res -= -= -0 -) -; -const -size_t -offset -= -res -/ -2 -; -const -size_t -out_xsize -= -in -. -xsize -( -) -/ -res -; -ImageF -out -( -in -. -ysize -( -) -out_xsize -) -; -const -int -r -= -kernel -. -size -( -) -/ -2 -; -HWY_FULL -( -float -) -df -; -std -: -: -vector -< -float -> -row_tmp -( -in -. -xsize -( -) -+ -2 -* -r -+ -Lanes -( -df -) -) -; -float -* -const -JXL_RESTRICT -rowp -= -& -row_tmp -[ -r -] -; -std -: -: -vector -< -float -> -padded_k -= -kernel -; -padded_k -. -resize -( -padded_k -. -size -( -) -+ -Lanes -( -df -) -) -; -const -float -* -const -kernelp -= -& -padded_k -[ -r -] -; -for -( -size_t -y -= -0 -; -y -< -in -. -ysize -( -) -; -+ -+ -y -) -{ -ExtrapolateBorders -( -in -. -Row -( -y -) -rowp -in -. -xsize -( -) -r -) -; -size_t -x -= -offset -ox -= -0 -; -for -( -; -x -< -static_cast -< -uint32_t -> -( -r -) -& -& -x -< -in -. -xsize -( -) -; -x -+ -= -res -+ -+ -ox -) -{ -float -sum -= -0 -. -0f -; -for -( -int -i -= -- -r -; -i -< -= -r -; -+ -+ -i -) -{ -sum -+ -= -rowp -[ -std -: -: -max -< -int -> -( -0 -std -: -: -min -< -int -> -( -static_cast -< -int -> -( -x -) -+ -i -in -. -xsize -( -) -) -) -] -* -kernelp -[ -i -] -; -} -out -. -Row -( -ox -) -[ -y -] -= -sum -; -} -for -( -; -x -+ -r -< -in -. -xsize -( -) -; -x -+ -= -res -+ -+ -ox -) -{ -auto -sum -= -Zero -( -df -) -; -for -( -int -i -= -- -r -; -i -< -= -r -; -i -+ -= -Lanes -( -df -) -) -{ -sum -= -MulAdd -( -LoadU -( -df -rowp -+ -x -+ -i -) -LoadU -( -df -kernelp -+ -i -) -sum -) -; -} -out -. -Row -( -ox -) -[ -y -] -= -GetLane -( -SumOfLanes -( -df -sum -) -) -; -} -for -( -; -x -< -in -. -xsize -( -) -; -x -+ -= -res -+ -+ -ox -) -{ -float -sum -= -0 -. -0f -; -for -( -int -i -= -- -r -; -i -< -= -r -; -+ -+ -i -) -{ -sum -+ -= -rowp -[ -std -: -: -max -< -int -> -( -0 -std -: -: -min -< -int -> -( -static_cast -< -int -> -( -x -) -+ -i -in -. -xsize -( -) -) -) -] -* -kernelp -[ -i -] -; -} -out -. -Row -( -ox -) -[ -y -] -= -sum -; -} -} -return -out -; -} -} -} -HWY_AFTER_NAMESPACE -( -) -; -# -if -HWY_ONCE -namespace -jxl -{ -HWY_EXPORT -( -FastGaussian1D -) -; -HWY_EXPORT -( -ConvolveXSampleAndTranspose -) -; -void -FastGaussian1D -( -const -hwy -: -: -AlignedUniquePtr -< -RecursiveGaussian -> -& -rg -const -float -* -JXL_RESTRICT -in -intptr_t -width -float -* -JXL_RESTRICT -out -) -{ -return -HWY_DYNAMIC_DISPATCH -( -FastGaussian1D -) -( -rg -in -width -out -) -; -} -HWY_EXPORT -( -FastGaussianVertical -) -; -void -ExtrapolateBorders -( -const -float -* -const -JXL_RESTRICT -row_in -float -* -const -JXL_RESTRICT -row_out -const -int -xsize -const -int -radius -) -{ -const -int -lastcol -= -xsize -- -1 -; -for -( -int -x -= -1 -; -x -< -= -radius -; -+ -+ -x -) -{ -row_out -[ -- -x -] -= -row_in -[ -std -: -: -min -( -x -xsize -- -1 -) -] -; -} -memcpy -( -row_out -row_in -xsize -* -sizeof -( -row_out -[ -0 -] -) -) -; -for -( -int -x -= -1 -; -x -< -= -radius -; -+ -+ -x -) -{ -row_out -[ -lastcol -+ -x -] -= -row_in -[ -std -: -: -max -( -0 -lastcol -- -x -) -] -; -} -} -ImageF -ConvolveXSampleAndTranspose -( -const -ImageF -& -in -const -std -: -: -vector -< -float -> -& -kernel -const -size_t -res -) -{ -return -HWY_DYNAMIC_DISPATCH -( -ConvolveXSampleAndTranspose -) -( -in -kernel -res -) -; -} -Image3F -ConvolveXSampleAndTranspose -( -const -Image3F -& -in -const -std -: -: -vector -< -float -> -& -kernel -const -size_t -res -) -{ -return -Image3F -( -ConvolveXSampleAndTranspose -( -in -. -Plane -( -0 -) -kernel -res -) -ConvolveXSampleAndTranspose -( -in -. -Plane -( -1 -) -kernel -res -) -ConvolveXSampleAndTranspose -( -in -. -Plane -( -2 -) -kernel -res -) -) -; -} -ImageF -ConvolveAndSample -( -const -ImageF -& -in -const -std -: -: -vector -< -float -> -& -kernel -const -size_t -res -) -{ -ImageF -tmp -= -ConvolveXSampleAndTranspose -( -in -kernel -res -) -; -return -ConvolveXSampleAndTranspose -( -tmp -kernel -res -) -; -} -hwy -: -: -AlignedUniquePtr -< -RecursiveGaussian -> -CreateRecursiveGaussian -( -double -sigma -) -{ -auto -rg -= -hwy -: -: -MakeUniqueAligned -< -RecursiveGaussian -> -( -) -; -constexpr -double -kPi -= -3 -. -141592653589793238 -; -const -double -radius -= -roundf -( -3 -. -2795 -* -sigma -+ -0 -. -2546 -) -; -const -double -pi_div_2r -= -kPi -/ -( -2 -. -0 -* -radius -) -; -const -double -omega -[ -3 -] -= -{ -pi_div_2r -3 -. -0 -* -pi_div_2r -5 -. -0 -* -pi_div_2r -} -; -const -double -p_1 -= -+ -1 -. -0 -/ -std -: -: -tan -( -0 -. -5 -* -omega -[ -0 -] -) -; -const -double -p_3 -= -- -1 -. -0 -/ -std -: -: -tan -( -0 -. -5 -* -omega -[ -1 -] -) -; -const -double -p_5 -= -+ -1 -. -0 -/ -std -: -: -tan -( -0 -. -5 -* -omega -[ -2 -] -) -; -const -double -r_1 -= -+ -p_1 -* -p_1 -/ -std -: -: -sin -( -omega -[ -0 -] -) -; -const -double -r_3 -= -- -p_3 -* -p_3 -/ -std -: -: -sin -( -omega -[ -1 -] -) -; -const -double -r_5 -= -+ -p_5 -* -p_5 -/ -std -: -: -sin -( -omega -[ -2 -] -) -; -const -double -neg_half_sigma2 -= -- -0 -. -5 -* -sigma -* -sigma -; -const -double -recip_radius -= -1 -. -0 -/ -radius -; -double -rho -[ -3 -] -; -for -( -size_t -i -= -0 -; -i -< -3 -; -+ -+ -i -) -{ -rho -[ -i -] -= -std -: -: -exp -( -neg_half_sigma2 -* -omega -[ -i -] -* -omega -[ -i -] -) -* -recip_radius -; -} -const -double -D_13 -= -p_1 -* -r_3 -- -r_1 -* -p_3 -; -const -double -D_35 -= -p_3 -* -r_5 -- -r_3 -* -p_5 -; -const -double -D_51 -= -p_5 -* -r_1 -- -r_5 -* -p_1 -; -const -double -recip_d13 -= -1 -. -0 -/ -D_13 -; -const -double -zeta_15 -= -D_35 -* -recip_d13 -; -const -double -zeta_35 -= -D_51 -* -recip_d13 -; -double -A -[ -9 -] -= -{ -p_1 -p_3 -p_5 -r_1 -r_3 -r_5 -zeta_15 -zeta_35 -1 -} -; -JXL_CHECK -( -Inv3x3Matrix -( -A -) -) -; -const -double -gamma -[ -3 -] -= -{ -1 -radius -* -radius -- -sigma -* -sigma -zeta_15 -* -rho -[ -0 -] -+ -zeta_35 -* -rho -[ -1 -] -+ -rho -[ -2 -] -} -; -double -beta -[ -3 -] -; -Mul3x3Vector -( -A -gamma -beta -) -; -const -double -sum -= -beta -[ -0 -] -* -p_1 -+ -beta -[ -1 -] -* -p_3 -+ -beta -[ -2 -] -* -p_5 -; -JXL_ASSERT -( -std -: -: -abs -( -sum -- -1 -) -< -1E -- -12 -) -; -( -void -) -sum -; -rg -- -> -radius -= -static_cast -< -int -> -( -radius -) -; -double -n2 -[ -3 -] -; -double -d1 -[ -3 -] -; -for -( -size_t -i -= -0 -; -i -< -3 -; -+ -+ -i -) -{ -n2 -[ -i -] -= -- -beta -[ -i -] -* -std -: -: -cos -( -omega -[ -i -] -* -( -radius -+ -1 -. -0 -) -) -; -d1 -[ -i -] -= -- -2 -. -0 -* -std -: -: -cos -( -omega -[ -i -] -) -; -for -( -size_t -lane -= -0 -; -lane -< -4 -; -+ -+ -lane -) -{ -rg -- -> -n2 -[ -4 -* -i -+ -lane -] -= -static_cast -< -float -> -( -n2 -[ -i -] -) -; -rg -- -> -d1 -[ -4 -* -i -+ -lane -] -= -static_cast -< -float -> -( -d1 -[ -i -] -) -; -} -const -double -d_2 -= -d1 -[ -i -] -* -d1 -[ -i -] -; -rg -- -> -mul_prev -[ -4 -* -i -+ -0 -] -= -- -d1 -[ -i -] -; -rg -- -> -mul_prev -[ -4 -* -i -+ -1 -] -= -d_2 -- -1 -. -0 -; -rg -- -> -mul_prev -[ -4 -* -i -+ -2 -] -= -- -d_2 -* -d1 -[ -i -] -+ -2 -. -0 -* -d1 -[ -i -] -; -rg -- -> -mul_prev -[ -4 -* -i -+ -3 -] -= -d_2 -* -d_2 -- -3 -. -0 -* -d_2 -+ -1 -. -0 -; -rg -- -> -mul_prev2 -[ -4 -* -i -+ -0 -] -= -- -1 -. -0 -; -rg -- -> -mul_prev2 -[ -4 -* -i -+ -1 -] -= -d1 -[ -i -] -; -rg -- -> -mul_prev2 -[ -4 -* -i -+ -2 -] -= -- -d_2 -+ -1 -. -0 -; -rg -- -> -mul_prev2 -[ -4 -* -i -+ -3 -] -= -d_2 -* -d1 -[ -i -] -- -2 -. -0 -* -d1 -[ -i -] -; -rg -- -> -mul_in -[ -4 -* -i -+ -0 -] -= -n2 -[ -i -] -; -rg -- -> -mul_in -[ -4 -* -i -+ -1 -] -= -- -d1 -[ -i -] -* -n2 -[ -i -] -; -rg -- -> -mul_in -[ -4 -* -i -+ -2 -] -= -d_2 -* -n2 -[ -i -] -- -n2 -[ -i -] -; -rg -- -> -mul_in -[ -4 -* -i -+ -3 -] -= -- -d_2 -* -d1 -[ -i -] -* -n2 -[ -i -] -+ -2 -. -0 -* -d1 -[ -i -] -* -n2 -[ -i -] -; -} -return -rg -; -} -namespace -{ -void -FastGaussianHorizontal -( -const -hwy -: -: -AlignedUniquePtr -< -RecursiveGaussian -> -& -rg -const -ImageF -& -in -ThreadPool -* -pool -ImageF -* -JXL_RESTRICT -out -) -{ -JXL_CHECK -( -SameSize -( -in -* -out -) -) -; -const -intptr_t -xsize -= -in -. -xsize -( -) -; -JXL_CHECK -( -RunOnPool -( -pool -0 -in -. -ysize -( -) -ThreadPool -: -: -NoInit -[ -& -] -( -const -uint32_t -task -size_t -) -{ -const -size_t -y -= -task -; -const -float -* -row_in -= -in -. -ConstRow -( -y -) -; -float -* -JXL_RESTRICT -row_out -= -out -- -> -Row -( -y -) -; -FastGaussian1D -( -rg -row_in -xsize -row_out -) -; -} -" -FastGaussianHorizontal -" -) -) -; -} -} -void -FastGaussian -( -const -hwy -: -: -AlignedUniquePtr -< -RecursiveGaussian -> -& -rg -const -ImageF -& -in -ThreadPool -* -pool -ImageF -* -JXL_RESTRICT -temp -ImageF -* -JXL_RESTRICT -out -) -{ -FastGaussianHorizontal -( -rg -in -pool -temp -) -; -HWY_DYNAMIC_DISPATCH -( -FastGaussianVertical -) -( -rg -* -temp -pool -out -) -; -} -} -# -endif diff --git a/third_party/jpeg-xl/lib/jxl/gauss_blur.h b/third_party/jpeg-xl/lib/jxl/gauss_blur.h deleted file mode 100644 index b8855045496b..000000000000 --- a/third_party/jpeg-xl/lib/jxl/gauss_blur.h +++ /dev/null @@ -1,400 +0,0 @@ -# -ifndef -LIB_JXL_GAUSS_BLUR_H_ -# -define -LIB_JXL_GAUSS_BLUR_H_ -# -include -< -stddef -. -h -> -# -include -< -cmath -> -# -include -< -hwy -/ -aligned_allocator -. -h -> -# -include -< -vector -> -# -include -" -lib -/ -jxl -/ -base -/ -data_parallel -. -h -" -# -include -" -lib -/ -jxl -/ -base -/ -status -. -h -" -# -include -" -lib -/ -jxl -/ -image -. -h -" -namespace -jxl -{ -template -< -typename -T -> -std -: -: -vector -< -T -> -GaussianKernel -( -int -radius -T -sigma -) -{ -JXL_ASSERT -( -sigma -> -0 -. -0 -) -; -std -: -: -vector -< -T -> -kernel -( -2 -* -radius -+ -1 -) -; -const -T -scaler -= -- -1 -. -0 -/ -( -2 -* -sigma -* -sigma -) -; -double -sum -= -0 -. -0 -; -for -( -int -i -= -- -radius -; -i -< -= -radius -; -+ -+ -i -) -{ -const -T -val -= -std -: -: -exp -( -scaler -* -i -* -i -) -; -kernel -[ -i -+ -radius -] -= -val -; -sum -+ -= -val -; -} -for -( -size_t -i -= -0 -; -i -< -kernel -. -size -( -) -; -+ -+ -i -) -{ -kernel -[ -i -] -/ -= -sum -; -} -return -kernel -; -} -ImageF -ConvolveAndSample -( -const -ImageF -& -in -const -std -: -: -vector -< -float -> -& -kernel -const -size_t -res -) -; -void -ExtrapolateBorders -( -const -float -* -const -JXL_RESTRICT -row_in -float -* -const -JXL_RESTRICT -row_out -const -int -xsize -const -int -radius -) -; -# -pragma -pack -( -push -1 -) -struct -RecursiveGaussian -{ -float -n2 -[ -3 -* -4 -] -; -float -d1 -[ -3 -* -4 -] -; -float -mul_prev -[ -3 -* -4 -] -; -float -mul_prev2 -[ -3 -* -4 -] -; -float -mul_in -[ -3 -* -4 -] -; -size_t -radius -; -} -; -# -pragma -pack -( -pop -) -hwy -: -: -AlignedUniquePtr -< -RecursiveGaussian -> -CreateRecursiveGaussian -( -double -sigma -) -; -void -FastGaussian1D -( -const -hwy -: -: -AlignedUniquePtr -< -RecursiveGaussian -> -& -rg -const -float -* -JXL_RESTRICT -in -intptr_t -width -float -* -JXL_RESTRICT -out -) -; -void -FastGaussian -( -const -hwy -: -: -AlignedUniquePtr -< -RecursiveGaussian -> -& -rg -const -ImageF -& -in -ThreadPool -* -pool -ImageF -* -JXL_RESTRICT -temp -ImageF -* -JXL_RESTRICT -out -) -; -} -# -endif diff --git a/third_party/jpeg-xl/lib/jxl/gauss_blur_gbench.cc b/third_party/jpeg-xl/lib/jxl/gauss_blur_gbench.cc deleted file mode 100644 index ca07da597d66..000000000000 --- a/third_party/jpeg-xl/lib/jxl/gauss_blur_gbench.cc +++ /dev/null @@ -1,812 +0,0 @@ -# -include -< -hwy -/ -targets -. -h -> -# -include -" -benchmark -/ -benchmark -. -h -" -# -include -" -lib -/ -jxl -/ -convolve -. -h -" -# -include -" -lib -/ -jxl -/ -gauss_blur -. -h -" -# -include -" -lib -/ -jxl -/ -image_ops -. -h -" -namespace -jxl -{ -namespace -{ -JXL_MAYBE_UNUSED -ImageF -Convolve -( -const -ImageF -& -in -const -std -: -: -vector -< -float -> -& -kernel -) -{ -return -ConvolveAndSample -( -in -kernel -1 -) -; -} -void -BM_GaussBlur1d -( -benchmark -: -: -State -& -state -) -{ -const -size_t -length -= -state -. -range -( -) -; -const -double -sigma -= -7 -. -0 -; -ImageF -in -( -length -1 -) -; -const -float -expected -= -length -; -FillImage -( -expected -& -in -) -; -ImageF -temp -( -length -1 -) -; -ImageF -out -( -length -1 -) -; -const -auto -rg -= -CreateRecursiveGaussian -( -sigma -) -; -for -( -auto -_ -: -state -) -{ -FastGaussian1D -( -rg -in -. -Row -( -0 -) -length -out -. -Row -( -0 -) -) -; -JXL_ASSERT -( -std -: -: -abs -( -out -. -ConstRow -( -0 -) -[ -length -/ -2 -] -- -expected -) -/ -expected -< -9E -- -5 -) -; -} -state -. -SetItemsProcessed -( -length -* -state -. -iterations -( -) -) -; -} -void -BM_GaussBlur2d -( -benchmark -: -: -State -& -state -) -{ -const -size_t -xsize -= -state -. -range -( -) -; -const -size_t -ysize -= -xsize -; -const -double -sigma -= -7 -. -0 -; -ImageF -in -( -xsize -ysize -) -; -const -float -expected -= -xsize -+ -ysize -; -FillImage -( -expected -& -in -) -; -ImageF -temp -( -xsize -ysize -) -; -ImageF -out -( -xsize -ysize -) -; -ThreadPool -* -null_pool -= -nullptr -; -const -auto -rg -= -CreateRecursiveGaussian -( -sigma -) -; -for -( -auto -_ -: -state -) -{ -FastGaussian -( -rg -in -null_pool -& -temp -& -out -) -; -JXL_ASSERT -( -std -: -: -abs -( -out -. -ConstRow -( -ysize -/ -2 -) -[ -xsize -/ -2 -] -- -expected -) -/ -expected -< -9E -- -5 -) -; -} -state -. -SetItemsProcessed -( -xsize -* -ysize -* -state -. -iterations -( -) -) -; -} -void -BM_GaussBlurFir -( -benchmark -: -: -State -& -state -) -{ -const -size_t -xsize -= -state -. -range -( -) -; -const -size_t -ysize -= -xsize -; -const -double -sigma -= -7 -. -0 -; -ImageF -in -( -xsize -ysize -) -; -const -float -expected -= -xsize -+ -ysize -; -FillImage -( -expected -& -in -) -; -ImageF -temp -( -xsize -ysize -) -; -ImageF -out -( -xsize -ysize -) -; -const -std -: -: -vector -< -float -> -kernel -= -GaussianKernel -( -static_cast -< -int -> -( -4 -* -sigma -) -static_cast -< -float -> -( -sigma -) -) -; -for -( -auto -_ -: -state -) -{ -JXL_ASSERT -( -std -: -: -abs -( -Convolve -( -in -kernel -) -. -ConstRow -( -ysize -/ -2 -) -[ -xsize -/ -2 -] -- -expected -) -/ -expected -< -9E -- -5 -) -; -} -state -. -SetItemsProcessed -( -xsize -* -ysize -* -state -. -iterations -( -) -) -; -} -void -BM_GaussBlurSep7 -( -benchmark -: -: -State -& -state -) -{ -const -size_t -xsize -= -state -. -range -( -) -; -const -size_t -ysize -= -xsize -; -ImageF -in -( -xsize -ysize -) -; -const -float -expected -= -xsize -+ -ysize -; -FillImage -( -expected -& -in -) -; -ImageF -temp -( -xsize -ysize -) -; -ImageF -out -( -xsize -ysize -) -; -ThreadPool -* -null_pool -= -nullptr -; -const -WeightsSeparable7 -weights -= -{ -{ -HWY_REP4 -( -0 -. -383103f -) -HWY_REP4 -( -0 -. -241843f -) -HWY_REP4 -( -0 -. -060626f -) -HWY_REP4 -( -0 -. -00598f -) -} -{ -HWY_REP4 -( -0 -. -383103f -) -HWY_REP4 -( -0 -. -241843f -) -HWY_REP4 -( -0 -. -060626f -) -HWY_REP4 -( -0 -. -00598f -) -} -} -; -for -( -auto -_ -: -state -) -{ -Separable7 -( -in -Rect -( -in -) -weights -null_pool -& -out -) -; -JXL_ASSERT -( -std -: -: -abs -( -out -. -ConstRow -( -ysize -/ -2 -) -[ -xsize -/ -2 -] -- -expected -) -/ -expected -< -9E -- -5 -) -; -} -state -. -SetItemsProcessed -( -xsize -* -ysize -* -state -. -iterations -( -) -) -; -} -BENCHMARK -( -BM_GaussBlur1d -) -- -> -Range -( -1 -< -< -8 -1 -< -< -14 -) -; -BENCHMARK -( -BM_GaussBlur2d -) -- -> -Range -( -1 -< -< -7 -1 -< -< -10 -) -; -BENCHMARK -( -BM_GaussBlurFir -) -- -> -Range -( -1 -< -< -7 -1 -< -< -10 -) -; -BENCHMARK -( -BM_GaussBlurSep7 -) -- -> -Range -( -1 -< -< -7 -1 -< -< -10 -) -; -} -} diff --git a/third_party/jpeg-xl/lib/jxl/gauss_blur_test.cc b/third_party/jpeg-xl/lib/jxl/gauss_blur_test.cc deleted file mode 100644 index 0bb874cf71b4..000000000000 --- a/third_party/jpeg-xl/lib/jxl/gauss_blur_test.cc +++ /dev/null @@ -1,6182 +0,0 @@ -# -include -" -lib -/ -jxl -/ -gauss_blur -. -h -" -# -include -< -cmath -> -# -include -< -hwy -/ -targets -. -h -> -# -include -< -vector -> -# -include -" -lib -/ -extras -/ -time -. -h -" -# -include -" -lib -/ -jxl -/ -base -/ -printf_macros -. -h -" -# -include -" -lib -/ -jxl -/ -convolve -. -h -" -# -include -" -lib -/ -jxl -/ -image_ops -. -h -" -# -include -" -lib -/ -jxl -/ -image_test_utils -. -h -" -# -include -" -lib -/ -jxl -/ -testing -. -h -" -namespace -jxl -{ -bool -NearEdge -( -const -int64_t -width -const -int64_t -peak -) -{ -return -peak -< -10 -| -| -peak -> -width -- -10 -; -} -void -VerifySymmetric -( -const -int64_t -width -const -int64_t -peak -const -float -* -out -) -{ -const -double -tolerance -= -NearEdge -( -width -peak -) -? -0 -. -015 -: -6E -- -7 -; -for -( -int64_t -i -= -1 -; -; -+ -+ -i -) -{ -if -( -peak -- -i -< -0 -| -| -peak -+ -i -> -= -width -) -break -; -EXPECT_GT -( -out -[ -peak -+ -i -- -1 -] -+ -tolerance -out -[ -peak -+ -i -] -) -; -EXPECT_NEAR -( -out -[ -peak -- -i -] -out -[ -peak -+ -i -] -tolerance -) -; -} -} -void -TestImpulseResponse -( -size_t -width -size_t -peak -) -{ -const -auto -rg3 -= -CreateRecursiveGaussian -( -3 -. -0 -) -; -const -auto -rg4 -= -CreateRecursiveGaussian -( -4 -. -0 -) -; -const -auto -rg5 -= -CreateRecursiveGaussian -( -5 -. -0 -) -; -auto -in -= -hwy -: -: -AllocateAligned -< -float -> -( -width -+ -3 -) -; -memset -( -in -. -get -( -) -0 -sizeof -( -float -) -* -( -width -+ -3 -) -) -; -in -[ -peak -] -= -1 -. -0f -; -auto -out3 -= -hwy -: -: -AllocateAligned -< -float -> -( -width -+ -3 -) -; -auto -out4 -= -hwy -: -: -AllocateAligned -< -float -> -( -width -+ -3 -) -; -auto -out5 -= -hwy -: -: -AllocateAligned -< -float -> -( -width -+ -3 -) -; -FastGaussian1D -( -rg3 -in -. -get -( -) -width -out3 -. -get -( -) -) -; -FastGaussian1D -( -rg4 -out3 -. -get -( -) -width -out4 -. -get -( -) -) -; -FastGaussian1D -( -rg5 -in -. -get -( -) -width -out5 -. -get -( -) -) -; -VerifySymmetric -( -width -peak -out3 -. -get -( -) -) -; -VerifySymmetric -( -width -peak -out4 -. -get -( -) -) -; -VerifySymmetric -( -width -peak -out5 -. -get -( -) -) -; -EXPECT_LT -( -out5 -[ -peak -] -+ -0 -. -05 -out3 -[ -peak -] -) -; -const -double -tolerance -= -NearEdge -( -width -peak -) -? -0 -. -04 -: -0 -. -01 -; -for -( -size_t -i -= -0 -; -i -< -width -; -+ -+ -i -) -{ -EXPECT_NEAR -( -out4 -[ -i -] -out5 -[ -i -] -tolerance -) -; -} -} -void -TestImpulseResponseForWidth -( -size_t -width -) -{ -for -( -size_t -i -= -0 -; -i -< -width -; -+ -+ -i -) -{ -TestImpulseResponse -( -width -i -) -; -} -} -TEST -( -GaussBlurTest -ImpulseResponse -) -{ -TestImpulseResponseForWidth -( -10 -) -; -TestImpulseResponseForWidth -( -15 -) -; -TestImpulseResponseForWidth -( -32 -) -; -TestImpulseResponseForWidth -( -31 -) -; -TestImpulseResponseForWidth -( -33 -) -; -} -ImageF -Convolve -( -const -ImageF -& -in -const -std -: -: -vector -< -float -> -& -kernel -) -{ -return -ConvolveAndSample -( -in -kernel -1 -) -; -} -ImageF -ConvolveAndTransposeF64 -( -const -ImageF -& -in -const -std -: -: -vector -< -double -> -& -kernel -) -{ -JXL_ASSERT -( -kernel -. -size -( -) -% -2 -= -= -1 -) -; -ImageF -out -( -in -. -ysize -( -) -in -. -xsize -( -) -) -; -const -int -r -= -kernel -. -size -( -) -/ -2 -; -std -: -: -vector -< -float -> -row_tmp -( -in -. -xsize -( -) -+ -2 -* -r -) -; -float -* -const -JXL_RESTRICT -rowp -= -& -row_tmp -[ -r -] -; -const -double -* -const -kernelp -= -& -kernel -[ -r -] -; -for -( -size_t -y -= -0 -; -y -< -in -. -ysize -( -) -; -+ -+ -y -) -{ -ExtrapolateBorders -( -in -. -Row -( -y -) -rowp -in -. -xsize -( -) -r -) -; -for -( -size_t -x -= -0 -ox -= -0 -; -x -< -in -. -xsize -( -) -; -+ -+ -x -+ -+ -ox -) -{ -double -sum -= -0 -. -0 -; -for -( -int -i -= -- -r -; -i -< -= -r -; -+ -+ -i -) -{ -sum -+ -= -rowp -[ -std -: -: -max -< -int -> -( -0 -std -: -: -min -< -int -> -( -static_cast -< -int -> -( -x -) -+ -i -in -. -xsize -( -) -) -) -] -* -kernelp -[ -i -] -; -} -out -. -Row -( -ox -) -[ -y -] -= -static_cast -< -float -> -( -sum -) -; -} -} -return -out -; -} -ImageF -ConvolveF64 -( -const -ImageF -& -in -const -std -: -: -vector -< -double -> -& -kernel -) -{ -ImageF -tmp -= -ConvolveAndTransposeF64 -( -in -kernel -) -; -return -ConvolveAndTransposeF64 -( -tmp -kernel -) -; -} -void -TestDirac2D -( -size_t -xsize -size_t -ysize -double -sigma -) -{ -ImageF -in -( -xsize -ysize -) -; -ZeroFillImage -( -& -in -) -; -in -. -Row -( -ysize -/ -2 -) -[ -xsize -/ -2 -] -= -1 -. -0f -; -ImageF -temp -( -xsize -ysize -) -; -ImageF -out -( -xsize -ysize -) -; -const -auto -rg -= -CreateRecursiveGaussian -( -sigma -) -; -ThreadPool -* -null_pool -= -nullptr -; -FastGaussian -( -rg -in -null_pool -& -temp -& -out -) -; -const -std -: -: -vector -< -float -> -kernel -= -GaussianKernel -( -static_cast -< -int -> -( -4 -* -sigma -) -static_cast -< -float -> -( -sigma -) -) -; -const -ImageF -expected -= -Convolve -( -in -kernel -) -; -const -double -max_l1 -= -sigma -< -1 -. -5 -? -5E -- -3 -: -6E -- -4 -; -const -size_t -border -= -2 -* -sigma -; -JXL_ASSERT_OK -( -VerifyRelativeError -( -expected -out -max_l1 -1E -- -8 -_ -border -) -) -; -} -TEST -( -GaussBlurTest -Test2D -) -{ -const -std -: -: -vector -< -int -> -dimensions -{ -6 -15 -17 -64 -50 -49 -} -; -for -( -int -xsize -: -dimensions -) -{ -for -( -int -ysize -: -dimensions -) -{ -for -( -double -sigma -: -{ -1 -. -0 -2 -. -5 -3 -. -6 -7 -. -0 -} -) -{ -TestDirac2D -( -static_cast -< -size_t -> -( -xsize -) -static_cast -< -size_t -> -( -ysize -) -sigma -) -; -} -} -} -} -TEST -( -GaussBlurTest -DISABLED_SlowTestDirac1D -) -{ -const -double -sigma -= -7 -. -0 -; -const -auto -rg -= -CreateRecursiveGaussian -( -sigma -) -; -const -size_t -radius -= -static_cast -< -size_t -> -( -7 -* -sigma -) -; -const -std -: -: -vector -< -double -> -kernel -= -GaussianKernel -( -radius -sigma -) -; -const -size_t -length -= -16384 -; -ImageF -inputs -( -length -1 -) -; -ZeroFillImage -( -& -inputs -) -; -auto -outputs -= -hwy -: -: -AllocateAligned -< -float -> -( -length -) -; -auto -sum_abs_err -= -hwy -: -: -AllocateAligned -< -double -> -( -length -) -; -std -: -: -fill -( -sum_abs_err -. -get -( -) -sum_abs_err -. -get -( -) -+ -length -0 -. -0 -) -; -for -( -size_t -center -= -radius -; -center -< -length -- -radius -; -+ -+ -center -) -{ -inputs -. -Row -( -0 -) -[ -center -- -1 -] -= -0 -. -0f -; -inputs -. -Row -( -0 -) -[ -center -] -= -1 -. -0f -; -FastGaussian1D -( -rg -inputs -. -Row -( -0 -) -length -outputs -. -get -( -) -) -; -const -ImageF -outputs_fir -= -ConvolveF64 -( -inputs -kernel -) -; -for -( -size_t -i -= -0 -; -i -< -length -; -+ -+ -i -) -{ -const -float -abs_err -= -std -: -: -abs -( -outputs -[ -i -] -- -outputs_fir -. -Row -( -0 -) -[ -i -] -) -; -sum_abs_err -[ -i -] -+ -= -static_cast -< -double -> -( -abs_err -) -; -} -} -const -double -max_abs_err -= -* -std -: -: -max_element -( -sum_abs_err -. -get -( -) -sum_abs_err -. -get -( -) -+ -length -) -; -printf -( -" -Max -abs -err -: -% -. -8e -\ -n -" -max_abs_err -) -; -} -void -TestRandom -( -size_t -xsize -size_t -ysize -float -min -float -max -double -sigma -double -max_l1 -double -max_rel -) -{ -printf -( -" -% -4 -" -PRIuS -" -x -% -4 -" -PRIuS -" -% -4 -. -1f -% -4 -. -1f -sigma -% -. -1f -\ -n -" -xsize -ysize -min -max -sigma -) -; -ImageF -in -( -xsize -ysize -) -; -RandomFillImage -( -& -in -min -max -65537 -+ -xsize -* -129 -+ -ysize -) -; -const -size_t -border -= -4 -* -sigma -; -SetBorder -( -border -0 -. -0f -& -in -) -; -ImageF -temp -( -xsize -ysize -) -; -ImageF -out -( -xsize -ysize -) -; -const -auto -rg -= -CreateRecursiveGaussian -( -sigma -) -; -ThreadPool -* -null_pool -= -nullptr -; -FastGaussian -( -rg -in -null_pool -& -temp -& -out -) -; -const -std -: -: -vector -< -float -> -kernel -= -GaussianKernel -( -static_cast -< -int -> -( -4 -* -sigma -) -static_cast -< -float -> -( -sigma -) -) -; -const -ImageF -expected -= -Convolve -( -in -kernel -) -; -JXL_ASSERT_OK -( -VerifyRelativeError -( -expected -out -max_l1 -max_rel -_ -border -) -) -; -} -void -TestRandomForSizes -( -float -min -float -max -double -sigma -) -{ -double -max_l1 -= -6E -- -3 -; -double -max_rel -= -3E -- -3 -; -TestRandom -( -128 -1 -min -max -sigma -max_l1 -max_rel -) -; -TestRandom -( -1 -128 -min -max -sigma -max_l1 -max_rel -) -; -TestRandom -( -30 -201 -min -max -sigma -max_l1 -* -1 -. -6 -max_rel -* -1 -. -2 -) -; -TestRandom -( -201 -30 -min -max -sigma -max_l1 -* -1 -. -6 -max_rel -* -1 -. -2 -) -; -TestRandom -( -201 -201 -min -max -sigma -max_l1 -* -2 -. -0 -max_rel -* -1 -. -2 -) -; -} -TEST -( -GaussBlurTest -TestRandom -) -{ -TestRandomForSizes -( -0 -. -0f -10 -. -0f -3 -. -0f -) -; -TestRandomForSizes -( -0 -. -0f -10 -. -0f -7 -. -0f -) -; -TestRandomForSizes -( -- -4 -. -0f -- -1 -. -0f -3 -. -0f -) -; -TestRandomForSizes -( -- -4 -. -0f -- -1 -. -0f -7 -. -0f -) -; -TestRandomForSizes -( -- -6 -. -0f -6 -. -0f -3 -. -0f -) -; -TestRandomForSizes -( -- -6 -. -0f -6 -. -0f -7 -. -0f -) -; -} -TEST -( -GaussBlurTest -TestSign -) -{ -const -size_t -xsize -= -500 -; -const -size_t -ysize -= -606 -; -ImageF -in -( -xsize -ysize -) -; -ZeroFillImage -( -& -in -) -; -const -float -center -[ -33 -* -33 -] -= -{ -- -0 -. -128445f -- -0 -. -098473f -- -0 -. -121883f -- -0 -. -093601f -0 -. -095665f -- -0 -. -271332f -- -0 -. -705475f -- -1 -. -324005f -- -2 -. -020741f -- -1 -. -329464f -1 -. -834064f -4 -. -787300f -5 -. -834560f -5 -. -272720f -3 -. -967960f -3 -. -547935f -3 -. -432732f -3 -. -383015f -3 -. -239326f -3 -. -290806f -3 -. -298954f -3 -. -397808f -3 -. -359730f -3 -. -533844f -3 -. -511856f -3 -. -436787f -3 -. -428310f -3 -. -460209f -3 -. -550011f -3 -. -590942f -3 -. -593109f -3 -. -560005f -3 -. -443165f -0 -. -089741f -0 -. -179230f -- -0 -. -032997f -- -0 -. -182610f -0 -. -005669f -- -0 -. -244759f -- -0 -. -395123f -- -0 -. -514961f -- -1 -. -003529f -- -1 -. -798656f -- -2 -. -377975f -0 -. -222191f -3 -. -957664f -5 -. -946804f -5 -. -543129f -4 -. -290096f -3 -. -621010f -3 -. -407257f -3 -. -392494f -3 -. -345367f -3 -. -391903f -3 -. -441605f -3 -. -429260f -3 -. -444969f -3 -. -507130f -3 -. -518612f -3 -. -443111f -3 -. -475948f -3 -. -536148f -3 -. -470333f -3 -. -628311f -3 -. -600243f -3 -. -292892f -- -0 -. -226730f -- -0 -. -573616f -- -0 -. -762165f -- -0 -. -398739f -- -0 -. -189842f -- -0 -. -275921f -- -0 -. -446739f -- -0 -. -550037f -- -0 -. -461033f -- -0 -. -724792f -- -1 -. -448349f -- -1 -. -814064f -- -0 -. -491032f -2 -. -817703f -5 -. -213242f -5 -. -675629f -4 -. -864548f -3 -. -876324f -3 -. -535587f -3 -. -530312f -3 -. -413765f -3 -. -386261f -3 -. -404854f -3 -. -383472f -3 -. -420830f -3 -. -326496f -3 -. -257877f -3 -. -362152f -3 -. -489609f -3 -. -619587f -3 -. -555805f -3 -. -423164f -3 -. -309708f -- -0 -. -483940f -- -0 -. -502926f -- -0 -. -592983f -- -0 -. -492527f -- -0 -. -413616f -- -0 -. -482555f -- -0 -. -475506f -- -0 -. -447990f -- -0 -. -338120f -- -0 -. -189072f -- -0 -. -376427f -- -0 -. -910828f -- -1 -. -878044f -- -1 -. -937927f -1 -. -423218f -4 -. -871609f -5 -. -767548f -5 -. -103741f -3 -. -983868f -3 -. -633003f -3 -. -458263f -3 -. -507309f -3 -. -247021f -3 -. -220612f -3 -. -326061f -3 -. -352814f -3 -. -291061f -3 -. -322739f -3 -. -444302f -3 -. -506207f -3 -. -556839f -3 -. -529575f -3 -. -457024f -- -0 -. -408161f -- -0 -. -431343f -- -0 -. -454369f -- -0 -. -356419f -- -0 -. -380924f -- -0 -. -399452f -- -0 -. -439476f -- -0 -. -412189f -- -0 -. -306816f -- -0 -. -008213f -- -0 -. -325813f -- -0 -. -537842f -- -0 -. -984100f -- -1 -. -805332f -- -2 -. -028198f -0 -. -773205f -4 -. -423046f -5 -. -604839f -5 -. -231617f -4 -. -080299f -3 -. -603008f -3 -. -498741f -3 -. -517010f -3 -. -333897f -3 -. -381336f -3 -. -342617f -3 -. -369686f -3 -. -434155f -3 -. -490452f -3 -. -607029f -3 -. -555298f -3 -. -702297f -3 -. -618679f -- -0 -. -503609f -- -0 -. -578564f -- -0 -. -419014f -- -0 -. -239883f -0 -. -269836f -0 -. -022984f -- -0 -. -455067f -- -0 -. -621777f -- -0 -. -304176f -- -0 -. -163792f -- -0 -. -490250f -- -0 -. -466637f -- -0 -. -391792f -- -0 -. -657940f -- -1 -. -498035f -- -1 -. -895836f -0 -. -036537f -3 -. -462456f -5 -. -586445f -5 -. -658791f -4 -. -434784f -3 -. -423435f -3 -. -318848f -3 -. -202328f -3 -. -532764f -3 -. -436687f -3 -. -354881f -3 -. -356941f -3 -. -382645f -3 -. -503902f -3 -. -512867f -3 -. -632366f -3 -. -537312f -- -0 -. -274734f -- -0 -. -658829f -- -0 -. -726532f -- -0 -. -281254f -0 -. -053196f -- -0 -. -064991f -- -0 -. -608517f -- -0 -. -720966f -- -0 -. -070602f -- -0 -. -111320f -- -0 -. -440956f -- -0 -. -492180f -- -0 -. -488762f -- -0 -. -569283f -- -1 -. -012741f -- -1 -. -582779f -- -2 -. -101479f -- -1 -. -392380f -2 -. -451153f -5 -. -555855f -6 -. -096313f -5 -. -230045f -4 -. -068172f -3 -. -404274f -3 -. -392586f -3 -. -326065f -3 -. -156670f -3 -. -284828f -3 -. -347012f -3 -. -319252f -3 -. -352310f -3 -. -610790f -3 -. -499847f -- -0 -. -150600f -- -0 -. -314445f -- -0 -. -093575f -- -0 -. -057384f -0 -. -053688f -- -0 -. -189255f -- -0 -. -263515f -- -0 -. -318653f -0 -. -053246f -0 -. -080627f -- -0 -. -119553f -- -0 -. -152454f -- -0 -. -305420f -- -0 -. -404869f -- -0 -. -385944f -- -0 -. -689949f -- -1 -. -204914f -- -1 -. -985748f -- -1 -. -711361f -1 -. -260658f -4 -. -626896f -5 -. -888351f -5 -. -450989f -4 -. -070587f -3 -. -539200f -3 -. -383492f -3 -. -296318f -3 -. -267334f -3 -. -436028f -3 -. -463005f -3 -. -502625f -3 -. -522282f -3 -. -403763f -- -0 -. -348049f -- -0 -. -302303f -- -0 -. -137016f -- -0 -. -041737f -- -0 -. -164001f -- -0 -. -358849f -- -0 -. -469627f -- -0 -. -428291f -- -0 -. -375797f -- -0 -. -246346f -- -0 -. -118950f -- -0 -. -084229f -- -0 -. -205681f -- -0 -. -241199f -- -0 -. -391796f -- -0 -. -323151f -- -0 -. -241211f -- -0 -. -834137f -- -1 -. -684219f -- -1 -. -972137f -0 -. -448399f -4 -. -019985f -5 -. -648144f -5 -. -647846f -4 -. -295094f -3 -. -641884f -3 -. -374790f -3 -. -197342f -3 -. -425545f -3 -. -507481f -3 -. -478065f -3 -. -430889f -3 -. -341900f -- -1 -. -016304f -- -0 -. -959221f -- -0 -. -909466f -- -0 -. -810715f -- -0 -. -590729f -- -0 -. -594467f -- -0 -. -646721f -- -0 -. -629364f -- -0 -. -528561f -- -0 -. -551819f -- -0 -. -301086f -- -0 -. -149101f -- -0 -. -060146f -- -0 -. -162220f -- -0 -. -326210f -- -0 -. -156548f -- -0 -. -036293f -- -0 -. -426098f -- -1 -. -145470f -- -1 -. -628998f -- -2 -. -003052f -- -1 -. -142891f -2 -. -885162f -5 -. -652863f -5 -. -718426f -4 -. -911140f -3 -. -234222f -3 -. -473373f -3 -. -577183f -3 -. -271603f -3 -. -410435f -3 -. -505489f -3 -. -434032f -- -0 -. -508911f -- -0 -. -438797f -- -0 -. -437450f -- -0 -. -627426f -- -0 -. -511745f -- -0 -. -304874f -- -0 -. -274246f -- -0 -. -261841f -- -0 -. -228466f -- -0 -. -342491f -- -0 -. -528206f -- -0 -. -490082f -- -0 -. -516350f -- -0 -. -361694f -- -0 -. -398514f -- -0 -. -276020f -- -0 -. -210369f -- -0 -. -355938f -- -0 -. -402622f -- -0 -. -538864f -- -1 -. -249573f -- -2 -. -100105f -- -0 -. -996178f -1 -. -886410f -4 -. -929745f -5 -. -630871f -5 -. -444199f -4 -. -042740f -3 -. -739189f -3 -. -691399f -3 -. -391956f -3 -. -469696f -3 -. -431232f -0 -. -204849f -0 -. -205433f -- -0 -. -131927f -- -0 -. -367908f -- -0 -. -374378f -- -0 -. -126820f -- -0 -. -186951f -- -0 -. -228565f -- -0 -. -081776f -- -0 -. -143143f -- -0 -. -379230f -- -0 -. -598701f -- -0 -. -458019f -- -0 -. -295586f -- -0 -. -407730f -- -0 -. -245853f -- -0 -. -043140f -0 -. -024242f -- -0 -. -038998f -- -0 -. -044151f -- -0 -. -425991f -- -1 -. -240753f -- -1 -. -943146f -- -2 -. -174755f -0 -. -523415f -4 -. -376751f -5 -. -956558f -5 -. -850082f -4 -. -403152f -3 -. -517399f -3 -. -560753f -3 -. -554836f -3 -. -471985f -- -0 -. -508503f -- -0 -. -109783f -0 -. -057747f -0 -. -190079f -- -0 -. -257153f -- -0 -. -591980f -- -0 -. -666771f -- -0 -. -525391f -- -0 -. -293060f -- -0 -. -489731f -- -0 -. -304855f -- -0 -. -259644f -- -0 -. -367825f -- -0 -. -346977f -- -0 -. -292889f -- -0 -. -215652f -- -0 -. -120705f -- -0 -. -176010f -- -0 -. -422905f -- -0 -. -114647f -- -0 -. -289749f -- -0 -. -374203f -- -0 -. -606754f -- -1 -. -127949f -- -1 -. -994583f -- -0 -. -588058f -3 -. -415840f -5 -. -603470f -5 -. -811581f -4 -. -959423f -3 -. -721760f -3 -. -710499f -3 -. -785461f -- -0 -. -554588f -- -0 -. -565517f -- -0 -. -434578f -- -0 -. -012482f -- -0 -. -284660f -- -0 -. -699795f -- -0 -. -957535f -- -0 -. -755135f -- -0 -. -382034f -- -0 -. -321552f -- -0 -. -287571f -- -0 -. -279537f -- -0 -. -314972f -- -0 -. -256287f -- -0 -. -372818f -- -0 -. -316017f -- -0 -. -287975f -- -0 -. -365639f -- -0 -. -512589f -- -0 -. -420692f -- -0 -. -436485f -- -0 -. -295353f -- -0 -. -451958f -- -0 -. -755459f -- -1 -. -272358f -- -2 -. -301353f -- -1 -. -776161f -1 -. -572483f -4 -. -826286f -5 -. -741898f -5 -. -162853f -4 -. -028049f -3 -. -686325f -- -0 -. -495590f -- -0 -. -664413f -- -0 -. -760044f -- -0 -. -152634f -- -0 -. -286480f -- -0 -. -340462f -0 -. -076477f -0 -. -187706f -- -0 -. -068787f -- -0 -. -293491f -- -0 -. -361145f -- -0 -. -292515f -- -0 -. -140671f -- -0 -. -190723f -- -0 -. -333302f -- -0 -. -368168f -- -0 -. -192581f -- -0 -. -154499f -- -0 -. -236544f -- -0 -. -124405f -- -0 -. -208321f -- -0 -. -465607f -- -0 -. -883080f -- -1 -. -104813f -- -1 -. -210567f -- -1 -. -415665f -- -1 -. -924683f -- -1 -. -634758f -0 -. -601017f -4 -. -276672f -5 -. -501350f -5 -. -331257f -3 -. -809288f -- -0 -. -727722f -- -0 -. -533619f -- -0 -. -511524f -- -0 -. -470688f -- -0 -. -610710f -- -0 -. -575130f -- -0 -. -311115f -- -0 -. -090420f -- -0 -. -297676f -- -0 -. -646118f -- -0 -. -742805f -- -0 -. -485050f -- -0 -. -330910f -- -0 -. -275417f -- -0 -. -357037f -- -0 -. -425598f -- -0 -. -481876f -- -0 -. -488941f -- -0 -. -393551f -- -0 -. -051105f -- -0 -. -090755f -- -0 -. -328674f -- -0 -. -536369f -- -0 -. -533684f -- -0 -. -336960f -- -0 -. -689194f -- -1 -. -187195f -- -1 -. -860954f -- -2 -. -290253f -- -0 -. -424774f -3 -. -050060f -5 -. -083332f -5 -. -291920f -- -0 -. -343605f -- -0 -. -190975f -- -0 -. -303692f -- -0 -. -456512f -- -0 -. -681820f -- -0 -. -690693f -- -0 -. -416729f -- -0 -. -286446f -- -0 -. -442055f -- -0 -. -709148f -- -0 -. -569160f -- -0 -. -382423f -- -0 -. -402321f -- -0 -. -383362f -- -0 -. -366413f -- -0 -. -290718f -- -0 -. -110069f -- -0 -. -220280f -- -0 -. -279018f -- -0 -. -255424f -- -0 -. -262081f -- -0 -. -487556f -- -0 -. -444492f -- -0 -. -250500f -- -0 -. -119583f -- -0 -. -291557f -- -0 -. -537781f -- -1 -. -104073f -- -1 -. -737091f -- -1 -. -697441f -- -0 -. -323456f -2 -. -042049f -4 -. -605103f -- -0 -. -310631f -- -0 -. -279568f -- -0 -. -012695f -- -0 -. -160130f -- -0 -. -358746f -- -0 -. -421101f -- -0 -. -559677f -- -0 -. -474136f -- -0 -. -416565f -- -0 -. -561817f -- -0 -. -534672f -- -0 -. -519157f -- -0 -. -767197f -- -0 -. -605831f -- -0 -. -186523f -0 -. -219872f -0 -. -264984f -- -0 -. -193432f -- -0 -. -363182f -- -0 -. -467472f -- -0 -. -462009f -- -0 -. -571053f -- -0 -. -522476f -- -0 -. -315903f -- -0 -. -237427f -- -0 -. -147320f -- -0 -. -100201f -- -0 -. -237568f -- -0 -. -763435f -- -1 -. -242043f -- -2 -. -135159f -- -1 -. -409485f -1 -. -236370f -- -0 -. -474247f -- -0 -. -517906f -- -0 -. -410217f -- -0 -. -542244f -- -0 -. -795986f -- -0 -. -590004f -- -0 -. -388863f -- -0 -. -462921f -- -0 -. -810627f -- -0 -. -778637f -- -0 -. -512486f -- -0 -. -718025f -- -0 -. -710854f -- -0 -. -482513f -- -0 -. -318233f -- -0 -. -194962f -- -0 -. -220116f -- -0 -. -421673f -- -0 -. -534233f -- -0 -. -403339f -- -0 -. -389332f -- -0 -. -407303f -- -0 -. -437355f -- -0 -. -469730f -- -0 -. -359600f -- -0 -. -352745f -- -0 -. -466755f -- -0 -. -414585f -- -0 -. -430756f -- -0 -. -656822f -- -1 -. -237038f -- -2 -. -046097f -- -1 -. -574898f -- -0 -. -593815f -- -0 -. -582165f -- -0 -. -336098f -- -0 -. -372612f -- -0 -. -554386f -- -0 -. -410603f -- -0 -. -428276f -- -0 -. -647644f -- -0 -. -640720f -- -0 -. -582207f -- -0 -. -414112f -- -0 -. -435547f -- -0 -. -435505f -- -0 -. -332561f -- -0 -. -248116f -- -0 -. -340221f -- -0 -. -277855f -- -0 -. -352699f -- -0 -. -377319f -- -0 -. -230850f -- -0 -. -313267f -- -0 -. -446270f -- -0 -. -346237f -- -0 -. -420422f -- -0 -. -530781f -- -0 -. -400341f -- -0 -. -463661f -- -0 -. -209091f -- -0 -. -056705f -- -0 -. -011772f -- -0 -. -169388f -- -0 -. -736275f -- -1 -. -463017f -- -0 -. -752701f -- -0 -. -668865f -- -0 -. -329765f -- -0 -. -299347f -- -0 -. -245667f -- -0 -. -286999f -- -0 -. -520420f -- -0 -. -675438f -- -0 -. -255753f -0 -. -141357f -- -0 -. -079639f -- -0 -. -419476f -- -0 -. -374069f -- -0 -. -046253f -0 -. -116116f -- -0 -. -145847f -- -0 -. -380371f -- -0 -. -563412f -- -0 -. -638634f -- -0 -. -310116f -- -0 -. -260914f -- -0 -. -508404f -- -0 -. -465508f -- -0 -. -527824f -- -0 -. -370979f -- -0 -. -305595f -- -0 -. -244694f -- -0 -. -254490f -0 -. -009968f -- -0 -. -050201f -- -0 -. -331219f -- -0 -. -614960f -- -0 -. -788208f -- -0 -. -483242f -- -0 -. -367516f -- -0 -. -186951f -- -0 -. -180031f -0 -. -129711f -- -0 -. -127811f -- -0 -. -384750f -- -0 -. -499542f -- -0 -. -418613f -- -0 -. -121635f -0 -. -203197f -- -0 -. -167290f -- -0 -. -397270f -- -0 -. -355461f -- -0 -. -218746f -- -0 -. -376785f -- -0 -. -521698f -- -0 -. -721581f -- -0 -. -845741f -- -0 -. -535439f -- -0 -. -220882f -- -0 -. -309067f -- -0 -. -555248f -- -0 -. -690342f -- -0 -. -664948f -- -0 -. -390102f -0 -. -020355f -- -0 -. -130447f -- -0 -. -173252f -- -0 -. -170059f -- -0 -. -633663f -- -0 -. -956001f -- -0 -. -621696f -- -0 -. -388302f -- -0 -. -342262f -- -0 -. -244370f -- -0 -. -386948f -- -0 -. -401421f -- -0 -. -172979f -- -0 -. -206163f -- -0 -. -450058f -- -0 -. -525789f -- -0 -. -549274f -- -0 -. -349251f -- -0 -. -474613f -- -0 -. -667976f -- -0 -. -435600f -- -0 -. -175369f -- -0 -. -196877f -- -0 -. -202976f -- -0 -. -242481f -- -0 -. -258369f -- -0 -. -189133f -- -0 -. -395397f -- -0 -. -765499f -- -0 -. -944016f -- -0 -. -850967f -- -0 -. -631561f -- -0 -. -152493f -- -0 -. -046432f -- -0 -. -262066f -- -0 -. -195919f -0 -. -048218f -0 -. -084972f -0 -. -039902f -0 -. -000618f -- -0 -. -404430f -- -0 -. -447456f -- -0 -. -418076f -- -0 -. -631935f -- -0 -. -717415f -- -0 -. -502888f -- -0 -. -530514f -- -0 -. -747826f -- -0 -. -704041f -- -0 -. -674969f -- -0 -. -516853f -- -0 -. -418446f -- -0 -. -327740f -- -0 -. -308815f -- -0 -. -481636f -- -0 -. -440083f -- -0 -. -481720f -- -0 -. -341053f -- -0 -. -283897f -- -0 -. -324368f -- -0 -. -352829f -- -0 -. -434349f -- -0 -. -545589f -- -0 -. -533104f -- -0 -. -472755f -- -0 -. -570496f -- -0 -. -557735f -- -0 -. -708176f -- -0 -. -493332f -- -0 -. -194416f -- -0 -. -186249f -- -0 -. -256710f -- -0 -. -271835f -- -0 -. -304752f -- -0 -. -431267f -- -0 -. -422398f -- -0 -. -646725f -- -0 -. -680801f -- -0 -. -249031f -- -0 -. -058567f -- -0 -. -213890f -- -0 -. -383949f -- -0 -. -540291f -- -0 -. -549877f -- -0 -. -225567f -- -0 -. -037174f -- -0 -. -499874f -- -0 -. -641010f -- -0 -. -628044f -- -0 -. -390549f -- -0 -. -311497f -- -0 -. -542313f -- -0 -. -569565f -- -0 -. -473408f -- -0 -. -331245f -- -0 -. -357197f -- -0 -. -285599f -- -0 -. -200157f -- -0 -. -201866f -- -0 -. -124428f -- -0 -. -346016f -- -0 -. -392311f -- -0 -. -264496f -- -0 -. -285370f -- -0 -. -436974f -- -0 -. -523483f -- -0 -. -410461f -- -0 -. -267925f -- -0 -. -055016f -- -0 -. -382458f -- -0 -. -319771f -- -0 -. -049927f -0 -. -124329f -0 -. -266102f -- -0 -. -106606f -- -0 -. -773647f -- -0 -. -973053f -- -0 -. -708206f -- -0 -. -486137f -- -0 -. -319923f -- -0 -. -493900f -- -0 -. -490860f -- -0 -. -324986f -- -0 -. -147346f -- -0 -. -146088f -- -0 -. -161758f -- -0 -. -084396f -- -0 -. -379494f -0 -. -041626f -- -0 -. -113361f -- -0 -. -277767f -0 -. -083366f -0 -. -126476f -0 -. -139057f -0 -. -038040f -0 -. -038162f -- -0 -. -242126f -- -0 -. -411736f -- -0 -. -370049f -- -0 -. -455357f -- -0 -. -039257f -0 -. -264442f -- -0 -. -271492f -- -0 -. -425346f -- -0 -. -514847f -- -0 -. -448650f -- -0 -. -580399f -- -0 -. -652603f -- -0 -. -774803f -- -0 -. -692524f -- -0 -. -579578f -- -0 -. -465206f -- -0 -. -386265f -- -0 -. -458012f -- -0 -. -446594f -- -0 -. -284893f -- -0 -. -345448f -- -0 -. -350876f -- -0 -. -440350f -- -0 -. -360378f -- -0 -. -270428f -0 -. -237213f -- -0 -. -063602f -- -0 -. -364529f -- -0 -. -179867f -0 -. -078197f -0 -. -117947f -- -0 -. -093410f -- -0 -. -359119f -- -0 -. -480961f -- -0 -. -540638f -- -0 -. -436287f -- -0 -. -598576f -- -0 -. -253735f -- -0 -. -060093f -- -0 -. -549145f -- -0 -. -808327f -- -0 -. -698593f -- -0 -. -595764f -- -0 -. -582508f -- -0 -. -497353f -- -0 -. -480892f -- -0 -. -584240f -- -0 -. -665791f -- -0 -. -690903f -- -0 -. -743446f -- -0 -. -796677f -- -0 -. -782391f -- -0 -. -649010f -- -0 -. -628139f -- -0 -. -880848f -- -0 -. -829361f -- -0 -. -373272f -- -0 -. -223667f -0 -. -174572f -- -0 -. -348743f -- -0 -. -798901f -- -0 -. -692307f -- -0 -. -607609f -- -0 -. -401455f -- -0 -. -480919f -- -0 -. -450798f -- -0 -. -435413f -- -0 -. -322338f -- -0 -. -228382f -- -0 -. -450466f -- -0 -. -504440f -- -0 -. -477402f -- -0 -. -662224f -- -0 -. -583397f -- -0 -. -217445f -- -0 -. -157459f -- -0 -. -079584f -- -0 -. -226168f -- -0 -. -488720f -- -0 -. -669624f -- -0 -. -666878f -- -0 -. -565311f -- -0 -. -549625f -- -0 -. -364601f -- -0 -. -497627f -- -0 -. -736897f -- -0 -. -763023f -- -0 -. -741020f -- -0 -. -404503f -0 -. -184814f -- -0 -. -075315f -- -0 -. -281513f -- -0 -. -532906f -- -0 -. -405800f -- -0 -. -313438f -- -0 -. -536652f -- -0 -. -403381f -0 -. -011967f -0 -. -103310f -- -0 -. -269848f -- -0 -. -508656f -- -0 -. -445923f -- -0 -. -644859f -- -0 -. -617870f -- -0 -. -500927f -- -0 -. -371559f -- -0 -. -125580f -0 -. -028625f -- -0 -. -154713f -- -0 -. -442024f -- -0 -. -492764f -- -0 -. -199371f -0 -. -236305f -0 -. -225925f -0 -. -075577f -- -0 -. -285812f -- -0 -. -437145f -- -0 -. -374260f -- -0 -. -156693f -- -0 -. -129635f -- -0 -. -243206f -- -0 -. -123058f -0 -. -162148f -- -0 -. -313152f -- -0 -. -337982f -- -0 -. -358421f -0 -. -040070f -0 -. -038925f -- -0 -. -333313f -- -0 -. -351662f -0 -. -023014f -0 -. -091362f -- -0 -. -282890f -- -0 -. -373253f -- -0 -. -389050f -- -0 -. -532707f -- -0 -. -423347f -- -0 -. -349968f -- -0 -. -287045f -- -0 -. -202442f -- -0 -. -308430f -- -0 -. -222801f -- -0 -. -106323f -- -0 -. -056358f -0 -. -027222f -0 -. -390732f -0 -. -033558f -- -0 -. -160088f -- -0 -. -382217f -- -0 -. -535282f -- -0 -. -515900f -- -0 -. -022736f -0 -. -165665f -- -0 -. -111408f -- -0 -. -233784f -- -0 -. -312357f -- -0 -. -541885f -- -0 -. -480022f -- -0 -. -482513f -- -0 -. -246254f -0 -. -132244f -0 -. -090134f -0 -. -234634f -- -0 -. -089249f -- -0 -. -460854f -- -0 -. -515457f -- -0 -. -450874f -- -0 -. -311031f -- -0 -. -387680f -- -0 -. -360554f -- -0 -. -179241f -- -0 -. -283817f -- -0 -. -475815f -- -0 -. -246399f -- -0 -. -388958f -- -0 -. -551140f -- -0 -. -496239f -- -0 -. -559879f -- -0 -. -379761f -- -0 -. -254288f -- -0 -. -395111f -- -0 -. -613018f -- -0 -. -459427f -- -0 -. -263580f -- -0 -. -268929f -0 -. -080826f -0 -. -115616f -- -0 -. -097324f -- -0 -. -325310f -- -0 -. -480450f -- -0 -. -313286f -- -0 -. -310371f -- -0 -. -517361f -- -0 -. -288288f -- -0 -. -112679f -- -0 -. -173241f -- -0 -. -221664f -- -0 -. -039452f -- -0 -. -107578f -- -0 -. -089630f -- -0 -. -483768f -- -0 -. -571087f -- -0 -. -497108f -- -0 -. -321533f -- -0 -. -375492f -- -0 -. -540363f -- -0 -. -406815f -- -0 -. -388512f -- -0 -. -514561f -- -0 -. -540192f -- -0 -. -402412f -- -0 -. -232246f -- -0 -. -304749f -- -0 -. -383724f -- -0 -. -679596f -- -0 -. -685463f -- -0 -. -694538f -- -0 -. -642937f -- -0 -. -425789f -0 -. -103271f -- -0 -. -194862f -- -0 -. -487999f -- -0 -. -717281f -- -0 -. -681850f -- -0 -. -709286f -- -0 -. -615398f -- -0 -. -554245f -- -0 -. -254681f -- -0 -. -049950f -- -0 -. -002914f -- -0 -. -095383f -- -0 -. -370911f -- -0 -. -564224f -- -0 -. -242714f -} -; -const -size_t -xtest -= -xsize -/ -2 -; -const -size_t -ytest -= -ysize -/ -2 -; -for -( -intptr_t -dy -= -- -16 -; -dy -< -= -16 -; -+ -+ -dy -) -{ -float -* -row -= -in -. -Row -( -ytest -+ -dy -) -; -for -( -intptr_t -dx -= -- -16 -; -dx -< -= -16 -; -+ -+ -dx -) -row -[ -xtest -+ -dx -] -= -center -[ -( -dy -+ -16 -) -* -33 -+ -( -dx -+ -16 -) -] -; -} -const -double -sigma -= -7 -. -155933 -; -ImageF -temp -( -xsize -ysize -) -; -ImageF -out_rg -( -xsize -ysize -) -; -const -auto -rg -= -CreateRecursiveGaussian -( -sigma -) -; -ThreadPool -* -null_pool -= -nullptr -; -FastGaussian -( -rg -in -null_pool -& -temp -& -out_rg -) -; -ImageF -out_old -; -{ -const -std -: -: -vector -< -float -> -kernel -= -GaussianKernel -( -static_cast -< -int -> -( -4 -* -sigma -) -static_cast -< -float -> -( -sigma -) -) -; -printf -( -" -old -kernel -size -% -" -PRIuS -" -\ -n -" -kernel -. -size -( -) -) -; -out_old -= -Convolve -( -in -kernel -) -; -} -printf -( -" -rg -% -. -4f -old -% -. -4f -\ -n -" -out_rg -. -Row -( -ytest -) -[ -xtest -] -out_old -. -Row -( -ytest -) -[ -xtest -] -) -; -} -} diff --git a/third_party/jpeg-xl/lib/jxl/gradient_test.cc b/third_party/jpeg-xl/lib/jxl/gradient_test.cc index 18520b5cca3e..7b98fc799eba 100644 --- a/third_party/jpeg-xl/lib/jxl/gradient_test.cc +++ b/third_party/jpeg-xl/lib/jxl/gradient_test.cc @@ -41,10 +41,20 @@ array # include < +cmath +> +# +include +< utility > # include +< +vector +> +# +include " lib / @@ -91,7 +101,7 @@ jxl / base / -override +span . h " @@ -124,17 +134,6 @@ lib / jxl / -enc_cache -. -h -" -# -include -" -lib -/ -jxl -/ enc_params . h diff --git a/third_party/jpeg-xl/lib/jxl/image.h b/third_party/jpeg-xl/lib/jxl/image.h index 85943a9c69de..fc3ac9c90fc8 100644 --- a/third_party/jpeg-xl/lib/jxl/image.h +++ b/third_party/jpeg-xl/lib/jxl/image.h @@ -66,6 +66,11 @@ sstream # include < +string +> +# +include +< utility > # @@ -1712,6 +1717,7 @@ T > parent ) +const { T new_x0 diff --git a/third_party/jpeg-xl/lib/jxl/image_bundle.h b/third_party/jpeg-xl/lib/jxl/image_bundle.h index 5e1453fd7158..2af12c4b58d0 100644 --- a/third_party/jpeg-xl/lib/jxl/image_bundle.h +++ b/third_party/jpeg-xl/lib/jxl/image_bundle.h @@ -30,6 +30,21 @@ h # include < +memory +> +# +include +< +string +> +# +include +< +utility +> +# +include +< vector > # @@ -41,7 +56,7 @@ jxl / base / -compiler_specific +common . h " @@ -100,39 +115,6 @@ lib / jxl / -dec_bit_reader -. -h -" -# -include -" -lib -/ -jxl -/ -dec_xyb -. -h -" -# -include -" -lib -/ -jxl -/ -field_encodings -. -h -" -# -include -" -lib -/ -jxl -/ frame_header . h @@ -144,7 +126,7 @@ lib / jxl / -headers +image . h " @@ -155,7 +137,7 @@ lib / jxl / -image +image_metadata . h " @@ -166,7 +148,7 @@ lib / jxl / -image_metadata +image_ops . h " @@ -183,17 +165,6 @@ jpeg_data . h " -# -include -" -lib -/ -jxl -/ -quantizer -. -h -" namespace jxl { diff --git a/third_party/jpeg-xl/lib/jxl/image_metadata.h b/third_party/jpeg-xl/lib/jxl/image_metadata.h index 84cb28eb8f51..3665fd97c46c 100644 --- a/third_party/jpeg-xl/lib/jxl/image_metadata.h +++ b/third_party/jpeg-xl/lib/jxl/image_metadata.h @@ -44,6 +44,32 @@ lib / jxl / +base +/ +compiler_specific +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +status +. +h +" +# +include +" +lib +/ +jxl +/ color_encoding_internal . h @@ -55,7 +81,7 @@ lib / jxl / -fields +dec_bit_reader . h " @@ -66,7 +92,7 @@ lib / jxl / -headers +field_encodings . h " @@ -77,9 +103,18 @@ lib / jxl / -jpeg +fields +. +h +" +# +include +" +lib +/ +jxl / -jpeg_data +headers . h " diff --git a/third_party/jpeg-xl/lib/jxl/jxl_test.cc b/third_party/jpeg-xl/lib/jxl/jxl_test.cc index dbe91a9b02d2..c31327da9623 100644 --- a/third_party/jpeg-xl/lib/jxl/jxl_test.cc +++ b/third_party/jpeg-xl/lib/jxl/jxl_test.cc @@ -25,6 +25,15 @@ include < jxl / +color_encoding +. +h +> +# +include +< +jxl +/ encode . h @@ -32,7 +41,21 @@ h # include < -array +jxl +/ +types +. +h +> +# +include +< +algorithm +> +# +include +< +cstddef > # include @@ -42,27 +65,32 @@ cstdint # include < -future +cstdio > # include < -ostream +cstring > # include < -string +future > # include < -tuple +ostream > # include < -utility +string +> +# +include +< +tuple > # include @@ -113,7 +141,9 @@ lib / extras / -packed_image +enc +/ +jxl . h " @@ -122,9 +152,9 @@ include " lib / -jxl +extras / -alpha +packed_image . h " @@ -135,9 +165,7 @@ lib / jxl / -base -/ -compiler_specific +alpha . h " @@ -163,7 +191,7 @@ jxl / base / -override +span . h " @@ -176,7 +204,7 @@ jxl / base / -span +status . h " @@ -231,17 +259,6 @@ lib / jxl / -enc_cache -. -h -" -# -include -" -lib -/ -jxl -/ enc_params . h @@ -286,44 +303,7 @@ lib / jxl / -image_ops -. -h -" -# -include -" -lib -/ -jxl -/ -image_test_utils -. -h -" -# -include -" -lib -/ -jxl -/ -jpeg -/ -dec_jpeg_data -. -h -" -# -include -" -lib -/ -jxl -/ -jpeg -/ -dec_jpeg_data_writer +image_metadata . h " @@ -347,32 +327,6 @@ lib / jxl / -jpeg -/ -jpeg_data -. -h -" -# -include -" -lib -/ -jxl -/ -modular -/ -options -. -h -" -# -include -" -lib -/ -jxl -/ test_image . h @@ -896,7 +850,7 @@ pool & ppf_out ) -1027 +916 40 ) ; @@ -2639,7 +2593,7 @@ pool & ppf_out ) -505555 +492867 5000 ) ; @@ -2656,7 +2610,7 @@ ppf_out ) IsSlightlyBelow ( -75 +78 ) ) ; @@ -2759,7 +2713,7 @@ pool & ppf_out ) -40777 +41355 300 ) ; @@ -3303,7 +3257,7 @@ pool & ppf_out ) -1027 +916 45 ) ; @@ -3416,7 +3370,7 @@ pool & ppf_out ) -41769 +41142 400 ) ; @@ -3559,7 +3513,7 @@ pool & ppf_out ) -1032 +1006 20 ) ; @@ -6243,7 +6197,7 @@ pool & ppf_out ) -13655 +13507 130 ) ; @@ -6937,6 +6891,31 @@ CompressParamsForLossless ( ) ; +JXLDecompressParams +dparams +; +dparams +. +accepted_formats +. +push_back +( +t +. +ppf +( +) +. +frames +[ +0 +] +. +color +. +format +) +; PackedPixelFile ppf_out ; @@ -6950,8 +6929,7 @@ ppf ( ) cparams -{ -} +dparams & pool & @@ -7054,6 +7032,31 @@ JXL_ENC_FRAME_SETTING_MODULAR_PREDICTOR 5 ) ; +JXLDecompressParams +dparams +; +dparams +. +accepted_formats +. +push_back +( +t +. +ppf +( +) +. +frames +[ +0 +] +. +color +. +format +) +; PackedPixelFile ppf_out ; @@ -7067,8 +7070,7 @@ ppf ( ) cparams -{ -} +dparams & pool & @@ -7163,6 +7165,31 @@ JXL_ENC_FRAME_SETTING_EFFORT 1 ) ; +JXLDecompressParams +dparams +; +dparams +. +accepted_formats +. +push_back +( +t +. +ppf +( +) +. +frames +[ +0 +] +. +color +. +format +) +; PackedPixelFile ppf_out ; @@ -7176,8 +7203,7 @@ ppf ( ) cparams -{ -} +dparams & pool & @@ -7275,6 +7301,31 @@ JXL_ENC_FRAME_SETTING_EFFORT 3 ) ; +JXLDecompressParams +dparams +; +dparams +. +accepted_formats +. +push_back +( +t +. +ppf +( +) +. +frames +[ +0 +] +. +color +. +format +) +; PackedPixelFile ppf_out ; @@ -7288,8 +7339,7 @@ ppf ( ) cparams -{ -} +dparams & pool & @@ -8415,7 +8465,7 @@ pool & ppf_out ) -42345 +41009 750 ) ; @@ -8434,7 +8484,7 @@ IsSlightlyBelow ( 1 . -35 +42 ) ) ; @@ -9200,7 +9250,7 @@ ppf_out ) IsSlightlyBelow ( -19252 +19300 ) ) ; @@ -10804,7 +10854,7 @@ pool & ppf_out ) -71444 +70544 750 ) ; @@ -11668,6 +11718,31 @@ JXL_ENC_FRAME_SETTING_EFFORT 1 ) ; +JXLDecompressParams +dparams +; +dparams +. +accepted_formats +. +push_back +( +t +. +ppf +( +) +. +frames +[ +0 +] +. +color +. +format +) +; PackedPixelFile ppf_out ; @@ -11679,8 +11754,7 @@ ppf ( ) cparams -{ -} +dparams & pool & @@ -11751,6 +11825,9 @@ is_grey int effort ; +bool +progressive +; size_t num_channels ( @@ -11834,6 +11911,7 @@ StreamingTestParam 517 g e +false } ) ; @@ -11847,11 +11925,26 @@ StreamingTestParam 2357 g e +false } ) ; } } +params +. +push_back +( +StreamingTestParam +{ +2247 +2357 +false +1 +true +} +) +; return params ; @@ -11923,6 +12016,21 @@ p . effort ; +if +( +p +. +progressive +) +{ +out +< +< +" +Progressive +" +; +} return out ; @@ -12037,6 +12145,22 @@ JXL_ENC_FRAME_SETTING_BUFFERING 3 ) ; +if +( +p +. +progressive +) +{ +cparams +. +AddOption +( +JXL_ENC_FRAME_SETTING_PROGRESSIVE_AC +1 +) +; +} ThreadPoolForTests pool ( @@ -12105,5 +12229,148 @@ All ) ) ; +TEST +( +JxlTest +JXL_X86_64_TEST +( +StreamingSamePixels +) +) +{ +const +std +: +: +vector +< +uint8_t +> +orig += +ReadTestData +( +" +jxl +/ +flower +/ +flower +. +png +" +) +; +jxl +: +: +test +: +: +TestImage +image +; +image +. +DecodeFromBytes +( +orig +) +; +JXLCompressParams +cparams +; +cparams +. +distance += +1 +. +0 +; +cparams +. +AddOption +( +JXL_ENC_FRAME_SETTING_EFFORT +6 +) +; +cparams +. +AddOption +( +JXL_ENC_FRAME_SETTING_USE_FULL_IMAGE_HEURISTICS +0 +) +; +ThreadPoolForTests +pool +( +8 +) +; +PackedPixelFile +ppf_out +; +Roundtrip +( +image +. +ppf +( +) +cparams +{ +} +& +pool +& +ppf_out +) +; +cparams +. +AddOption +( +JXL_ENC_FRAME_SETTING_BUFFERING +3 +) +; +PackedPixelFile +ppf_out_streaming +; +Roundtrip +( +image +. +ppf +( +) +cparams +{ +} +& +pool +& +ppf_out_streaming +) +; +EXPECT_TRUE +( +jxl +: +: +test +: +: +SamePixels +( +ppf_out +ppf_out_streaming +) +) +; +} } } diff --git a/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h b/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h index 4bd3ffd80be4..4a6b3d616075 100644 --- a/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h +++ b/third_party/jpeg-xl/lib/jxl/memory_manager_internal.h @@ -23,13 +23,6 @@ h # include < -stdint -. -h -> -# -include -< stdlib . h @@ -44,11 +37,6 @@ h # include < -atomic -> -# -include -< memory > # diff --git a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_encoding.cc b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_encoding.cc index 4eef3d6ea930..3e003a08519a 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_encoding.cc +++ b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_encoding.cc @@ -475,6 +475,257 @@ return } ; } +Tree +MakeFixedTree +( +int +property +const +std +: +: +vector +< +int32_t +> +& +cutoffs +Predictor +pred +size_t +num_pixels +) +{ +size_t +log_px += +CeilLog2Nonzero +( +num_pixels +) +; +size_t +min_gap += +0 +; +if +( +log_px +< +14 +) +{ +min_gap += +8 +* +( +14 +- +log_px +) +; +} +Tree +tree +; +struct +NodeInfo +{ +size_t +begin +end +pos +; +} +; +std +: +: +queue +< +NodeInfo +> +q +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +pred +) +) +; +q +. +push +( +NodeInfo +{ +0 +cutoffs +. +size +( +) +0 +} +) +; +while +( +! +q +. +empty +( +) +) +{ +NodeInfo +info += +q +. +front +( +) +; +q +. +pop +( +) +; +if +( +info +. +begin ++ +min_gap +> += +info +. +end +) +continue +; +uint32_t +split += +( +info +. +begin ++ +info +. +end +) +/ +2 +; +tree +[ +info +. +pos +] += +PropertyDecisionNode +: +: +Split +( +property +cutoffs +[ +split +] +tree +. +size +( +) +) +; +q +. +push +( +NodeInfo +{ +split ++ +1 +info +. +end +tree +. +size +( +) +} +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +pred +) +) +; +q +. +push +( +NodeInfo +{ +info +. +begin +split +tree +. +size +( +) +} +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +pred +) +) +; +} +return +tree +; +} } void GatherTreeData @@ -1159,118 +1410,850 @@ PredictorFromIndex ( 0 ) -references -& -wp_state +references +& +wp_state +) +. +guess +; +} +( +* +total_pixels +) ++ ++ +; +if +( +use_sample +( +) +) +{ +tree_samples +. +AddSample +( +p +[ +x +] +properties +pred +) +; +} +wp_state +. +UpdateErrors +( +p +[ +x +] +x +y +channel +. +w +) +; +} +for +( +size_t +x += +channel +. +w +- +2 +; +x +< +channel +. +w +; +x ++ ++ +) +{ +compute_sample +( +p +x +y +) +; +} +} +else +{ +for +( +size_t +x += +0 +; +x +< +channel +. +w +; +x ++ ++ +) +{ +compute_sample +( +p +x +y +) +; +} +} +} +} +Tree +PredefinedTree +( +ModularOptions +: +: +TreeKind +tree_kind +size_t +total_pixels +) +{ +if +( +tree_kind += += +ModularOptions +: +: +TreeKind +: +: +kJpegTranscodeACMeta +| +| +tree_kind += += +ModularOptions +: +: +TreeKind +: +: +kTrivialTreeNoPredictor +) +{ +return +{ +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Zero +) +} +; +} +if +( +tree_kind += += +ModularOptions +: +: +TreeKind +: +: +kFalconACMeta +) +{ +return +{ +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Left +) +} +; +} +if +( +tree_kind += += +ModularOptions +: +: +TreeKind +: +: +kACMeta +) +{ +if +( +total_pixels +< +1024 +) +{ +return +{ +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Left +) +} +; +} +Tree +tree +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +0 +1 +1 +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +0 +2 +3 +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +0 +0 +5 +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +6 +0 +21 +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +2 +0 +7 +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Gradient +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Gradient +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +7 +5 +9 +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +7 +5 +15 +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +7 +11 +11 +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +7 +3 +13 +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Left +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Left +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Left +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Left +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +7 +11 +17 +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +7 +3 +19 +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Zero +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Zero +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Zero +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Zero +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +7 +0 +23 +) +) +; +tree +. +push_back +( +PropertyDecisionNode +: +: +Split +( +7 +0 +25 +) ) -. -guess ; -} +tree +. +push_back ( -* -total_pixels +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Zero +) ) -+ -+ ; -if +tree +. +push_back ( -use_sample +PropertyDecisionNode +: +: +Leaf ( +Predictor +: +: +Zero ) ) -{ -tree_samples +; +tree . -AddSample +push_back ( -p -[ -x -] -properties -pred +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Zero +) ) ; -} -wp_state +tree . -UpdateErrors +push_back ( -p -[ -x -] -x -y -channel -. -w +PropertyDecisionNode +: +: +Leaf +( +Predictor +: +: +Zero +) ) ; +return +tree +; } -for +if ( -size_t -x +tree_kind = -channel -. -w -- -2 -; -x -< -channel -. -w -; -x -+ -+ += +ModularOptions +: +: +TreeKind +: +: +kWPFixedDC ) { -compute_sample +std +: +: +vector +< +int32_t +> +cutoffs += +{ +- +500 +- +392 +- +255 +- +191 +- +127 +- +95 +- +63 +- +47 +- +31 +- +23 +- +15 +- +11 +- +7 +- +4 +- +3 +- +1 +0 +1 +3 +5 +7 +11 +15 +23 +31 +47 +63 +95 +127 +191 +255 +392 +500 +} +; +return +MakeFixedTree ( -p -x -y +kWPProp +cutoffs +Predictor +: +: +Weighted +total_pixels ) ; } -} -else -{ -for +if ( -size_t -x +tree_kind = -0 -; -x -< -channel -. -w -; -x -+ -+ += +ModularOptions +: +: +TreeKind +: +: +kGradientFixedDC ) { -compute_sample +std +: +: +vector +< +int32_t +> +cutoffs += +{ +- +500 +- +392 +- +255 +- +191 +- +127 +- +95 +- +63 +- +47 +- +31 +- +23 +- +15 +- +11 +- +7 +- +4 +- +3 +- +1 +0 +1 +3 +5 +7 +11 +15 +23 +31 +47 +63 +95 +127 +191 +255 +392 +500 +} +; +return +MakeFixedTree ( -p -x -y +kGradientProp +cutoffs +Predictor +: +: +Gradient +total_pixels ) ; } +JXL_UNREACHABLE +( +" +Unreachable +" +) +; +return +{ } -} +; } Tree LearnTree @@ -4213,6 +5196,19 @@ tree_tokens ; tree_storage = +options +. +tree_kind += += +ModularOptions +: +: +TreeKind +: +: +kLearn +? LearnTree ( std @@ -4226,6 +5222,15 @@ tree_samples_storage total_pixels options ) +: +PredefinedTree +( +options +. +tree_kind +* +total_pixels +) ; tree = diff --git a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_encoding.h b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_encoding.h index c053ba0884d9..6da1646d12f6 100644 --- a/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_encoding.h +++ b/third_party/jpeg-xl/lib/jxl/modular/encoding/enc_encoding.h @@ -21,7 +21,9 @@ lib / jxl / -enc_ans +base +/ +status . h " @@ -32,7 +34,7 @@ lib / jxl / -enc_bit_writer +enc_ans . h " @@ -43,7 +45,7 @@ lib / jxl / -image +enc_bit_writer . h " @@ -86,6 +88,19 @@ jxl / modular / +modular_image +. +h +" +# +include +" +lib +/ +jxl +/ +modular +/ options . h @@ -100,6 +115,18 @@ struct GroupHeader ; Tree +PredefinedTree +( +ModularOptions +: +: +TreeKind +tree_kind +size_t +total_pixels +) +; +Tree LearnTree ( TreeSamples diff --git a/third_party/jpeg-xl/lib/jxl/modular_test.cc b/third_party/jpeg-xl/lib/jxl/modular_test.cc index d615b555da06..99066562d681 100644 --- a/third_party/jpeg-xl/lib/jxl/modular_test.cc +++ b/third_party/jpeg-xl/lib/jxl/modular_test.cc @@ -10,7 +10,25 @@ h # include < -array +jxl +/ +encode +. +h +> +# +include +< +jxl +/ +types +. +h +> +# +include +< +cstddef > # include @@ -20,6 +38,11 @@ cstdint # include < +sstream +> +# +include +< string > # @@ -63,6 +86,19 @@ lib / extras / +enc +/ +jxl +. +h +" +# +include +" +lib +/ +extras +/ metrics . h @@ -72,6 +108,17 @@ include " lib / +extras +/ +packed_image +. +h +" +# +include +" +lib +/ jxl / base @@ -102,7 +149,7 @@ jxl / base / -override +random . h " @@ -126,6 +173,19 @@ lib / jxl / +base +/ +status +. +h +" +# +include +" +lib +/ +jxl +/ codec_in_out . h @@ -148,6 +208,17 @@ lib / jxl / +dec_bit_reader +. +h +" +# +include +" +lib +/ +jxl +/ enc_aux_out . h @@ -159,7 +230,7 @@ lib / jxl / -enc_butteraugli_comparator +enc_bit_writer . h " @@ -170,7 +241,7 @@ lib / jxl / -enc_cache +enc_butteraugli_comparator . h " @@ -214,6 +285,39 @@ lib / jxl / +fields +. +h +" +# +include +" +lib +/ +jxl +/ +frame_header +. +h +" +# +include +" +lib +/ +jxl +/ +headers +. +h +" +# +include +" +lib +/ +jxl +/ image . h @@ -236,6 +340,17 @@ lib / jxl / +image_metadata +. +h +" +# +include +" +lib +/ +jxl +/ image_ops . h @@ -290,9 +405,35 @@ jxl / modular / -encoding +modular_image +. +h +" +# +include +" +lib +/ +jxl +/ +modular +/ +options +. +h +" +# +include +" +lib / -ma_common +jxl +/ +modular +/ +transform +/ +transform . h " @@ -314,6 +455,17 @@ lib / jxl / +test_image +. +h +" +# +include +" +lib +/ +jxl +/ test_utils . h @@ -346,6 +498,12 @@ test : Roundtrip ; +using +test +: +: +TestImage +; void TestLosslessGroups ( @@ -376,52 +534,40 @@ png " ) ; -CompressParams -cparams +TestImage +t ; -cparams +t . -SetLossless +DecodeFromBytes ( +orig ) -; -cparams . -modular_group_size_shift -= -group_size_shift -; -CodecInOut -io_out -; -CodecInOut -io -; -ASSERT_TRUE -( -SetFromBytes +ClearMetadata ( -Bytes -( -orig -) -& -io -) ) ; -io +t . -ShrinkTo +SetDimensions ( -io +t +. +ppf +( +) . xsize ( ) / 4 -io +t +. +ppf +( +) . ysize ( @@ -430,24 +576,68 @@ ysize 4 ) ; -size_t -compressed_size +extras +: +: +JXLCompressParams +cparams ; -JXL_EXPECT_OK -( -Roundtrip -( -& -io cparams +. +distance += +0 +. +0f +; +cparams +. +AddOption +( +JXL_ENC_FRAME_SETTING_MODULAR_GROUP_SIZE +group_size_shift +) +; +extras +: +: +JXLDecompressParams +dparams +; +dparams +. +accepted_formats += { +{ +3 +JXL_TYPE_UINT16 +JXL_LITTLE_ENDIAN +0 } -& -io_out -_ -& +} +; +extras +: +: +PackedPixelFile +ppf_out +; +size_t compressed_size += +Roundtrip +( +t +. +ppf +( ) +cparams +dparams +nullptr +& +ppf_out ) ; EXPECT_LE @@ -456,31 +646,22 @@ compressed_size 280000u ) ; -JXL_EXPECT_OK -( -SamePixels -( -* -io -. -Main -( -) -. -color +EXPECT_EQ ( -) -* -io_out +0 . -Main +0f +test +: +: +ComputeDistance2 ( -) +t . -color +ppf ( ) -_ +ppf_out ) ) ; @@ -558,88 +739,115 @@ png " ) ; -CompressParams -cparams +TestImage +t ; -cparams +t . -SetLossless +DecodeFromBytes +( +orig +) +. +ClearMetadata ( ) ; -cparams +t . -colorspace -= -9 +SetDimensions +( +100 +100 +) +; +extras +: +: +JXLCompressParams +cparams ; cparams . -speed_tier +distance = -SpeedTier -: -: -kTortoise +0 +. +0f ; cparams . -options +AddOption +( +JXL_ENC_FRAME_SETTING_MODULAR_COLOR_SPACE +9 +) +; +cparams . -predictor -= -{ +AddOption +( +JXL_ENC_FRAME_SETTING_MODULAR_PREDICTOR +static_cast +< +int64_t +> +( Predictor : : Weighted -} -; -CodecInOut -io_out -; -CodecInOut -io -; -ASSERT_TRUE -( -SetFromBytes -( -Bytes -( -orig -) -& -io ) ) ; -io +cparams . -ShrinkTo +AddOption ( -100 -100 +JXL_ENC_FRAME_SETTING_EFFORT +9 ) ; -size_t -compressed_size +extras +: +: +JXLDecompressParams +dparams ; -JXL_EXPECT_OK -( +dparams +. +accepted_formats += +{ +{ +3 +JXL_TYPE_UINT16 +JXL_LITTLE_ENDIAN +0 +} +} +; +extras +: +: +PackedPixelFile +ppf_out +; +size_t +compressed_size += Roundtrip ( -& -io +t +. +ppf +( +) cparams -{ -} -& -io_out -_ +dparams +nullptr & -compressed_size -) +ppf_out ) ; EXPECT_LE @@ -648,31 +856,22 @@ compressed_size 10169u ) ; -JXL_EXPECT_OK -( -SamePixels -( -* -io -. -Main -( -) -. -color +EXPECT_EQ ( -) -* -io_out +0 . -Main +0f +test +: +: +ComputeDistance2 ( -) +t . -color +ppf ( ) -_ +ppf_out ) ) ; @@ -1723,231 +1922,6 @@ y } } } -TEST -( -ModularTest -RoundtripLosslessCustomSqueeze -) -{ -const -std -: -: -vector -< -uint8_t -> -orig -= -ReadTestData -( -" -external -/ -wesaturate -/ -500px -/ -tmshre_riaphotographs_srgb8 -. -png -" -) -; -CodecInOut -io -; -ASSERT_TRUE -( -SetFromBytes -( -Bytes -( -orig -) -& -io -) -) -; -CompressParams -cparams -; -cparams -. -modular_mode -= -true -; -cparams -. -color_transform -= -jxl -: -: -ColorTransform -: -: -kNone -; -cparams -. -butteraugli_distance -= -0 -. -f -; -cparams -. -options -. -predictor -= -{ -Predictor -: -: -Zero -} -; -cparams -. -speed_tier -= -SpeedTier -: -: -kThunder -; -cparams -. -responsive -= -1 -; -SqueezeParams -p -; -p -. -horizontal -= -true -; -p -. -in_place -= -false -; -p -. -begin_c -= -0 -; -p -. -num_c -= -3 -; -cparams -. -squeezes -. -push_back -( -p -) -; -p -. -begin_c -= -1 -; -p -. -in_place -= -true -; -p -. -horizontal -= -false -; -cparams -. -squeezes -. -push_back -( -p -) -; -CodecInOut -io2 -; -size_t -compressed_size -; -JXL_EXPECT_OK -( -Roundtrip -( -& -io -cparams -{ -} -& -io2 -_ -& -compressed_size -) -) -; -EXPECT_LE -( -compressed_size -265000u -) -; -JXL_EXPECT_OK -( -SamePixels -( -* -io -. -Main -( -) -. -color -( -) -* -io2 -. -Main -( -) -. -color -( -) -_ -) -) -; -} struct RoundtripLosslessConfig { diff --git a/third_party/jpeg-xl/lib/jxl/opsin_image_test.cc b/third_party/jpeg-xl/lib/jxl/opsin_image_test.cc index a29bc425e529..8b6cfdedef29 100644 --- a/third_party/jpeg-xl/lib/jxl/opsin_image_test.cc +++ b/third_party/jpeg-xl/lib/jxl/opsin_image_test.cc @@ -9,6 +9,16 @@ h > # include +< +cstddef +> +# +include +< +utility +> +# +include " lib / @@ -86,6 +96,28 @@ lib / jxl / +image_bundle +. +h +" +# +include +" +lib +/ +jxl +/ +image_metadata +. +h +" +# +include +" +lib +/ +jxl +/ opsin_params . h diff --git a/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc b/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc index 0948ef71f421..777111ec1612 100644 --- a/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc +++ b/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc @@ -9,6 +9,11 @@ h > # include +< +utility +> +# +include " lib / @@ -82,7 +87,7 @@ lib / jxl / -image_bundle +image_ops . h " diff --git a/third_party/jpeg-xl/lib/jxl/passes_test.cc b/third_party/jpeg-xl/lib/jxl/passes_test.cc index 9e4e201c0dd7..d1f19761491e 100644 --- a/third_party/jpeg-xl/lib/jxl/passes_test.cc +++ b/third_party/jpeg-xl/lib/jxl/passes_test.cc @@ -17,6 +17,11 @@ h # include < +cstdint +> +# +include +< future > # @@ -31,6 +36,11 @@ utility > # include +< +vector +> +# +include " lib / @@ -45,11 +55,11 @@ include " lib / -jxl +extras / -base +dec / -compiler_specific +jxl . h " @@ -99,28 +109,6 @@ lib / jxl / -color_encoding_internal -. -h -" -# -include -" -lib -/ -jxl -/ -enc_aux_out -. -h -" -# -include -" -lib -/ -jxl -/ enc_butteraugli_comparator . h @@ -132,7 +120,7 @@ lib / jxl / -enc_cache +enc_params . h " @@ -143,7 +131,7 @@ lib / jxl / -enc_params +image . h " @@ -296,7 +284,10 @@ cparams . progressive_mode = -true +Override +: +: +kOn ; cparams . @@ -436,7 +427,10 @@ cparams . progressive_mode = -true +Override +: +: +kOn ; cparams . @@ -589,7 +583,10 @@ cparams . progressive_mode = -true +Override +: +: +kOn ; cparams . @@ -771,7 +768,10 @@ cparams . progressive_mode = -true +Override +: +: +kOn ; cparams . @@ -874,7 +874,10 @@ cparams . progressive_mode = -true +Override +: +: +kOn ; cparams . @@ -1110,7 +1113,10 @@ cparams . progressive_mode = -true +Override +: +: +kOn ; cparams . @@ -1452,7 +1458,10 @@ cparams . qprogressive_mode = -true +Override +: +: +kOn ; cparams . @@ -1886,7 +1895,10 @@ cparams . qprogressive_mode = -true +Override +: +: +kOn ; cparams . @@ -2182,7 +2194,10 @@ cparams . qprogressive_mode = -true +Override +: +: +kOn ; cparams . @@ -2393,7 +2408,10 @@ cparams . progressive_mode = -false +Override +: +: +kOff ; cparams . @@ -2574,7 +2592,10 @@ cparams . progressive_mode = -true +Override +: +: +kOn ; cparams . diff --git a/third_party/jpeg-xl/lib/jxl/patch_dictionary_test.cc b/third_party/jpeg-xl/lib/jxl/patch_dictionary_test.cc index 807dfbdc6163..0f4c65a097ad 100644 --- a/third_party/jpeg-xl/lib/jxl/patch_dictionary_test.cc +++ b/third_party/jpeg-xl/lib/jxl/patch_dictionary_test.cc @@ -10,6 +10,11 @@ h # include < +cstddef +> +# +include +< cstdint > # @@ -35,6 +40,32 @@ lib / jxl / +base +/ +override +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +span +. +h +" +# +include +" +lib +/ +jxl +/ enc_butteraugli_comparator . h diff --git a/third_party/jpeg-xl/lib/jxl/preview_test.cc b/third_party/jpeg-xl/lib/jxl/preview_test.cc index 7ccb09238955..281b0053c119 100644 --- a/third_party/jpeg-xl/lib/jxl/preview_test.cc +++ b/third_party/jpeg-xl/lib/jxl/preview_test.cc @@ -47,45 +47,6 @@ jxl / base / -compiler_specific -. -h -" -# -include -" -lib -/ -jxl -/ -base -/ -data_parallel -. -h -" -# -include -" -lib -/ -jxl -/ -base -/ -override -. -h -" -# -include -" -lib -/ -jxl -/ -base -/ span . h @@ -108,17 +69,6 @@ lib / jxl / -color_encoding_internal -. -h -" -# -include -" -lib -/ -jxl -/ enc_butteraugli_comparator . h @@ -130,17 +80,6 @@ lib / jxl / -enc_cache -. -h -" -# -include -" -lib -/ -jxl -/ enc_params . h diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc index 7067019f54ff..8a85223e9d04 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/render_pipeline_test.cc @@ -28,6 +28,11 @@ algorithm # include < +cctype +> +# +include +< cstdint > # @@ -38,6 +43,21 @@ cstdio # include < +ostream +> +# +include +< +sstream +> +# +include +< +string +> +# +include +< utility > # @@ -78,6 +98,32 @@ jxl / base / +compiler_specific +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +override +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ span . h @@ -89,6 +135,30 @@ lib / jxl / +base +/ +status +. +h +" +# +include +" +lib +/ +jxl +/ +chroma_from_luma +. +h +" +# +include +" +lib +/ +jxl +/ color_encoding_internal . h @@ -111,7 +181,7 @@ lib / jxl / -dec_frame +dec_bit_reader . h " @@ -122,7 +192,18 @@ lib / jxl / -enc_cache +dec_cache +. +h +" +# +include +" +lib +/ +jxl +/ +dec_frame . h " @@ -155,6 +236,17 @@ lib / jxl / +fields +. +h +" +# +include +" +lib +/ +jxl +/ frame_dimensions . h @@ -177,7 +269,40 @@ lib / jxl / -icc_codec +headers +. +h +" +# +include +" +lib +/ +jxl +/ +image +. +h +" +# +include +" +lib +/ +jxl +/ +image_metadata +. +h +" +# +include +" +lib +/ +jxl +/ +image_ops . h " @@ -225,6 +350,17 @@ lib / jxl / +splines +. +h +" +# +include +" +lib +/ +jxl +/ test_utils . h @@ -1772,7 +1908,7 @@ constexpr float kMaxError = -1e +5e - 5 ; diff --git a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_upsampling.cc b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_upsampling.cc index 5dc97740dc77..0fa943a34873 100644 --- a/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_upsampling.cc +++ b/third_party/jpeg-xl/lib/jxl/render_pipeline/stage_upsampling.cc @@ -12,6 +12,19 @@ stage_upsampling h " # +include +" +lib +/ +jxl +/ +base +/ +status +. +h +" +# undef HWY_TARGET_INCLUDE # @@ -892,8 +905,40 @@ V * ups [ -N +8 ] += +{ +} +; +static_assert +( +N += += +2 +| +| +N += += +4 +| +| +N += += +8 +" +N +must +be +2 +4 +or +8 +" +) ; if ( diff --git a/third_party/jpeg-xl/lib/jxl/roundtrip_test.cc b/third_party/jpeg-xl/lib/jxl/roundtrip_test.cc index c89d88aeb085..4b7fb5bdd5d6 100644 --- a/third_party/jpeg-xl/lib/jxl/roundtrip_test.cc +++ b/third_party/jpeg-xl/lib/jxl/roundtrip_test.cc @@ -21,6 +21,15 @@ include < jxl / +color_encoding +. +h +> +# +include +< +jxl +/ decode . h @@ -64,22 +73,32 @@ h # include < -cmath +cstddef > # include < -cstddef +cstdint > # include < -cstdint +cstdio > # include < -cstdio +cstring +> +# +include +< +string +> +# +include +< +utility > # include @@ -106,6 +125,19 @@ jxl / base / +common +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ span . h @@ -117,7 +149,9 @@ lib / jxl / -dec_bit_reader +butteraugli +/ +butteraugli . h " @@ -128,7 +162,7 @@ lib / jxl / -dec_external_image +color_encoding_internal . h " @@ -139,7 +173,7 @@ lib / jxl / -enc_butteraugli_comparator +dec_bit_reader . h " @@ -150,7 +184,7 @@ lib / jxl / -enc_comparator +enc_butteraugli_comparator . h " @@ -183,7 +217,18 @@ lib / jxl / -icc_codec +image +. +h +" +# +include +" +lib +/ +jxl +/ +image_ops . h " diff --git a/third_party/jpeg-xl/lib/jxl/speed_tier_test.cc b/third_party/jpeg-xl/lib/jxl/speed_tier_test.cc index a3c5005d3f13..70a47ba0f922 100644 --- a/third_party/jpeg-xl/lib/jxl/speed_tier_test.cc +++ b/third_party/jpeg-xl/lib/jxl/speed_tier_test.cc @@ -3,92 +3,59 @@ include < jxl / -cms +encode . h > # include < -cstdint +jxl +/ +types +. +h > # include < -string +cstddef > # include < -vector +cstdint > # include -" -lib -/ -extras -/ -codec -. -h -" +< +ios +> # include -" -lib -/ -jxl -/ -base -/ -data_parallel -. -h -" +< +ostream +> # include -" -lib -/ -jxl -/ -base -/ -span -. -h -" +< +string +> # include -" -lib -/ -jxl -/ -codec_in_out -. -h -" +< +vector +> # include " lib / -jxl +extras / -enc_butteraugli_comparator -. -h -" -# -include -" -lib +dec / jxl -/ -enc_cache . h " @@ -97,9 +64,11 @@ include " lib / -jxl +extras / -enc_params +enc +/ +jxl . h " @@ -110,7 +79,7 @@ lib / jxl / -image +enc_params . h " @@ -121,7 +90,7 @@ lib / jxl / -image_test_utils +test_image . h " @@ -441,6 +410,24 @@ Roundtrip ) { const +SpeedTierTestParams +& +params += +GetParam +( +) +; +test +: +: +ThreadPoolForTests +pool +( +8 +) +; +const std : : @@ -471,39 +458,20 @@ png " ) ; -CodecInOut -io -; test : : -ThreadPoolForTests -pool -( -8 -) +TestImage +t ; -ASSERT_TRUE -( -SetFromBytes -( -Bytes +t +. +DecodeFromBytes ( orig ) -& -io -& -pool -) -) -; -const -SpeedTierTestParams -& -params -= -GetParam +. +ClearMetadata ( ) ; @@ -520,9 +488,9 @@ SpeedTier kGlacier ) { -io +t . -ShrinkTo +SetDimensions ( 8 8 @@ -537,18 +505,26 @@ params shrink8 ) { -io +t . -ShrinkTo +SetDimensions ( -io +t +. +ppf +( +) . xsize ( ) / 8 -io +t +. +ppf +( +) . ysize ( @@ -558,74 +534,107 @@ ysize ) ; } -CompressParams +extras +: +: +JXLCompressParams cparams ; cparams . -speed_tier +distance = -params +1 . -speed_tier +0f +; +cparams +. +allow_expert_options += +true ; cparams . -SetCms +AddOption ( -* -JxlGetDefaultCms +JXL_ENC_FRAME_SETTING_EFFORT +10 +- +static_cast +< +int +> ( +params +. +speed_tier ) ) ; -CodecInOut -io2 -io3 +extras +: +: +JXLDecompressParams +dparams +; +dparams +. +accepted_formats += +{ +{ +3 +JXL_TYPE_UINT16 +JXL_LITTLE_ENDIAN +0 +} +} +; +{ +extras +: +: +PackedPixelFile +ppf_out ; -JXL_EXPECT_OK -( test : : Roundtrip ( -& -io +t +. +ppf +( +) cparams -{ -} +dparams +nullptr & -io2 -_ -) +ppf_out ) ; EXPECT_LE ( +test +: +: ButteraugliDistance ( -io -. -frames -io2 +t . -frames -ButteraugliParams +ppf ( ) -* -JxlGetDefaultCms -( -) -nullptr -nullptr +ppf_out ) 1 . 6 ) ; +} if ( params @@ -635,53 +644,51 @@ shrink8 { cparams . -SetLossless -( -) +distance += +0 +. +0f +; +extras +: +: +PackedPixelFile +ppf_out ; -JXL_EXPECT_OK -( test : : Roundtrip ( -& -io +t +. +ppf +( +) cparams -{ -} +dparams +nullptr & -io3 -_ -) +ppf_out ) ; -JXL_EXPECT_OK -( -SamePixels +EXPECT_EQ ( -* -io -. -Main -( -) -. -color -( -) -* -io3 +0 . -Main +0f +test +: +: +ComputeDistance2 ( -) +t . -color +ppf ( ) -_ +ppf_out ) ) ; diff --git a/third_party/jpeg-xl/lib/jxl/splines_test.cc b/third_party/jpeg-xl/lib/jxl/splines_test.cc index 6f3421e390f1..8f4bb700ef07 100644 --- a/third_party/jpeg-xl/lib/jxl/splines_test.cc +++ b/third_party/jpeg-xl/lib/jxl/splines_test.cc @@ -21,11 +21,31 @@ h # include < +cstddef +> +# +include +< cstdint > # include < +cstdio +> +# +include +< +ostream +> +# +include +< +utility +> +# +include +< vector > # @@ -48,6 +68,32 @@ jxl / base / +common +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ +compiler_specific +. +h +" +# +include +" +lib +/ +jxl +/ +base +/ printf_macros . h @@ -72,6 +118,30 @@ lib / jxl / +base +/ +status +. +h +" +# +include +" +lib +/ +jxl +/ +chroma_from_luma +. +h +" +# +include +" +lib +/ +jxl +/ enc_aux_out . h @@ -83,7 +153,18 @@ lib / jxl / -enc_butteraugli_comparator +enc_bit_writer +. +h +" +# +include +" +lib +/ +jxl +/ +enc_params . h " @@ -105,6 +186,28 @@ lib / jxl / +image +. +h +" +# +include +" +lib +/ +jxl +/ +image_ops +. +h +" +# +include +" +lib +/ +jxl +/ image_test_utils . h diff --git a/third_party/jpeg-xl/lib/jxl/testing.h b/third_party/jpeg-xl/lib/jxl/testing.h index 0ef4fc0443d9..ed2b226c99c1 100644 --- a/third_party/jpeg-xl/lib/jxl/testing.h +++ b/third_party/jpeg-xl/lib/jxl/testing.h @@ -47,11 +47,6 @@ PRIdS ) # include -< -sstream -> -# -include " gtest / @@ -167,6 +162,33 @@ X # endif # +if +defined +( +__x86_64__ +) +# +define +JXL_X86_64_TEST +( +X +) +X +# +else +# +define +JXL_X86_64_TEST +( +X +) +DISABLED_ +# +# +X +# +endif +# ifdef INSTANTIATE_TEST_SUITE_P # diff --git a/third_party/jpeg-xl/lib/jxl_benchmark.cmake b/third_party/jpeg-xl/lib/jxl_benchmark.cmake index 9bc0c0f471fa..7fbd53a42faa 100644 --- a/third_party/jpeg-xl/lib/jxl_benchmark.cmake +++ b/third_party/jpeg-xl/lib/jxl_benchmark.cmake @@ -123,6 +123,30 @@ lrt endif ( ) +list +( +APPEND +JPEGXL_INTERNAL_TESTS +# +TODO +( +eustas +) +: +Move +this +to +tools +/ +. +. +/ +tools +/ +gauss_blur_gbench +. +cc +) # Compiles all diff --git a/third_party/jpeg-xl/lib/jxl_lists.bzl b/third_party/jpeg-xl/lib/jxl_lists.bzl index 22595e454687..0b00bb7f9497 100644 --- a/third_party/jpeg-xl/lib/jxl_lists.bzl +++ b/third_party/jpeg-xl/lib/jxl_lists.bzl @@ -38,7 +38,9 @@ the LICENSE file . -# +" +" +" This file is @@ -49,7 +51,6 @@ modify by manually . -# Run tools / @@ -65,6 +66,9 @@ to regenerate it . +" +" +" libjxl_base_sources = [ @@ -964,13 +968,6 @@ cc " jxl / -convolve_separable7 -. -cc -" -" -jxl -/ convolve_slow . cc @@ -1378,20 +1375,6 @@ h " jxl / -gauss_blur -. -cc -" -" -jxl -/ -gauss_blur -. -h -" -" -jxl -/ headers . cc @@ -3349,13 +3332,6 @@ cc " jxl / -gauss_blur_gbench -. -cc -" -" -jxl -/ splines_gbench . cc @@ -4333,13 +4309,6 @@ cc " jxl / -gauss_blur_test -. -cc -" -" -jxl -/ gradient_test . cc diff --git a/third_party/jpeg-xl/lib/jxl_lists.cmake b/third_party/jpeg-xl/lib/jxl_lists.cmake index c48f2faf1a2d..9d19edc56fa9 100644 --- a/third_party/jpeg-xl/lib/jxl_lists.cmake +++ b/third_party/jpeg-xl/lib/jxl_lists.cmake @@ -765,11 +765,6 @@ convolve_separable5 cc jxl / -convolve_separable7 -. -cc -jxl -/ convolve_slow . cc @@ -1067,16 +1062,6 @@ frame_header h jxl / -gauss_blur -. -cc -jxl -/ -gauss_blur -. -h -jxl -/ headers . cc @@ -2548,11 +2533,6 @@ enc_external_image_gbench cc jxl / -gauss_blur_gbench -. -cc -jxl -/ splines_gbench . cc @@ -3264,11 +3244,6 @@ gamma_correct_test cc jxl / -gauss_blur_test -. -cc -jxl -/ gradient_test . cc diff --git a/third_party/jpeg-xl/lib/jxl_tests.cmake b/third_party/jpeg-xl/lib/jxl_tests.cmake index 6f691caead43..8273dbd50fd8 100644 --- a/third_party/jpeg-xl/lib/jxl_tests.cmake +++ b/third_party/jpeg-xl/lib/jxl_tests.cmake @@ -104,9 +104,6 @@ jxl_testlib - internal hwy -jxl_extras_nocodec -- -internal jxl - internal @@ -149,11 +146,125 @@ tools djxl_fuzzer_test . cc +. +. +/ +tools +/ +gauss_blur_test +. +cc ) find_package ( GTest ) +set +( +JXL_WASM_TEST_LINK_FLAGS +" +" +) +if +( +EMSCRIPTEN +) +# +The +emscripten +linking +step +takes +too +much +memory +and +crashes +during +the +# +wasm +- +opt +step +when +using +- +O2 +optimization +level +set +( +JXL_WASM_TEST_LINK_FLAGS +" +\ +- +O1 +\ +- +s +USE_LIBPNG += +1 +\ +- +s +ALLOW_MEMORY_GROWTH += +1 +\ +- +s +SINGLE_FILE += +1 +\ +- +s +EXIT_RUNTIME += +1 +\ +- +s +NODERAWFS += +1 +\ +" +) +if +( +JPEGXL_ENABLE_WASM_TRHEADS +) +set +( +JXL_WASM_TEST_LINK_FLAGS +" +{ +JXL_WASM_TEST_LINK_FLAGS +} +\ +- +s +PROXY_TO_PTHREAD +\ +- +s +USE_PTHREADS += +1 +\ +" +) +endif +( +) +endif +( +) +# +EMSCRIPTEN # Individual test @@ -244,30 +355,6 @@ if ( EMSCRIPTEN ) -# -The -emscripten -linking -step -takes -too -much -memory -and -crashes -during -the -# -wasm -- -opt -step -when -using -- -O2 -optimization -level set_target_properties ( { @@ -276,50 +363,9 @@ TESTNAME PROPERTIES LINK_FLAGS " -\ -- -O1 -\ -- -s -USE_LIBPNG -= -1 -\ -- -s -ALLOW_MEMORY_GROWTH -= -1 -\ -- -s -SINGLE_FILE -= -1 -\ -- -s -PROXY_TO_PTHREAD -\ -- -s -EXIT_RUNTIME -= -1 -\ -- -s -USE_PTHREADS -= -1 -\ -- -s -NODERAWFS -= -1 -\ +{ +JXL_WASM_TEST_LINK_FLAGS +} " ) else @@ -396,13 +442,36 @@ GTest : : Main -jxl_extras +jxl_testlib - internal -jxl_testlib +jxl_extras - internal ) +if +( +TESTFILE +STREQUAL +. +. +/ +tools +/ +gauss_blur_test +. +cc +) +target_link_libraries +( +{ +TESTNAME +} +jxl_gauss_blur +) +endif +( +) # Output test diff --git a/third_party/jpeg-xl/lib/jxl_threads.cmake b/third_party/jpeg-xl/lib/jxl_threads.cmake index 4dab315eef9b..5579209c9c7e 100644 --- a/third_party/jpeg-xl/lib/jxl_threads.cmake +++ b/third_party/jpeg-xl/lib/jxl_threads.cmake @@ -311,6 +311,36 @@ jxl_threads_export h ) # +Place +all +public +headers +in +a +single +directory +. +foreach +( +path +{ +JPEGXL_INTERNAL_THREADS_PUBLIC_HEADERS +} +) +configure_file +( +{ +path +} +{ +path +} +COPYONLY +) +endforeach +( +) +# # # Add diff --git a/third_party/jpeg-xl/lib/threads/resizable_parallel_runner.cc b/third_party/jpeg-xl/lib/threads/resizable_parallel_runner.cc index 84a10b0db64a..f9e2fdf8dda9 100644 --- a/third_party/jpeg-xl/lib/threads/resizable_parallel_runner.cc +++ b/third_party/jpeg-xl/lib/threads/resizable_parallel_runner.cc @@ -3,6 +3,33 @@ include < jxl / +jxl_threads_export +. +h +> +# +include +< +jxl +/ +memory_manager +. +h +> +# +include +< +jxl +/ +parallel_runner +. +h +> +# +include +< +jxl +/ resizable_parallel_runner . h @@ -25,6 +52,16 @@ condition_variable # include < +cstddef +> +# +include +< +cstdint +> +# +include +< mutex > # diff --git a/third_party/jpeg-xl/lib/threads/thread_parallel_runner.cc b/third_party/jpeg-xl/lib/threads/thread_parallel_runner.cc index f866bc88894b..1c7dbff09815 100644 --- a/third_party/jpeg-xl/lib/threads/thread_parallel_runner.cc +++ b/third_party/jpeg-xl/lib/threads/thread_parallel_runner.cc @@ -3,6 +3,24 @@ include < jxl / +memory_manager +. +h +> +# +include +< +jxl +/ +parallel_runner +. +h +> +# +include +< +jxl +/ thread_parallel_runner . h @@ -16,6 +34,21 @@ h > # include +< +cstdint +> +# +include +< +cstdlib +> +# +include +< +thread +> +# +include " lib / diff --git a/third_party/jpeg-xl/lib/threads/thread_parallel_runner_internal.cc b/third_party/jpeg-xl/lib/threads/thread_parallel_runner_internal.cc index cec8e784432e..ae3c7707a15a 100644 --- a/third_party/jpeg-xl/lib/threads/thread_parallel_runner_internal.cc +++ b/third_party/jpeg-xl/lib/threads/thread_parallel_runner_internal.cc @@ -12,9 +12,43 @@ h # include < +jxl +/ +parallel_runner +. +h +> +# +include +< algorithm > # +include +< +atomic +> +# +include +< +cstddef +> +# +include +< +cstdint +> +# +include +< +mutex +> +# +include +< +thread +> +# if defined ( @@ -44,15 +78,6 @@ h " # endif -# -include -< -jxl -/ -thread_parallel_runner -. -h -> namespace { # diff --git a/third_party/jpeg-xl/plugins/gdk-pixbuf/CMakeLists.txt b/third_party/jpeg-xl/plugins/gdk-pixbuf/CMakeLists.txt index 2860792773e0..edff9d9a64ce 100644 --- a/third_party/jpeg-xl/plugins/gdk-pixbuf/CMakeLists.txt +++ b/third_party/jpeg-xl/plugins/gdk-pixbuf/CMakeLists.txt @@ -599,11 +599,9 @@ cache " " { -CMAKE_SOURCE_DIR +JPEGXL_TEST_DATA_PATH } / -testdata -/ jxl / blending