### Install Documentation and Example Files Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Installs various documentation files, READMEs, and example C source files. These are placed in the documentation directory. ```cmake install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/src/example.c ${CMAKE_CURRENT_SOURCE_DIR}/src/tjcomp.c ${CMAKE_CURRENT_SOURCE_DIR}/src/tjdecomp.c ${CMAKE_CURRENT_SOURCE_DIR}/src/tjtran.c ${CMAKE_CURRENT_SOURCE_DIR}/doc/libjpeg.txt ${CMAKE_CURRENT_SOURCE_DIR}/doc/structure.txt ${CMAKE_CURRENT_SOURCE_DIR}/doc/usage.txt ${CMAKE_CURRENT_SOURCE_DIR}/doc/wizard.txt ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc) if(WITH_JAVA) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/java/TJComp.java ${CMAKE_CURRENT_SOURCE_DIR}/java/TJDecomp.java ${CMAKE_CURRENT_SOURCE_DIR}/java/TJTran.java DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc) endif() ``` -------------------------------- ### Install libjpeg-turbo using Make Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/BUILDING.md Install libjpeg-turbo using the build system by running 'make install'. Use 'make uninstall' to remove it. The installation directory can be customized with CMAKE_INSTALL_PREFIX. ```bash make install ``` ```bash make uninstall ``` -------------------------------- ### Configure Example Executable Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/sharedlib/CMakeLists.txt Builds a simple 'example' executable using the 'jpeg' library. This is useful for demonstrating basic JPEG operations. ```cmake if(WITH_TESTS) add_executable(example ../src/example.c) target_link_libraries(example jpeg) endif() ``` -------------------------------- ### Install Project Tools Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Installs command-line tools such as rdjpgcom and wrjpgcom. These are installed to the runtime destination directory. ```cmake if(WITH_TOOLS) install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin) endif() ``` -------------------------------- ### Install JPEG Library and Tools Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/sharedlib/CMakeLists.txt Installs the 'jpeg' library and associated tools (cjpeg, djpeg, jpegtran) to their designated directories. Includes optional PDB file installation for MSVC. ```cmake install(TARGETS jpeg EXPORT ${CMAKE_PROJECT_NAME}Targets INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin) if(WITH_TOOLS) install(TARGETS cjpeg djpeg jpegtran RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin) endif() if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC_LIKE AND CMAKE_C_LINKER_SUPPORTS_PDB) install(FILES "$" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin OPTIONAL) endif() ``` -------------------------------- ### Example Quantization Table File for cjpeg Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/doc/wizard.txt This example file demonstrates the format for providing custom quantization tables, including comments and the default luminance and chrominance tables. ```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 ``` -------------------------------- ### Set Standard Install Subdirectories Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt This section defines standard installation subdirectories like DATAROOTDIR, DOCDIR, and LIBDIR, particularly when the installation prefix is the default. It adjusts the library directory name (e.g., lib64, libx32, lib32) based on the system's bitness and compiler ABI for Unix-like systems. This ensures a structured installation layout. ```cmake if(CMAKE_INSTALL_PREFIX STREQUAL "${CMAKE_INSTALL_DEFAULT_PREFIX}") set(CMAKE_INSTALL_DEFAULT_DATAROOTDIR "") set(CMAKE_INSTALL_DEFAULT_DOCDIR "/doc") set(CMAKE_INSTALL_DEFAULT_JAVADIR "/classes") if(UNIX AND NOT APPLE) if(BITS EQUAL 64) set(CMAKE_INSTALL_DEFAULT_LIBDIR "lib64") elseif(CMAKE_C_COMPILER_ABI MATCHES "ELF X32") set(CMAKE_INSTALL_DEFAULT_LIBDIR "libx32") else() set(CMAKE_INSTALL_DEFAULT_LIBDIR "lib32") endif() endif() endif() include(cmakescripts/GNUInstallDirs.cmake) ``` -------------------------------- ### Add Test for example compress comparison Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Adds a test to compare the MD5 checksum of the compressed image generated by the 'example' tool. This ensures the compression output is consistent. ```cmake add_test(NAME example-${sample_bits}bit-${libtype}-compress-cmp COMMAND md5cmp ${MD5_JPEG_EXAMPLE_COMPRESS} ${testout}-example.jpg) ``` -------------------------------- ### Install Core Header Files Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Installs essential header files for the project, including jconfig.h, jerror.h, jmorecfg.h, and jpeglib.h. These are placed in the include directory. ```cmake install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h ${CMAKE_CURRENT_SOURCE_DIR}/src/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/src/jmorecfg.h ${CMAKE_CURRENT_SOURCE_DIR}/src/jpeglib.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include) ``` -------------------------------- ### Install PkgConfig Files Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Installs pkgconfig files for the project's libraries, enabling easier integration with other build systems. This includes files for libjpeg and libturbojpeg if enabled. ```cmake install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libjpeg.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT lib) if(WITH_TURBOJPEG) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libturbojpeg.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT lib) endif() ``` -------------------------------- ### Configure Installation Directories Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt This script sets default installation prefixes based on the operating system and build bitness. It ensures that the installation path is correctly determined for Windows (MSVC or GCC) and Unix-like systems. The `CMAKE_INSTALL_PREFIX` is set to a default value if it hasn't been explicitly provided by the user. ```cmake if(WIN32) if(MSVC_LIKE) set(CMAKE_INSTALL_DEFAULT_PREFIX "c:/${CMAKE_PROJECT_NAME}") else() set(CMAKE_INSTALL_DEFAULT_PREFIX "c:/${CMAKE_PROJECT_NAME}-gcc") endif() if(BITS EQUAL 64) set(CMAKE_INSTALL_DEFAULT_PREFIX "${CMAKE_INSTALL_DEFAULT_PREFIX}64") endif() else() if(NOT CMAKE_INSTALL_DEFAULT_PREFIX) set(CMAKE_INSTALL_DEFAULT_PREFIX /opt/${CMAKE_PROJECT_NAME}) endif() endif() if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_DEFAULT_PREFIX}" CACHE PATH "Directory into which to install ${CMAKE_PROJECT_NAME} (default: ${CMAKE_INSTALL_DEFAULT_PREFIX})") endif() message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Add Test for example compress Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Adds a test for the 'example' tool to compress an image with a quality setting of 95. Supports 12-bit precision if specified. ```cmake add_test(NAME example-${sample_bits}bit-${libtype}-compress COMMAND example${suffix} compress -q 95 ${EXAMPLE_12BIT_ARG} ${testout}-example.jpg) ``` -------------------------------- ### Install TurboJPEG Shared Library Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Installs the TurboJPEG shared library, including headers, archives, and runtime components. Also installs associated tools like tjbench if enabled. ```cmake set(EXE ${CMAKE_EXECUTABLE_SUFFIX}) if(WITH_TURBOJPEG) if(ENABLE_SHARED) install(TARGETS turbojpeg EXPORT ${CMAKE_PROJECT_NAME}Targets INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin) if(WITH_TOOLS) install(TARGETS tjbench RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin) endif() if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC_LIKE AND CMAKE_C_LINKER_SUPPORTS_PDB) install(FILES "$" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin OPTIONAL) endif() endif() if(ENABLE_STATIC) install(TARGETS turbojpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib) if(NOT ENABLE_SHARED) if(GENERATOR_IS_MULTI_CONFIG) set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\\ {CMAKE_INSTALL_CONFIG_NAME}") else() set(DIR ${CMAKE_CURRENT_BINARY_DIR}) endif() if(WITH_TOOLS) install(PROGRAMS ${DIR}/tjbench-static${EXE} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin RENAME tjbench${EXE}) endif() endif() endif() install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/turbojpeg.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT include) endif() ``` -------------------------------- ### Install CMake Configuration Files Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Installs CMake configuration files for the project, including Config.cmake and ConfigVersion.cmake, and exports targets for easy use in other CMake projects. ```cmake install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/${CMAKE_PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/${CMAKE_PROJECT_NAME}ConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME} COMPONENT lib) install(EXPORT ${CMAKE_PROJECT_NAME}Targets NAMESPACE ${CMAKE_PROJECT_NAME}:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME} COMPONENT lib) ``` -------------------------------- ### Add Test for example decompress Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Adds a test for the 'example' tool to decompress a JPEG image back to a PPM format. Supports 12-bit precision if specified. ```cmake add_test(NAME example-${sample_bits}bit-${libtype}-decompress COMMAND example${suffix} decompress ${EXAMPLE_12BIT_ARG} ${TESTIMAGES}/${TESTORIG} ${testout}-example.ppm) ``` -------------------------------- ### Add Test for example decompress comparison Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Adds a test to compare the MD5 checksum of the decompressed PPM image generated by the 'example' tool. This ensures the decompression output is consistent. ```cmake add_test(NAME example-${sample_bits}bit-${libtype}-decompress-cmp COMMAND md5cmp ${MD5_PPM_EXAMPLE_DECOMPRESS} ${testout}-example.ppm) ``` -------------------------------- ### Report Installation Directories Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt This macro iterates through a list of standard installation directory variables (e.g., BINDIR, LIBDIR) and reports their final values. It indicates whether the variable was explicitly set or inherited from the default. The `mark_as_advanced` command is used to clear the cache for these variables after reporting, allowing them to be re-evaluated if necessary. ```cmake macro(report_directory var) if(CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_FULL_${var}) message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}}") else() message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}} (${CMAKE_INSTALL_FULL_${var}})") endif() mark_as_advanced(CLEAR CMAKE_INSTALL_${var}) endmacro() set(DIRLIST "BINDIR;DATAROOTDIR;DOCDIR;INCLUDEDIR;LIBDIR") if(UNIX) list(APPEND DIRLIST "MANDIR") endif() foreach(dir ${DIRLIST}) report_directory(${dir}) endforeach() ``` -------------------------------- ### Install Man Pages for Tools Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Installs man pages for various command-line tools if the system is Unix-like or MinGW and tools are enabled. These are placed in the man1 directory. ```cmake if(UNIX OR MINGW) if(WITH_TOOLS) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/doc/cjpeg.1 ${CMAKE_CURRENT_SOURCE_DIR}/doc/djpeg.1 ${CMAKE_CURRENT_SOURCE_DIR}/doc/jpegtran.1 ${CMAKE_CURRENT_SOURCE_DIR}/doc/rdjpgcom.1 ${CMAKE_CURRENT_SOURCE_DIR}/doc/wrjpgcom.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT man) endif() endif() ``` -------------------------------- ### Install JPEG Static Library and Tools Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Installs the JPEG static library and associated tools like cjpeg, djpeg, and jpegtran. This configuration is applied when static libraries are enabled and shared libraries are not. ```cmake if(ENABLE_STATIC) install(TARGETS jpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib) if(NOT ENABLE_SHARED) if(GENERATOR_IS_MULTI_CONFIG) set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\\ {CMAKE_INSTALL_CONFIG_NAME}") else() set(DIR ${CMAKE_CURRENT_BINARY_DIR}) endif() if(WITH_TOOLS) install(PROGRAMS ${DIR}/cjpeg-static${EXE} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin RENAME cjpeg${EXE}) install(PROGRAMS ${DIR}/djpeg-static${EXE} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin RENAME djpeg${EXE}) install(PROGRAMS ${DIR}/jpegtran-static${EXE} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT bin RENAME jpegtran${EXE}) endif() endif() endif() ``` -------------------------------- ### K&R Style Indentation Example Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/doc/coderules.txt Demonstrates the K&R style of indentation for code blocks, using two spaces per indentation level. ```c if (test) { then-part; } else { else-part; } ``` -------------------------------- ### Configure Fuzz Binary Directory Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/fuzz/CMakeLists.txt Sets the installation directory for fuzz targets. This variable must be specified by the user; otherwise, the build will fail. ```cmake set(FUZZ_BINDIR "" CACHE PATH "Directory into which fuzz targets should be installed") if(NOT FUZZ_BINDIR) message(FATAL_ERROR "FUZZ_BINDIR must be specified.") endif() message(STATUS "FUZZ_BINDIR = ${FUZZ_BINDIR}") ``` -------------------------------- ### Scan Script Syntax Example (Successive Approximation) Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/doc/wizard.txt This scan script creates a successive-approximation JPEG file, equivalent to the default progressive script for YCbCr images. It starts with an initial DC scan for Y, Cb, Cr, excluding the lowest bit. ```text # Initial DC scan for Y,Cb,Cr (lowest bit not sent) 0,1,2: 0-0, 0, 1 ; ``` -------------------------------- ### Create example-static Executable for Tests Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Configures the example-static executable for testing purposes, compiling the example C file and linking it with the jpeg-static library. This is conditional on WITH_TESTS being enabled. ```cmake add_executable(example-static src/example.c) target_link_libraries(example-static jpeg-static) ``` -------------------------------- ### Initialize JPEG Compression Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/doc/libjpeg.txt Sets up JPEG compression parameters and initializes the compression process. Ensure all parameters are set before calling this. ```c cinfo.input_components = 3; /* # of color components per pixel */ cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ jpeg_set_defaults(&cinfo); /* Make optional parameter settings here */ ``` -------------------------------- ### tj3Init() - Create TurboJPEG Instance Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/doc/turbojpeg/group___turbo_j_p_e_g.html Initializes a new TurboJPEG instance. Returns a handle to the instance or NULL if an error occurs. ```APIDOC ## tj3Init() ### Description Create a new TurboJPEG instance. ### Method `tj3Init` ### Parameters #### Path Parameters - **initType** (int) - Required - One of the initialization options. ### Returns - A handle to the newly-created instance, or NULL if an error occurred (see tj3GetErrorStr()). ``` -------------------------------- ### Install TurboJPEG Java JAR Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/java/CMakeLists.txt Installs the built turbojpeg-java JAR file to the system's Java directory. The installation destination is determined by CMAKE_INSTALL_JAVADIR, with a fallback for older CMake versions. ```cmake if(NOT DEFINED CMAKE_INSTALL_DEFAULT_JAVADIR) set(CMAKE_INSTALL_DEFAULT_JAVADIR "/java") endif() GNUInstallDirs_set_install_dir(JAVADIR "The directory into which Java classes should be installed") GNUInstallDirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_JAVADIR CMAKE_INSTALL_JAVADIR) set(CMAKE_INSTALL_JAVADIR ${CMAKE_INSTALL_JAVADIR} PARENT_SCOPE) set(CMAKE_INSTALL_FULL_JAVADIR ${CMAKE_INSTALL_FULL_JAVADIR} PARENT_SCOPE) report_directory(JAVADIR) if(CMAKE_VERSION VERSION_EQUAL "3.4" OR CMAKE_VERSION VERSION_GREATER "3.4") install_jar(turbojpeg-java DESTINATION ${CMAKE_INSTALL_JAVADIR} COMPONENT java) else() install_jar(turbojpeg-java ${CMAKE_INSTALL_JAVADIR}) endif() mark_as_advanced(CLEAR CMAKE_INSTALL_JAVADIR) ``` -------------------------------- ### Build libjpeg-turbo on Unix-like Systems Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/BUILDING.md Use this command to build libjpeg-turbo on Unix and Unix-like systems. Ensure you are in the build directory and provide the source directory. ```bash cd {build_directory} cmake -G"Unix Makefiles" [additional CMake flags] {source_directory} make ``` -------------------------------- ### 32-bit MinGW Build CMake and Make Commands Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/BUILDING.md Execute CMake with the specified toolchain file and then run make to build libjpeg-turbo for 32-bit MinGW. ```bash cd {build_directory} cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \ -DCMAKE_INSTALL_PREFIX={install_path} \ [additional CMake flags] {source_directory} make ``` -------------------------------- ### Enable libjpeg v7 API/ABI Emulation Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/BUILDING.md Use the '-DWITH_JPEG7=1' flag to build a version of libjpeg-turbo that is API/ABI-compatible with libjpeg v7. ```bash -DWITH_JPEG7=1 ``` -------------------------------- ### Starting Output Pass for Progressive JPEG Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/doc/libjpeg.txt When displaying progressive images one pass per scan, use this call to `jpeg_start_output`. The second parameter indicates the input scan number to be displayed, starting from 1. ```c jpeg_start_output(&cinfo, cinfo.input_scan_number); ``` -------------------------------- ### Implement CameraFragment for Basic Usage Source: https://github.com/ernestp/androidusbcamera/blob/master/README.md Extend CameraFragment and override essential methods like getRootView, getCameraView, and getCameraViewContainer for basic camera preview. Implement onCameraState for handling camera events. ```kotlin class DemoFragment: CameraFragment() { private var mViewBinding: FragmentUvcBinding? = null override fun getRootView(inflater: LayoutInflater, container: ViewGroup?): View? { if (mViewBinding == null) { mViewBinding = FragmentUvcBinding.inflate(inflater, container, false) } return mViewBinding?.root } // if you want offscreen render // please return null override fun getCameraView(): IAspectRatio? { return mViewBinding?.tvCameraRender } // if you want offscreen render // please return null, the same as getCameraView() override fun getCameraViewContainer(): ViewGroup? { return mViewBinding?.container } // camera open status callback override fun onCameraState(self: ICamera, code: ICameraStateCallBack.State, msg: String?) { when (code) { ICameraStateCallBack.State.OPENED -> handleCameraOpened() ICameraStateCallBack.State.CLOSED -> handleCameraClosed() ICameraStateCallBack.State.ERROR -> handleCameraError() } } override fun getGravity(): Int = Gravity.TOP } ``` -------------------------------- ### GET /getJPEGBuf Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html Returns the JPEG buffer associated with this decompressor instance. ```APIDOC ## GET /getJPEGBuf ### Description Returns the JPEG buffer associated with this decompressor instance. ### Method GET ### Endpoint /getJPEGBuf ### Response #### Success Response (200) - **jpeg_buffer** (byte[]) - The JPEG buffer. #### Response Example { "jpeg_buffer": "[byte array representing JPEG data]" } ``` -------------------------------- ### Get Compression Parameter Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html Retrieves the value of a specified compression parameter. ```APIDOC ## GET /TJ/PARAM ### Description Get the value of a compression parameter. ### Method GET ### Endpoint /TJ/PARAM ### Parameters #### Query Parameters - **param** (string) - Required - One of [`TJ.PARAM_*`](TJ.html#PARAM_STOPONWARNING) ### Response #### Success Response (200) - **value** (integer) - The value of the specified compression parameter, or -1 if the value is unknown. #### Response Example ```json { "value": 1 } ``` ``` -------------------------------- ### Build libjpeg-turbo for iOS Simulator (arm64) Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/BUILDING.md Adapt the iOS arm64 build script for the iOS simulator by changing 'iPhoneOS' to 'iPhoneSimulator' and adjusting the version-min flag. This is for Macs with Apple silicon CPUs. ```bash # Replace iPhoneOS with iPhoneSimulator and -miphoneos-version-min with -miphonesimulator-version-min ``` -------------------------------- ### Compression Parameter Configuration Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html Methods for setting and getting compression parameters. ```APIDOC ## Configure Compression Parameters ### Description These methods allow you to set and retrieve the values of specific compression parameters. ### Methods #### set ##### Description Set the value of a compression parameter. ##### Parameters - **param** (int) - Required - One of `TJ.PARAM_*`. - **value** (int) - Required - Value of the compression parameter (refer to `parameter documentation`.) #### get ##### Description Get the value of a compression parameter. ##### Parameters - **param** (int) - Required - One of `TJ.PARAM_*`. ##### Returns - `int` - The value of the compression parameter. ``` -------------------------------- ### Scan Script Syntax Example (Progressive Spectral Selection) Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/doc/wizard.txt This scan script demonstrates a progressive JPEG file using only spectral selection. It includes an interleaved DC scan for Y, Cb, Cr, followed by multiple AC scans for Y, Cb, and Cr components. ```text # Interleaved DC scan for Y,Cb,Cr: 0,1,2: 0-0, 0, 0 ; # AC scans: 0: 1-2, 0, 0 ; # First two Y AC coefficients 0: 3-5, 0, 0 ; # Three more 1: 1-63, 0, 0 ; # All AC coefficients for Cb 2: 1-63, 0, 0 ; # All AC coefficients for Cr 0: 6-9, 0, 0 ; # More Y coefficients 0: 10-63, 0, 0 ; # Remaining Y coefficients ``` -------------------------------- ### Parameter Management Methods Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html Methods for getting and setting decompression parameters. ```APIDOC ## get (int) ### Description Get the value of a decompression parameter. ### Method `int` ### Endpoint `[get(int)] ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) `int` #### Response Example None ``` -------------------------------- ### 64-bit MinGW Build Configuration Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/BUILDING.md Create a toolchain.cmake file to configure a 64-bit MinGW build on Un*x systems. Specify the system name, processor, and compiler paths. ```cmake set(CMAKE_SYSTEM_NAME Windows) set(CMAKE_SYSTEM_PROCESSOR AMD64) set(CMAKE_C_COMPILER {mingw_binary_path}/x86_64-w64-mingw32-gcc) set(CMAKE_RC_COMPILER {mingw_binary_path}/x86_64-w64-mingw32-windres) ``` -------------------------------- ### Parameter Management Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/doc/turbojpeg/group___turbo_j_p_e_g.html Functions for setting and getting parameter values for TurboJPEG operations. ```APIDOC ## TJPARAMSETGET ### Description Functions to set and get the values of various parameters for TurboJPEG operations. ### Functions - `int tj3Set(tjhandle handle, int param, int value)`: Sets the value of a specified parameter. - `int tj3Get(tjhandle handle, int param)`: Gets the current value of a specified parameter. ``` -------------------------------- ### Enable libjpeg v8 API/ABI Emulation Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/BUILDING.md Use the '-DWITH_JPEG8=1' flag to build a version of libjpeg-turbo that is API/ABI-compatible with libjpeg v8. ```bash -DWITH_JPEG8=1 ``` -------------------------------- ### Get Compressed Size Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html Retrieves the size of the image generated by the most recent compression operation. ```APIDOC ## getCompressedSize ### Description Returns the size of the image (in bytes) generated by the most recent compression operation. ### Method public int getCompressedSize() ### Response #### Success Response (200) - **size** (int) - The size of the image in bytes generated by the most recent compression operation. ``` -------------------------------- ### Build libjpeg-turbo with Visual C++ (IDE) Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/BUILDING.md Configure the build for Visual Studio IDE by specifying the generator. Use 'Win64' in the generator name for a 64-bit build. A separate build directory is required for 32-bit and 64-bit builds. ```bash cd {build_directory} cmake -G"Visual Studio 10" [additional CMake flags] {source_directory} ``` -------------------------------- ### TurboJPEG Decompressor - Get Parameter Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html Retrieves the current value of a specific decompression parameter. ```APIDOC ## GET /api/decompressor/parameters/{param} ### Description Gets the value of a decompression parameter. ### Method GET ### Endpoint /api/decompressor/parameters/{param} ### Parameters #### Path Parameters - **param** (int) - Required - One of `TJ.PARAM_*` constants. ### Response #### Success Response (200) - **value** (int) - The current value of the specified decompression parameter. #### Response Example { "value": 1 } #### Error Response (404) - **message** (string) - Indicates the parameter value is unknown. #### Error Response Example { "message": "Parameter value unknown." } ``` -------------------------------- ### Build libjpeg-turbo for Android (x86 32-bit) Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/BUILDING.md General recipe script for building libjpeg-turbo for Android x86 (32-bit) using CMake and the Android NDK. Set NDK_PATH, TOOLCHAIN, and ANDROID_VERSION variables. ```bash # Set these variables to suit your needs NDK_PATH={full path to the NDK directory-- for example, /opt/android/android-ndk-r16b} TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier, and "clang" must be used with NDK r17c and later} ANDROID_VERSION={The minimum version of Android to support-- for example, "16", "19", etc.} cd {build_directory} cmake -G"Unix Makefiles" \ -DANDROID_ABI=x86 \ -DANDROID_PLATFORM=android-${ANDROID_VERSION} \ -DANDROID_TOOLCHAIN=${TOOLCHAIN} \ -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \ [additional CMake flags] {source_directory} make ``` -------------------------------- ### Get Scaling Factors Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/doc/turbojpeg/group___turbo_j_p_e_g.html Returns a list of fractional scaling factors that the JPEG decompressor supports. ```APIDOC ## tj3GetScalingFactors ### Description Returns a list of fractional scaling factors that the JPEG decompressor supports. ### Method DLLEXPORT tjscalingfactor * ### Endpoint tj3GetScalingFactors(int *numScalingFactors) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Get Supported Scaling Factors Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/java/doc/org/libjpegturbo/turbojpeg/TJ.html Retrieves a list of fractional scaling factors supported by the JPEG decompressor. ```APIDOC ## getScalingFactors ### Description Returns a list of fractional scaling factors that the JPEG decompressor supports. ### Method `public static TJScalingFactor[] getScalingFactors()` ### Response #### Success Response (200) - **scalingFactors** (TJScalingFactor[]) - An array of supported scaling factors. ``` -------------------------------- ### Create Linux Distribution Packages Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/BUILDING.md Generate distribution packages for Linux. 'make rpm' creates a binary RPM, 'make srpm' creates a source RPM, and 'make deb' creates a Debian-style binary package. ```bash make rpm ``` ```bash make srpm ``` ```bash make deb ``` -------------------------------- ### Include Package Information Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/CMakeLists.txt Includes the PackageInfo.cmake script, which likely contains definitions related to package metadata or installation. ```cmake include(cmakescripts/PackageInfo.cmake) ``` -------------------------------- ### Build libjpeg-turbo with Visual C++ (Command Line) Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/BUILDING.md Build libjpeg-turbo using NMake Makefiles with Visual C++. This command generates a Release build. For Debug builds, omit '-DCMAKE_BUILD_TYPE=Release'. ```bash cd {build_directory} cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release [additional CMake flags] {source_directory} nmake ``` -------------------------------- ### Create macOS Distribution Package Source: https://github.com/ernestp/androidusbcamera/blob/master/libuvc/src/main/jni/libjpeg-turbo-3.1.3/BUILDING.md Create a Mac disk image package. This requires pkgbuild and productbuild. For universal binaries, set the SECONDARY_BUILD CMake variable to include cross-compiled binaries. ```bash make dmg ```