### Example Usage of Python libwebp Bindings Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webp/libwebp/swig/README.md Demonstrates how to import and use the libwebp Python bindings. It appends the installation path to sys.path and prints the decoder version and available attributes. ```python import glob import sys sys.path.append(glob.glob('pylocal/lib/python*/site-packages')[0]) from com.google.webp import libwebp print "libwebp decoder version: %x" % libwebp.WebPGetDecoderVersion() print "libwebp attributes:" for attr in dir(libwebp): print attr ``` -------------------------------- ### Install FFmpeg Source: https://github.com/telegrammessenger/telegram-ios/blob/master/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-7.1.1/INSTALL.md Install the built FFmpeg binaries and libraries. ```bash make install ``` -------------------------------- ### Release build and install with CMake Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libyuv/third_party/libyuv/docs/getting_started.md Configures a Release build for libyuv with a specified installation prefix, then builds and installs the library using CMake. ```bash mkdir out cd out cmake -DCMAKE_INSTALL_PREFIX="/usr/lib" -DCMAKE_BUILD_TYPE="Release" .. cmake --build . --config Release sudo cmake --build . --target install --config Release ``` -------------------------------- ### Enable Examples Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/third_party/highway/CMakeLists.txt Toggles the building of examples. Disabled by default. ```cmake set(HWY_ENABLE_EXAMPLES FALSE CACHE BOOL "Build examples") ``` -------------------------------- ### Install libjxl Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/BUILDING.md Install the compiled libjxl library using CMake's install command. ```bash sudo cmake --install . ``` -------------------------------- ### Enable Installation Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/third_party/highway/CMakeLists.txt Toggles the installation of the library. Enabled by default. ```cmake set(HWY_ENABLE_INSTALL ON CACHE BOOL "Install library") ``` -------------------------------- ### Compile and Run JNI libwebp Example Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webp/libwebp/swig/README.md Commands to compile the Java example and run it, specifying the library path. ```shell $ javac -cp libwebp.jar libwebp_jni_example.java $ java -Djava.library.path=. -cp libwebp.jar:. libwebp_jni_example ``` -------------------------------- ### Install Tool Binaries Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/tools/CMakeLists.txt Installs all defined tool binaries to the runtime directory. ```cmake install(TARGETS ${TOOL_BINARIES} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") message(STATUS "Building tools: ${TOOL_BINARIES}") ``` -------------------------------- ### Install Brotli using vcpkg Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/third_party/brotli/README.md Instructions for installing Brotli using the vcpkg dependency manager. Ensure vcpkg is cloned, bootstrapped, and integrated before installing. ```bash git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install ./vcpkg install brotli ``` -------------------------------- ### Installation Directives Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libyuv/third_party/libyuv/CMakeLists.txt Specifies which files and targets to install, including executables, libraries, and header files. ```cmake # install the conversion tool, .so, .a, and all the header files INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin ) INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib ) INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include ) ``` -------------------------------- ### Install libjpeg-turbo Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/mozjpeg/mozjpeg/BUILDING.md Build and install libjpeg-turbo using 'make install' or 'nmake install'. Use 'make uninstall' or 'nmake uninstall' to remove it. The installation path can be customized with CMAKE_INSTALL_PREFIX. ```bash make install ``` ```bash nmake install ``` -------------------------------- ### Example Quantization Table File Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/mozjpeg/mozjpeg/wizard.txt This file defines quantization tables for luminance and chrominance components. Comments start with '#'. Use this with the -qtables switch. ```text # Quantization tables given in Annex K (Clause K.1) of # Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994. # This is table 0 (the luminance table): 16 11 10 16 24 40 51 61 12 12 14 19 26 58 60 55 14 13 16 24 40 57 69 56 14 17 22 29 51 87 80 62 18 22 37 56 68 109 103 77 24 35 55 64 81 104 113 92 49 64 78 87 103 121 120 101 72 92 95 98 112 100 103 99 # This is table 1 (the chrominance table): 17 18 24 47 99 99 99 99 18 21 26 66 99 99 99 99 24 26 56 99 99 99 99 99 47 66 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 ``` -------------------------------- ### img2webp Example Usage Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webp/libwebp/doc/tools.md An example demonstrating how to use `img2webp` with multiple input files and specific frame options. ```shell img2webp -loop 2 in0.png -lossy in1.jpg -d 80 in2.tiff -o out.webp ``` -------------------------------- ### libyuv .gclient Configuration Example Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libyuv/third_party/libyuv/docs/getting_started.md An example of the .gclient file configuration for fetching the libyuv source. This file specifies the repository URL and other settings. ```json solutions = [ { "name" : "src", "url" : "https://chromium.googlesource.com/libyuv/libyuv", "deps_file" : "DEPS", "managed" : True, "custom_deps" : { }, "safesync_url": "", }, ]; ``` -------------------------------- ### Build and Install Linux Library with CMake (Release) Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libyuv/third_party/libyuv/docs/deprecated_builds.md Builds and installs libyuv in Release mode on Linux using CMake, specifying an installation prefix. ```bash mkdir out cd out cmake -DCMAKE_INSTALL_PREFIX="/usr/lib" -DCMAKE_BUILD_TYPE="Release" .. cmake --build . --config Release sudo cmake --build . --target install --config Release ``` -------------------------------- ### Build and Install Google Test Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webrtc/absl/CMake/README.md Builds and installs Google Test using CMake. Ensure CMAKE_INSTALL_PREFIX is set to your desired installation directory. ```bash cmake -S /source/googletest -B /build/googletest -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/installation/dir -DBUILD_GMOCK=ON cmake --build /build/googletest --target install ``` -------------------------------- ### Install Minimum Build Dependencies Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/doc/developing_in_debian.md Installs essential tools and libraries required for building the project. Ensure your system is up-to-date before running. ```bash sudo apt install cmake clang doxygen g++ extra-cmake-modules \ libgif-dev libjpeg-dev ninja-build libgoogle-perftools-dev ``` -------------------------------- ### Install libpng using Vcpkg Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/mozjpeg/mozjpeg/BUILDING.md Install libpng using the vcpkg dependency manager for Windows. This is a prerequisite for building MozJPEG with vcpkg. ```bash git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install vcpkg install libpng:x64-windows vcpkg install libpng:x64-windows-static ``` -------------------------------- ### Install Build Dependencies with vcpkg Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/doc/developing_in_windows_vcpkg.md Use vcpkg to install essential libraries for building JPEG XL on Windows. Ensure vcpkg is installed and tested before running these commands. ```bash vcpkg install gtest:x64-windows vcpkg install giflib:x64-windows vcpkg install libjpeg-turbo:x64-windows vcpkg install libpng:x64-windows vcpkg install zlib:x64-windows ``` -------------------------------- ### Install usrsctplib on Unix-like Systems Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/Manual.md Command to install the built usrsctplib library and header files to system directories, requiring root privileges. ```bash sudo make install ``` -------------------------------- ### Enable Standard CMake Installation Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webrtc/absl/CMake/README.md CMake option to enable standard installation procedures for Abseil. ```cmake -DABSL_ENABLE_INSTALL=ON ``` -------------------------------- ### Configure and Install Pkg-config Files Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/third_party/highway/CMakeLists.txt Configures pkg-config files for libhwy, libhwy-contrib, and libhwy-test based on build options and installs them to the pkgconfig directory. ```cmake set(HWY_LIBRARY_VERSION "${CMAKE_PROJECT_VERSION}") set(HWY_PC_FILES libhwy.pc) if (HWY_ENABLE_CONTRIB) list(APPEND HWY_PC_FILES libhwy-contrib.pc) endif() # HWY_ENABLE_CONTRIB if (HWY_ENABLE_TESTS) list(APPEND HWY_PC_FILES libhwy-test.pc) endif() # HWY_ENABLE_TESTS foreach (pc ${HWY_PC_FILES}) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${pc}.in" "${pc}" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${pc}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") endforeach() ``` -------------------------------- ### Install Highway using vcpkg Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/third_party/highway/README.md Installs the Highway library using the vcpkg package manager. ```bash vcpkg install highway ``` -------------------------------- ### Install Crossroad Dependencies Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/doc/developing_with_crossroad.md Installs necessary packages like python3-docutils and mingw-w64 for Crossroad. Ensure these are installed before proceeding with Crossroad setup. ```bash sudo aptitude install python3-docutils mingw-w64 ``` -------------------------------- ### Configure, Make, and Install with Autoconf Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webp/libwebp/doc/building.md Standard build process using autoconf tools. Generates the configure script, builds the library, and installs it to /usr/local. ```shell ./configure make make install ``` -------------------------------- ### Example WebP Lossless Bitstream Sequence Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webp/libwebp/doc/webp-lossless-bitstream-spec.txt Illustrates a potential sequence of elements in a WebP lossless bitstream, starting with the RIFF header and followed by image size and various coding information. ```bnf RIFF-header image-size %b1 subtract-green-tx %b1 predictor-tx %b0 color-cache-info %b0 prefix-codes lz77-coded-image ``` -------------------------------- ### Configure and Sync libyuv Repository Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libyuv/third_party/libyuv/docs/deprecated_builds.md Use these commands to set up the libyuv repository using gclient. Ensure depot tools are installed and follow the configuration steps for your target platform. ```bash gclient config https://chromium.googlesource.com/libyuv/libyuv gclient sync ``` ```bash solutions = [ { "name" : "libyuv", "url" : "https://chromium.googlesource.com/libyuv/libyuv", "deps_file" : "DEPS", "managed" : True, "custom_deps" : { }, "safesync_url": "", }, ]; ``` -------------------------------- ### Dilithium Test Vector Example Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/boringssl/src/crypto/dilithium/dilithium_tests.txt This is a test vector for the Dilithium algorithm, including parameters like count, seed, message length, and public key. It is used for verifying the correctness of Dilithium implementations. ```text count = 2 seed = BFF58FDA9DB4C2D8BD02E4647868D4A2FA12500A65CA4C9F918B505707FA775951018D9149C97D443EA16B07DD68435B mlen = 99 msg = 2B8C4B0F29363EAEE469A7E33524538AA066AE98980EAA19D1F10593203DA2143B9E9E1973F7FF0E6C6AAA3C0B900E50D003412EFE96DEECE3046D8C46BC7709228789775ABDF56AED6416C90033780CB7A4984815DA1B14660DCF34AA34BF82CEBBCF pk = CF39B474CE5D8EEB353C885DBC60D2A95546F4D2A97B9F0E46C5E17C1A8CC13949AFC995EB675DF6D845CDDFB6D490CF8A11F344C45CCFCB5DAC38B8C49AC6D19535E00E05C7C3DD4E6A20320D152470ADC1B70E84B174C8FE74970D0CBA5FE3915C198D8CAD29EFB72D6B0D50ABEF7205B0CFCD578232222329DC91BF372FA23A57F861D6330011C059683F7872BC9797DE9ADDA2CF4380A57F473F8C87BAB824FA73C753BA41812FC363514CB5452493494FD248E7AAA00A5D994D11C93F66C6E808930ED980E549D9055969427CB0F71B401FC7859BC36CB2ED27BEEA8986E391C3216BE6C0EFFD7A16F2ED5AC3B01B6FB6A2AC3569C5656DFA5BED74C4FB21DB654FAA6F6C0E02A6F47F33B8F61C830843C450ADB43D48C8E300B851ED673E05308300365186DA59763F01C5B43B9149AF66DE58151C15C200EA2BADAAB0E4710447917452FF351C0E4C2348934C54D6EB28C38700E6560888CE010DE5CE0D505F62FFD1B01F0DB73C586357504D82D49CC051DDE0913F50207F8E2AD80DB12E920DAF15BE172DBD7EB9AA367558155EAB628BE38FE19DF145BFE8E834C972CCA72ADCE315E70BF9C6CD98D4CBA35A5532BF20AD9C308377E6CBE5814EB43AC1AABC8956F1D6DD61E7538B17AC6D98291B83A4EBDC3CB98FEA53A52C5B206D1F1515EF7048F54E3EFD09850882760379B6F1A54F9D77212EAE5976033241B9D68FB9C744605F92F91F052E34DC5B4164A588E51D39166B6E69ABB0AB0E96785B47AE25E22C9D342390F5FD4C58156119ADC0325F61A0EEB4D7FDD12752A76A33E15082EAF249542C036C06C84B358392645B9C7CB16DE56F6BE5A824C86A8AA81A683131BB03E26DA0060807E4C0D3F35F3CA05E9C6C7A7C363F8F81B06FEE6482F450E6EC2A0F423C3B5F16552591671C7D3DAD856053E66CC06CAA2E07BD03A0B5D157146971C3B04502D783A54603A3227E7B24A02236E36CB619C41ECDF5167AF64B263A676E1F283033486ECE825FC4970E9233D361AE612D2ACA25ED0F2AD304A5BBD188D8ED98CA72F3508FF5B90703F1B3B7ABE37472E221D688132106FC6588041A519E59E429E1724EF941DA3846DB89141811036613B67B50AA8C8557B6BFEEB276D145E02EEB04BB8F3D9D792F3BCDCADDCAD9BA595D0674015AB5DA5B28FB35AB35D0BB0EC5CE3C95CF47CAABF65C5C328C87102E5191DCE582D0C77C9BC3F598322F1691C9BB216F9FE60510D40458B2125FBEE068F1EE3550427127490110D0E62F6A50E997006D810F0214A034DF24C48C7665DDDB00173A7CCC6D9C16A87C68ABBF851ABECEF965B35ED3B910EB143D07EA4CD8B59A7240001D3A507FB1AC168B4AEF067403D9C0FBCC205FE54755359E9C752A3080966967AC0466104AE8BC932B4CB073713073FDFCD5C7539A19F17831F0BF694EFE60F1266933EC8A78CAF25999B32F29A197FF1629FD2FF90EFBB48BF9ABA1455F4073640B766FA65CC0FD865BCD2EAAFB4EB14667BB8E726EA6C595E99D8E581AD17B489570FF86C67879F03D39415C929138D365CA56E00D2DD96A05A09B350575CC2DE9745C496BF61E7C903F2BBC1F61B2D7C4A11FDFB4080698D3B1BF25896F4D772953D10D2619C1E23E8F448F7A2BF3344E847CC30B893397CFF2E7A55849E18A22FF8605FC885284CD64AAF451D6B928E98B67C0F06C905BABF004C48AB3D4C27E4945FE761476DBCBA76A248BCD6A510E802B139067A5C136A31CFDFF7FAC810EB405A89058420D90218E96AFDC0522A7DA7F1F5E800098AA621088071AE09025F702E46DEE23C8024E8707F2C761B53E2FADF0E3E24C19CF9595731F162664B78AD28B52E5961BBCE7542AE0BD7D05B8E7637CC52F0640E21CB590EFDE7E68AE973D01B751A2D75031742EE2816FA8A70A57899616DBD48D3627B568BE82E409D30DAC4CA9AD18588FAE49EE18E ``` -------------------------------- ### Setting up JPEG stdio source Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/mozjpeg/mozjpeg/libjpeg.txt This snippet shows how to initialize the standard input/output source module for libjpeg. Ensure the file is opened in binary mode to prevent data corruption. ```c FILE *infile; ... if ((infile = fopen(filename, "rb")) == NULL) { fprintf(stderr, "can't open %s\n", filename); exit(1); } jpeg_stdio_src(&cinfo, infile); ``` -------------------------------- ### Install Crossroad Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/doc/developing_with_crossroad.md Installs the Crossroad tool itself using pip. If installation fails, consider downloading and installing directly from the Crossroad homepage. ```bash pip3 install crossroad ``` -------------------------------- ### Configure Abseil Installation Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webrtc/absl/CMakeLists.txt Handles the installation of Abseil targets, configuration files, and headers. It includes checks for unsupported system-wide installation paths and ensures package configuration files are correctly generated and installed. ```cmake if(ABSL_ENABLE_INSTALL) # absl:lts-remove-begin(system installation is supported for LTS releases) # We don't support system-wide installation list(APPEND SYSTEM_INSTALL_DIRS "/usr/local" "/usr" "/opt/" "/opt/local" "c:/Program Files/${PROJECT_NAME}") if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX IN_LIST SYSTEM_INSTALL_DIRS) message(WARNING "\n The default and system-level install directories are unsupported except in LTS \n releases of Abseil. Please set CMAKE_INSTALL_PREFIX to install Abseil in your \n source or build tree directly.\n ") endif() # absl:lts-remove-end # install as a subdirectory only install(EXPORT ${PROJECT_NAME}Targets NAMESPACE absl:: DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" ) configure_package_config_file( CMake/abslConfig.cmake.in "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" ) install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" ) # Abseil only has a version in LTS releases. This mechanism is accomplished # Abseil's internal Copybara (https://github.com/google/copybara) workflows and # isn't visible in the CMake buildsystem itself. if(absl_VERSION) write_basic_package_version_file( "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" COMPATIBILITY ExactVersion ) install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" ) endif() # absl_VERSION install(DIRECTORY absl DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.inc" PATTERN "*.h" PATTERN "copts" EXCLUDE PATTERN "testdata" EXCLUDE ) # Rewrite options.h to use the compiled ABI. file(READ "absl/base/options.h" ABSL_INTERNAL_OPTIONS_H_CONTENTS) # Handle features that require at least C++20. if (ABSL_INTERNAL_AT_LEAST_CXX20) foreach(FEATURE "ORDERING") string(REPLACE "#define ABSL_OPTION_USE_STD_${FEATURE} 2" "#define ABSL_OPTION_USE_STD_${FEATURE} 1" ``` -------------------------------- ### Set up MING64 Environment Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/doc/developing_in_windows_msys.md Install essential development tools and libraries for the MING64 build environment. The `--needed` flag prevents reinstallation of already present packages. ```bash pacman -S --needed base-devel mingw-w64-x86_64-toolchain pacman -S git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja \ mingw-w64-x86_64-gtest mingw-w64-x86_64-giflib \ mingw-w64-x86_64-libpng mingw-w64-x86_64-libjpeg-turbo ``` -------------------------------- ### Set Installation Paths Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webp/libwebp/CMakeLists.txt Defines installation paths for libraries and include directories, ensuring they are absolute or relative to the installation prefix. ```cmake set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix "${prefix}") if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") set(libdir "${CMAKE_INSTALL_LIBDIR}") else() set(libdir "${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") endif() if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") set(includedir "${CMAKE_INSTALL_INCLUDEDIR}") else() set(includedir "${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") endif() ``` -------------------------------- ### Install JPEG Library and Targets Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/mozjpeg/mozjpeg/sharedlib/CMakeLists.txt Installs the 'jpeg' shared library, its export file, and related targets to their designated locations based on CMake installation variables. It also installs the cjpeg, djpeg, and jpegtran executables. ```cmake install(TARGETS jpeg EXPORT ${CMAKE_PROJECT_NAME}Targets INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS cjpeg djpeg jpegtran RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ``` -------------------------------- ### Install JNI Shared Library Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/tools/CMakeLists.txt Installs the JNI shared library to a specified destination directory. The installation directory is determined by JPEGXL_INSTALL_JNIDIR, defaulting to CMAKE_INSTALL_LIBDIR. ```cmake if(NOT DEFINED JPEGXL_INSTALL_JNIDIR) set(JPEGXL_INSTALL_JNIDIR ${CMAKE_INSTALL_LIBDIR}) endif() install(TARGETS jxl_jni DESTINATION ${JPEGXL_INSTALL_JNIDIR}) ``` -------------------------------- ### Build vwebp using makefile.unix Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webp/libwebp/doc/tools.md Compile the `vwebp` visualization tool on Unix-like systems using the provided Makefile. This command builds the executable in the examples directory. ```shell $ make -f makefile.unix examples/vwebp ``` -------------------------------- ### Configure FFmpeg Build Source: https://github.com/telegrammessenger/telegram-ios/blob/master/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-7.1.1/INSTALL.md Run the configure script to set up the build environment. Use '--help' for a list of options. Building out of tree is supported by providing an absolute path to the configure script. ```bash ./configure ``` ```bash configure --help ``` ```bash /ffmpegdir/ffmpeg/configure ``` -------------------------------- ### Install Highway Library and Headers Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/third_party/highway/CMakeLists.txt Installs the Highway library targets, exports targets for external use, and installs all header files while preserving their directory structure. ```cmake install(TARGETS hwy EXPORT hwy_targets LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") # Install all the headers keeping the relative path to the current directory # when installing them. foreach (source ${HWY_SOURCES}) if ("${source}" MATCHES ".h$") get_filename_component(dirname "${source}" DIRECTORY) install(FILES "${source}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${dirname}") endif() endforeach() ``` -------------------------------- ### Install Brotli Targets Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/third_party/brotli/CMakeLists.txt Installs the brotli executable, libraries, and include directories if BROTLI_BUNDLED_MODE is not enabled. Specifies installation destinations based on standard CMake variables. ```cmake if(NOT BROTLI_BUNDLED_MODE) install( TARGETS brotli RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) install( TARGETS ${BROTLI_LIBRARIES_CORE} ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) install( DIRECTORY ${BROTLI_INCLUDE_DIRS}/brotli DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) endif() # BROTLI_BUNDLED_MODE ``` -------------------------------- ### Prepare RISC-V toolchain and QEMU Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libyuv/third_party/libyuv/docs/getting_started.md Downloads and builds the RISC-V clang toolchain and QEMU emulator if they are not already present. This is a prerequisite for cross-compiling for RISC-V. ```bash ./riscv_script/prepare_toolchain_qemu.sh ``` -------------------------------- ### Install Emscripten SDK Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/doc/building_wasm.md Installs the Emscripten SDK, which is required for building WebAssembly artifacts. Ensure the OPT environment variable is set to the desired installation directory. ```bash cd $OPT # Get the emsdk repo. git clone https://github.com/emscripten-core/emsdk.git # Enter that directory. cd emsdk # Download and install the latest SDK tools. ./emsdk install latest # Make the "latest" SDK "active" for the current user. (writes ~/.emscripten file) ./emsdk activate latest ``` -------------------------------- ### Install Abseil Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webrtc/absl/CMake/README.md Installs Abseil to the specified CMAKE_INSTALL_PREFIX after building. ```bash cmake --build /temporary/build/abseil-cpp --target install ``` -------------------------------- ### Install Clang and Set Compiler Variables Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/BUILDING.md Install the Clang compiler and set the CC and CXX environment variables to use Clang for compilation. Recommended for version 7 or newer. ```bash sudo apt install clang export CC=clang CXX=clang++ ``` -------------------------------- ### Build Static Example Binaries Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/examples/CMakeLists.txt This section defines executables for one-shot decoding and encoding that are statically linked against libjxl. It uses the previously defined static interface libraries. ```cmake add_executable(decode_oneshot_static decode_oneshot.cc) target_link_libraries(decode_oneshot_static -static StaticJxl StaticJxlThreads) add_executable(encode_oneshot_static encode_oneshot.cc) target_link_libraries(encode_oneshot_static -static StaticJxl StaticJxlThreads) ``` -------------------------------- ### Starting Compression (Abbreviated Image) Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/mozjpeg/mozjpeg/libjpeg.txt This C code demonstrates how to start the JPEG compression process for an abbreviated image. Passing `FALSE` to `jpeg_start_compress` indicates that the image will be abbreviated. ```c jpeg_start_compress(&cinfo); ``` -------------------------------- ### Display webpinfo Help Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webp/libwebp/doc/tools.md Show the usage instructions and available options for the `webpinfo` tool, which analyzes WebP file structure and headers. ```shell webpinfo [options] in_files ``` -------------------------------- ### Android .gclient Configuration Example Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libyuv/third_party/libyuv/docs/getting_started.md An example of the .gclient file configuration for fetching libyuv source targeting Android. It includes the target_os setting for Android and Linux. ```json solutions = [ { "name" : "src", "url" : "https://chromium.googlesource.com/libyuv/libyuv", "deps_file" : "DEPS", "managed" : True, "custom_deps" : { }, "safesync_url": "", }, ]; target_os = ["android", "linux"]; ``` -------------------------------- ### Install JPEG XL via Homebrew Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/BUILDING_OSX.md Installs the JPEG XL library and its binaries using the Homebrew package manager. Ensure Homebrew is installed and up-to-date before running. ```bash brew install jpeg-xl ``` -------------------------------- ### Build JXL WASM Demo Site Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/tools/wasm_demo/README.md Execute the `build_site.py` script to build the demo site. Provide the source path, binary path, and output path as arguments. ```bash python3 ./tools/wasm_demo/build_site.py ./tools/wasm_demo/ ./build-wasm32/tools/wasm_demo/ /path/to/demo-site ``` -------------------------------- ### Benchmark Output Example Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/third_party/highway/hwy/contrib/sort/README.md Example output from the sort benchmark, showing instruction set, algorithm, key type, distribution, key count, and throughput in MB/s. ```text [ RUN ] BenchSortGroup/BenchSort.BenchAllSort/AVX3 AVX3: std: f32: uniform32: 1.00E+06 54 MB/s ( 1 threads) AVX3: vq: f32: uniform32: 1.00E+06 1143 MB/s ( 1 threads) ``` -------------------------------- ### Install a Specific Package Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/doc/developing_in_windows_msys.md Install a package, specifying the group if necessary. For tools that need compiler awareness, ensure you install the version corresponding to your build environment (e.g., `mingw64`). ```bash pacman -S mingw-w64-x86_64-cmake ``` -------------------------------- ### Install ytasm Executable Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/yasm/yasm-1.3.0/frontends/tasm/CMakeLists.txt Installs the 'ytasm' executable to the 'bin' directory at runtime. ```cmake INSTALL(TARGETS ytasm RUNTIME DESTINATION bin) ``` -------------------------------- ### Initialize JPEG Compression Object (C) Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/mozjpeg/mozjpeg/example.txt This snippet shows the initial steps for setting up a JPEG compression object using the MozJPEG library. It includes error handler initialization and object creation. ```c #include "jpeglib.h" #include /* * IMAGE DATA FORMATS: * * The standard input image format is a rectangular array of pixels, with * each pixel having the same number of "component" values (color channels). * Each pixel row is an array of JSAMPLEs (which typically are unsigned chars). * If you are working with color data, then the color values for each pixel * must be adjacent in the row; for example, R,G,B,R,G,B,R,G,B,... for 24-bit * RGB color. * * For this example, we'll assume that this data structure matches the way * our application has stored the image in memory, so we can just pass a * pointer to our image buffer. In particular, let's say that the image is * RGB color and is described by: */ extern JSAMPLE *image_buffer; /* Points to large array of R,G,B-order data */ extern int image_height; /* Number of rows in image */ extern int image_width; /* Number of columns in image */ /* * Sample routine for JPEG compression. We assume that the target file name * and a compression quality factor are passed in. */ GLOBAL(void) write_JPEG_file(char *filename, int quality) { /* This struct contains the JPEG compression parameters and pointers to * working space (which is allocated as needed by the JPEG library). * It is possible to have several such structures, representing multiple * compression/decompression processes, in existence at once. We refer * to any one struct (and its associated working data) as a "JPEG object". */ struct jpeg_compress_struct cinfo; /* This struct represents a JPEG error handler. It is declared separately * because applications often want to supply a specialized error handler * (see the second half of this file for an example). But here we just * take the easy way out and use the standard error handler, which will * print a message on stderr and call exit() if compression fails. * Note that this struct must live as long as the main JPEG parameter * struct, to avoid dangling-pointer problems. */ struct jpeg_error_mgr jerr; /* More stuff */ FILE *outfile; /* target file */ JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ int row_stride; /* physical row width in image buffer */ /* Step 1: allocate and initialize JPEG compression object */ /* We have to set up the error handler first, in case the initialization * step fails. (Unlikely, but it could happen if you are out of memory.) * This routine fills in the contents of struct jerr, and returns jerr's * address which we place into the link field in cinfo. */ cinfo.err = jpeg_std_error(&jerr); /* Now we can initialize the JPEG compression object. */ jpeg_create_compress(&cinfo); ``` -------------------------------- ### Install googletest on Debian Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/third_party/highway/README.md Installs the googletest development package on Debian-based systems. ```bash sudo apt install libgtest-dev ``` -------------------------------- ### Install CMake on Debian Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/third_party/highway/README.md Installs CMake on Debian-based systems using apt. ```bash sudo apt install cmake ``` -------------------------------- ### Install build prerequisites for Gradle on Debian-like systems Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webp/libwebp/doc/building.md Installs essential build tools like build-essential and gradle on Debian-based systems for building with Gradle. ```shell $ sudo apt-get install build-essential gradle ``` -------------------------------- ### Install Yasm Executable Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/yasm/yasm-1.3.0/frontends/yasm/CMakeLists.txt Installs the built Yasm executable to the 'bin' directory at runtime. ```cmake INSTALL(TARGETS yasm RUNTIME DESTINATION bin) ``` -------------------------------- ### Call-Site Migration Example Source: https://github.com/telegrammessenger/telegram-ios/blob/master/docs/superpowers/plans/2026-04-17-mediaresource-to-enginemediaresource-wave-2.md Demonstrates the mechanical change required at call sites when migrating from MediaResource to EngineMediaResource. This involves wrapping raw resources or updating closure parameters. ```swift engine.peers.uploadedPeerPhoto(resource: someRawResource) → engine.peers.uploadedPeerPhoto(resource: EngineMediaResource(someRawResource)) ``` ```swift engine.peers.updatePeerPhoto(..., mapResourceToAvatarSizes: { resource, representations in ... resource ... }) — the closure's resource is now EngineMediaResource. Any expression inside the closure that previously treated resource as raw protocol (e.g. postbox.mediaBox.resourceData(resource)) must use resource._asResource(). ``` -------------------------------- ### Include GNU Install Directories Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/third_party/brotli/CMakeLists.txt Includes the standard CMake module for defining installation directories. ```cmake include(GNUInstallDirs) ``` -------------------------------- ### FFmpeg Activate Callback Example Source: https://github.com/telegrammessenger/telegram-ios/blob/master/submodules/ffmpeg/Sources/FFMpeg/ffmpeg-7.1.1/doc/filter_design.txt Illustrates the typical logic within an activate callback for managing input and output links, consuming frames, and handling status changes. Use this when implementing complex filters requiring detailed control over data flow and error handling. ```c ret = ff_outlink_get_status(outlink); if (ret) { ff_inlink_set_status(inlink, ret); return 0; } if (priv->next_frame) { /* use it */ return 0; } ret = ff_inlink_consume_frame(inlink, &frame); if (ret < 0) return ret; if (ret) { /* use it */ return 0; } ret = ff_inlink_acknowledge_status(inlink, &status, &pts); if (ret) { /* flush */ ff_outlink_set_status(outlink, status, pts); return 0; } if (ff_outlink_frame_wanted(outlink)) { ff_inlink_request_frame(inlink); return 0; } return FFERROR_NOT_READY; ``` -------------------------------- ### Configure Cross-Compiler Wrappers Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/third_party/brotli/CMakeLists.txt Sets up QEMU wrappers for ARM and AArch64 cross-compilation environments to run tests. ```cmake if(NOT BROTLI_DISABLE_TESTS) if ("${CMAKE_C_COMPILER}" MATCHES "^.*/arm-linux-gnueabihf-.*$") message(STATUS "Detected arm-linux-gnueabihf cross-compilation") set(BROTLI_WRAPPER "qemu-arm") set(BROTLI_WRAPPER_LD_PREFIX "/usr/arm-linux-gnueabihf") endif() if ("${CMAKE_C_COMPILER}" MATCHES "^.*/arm-linux-gnueabi-.*$") message(STATUS "Detected arm-linux-gnueabi cross-compilation") set(BROTLI_WRAPPER "qemu-arm") set(BROTLI_WRAPPER_LD_PREFIX "/usr/arm-linux-gnueabi") endif() if ("${CMAKE_C_COMPILER}" MATCHES "^.*/aarch64-linux-gnu-.*$") message(STATUS "Detected aarch64-linux-gnu cross-compilation") set(BROTLI_WRAPPER "qemu-aarch64") set(BROTLI_WRAPPER_LD_PREFIX "/usr/aarch64-linux-gnu") endif() endif() ``` -------------------------------- ### Scan Script Syntax Example Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/mozjpeg/mozjpeg/wizard.txt Demonstrates equivalent scan definitions in a scan script file, showing flexibility in formatting with whitespace, comments, and punctuation. ```text 0 1 2: 0 63 0 0; 0,1,2 : 0-63, 0,0 ; ``` -------------------------------- ### Install uglify-js Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/tools/wasm_demo/README.md Install the uglify-js tool globally using npm, which is a dependency for the build script. ```bash npm install uglify-js -g ``` -------------------------------- ### Install GIMP Plugin Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/plugins/gimp/CMakeLists.txt Installs the compiled GIMP plugin executable to the appropriate GIMP plug-ins directory. ```cmake pkg_get_variable(GIMP_LIB_DIR gimp-2.0 gimplibdir) install(TARGETS file-jxl RUNTIME DESTINATION "${GIMP_LIB_DIR}/plug-ins/file-jxl/") ``` -------------------------------- ### Build and Run Abseil Tests with CMake Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webrtc/absl/CMake/README.md Command-line example to configure, build, and run Abseil tests using CMake. This requires Abseil tests to be enabled and Google Test to be available. ```bash cd path/to/abseil-cpp mkdir build cd build cmake -DABSL_BUILD_TESTING=ON -DABSL_USE_GOOGLETEST_HEAD=ON .. make -j ctest ``` -------------------------------- ### Install Required Dependencies (Debian/Ubuntu) Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/libjxl/libjxl/BUILDING.md Install the necessary dependencies for compiling libjxl on Debian or Ubuntu-based systems. ```bash sudo apt install cmake pkg-config libbrotli-dev ``` -------------------------------- ### Run client with UDP Encapsulation Source: https://github.com/telegrammessenger/telegram-ios/blob/master/third-party/webrtc/dependencies/third_party/usrsctp/usrsctplib/Manual.md Example of running the client with UDP encapsulation. Requires server address, server port, and matching encapsulation ports. The local port is set to 0. ```bash ./client 127.0.0.1 9 0 22222 11111 ``` ```bash client.exe 192.168.0.1 9 0 22222 11111 ```