diff --git a/code/client/CMakeLists.txt b/code/client/CMakeLists.txt index 259e055b..da43e611 100644 --- a/code/client/CMakeLists.txt +++ b/code/client/CMakeLists.txt @@ -63,7 +63,7 @@ set(OLD_VALUE ${BUILD_SHARED_LIBS}) set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) if(USE_INTERNAL_MAD) - add_subdirectory("../libmad" "./libmad" EXCLUDE_FROM_ALL) + add_subdirectory("../thirdparty/libmad" "./libmad" EXCLUDE_FROM_ALL) target_link_libraries(omohclient INTERFACE mad) else() include(FindPackageHandleStandardArgs) diff --git a/code/curl-7.54.0/include/README b/code/curl-7.54.0/include/README deleted file mode 100644 index 6eb73b2b..00000000 --- a/code/curl-7.54.0/include/README +++ /dev/null @@ -1,55 +0,0 @@ - _ _ ____ _ - ___| | | | _ \| | - / __| | | | |_) | | - | (__| |_| | _ <| |___ - \___|\___/|_| \_\_____| - -Include files for libcurl, external users. - -They're all placed in the curl subdirectory here for better fit in any kind -of environment. You must include files from here using... - - #include - -... style and point the compiler's include path to the directory holding the -curl subdirectory. It makes it more likely to survive future modifications. - -NOTE FOR LIBCURL HACKERS - -The following notes apply to libcurl version 7.19.0 and later. - -* The distributed curl/curlbuild.h file is only intended to be used on systems - which can not run the also distributed configure script. - -* The distributed curlbuild.h file is generated as a copy of curlbuild.h.dist - when the libcurl source code distribution archive file is originally created. - -* If you check out from git on a non-configure platform, you must run the - appropriate buildconf* script to set up curlbuild.h and other local files - before being able of compiling the library. - -* On systems capable of running the configure script, the configure process - will overwrite the distributed include/curl/curlbuild.h file with one that - is suitable and specific to the library being configured and built, which - is generated from the include/curl/curlbuild.h.in template file. - -* If you intend to distribute an already compiled libcurl library you _MUST_ - also distribute along with it the generated curl/curlbuild.h which has been - used to compile it. Otherwise the library will be of no use for the users of - the library that you have built. It is _your_ responsibility to provide this - file. No one at the curl project can know how you have built the library. - -* File curl/curlbuild.h includes platform and configuration dependent info, - and must not be modified by anyone. Configure script generates it for you. - -* We cannot assume anything else but very basic compiler features being - present. While libcurl requires an ANSI C compiler to build, some of the - earlier ANSI compilers clearly can't deal with some preprocessor operators. - -* Newlines must remain unix-style for older compilers' sake. - -* Comments must be written in the old-style /* unnested C-fashion */ - -To figure out how to do good and portable checks for features, operating -systems or specific hardwarare, a very good resource is Bjorn Reese's -collection at http://predef.sf.net/ diff --git a/code/curl-7.54.0/include/curl/curlbuild.h b/code/curl-7.54.0/include/curl/curlbuild.h deleted file mode 100644 index f596c607..00000000 --- a/code/curl-7.54.0/include/curl/curlbuild.h +++ /dev/null @@ -1,586 +0,0 @@ -#ifndef __CURL_CURLBUILD_H -#define __CURL_CURLBUILD_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* ================================================================ */ -/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * - * See file include/curl/curlbuild.h.in, run configure, and forget - * that this file exists it is only used for non-configure systems. - * But you can keep reading if you want ;-) - * - */ - -/* ================================================================ */ -/* NOTES FOR NON-CONFIGURE SYSTEMS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * - * Nothing in this file is intended to be modified or adjusted by the - * curl library user nor by the curl library builder. - * - * If you think that something actually needs to be changed, adjusted - * or fixed in this file, then, report it on the libcurl development - * mailing list: https://cool.haxx.se/mailman/listinfo/curl-library/ - * - * Try to keep one section per platform, compiler and architecture, - * otherwise, if an existing section is reused for a different one and - * later on the original is adjusted, probably the piggybacking one can - * be adversely changed. - * - * In order to differentiate between platforms/compilers/architectures - * use only compiler built in predefined preprocessor symbols. - * - * This header file shall only export symbols which are 'curl' or 'CURL' - * prefixed, otherwise public name space would be polluted. - * - * NOTE 2: - * ------- - * - * For any given platform/compiler curl_off_t must be typedef'ed to a - * 64-bit wide signed integral data type. The width of this data type - * must remain constant and independent of any possible large file - * support settings. - * - * As an exception to the above, curl_off_t shall be typedef'ed to a - * 32-bit wide signed integral data type if there is no 64-bit type. - * - * As a general rule, curl_off_t shall not be mapped to off_t. This - * rule shall only be violated if off_t is the only 64-bit data type - * available and the size of off_t is independent of large file support - * settings. Keep your build on the safe side avoiding an off_t gating. - * If you have a 64-bit off_t then take for sure that another 64-bit - * data type exists, dig deeper and you will find it. - * - * NOTE 3: - * ------- - * - * Right now you might be staring at file include/curl/curlbuild.h.dist or - * at file include/curl/curlbuild.h, this is due to the following reason: - * file include/curl/curlbuild.h.dist is renamed to include/curl/curlbuild.h - * when the libcurl source code distribution archive file is created. - * - * File include/curl/curlbuild.h.dist is not included in the distribution - * archive. File include/curl/curlbuild.h is not present in the git tree. - * - * The distributed include/curl/curlbuild.h file is only intended to be used - * on systems which can not run the also distributed configure script. - * - * On systems capable of running the configure script, the configure process - * will overwrite the distributed include/curl/curlbuild.h file with one that - * is suitable and specific to the library being configured and built, which - * is generated from the include/curl/curlbuild.h.in template file. - * - * If you check out from git on a non-configure platform, you must run the - * appropriate buildconf* script to set up curlbuild.h and other local files. - * - */ - -/* ================================================================ */ -/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */ -/* ================================================================ */ - -#ifdef CURL_SIZEOF_LONG -# error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_SOCKLEN_T -# error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_SOCKLEN_T -# error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined -#endif - -#ifdef CURL_TYPEOF_CURL_OFF_T -# error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_T -# error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_FORMAT_CURL_OFF_TU -# error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined -#endif - -#ifdef CURL_FORMAT_OFF_T -# error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined -#endif - -#ifdef CURL_SIZEOF_CURL_OFF_T -# error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_T -# error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined -#endif - -#ifdef CURL_SUFFIX_CURL_OFF_TU -# error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined -#endif - -/* ================================================================ */ -/* EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY */ -/* ================================================================ */ - -#if defined(__DJGPP__) || defined(__GO32__) -# if defined(__DJGPP__) && (__DJGPP__ > 1) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# else -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__SALFORDC__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__BORLANDC__) -# if (__BORLANDC__ < 0x520) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# else -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T __int64 -# define CURL_FORMAT_CURL_OFF_T "I64d" -# define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T i64 -# define CURL_SUFFIX_CURL_OFF_TU ui64 -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__TURBOC__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__WATCOMC__) -# if defined(__386__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T __int64 -# define CURL_FORMAT_CURL_OFF_T "I64d" -# define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T i64 -# define CURL_SUFFIX_CURL_OFF_TU ui64 -# else -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__POCC__) -# if (__POCC__ < 280) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# elif defined(_MSC_VER) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T __int64 -# define CURL_FORMAT_CURL_OFF_T "I64d" -# define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T i64 -# define CURL_SUFFIX_CURL_OFF_TU ui64 -# else -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__LCC__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__SYMBIAN32__) -# if defined(__EABI__) /* Treat all ARM compilers equally */ -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# elif defined(__CW32__) -# pragma longlong on -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# elif defined(__VC32__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T __int64 -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__MWERKS__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(_WIN32_WCE) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T __int64 -# define CURL_FORMAT_CURL_OFF_T "I64d" -# define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T i64 -# define CURL_SUFFIX_CURL_OFF_TU ui64 -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__MINGW32__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "I64d" -# define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__VMS) -# if defined(__VAX) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# else -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__OS400__) -# if defined(__ILEC400__) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 -# define CURL_PULL_SYS_TYPES_H 1 -# define CURL_PULL_SYS_SOCKET_H 1 -# endif - -#elif defined(__MVS__) -# if defined(__IBMC__) || defined(__IBMCPP__) -# if defined(_ILP32) -# define CURL_SIZEOF_LONG 4 -# elif defined(_LP64) -# define CURL_SIZEOF_LONG 8 -# endif -# if defined(_LONG_LONG) -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# elif defined(_LP64) -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# else -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 -# define CURL_PULL_SYS_TYPES_H 1 -# define CURL_PULL_SYS_SOCKET_H 1 -# endif - -#elif defined(__370__) -# if defined(__IBMC__) || defined(__IBMCPP__) -# if defined(_ILP32) -# define CURL_SIZEOF_LONG 4 -# elif defined(_LP64) -# define CURL_SIZEOF_LONG 8 -# endif -# if defined(_LONG_LONG) -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# elif defined(_LP64) -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# else -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 -# define CURL_PULL_SYS_TYPES_H 1 -# define CURL_PULL_SYS_SOCKET_H 1 -# endif - -#elif defined(TPF) -# define CURL_SIZEOF_LONG 8 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -/* ===================================== */ -/* KEEP MSVC THE PENULTIMATE ENTRY */ -/* ===================================== */ - -#elif defined(_MSC_VER) -# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T __int64 -# define CURL_FORMAT_CURL_OFF_T "I64d" -# define CURL_FORMAT_CURL_OFF_TU "I64u" -# define CURL_FORMAT_OFF_T "%I64d" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T i64 -# define CURL_SUFFIX_CURL_OFF_TU ui64 -# else -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 4 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T int -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 - -/* ===================================== */ -/* KEEP GENERIC GCC THE LAST ENTRY */ -/* ===================================== */ - -#elif defined(__GNUC__) -# if !defined(__LP64__) && (defined(__ILP32__) || \ - defined(__i386__) || defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \ - defined(__sparc__) || defined(__mips__) || defined(__sh__)) -# define CURL_SIZEOF_LONG 4 -# define CURL_TYPEOF_CURL_OFF_T long long -# define CURL_FORMAT_CURL_OFF_T "lld" -# define CURL_FORMAT_CURL_OFF_TU "llu" -# define CURL_FORMAT_OFF_T "%lld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T LL -# define CURL_SUFFIX_CURL_OFF_TU ULL -# elif defined(__LP64__) || \ - defined(__x86_64__) || defined(__ppc64__) || defined(__powerpc64__) || defined(__sparc64__) -# define CURL_SIZEOF_LONG 8 -# define CURL_TYPEOF_CURL_OFF_T long -# define CURL_FORMAT_CURL_OFF_T "ld" -# define CURL_FORMAT_CURL_OFF_TU "lu" -# define CURL_FORMAT_OFF_T "%ld" -# define CURL_SIZEOF_CURL_OFF_T 8 -# define CURL_SUFFIX_CURL_OFF_T L -# define CURL_SUFFIX_CURL_OFF_TU UL -# endif -# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURL_SIZEOF_CURL_SOCKLEN_T 4 -# define CURL_PULL_SYS_TYPES_H 1 -# define CURL_PULL_SYS_SOCKET_H 1 - -#else -# error "Unknown non-configure build target!" - Error Compilation_aborted_Unknown_non_configure_build_target -#endif - -/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */ -/* sys/types.h is required here to properly make type definitions below. */ -#ifdef CURL_PULL_SYS_TYPES_H -# include -#endif - -/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ -/* sys/socket.h is required here to properly make type definitions below. */ -#ifdef CURL_PULL_SYS_SOCKET_H -# include -#endif - -/* Data type definition of curl_socklen_t. */ - -#ifdef CURL_TYPEOF_CURL_SOCKLEN_T - typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; -#endif - -/* Data type definition of curl_off_t. */ - -#ifdef CURL_TYPEOF_CURL_OFF_T - typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; -#endif - -#endif /* __CURL_CURLBUILD_H */ diff --git a/code/curl-7.54.0/include/curl/curlrules.h b/code/curl-7.54.0/include/curl/curlrules.h deleted file mode 100644 index 0abd9f71..00000000 --- a/code/curl-7.54.0/include/curl/curlrules.h +++ /dev/null @@ -1,239 +0,0 @@ -#ifndef __CURL_CURLRULES_H -#define __CURL_CURLRULES_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* ================================================================ */ -/* COMPILE TIME SANITY CHECKS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * - * All checks done in this file are intentionally placed in a public - * header file which is pulled by curl/curl.h when an application is - * being built using an already built libcurl library. Additionally - * this file is also included and used when building the library. - * - * If compilation fails on this file it is certainly sure that the - * problem is elsewhere. It could be a problem in the curlbuild.h - * header file, or simply that you are using different compilation - * settings than those used to build the library. - * - * Nothing in this file is intended to be modified or adjusted by the - * curl library user nor by the curl library builder. - * - * Do not deactivate any check, these are done to make sure that the - * library is properly built and used. - * - * You can find further help on the libcurl development mailing list: - * https://cool.haxx.se/mailman/listinfo/curl-library/ - * - * NOTE 2 - * ------ - * - * Some of the following compile time checks are based on the fact - * that the dimension of a constant array can not be a negative one. - * In this way if the compile time verification fails, the compilation - * will fail issuing an error. The error description wording is compiler - * dependent but it will be quite similar to one of the following: - * - * "negative subscript or subscript is too large" - * "array must have at least one element" - * "-1 is an illegal array size" - * "size of array is negative" - * - * If you are building an application which tries to use an already - * built libcurl library and you are getting this kind of errors on - * this file, it is a clear indication that there is a mismatch between - * how the library was built and how you are trying to use it for your - * application. Your already compiled or binary library provider is the - * only one who can give you the details you need to properly use it. - */ - -/* - * Verify that some macros are actually defined. - */ - -#ifndef CURL_SIZEOF_LONG -# error "CURL_SIZEOF_LONG definition is missing!" - Error Compilation_aborted_CURL_SIZEOF_LONG_is_missing -#endif - -#ifndef CURL_TYPEOF_CURL_SOCKLEN_T -# error "CURL_TYPEOF_CURL_SOCKLEN_T definition is missing!" - Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_is_missing -#endif - -#ifndef CURL_SIZEOF_CURL_SOCKLEN_T -# error "CURL_SIZEOF_CURL_SOCKLEN_T definition is missing!" - Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_is_missing -#endif - -#ifndef CURL_TYPEOF_CURL_OFF_T -# error "CURL_TYPEOF_CURL_OFF_T definition is missing!" - Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_is_missing -#endif - -#ifndef CURL_FORMAT_CURL_OFF_T -# error "CURL_FORMAT_CURL_OFF_T definition is missing!" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_is_missing -#endif - -#ifndef CURL_FORMAT_CURL_OFF_TU -# error "CURL_FORMAT_CURL_OFF_TU definition is missing!" - Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_is_missing -#endif - -#ifndef CURL_SIZEOF_CURL_OFF_T -# error "CURL_SIZEOF_CURL_OFF_T definition is missing!" - Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_is_missing -#endif - -#ifndef CURL_SUFFIX_CURL_OFF_T -# error "CURL_SUFFIX_CURL_OFF_T definition is missing!" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_is_missing -#endif - -#ifndef CURL_SUFFIX_CURL_OFF_TU -# error "CURL_SUFFIX_CURL_OFF_TU definition is missing!" - Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_is_missing -#endif - -/* - * Macros private to this header file. - */ - -#define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1 - -#define CurlchkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1 - -/* - * Verify that the size previously defined and expected for long - * is the same as the one reported by sizeof() at compile time. - */ - -typedef char - __curl_rule_01__ - [CurlchkszEQ(long, CURL_SIZEOF_LONG)]; - -/* - * Verify that the size previously defined and expected for - * curl_off_t is actually the the same as the one reported - * by sizeof() at compile time. - */ - -typedef char - __curl_rule_02__ - [CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)]; - -/* - * Verify at compile time that the size of curl_off_t as reported - * by sizeof() is greater or equal than the one reported for long - * for the current compilation. - */ - -typedef char - __curl_rule_03__ - [CurlchkszGE(curl_off_t, long)]; - -/* - * Verify that the size previously defined and expected for - * curl_socklen_t is actually the the same as the one reported - * by sizeof() at compile time. - */ - -typedef char - __curl_rule_04__ - [CurlchkszEQ(curl_socklen_t, CURL_SIZEOF_CURL_SOCKLEN_T)]; - -/* - * Verify at compile time that the size of curl_socklen_t as reported - * by sizeof() is greater or equal than the one reported for int for - * the current compilation. - */ - -typedef char - __curl_rule_05__ - [CurlchkszGE(curl_socklen_t, int)]; - -/* ================================================================ */ -/* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */ -/* ================================================================ */ - -/* - * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow - * these to be visible and exported by the external libcurl interface API, - * while also making them visible to the library internals, simply including - * curl_setup.h, without actually needing to include curl.h internally. - * If some day this section would grow big enough, all this should be moved - * to its own header file. - */ - -/* - * Figure out if we can use the ## preprocessor operator, which is supported - * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__ - * or __cplusplus so we need to carefully check for them too. - */ - -#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \ - defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \ - defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \ - defined(__ILEC400__) - /* This compiler is believed to have an ISO compatible preprocessor */ -#define CURL_ISOCPP -#else - /* This compiler is believed NOT to have an ISO compatible preprocessor */ -#undef CURL_ISOCPP -#endif - -/* - * Macros for minimum-width signed and unsigned curl_off_t integer constants. - */ - -#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551) -# define __CURL_OFF_T_C_HLPR2(x) x -# define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x) -# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \ - __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T) -# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \ - __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU) -#else -# ifdef CURL_ISOCPP -# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix -# else -# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix -# endif -# define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix) -# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T) -# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU) -#endif - -/* - * Get rid of macros private to this header file. - */ - -#undef CurlchkszEQ -#undef CurlchkszGE - -#endif /* __CURL_CURLRULES_H */ diff --git a/code/curl-7.54.0/include/curl/system.h b/code/curl-7.54.0/include/curl/system.h deleted file mode 100644 index ed3a55c9..00000000 --- a/code/curl-7.54.0/include/curl/system.h +++ /dev/null @@ -1,484 +0,0 @@ -#ifndef __CURL_SYSTEM_H -#define __CURL_SYSTEM_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* - * This header is supposed to eventually replace curlbuild.h. This little one - * is still learning. During the experimental phase, this header files - * defines symbols using the prefixes CURLSYS_ or curlsys_. When we feel - * confident enough, we replace curlbuild.h with this file and rename all - * prefixes to CURL_ and curl_. - */ - -/* - * Try to keep one section per platform, compiler and architecture, otherwise, - * if an existing section is reused for a different one and later on the - * original is adjusted, probably the piggybacking one can be adversely - * changed. - * - * In order to differentiate between platforms/compilers/architectures use - * only compiler built in predefined preprocessor symbols. - * - * curl_off_t - * ---------- - * - * For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit - * wide signed integral data type. The width of this data type must remain - * constant and independent of any possible large file support settings. - * - * As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit - * wide signed integral data type if there is no 64-bit type. - * - * As a general rule, curl_off_t shall not be mapped to off_t. This rule shall - * only be violated if off_t is the only 64-bit data type available and the - * size of off_t is independent of large file support settings. Keep your - * build on the safe side avoiding an off_t gating. If you have a 64-bit - * off_t then take for sure that another 64-bit data type exists, dig deeper - * and you will find it. - * - */ - -#if defined(__DJGPP__) || defined(__GO32__) -# if defined(__DJGPP__) && (__DJGPP__ > 1) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long long -# define CURLSYS_FORMAT_CURL_OFF_T "lld" -# define CURLSYS_FORMAT_CURL_OFF_TU "llu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# else -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 4 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# endif -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__SALFORDC__) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 4 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__BORLANDC__) -# if (__BORLANDC__ < 0x520) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 4 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# else -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T __int64 -# define CURLSYS_FORMAT_CURL_OFF_T "I64d" -# define CURLSYS_FORMAT_CURL_OFF_TU "I64u" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T i64 -# define CURLSYS_SUFFIX_CURL_OFF_TU ui64 -# endif -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__TURBOC__) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 4 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__WATCOMC__) -# if defined(__386__) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T __int64 -# define CURLSYS_FORMAT_CURL_OFF_T "I64d" -# define CURLSYS_FORMAT_CURL_OFF_TU "I64u" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T i64 -# define CURLSYS_SUFFIX_CURL_OFF_TU ui64 -# else -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 4 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# endif -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__POCC__) -# if (__POCC__ < 280) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 4 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# elif defined(_MSC_VER) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T __int64 -# define CURLSYS_FORMAT_CURL_OFF_T "I64d" -# define CURLSYS_FORMAT_CURL_OFF_TU "I64u" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T i64 -# define CURLSYS_SUFFIX_CURL_OFF_TU ui64 -# else -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long long -# define CURLSYS_FORMAT_CURL_OFF_T "lld" -# define CURLSYS_FORMAT_CURL_OFF_TU "llu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# endif -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__LCC__) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 4 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__SYMBIAN32__) -# if defined(__EABI__) /* Treat all ARM compilers equally */ -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long long -# define CURLSYS_FORMAT_CURL_OFF_T "lld" -# define CURLSYS_FORMAT_CURL_OFF_TU "llu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# elif defined(__CW32__) -# pragma longlong on -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long long -# define CURLSYS_FORMAT_CURL_OFF_T "lld" -# define CURLSYS_FORMAT_CURL_OFF_TU "llu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# elif defined(__VC32__) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T __int64 -# define CURLSYS_FORMAT_CURL_OFF_T "lld" -# define CURLSYS_FORMAT_CURL_OFF_TU "llu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# endif -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T unsigned int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__MWERKS__) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long long -# define CURLSYS_FORMAT_CURL_OFF_T "lld" -# define CURLSYS_FORMAT_CURL_OFF_TU "llu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(_WIN32_WCE) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T __int64 -# define CURLSYS_FORMAT_CURL_OFF_T "I64d" -# define CURLSYS_FORMAT_CURL_OFF_TU "I64u" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T i64 -# define CURLSYS_SUFFIX_CURL_OFF_TU ui64 -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__MINGW32__) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long long -# define CURLSYS_FORMAT_CURL_OFF_T "I64d" -# define CURLSYS_FORMAT_CURL_OFF_TU "I64u" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 -# define CURLSYS_PULL_SYS_TYPES_H 1 -# define CURLSYS_PULL_WS2TCPIP_H 1 - -#elif defined(__VMS) -# if defined(__VAX) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 4 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# else -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long long -# define CURLSYS_FORMAT_CURL_OFF_T "lld" -# define CURLSYS_FORMAT_CURL_OFF_TU "llu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# endif -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T unsigned int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__OS400__) -# if defined(__ILEC400__) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long long -# define CURLSYS_FORMAT_CURL_OFF_T "lld" -# define CURLSYS_FORMAT_CURL_OFF_TU "llu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 -# define CURLSYS_PULL_SYS_TYPES_H 1 -# define CURLSYS_PULL_SYS_SOCKET_H 1 -# endif - -#elif defined(__MVS__) -# if defined(__IBMC__) || defined(__IBMCPP__) -# if defined(_ILP32) -# define CURLSYS_SIZEOF_LONG 4 -# elif defined(_LP64) -# define CURLSYS_SIZEOF_LONG 8 -# endif -# if defined(_LONG_LONG) -# define CURLSYS_TYPEOF_CURL_OFF_T long long -# define CURLSYS_FORMAT_CURL_OFF_T "lld" -# define CURLSYS_FORMAT_CURL_OFF_TU "llu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# elif defined(_LP64) -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# else -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 4 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# endif -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 -# define CURLSYS_PULL_SYS_TYPES_H 1 -# define CURLSYS_PULL_SYS_SOCKET_H 1 -# endif - -#elif defined(__370__) -# if defined(__IBMC__) || defined(__IBMCPP__) -# if defined(_ILP32) -# define CURLSYS_SIZEOF_LONG 4 -# elif defined(_LP64) -# define CURLSYS_SIZEOF_LONG 8 -# endif -# if defined(_LONG_LONG) -# define CURLSYS_TYPEOF_CURL_OFF_T long long -# define CURLSYS_FORMAT_CURL_OFF_T "lld" -# define CURLSYS_FORMAT_CURL_OFF_TU "llu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# elif defined(_LP64) -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# else -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 4 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# endif -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 -# define CURLSYS_PULL_SYS_TYPES_H 1 -# define CURLSYS_PULL_SYS_SOCKET_H 1 -# endif - -#elif defined(TPF) -# define CURLSYS_SIZEOF_LONG 8 -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -#elif defined(__TINYC__) /* also known as tcc */ - -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long long -# define CURLSYS_FORMAT_CURL_OFF_T "lld" -# define CURLSYS_FORMAT_CURL_OFF_TU "llu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURLSYS_PULL_SYS_TYPES_H 1 -# define CURLSYS_PULL_SYS_SOCKET_H 1 - -/* ===================================== */ -/* KEEP MSVC THE PENULTIMATE ENTRY */ -/* ===================================== */ - -#elif defined(_MSC_VER) -# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T __int64 -# define CURLSYS_FORMAT_CURL_OFF_T "I64d" -# define CURLSYS_FORMAT_CURL_OFF_TU "I64u" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T i64 -# define CURLSYS_SUFFIX_CURL_OFF_TU ui64 -# else -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 4 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# endif -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 - -/* ===================================== */ -/* KEEP GENERIC GCC THE LAST ENTRY */ -/* ===================================== */ - -#elif defined(__GNUC__) -# if !defined(__LP64__) && (defined(__ILP32__) || \ - defined(__i386__) || defined(__ppc__) || defined(__arm__) || \ - defined(__sparc__) || defined(__mips__) || defined(__sh__)) -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long long -# define CURLSYS_FORMAT_CURL_OFF_T "lld" -# define CURLSYS_FORMAT_CURL_OFF_TU "llu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T LL -# define CURLSYS_SUFFIX_CURL_OFF_TU ULL -# elif defined(__LP64__) || \ - defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) -# define CURLSYS_SIZEOF_LONG 8 -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SIZEOF_CURL_OFF_T 8 -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# endif -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T socklen_t -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 -# define CURLSYS_PULL_SYS_TYPES_H 1 -# define CURLSYS_PULL_SYS_SOCKET_H 1 - -#else -/* generic "safe guess" on old 32 bit style */ -# define CURLSYS_SIZEOF_LONG 4 -# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4 -# define CURLSYS_SIZEOF_CURL_OFF_T 4 -# define CURLSYS_TYPEOF_CURL_OFF_T long -# define CURLSYS_FORMAT_CURL_OFF_T "ld" -# define CURLSYS_FORMAT_CURL_OFF_TU "lu" -# define CURLSYS_SUFFIX_CURL_OFF_T L -# define CURLSYS_SUFFIX_CURL_OFF_TU UL -# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int -#endif - -/* CURLSYS_PULL_WS2TCPIP_H is defined above when inclusion of header file */ -/* ws2tcpip.h is required here to properly make type definitions below. */ -#ifdef CURLSYS_PULL_WS2TCPIP_H -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include -# include -# include -#endif - -/* CURLSYS_PULL_SYS_TYPES_H is defined above when inclusion of header file */ -/* sys/types.h is required here to properly make type definitions below. */ -#ifdef CURLSYS_PULL_SYS_TYPES_H -# include -#endif - -/* CURLSYS_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ -/* sys/socket.h is required here to properly make type definitions below. */ -#ifdef CURLSYS_PULL_SYS_SOCKET_H -# include -#endif - -/* Data type definition of curl_socklen_t. */ -#ifdef CURLSYS_TYPEOF_CURL_SOCKLEN_T - typedef CURLSYS_TYPEOF_CURL_SOCKLEN_T curlsys_socklen_t; -#endif - -/* Data type definition of curl_off_t. */ - -#ifdef CURLSYS_TYPEOF_CURL_OFF_T - typedef CURLSYS_TYPEOF_CURL_OFF_T curlsys_off_t; -#endif - -#endif /* __CURL_SYSTEM_H */ - diff --git a/code/curl-7.54.0/include/curl/typecheck-gcc.h b/code/curl-7.54.0/include/curl/typecheck-gcc.h deleted file mode 100644 index 3d683152..00000000 --- a/code/curl-7.54.0/include/curl/typecheck-gcc.h +++ /dev/null @@ -1,624 +0,0 @@ -#ifndef __CURL_TYPECHECK_GCC_H -#define __CURL_TYPECHECK_GCC_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* wraps curl_easy_setopt() with typechecking */ - -/* To add a new kind of warning, add an - * if(_curl_is_sometype_option(_curl_opt)) - * if(!_curl_is_sometype(value)) - * _curl_easy_setopt_err_sometype(); - * block and define _curl_is_sometype_option, _curl_is_sometype and - * _curl_easy_setopt_err_sometype below - * - * NOTE: We use two nested 'if' statements here instead of the && operator, in - * order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x - * when compiling with -Wlogical-op. - * - * To add an option that uses the same type as an existing option, you'll just - * need to extend the appropriate _curl_*_option macro - */ -#define curl_easy_setopt(handle, option, value) \ -__extension__ ({ \ - __typeof__(option) _curl_opt = option; \ - if(__builtin_constant_p(_curl_opt)) { \ - if(_curl_is_long_option(_curl_opt)) \ - if(!_curl_is_long(value)) \ - _curl_easy_setopt_err_long(); \ - if(_curl_is_off_t_option(_curl_opt)) \ - if(!_curl_is_off_t(value)) \ - _curl_easy_setopt_err_curl_off_t(); \ - if(_curl_is_string_option(_curl_opt)) \ - if(!_curl_is_string(value)) \ - _curl_easy_setopt_err_string(); \ - if(_curl_is_write_cb_option(_curl_opt)) \ - if(!_curl_is_write_cb(value)) \ - _curl_easy_setopt_err_write_callback(); \ - if((_curl_opt) == CURLOPT_READFUNCTION) \ - if(!_curl_is_read_cb(value)) \ - _curl_easy_setopt_err_read_cb(); \ - if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \ - if(!_curl_is_ioctl_cb(value)) \ - _curl_easy_setopt_err_ioctl_cb(); \ - if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \ - if(!_curl_is_sockopt_cb(value)) \ - _curl_easy_setopt_err_sockopt_cb(); \ - if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \ - if(!_curl_is_opensocket_cb(value)) \ - _curl_easy_setopt_err_opensocket_cb(); \ - if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \ - if(!_curl_is_progress_cb(value)) \ - _curl_easy_setopt_err_progress_cb(); \ - if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \ - if(!_curl_is_debug_cb(value)) \ - _curl_easy_setopt_err_debug_cb(); \ - if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \ - if(!_curl_is_ssl_ctx_cb(value)) \ - _curl_easy_setopt_err_ssl_ctx_cb(); \ - if(_curl_is_conv_cb_option(_curl_opt)) \ - if(!_curl_is_conv_cb(value)) \ - _curl_easy_setopt_err_conv_cb(); \ - if((_curl_opt) == CURLOPT_SEEKFUNCTION) \ - if(!_curl_is_seek_cb(value)) \ - _curl_easy_setopt_err_seek_cb(); \ - if(_curl_is_cb_data_option(_curl_opt)) \ - if(!_curl_is_cb_data(value)) \ - _curl_easy_setopt_err_cb_data(); \ - if((_curl_opt) == CURLOPT_ERRORBUFFER) \ - if(!_curl_is_error_buffer(value)) \ - _curl_easy_setopt_err_error_buffer(); \ - if((_curl_opt) == CURLOPT_STDERR) \ - if(!_curl_is_FILE(value)) \ - _curl_easy_setopt_err_FILE(); \ - if(_curl_is_postfields_option(_curl_opt)) \ - if(!_curl_is_postfields(value)) \ - _curl_easy_setopt_err_postfields(); \ - if((_curl_opt) == CURLOPT_HTTPPOST) \ - if(!_curl_is_arr((value), struct curl_httppost)) \ - _curl_easy_setopt_err_curl_httpost(); \ - if(_curl_is_slist_option(_curl_opt)) \ - if(!_curl_is_arr((value), struct curl_slist)) \ - _curl_easy_setopt_err_curl_slist(); \ - if((_curl_opt) == CURLOPT_SHARE) \ - if(!_curl_is_ptr((value), CURLSH)) \ - _curl_easy_setopt_err_CURLSH(); \ - } \ - curl_easy_setopt(handle, _curl_opt, value); \ -}) - -/* wraps curl_easy_getinfo() with typechecking */ -/* FIXME: don't allow const pointers */ -#define curl_easy_getinfo(handle, info, arg) \ -__extension__ ({ \ - __typeof__(info) _curl_info = info; \ - if(__builtin_constant_p(_curl_info)) { \ - if(_curl_is_string_info(_curl_info)) \ - if(!_curl_is_arr((arg), char *)) \ - _curl_easy_getinfo_err_string(); \ - if(_curl_is_long_info(_curl_info)) \ - if(!_curl_is_arr((arg), long)) \ - _curl_easy_getinfo_err_long(); \ - if(_curl_is_double_info(_curl_info)) \ - if(!_curl_is_arr((arg), double)) \ - _curl_easy_getinfo_err_double(); \ - if(_curl_is_slist_info(_curl_info)) \ - if(!_curl_is_arr((arg), struct curl_slist *)) \ - _curl_easy_getinfo_err_curl_slist(); \ - } \ - curl_easy_getinfo(handle, _curl_info, arg); \ -}) - -/* TODO: typechecking for curl_share_setopt() and curl_multi_setopt(), - * for now just make sure that the functions are called with three - * arguments - */ -#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param) -#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param) - - -/* the actual warnings, triggered by calling the _curl_easy_setopt_err* - * functions */ - -/* To define a new warning, use _CURL_WARNING(identifier, "message") */ -#define _CURL_WARNING(id, message) \ - static void __attribute__((__warning__(message))) \ - __attribute__((__unused__)) __attribute__((__noinline__)) \ - id(void) { __asm__(""); } - -_CURL_WARNING(_curl_easy_setopt_err_long, - "curl_easy_setopt expects a long argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_curl_off_t, - "curl_easy_setopt expects a curl_off_t argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_string, - "curl_easy_setopt expects a " - "string ('char *' or char[]) argument for this option" - ) -_CURL_WARNING(_curl_easy_setopt_err_write_callback, - "curl_easy_setopt expects a curl_write_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_read_cb, - "curl_easy_setopt expects a curl_read_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_ioctl_cb, - "curl_easy_setopt expects a curl_ioctl_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_sockopt_cb, - "curl_easy_setopt expects a curl_sockopt_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_opensocket_cb, - "curl_easy_setopt expects a " - "curl_opensocket_callback argument for this option" - ) -_CURL_WARNING(_curl_easy_setopt_err_progress_cb, - "curl_easy_setopt expects a curl_progress_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_debug_cb, - "curl_easy_setopt expects a curl_debug_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb, - "curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_conv_cb, - "curl_easy_setopt expects a curl_conv_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_seek_cb, - "curl_easy_setopt expects a curl_seek_callback argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_cb_data, - "curl_easy_setopt expects a " - "private data pointer as argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_error_buffer, - "curl_easy_setopt expects a " - "char buffer of CURL_ERROR_SIZE as argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_FILE, - "curl_easy_setopt expects a 'FILE *' argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_postfields, - "curl_easy_setopt expects a 'void *' or 'char *' argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_curl_httpost, - "curl_easy_setopt expects a 'struct curl_httppost *' " - "argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_curl_slist, - "curl_easy_setopt expects a 'struct curl_slist *' argument for this option") -_CURL_WARNING(_curl_easy_setopt_err_CURLSH, - "curl_easy_setopt expects a CURLSH* argument for this option") - -_CURL_WARNING(_curl_easy_getinfo_err_string, - "curl_easy_getinfo expects a pointer to 'char *' for this info") -_CURL_WARNING(_curl_easy_getinfo_err_long, - "curl_easy_getinfo expects a pointer to long for this info") -_CURL_WARNING(_curl_easy_getinfo_err_double, - "curl_easy_getinfo expects a pointer to double for this info") -_CURL_WARNING(_curl_easy_getinfo_err_curl_slist, - "curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info") - -/* groups of curl_easy_setops options that take the same type of argument */ - -/* To add a new option to one of the groups, just add - * (option) == CURLOPT_SOMETHING - * to the or-expression. If the option takes a long or curl_off_t, you don't - * have to do anything - */ - -/* evaluates to true if option takes a long argument */ -#define _curl_is_long_option(option) \ - (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT) - -#define _curl_is_off_t_option(option) \ - ((option) > CURLOPTTYPE_OFF_T) - -/* evaluates to true if option takes a char* argument */ -#define _curl_is_string_option(option) \ - ((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \ - (option) == CURLOPT_ACCEPT_ENCODING || \ - (option) == CURLOPT_CAINFO || \ - (option) == CURLOPT_CAPATH || \ - (option) == CURLOPT_COOKIE || \ - (option) == CURLOPT_COOKIEFILE || \ - (option) == CURLOPT_COOKIEJAR || \ - (option) == CURLOPT_COOKIELIST || \ - (option) == CURLOPT_CRLFILE || \ - (option) == CURLOPT_CUSTOMREQUEST || \ - (option) == CURLOPT_DEFAULT_PROTOCOL || \ - (option) == CURLOPT_DNS_INTERFACE || \ - (option) == CURLOPT_DNS_LOCAL_IP4 || \ - (option) == CURLOPT_DNS_LOCAL_IP6 || \ - (option) == CURLOPT_DNS_SERVERS || \ - (option) == CURLOPT_EGDSOCKET || \ - (option) == CURLOPT_FTPPORT || \ - (option) == CURLOPT_FTP_ACCOUNT || \ - (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \ - (option) == CURLOPT_INTERFACE || \ - (option) == CURLOPT_ISSUERCERT || \ - (option) == CURLOPT_KEYPASSWD || \ - (option) == CURLOPT_KRBLEVEL || \ - (option) == CURLOPT_LOGIN_OPTIONS || \ - (option) == CURLOPT_MAIL_AUTH || \ - (option) == CURLOPT_MAIL_FROM || \ - (option) == CURLOPT_NETRC_FILE || \ - (option) == CURLOPT_NOPROXY || \ - (option) == CURLOPT_PASSWORD || \ - (option) == CURLOPT_PINNEDPUBLICKEY || \ - (option) == CURLOPT_PROXY || \ - (option) == CURLOPT_PROXYPASSWORD || \ - (option) == CURLOPT_PROXYUSERNAME || \ - (option) == CURLOPT_PROXYUSERPWD || \ - (option) == CURLOPT_PROXY_SERVICE_NAME || \ - (option) == CURLOPT_RANDOM_FILE || \ - (option) == CURLOPT_RANGE || \ - (option) == CURLOPT_REFERER || \ - (option) == CURLOPT_RTSP_SESSION_ID || \ - (option) == CURLOPT_RTSP_STREAM_URI || \ - (option) == CURLOPT_RTSP_TRANSPORT || \ - (option) == CURLOPT_SERVICE_NAME || \ - (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \ - (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \ - (option) == CURLOPT_SSH_KNOWNHOSTS || \ - (option) == CURLOPT_SSH_PRIVATE_KEYFILE || \ - (option) == CURLOPT_SSH_PUBLIC_KEYFILE || \ - (option) == CURLOPT_SSLCERT || \ - (option) == CURLOPT_SSLCERTTYPE || \ - (option) == CURLOPT_SSLENGINE || \ - (option) == CURLOPT_SSLKEY || \ - (option) == CURLOPT_SSLKEYTYPE || \ - (option) == CURLOPT_SSL_CIPHER_LIST || \ - (option) == CURLOPT_TLSAUTH_PASSWORD || \ - (option) == CURLOPT_TLSAUTH_TYPE || \ - (option) == CURLOPT_TLSAUTH_USERNAME || \ - (option) == CURLOPT_UNIX_SOCKET_PATH || \ - (option) == CURLOPT_URL || \ - (option) == CURLOPT_USERAGENT || \ - (option) == CURLOPT_USERNAME || \ - (option) == CURLOPT_USERPWD || \ - (option) == CURLOPT_XOAUTH2_BEARER || \ - 0) - -/* evaluates to true if option takes a curl_write_callback argument */ -#define _curl_is_write_cb_option(option) \ - ((option) == CURLOPT_HEADERFUNCTION || \ - (option) == CURLOPT_WRITEFUNCTION) - -/* evaluates to true if option takes a curl_conv_callback argument */ -#define _curl_is_conv_cb_option(option) \ - ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \ - (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \ - (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION) - -/* evaluates to true if option takes a data argument to pass to a callback */ -#define _curl_is_cb_data_option(option) \ - ((option) == CURLOPT_CHUNK_DATA || \ - (option) == CURLOPT_CLOSESOCKETDATA || \ - (option) == CURLOPT_DEBUGDATA || \ - (option) == CURLOPT_FNMATCH_DATA || \ - (option) == CURLOPT_HEADERDATA || \ - (option) == CURLOPT_INTERLEAVEDATA || \ - (option) == CURLOPT_IOCTLDATA || \ - (option) == CURLOPT_OPENSOCKETDATA || \ - (option) == CURLOPT_PRIVATE || \ - (option) == CURLOPT_PROGRESSDATA || \ - (option) == CURLOPT_READDATA || \ - (option) == CURLOPT_SEEKDATA || \ - (option) == CURLOPT_SOCKOPTDATA || \ - (option) == CURLOPT_SSH_KEYDATA || \ - (option) == CURLOPT_SSL_CTX_DATA || \ - (option) == CURLOPT_WRITEDATA || \ - 0) - -/* evaluates to true if option takes a POST data argument (void* or char*) */ -#define _curl_is_postfields_option(option) \ - ((option) == CURLOPT_POSTFIELDS || \ - (option) == CURLOPT_COPYPOSTFIELDS || \ - 0) - -/* evaluates to true if option takes a struct curl_slist * argument */ -#define _curl_is_slist_option(option) \ - ((option) == CURLOPT_HTTP200ALIASES || \ - (option) == CURLOPT_HTTPHEADER || \ - (option) == CURLOPT_MAIL_RCPT || \ - (option) == CURLOPT_POSTQUOTE || \ - (option) == CURLOPT_PREQUOTE || \ - (option) == CURLOPT_PROXYHEADER || \ - (option) == CURLOPT_QUOTE || \ - (option) == CURLOPT_RESOLVE || \ - (option) == CURLOPT_TELNETOPTIONS || \ - 0) - -/* groups of curl_easy_getinfo infos that take the same type of argument */ - -/* evaluates to true if info expects a pointer to char * argument */ -#define _curl_is_string_info(info) \ - (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG) - -/* evaluates to true if info expects a pointer to long argument */ -#define _curl_is_long_info(info) \ - (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE) - -/* evaluates to true if info expects a pointer to double argument */ -#define _curl_is_double_info(info) \ - (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST) - -/* true if info expects a pointer to struct curl_slist * argument */ -#define _curl_is_slist_info(info) \ - (CURLINFO_SLIST < (info)) - - -/* typecheck helpers -- check whether given expression has requested type*/ - -/* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros, - * otherwise define a new macro. Search for __builtin_types_compatible_p - * in the GCC manual. - * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is - * the actual expression passed to the curl_easy_setopt macro. This - * means that you can only apply the sizeof and __typeof__ operators, no - * == or whatsoever. - */ - -/* XXX: should evaluate to true iff expr is a pointer */ -#define _curl_is_any_ptr(expr) \ - (sizeof(expr) == sizeof(void *)) - -/* evaluates to true if expr is NULL */ -/* XXX: must not evaluate expr, so this check is not accurate */ -#define _curl_is_NULL(expr) \ - (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL))) - -/* evaluates to true if expr is type*, const type* or NULL */ -#define _curl_is_ptr(expr, type) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), type *) || \ - __builtin_types_compatible_p(__typeof__(expr), const type *)) - -/* evaluates to true if expr is one of type[], type*, NULL or const type* */ -#define _curl_is_arr(expr, type) \ - (_curl_is_ptr((expr), type) || \ - __builtin_types_compatible_p(__typeof__(expr), type [])) - -/* evaluates to true if expr is a string */ -#define _curl_is_string(expr) \ - (_curl_is_arr((expr), char) || \ - _curl_is_arr((expr), signed char) || \ - _curl_is_arr((expr), unsigned char)) - -/* evaluates to true if expr is a long (no matter the signedness) - * XXX: for now, int is also accepted (and therefore short and char, which - * are promoted to int when passed to a variadic function) */ -#define _curl_is_long(expr) \ - (__builtin_types_compatible_p(__typeof__(expr), long) || \ - __builtin_types_compatible_p(__typeof__(expr), signed long) || \ - __builtin_types_compatible_p(__typeof__(expr), unsigned long) || \ - __builtin_types_compatible_p(__typeof__(expr), int) || \ - __builtin_types_compatible_p(__typeof__(expr), signed int) || \ - __builtin_types_compatible_p(__typeof__(expr), unsigned int) || \ - __builtin_types_compatible_p(__typeof__(expr), short) || \ - __builtin_types_compatible_p(__typeof__(expr), signed short) || \ - __builtin_types_compatible_p(__typeof__(expr), unsigned short) || \ - __builtin_types_compatible_p(__typeof__(expr), char) || \ - __builtin_types_compatible_p(__typeof__(expr), signed char) || \ - __builtin_types_compatible_p(__typeof__(expr), unsigned char)) - -/* evaluates to true if expr is of type curl_off_t */ -#define _curl_is_off_t(expr) \ - (__builtin_types_compatible_p(__typeof__(expr), curl_off_t)) - -/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */ -/* XXX: also check size of an char[] array? */ -#define _curl_is_error_buffer(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), char *) || \ - __builtin_types_compatible_p(__typeof__(expr), char[])) - -/* evaluates to true if expr is of type (const) void* or (const) FILE* */ -#if 0 -#define _curl_is_cb_data(expr) \ - (_curl_is_ptr((expr), void) || \ - _curl_is_ptr((expr), FILE)) -#else /* be less strict */ -#define _curl_is_cb_data(expr) \ - _curl_is_any_ptr(expr) -#endif - -/* evaluates to true if expr is of type FILE* */ -#define _curl_is_FILE(expr) \ - (__builtin_types_compatible_p(__typeof__(expr), FILE *)) - -/* evaluates to true if expr can be passed as POST data (void* or char*) */ -#define _curl_is_postfields(expr) \ - (_curl_is_ptr((expr), void) || \ - _curl_is_arr((expr), char)) - -/* FIXME: the whole callback checking is messy... - * The idea is to tolerate char vs. void and const vs. not const - * pointers in arguments at least - */ -/* helper: __builtin_types_compatible_p distinguishes between functions and - * function pointers, hide it */ -#define _curl_callback_compatible(func, type) \ - (__builtin_types_compatible_p(__typeof__(func), type) || \ - __builtin_types_compatible_p(__typeof__(func), type*)) - -/* evaluates to true if expr is of type curl_read_callback or "similar" */ -#define _curl_is_read_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), __typeof__(fread)) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_read_callback) || \ - _curl_callback_compatible((expr), _curl_read_callback1) || \ - _curl_callback_compatible((expr), _curl_read_callback2) || \ - _curl_callback_compatible((expr), _curl_read_callback3) || \ - _curl_callback_compatible((expr), _curl_read_callback4) || \ - _curl_callback_compatible((expr), _curl_read_callback5) || \ - _curl_callback_compatible((expr), _curl_read_callback6)) -typedef size_t (_curl_read_callback1)(char *, size_t, size_t, void *); -typedef size_t (_curl_read_callback2)(char *, size_t, size_t, const void *); -typedef size_t (_curl_read_callback3)(char *, size_t, size_t, FILE *); -typedef size_t (_curl_read_callback4)(void *, size_t, size_t, void *); -typedef size_t (_curl_read_callback5)(void *, size_t, size_t, const void *); -typedef size_t (_curl_read_callback6)(void *, size_t, size_t, FILE *); - -/* evaluates to true if expr is of type curl_write_callback or "similar" */ -#define _curl_is_write_cb(expr) \ - (_curl_is_read_cb(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), __typeof__(fwrite)) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_write_callback) || \ - _curl_callback_compatible((expr), _curl_write_callback1) || \ - _curl_callback_compatible((expr), _curl_write_callback2) || \ - _curl_callback_compatible((expr), _curl_write_callback3) || \ - _curl_callback_compatible((expr), _curl_write_callback4) || \ - _curl_callback_compatible((expr), _curl_write_callback5) || \ - _curl_callback_compatible((expr), _curl_write_callback6)) -typedef size_t (_curl_write_callback1)(const char *, size_t, size_t, void *); -typedef size_t (_curl_write_callback2)(const char *, size_t, size_t, - const void *); -typedef size_t (_curl_write_callback3)(const char *, size_t, size_t, FILE *); -typedef size_t (_curl_write_callback4)(const void *, size_t, size_t, void *); -typedef size_t (_curl_write_callback5)(const void *, size_t, size_t, - const void *); -typedef size_t (_curl_write_callback6)(const void *, size_t, size_t, FILE *); - -/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */ -#define _curl_is_ioctl_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_ioctl_callback) || \ - _curl_callback_compatible((expr), _curl_ioctl_callback1) || \ - _curl_callback_compatible((expr), _curl_ioctl_callback2) || \ - _curl_callback_compatible((expr), _curl_ioctl_callback3) || \ - _curl_callback_compatible((expr), _curl_ioctl_callback4)) -typedef curlioerr (_curl_ioctl_callback1)(CURL *, int, void *); -typedef curlioerr (_curl_ioctl_callback2)(CURL *, int, const void *); -typedef curlioerr (_curl_ioctl_callback3)(CURL *, curliocmd, void *); -typedef curlioerr (_curl_ioctl_callback4)(CURL *, curliocmd, const void *); - -/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */ -#define _curl_is_sockopt_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_sockopt_callback) || \ - _curl_callback_compatible((expr), _curl_sockopt_callback1) || \ - _curl_callback_compatible((expr), _curl_sockopt_callback2)) -typedef int (_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype); -typedef int (_curl_sockopt_callback2)(const void *, curl_socket_t, - curlsocktype); - -/* evaluates to true if expr is of type curl_opensocket_callback or - "similar" */ -#define _curl_is_opensocket_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_opensocket_callback) ||\ - _curl_callback_compatible((expr), _curl_opensocket_callback1) || \ - _curl_callback_compatible((expr), _curl_opensocket_callback2) || \ - _curl_callback_compatible((expr), _curl_opensocket_callback3) || \ - _curl_callback_compatible((expr), _curl_opensocket_callback4)) -typedef curl_socket_t (_curl_opensocket_callback1) - (void *, curlsocktype, struct curl_sockaddr *); -typedef curl_socket_t (_curl_opensocket_callback2) - (void *, curlsocktype, const struct curl_sockaddr *); -typedef curl_socket_t (_curl_opensocket_callback3) - (const void *, curlsocktype, struct curl_sockaddr *); -typedef curl_socket_t (_curl_opensocket_callback4) - (const void *, curlsocktype, const struct curl_sockaddr *); - -/* evaluates to true if expr is of type curl_progress_callback or "similar" */ -#define _curl_is_progress_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_progress_callback) || \ - _curl_callback_compatible((expr), _curl_progress_callback1) || \ - _curl_callback_compatible((expr), _curl_progress_callback2)) -typedef int (_curl_progress_callback1)(void *, - double, double, double, double); -typedef int (_curl_progress_callback2)(const void *, - double, double, double, double); - -/* evaluates to true if expr is of type curl_debug_callback or "similar" */ -#define _curl_is_debug_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_debug_callback) || \ - _curl_callback_compatible((expr), _curl_debug_callback1) || \ - _curl_callback_compatible((expr), _curl_debug_callback2) || \ - _curl_callback_compatible((expr), _curl_debug_callback3) || \ - _curl_callback_compatible((expr), _curl_debug_callback4) || \ - _curl_callback_compatible((expr), _curl_debug_callback5) || \ - _curl_callback_compatible((expr), _curl_debug_callback6) || \ - _curl_callback_compatible((expr), _curl_debug_callback7) || \ - _curl_callback_compatible((expr), _curl_debug_callback8)) -typedef int (_curl_debug_callback1) (CURL *, - curl_infotype, char *, size_t, void *); -typedef int (_curl_debug_callback2) (CURL *, - curl_infotype, char *, size_t, const void *); -typedef int (_curl_debug_callback3) (CURL *, - curl_infotype, const char *, size_t, void *); -typedef int (_curl_debug_callback4) (CURL *, - curl_infotype, const char *, size_t, const void *); -typedef int (_curl_debug_callback5) (CURL *, - curl_infotype, unsigned char *, size_t, void *); -typedef int (_curl_debug_callback6) (CURL *, - curl_infotype, unsigned char *, size_t, const void *); -typedef int (_curl_debug_callback7) (CURL *, - curl_infotype, const unsigned char *, size_t, void *); -typedef int (_curl_debug_callback8) (CURL *, - curl_infotype, const unsigned char *, size_t, const void *); - -/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */ -/* this is getting even messier... */ -#define _curl_is_ssl_ctx_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_ssl_ctx_callback) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback1) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback2) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback3) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback4) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback5) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback6) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback7) || \ - _curl_callback_compatible((expr), _curl_ssl_ctx_callback8)) -typedef CURLcode (_curl_ssl_ctx_callback1)(CURL *, void *, void *); -typedef CURLcode (_curl_ssl_ctx_callback2)(CURL *, void *, const void *); -typedef CURLcode (_curl_ssl_ctx_callback3)(CURL *, const void *, void *); -typedef CURLcode (_curl_ssl_ctx_callback4)(CURL *, const void *, const void *); -#ifdef HEADER_SSL_H -/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX - * this will of course break if we're included before OpenSSL headers... - */ -typedef CURLcode (_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *); -typedef CURLcode (_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *); -typedef CURLcode (_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *); -typedef CURLcode (_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX, - const void *); -#else -typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5; -typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6; -typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7; -typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8; -#endif - -/* evaluates to true if expr is of type curl_conv_callback or "similar" */ -#define _curl_is_conv_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_conv_callback) || \ - _curl_callback_compatible((expr), _curl_conv_callback1) || \ - _curl_callback_compatible((expr), _curl_conv_callback2) || \ - _curl_callback_compatible((expr), _curl_conv_callback3) || \ - _curl_callback_compatible((expr), _curl_conv_callback4)) -typedef CURLcode (*_curl_conv_callback1)(char *, size_t length); -typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length); -typedef CURLcode (*_curl_conv_callback3)(void *, size_t length); -typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length); - -/* evaluates to true if expr is of type curl_seek_callback or "similar" */ -#define _curl_is_seek_cb(expr) \ - (_curl_is_NULL(expr) || \ - __builtin_types_compatible_p(__typeof__(expr), curl_seek_callback) || \ - _curl_callback_compatible((expr), _curl_seek_callback1) || \ - _curl_callback_compatible((expr), _curl_seek_callback2)) -typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int); -typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int); - - -#endif /* __CURL_TYPECHECK_GCC_H */ diff --git a/code/fgame/CMakeLists.txt b/code/fgame/CMakeLists.txt index c0161b52..66d42a98 100644 --- a/code/fgame/CMakeLists.txt +++ b/code/fgame/CMakeLists.txt @@ -59,9 +59,9 @@ if (FLEX_FOUND AND BISON_FOUND) endif() # Recast navigation -add_subdirectory(../recastnavigation/Detour fgame_detour) -add_subdirectory(../recastnavigation/DetourCrowd fgame_detour_crowd) -add_subdirectory(../recastnavigation/Recast fgame_recast) +add_subdirectory(../thirdparty/recastnavigation/Detour fgame_detour) +add_subdirectory(../thirdparty/recastnavigation/DetourCrowd fgame_detour_crowd) +add_subdirectory(../thirdparty/recastnavigation/Recast fgame_recast) # Enable position independant code on recast navigation libraries. # Otherwise linking will fail relocating some functions on Linux set_property(TARGET Detour DetourCrowd Recast PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/code/jpeg-9f/cdjpeg.c b/code/jpeg-9f/cdjpeg.c deleted file mode 100644 index b6250ff9..00000000 --- a/code/jpeg-9f/cdjpeg.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * cdjpeg.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains common support routines used by the IJG application - * programs (cjpeg, djpeg, jpegtran). - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include /* to declare isupper(), tolower() */ -#ifdef NEED_SIGNAL_CATCHER -#include /* to declare signal() */ -#endif -#ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ -#endif - - -/* - * Signal catcher to ensure that temporary files are removed before aborting. - * NB: for Amiga Manx C this is actually a global routine named _abort(); - * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus... - */ - -#ifdef NEED_SIGNAL_CATCHER - -static j_common_ptr sig_cinfo; - -void /* must be global for Manx C */ -signal_catcher (int signum) -{ - if (sig_cinfo != NULL) { - if (sig_cinfo->err != NULL) /* turn off trace output */ - sig_cinfo->err->trace_level = 0; - jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */ - } - exit(EXIT_FAILURE); -} - - -GLOBAL(void) -enable_signal_catcher (j_common_ptr cinfo) -{ - sig_cinfo = cinfo; -#ifdef SIGINT /* not all systems have SIGINT */ - signal(SIGINT, signal_catcher); -#endif -#ifdef SIGTERM /* not all systems have SIGTERM */ - signal(SIGTERM, signal_catcher); -#endif -} - -#endif - - -/* - * Optional progress monitor: display a percent-done figure on stderr. - */ - -#ifdef PROGRESS_REPORT - -METHODDEF(void) -progress_monitor (j_common_ptr cinfo) -{ - cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress; - int total_passes = prog->pub.total_passes + prog->total_extra_passes; - int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit); - - if (percent_done != prog->percent_done) { - prog->percent_done = percent_done; - if (total_passes > 1) { - fprintf(stderr, "\rPass %d/%d: %3d%% ", - prog->pub.completed_passes + prog->completed_extra_passes + 1, - total_passes, percent_done); - } else { - fprintf(stderr, "\r %3d%% ", percent_done); - } - fflush(stderr); - } -} - - -GLOBAL(void) -start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress) -{ - /* Enable progress display, unless trace output is on */ - if (cinfo->err->trace_level == 0) { - progress->pub.progress_monitor = progress_monitor; - progress->completed_extra_passes = 0; - progress->total_extra_passes = 0; - progress->percent_done = -1; - cinfo->progress = &progress->pub; - } -} - - -GLOBAL(void) -end_progress_monitor (j_common_ptr cinfo) -{ - /* Clear away progress display */ - if (cinfo->err->trace_level == 0) { - fprintf(stderr, "\r \r"); - fflush(stderr); - } -} - -#endif - - -/* - * Case-insensitive matching of possibly-abbreviated keyword switches. - * keyword is the constant keyword (must be lower case already), - * minchars is length of minimum legal abbreviation. - */ - -GLOBAL(boolean) -keymatch (char * arg, const char * keyword, int minchars) -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return FALSE; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return FALSE; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return FALSE; - return TRUE; /* A-OK */ -} - - -/* - * Routines to establish binary I/O mode for stdin and stdout. - * Non-Unix systems often require some hacking to get out of text mode. - */ - -GLOBAL(FILE *) -read_stdin (void) -{ - FILE * input_file = stdin; - -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "Cannot reopen stdin\n"); - exit(EXIT_FAILURE); - } -#endif - return input_file; -} - - -GLOBAL(FILE *) -write_stdout (void) -{ - FILE * output_file = stdout; - -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdout), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { - fprintf(stderr, "Cannot reopen stdout\n"); - exit(EXIT_FAILURE); - } -#endif - return output_file; -} diff --git a/code/jpeg-9f/cjpeg.c b/code/jpeg-9f/cjpeg.c deleted file mode 100644 index 3cb07fa4..00000000 --- a/code/jpeg-9f/cjpeg.c +++ /dev/null @@ -1,664 +0,0 @@ -/* - * cjpeg.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * Modified 2003-2013 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a command-line user interface for the JPEG compressor. - * It should work on any system with Unix- or MS-DOS-style command lines. - * - * Two different command line styles are permitted, depending on the - * compile-time switch TWO_FILE_COMMANDLINE: - * cjpeg [options] inputfile outputfile - * cjpeg [options] [inputfile] - * In the second style, output is always to standard output, which you'd - * normally redirect to a file or pipe to some other program. Input is - * either from a named file or from standard input (typically redirected). - * The second style is convenient on Unix but is unhelpful on systems that - * don't support pipes. Also, you MUST use the first style if your system - * doesn't do binary I/O to stdin/stdout. - * To simplify script writing, the "-outfile" switch is provided. The syntax - * cjpeg [options] -outfile outputfile inputfile - * works regardless of which command line style is used. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "jversion.h" /* for version message */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - - -/* Create the add-on message string table. */ - -#define JMESSAGE(code,string) string , - -static const char * const cdjpeg_message_table[] = { -#include "cderror.h" - NULL -}; - - -/* - * This routine determines what format the input file is, - * and selects the appropriate input-reading module. - * - * To determine which family of input formats the file belongs to, - * we may look only at the first byte of the file, since C does not - * guarantee that more than one character can be pushed back with ungetc. - * Looking at additional bytes would require one of these approaches: - * 1) assume we can fseek() the input file (fails for piped input); - * 2) assume we can push back more than one character (works in - * some C implementations, but unportable); - * 3) provide our own buffering (breaks input readers that want to use - * stdio directly, such as the RLE library); - * or 4) don't put back the data, and modify the input_init methods to assume - * they start reading after the start of file (also breaks RLE library). - * #1 is attractive for MS-DOS but is untenable on Unix. - * - * The most portable solution for file types that can't be identified by their - * first byte is to make the user tell us what they are. This is also the - * only approach for "raw" file types that contain only arbitrary values. - * We presently apply this method for Targa files. Most of the time Targa - * files start with 0x00, so we recognize that case. Potentially, however, - * a Targa file could start with any byte value (byte 0 is the length of the - * seldom-used ID field), so we provide a switch to force Targa input mode. - */ - -static boolean is_targa; /* records user -targa switch */ - - -LOCAL(cjpeg_source_ptr) -select_file_type (j_compress_ptr cinfo, FILE * infile) -{ - int c; - - if (is_targa) { -#ifdef TARGA_SUPPORTED - return jinit_read_targa(cinfo); -#else - ERREXIT(cinfo, JERR_TGA_NOTCOMP); -#endif - } - - if ((c = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_INPUT_EMPTY); - if (ungetc(c, infile) == EOF) - ERREXIT(cinfo, JERR_UNGETC_FAILED); - - switch (c) { -#ifdef BMP_SUPPORTED - case 'B': - return jinit_read_bmp(cinfo); -#endif -#ifdef GIF_SUPPORTED - case 'G': - return jinit_read_gif(cinfo); -#endif -#ifdef PPM_SUPPORTED - case 'P': - return jinit_read_ppm(cinfo); -#endif -#ifdef RLE_SUPPORTED - case 'R': - return jinit_read_rle(cinfo); -#endif -#ifdef TARGA_SUPPORTED - case 0x00: - return jinit_read_targa(cinfo); -#endif - default: - ERREXIT(cinfo, JERR_UNKNOWN_FORMAT); - break; - } - - return NULL; /* suppress compiler warnings */ -} - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - * The main program in this file doesn't actually use this capability... - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -quality N[,...] Compression quality (0..100; 5-95 is useful range)\n"); - fprintf(stderr, " -grayscale Create monochrome JPEG file\n"); - fprintf(stderr, " -rgb Create RGB JPEG file\n"); -#ifdef ENTROPY_OPT_SUPPORTED - fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); -#endif -#ifdef C_PROGRESSIVE_SUPPORTED - fprintf(stderr, " -progressive Create progressive JPEG file\n"); -#endif -#ifdef DCT_SCALING_SUPPORTED - fprintf(stderr, " -scale M/N Scale image by fraction M/N, eg, 1/2\n"); -#endif -#ifdef TARGA_SUPPORTED - fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n"); -#endif - fprintf(stderr, "Switches for advanced users:\n"); -#ifdef C_ARITH_CODING_SUPPORTED - fprintf(stderr, " -arithmetic Use arithmetic coding\n"); -#endif -#ifdef DCT_SCALING_SUPPORTED - fprintf(stderr, " -block N DCT block size (1..16; default is 8)\n"); -#endif -#if JPEG_LIB_VERSION_MAJOR >= 9 - fprintf(stderr, " -rgb1 Create RGB JPEG file with reversible color transform\n"); - fprintf(stderr, " -bgycc Create big gamut YCC JPEG file\n"); -#endif -#ifdef DCT_ISLOW_SUPPORTED - fprintf(stderr, " -dct int Use integer DCT method%s\n", - (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); -#endif -#ifdef DCT_IFAST_SUPPORTED - fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", - (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); -#endif -#ifdef DCT_FLOAT_SUPPORTED - fprintf(stderr, " -dct float Use floating-point DCT method%s\n", - (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); -#endif - fprintf(stderr, " -nosmooth Don't use high-quality downsampling\n"); - fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); -#ifdef INPUT_SMOOTHING_SUPPORTED - fprintf(stderr, " -smooth N Smooth dithered input (N=1..100 is strength)\n"); -#endif - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - fprintf(stderr, "Switches for wizards:\n"); - fprintf(stderr, " -baseline Force baseline quantization tables\n"); - fprintf(stderr, " -qtables file Use quantization tables given in file\n"); - fprintf(stderr, " -qslots N[,...] Set component quantization tables\n"); - fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n"); -#ifdef C_MULTISCAN_FILES_SUPPORTED - fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); -#endif - exit(EXIT_FAILURE); -} - - -LOCAL(int) -parse_switches (j_compress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - boolean force_baseline; - boolean simple_progressive; - char * qualityarg = NULL; /* saves -quality parm if any */ - char * qtablefile = NULL; /* saves -qtables filename if any */ - char * qslotsarg = NULL; /* saves -qslots parm if any */ - char * samplearg = NULL; /* saves -sample parm if any */ - char * scansarg = NULL; /* saves -scans parm if any */ - - /* Set up default JPEG parameters. */ - - force_baseline = FALSE; /* by default, allow 16-bit quantizers */ - simple_progressive = FALSE; - is_targa = FALSE; - outfilename = NULL; - cinfo->err->trace_level = 0; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "arithmetic", 1)) { - /* Use arithmetic coding. */ -#ifdef C_ARITH_CODING_SUPPORTED - cinfo->arith_code = TRUE; -#else - fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "baseline", 2)) { - /* Force baseline-compatible output (8-bit quantizer values). */ - force_baseline = TRUE; - - } else if (keymatch(arg, "block", 2)) { - /* Set DCT block size. */ -#if defined DCT_SCALING_SUPPORTED && JPEG_LIB_VERSION_MAJOR >= 8 && \ - (JPEG_LIB_VERSION_MAJOR > 8 || JPEG_LIB_VERSION_MINOR >= 3) - int val; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &val) != 1) - usage(); - if (val < 1 || val > 16) - usage(); - cinfo->block_size = val; -#else - fprintf(stderr, "%s: sorry, block size setting not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "dct", 2)) { - /* Select DCT algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "int", 1)) { - cinfo->dct_method = JDCT_ISLOW; - } else if (keymatch(argv[argn], "fast", 2)) { - cinfo->dct_method = JDCT_IFAST; - } else if (keymatch(argv[argn], "float", 2)) { - cinfo->dct_method = JDCT_FLOAT; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's CJPEG, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { - /* Force a monochrome JPEG file to be generated. */ - jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); - - } else if (keymatch(arg, "rgb", 3) || keymatch(arg, "rgb1", 4)) { - /* Force an RGB JPEG file to be generated. */ -#if JPEG_LIB_VERSION_MAJOR >= 9 - /* Note: Entropy table assignment in jpeg_set_colorspace depends - * on color_transform. - */ - cinfo->color_transform = arg[3] ? JCT_SUBTRACT_GREEN : JCT_NONE; -#endif - jpeg_set_colorspace(cinfo, JCS_RGB); - - } else if (keymatch(arg, "bgycc", 5)) { - /* Force a big gamut YCC JPEG file to be generated. */ -#if JPEG_LIB_VERSION_MAJOR >= 9 && \ - (JPEG_LIB_VERSION_MAJOR > 9 || JPEG_LIB_VERSION_MINOR >= 1) - jpeg_set_colorspace(cinfo, JCS_BG_YCC); -#else - fprintf(stderr, "%s: sorry, BG_YCC colorspace not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "nosmooth", 3)) { - /* Suppress fancy downsampling. */ - cinfo->do_fancy_downsampling = FALSE; - - } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { - /* Enable entropy parm optimization. */ -#ifdef ENTROPY_OPT_SUPPORTED - cinfo->optimize_coding = TRUE; -#else - fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "progressive", 1)) { - /* Select simple progressive mode. */ -#ifdef C_PROGRESSIVE_SUPPORTED - simple_progressive = TRUE; - /* We must postpone execution until num_components is known. */ -#else - fprintf(stderr, "%s: sorry, progressive output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "quality", 1)) { - /* Quality ratings (quantization table scaling factors). */ - if (++argn >= argc) /* advance to next argument */ - usage(); - qualityarg = argv[argn]; - - } else if (keymatch(arg, "qslots", 2)) { - /* Quantization table slot numbers. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - qslotsarg = argv[argn]; - /* Must delay setting qslots until after we have processed any - * colorspace-determining switches, since jpeg_set_colorspace sets - * default quant table numbers. - */ - - } else if (keymatch(arg, "qtables", 2)) { - /* Quantization tables fetched from file. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - qtablefile = argv[argn]; - /* We postpone actually reading the file in case -quality comes later. */ - - } else if (keymatch(arg, "restart", 1)) { - /* Restart interval in MCU rows (or in MCUs with 'b'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (lval < 0 || lval > 65535L) - usage(); - if (ch == 'b' || ch == 'B') { - cinfo->restart_interval = (unsigned int) lval; - cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ - } else { - cinfo->restart_in_rows = (int) lval; - /* restart_interval will be computed during startup */ - } - - } else if (keymatch(arg, "sample", 2)) { - /* Set sampling factors. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - samplearg = argv[argn]; - /* Must delay setting sample factors until after we have processed any - * colorspace-determining switches, since jpeg_set_colorspace sets - * default sampling factors. - */ - - } else if (keymatch(arg, "scale", 4)) { - /* Scale the image by a fraction M/N. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%u/%u", - &cinfo->scale_num, &cinfo->scale_denom) != 2) - usage(); - - } else if (keymatch(arg, "scans", 4)) { - /* Set scan script. */ -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (++argn >= argc) /* advance to next argument */ - usage(); - scansarg = argv[argn]; - /* We must postpone reading the file in case -progressive appears. */ -#else - fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "smooth", 2)) { - /* Set input smoothing factor. */ - int val; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &val) != 1) - usage(); - if (val < 0 || val > 100) - usage(); - cinfo->smoothing_factor = val; - - } else if (keymatch(arg, "targa", 1)) { - /* Input file is Targa format. */ - is_targa = TRUE; - - } else { - usage(); /* bogus switch */ - } - } - - /* Post-switch-scanning cleanup */ - - if (for_real) { - - /* Set quantization tables for selected quality. */ - /* Some or all may be overridden if -qtables is present. */ - if (qualityarg != NULL) /* process -quality if it was present */ - if (! set_quality_ratings(cinfo, qualityarg, force_baseline)) - usage(); - - if (qtablefile != NULL) /* process -qtables if it was present */ - if (! read_quant_tables(cinfo, qtablefile, force_baseline)) - usage(); - - if (qslotsarg != NULL) /* process -qslots if it was present */ - if (! set_quant_slots(cinfo, qslotsarg)) - usage(); - - if (samplearg != NULL) /* process -sample if it was present */ - if (! set_sample_factors(cinfo, samplearg)) - usage(); - -#ifdef C_PROGRESSIVE_SUPPORTED - if (simple_progressive) /* process -progressive; -scans can override */ - jpeg_simple_progression(cinfo); -#endif - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (scansarg != NULL) /* process -scans if it was present */ - if (! read_scan_script(cinfo, scansarg)) - usage(); -#endif - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - int file_index; - cjpeg_source_ptr src_mgr; - FILE * input_file; - FILE * output_file; - JDIMENSION num_scanlines; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "cjpeg"; /* in case C library doesn't provide it */ - - /* Initialize the JPEG compression object with default error handling. */ - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - /* Add some application-specific error messages (from cderror.h) */ - jerr.addon_message_table = cdjpeg_message_table; - jerr.first_addon_message = JMSG_FIRSTADDONCODE; - jerr.last_addon_message = JMSG_LASTADDONCODE; - - /* Now safe to enable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &cinfo); -#endif - - /* Initialize JPEG parameters. - * Much of this may be overridden later. - * In particular, we don't yet know the input file's color space, - * but we need to provide some value for jpeg_set_defaults() to work. - */ - - cinfo.in_color_space = JCS_RGB; /* arbitrary guess */ - jpeg_set_defaults(&cinfo); - - /* Scan command line to find file names. - * It is convenient to use just one switch-parsing routine, but the switch - * values read here are ignored; we will rescan the switches after opening - * the input file. - */ - - file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); - -#ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - } -#else - /* Unix style: expect zero or one file name */ - if (file_index < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } -#endif /* TWO_FILE_COMMANDLINE */ - - /* Open the input file. */ - if (file_index < argc) { - if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ - input_file = read_stdin(); - } - - /* Open the output file. */ - if (outfilename != NULL) { - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, outfilename); - exit(EXIT_FAILURE); - } - } else { - /* default output file is stdout */ - output_file = write_stdout(); - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &cinfo, &progress); -#endif - - /* Figure out the input file format, and set up to read it. */ - src_mgr = select_file_type(&cinfo, input_file); - src_mgr->input_file = input_file; - - /* Read the input file header to obtain file size & colorspace. */ - (*src_mgr->start_input) (&cinfo, src_mgr); - - /* Now that we know input colorspace, fix colorspace-dependent defaults */ - jpeg_default_colorspace(&cinfo); - - /* Adjust default compression parameters by re-parsing the options */ - file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); - - /* Specify data destination for compression */ - jpeg_stdio_dest(&cinfo, output_file); - - /* Start compressor */ - jpeg_start_compress(&cinfo, TRUE); - - /* Process data */ - while (cinfo.next_scanline < cinfo.image_height) { - num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr); - (void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines); - } - - /* Finish compression and release memory */ - (*src_mgr->finish_input) (&cinfo, src_mgr); - jpeg_finish_compress(&cinfo); - jpeg_destroy_compress(&cinfo); - - /* Close files, if we opened them */ - if (input_file != stdin) - fclose(input_file); - if (output_file != stdout) - fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &cinfo); -#endif - - /* All done. */ - exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/code/jpeg-9f/cjpegalt.c b/code/jpeg-9f/cjpegalt.c deleted file mode 100644 index c89827e2..00000000 --- a/code/jpeg-9f/cjpegalt.c +++ /dev/null @@ -1,791 +0,0 @@ -/* - * alternate cjpeg.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * Modified 2009-2023 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains an alternate user interface for the JPEG compressor. - * One or more input files are named on the command line, and output file - * names are created by substituting ".jpg" for the input file's extension. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "jversion.h" /* for version message */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - -#ifndef PATH_MAX /* ANSI maximum-pathname-length constant */ -#define PATH_MAX 256 -#endif - - -/* Create the add-on message string table. */ - -#define JMESSAGE(code,string) string , - -static const char * const cdjpeg_message_table[] = { -#include "cderror.h" - NULL -}; - - -/* - * Automatic determination of available memory. - */ - -static long default_maxmem; /* saves value determined at startup, or 0 */ - -#ifndef FREE_MEM_ESTIMATE /* may be defined from command line */ - -#ifdef MSDOS /* For MS-DOS (unless flat-memory model) */ - -#include /* for access to intdos() call */ - -LOCAL(long) -unused_dos_memory (void) -/* Obtain total amount of unallocated DOS memory */ -{ - union REGS regs; - long nparas; - - regs.h.ah = 0x48; /* DOS function Allocate Memory Block */ - regs.x.bx = 0xFFFF; /* Ask for more memory than DOS can have */ - (void) intdos(®s, ®s); - /* DOS will fail and return # of paragraphs actually available in BX. */ - nparas = (unsigned int) regs.x.bx; - /* Times 16 to convert to bytes. */ - return nparas << 4; -} - -/* The default memory setting is 95% of the available space. */ -#define FREE_MEM_ESTIMATE ((unused_dos_memory() * 95L) / 100L) - -#endif /* MSDOS */ - -#ifdef ATARI /* For Atari ST/Mega/STE/TT/Falcon, Pure C or Turbo C */ - -#include - -/* The default memory setting is 90% of the available space. */ -#define FREE_MEM_ESTIMATE (((long) coreleft() * 90L) / 100L) - -#endif /* ATARI */ - -/* Add memory-estimation procedures for other operating systems here, - * with appropriate #ifdef's around them. - */ - -#endif /* !FREE_MEM_ESTIMATE */ - - -/* - * This routine determines what format the input file is, - * and selects the appropriate input-reading module. - * - * To determine which family of input formats the file belongs to, - * we may look only at the first byte of the file, since C does not - * guarantee that more than one character can be pushed back with ungetc. - * Looking at additional bytes would require one of these approaches: - * 1) assume we can fseek() the input file (fails for piped input); - * 2) assume we can push back more than one character (works in - * some C implementations, but unportable); - * 3) provide our own buffering (breaks input readers that want to use - * stdio directly, such as the RLE library); - * or 4) don't put back the data, and modify the input_init methods to assume - * they start reading after the start of file (also breaks RLE library). - * #1 is attractive for MS-DOS but is untenable on Unix. - * - * The most portable solution for file types that can't be identified by their - * first byte is to make the user tell us what they are. This is also the - * only approach for "raw" file types that contain only arbitrary values. - * We presently apply this method for Targa files. Most of the time Targa - * files start with 0x00, so we recognize that case. Potentially, however, - * a Targa file could start with any byte value (byte 0 is the length of the - * seldom-used ID field), so we provide a switch to force Targa input mode. - */ - -static boolean is_targa; /* records user -targa switch */ - - -LOCAL(cjpeg_source_ptr) -select_file_type (j_compress_ptr cinfo, FILE * infile) -{ - int c; - - if (is_targa) { -#ifdef TARGA_SUPPORTED - return jinit_read_targa(cinfo); -#else - ERREXIT(cinfo, JERR_TGA_NOTCOMP); -#endif - } - - if ((c = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_INPUT_EMPTY); - if (ungetc(c, infile) == EOF) - ERREXIT(cinfo, JERR_UNGETC_FAILED); - - switch (c) { -#ifdef BMP_SUPPORTED - case 'B': - return jinit_read_bmp(cinfo); -#endif -#ifdef GIF_SUPPORTED - case 'G': - return jinit_read_gif(cinfo); -#endif -#ifdef PPM_SUPPORTED - case 'P': - return jinit_read_ppm(cinfo); -#endif -#ifdef RLE_SUPPORTED - case 'R': - return jinit_read_rle(cinfo); -#endif -#ifdef TARGA_SUPPORTED - case 0x00: - return jinit_read_targa(cinfo); -#endif - default: - ERREXIT(cinfo, JERR_UNKNOWN_FORMAT); - break; - } - - return NULL; /* suppress compiler warnings */ -} - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] inputfile(s)\n", progname); - fprintf(stderr, "List of input files may use wildcards (* and ?)\n"); - fprintf(stderr, "Output filename is same as input filename, but extension .jpg\n"); - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -quality N[,...] Compression quality (0..100; 5-95 is useful range)\n"); - fprintf(stderr, " -grayscale Create monochrome JPEG file\n"); - fprintf(stderr, " -rgb Create RGB JPEG file\n"); -#ifdef ENTROPY_OPT_SUPPORTED - fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); -#endif -#ifdef C_PROGRESSIVE_SUPPORTED - fprintf(stderr, " -progressive Create progressive JPEG file\n"); -#endif -#ifdef DCT_SCALING_SUPPORTED - fprintf(stderr, " -scale M/N Scale image by fraction M/N, eg, 1/2\n"); -#endif -#ifdef TARGA_SUPPORTED - fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n"); -#endif - fprintf(stderr, "Switches for advanced users:\n"); -#ifdef C_ARITH_CODING_SUPPORTED - fprintf(stderr, " -arithmetic Use arithmetic coding\n"); -#endif -#ifdef DCT_SCALING_SUPPORTED - fprintf(stderr, " -block N DCT block size (1..16; default is 8)\n"); -#endif -#if JPEG_LIB_VERSION_MAJOR >= 9 - fprintf(stderr, " -rgb1 Create RGB JPEG file with reversible color transform\n"); - fprintf(stderr, " -bgycc Create big gamut YCC JPEG file\n"); -#endif -#ifdef DCT_ISLOW_SUPPORTED - fprintf(stderr, " -dct int Use integer DCT method%s\n", - (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); -#endif -#ifdef DCT_IFAST_SUPPORTED - fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", - (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); -#endif -#ifdef DCT_FLOAT_SUPPORTED - fprintf(stderr, " -dct float Use floating-point DCT method%s\n", - (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); -#endif - fprintf(stderr, " -nosmooth Don't use high-quality downsampling\n"); - fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); -#ifdef INPUT_SMOOTHING_SUPPORTED - fprintf(stderr, " -smooth N Smooth dithered input (N=1..100 is strength)\n"); -#endif -#ifndef FREE_MEM_ESTIMATE - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); -#endif - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - fprintf(stderr, "Switches for wizards:\n"); - fprintf(stderr, " -baseline Force baseline quantization tables\n"); - fprintf(stderr, " -qtables file Use quantization tables given in file\n"); - fprintf(stderr, " -qslots N[,...] Set component quantization tables\n"); - fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n"); -#ifdef C_MULTISCAN_FILES_SUPPORTED - fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); -#endif - exit(EXIT_FAILURE); -} - - -LOCAL(int) -parse_switches (j_compress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - boolean force_baseline; - boolean simple_progressive; - char * qualityarg = NULL; /* saves -quality parm if any */ - char * qtablefile = NULL; /* saves -qtables filename if any */ - char * qslotsarg = NULL; /* saves -qslots parm if any */ - char * samplearg = NULL; /* saves -sample parm if any */ - char * scansarg = NULL; /* saves -scans parm if any */ - - /* Set up default JPEG parameters. */ - - force_baseline = FALSE; /* by default, allow 16-bit quantizers */ - simple_progressive = FALSE; - is_targa = FALSE; - outfilename = NULL; - cinfo->err->trace_level = 0; - if (default_maxmem > 0) /* override library's default value */ - cinfo->mem->max_memory_to_use = default_maxmem; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "arithmetic", 1)) { - /* Use arithmetic coding. */ -#ifdef C_ARITH_CODING_SUPPORTED - cinfo->arith_code = TRUE; -#else - fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "baseline", 2)) { - /* Force baseline-compatible output (8-bit quantizer values). */ - force_baseline = TRUE; - - } else if (keymatch(arg, "block", 2)) { - /* Set DCT block size. */ -#if defined DCT_SCALING_SUPPORTED && JPEG_LIB_VERSION_MAJOR >= 8 && \ - (JPEG_LIB_VERSION_MAJOR > 8 || JPEG_LIB_VERSION_MINOR >= 3) - int val; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &val) != 1) - usage(); - if (val < 1 || val > 16) - usage(); - cinfo->block_size = val; -#else - fprintf(stderr, "%s: sorry, block size setting not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "dct", 2)) { - /* Select DCT algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "int", 1)) { - cinfo->dct_method = JDCT_ISLOW; - } else if (keymatch(argv[argn], "fast", 2)) { - cinfo->dct_method = JDCT_IFAST; - } else if (keymatch(argv[argn], "float", 2)) { - cinfo->dct_method = JDCT_FLOAT; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's CJPEG, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { - /* Force a monochrome JPEG file to be generated. */ - jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); - - } else if (keymatch(arg, "rgb", 3) || keymatch(arg, "rgb1", 4)) { - /* Force an RGB JPEG file to be generated. */ -#if JPEG_LIB_VERSION_MAJOR >= 9 - /* Note: Entropy table assignment in jpeg_set_colorspace depends - * on color_transform. - */ - cinfo->color_transform = arg[3] ? JCT_SUBTRACT_GREEN : JCT_NONE; -#endif - jpeg_set_colorspace(cinfo, JCS_RGB); - - } else if (keymatch(arg, "bgycc", 5)) { - /* Force a big gamut YCC JPEG file to be generated. */ -#if JPEG_LIB_VERSION_MAJOR >= 9 && \ - (JPEG_LIB_VERSION_MAJOR > 9 || JPEG_LIB_VERSION_MINOR >= 1) - jpeg_set_colorspace(cinfo, JCS_BG_YCC); -#else - fprintf(stderr, "%s: sorry, BG_YCC colorspace not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "nosmooth", 3)) { - /* Suppress fancy downsampling. */ - cinfo->do_fancy_downsampling = FALSE; - - } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { - /* Enable entropy parm optimization. */ -#ifdef ENTROPY_OPT_SUPPORTED - cinfo->optimize_coding = TRUE; -#else - fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "progressive", 1)) { - /* Select simple progressive mode. */ -#ifdef C_PROGRESSIVE_SUPPORTED - simple_progressive = TRUE; - /* We must postpone execution until num_components is known. */ -#else - fprintf(stderr, "%s: sorry, progressive output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "quality", 1)) { - /* Quality ratings (quantization table scaling factors). */ - if (++argn >= argc) /* advance to next argument */ - usage(); - qualityarg = argv[argn]; - - } else if (keymatch(arg, "qslots", 2)) { - /* Quantization table slot numbers. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - qslotsarg = argv[argn]; - /* Must delay setting qslots until after we have processed any - * colorspace-determining switches, since jpeg_set_colorspace sets - * default quant table numbers. - */ - - } else if (keymatch(arg, "qtables", 2)) { - /* Quantization tables fetched from file. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - qtablefile = argv[argn]; - /* We postpone actually reading the file in case -quality comes later. */ - - } else if (keymatch(arg, "restart", 1)) { - /* Restart interval in MCU rows (or in MCUs with 'b'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (lval < 0 || lval > 65535L) - usage(); - if (ch == 'b' || ch == 'B') { - cinfo->restart_interval = (unsigned int) lval; - cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ - } else { - cinfo->restart_in_rows = (int) lval; - /* restart_interval will be computed during startup */ - } - - } else if (keymatch(arg, "sample", 2)) { - /* Set sampling factors. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - samplearg = argv[argn]; - /* Must delay setting sample factors until after we have processed any - * colorspace-determining switches, since jpeg_set_colorspace sets - * default sampling factors. - */ - - } else if (keymatch(arg, "scale", 4)) { - /* Scale the image by a fraction M/N. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d/%d", - &cinfo->scale_num, &cinfo->scale_denom) != 2) - usage(); - - } else if (keymatch(arg, "scans", 4)) { - /* Set scan script. */ -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (++argn >= argc) /* advance to next argument */ - usage(); - scansarg = argv[argn]; - /* We must postpone reading the file in case -progressive appears. */ -#else - fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "smooth", 2)) { - /* Set input smoothing factor. */ - int val; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &val) != 1) - usage(); - if (val < 0 || val > 100) - usage(); - cinfo->smoothing_factor = val; - - } else if (keymatch(arg, "targa", 1)) { - /* Input file is Targa format. */ - is_targa = TRUE; - - } else { - usage(); /* bogus switch */ - } - } - - /* Post-switch-scanning cleanup */ - - if (for_real) { - - /* Set quantization tables for selected quality. */ - /* Some or all may be overridden if -qtables is present. */ - if (qualityarg != NULL) /* process -quality if it was present */ - if (! set_quality_ratings(cinfo, qualityarg, force_baseline)) - usage(); - - if (qtablefile != NULL) /* process -qtables if it was present */ - if (! read_quant_tables(cinfo, qtablefile, force_baseline)) - usage(); - - if (qslotsarg != NULL) /* process -qslots if it was present */ - if (! set_quant_slots(cinfo, qslotsarg)) - usage(); - - if (samplearg != NULL) /* process -sample if it was present */ - if (! set_sample_factors(cinfo, samplearg)) - usage(); - -#ifdef C_PROGRESSIVE_SUPPORTED - if (simple_progressive) /* process -progressive; -scans can override */ - jpeg_simple_progression(cinfo); -#endif - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (scansarg != NULL) /* process -scans if it was present */ - if (! read_scan_script(cinfo, scansarg)) - usage(); -#endif - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * Check for overwrite of an existing file; clear it with user - */ - -#ifndef NO_OVERWRITE_CHECK - -LOCAL(boolean) -is_write_ok (char * outfname) -{ - FILE * ofile; - int ch; - - ofile = fopen(outfname, READ_BINARY); - if (ofile == NULL) - return TRUE; /* not present */ - fclose(ofile); /* oops, it is present */ - - for (;;) { - fprintf(stderr, "%s already exists, overwrite it? [y/n] ", - outfname); - fflush(stderr); - ch = getc(stdin); - if (ch != '\n') /* flush rest of line */ - while (getc(stdin) != '\n') - /* nothing */; - - switch (ch) { - case 'Y': - case 'y': - return TRUE; - case 'N': - case 'n': - return FALSE; - /* otherwise, ask again */ - } - } -} - -#endif - - -/* - * Process a single input file name, and return its index in argv[]. - * File names at or to left of old_file_index have been processed already. - */ - -LOCAL(int) -process_one_file (int argc, char **argv, int old_file_index) -{ - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - char *infilename; - char workfilename[PATH_MAX]; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - int file_index; - cjpeg_source_ptr src_mgr; - FILE * input_file = NULL; - FILE * output_file = NULL; - JDIMENSION num_scanlines; - - /* Initialize the JPEG compression object with default error handling. */ - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - /* Add some application-specific error messages (from cderror.h) */ - jerr.addon_message_table = cdjpeg_message_table; - jerr.first_addon_message = JMSG_FIRSTADDONCODE; - jerr.last_addon_message = JMSG_LASTADDONCODE; - - /* Now safe to enable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &cinfo); -#endif - - /* Initialize JPEG parameters. - * Much of this may be overridden later. - * In particular, we don't yet know the input file's color space, - * but we need to provide some value for jpeg_set_defaults() to work. - */ - - cinfo.in_color_space = JCS_RGB; /* arbitrary guess */ - jpeg_set_defaults(&cinfo); - - /* Scan command line to find next file name. - * It is convenient to use just one switch-parsing routine, but the switch - * values read here are ignored; we will rescan the switches after opening - * the input file. - */ - - file_index = parse_switches(&cinfo, argc, argv, old_file_index, FALSE); - if (file_index >= argc) { - fprintf(stderr, "%s: missing input file name\n", progname); - usage(); - } - - /* Open the input file. */ - infilename = argv[file_index]; - if ((input_file = fopen(infilename, READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, infilename); - goto fail; - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &cinfo, &progress); -#endif - - /* Figure out the input file format, and set up to read it. */ - src_mgr = select_file_type(&cinfo, input_file); - src_mgr->input_file = input_file; - - /* Read the input file header to obtain file size & colorspace. */ - (*src_mgr->start_input) (&cinfo, src_mgr); - - /* Now that we know input colorspace, fix colorspace-dependent defaults */ - jpeg_default_colorspace(&cinfo); - - /* Adjust default compression parameters by re-parsing the options */ - file_index = parse_switches(&cinfo, argc, argv, old_file_index, TRUE); - - /* If user didn't supply -outfile switch, select output file name. */ - if (outfilename == NULL) { - int i; - - outfilename = workfilename; - /* Make outfilename be infilename with .jpg substituted for extension */ - strcpy(outfilename, infilename); - for (i = (int)strlen(outfilename)-1; i >= 0; i--) { - switch (outfilename[i]) { - case ':': - case '/': - case '\\': - i = 0; /* stop scanning */ - break; - case '.': - outfilename[i] = '\0'; /* lop off existing extension */ - i = 0; /* stop scanning */ - break; - default: - break; /* keep scanning */ - } - } - strcat(outfilename, ".jpg"); - } - - fprintf(stderr, "Compressing %s => %s\n", infilename, outfilename); -#ifndef NO_OVERWRITE_CHECK - if (! is_write_ok(outfilename)) - goto fail; -#endif - - /* Open the output file. */ - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't create %s\n", progname, outfilename); - goto fail; - } - - /* Specify data destination for compression */ - jpeg_stdio_dest(&cinfo, output_file); - - /* Start compressor */ - jpeg_start_compress(&cinfo, TRUE); - - /* Process data */ - while (cinfo.next_scanline < cinfo.image_height) { - num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr); - (void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines); - } - - /* Finish compression and release memory */ - (*src_mgr->finish_input) (&cinfo, src_mgr); - jpeg_finish_compress(&cinfo); - - /* Clean up and exit */ -fail: - jpeg_destroy_compress(&cinfo); - - if (input_file != NULL) fclose(input_file); - if (output_file != NULL) fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &cinfo); -#endif - - /* Disable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) NULL); -#endif - - return file_index; -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - int file_index; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - -#ifdef MSDOS - progname = "cjpeg"; /* DOS tends to be too verbose about argv[0] */ -#else - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "cjpeg"; /* in case C library doesn't provide it */ -#endif - - /* The default maxmem must be computed only once at program startup, - * since releasing memory with free() won't give it back to the OS. - */ -#ifdef FREE_MEM_ESTIMATE - default_maxmem = FREE_MEM_ESTIMATE; -#else - default_maxmem = 0; -#endif - - /* Scan command line, parse switches and locate input file names */ - - if (argc < 2) - usage(); /* nothing on the command line?? */ - - file_index = 0; - - while (file_index < argc-1) - file_index = process_one_file(argc, argv, file_index); - - /* All done. */ - exit(EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/code/jpeg-9f/ckconfig.c b/code/jpeg-9f/ckconfig.c deleted file mode 100644 index e658623f..00000000 --- a/code/jpeg-9f/ckconfig.c +++ /dev/null @@ -1,402 +0,0 @@ -/* - * ckconfig.c - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - */ - -/* - * This program is intended to help you determine how to configure the JPEG - * software for installation on a particular system. The idea is to try to - * compile and execute this program. If your compiler fails to compile the - * program, make changes as indicated in the comments below. Once you can - * compile the program, run it, and it will produce a "jconfig.h" file for - * your system. - * - * As a general rule, each time you try to compile this program, - * pay attention only to the *first* error message you get from the compiler. - * Many C compilers will issue lots of spurious error messages once they - * have gotten confused. Go to the line indicated in the first error message, - * and read the comments preceding that line to see what to change. - * - * Almost all of the edits you may need to make to this program consist of - * changing a line that reads "#define SOME_SYMBOL" to "#undef SOME_SYMBOL", - * or vice versa. This is called defining or undefining that symbol. - */ - - -/* First we must see if your system has the include files we need. - * We start out with the assumption that your system has all the ANSI-standard - * include files. If you get any error trying to include one of these files, - * undefine the corresponding HAVE_xxx symbol. - */ - -#define HAVE_STDDEF_H /* replace 'define' by 'undef' if error here */ -#ifdef HAVE_STDDEF_H /* next line will be skipped if you undef... */ -#include -#endif - -#define HAVE_STDLIB_H /* same thing for stdlib.h */ -#ifdef HAVE_STDLIB_H -#include -#endif - -#include /* If you ain't got this, you ain't got C. */ - -/* We have to see if your string functions are defined by - * strings.h (old BSD convention) or string.h (everybody else). - * We try the non-BSD convention first; define NEED_BSD_STRINGS - * if the compiler says it can't find string.h. - */ - -#undef NEED_BSD_STRINGS - -#ifdef NEED_BSD_STRINGS -#include -#else -#include -#endif - -/* On some systems (especially older Unix machines), type size_t is - * defined only in the include file . If you get a failure - * on the size_t test below, try defining NEED_SYS_TYPES_H. - */ - -#undef NEED_SYS_TYPES_H /* start by assuming we don't need it */ -#ifdef NEED_SYS_TYPES_H -#include -#endif - - -/* Usually type size_t is defined in one of the include files we've included - * above. If not, you'll get an error on the "typedef size_t my_size_t;" line. - * In that case, first try defining NEED_SYS_TYPES_H just above. - * If that doesn't work, you'll have to search through your system library - * to figure out which include file defines "size_t". Look for a line that - * says "typedef something-or-other size_t;". Then, change the line below - * that says "#include " to instead include the file - * you found size_t in, and define NEED_SPECIAL_INCLUDE. If you can't find - * type size_t anywhere, try replacing "#include " with - * "typedef unsigned int size_t;". - */ - -#undef NEED_SPECIAL_INCLUDE /* assume we DON'T need it, for starters */ - -#ifdef NEED_SPECIAL_INCLUDE -#include -#endif - -typedef size_t my_size_t; /* The payoff: do we have size_t now? */ - - -/* The next question is whether your compiler supports ANSI-style function - * prototypes. You need to know this in order to choose between using - * makefile.ansi and using makefile.unix. - * The #define line below is set to assume you have ANSI function prototypes. - * If you get an error in this group of lines, undefine HAVE_PROTOTYPES. - */ - -#define HAVE_PROTOTYPES - -#ifdef HAVE_PROTOTYPES -int testfunction (int arg1, int * arg2); /* check prototypes */ - -struct methods_struct { /* check method-pointer declarations */ - int (*error_exit) (char *msgtext); - int (*trace_message) (char *msgtext); - int (*another_method) (void); -}; - -int testfunction (int arg1, int * arg2) /* check definitions */ -{ - return arg2[arg1]; -} - -int test2function (void) /* check void arg list */ -{ - return 0; -} -#endif - - -/* Now we want to find out if your compiler knows what "unsigned char" means. - * If you get an error on the "unsigned char un_char;" line, - * then undefine HAVE_UNSIGNED_CHAR. - */ - -#define HAVE_UNSIGNED_CHAR - -#ifdef HAVE_UNSIGNED_CHAR -unsigned char un_char; -#endif - - -/* Now we want to find out if your compiler knows what "unsigned short" means. - * If you get an error on the "unsigned short un_short;" line, - * then undefine HAVE_UNSIGNED_SHORT. - */ - -#define HAVE_UNSIGNED_SHORT - -#ifdef HAVE_UNSIGNED_SHORT -unsigned short un_short; -#endif - - -/* Now we want to find out if your compiler understands type "void". - * If you get an error anywhere in here, undefine HAVE_VOID. - */ - -#define HAVE_VOID - -#ifdef HAVE_VOID -/* Caution: a C++ compiler will insist on complete prototypes */ -typedef void * void_ptr; /* check void * */ -#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */ -typedef void (*void_func) (int a, int b); -#else -typedef void (*void_func) (); -#endif - -#ifdef HAVE_PROTOTYPES /* check void function result */ -void test3function (void_ptr arg1, void_func arg2) -#else -void test3function (arg1, arg2) - void_ptr arg1; - void_func arg2; -#endif -{ - char * locptr = (char *) arg1; /* check casting to and from void * */ - arg1 = (void *) locptr; - (*arg2) (1, 2); /* check call of fcn returning void */ -} -#endif - - -/* Now we want to find out if your compiler knows what "const" means. - * If you get an error here, undefine HAVE_CONST. - */ - -#define HAVE_CONST - -#ifdef HAVE_CONST -static const int carray[3] = {1, 2, 3}; - -#ifdef HAVE_PROTOTYPES -int test4function (const int arg1) -#else -int test4function (arg1) - const int arg1; -#endif -{ - return carray[arg1]; -} -#endif - - -/* If you get an error or warning about this structure definition, - * define INCOMPLETE_TYPES_BROKEN. - */ - -#undef INCOMPLETE_TYPES_BROKEN - -#ifndef INCOMPLETE_TYPES_BROKEN -typedef struct undefined_structure * undef_struct_ptr; -#endif - - -/* If you get an error about duplicate names, - * define NEED_SHORT_EXTERNAL_NAMES. - */ - -#undef NEED_SHORT_EXTERNAL_NAMES - -#ifndef NEED_SHORT_EXTERNAL_NAMES - -int possibly_duplicate_function () -{ - return 0; -} - -int possibly_dupli_function () -{ - return 1; -} - -#endif - - - -/************************************************************************ - * OK, that's it. You should not have to change anything beyond this - * point in order to compile and execute this program. (You might get - * some warnings, but you can ignore them.) - * When you run the program, it will make a couple more tests that it - * can do automatically, and then it will create jconfig.h and print out - * any additional suggestions it has. - ************************************************************************ - */ - - -#ifdef HAVE_PROTOTYPES -int is_char_signed (int arg) -#else -int is_char_signed (arg) - int arg; -#endif -{ - if (arg == 189) { /* expected result for unsigned char */ - return 0; /* type char is unsigned */ - } - else if (arg != -67) { /* expected result for signed char */ - printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n"); - printf("I fear the JPEG software will not work at all.\n\n"); - } - return 1; /* assume char is signed otherwise */ -} - - -#ifdef HAVE_PROTOTYPES -int is_shifting_signed (long arg) -#else -int is_shifting_signed (arg) - long arg; -#endif -/* See whether right-shift on a long is signed or not. */ -{ - long res = arg >> 4; - - if (res == -0x7F7E80CL) { /* expected result for signed shift */ - return 1; /* right shift is signed */ - } - /* see if unsigned-shift hack will fix it. */ - /* we can't just test exact value since it depends on width of long... */ - res |= (~0L) << (32-4); - if (res == -0x7F7E80CL) { /* expected result now? */ - return 0; /* right shift is unsigned */ - } - printf("Right shift isn't acting as I expect it to.\n"); - printf("I fear the JPEG software will not work at all.\n\n"); - return 0; /* try it with unsigned anyway */ -} - - -#ifdef HAVE_PROTOTYPES -int main (int argc, char ** argv) -#else -int main (argc, argv) - int argc; - char ** argv; -#endif -{ - char signed_char_check = (char) (-67); - FILE *outfile; - - /* Attempt to write jconfig.h */ - if ((outfile = fopen("jconfig.h", "w")) == NULL) { - printf("Failed to write jconfig.h\n"); - return 1; - } - - /* Write out all the info */ - fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n"); - fprintf(outfile, "/* see jconfig.txt for explanations */\n\n"); -#ifdef HAVE_PROTOTYPES - fprintf(outfile, "#define HAVE_PROTOTYPES\n"); -#else - fprintf(outfile, "#undef HAVE_PROTOTYPES\n"); -#endif -#ifdef HAVE_UNSIGNED_CHAR - fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n"); -#else - fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n"); -#endif -#ifdef HAVE_UNSIGNED_SHORT - fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n"); -#else - fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n"); -#endif -#ifdef HAVE_VOID - fprintf(outfile, "/* #define void char */\n"); -#else - fprintf(outfile, "#define void char\n"); -#endif -#ifdef HAVE_CONST - fprintf(outfile, "/* #define const */\n"); -#else - fprintf(outfile, "#define const\n"); -#endif - if (is_char_signed((int) signed_char_check)) - fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n"); - else - fprintf(outfile, "#define CHAR_IS_UNSIGNED\n"); -#ifdef HAVE_STDDEF_H - fprintf(outfile, "#define HAVE_STDDEF_H\n"); -#else - fprintf(outfile, "#undef HAVE_STDDEF_H\n"); -#endif -#ifdef HAVE_STDLIB_H - fprintf(outfile, "#define HAVE_STDLIB_H\n"); -#else - fprintf(outfile, "#undef HAVE_STDLIB_H\n"); -#endif -#ifdef NEED_BSD_STRINGS - fprintf(outfile, "#define NEED_BSD_STRINGS\n"); -#else - fprintf(outfile, "#undef NEED_BSD_STRINGS\n"); -#endif -#ifdef NEED_SYS_TYPES_H - fprintf(outfile, "#define NEED_SYS_TYPES_H\n"); -#else - fprintf(outfile, "#undef NEED_SYS_TYPES_H\n"); -#endif - fprintf(outfile, "#undef NEED_FAR_POINTERS\n"); -#ifdef NEED_SHORT_EXTERNAL_NAMES - fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n"); -#else - fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n"); -#endif -#ifdef INCOMPLETE_TYPES_BROKEN - fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n"); -#else - fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n"); -#endif - fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n"); - if (is_shifting_signed(-0x7F7E80B1L)) - fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n"); - else - fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n"); - fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n"); - fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n"); - fprintf(outfile, "#define BMP_SUPPORTED /* BMP image file format */\n"); - fprintf(outfile, "#define GIF_SUPPORTED /* GIF image file format */\n"); - fprintf(outfile, "#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */\n"); - fprintf(outfile, "#undef RLE_SUPPORTED /* Utah RLE image file format */\n"); - fprintf(outfile, "#define TARGA_SUPPORTED /* Targa image file format */\n\n"); - fprintf(outfile, "#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */\n"); - fprintf(outfile, "#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */\n"); - fprintf(outfile, "#undef DONT_USE_B_MODE\n"); - fprintf(outfile, "/* #define PROGRESS_REPORT */ /* optional */\n"); - fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n"); - - /* Close the jconfig.h file */ - fclose(outfile); - - /* User report */ - printf("Configuration check for Independent JPEG Group's software done.\n"); - printf("\nI have written the jconfig.h file for you.\n\n"); -#ifdef HAVE_PROTOTYPES - printf("You should use makefile.ansi as the starting point for your Makefile.\n"); -#else - printf("You should use makefile.unix as the starting point for your Makefile.\n"); -#endif - -#ifdef NEED_SPECIAL_INCLUDE - printf("\nYou'll need to change jconfig.h to include the system include file\n"); - printf("that you found type size_t in, or add a direct definition of type\n"); - printf("size_t if that's what you used. Just add it to the end.\n"); -#endif - - return 0; -} diff --git a/code/jpeg-9f/djpeg.c b/code/jpeg-9f/djpeg.c deleted file mode 100644 index a01b3968..00000000 --- a/code/jpeg-9f/djpeg.c +++ /dev/null @@ -1,631 +0,0 @@ -/* - * djpeg.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * Modified 2009-2019 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a command-line user interface for the JPEG decompressor. - * It should work on any system with Unix- or MS-DOS-style command lines. - * - * Two different command line styles are permitted, depending on the - * compile-time switch TWO_FILE_COMMANDLINE: - * djpeg [options] inputfile outputfile - * djpeg [options] [inputfile] - * In the second style, output is always to standard output, which you'd - * normally redirect to a file or pipe to some other program. Input is - * either from a named file or from standard input (typically redirected). - * The second style is convenient on Unix but is unhelpful on systems that - * don't support pipes. Also, you MUST use the first style if your system - * doesn't do binary I/O to stdin/stdout. - * To simplify script writing, the "-outfile" switch is provided. The syntax - * djpeg [options] -outfile outputfile inputfile - * works regardless of which command line style is used. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "jversion.h" /* for version message */ - -#include /* to declare isprint() */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - - -/* Create the add-on message string table. */ - -#define JMESSAGE(code,string) string , - -static const char * const cdjpeg_message_table[] = { -#include "cderror.h" - NULL -}; - - -/* - * This list defines the known output image formats - * (not all of which need be supported by a given version). - * You can change the default output format by defining DEFAULT_FMT; - * indeed, you had better do so if you undefine PPM_SUPPORTED. - */ - -typedef enum { - FMT_BMP, /* BMP format (Windows flavor) */ - FMT_GIF, /* GIF format (LZW compressed) */ - FMT_GIF0, /* GIF format (uncompressed) */ - FMT_OS2, /* BMP format (OS/2 flavor) */ - FMT_PPM, /* PPM/PGM (PBMPLUS formats) */ - FMT_RLE, /* RLE format */ - FMT_TARGA, /* Targa format */ - FMT_TIFF /* TIFF format */ -} IMAGE_FORMATS; - -#ifndef DEFAULT_FMT /* so can override from CFLAGS in Makefile */ -#define DEFAULT_FMT FMT_PPM -#endif - -static IMAGE_FORMATS requested_fmt; - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - * The main program in this file doesn't actually use this capability... - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -colors N Reduce image to no more than N colors\n"); - fprintf(stderr, " -fast Fast, low-quality processing\n"); - fprintf(stderr, " -grayscale Force grayscale output\n"); - fprintf(stderr, " -rgb Force RGB output\n"); -#ifdef IDCT_SCALING_SUPPORTED - fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n"); -#endif -#ifdef BMP_SUPPORTED - fprintf(stderr, " -bmp Select BMP output format (Windows style)%s\n", - (DEFAULT_FMT == FMT_BMP ? " (default)" : "")); -#endif -#ifdef GIF_SUPPORTED - fprintf(stderr, " -gif Select GIF output format (LZW compressed)%s\n", - (DEFAULT_FMT == FMT_GIF ? " (default)" : "")); - fprintf(stderr, " -gif0 Select GIF output format (uncompressed)%s\n", - (DEFAULT_FMT == FMT_GIF0 ? " (default)" : "")); -#endif -#ifdef BMP_SUPPORTED - fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n", - (DEFAULT_FMT == FMT_OS2 ? " (default)" : "")); -#endif -#ifdef PPM_SUPPORTED - fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n", - (DEFAULT_FMT == FMT_PPM ? " (default)" : "")); -#endif -#ifdef RLE_SUPPORTED - fprintf(stderr, " -rle Select Utah RLE output format%s\n", - (DEFAULT_FMT == FMT_RLE ? " (default)" : "")); -#endif -#ifdef TARGA_SUPPORTED - fprintf(stderr, " -targa Select Targa output format%s\n", - (DEFAULT_FMT == FMT_TARGA ? " (default)" : "")); -#endif - fprintf(stderr, "Switches for advanced users:\n"); -#ifdef DCT_ISLOW_SUPPORTED - fprintf(stderr, " -dct int Use integer DCT method%s\n", - (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); -#endif -#ifdef DCT_IFAST_SUPPORTED - fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", - (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); -#endif -#ifdef DCT_FLOAT_SUPPORTED - fprintf(stderr, " -dct float Use floating-point DCT method%s\n", - (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); -#endif - fprintf(stderr, " -dither fs Use F-S dithering (default)\n"); - fprintf(stderr, " -dither none Don't use dithering in quantization\n"); - fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n"); -#ifdef QUANT_2PASS_SUPPORTED - fprintf(stderr, " -map FILE Map to colors used in named image file\n"); -#endif - fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n"); -#ifdef QUANT_1PASS_SUPPORTED - fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n"); -#endif - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - exit(EXIT_FAILURE); -} - - -LOCAL(int) -parse_switches (j_decompress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - - /* Set up default JPEG parameters. */ - requested_fmt = DEFAULT_FMT; /* set default output file format */ - outfilename = NULL; - cinfo->err->trace_level = 0; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "bmp", 1)) { - /* BMP output format (Windows flavor). */ - requested_fmt = FMT_BMP; - - } else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) || - keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) { - /* Do color quantization. */ - int val; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &val) != 1) - usage(); - cinfo->desired_number_of_colors = val; - cinfo->quantize_colors = TRUE; - - } else if (keymatch(arg, "dct", 2)) { - /* Select IDCT algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "int", 1)) { - cinfo->dct_method = JDCT_ISLOW; - } else if (keymatch(argv[argn], "fast", 2)) { - cinfo->dct_method = JDCT_IFAST; - } else if (keymatch(argv[argn], "float", 2)) { - cinfo->dct_method = JDCT_FLOAT; - } else - usage(); - - } else if (keymatch(arg, "dither", 2)) { - /* Select dithering algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "fs", 2)) { - cinfo->dither_mode = JDITHER_FS; - } else if (keymatch(argv[argn], "none", 2)) { - cinfo->dither_mode = JDITHER_NONE; - } else if (keymatch(argv[argn], "ordered", 2)) { - cinfo->dither_mode = JDITHER_ORDERED; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "fast", 1)) { - /* Select recommended processing options for quick-and-dirty output. */ - cinfo->two_pass_quantize = FALSE; - cinfo->dither_mode = JDITHER_ORDERED; - if (! cinfo->quantize_colors) /* don't override an earlier -colors */ - cinfo->desired_number_of_colors = 216; - cinfo->dct_method = JDCT_FASTEST; - cinfo->do_fancy_upsampling = FALSE; - - } else if (keymatch(arg, "gif", 1)) { - /* GIF output format (LZW compressed). */ - requested_fmt = FMT_GIF; - - } else if (keymatch(arg, "gif0", 4)) { - /* GIF output format (uncompressed). */ - requested_fmt = FMT_GIF0; - - } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { - /* Force monochrome output. */ - cinfo->out_color_space = JCS_GRAYSCALE; - - } else if (keymatch(arg, "rgb", 3)) { - /* Force RGB output. */ - cinfo->out_color_space = JCS_RGB; - - } else if (keymatch(arg, "map", 3)) { - /* Quantize to a color map taken from an input file. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (for_real) { /* too expensive to do twice! */ -#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ - FILE * mapfile; - - if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - read_color_map(cinfo, mapfile); - fclose(mapfile); - cinfo->quantize_colors = TRUE; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "nosmooth", 3)) { - /* Suppress fancy upsampling. */ - cinfo->do_fancy_upsampling = FALSE; - - } else if (keymatch(arg, "onepass", 3)) { - /* Use fast one-pass quantization. */ - cinfo->two_pass_quantize = FALSE; - - } else if (keymatch(arg, "os2", 3)) { - /* BMP output format (OS/2 flavor). */ - requested_fmt = FMT_OS2; - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) { - /* PPM/PGM output format. */ - requested_fmt = FMT_PPM; - - } else if (keymatch(arg, "rle", 1)) { - /* RLE output format. */ - requested_fmt = FMT_RLE; - - } else if (keymatch(arg, "scale", 1)) { - /* Scale the output image by a fraction M/N. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%u/%u", - &cinfo->scale_num, &cinfo->scale_denom) < 1) - usage(); - - } else if (keymatch(arg, "targa", 1)) { - /* Targa output format. */ - requested_fmt = FMT_TARGA; - - } else { - usage(); /* bogus switch */ - } - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * Marker processor for COM and interesting APPn markers. - * This replaces the library's built-in processor, which just skips the marker. - * We want to print out the marker as text, to the extent possible. - * Note this code relies on a non-suspending data source. - */ - -LOCAL(unsigned int) -jpeg_getc (j_decompress_ptr cinfo) -/* Read next byte */ -{ - struct jpeg_source_mgr * datasrc = cinfo->src; - - if (datasrc->bytes_in_buffer == 0) { - if (! (*datasrc->fill_input_buffer) (cinfo)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } - datasrc->bytes_in_buffer--; - return GETJOCTET(*datasrc->next_input_byte++); -} - - -METHODDEF(boolean) -print_text_marker (j_decompress_ptr cinfo) -{ - boolean traceit = (cinfo->err->trace_level >= 1); - INT32 length; - unsigned int ch; - unsigned int lastch = 0; - - length = jpeg_getc(cinfo) << 8; - length += jpeg_getc(cinfo); - length -= 2; /* discount the length word itself */ - - if (traceit) { - if (cinfo->unread_marker == JPEG_COM) - fprintf(stderr, "Comment, length %ld:\n", (long) length); - else /* assume it is an APPn otherwise */ - fprintf(stderr, "APP%d, length %ld:\n", - cinfo->unread_marker - JPEG_APP0, (long) length); - } - - while (--length >= 0) { - ch = jpeg_getc(cinfo); - if (traceit) { - /* Emit the character in a readable form. - * Nonprintables are converted to \nnn form, - * while \ is converted to \\. - * Newlines in CR, CR/LF, or LF form will be printed as one newline. - */ - if (ch == '\r') { - fprintf(stderr, "\n"); - } else if (ch == '\n') { - if (lastch != '\r') - fprintf(stderr, "\n"); - } else if (ch == '\\') { - fprintf(stderr, "\\\\"); - } else if (isprint(ch)) { - putc(ch, stderr); - } else { - fprintf(stderr, "\\%03o", ch); - } - lastch = ch; - } - } - - if (traceit) - fprintf(stderr, "\n"); - - return TRUE; -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - struct jpeg_decompress_struct cinfo; - struct jpeg_error_mgr jerr; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - int file_index; - djpeg_dest_ptr dest_mgr = NULL; - FILE * input_file; - FILE * output_file; - JDIMENSION num_scanlines; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "djpeg"; /* in case C library doesn't provide it */ - - /* Initialize the JPEG decompression object with default error handling. */ - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_decompress(&cinfo); - /* Add some application-specific error messages (from cderror.h) */ - jerr.addon_message_table = cdjpeg_message_table; - jerr.first_addon_message = JMSG_FIRSTADDONCODE; - jerr.last_addon_message = JMSG_LASTADDONCODE; - - /* Insert custom marker processor for COM and APP12. - * APP12 is used by some digital camera makers for textual info, - * so we provide the ability to display it as text. - * If you like, additional APPn marker types can be selected for display, - * but don't try to override APP0 or APP14 this way (see libjpeg.txt). - */ - jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker); - jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker); - - /* Now safe to enable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &cinfo); -#endif - - /* Scan command line to find file names. */ - /* It is convenient to use just one switch-parsing routine, but the switch - * values read here are ignored; we will rescan the switches after opening - * the input file. - * (Exception: tracing level set here controls verbosity for COM markers - * found during jpeg_read_header...) - */ - - file_index = parse_switches(&cinfo, argc, argv, 0, FALSE); - -#ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - } -#else - /* Unix style: expect zero or one file name */ - if (file_index < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } -#endif /* TWO_FILE_COMMANDLINE */ - - /* Open the input file. */ - if (file_index < argc) { - if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ - input_file = read_stdin(); - } - - /* Open the output file. */ - if (outfilename != NULL) { - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, outfilename); - exit(EXIT_FAILURE); - } - } else { - /* default output file is stdout */ - output_file = write_stdout(); - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &cinfo, &progress); -#endif - - /* Specify data source for decompression */ - jpeg_stdio_src(&cinfo, input_file); - - /* Read file header, set default decompression parameters */ - (void) jpeg_read_header(&cinfo, TRUE); - - /* Adjust default decompression parameters by re-parsing the options */ - file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); - - /* Initialize the output module now to let it override any crucial - * option settings (for instance, GIF wants to force color quantization). - */ - switch (requested_fmt) { -#ifdef BMP_SUPPORTED - case FMT_BMP: - dest_mgr = jinit_write_bmp(&cinfo, FALSE); - break; - case FMT_OS2: - dest_mgr = jinit_write_bmp(&cinfo, TRUE); - break; -#endif -#ifdef GIF_SUPPORTED - case FMT_GIF: - dest_mgr = jinit_write_gif(&cinfo, TRUE); - break; - case FMT_GIF0: - dest_mgr = jinit_write_gif(&cinfo, FALSE); - break; -#endif -#ifdef PPM_SUPPORTED - case FMT_PPM: - dest_mgr = jinit_write_ppm(&cinfo); - break; -#endif -#ifdef RLE_SUPPORTED - case FMT_RLE: - dest_mgr = jinit_write_rle(&cinfo); - break; -#endif -#ifdef TARGA_SUPPORTED - case FMT_TARGA: - dest_mgr = jinit_write_targa(&cinfo); - break; -#endif - default: - ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT); - } - dest_mgr->output_file = output_file; - - /* Start decompressor */ - (void) jpeg_start_decompress(&cinfo); - - /* Write output file header */ - (*dest_mgr->start_output) (&cinfo, dest_mgr); - - /* Process data */ - while (cinfo.output_scanline < cinfo.output_height) { - num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer, - dest_mgr->buffer_height); - (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines); - } - -#ifdef PROGRESS_REPORT - /* Hack: count final pass as done in case finish_output does an extra pass. - * The library won't have updated completed_passes. - */ - progress.pub.completed_passes = progress.pub.total_passes; -#endif - - /* Finish decompression and release memory. - * I must do it in this order because output module has allocated memory - * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory. - */ - (*dest_mgr->finish_output) (&cinfo, dest_mgr); - (void) jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - - /* Close files, if we opened them */ - if (input_file != stdin) - fclose(input_file); - if (output_file != stdout) - fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &cinfo); -#endif - - /* All done. */ - exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/code/jpeg-9f/djpegalt.c b/code/jpeg-9f/djpegalt.c deleted file mode 100644 index 969c58b4..00000000 --- a/code/jpeg-9f/djpegalt.c +++ /dev/null @@ -1,766 +0,0 @@ -/* - * alternate djpeg.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * Modified 2009-2023 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains an alternate user interface for the JPEG decompressor. - * One or more input files are named on the command line, and output file - * names are created by substituting an appropriate extension. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "jversion.h" /* for version message */ - -#include /* to declare isprint() */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - -#ifndef PATH_MAX /* ANSI maximum-pathname-length constant */ -#define PATH_MAX 256 -#endif - - -/* Create the add-on message string table. */ - -#define JMESSAGE(code,string) string , - -static const char * const cdjpeg_message_table[] = { -#include "cderror.h" - NULL -}; - - -/* - * Automatic determination of available memory. - */ - -static long default_maxmem; /* saves value determined at startup, or 0 */ - -#ifndef FREE_MEM_ESTIMATE /* may be defined from command line */ - -#ifdef MSDOS /* For MS-DOS (unless flat-memory model) */ - -#include /* for access to intdos() call */ - -LOCAL(long) -unused_dos_memory (void) -/* Obtain total amount of unallocated DOS memory */ -{ - union REGS regs; - long nparas; - - regs.h.ah = 0x48; /* DOS function Allocate Memory Block */ - regs.x.bx = 0xFFFF; /* Ask for more memory than DOS can have */ - (void) intdos(®s, ®s); - /* DOS will fail and return # of paragraphs actually available in BX. */ - nparas = (unsigned int) regs.x.bx; - /* Times 16 to convert to bytes. */ - return nparas << 4; -} - -/* The default memory setting is 95% of the available space. */ -#define FREE_MEM_ESTIMATE ((unused_dos_memory() * 95L) / 100L) - -#endif /* MSDOS */ - -#ifdef ATARI /* For Atari ST/Mega/STE/TT/Falcon, Pure C or Turbo C */ - -#include - -/* The default memory setting is 90% of the available space. */ -#define FREE_MEM_ESTIMATE (((long) coreleft() * 90L) / 100L) - -#endif /* ATARI */ - -/* Add memory-estimation procedures for other operating systems here, - * with appropriate #ifdef's around them. - */ - -#endif /* !FREE_MEM_ESTIMATE */ - - -/* - * This list defines the known output image formats - * (not all of which need be supported by a given version). - * You can change the default output format by defining DEFAULT_FMT; - * indeed, you had better do so if you undefine PPM_SUPPORTED. - */ - -typedef enum { - FMT_BMP, /* BMP format (Windows flavor) */ - FMT_GIF, /* GIF format (LZW compressed) */ - FMT_GIF0, /* GIF format (uncompressed) */ - FMT_OS2, /* BMP format (OS/2 flavor) */ - FMT_PPM, /* PPM/PGM (PBMPLUS formats) */ - FMT_RLE, /* RLE format */ - FMT_TARGA, /* Targa format */ - FMT_TIFF /* TIFF format */ -} IMAGE_FORMATS; - -#ifndef DEFAULT_FMT /* so can override from CFLAGS in Makefile */ -#define DEFAULT_FMT FMT_BMP -#endif - -static IMAGE_FORMATS requested_fmt; - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] inputfile(s)\n", progname); - fprintf(stderr, "List of input files may use wildcards (* and ?)\n"); - fprintf(stderr, "Output filename is same as input filename except for extension\n"); - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -colors N Reduce image to no more than N colors\n"); - fprintf(stderr, " -fast Fast, low-quality processing\n"); - fprintf(stderr, " -grayscale Force grayscale output\n"); - fprintf(stderr, " -rgb Force RGB output\n"); -#ifdef IDCT_SCALING_SUPPORTED - fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n"); -#endif -#ifdef BMP_SUPPORTED - fprintf(stderr, " -bmp Select BMP output format (Windows style)%s\n", - (DEFAULT_FMT == FMT_BMP ? " (default)" : "")); -#endif -#ifdef GIF_SUPPORTED - fprintf(stderr, " -gif Select GIF output format (LZW compressed)%s\n", - (DEFAULT_FMT == FMT_GIF ? " (default)" : "")); - fprintf(stderr, " -gif0 Select GIF output format (uncompressed)%s\n", - (DEFAULT_FMT == FMT_GIF0 ? " (default)" : "")); -#endif -#ifdef BMP_SUPPORTED - fprintf(stderr, " -os2 Select BMP output format (OS/2 style)%s\n", - (DEFAULT_FMT == FMT_OS2 ? " (default)" : "")); -#endif -#ifdef PPM_SUPPORTED - fprintf(stderr, " -pnm Select PBMPLUS (PPM/PGM) output format%s\n", - (DEFAULT_FMT == FMT_PPM ? " (default)" : "")); -#endif -#ifdef RLE_SUPPORTED - fprintf(stderr, " -rle Select Utah RLE output format%s\n", - (DEFAULT_FMT == FMT_RLE ? " (default)" : "")); -#endif -#ifdef TARGA_SUPPORTED - fprintf(stderr, " -targa Select Targa output format%s\n", - (DEFAULT_FMT == FMT_TARGA ? " (default)" : "")); -#endif - fprintf(stderr, "Switches for advanced users:\n"); -#ifdef DCT_ISLOW_SUPPORTED - fprintf(stderr, " -dct int Use integer DCT method%s\n", - (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : "")); -#endif -#ifdef DCT_IFAST_SUPPORTED - fprintf(stderr, " -dct fast Use fast integer DCT (less accurate)%s\n", - (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : "")); -#endif -#ifdef DCT_FLOAT_SUPPORTED - fprintf(stderr, " -dct float Use floating-point DCT method%s\n", - (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : "")); -#endif - fprintf(stderr, " -dither fs Use F-S dithering (default)\n"); - fprintf(stderr, " -dither none Don't use dithering in quantization\n"); - fprintf(stderr, " -dither ordered Use ordered dither (medium speed, quality)\n"); -#ifdef QUANT_2PASS_SUPPORTED - fprintf(stderr, " -map FILE Map to colors used in named image file\n"); -#endif - fprintf(stderr, " -nosmooth Don't use high-quality upsampling\n"); -#ifdef QUANT_1PASS_SUPPORTED - fprintf(stderr, " -onepass Use 1-pass quantization (fast, low quality)\n"); -#endif -#ifndef FREE_MEM_ESTIMATE - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); -#endif - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - exit(EXIT_FAILURE); -} - - -LOCAL(int) -parse_switches (j_decompress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - - /* Set up default JPEG parameters. */ - requested_fmt = DEFAULT_FMT; /* set default output file format */ - outfilename = NULL; - cinfo->err->trace_level = 0; - if (default_maxmem > 0) /* override library's default value */ - cinfo->mem->max_memory_to_use = default_maxmem; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "bmp", 1)) { - /* BMP output format (Windows flavor). */ - requested_fmt = FMT_BMP; - - } else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) || - keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) { - /* Do color quantization. */ - int val; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d", &val) != 1) - usage(); - cinfo->desired_number_of_colors = val; - cinfo->quantize_colors = TRUE; - - } else if (keymatch(arg, "dct", 2)) { - /* Select IDCT algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "int", 1)) { - cinfo->dct_method = JDCT_ISLOW; - } else if (keymatch(argv[argn], "fast", 2)) { - cinfo->dct_method = JDCT_IFAST; - } else if (keymatch(argv[argn], "float", 2)) { - cinfo->dct_method = JDCT_FLOAT; - } else - usage(); - - } else if (keymatch(arg, "dither", 2)) { - /* Select dithering algorithm. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "fs", 2)) { - cinfo->dither_mode = JDITHER_FS; - } else if (keymatch(argv[argn], "none", 2)) { - cinfo->dither_mode = JDITHER_NONE; - } else if (keymatch(argv[argn], "ordered", 2)) { - cinfo->dither_mode = JDITHER_ORDERED; - } else - usage(); - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "fast", 1)) { - /* Select recommended processing options for quick-and-dirty output. */ - cinfo->two_pass_quantize = FALSE; - cinfo->dither_mode = JDITHER_ORDERED; - if (! cinfo->quantize_colors) /* don't override an earlier -colors */ - cinfo->desired_number_of_colors = 216; - cinfo->dct_method = JDCT_FASTEST; - cinfo->do_fancy_upsampling = FALSE; - - } else if (keymatch(arg, "gif", 1)) { - /* GIF output format (LZW compressed). */ - requested_fmt = FMT_GIF; - - } else if (keymatch(arg, "gif0", 4)) { - /* GIF output format (uncompressed). */ - requested_fmt = FMT_GIF0; - - } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { - /* Force monochrome output. */ - cinfo->out_color_space = JCS_GRAYSCALE; - - } else if (keymatch(arg, "rgb", 3)) { - /* Force RGB output. */ - cinfo->out_color_space = JCS_RGB; - - } else if (keymatch(arg, "map", 3)) { - /* Quantize to a color map taken from an input file. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (for_real) { /* too expensive to do twice! */ -#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ - FILE * mapfile; - - if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - read_color_map(cinfo, mapfile); - fclose(mapfile); - cinfo->quantize_colors = TRUE; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "nosmooth", 3)) { - /* Suppress fancy upsampling. */ - cinfo->do_fancy_upsampling = FALSE; - - } else if (keymatch(arg, "onepass", 3)) { - /* Use fast one-pass quantization. */ - cinfo->two_pass_quantize = FALSE; - - } else if (keymatch(arg, "os2", 3)) { - /* BMP output format (OS/2 flavor). */ - requested_fmt = FMT_OS2; - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) { - /* PPM/PGM output format. */ - requested_fmt = FMT_PPM; - - } else if (keymatch(arg, "rle", 1)) { - /* RLE output format. */ - requested_fmt = FMT_RLE; - - } else if (keymatch(arg, "scale", 1)) { - /* Scale the output image by a fraction M/N. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%u/%u", - &cinfo->scale_num, &cinfo->scale_denom) < 1) - usage(); - - } else if (keymatch(arg, "targa", 1)) { - /* Targa output format. */ - requested_fmt = FMT_TARGA; - - } else { - usage(); /* bogus switch */ - } - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * Marker processor for COM and interesting APPn markers. - * This replaces the library's built-in processor, which just skips the marker. - * We want to print out the marker as text, to the extent possible. - * Note this code relies on a non-suspending data source. - */ - -LOCAL(unsigned int) -jpeg_getc (j_decompress_ptr cinfo) -/* Read next byte */ -{ - struct jpeg_source_mgr * datasrc = cinfo->src; - - if (datasrc->bytes_in_buffer == 0) { - if (! (*datasrc->fill_input_buffer) (cinfo)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } - datasrc->bytes_in_buffer--; - return GETJOCTET(*datasrc->next_input_byte++); -} - - -METHODDEF(boolean) -print_text_marker (j_decompress_ptr cinfo) -{ - boolean traceit = (cinfo->err->trace_level >= 1); - INT32 length; - unsigned int ch; - unsigned int lastch = 0; - - length = jpeg_getc(cinfo) << 8; - length += jpeg_getc(cinfo); - length -= 2; /* discount the length word itself */ - - if (traceit) { - if (cinfo->unread_marker == JPEG_COM) - fprintf(stderr, "Comment, length %ld:\n", (long) length); - else /* assume it is an APPn otherwise */ - fprintf(stderr, "APP%d, length %ld:\n", - cinfo->unread_marker - JPEG_APP0, (long) length); - } - - while (--length >= 0) { - ch = jpeg_getc(cinfo); - if (traceit) { - /* Emit the character in a readable form. - * Nonprintables are converted to \nnn form, - * while \ is converted to \\. - * Newlines in CR, CR/LF, or LF form will be printed as one newline. - */ - if (ch == '\r') { - fprintf(stderr, "\n"); - } else if (ch == '\n') { - if (lastch != '\r') - fprintf(stderr, "\n"); - } else if (ch == '\\') { - fprintf(stderr, "\\\\"); - } else if (isprint(ch)) { - putc(ch, stderr); - } else { - fprintf(stderr, "\\%03o", ch); - } - lastch = ch; - } - } - - if (traceit) - fprintf(stderr, "\n"); - - return TRUE; -} - - -/* - * Check for overwrite of an existing file; clear it with user - */ - -#ifndef NO_OVERWRITE_CHECK - -LOCAL(boolean) -is_write_ok (char * outfname) -{ - FILE * ofile; - int ch; - - ofile = fopen(outfname, READ_BINARY); - if (ofile == NULL) - return TRUE; /* not present */ - fclose(ofile); /* oops, it is present */ - - for (;;) { - fprintf(stderr, "%s already exists, overwrite it? [y/n] ", - outfname); - fflush(stderr); - ch = getc(stdin); - if (ch != '\n') /* flush rest of line */ - while (getc(stdin) != '\n') - /* nothing */; - - switch (ch) { - case 'Y': - case 'y': - return TRUE; - case 'N': - case 'n': - return FALSE; - /* otherwise, ask again */ - } - } -} - -#endif - - -/* - * Process a single input file name, and return its index in argv[]. - * File names at or to left of old_file_index have been processed already. - */ - -LOCAL(int) -process_one_file (int argc, char **argv, int old_file_index) -{ - struct jpeg_decompress_struct cinfo; - struct jpeg_error_mgr jerr; - char *infilename; - char workfilename[PATH_MAX]; - const char *default_extension = NULL; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - int file_index; - djpeg_dest_ptr dest_mgr = NULL; - FILE * input_file = NULL; - FILE * output_file = NULL; - JDIMENSION num_scanlines; - - /* Initialize the JPEG decompression object with default error handling. */ - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_decompress(&cinfo); - /* Add some application-specific error messages (from cderror.h) */ - jerr.addon_message_table = cdjpeg_message_table; - jerr.first_addon_message = JMSG_FIRSTADDONCODE; - jerr.last_addon_message = JMSG_LASTADDONCODE; - - /* Insert custom marker processor for COM and APP12. - * APP12 is used by some digital camera makers for textual info, - * so we provide the ability to display it as text. - * If you like, additional APPn marker types can be selected for display, - * but don't try to override APP0 or APP14 this way (see libjpeg.txt). - */ - jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker); - jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker); - - /* Now safe to enable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &cinfo); -#endif - - /* Scan command line to find next file name. - * It is convenient to use just one switch-parsing routine, but the switch - * values read here are ignored; we will rescan the switches after opening - * the input file. - * (Exception: tracing level set here controls verbosity for COM markers - * found during jpeg_read_header...) - */ - - file_index = parse_switches(&cinfo, argc, argv, old_file_index, FALSE); - if (file_index >= argc) { - fprintf(stderr, "%s: missing input file name\n", progname); - usage(); - } - - /* Open the input file. */ - infilename = argv[file_index]; - if ((input_file = fopen(infilename, READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, infilename); - goto fail; - } - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &cinfo, &progress); -#endif - - /* Specify data source for decompression */ - jpeg_stdio_src(&cinfo, input_file); - - /* Read file header, set default decompression parameters */ - (void) jpeg_read_header(&cinfo, TRUE); - - /* Adjust default decompression parameters by re-parsing the options */ - file_index = parse_switches(&cinfo, argc, argv, old_file_index, TRUE); - - /* Initialize the output module now to let it override any crucial - * option settings (for instance, GIF wants to force color quantization). - */ - switch (requested_fmt) { -#ifdef BMP_SUPPORTED - case FMT_BMP: - dest_mgr = jinit_write_bmp(&cinfo, FALSE); - default_extension = ".bmp"; - break; - case FMT_OS2: - dest_mgr = jinit_write_bmp(&cinfo, TRUE); - default_extension = ".bmp"; - break; -#endif -#ifdef GIF_SUPPORTED - case FMT_GIF: - dest_mgr = jinit_write_gif(&cinfo, TRUE); - default_extension = ".gif"; - break; - case FMT_GIF0: - dest_mgr = jinit_write_gif(&cinfo, FALSE); - default_extension = ".gif"; - break; -#endif -#ifdef PPM_SUPPORTED - case FMT_PPM: - dest_mgr = jinit_write_ppm(&cinfo); - default_extension = ".ppm"; - break; -#endif -#ifdef RLE_SUPPORTED - case FMT_RLE: - dest_mgr = jinit_write_rle(&cinfo); - default_extension = ".rle"; - break; -#endif -#ifdef TARGA_SUPPORTED - case FMT_TARGA: - dest_mgr = jinit_write_targa(&cinfo); - default_extension = ".tga"; - break; -#endif - default: - ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT); - } - - /* If user didn't supply -outfile switch, select output file name. */ - if (outfilename == NULL) { - int i; - - outfilename = workfilename; - /* Make outfilename be infilename with appropriate extension */ - strcpy(outfilename, infilename); - for (i = (int)strlen(outfilename)-1; i >= 0; i--) { - switch (outfilename[i]) { - case ':': - case '/': - case '\\': - i = 0; /* stop scanning */ - break; - case '.': - outfilename[i] = '\0'; /* lop off existing extension */ - i = 0; /* stop scanning */ - break; - default: - break; /* keep scanning */ - } - } - strcat(outfilename, default_extension); - } - - fprintf(stderr, "Decompressing %s => %s\n", infilename, outfilename); -#ifndef NO_OVERWRITE_CHECK - if (! is_write_ok(outfilename)) - goto fail; -#endif - - /* Open the output file. */ - if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't create %s\n", progname, outfilename); - goto fail; - } - dest_mgr->output_file = output_file; - - /* Start decompressor */ - (void) jpeg_start_decompress(&cinfo); - - /* Write output file header */ - (*dest_mgr->start_output) (&cinfo, dest_mgr); - - /* Process data */ - while (cinfo.output_scanline < cinfo.output_height) { - num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer, - dest_mgr->buffer_height); - (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines); - } - -#ifdef PROGRESS_REPORT - /* Hack: count final pass as done in case finish_output does an extra pass. - * The library won't have updated completed_passes. - */ - progress.pub.completed_passes = progress.pub.total_passes; -#endif - - /* Finish decompression and release memory. - * I must do it in this order because output module has allocated memory - * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory. - */ - (*dest_mgr->finish_output) (&cinfo, dest_mgr); - (void) jpeg_finish_decompress(&cinfo); - - /* Clean up and exit */ -fail: - jpeg_destroy_decompress(&cinfo); - - if (input_file != NULL) fclose(input_file); - if (output_file != NULL) fclose(output_file); - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &cinfo); -#endif - - /* Disable signal catcher. */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) NULL); -#endif - - return file_index; -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - int file_index; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - -#ifdef MSDOS - progname = "djpeg"; /* DOS tends to be too verbose about argv[0] */ -#else - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "djpeg"; /* in case C library doesn't provide it */ -#endif - - /* The default maxmem must be computed only once at program startup, - * since releasing memory with free() won't give it back to the OS. - */ -#ifdef FREE_MEM_ESTIMATE - default_maxmem = FREE_MEM_ESTIMATE; -#else - default_maxmem = 0; -#endif - - /* Scan command line, parse switches and locate input file names */ - - if (argc < 2) - usage(); /* nothing on the command line?? */ - - file_index = 0; - - while (file_index < argc-1) - file_index = process_one_file(argc, argv, file_index); - - /* All done. */ - exit(EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/code/jpeg-9f/example.c b/code/jpeg-9f/example.c deleted file mode 100644 index 1d6f6cc3..00000000 --- a/code/jpeg-9f/example.c +++ /dev/null @@ -1,433 +0,0 @@ -/* - * example.c - * - * This file illustrates how to use the IJG code as a subroutine library - * to read or write JPEG image files. You should look at this code in - * conjunction with the documentation file libjpeg.txt. - * - * This code will not do anything useful as-is, but it may be helpful as a - * skeleton for constructing routines that call the JPEG library. - * - * We present these routines in the same coding style used in the JPEG code - * (ANSI function definitions, etc); but you are of course free to code your - * routines in a different style if you prefer. - */ - -#include - -/* - * Include file for users of JPEG library. - * You will need to have included system headers that define at least - * the typedefs FILE and size_t before you can include jpeglib.h. - * (stdio.h is sufficient on ANSI-conforming systems.) - * You may also wish to include "jerror.h". - */ - -#include "jpeglib.h" - -/* - * is used for the optional error recovery mechanism shown in - * the second part of the example. - */ - -#include - - - -/******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/ - -/* This half of the example shows how to feed data into the JPEG compressor. - * We present a minimal version that does not worry about refinements such - * as error recovery (the JPEG code will just exit() if it gets an error). - */ - - -/* - * 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); - - /* Step 2: specify data destination (eg, a file) */ - /* Note: steps 2 and 3 can be done in either order. */ - - /* Here we use the library-supplied code to send compressed data to a - * stdio stream. You can also write your own code to do something else. - * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that - * requires it in order to write binary files. - */ - if ((outfile = fopen(filename, "wb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - exit(1); - } - jpeg_stdio_dest(&cinfo, outfile); - - /* Step 3: set parameters for compression */ - - /* First we supply a description of the input image. - * Four fields of the cinfo struct must be filled in: - */ - cinfo.image_width = image_width; /* image width and height, in pixels */ - cinfo.image_height = image_height; - cinfo.input_components = 3; /* # of color components per pixel */ - cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ - /* Now use the library's routine to set default compression parameters. - * (You must set at least cinfo.in_color_space before calling this, - * since the defaults depend on the source color space.) - */ - jpeg_set_defaults(&cinfo); - /* Now you can set any non-default parameters you wish to. - * Here we just illustrate the use of quality (quantization table) scaling: - */ - jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); - - /* Step 4: Start compressor */ - - /* TRUE ensures that we will write a complete interchange-JPEG file. - * Pass TRUE unless you are very sure of what you're doing. - */ - jpeg_start_compress(&cinfo, TRUE); - - /* Step 5: while (scan lines remain to be written) */ - /* jpeg_write_scanlines(...); */ - - /* Here we use the library's state variable cinfo.next_scanline as the - * loop counter, so that we don't have to keep track ourselves. - * To keep things simple, we pass one scanline per call; you can pass - * more if you wish, though. - */ - row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ - - while (cinfo.next_scanline < cinfo.image_height) { - /* jpeg_write_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could pass - * more than one scanline at a time if that's more convenient. - */ - row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; - (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - - /* Step 6: Finish compression */ - - jpeg_finish_compress(&cinfo); - /* After finish_compress, we can close the output file. */ - fclose(outfile); - - /* Step 7: release JPEG compression object */ - - /* This is an important step since it will release a good deal of memory. */ - jpeg_destroy_compress(&cinfo); - - /* And we're done! */ -} - - -/* - * SOME FINE POINTS: - * - * In the above loop, we ignored the return value of jpeg_write_scanlines, - * which is the number of scanlines actually written. We could get away - * with this because we were only relying on the value of cinfo.next_scanline, - * which will be incremented correctly. If you maintain additional loop - * variables then you should be careful to increment them properly. - * Actually, for output to a stdio stream you needn't worry, because - * then jpeg_write_scanlines will write all the lines passed (or else exit - * with a fatal error). Partial writes can only occur if you use a data - * destination module that can demand suspension of the compressor. - * (If you don't know what that's for, you don't need it.) - * - * If the compressor requires full-image buffers (for entropy-coding - * optimization or a multi-scan JPEG file), it will create temporary - * files for anything that doesn't fit within the maximum-memory setting. - * (Note that temp files are NOT needed if you use the default parameters.) - * On some systems you may need to set up a signal handler to ensure that - * temporary files are deleted if the program is interrupted. See libjpeg.txt. - * - * Scanlines MUST be supplied in top-to-bottom order if you want your JPEG - * files to be compatible with everyone else's. If you cannot readily read - * your data in that order, you'll need an intermediate array to hold the - * image. See rdtarga.c or rdbmp.c for examples of handling bottom-to-top - * source data using the JPEG code's internal virtual-array mechanisms. - */ - - - -/******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/ - -/* This half of the example shows how to read data from the JPEG decompressor. - * It's a bit more refined than the above, in that we show: - * (a) how to modify the JPEG library's standard error-reporting behavior; - * (b) how to allocate workspace using the library's memory manager. - * - * Just to make this example a little different from the first one, we'll - * assume that we do not intend to put the whole image into an in-memory - * buffer, but to send it line-by-line someplace else. We need a one- - * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG - * memory manager allocate it for us. This approach is actually quite useful - * because we don't need to remember to deallocate the buffer separately: it - * will go away automatically when the JPEG object is cleaned up. - */ - - -/* - * ERROR HANDLING: - * - * The JPEG library's standard error handler (jerror.c) is divided into - * several "methods" which you can override individually. This lets you - * adjust the behavior without duplicating a lot of code, which you might - * have to update with each future release. - * - * Our example here shows how to override the "error_exit" method so that - * control is returned to the library's caller when a fatal error occurs, - * rather than calling exit() as the standard error_exit method does. - * - * We use C's setjmp/longjmp facility to return control. This means that the - * routine which calls the JPEG library must first execute a setjmp() call to - * establish the return point. We want the replacement error_exit to do a - * longjmp(). But we need to make the setjmp buffer accessible to the - * error_exit routine. To do this, we make a private extension of the - * standard JPEG error handler object. (If we were using C++, we'd say we - * were making a subclass of the regular error handler.) - * - * Here's the extended error handler struct: - */ - -struct my_error_mgr { - struct jpeg_error_mgr pub; /* "public" fields */ - - jmp_buf setjmp_buffer; /* for return to caller */ -}; - -typedef struct my_error_mgr * my_error_ptr; - -/* - * Here's the routine that will replace the standard error_exit method: - */ - -METHODDEF(void) -my_error_exit (j_common_ptr cinfo) -{ - /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ - my_error_ptr myerr = (my_error_ptr) cinfo->err; - - /* Always display the message. */ - /* We could postpone this until after returning, if we chose. */ - (*cinfo->err->output_message) (cinfo); - - /* Return control to the setjmp point */ - longjmp(myerr->setjmp_buffer, 1); -} - - -/* - * Sample routine for JPEG decompression. We assume that the source file name - * is passed in. We want to return 1 on success, 0 on error. - */ - - -GLOBAL(int) -read_JPEG_file (char * filename) -{ - /* This struct contains the JPEG decompression parameters and pointers to - * working space (which is allocated as needed by the JPEG library). - */ - struct jpeg_decompress_struct cinfo; - /* We use our private extension JPEG error handler. - * Note that this struct must live as long as the main JPEG parameter - * struct, to avoid dangling-pointer problems. - */ - struct my_error_mgr jerr; - /* More stuff */ - FILE * infile; /* source file */ - JSAMPARRAY buffer; /* Output row buffer */ - int row_stride; /* physical row width in output buffer */ - - /* In this example we want to open the input file before doing anything else, - * so that the setjmp() error recovery below can assume the file is open. - * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that - * requires it in order to read binary files. - */ - - if ((infile = fopen(filename, "rb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - return 0; - } - - /* Step 1: allocate and initialize JPEG decompression object */ - - /* We set up the normal JPEG error routines, then override error_exit. */ - cinfo.err = jpeg_std_error(&jerr.pub); - jerr.pub.error_exit = my_error_exit; - /* Establish the setjmp return context for my_error_exit to use. */ - if (setjmp(jerr.setjmp_buffer)) { - /* If we get here, the JPEG code has signaled an error. - * We need to clean up the JPEG object, close the input file, and return. - */ - jpeg_destroy_decompress(&cinfo); - fclose(infile); - return 0; - } - /* Now we can initialize the JPEG decompression object. */ - jpeg_create_decompress(&cinfo); - - /* Step 2: specify data source (eg, a file) */ - - jpeg_stdio_src(&cinfo, infile); - - /* Step 3: read file parameters with jpeg_read_header() */ - - (void) jpeg_read_header(&cinfo, TRUE); - /* We can ignore the return value from jpeg_read_header since - * (a) suspension is not possible with the stdio data source, and - * (b) we passed TRUE to reject a tables-only JPEG file as an error. - * See libjpeg.txt for more info. - */ - - /* Step 4: set parameters for decompression */ - - /* In this example, we don't need to change any of the defaults set by - * jpeg_read_header(), so we do nothing here. - */ - - /* Step 5: Start decompressor */ - - (void) jpeg_start_decompress(&cinfo); - /* We can ignore the return value since suspension is not possible - * with the stdio data source. - */ - - /* We may need to do some setup of our own at this point before reading - * the data. After jpeg_start_decompress() we have the correct scaled - * output image dimensions available, as well as the output colormap - * if we asked for color quantization. - * In this example, we need to make an output work buffer of the right size. - */ - /* JSAMPLEs per row in output buffer */ - row_stride = cinfo.output_width * cinfo.output_components; - /* Make a one-row-high sample array that will go away when done with image */ - buffer = (*cinfo.mem->alloc_sarray) - ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); - - /* Step 6: while (scan lines remain to be read) */ - /* jpeg_read_scanlines(...); */ - - /* Here we use the library's state variable cinfo.output_scanline as the - * loop counter, so that we don't have to keep track ourselves. - */ - while (cinfo.output_scanline < cinfo.output_height) { - /* jpeg_read_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could ask for - * more than one scanline at a time if that's more convenient. - */ - (void) jpeg_read_scanlines(&cinfo, buffer, 1); - /* Assume put_scanline_someplace wants a pointer and sample count. */ - put_scanline_someplace(buffer[0], row_stride); - } - - /* Step 7: Finish decompression */ - - (void) jpeg_finish_decompress(&cinfo); - /* We can ignore the return value since suspension is not possible - * with the stdio data source. - */ - - /* Step 8: Release JPEG decompression object */ - - /* This is an important step since it will release a good deal of memory. */ - jpeg_destroy_decompress(&cinfo); - - /* After finish_decompress, we can close the input file. - * Here we postpone it until after no more JPEG errors are possible, - * so as to simplify the setjmp error logic above. (Actually, I don't - * think that jpeg_destroy can do an error exit, but why assume anything...) - */ - fclose(infile); - - /* At this point you may want to check to see whether any corrupt-data - * warnings occurred (test whether jerr.pub.num_warnings is nonzero). - */ - - /* And we're done! */ - return 1; -} - - -/* - * SOME FINE POINTS: - * - * In the above code, we ignored the return value of jpeg_read_scanlines, - * which is the number of scanlines actually read. We could get away with - * this because we asked for only one line at a time and we weren't using - * a suspending data source. See libjpeg.txt for more info. - * - * We cheated a bit by calling alloc_sarray() after jpeg_start_decompress(); - * we should have done it beforehand to ensure that the space would be - * counted against the JPEG max_memory setting. In some systems the above - * code would risk an out-of-memory error. However, in general we don't - * know the output image dimensions before jpeg_start_decompress(), unless we - * call jpeg_calc_output_dimensions(). See libjpeg.txt for more about this. - * - * Scanlines are returned in the same order as they appear in the JPEG file, - * which is standardly top-to-bottom. If you must emit data bottom-to-top, - * you can use one of the virtual arrays provided by the JPEG memory manager - * to invert the data. See wrbmp.c for an example. - * - * As with compression, some operating modes may require temporary files. - * On some systems you may need to set up a signal handler to ensure that - * temporary files are deleted if the program is interrupted. See libjpeg.txt. - */ diff --git a/code/jpeg-9f/jmemansi.c b/code/jpeg-9f/jmemansi.c deleted file mode 100644 index 2d93e496..00000000 --- a/code/jpeg-9f/jmemansi.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * jmemansi.c - * - * Copyright (C) 1992-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a simple generic implementation of the system- - * dependent portion of the JPEG memory manager. This implementation - * assumes that you have the ANSI-standard library routine tmpfile(). - * Also, the problem of determining the amount of memory available - * is shoved onto the user. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - -#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ -#define SEEK_SET 0 /* if not, assume 0 is correct */ -#endif - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * It's impossible to do this in a portable way; our current solution is - * to make the user tell us (with a default value set at compile time). - * If you can actually get the available space, it's a good idea to subtract - * a slop factor of 5% or so. - */ - -#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ -#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ -#endif - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return cinfo->mem->max_memory_to_use - already_allocated; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - - -METHODDEF(void) -read_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFREAD(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFWRITE(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_backing_store (j_common_ptr cinfo, backing_store_ptr info) -{ - fclose(info->temp_file); - /* Since this implementation uses tmpfile() to create the file, - * no explicit file deletion is needed. - */ -} - - -/* - * Initial opening of a backing-store object. - * - * This version uses tmpfile(), which constructs a suitable file name - * behind the scenes. We don't have to use info->temp_name[] at all; - * indeed, we can't even find out the actual name of the temp file. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - if ((info->temp_file = tmpfile()) == NULL) - ERREXITS(cinfo, JERR_TFILE_CREATE, ""); - info->read_backing_store = read_backing_store; - info->write_backing_store = write_backing_store; - info->close_backing_store = close_backing_store; -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/code/jpeg-9f/jmemdos.c b/code/jpeg-9f/jmemdos.c deleted file mode 100644 index 60b45c69..00000000 --- a/code/jpeg-9f/jmemdos.c +++ /dev/null @@ -1,638 +0,0 @@ -/* - * jmemdos.c - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides an MS-DOS-compatible implementation of the system- - * dependent portion of the JPEG memory manager. Temporary data can be - * stored in extended or expanded memory as well as in regular DOS files. - * - * If you use this file, you must be sure that NEED_FAR_POINTERS is defined - * if you compile in a small-data memory model; it should NOT be defined if - * you use a large-data memory model. This file is not recommended if you - * are using a flat-memory-space 386 environment such as DJGCC or Watcom C. - * Also, this code will NOT work if struct fields are aligned on greater than - * 2-byte boundaries. - * - * Based on code contributed by Ge' Weijers. - */ - -/* - * If you have both extended and expanded memory, you may want to change the - * order in which they are tried in jopen_backing_store. On a 286 machine - * expanded memory is usually faster, since extended memory access involves - * an expensive protected-mode-and-back switch. On 386 and better, extended - * memory is usually faster. As distributed, the code tries extended memory - * first (what? not everyone has a 386? :-). - * - * You can disable use of extended/expanded memory entirely by altering these - * definitions or overriding them from the Makefile (eg, -DEMS_SUPPORTED=0). - */ - -#ifndef XMS_SUPPORTED -#define XMS_SUPPORTED 1 -#endif -#ifndef EMS_SUPPORTED -#define EMS_SUPPORTED 1 -#endif - - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare these */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -extern char * getenv JPP((const char * name)); -#endif - -#ifdef NEED_FAR_POINTERS - -#ifdef __TURBOC__ -/* These definitions work for Borland C (Turbo C) */ -#include /* need farmalloc(), farfree() */ -#define far_malloc(x) farmalloc(x) -#define far_free(x) farfree(x) -#else -/* These definitions work for Microsoft C and compatible compilers */ -#include /* need _fmalloc(), _ffree() */ -#define far_malloc(x) _fmalloc(x) -#define far_free(x) _ffree(x) -#endif - -#else /* not NEED_FAR_POINTERS */ - -#define far_malloc(x) malloc(x) -#define far_free(x) free(x) - -#endif /* NEED_FAR_POINTERS */ - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#else -#define READ_BINARY "rb" -#endif - -#ifndef USE_MSDOS_MEMMGR /* make sure user got configuration right */ - You forgot to define USE_MSDOS_MEMMGR in jconfig.h. /* deliberate syntax error */ -#endif - -#if MAX_ALLOC_CHUNK >= 65535L /* make sure jconfig.h got this right */ - MAX_ALLOC_CHUNK should be less than 64K. /* deliberate syntax error */ -#endif - - -/* - * Declarations for assembly-language support routines (see jmemdosa.asm). - * - * The functions are declared "far" as are all their pointer arguments; - * this ensures the assembly source code will work regardless of the - * compiler memory model. We assume "short" is 16 bits, "long" is 32. - */ - -typedef void far * XMSDRIVER; /* actually a pointer to code */ -typedef struct { /* registers for calling XMS driver */ - unsigned short ax, dx, bx; - void far * ds_si; - } XMScontext; -typedef struct { /* registers for calling EMS driver */ - unsigned short ax, dx, bx; - void far * ds_si; - } EMScontext; - -extern short far jdos_open JPP((short far * handle, char far * filename)); -extern short far jdos_close JPP((short handle)); -extern short far jdos_seek JPP((short handle, long offset)); -extern short far jdos_read JPP((short handle, void far * buffer, - unsigned short count)); -extern short far jdos_write JPP((short handle, void far * buffer, - unsigned short count)); -extern void far jxms_getdriver JPP((XMSDRIVER far *)); -extern void far jxms_calldriver JPP((XMSDRIVER, XMScontext far *)); -extern short far jems_available JPP((void)); -extern void far jems_calldriver JPP((EMScontext far *)); - - -/* - * Selection of a file name for a temporary file. - * This is highly system-dependent, and you may want to customize it. - */ - -static int next_file_num; /* to distinguish among several temp files */ - -LOCAL(void) -select_file_name (char * fname) -{ - const char * env; - char * ptr; - FILE * tfile; - - /* Keep generating file names till we find one that's not in use */ - for (;;) { - /* Get temp directory name from environment TMP or TEMP variable; - * if none, use "." - */ - if ((env = (const char *) getenv("TMP")) == NULL) - if ((env = (const char *) getenv("TEMP")) == NULL) - env = "."; - if (*env == '\0') /* null string means "." */ - env = "."; - ptr = fname; /* copy name to fname */ - while (*env != '\0') - *ptr++ = *env++; - if (ptr[-1] != '\\' && ptr[-1] != '/') - *ptr++ = '\\'; /* append backslash if not in env variable */ - /* Append a suitable file name */ - next_file_num++; /* advance counter */ - sprintf(ptr, "JPG%03d.TMP", next_file_num); - /* Probe to see if file name is already in use */ - if ((tfile = fopen(fname, READ_BINARY)) == NULL) - break; - fclose(tfile); /* oops, it's there; close tfile & try again */ - } -} - - -/* - * Near-memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are allocated in far memory, if possible - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) far_malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - far_free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * It's impossible to do this in a portable way; our current solution is - * to make the user tell us (with a default value set at compile time). - * If you can actually get the available space, it's a good idea to subtract - * a slop factor of 5% or so. - */ - -#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ -#define DEFAULT_MAX_MEM 300000L /* for total usage about 450K */ -#endif - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return cinfo->mem->max_memory_to_use - already_allocated; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - -/* - * For MS-DOS we support three types of backing storage: - * 1. Conventional DOS files. We access these by direct DOS calls rather - * than via the stdio package. This provides a bit better performance, - * but the real reason is that the buffers to be read or written are FAR. - * The stdio library for small-data memory models can't cope with that. - * 2. Extended memory, accessed per the XMS V2.0 specification. - * 3. Expanded memory, accessed per the LIM/EMS 4.0 specification. - * You'll need copies of those specs to make sense of the related code. - * The specs are available by Internet FTP from the SIMTEL archives - * (oak.oakland.edu and its various mirror sites). See files - * pub/msdos/microsoft/xms20.arc and pub/msdos/info/limems41.zip. - */ - - -/* - * Access methods for a DOS file. - */ - - -METHODDEF(void) -read_file_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (jdos_seek(info->handle.file_handle, file_offset)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ - if (byte_count > 65535L) /* safety check */ - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - if (jdos_read(info->handle.file_handle, buffer_address, - (unsigned short) byte_count)) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_file_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (jdos_seek(info->handle.file_handle, file_offset)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */ - if (byte_count > 65535L) /* safety check */ - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - if (jdos_write(info->handle.file_handle, buffer_address, - (unsigned short) byte_count)) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_file_store (j_common_ptr cinfo, backing_store_ptr info) -{ - jdos_close(info->handle.file_handle); /* close the file */ - remove(info->temp_name); /* delete the file */ -/* If your system doesn't have remove(), try unlink() instead. - * remove() is the ANSI-standard name for this function, but - * unlink() was more common in pre-ANSI systems. - */ - TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); -} - - -LOCAL(boolean) -open_file_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - short handle; - - select_file_name(info->temp_name); - if (jdos_open((short far *) & handle, (char far *) info->temp_name)) { - /* might as well exit since jpeg_open_backing_store will fail anyway */ - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - return FALSE; - } - info->handle.file_handle = handle; - info->read_backing_store = read_file_store; - info->write_backing_store = write_file_store; - info->close_backing_store = close_file_store; - TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); - return TRUE; /* succeeded */ -} - - -/* - * Access methods for extended memory. - */ - -#if XMS_SUPPORTED - -static XMSDRIVER xms_driver; /* saved address of XMS driver */ - -typedef union { /* either long offset or real-mode pointer */ - long offset; - void far * ptr; - } XMSPTR; - -typedef struct { /* XMS move specification structure */ - long length; - XMSH src_handle; - XMSPTR src; - XMSH dst_handle; - XMSPTR dst; - } XMSspec; - -#define ODD(X) (((X) & 1L) != 0) - - -METHODDEF(void) -read_xms_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - XMScontext ctx; - XMSspec spec; - char endbuffer[2]; - - /* The XMS driver can't cope with an odd length, so handle the last byte - * specially if byte_count is odd. We don't expect this to be common. - */ - - spec.length = byte_count & (~ 1L); - spec.src_handle = info->handle.xms_handle; - spec.src.offset = file_offset; - spec.dst_handle = 0; - spec.dst.ptr = buffer_address; - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x0b00; /* EMB move */ - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax != 1) - ERREXIT(cinfo, JERR_XMS_READ); - - if (ODD(byte_count)) { - read_xms_store(cinfo, info, (void FAR *) endbuffer, - file_offset + byte_count - 1L, 2L); - ((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0]; - } -} - - -METHODDEF(void) -write_xms_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - XMScontext ctx; - XMSspec spec; - char endbuffer[2]; - - /* The XMS driver can't cope with an odd length, so handle the last byte - * specially if byte_count is odd. We don't expect this to be common. - */ - - spec.length = byte_count & (~ 1L); - spec.src_handle = 0; - spec.src.ptr = buffer_address; - spec.dst_handle = info->handle.xms_handle; - spec.dst.offset = file_offset; - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x0b00; /* EMB move */ - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax != 1) - ERREXIT(cinfo, JERR_XMS_WRITE); - - if (ODD(byte_count)) { - read_xms_store(cinfo, info, (void FAR *) endbuffer, - file_offset + byte_count - 1L, 2L); - endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L]; - write_xms_store(cinfo, info, (void FAR *) endbuffer, - file_offset + byte_count - 1L, 2L); - } -} - - -METHODDEF(void) -close_xms_store (j_common_ptr cinfo, backing_store_ptr info) -{ - XMScontext ctx; - - ctx.dx = info->handle.xms_handle; - ctx.ax = 0x0a00; - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle); - /* we ignore any error return from the driver */ -} - - -LOCAL(boolean) -open_xms_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - XMScontext ctx; - - /* Get address of XMS driver */ - jxms_getdriver((XMSDRIVER far *) & xms_driver); - if (xms_driver == NULL) - return FALSE; /* no driver to be had */ - - /* Get version number, must be >= 2.00 */ - ctx.ax = 0x0000; - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax < (unsigned short) 0x0200) - return FALSE; - - /* Try to get space (expressed in kilobytes) */ - ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10); - ctx.ax = 0x0900; - jxms_calldriver(xms_driver, (XMScontext far *) & ctx); - if (ctx.ax != 1) - return FALSE; - - /* Succeeded, save the handle and away we go */ - info->handle.xms_handle = ctx.dx; - info->read_backing_store = read_xms_store; - info->write_backing_store = write_xms_store; - info->close_backing_store = close_xms_store; - TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx); - return TRUE; /* succeeded */ -} - -#endif /* XMS_SUPPORTED */ - - -/* - * Access methods for expanded memory. - */ - -#if EMS_SUPPORTED - -/* The EMS move specification structure requires word and long fields aligned - * at odd byte boundaries. Some compilers will align struct fields at even - * byte boundaries. While it's usually possible to force byte alignment, - * that causes an overall performance penalty and may pose problems in merging - * JPEG into a larger application. Instead we accept some rather dirty code - * here. Note this code would fail if the hardware did not allow odd-byte - * word & long accesses, but all 80x86 CPUs do. - */ - -typedef void far * EMSPTR; - -typedef union { /* EMS move specification structure */ - long length; /* It's easy to access first 4 bytes */ - char bytes[18]; /* Misaligned fields in here! */ - } EMSspec; - -/* Macros for accessing misaligned fields */ -#define FIELD_AT(spec,offset,type) (*((type *) &(spec.bytes[offset]))) -#define SRC_TYPE(spec) FIELD_AT(spec,4,char) -#define SRC_HANDLE(spec) FIELD_AT(spec,5,EMSH) -#define SRC_OFFSET(spec) FIELD_AT(spec,7,unsigned short) -#define SRC_PAGE(spec) FIELD_AT(spec,9,unsigned short) -#define SRC_PTR(spec) FIELD_AT(spec,7,EMSPTR) -#define DST_TYPE(spec) FIELD_AT(spec,11,char) -#define DST_HANDLE(spec) FIELD_AT(spec,12,EMSH) -#define DST_OFFSET(spec) FIELD_AT(spec,14,unsigned short) -#define DST_PAGE(spec) FIELD_AT(spec,16,unsigned short) -#define DST_PTR(spec) FIELD_AT(spec,14,EMSPTR) - -#define EMSPAGESIZE 16384L /* gospel, see the EMS specs */ - -#define HIBYTE(W) (((W) >> 8) & 0xFF) -#define LOBYTE(W) ((W) & 0xFF) - - -METHODDEF(void) -read_ems_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - EMScontext ctx; - EMSspec spec; - - spec.length = byte_count; - SRC_TYPE(spec) = 1; - SRC_HANDLE(spec) = info->handle.ems_handle; - SRC_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); - SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); - DST_TYPE(spec) = 0; - DST_HANDLE(spec) = 0; - DST_PTR(spec) = buffer_address; - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x5700; /* move memory region */ - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - ERREXIT(cinfo, JERR_EMS_READ); -} - - -METHODDEF(void) -write_ems_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - EMScontext ctx; - EMSspec spec; - - spec.length = byte_count; - SRC_TYPE(spec) = 0; - SRC_HANDLE(spec) = 0; - SRC_PTR(spec) = buffer_address; - DST_TYPE(spec) = 1; - DST_HANDLE(spec) = info->handle.ems_handle; - DST_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE); - DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE); - - ctx.ds_si = (void far *) & spec; - ctx.ax = 0x5700; /* move memory region */ - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - ERREXIT(cinfo, JERR_EMS_WRITE); -} - - -METHODDEF(void) -close_ems_store (j_common_ptr cinfo, backing_store_ptr info) -{ - EMScontext ctx; - - ctx.ax = 0x4500; - ctx.dx = info->handle.ems_handle; - jems_calldriver((EMScontext far *) & ctx); - TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle); - /* we ignore any error return from the driver */ -} - - -LOCAL(boolean) -open_ems_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - EMScontext ctx; - - /* Is EMS driver there? */ - if (! jems_available()) - return FALSE; - - /* Get status, make sure EMS is OK */ - ctx.ax = 0x4000; - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - return FALSE; - - /* Get version, must be >= 4.0 */ - ctx.ax = 0x4600; - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40) - return FALSE; - - /* Try to allocate requested space */ - ctx.ax = 0x4300; - ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE); - jems_calldriver((EMScontext far *) & ctx); - if (HIBYTE(ctx.ax) != 0) - return FALSE; - - /* Succeeded, save the handle and away we go */ - info->handle.ems_handle = ctx.dx; - info->read_backing_store = read_ems_store; - info->write_backing_store = write_ems_store; - info->close_backing_store = close_ems_store; - TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx); - return TRUE; /* succeeded */ -} - -#endif /* EMS_SUPPORTED */ - - -/* - * Initial opening of a backing-store object. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - /* Try extended memory, then expanded memory, then regular file. */ -#if XMS_SUPPORTED - if (open_xms_store(cinfo, info, total_bytes_needed)) - return; -#endif -#if EMS_SUPPORTED - if (open_ems_store(cinfo, info, total_bytes_needed)) - return; -#endif - if (open_file_store(cinfo, info, total_bytes_needed)) - return; - ERREXITS(cinfo, JERR_TFILE_CREATE, ""); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - next_file_num = 0; /* initialize temp file name generator */ - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* Microsoft C, at least in v6.00A, will not successfully reclaim freed - * blocks of size > 32Kbytes unless we give it a kick in the rear, like so: - */ -#ifdef NEED_FHEAPMIN - _fheapmin(); -#endif -} diff --git a/code/jpeg-9f/jmemmac.c b/code/jpeg-9f/jmemmac.c deleted file mode 100644 index 106f9bea..00000000 --- a/code/jpeg-9f/jmemmac.c +++ /dev/null @@ -1,289 +0,0 @@ -/* - * jmemmac.c - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * jmemmac.c provides an Apple Macintosh implementation of the system- - * dependent portion of the JPEG memory manager. - * - * If you use jmemmac.c, then you must define USE_MAC_MEMMGR in the - * JPEG_INTERNALS part of jconfig.h. - * - * jmemmac.c uses the Macintosh toolbox routines NewPtr and DisposePtr - * instead of malloc and free. It accurately determines the amount of - * memory available by using CompactMem. Notice that if left to its - * own devices, this code can chew up all available space in the - * application's zone, with the exception of the rather small "slop" - * factor computed in jpeg_mem_available(). The application can ensure - * that more space is left over by reducing max_memory_to_use. - * - * Large images are swapped to disk using temporary files and System 7.0+'s - * temporary folder functionality. - * - * Note that jmemmac.c depends on two features of MacOS that were first - * introduced in System 7: FindFolder and the FSSpec-based calls. - * If your application uses jmemmac.c and is run under System 6 or earlier, - * and the jpeg library decides it needs a temporary file, it will abort, - * printing error messages about requiring System 7. (If no temporary files - * are created, it will run fine.) - * - * If you want to use jmemmac.c in an application that might be used with - * System 6 or earlier, then you should remove dependencies on FindFolder - * and the FSSpec calls. You will need to replace FindFolder with some - * other mechanism for finding a place to put temporary files, and you - * should replace the FSSpec calls with their HFS equivalents: - * - * FSpDelete -> HDelete - * FSpGetFInfo -> HGetFInfo - * FSpCreate -> HCreate - * FSpOpenDF -> HOpen *** Note: not HOpenDF *** - * FSMakeFSSpec -> (fill in spec by hand.) - * - * (Use HOpen instead of HOpenDF. HOpen is just a glue-interface to PBHOpen, - * which is on all HFS macs. HOpenDF is a System 7 addition which avoids the - * ages-old problem of names starting with a period.) - * - * Contributed by Sam Bushell (jsam@iagu.on.net) and - * Dan Gildor (gyld@in-touch.com). - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef USE_MAC_MEMMGR /* make sure user got configuration right */ - You forgot to define USE_MAC_MEMMGR in jconfig.h. /* deliberate syntax error */ -#endif - -#include /* we use the MacOS memory manager */ -#include /* we use the MacOS File stuff */ -#include /* we use the MacOS HFS stuff */ -#include /* for smSystemScript */ -#include /* we use Gestalt to test for specific functionality */ - -#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ -#define TEMP_FILE_NAME "JPG%03d.TMP" -#endif - -static int next_file_num; /* to distinguish among several temp files */ - - -/* - * Memory allocation and freeing are controlled by the MacOS library - * routines NewPtr() and DisposePtr(), which allocate fixed-address - * storage. Unfortunately, the IJG library isn't smart enough to cope - * with relocatable storage. - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) NewPtr(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - DisposePtr((Ptr) object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: we include FAR keywords in the routine declarations simply for - * consistency with the rest of the IJG code; FAR should expand to empty - * on rational architectures like the Mac. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) NewPtr(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - DisposePtr((Ptr) object); -} - - -/* - * This routine computes the total memory space available for allocation. - */ - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - long limit = cinfo->mem->max_memory_to_use - already_allocated; - long slop, mem; - - /* Don't ask for more than what application has told us we may use */ - if (max_bytes_needed > limit && limit > 0) - max_bytes_needed = limit; - /* Find whether there's a big enough free block in the heap. - * CompactMem tries to create a contiguous block of the requested size, - * and then returns the size of the largest free block (which could be - * much more or much less than we asked for). - * We add some slop to ensure we don't use up all available memory. - */ - slop = max_bytes_needed / 16 + 32768L; - mem = CompactMem(max_bytes_needed + slop) - slop; - if (mem < 0) - mem = 0; /* sigh, couldn't even get the slop */ - /* Don't take more than the application says we can have */ - if (mem > limit && limit > 0) - mem = limit; - return mem; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - - -METHODDEF(void) -read_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - long bytes = byte_count; - long retVal; - - if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) - ERREXIT(cinfo, JERR_TFILE_SEEK); - - retVal = FSRead ( info->temp_file, &bytes, - (unsigned char *) buffer_address ); - if ( retVal != noErr || bytes != byte_count ) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - long bytes = byte_count; - long retVal; - - if ( SetFPos ( info->temp_file, fsFromStart, file_offset ) != noErr ) - ERREXIT(cinfo, JERR_TFILE_SEEK); - - retVal = FSWrite ( info->temp_file, &bytes, - (unsigned char *) buffer_address ); - if ( retVal != noErr || bytes != byte_count ) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_backing_store (j_common_ptr cinfo, backing_store_ptr info) -{ - FSClose ( info->temp_file ); - FSpDelete ( &(info->tempSpec) ); -} - - -/* - * Initial opening of a backing-store object. - * - * This version uses FindFolder to find the Temporary Items folder, - * and puts the temporary file in there. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - short tmpRef, vRefNum; - long dirID; - FInfo finderInfo; - FSSpec theSpec; - Str255 fName; - OSErr osErr; - long gestaltResponse = 0; - - /* Check that FSSpec calls are available. */ - osErr = Gestalt( gestaltFSAttr, &gestaltResponse ); - if ( ( osErr != noErr ) - || !( gestaltResponse & (1<temp_name, TEMP_FILE_NAME, next_file_num); - strcpy ( (Ptr)fName+1, info->temp_name ); - *fName = strlen (info->temp_name); - osErr = FSMakeFSSpec ( vRefNum, dirID, fName, &theSpec ); - - if ( (osErr = FSpGetFInfo ( &theSpec, &finderInfo ) ) != noErr ) - break; - } - - osErr = FSpCreate ( &theSpec, '????', '????', smSystemScript ); - if ( osErr != noErr ) - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - - osErr = FSpOpenDF ( &theSpec, fsRdWrPerm, &(info->temp_file) ); - if ( osErr != noErr ) - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - - info->tempSpec = theSpec; - - info->read_backing_store = read_backing_store; - info->write_backing_store = write_backing_store; - info->close_backing_store = close_backing_store; - TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - next_file_num = 0; - - /* max_memory_to_use will be initialized to FreeMem()'s result; - * the calling application might later reduce it, for example - * to leave room to invoke multiple JPEG objects. - * Note that FreeMem returns the total number of free bytes; - * it may not be possible to allocate a single block of this size. - */ - return FreeMem(); -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/code/jpeg-9f/jmemname.c b/code/jpeg-9f/jmemname.c deleted file mode 100644 index ed96dee1..00000000 --- a/code/jpeg-9f/jmemname.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * jmemname.c - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a generic implementation of the system-dependent - * portion of the JPEG memory manager. This implementation assumes that - * you must explicitly construct a name for each temp file. - * Also, the problem of determining the amount of memory available - * is shoved onto the user. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - -#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ -#define SEEK_SET 0 /* if not, assume 0 is correct */ -#endif - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#define RW_BINARY "w+" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#define RW_BINARY "w+b", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#define RW_BINARY "w+b" -#endif -#endif - - -/* - * Selection of a file name for a temporary file. - * This is system-dependent! - * - * The code as given is suitable for most Unix systems, and it is easily - * modified for most non-Unix systems. Some notes: - * 1. The temp file is created in the directory named by TEMP_DIRECTORY. - * The default value is /usr/tmp, which is the conventional place for - * creating large temp files on Unix. On other systems you'll probably - * want to change the file location. You can do this by editing the - * #define, or (preferred) by defining TEMP_DIRECTORY in jconfig.h. - * - * 2. If you need to change the file name as well as its location, - * you can override the TEMP_FILE_NAME macro. (Note that this is - * actually a printf format string; it must contain %s and %d.) - * Few people should need to do this. - * - * 3. mktemp() is used to ensure that multiple processes running - * simultaneously won't select the same file names. If your system - * doesn't have mktemp(), define NO_MKTEMP to do it the hard way. - * (If you don't have , also define NO_ERRNO_H.) - * - * 4. You probably want to define NEED_SIGNAL_CATCHER so that cjpeg.c/djpeg.c - * will cause the temp files to be removed if you stop the program early. - */ - -#ifndef TEMP_DIRECTORY /* can override from jconfig.h or Makefile */ -#define TEMP_DIRECTORY "/usr/tmp/" /* recommended setting for Unix */ -#endif - -static int next_file_num; /* to distinguish among several temp files */ - -#ifdef NO_MKTEMP - -#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ -#define TEMP_FILE_NAME "%sJPG%03d.TMP" -#endif - -#ifndef NO_ERRNO_H -#include /* to define ENOENT */ -#endif - -/* ANSI C specifies that errno is a macro, but on older systems it's more - * likely to be a plain int variable. And not all versions of errno.h - * bother to declare it, so we have to in order to be most portable. Thus: - */ -#ifndef errno -extern int errno; -#endif - - -LOCAL(void) -select_file_name (char * fname) -{ - FILE * tfile; - - /* Keep generating file names till we find one that's not in use */ - for (;;) { - next_file_num++; /* advance counter */ - sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); - if ((tfile = fopen(fname, READ_BINARY)) == NULL) { - /* fopen could have failed for a reason other than the file not - * being there; for example, file there but unreadable. - * If isn't available, then we cannot test the cause. - */ -#ifdef ENOENT - if (errno != ENOENT) - continue; -#endif - break; - } - fclose(tfile); /* oops, it's there; close tfile & try again */ - } -} - -#else /* ! NO_MKTEMP */ - -/* Note that mktemp() requires the initial filename to end in six X's */ -#ifndef TEMP_FILE_NAME /* can override from jconfig.h or Makefile */ -#define TEMP_FILE_NAME "%sJPG%dXXXXXX" -#endif - -LOCAL(void) -select_file_name (char * fname) -{ - next_file_num++; /* advance counter */ - sprintf(fname, TEMP_FILE_NAME, TEMP_DIRECTORY, next_file_num); - mktemp(fname); /* make sure file name is unique */ - /* mktemp replaces the trailing XXXXXX with a unique string of characters */ -} - -#endif /* NO_MKTEMP */ - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * It's impossible to do this in a portable way; our current solution is - * to make the user tell us (with a default value set at compile time). - * If you can actually get the available space, it's a good idea to subtract - * a slop factor of 5% or so. - */ - -#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ -#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ -#endif - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return cinfo->mem->max_memory_to_use - already_allocated; -} - - -/* - * Backing store (temporary file) management. - * Backing store objects are only used when the value returned by - * jpeg_mem_available is less than the total space needed. You can dispense - * with these routines if you have plenty of virtual memory; see jmemnobs.c. - */ - - -METHODDEF(void) -read_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFREAD(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_READ); -} - - -METHODDEF(void) -write_backing_store (j_common_ptr cinfo, backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count) -{ - if (fseek(info->temp_file, file_offset, SEEK_SET)) - ERREXIT(cinfo, JERR_TFILE_SEEK); - if (JFWRITE(info->temp_file, buffer_address, byte_count) - != (size_t) byte_count) - ERREXIT(cinfo, JERR_TFILE_WRITE); -} - - -METHODDEF(void) -close_backing_store (j_common_ptr cinfo, backing_store_ptr info) -{ - fclose(info->temp_file); /* close the file */ - unlink(info->temp_name); /* delete the file */ -/* If your system doesn't have unlink(), use remove() instead. - * remove() is the ANSI-standard name for this function, but if - * your system was ANSI you'd be using jmemansi.c, right? - */ - TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name); -} - - -/* - * Initial opening of a backing-store object. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - select_file_name(info->temp_name); - if ((info->temp_file = fopen(info->temp_name, RW_BINARY)) == NULL) - ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name); - info->read_backing_store = read_backing_store; - info->write_backing_store = write_backing_store; - info->close_backing_store = close_backing_store; - TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - next_file_num = 0; /* initialize temp file name generator */ - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/code/jpeg-9f/jpegtran.c b/code/jpeg-9f/jpegtran.c deleted file mode 100644 index bfaa8aca..00000000 --- a/code/jpeg-9f/jpegtran.c +++ /dev/null @@ -1,654 +0,0 @@ -/* - * jpegtran.c - * - * Copyright (C) 1995-2019, Thomas G. Lane, Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a command-line user interface for JPEG transcoding. - * It is very similar to cjpeg.c, and partly to djpeg.c, but provides - * lossless transcoding between different JPEG file formats. It also - * provides some lossless and sort-of-lossless transformations of JPEG data. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include "transupp.h" /* Support routines for jpegtran */ -#include "jversion.h" /* for version message */ - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - - -/* - * Argument-parsing code. - * The switch parser is designed to be useful with DOS-style command line - * syntax, ie, intermixed switches and file names, where only the switches - * to the left of a given file name affect processing of that file. - * The main program in this file doesn't actually use this capability... - */ - - -static const char * progname; /* program name for error messages */ -static char * outfilename; /* for -outfile switch */ -static char * dropfilename; /* for -drop switch */ -static char * scaleoption; /* -scale switch */ -static JCOPY_OPTION copyoption; /* -copy switch */ -static jpeg_transform_info transformoption; /* image transformation options */ - - -LOCAL(void) -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -copy none Copy no extra markers from source file\n"); - fprintf(stderr, " -copy comments Copy only comment markers (default)\n"); - fprintf(stderr, " -copy all Copy all extra markers\n"); -#ifdef ENTROPY_OPT_SUPPORTED - fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n"); -#endif -#ifdef C_PROGRESSIVE_SUPPORTED - fprintf(stderr, " -progressive Create progressive JPEG file\n"); -#endif - fprintf(stderr, "Switches for modifying the image:\n"); -#if TRANSFORMS_SUPPORTED - fprintf(stderr, " -crop WxH+X+Y Crop to a rectangular subarea\n"); - fprintf(stderr, " -drop +X+Y filename Drop another image\n"); - fprintf(stderr, " -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n"); - fprintf(stderr, " -grayscale Reduce to grayscale (omit color data)\n"); - fprintf(stderr, " -perfect Fail if there is non-transformable edge blocks\n"); - fprintf(stderr, " -rotate [90|180|270] Rotate image (degrees clockwise)\n"); -#endif - fprintf(stderr, " -scale M/N Scale output image by fraction M/N, eg, 1/8\n"); -#if TRANSFORMS_SUPPORTED - fprintf(stderr, " -transpose Transpose image\n"); - fprintf(stderr, " -transverse Transverse transpose image\n"); - fprintf(stderr, " -trim Drop non-transformable edge blocks\n"); - fprintf(stderr, " with -drop: Requantize drop file to source file\n"); - fprintf(stderr, " -wipe WxH+X+Y Wipe (gray out) a rectangular subarea\n"); -#endif - fprintf(stderr, "Switches for advanced users:\n"); -#ifdef C_ARITH_CODING_SUPPORTED - fprintf(stderr, " -arithmetic Use arithmetic coding\n"); -#endif - fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n"); - fprintf(stderr, " -maxmemory N Maximum memory to use (in kbytes)\n"); - fprintf(stderr, " -outfile name Specify name for output file\n"); - fprintf(stderr, " -verbose or -debug Emit debug output\n"); - fprintf(stderr, "Switches for wizards:\n"); -#ifdef C_MULTISCAN_FILES_SUPPORTED - fprintf(stderr, " -scans file Create multi-scan JPEG per script file\n"); -#endif - exit(EXIT_FAILURE); -} - - -LOCAL(void) -select_transform (JXFORM_CODE transform) -/* Silly little routine to detect multiple transform options, - * which we can't handle. - */ -{ -#if TRANSFORMS_SUPPORTED - if (transformoption.transform == JXFORM_NONE || - transformoption.transform == transform) { - transformoption.transform = transform; - } else { - fprintf(stderr, "%s: can only do one image transformation at a time\n", - progname); - usage(); - } -#else - fprintf(stderr, "%s: sorry, image transformation was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif -} - - -LOCAL(int) -parse_switches (j_compress_ptr cinfo, int argc, char **argv, - int last_file_arg_seen, boolean for_real) -/* Parse optional switches. - * Returns argv[] index of first file-name argument (== argc if none). - * Any file names with indexes <= last_file_arg_seen are ignored; - * they have presumably been processed in a previous iteration. - * (Pass 0 for last_file_arg_seen on the first or only iteration.) - * for_real is FALSE on the first (dummy) pass; we may skip any expensive - * processing. - */ -{ - int argn; - char * arg; - boolean simple_progressive; - char * scansarg = NULL; /* saves -scans parm if any */ - - /* Set up default JPEG parameters. */ - simple_progressive = FALSE; - outfilename = NULL; - scaleoption = NULL; - copyoption = JCOPYOPT_DEFAULT; - transformoption.transform = JXFORM_NONE; - transformoption.perfect = FALSE; - transformoption.trim = FALSE; - transformoption.force_grayscale = FALSE; - transformoption.crop = FALSE; - cinfo->err->trace_level = 0; - - /* Scan command line options, adjust parameters */ - - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (*arg != '-') { - /* Not a switch, must be a file name argument */ - if (argn <= last_file_arg_seen) { - outfilename = NULL; /* -outfile applies to just one input file */ - continue; /* ignore this name if previously processed */ - } - break; /* else done parsing switches */ - } - arg++; /* advance past switch marker character */ - - if (keymatch(arg, "arithmetic", 1)) { - /* Use arithmetic coding. */ -#ifdef C_ARITH_CODING_SUPPORTED - cinfo->arith_code = TRUE; -#else - fprintf(stderr, "%s: sorry, arithmetic coding not supported\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "copy", 2)) { - /* Select which extra markers to copy. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "none", 1)) { - copyoption = JCOPYOPT_NONE; - } else if (keymatch(argv[argn], "comments", 1)) { - copyoption = JCOPYOPT_COMMENTS; - } else if (keymatch(argv[argn], "all", 1)) { - copyoption = JCOPYOPT_ALL; - } else - usage(); - - } else if (keymatch(arg, "crop", 2)) { - /* Perform lossless cropping. */ -#if TRANSFORMS_SUPPORTED - if (++argn >= argc) /* advance to next argument */ - usage(); - if (transformoption.crop /* reject multiple crop/drop/wipe requests */ || - ! jtransform_parse_crop_spec(&transformoption, argv[argn])) { - fprintf(stderr, "%s: bogus -crop argument '%s'\n", - progname, argv[argn]); - exit(EXIT_FAILURE); - } -#else - select_transform(JXFORM_NONE); /* force an error */ -#endif - - } else if (keymatch(arg, "drop", 2)) { -#if TRANSFORMS_SUPPORTED - if (++argn >= argc) /* advance to next argument */ - usage(); - if (transformoption.crop /* reject multiple crop/drop/wipe requests */ || - ! jtransform_parse_crop_spec(&transformoption, argv[argn]) || - transformoption.crop_width_set != JCROP_UNSET || - transformoption.crop_height_set != JCROP_UNSET) { - fprintf(stderr, "%s: bogus -drop argument '%s'\n", - progname, argv[argn]); - exit(EXIT_FAILURE); - } - if (++argn >= argc) /* advance to next argument */ - usage(); - dropfilename = argv[argn]; - select_transform(JXFORM_DROP); -#else - select_transform(JXFORM_NONE); /* force an error */ -#endif - - } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { - /* Enable debug printouts. */ - /* On first -d, print version identification */ - static boolean printed_version = FALSE; - - if (! printed_version) { - fprintf(stderr, "Independent JPEG Group's JPEGTRAN, version %s\n%s\n", - JVERSION, JCOPYRIGHT); - printed_version = TRUE; - } - cinfo->err->trace_level++; - - } else if (keymatch(arg, "flip", 1)) { - /* Mirror left-right or top-bottom. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "horizontal", 1)) - select_transform(JXFORM_FLIP_H); - else if (keymatch(argv[argn], "vertical", 1)) - select_transform(JXFORM_FLIP_V); - else - usage(); - - } else if (keymatch(arg, "grayscale", 1) || keymatch(arg, "greyscale",1)) { - /* Force to grayscale. */ -#if TRANSFORMS_SUPPORTED - transformoption.force_grayscale = TRUE; -#else - select_transform(JXFORM_NONE); /* force an error */ -#endif - - } else if (keymatch(arg, "maxmemory", 3)) { - /* Maximum memory in Kb (or Mb with 'm'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (ch == 'm' || ch == 'M') - lval *= 1000L; - cinfo->mem->max_memory_to_use = lval * 1000L; - - } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) { - /* Enable entropy parm optimization. */ -#ifdef ENTROPY_OPT_SUPPORTED - cinfo->optimize_coding = TRUE; -#else - fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "outfile", 4)) { - /* Set output file name. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - outfilename = argv[argn]; /* save it away for later use */ - - } else if (keymatch(arg, "perfect", 2)) { - /* Fail if there is any partial edge MCUs that the transform can't - * handle. */ - transformoption.perfect = TRUE; - - } else if (keymatch(arg, "progressive", 2)) { - /* Select simple progressive mode. */ -#ifdef C_PROGRESSIVE_SUPPORTED - simple_progressive = TRUE; - /* We must postpone execution until num_components is known. */ -#else - fprintf(stderr, "%s: sorry, progressive output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "restart", 1)) { - /* Restart interval in MCU rows (or in MCUs with 'b'). */ - long lval; - char ch = 'x'; - - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1) - usage(); - if (lval < 0 || lval > 65535L) - usage(); - if (ch == 'b' || ch == 'B') { - cinfo->restart_interval = (unsigned int) lval; - cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */ - } else { - cinfo->restart_in_rows = (int) lval; - /* restart_interval will be computed during startup */ - } - - } else if (keymatch(arg, "rotate", 2)) { - /* Rotate 90, 180, or 270 degrees (measured clockwise). */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (keymatch(argv[argn], "90", 2)) - select_transform(JXFORM_ROT_90); - else if (keymatch(argv[argn], "180", 3)) - select_transform(JXFORM_ROT_180); - else if (keymatch(argv[argn], "270", 3)) - select_transform(JXFORM_ROT_270); - else - usage(); - - } else if (keymatch(arg, "scale", 4)) { - /* Scale the output image by a fraction M/N. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - scaleoption = argv[argn]; - /* We must postpone processing until decompression startup. */ - - } else if (keymatch(arg, "scans", 1)) { - /* Set scan script. */ -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (++argn >= argc) /* advance to next argument */ - usage(); - scansarg = argv[argn]; - /* We must postpone reading the file in case -progressive appears. */ -#else - fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", - progname); - exit(EXIT_FAILURE); -#endif - - } else if (keymatch(arg, "transpose", 1)) { - /* Transpose (across UL-to-LR axis). */ - select_transform(JXFORM_TRANSPOSE); - - } else if (keymatch(arg, "transverse", 6)) { - /* Transverse transpose (across UR-to-LL axis). */ - select_transform(JXFORM_TRANSVERSE); - - } else if (keymatch(arg, "trim", 3)) { - /* Trim off any partial edge MCUs that the transform can't handle. */ - transformoption.trim = TRUE; - - } else if (keymatch(arg, "wipe", 1)) { -#if TRANSFORMS_SUPPORTED - if (++argn >= argc) /* advance to next argument */ - usage(); - if (transformoption.crop /* reject multiple crop/drop/wipe requests */ || - ! jtransform_parse_crop_spec(&transformoption, argv[argn])) { - fprintf(stderr, "%s: bogus -wipe argument '%s'\n", - progname, argv[argn]); - exit(EXIT_FAILURE); - } - select_transform(JXFORM_WIPE); -#else - select_transform(JXFORM_NONE); /* force an error */ -#endif - - } else { - usage(); /* bogus switch */ - } - } - - /* Post-switch-scanning cleanup */ - - if (for_real) { - -#ifdef C_PROGRESSIVE_SUPPORTED - if (simple_progressive) /* process -progressive; -scans can override */ - jpeg_simple_progression(cinfo); -#endif - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (scansarg != NULL) /* process -scans if it was present */ - if (! read_scan_script(cinfo, scansarg)) - usage(); -#endif - } - - return argn; /* return index of next arg (file name) */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - struct jpeg_decompress_struct srcinfo; - struct jpeg_error_mgr jsrcerr; -#if TRANSFORMS_SUPPORTED - struct jpeg_decompress_struct dropinfo; - struct jpeg_error_mgr jdroperr; - FILE * drop_file; -#endif - struct jpeg_compress_struct dstinfo; - struct jpeg_error_mgr jdsterr; -#ifdef PROGRESS_REPORT - struct cdjpeg_progress_mgr progress; -#endif - jvirt_barray_ptr * src_coef_arrays; - jvirt_barray_ptr * dst_coef_arrays; - int file_index; - /* We assume all-in-memory processing and can therefore use only a - * single file pointer for sequential input and output operation. - */ - FILE * fp; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "jpegtran"; /* in case C library doesn't provide it */ - - /* Initialize the JPEG decompression object with default error handling. */ - srcinfo.err = jpeg_std_error(&jsrcerr); - jpeg_create_decompress(&srcinfo); - /* Initialize the JPEG compression object with default error handling. */ - dstinfo.err = jpeg_std_error(&jdsterr); - jpeg_create_compress(&dstinfo); - - /* Now safe to enable signal catcher. - * Note: we assume only the decompression object will have virtual arrays. - */ -#ifdef NEED_SIGNAL_CATCHER - enable_signal_catcher((j_common_ptr) &srcinfo); -#endif - - /* Scan command line to find file names. - * It is convenient to use just one switch-parsing routine, but the switch - * values read here are mostly ignored; we will rescan the switches after - * opening the input file. Also note that most of the switches affect the - * destination JPEG object, so we parse into that and then copy over what - * needs to affect the source too. - */ - - file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE); - jsrcerr.trace_level = jdsterr.trace_level; - srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use; - -#ifdef TWO_FILE_COMMANDLINE - /* Must have either -outfile switch or explicit output file name */ - if (outfilename == NULL) { - if (file_index != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - outfilename = argv[file_index+1]; - } else { - if (file_index != argc-1) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - } -#else - /* Unix style: expect zero or one file name */ - if (file_index < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } -#endif /* TWO_FILE_COMMANDLINE */ - - /* Open the input file. */ - if (file_index < argc) { - if ((fp = fopen(argv[file_index], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s for reading\n", progname, argv[file_index]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ - fp = read_stdin(); - } - -#if TRANSFORMS_SUPPORTED - /* Open the drop file. */ - if (dropfilename != NULL) { - if ((drop_file = fopen(dropfilename, READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s for reading\n", progname, dropfilename); - exit(EXIT_FAILURE); - } - dropinfo.err = jpeg_std_error(&jdroperr); - jpeg_create_decompress(&dropinfo); - jpeg_stdio_src(&dropinfo, drop_file); - } else { - drop_file = NULL; - } -#endif - -#ifdef PROGRESS_REPORT - start_progress_monitor((j_common_ptr) &dstinfo, &progress); -#endif - - /* Specify data source for decompression */ - jpeg_stdio_src(&srcinfo, fp); - - /* Enable saving of extra markers that we want to copy */ - jcopy_markers_setup(&srcinfo, copyoption); - - /* Read file header */ - (void) jpeg_read_header(&srcinfo, TRUE); - - /* Adjust default decompression parameters */ - if (scaleoption != NULL) - if (sscanf(scaleoption, "%u/%u", - &srcinfo.scale_num, &srcinfo.scale_denom) < 1) - usage(); - -#if TRANSFORMS_SUPPORTED - if (dropfilename != NULL) { - (void) jpeg_read_header(&dropinfo, TRUE); - transformoption.crop_width = dropinfo.image_width; - transformoption.crop_width_set = JCROP_POS; - transformoption.crop_height = dropinfo.image_height; - transformoption.crop_height_set = JCROP_POS; - transformoption.drop_ptr = &dropinfo; - } -#endif - - /* Any space needed by a transform option must be requested before - * jpeg_read_coefficients so that memory allocation will be done right. - */ -#if TRANSFORMS_SUPPORTED - /* Fail right away if -perfect is given and transformation is not perfect. - */ - if (!jtransform_request_workspace(&srcinfo, &transformoption)) { - fprintf(stderr, "%s: transformation is not perfect\n", progname); - exit(EXIT_FAILURE); - } -#endif - - /* Read source file as DCT coefficients */ - src_coef_arrays = jpeg_read_coefficients(&srcinfo); - -#if TRANSFORMS_SUPPORTED - if (dropfilename != NULL) { - transformoption.drop_coef_arrays = jpeg_read_coefficients(&dropinfo); - } -#endif - - /* Initialize destination compression parameters from source values */ - jpeg_copy_critical_parameters(&srcinfo, &dstinfo); - - /* Adjust destination parameters if required by transform options; - * also find out which set of coefficient arrays will hold the output. - */ -#if TRANSFORMS_SUPPORTED - dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo, - src_coef_arrays, - &transformoption); -#else - dst_coef_arrays = src_coef_arrays; -#endif - - /* Close input file, if we opened it. - * Note: we assume that jpeg_read_coefficients consumed all input - * until JPEG_REACHED_EOI, and that jpeg_finish_decompress will - * only consume more while (! cinfo->inputctl->eoi_reached). - * We cannot call jpeg_finish_decompress here since we still need the - * virtual arrays allocated from the source object for processing. - */ - if (fp != stdin) - fclose(fp); - - /* Open the output file. */ - if (outfilename != NULL) { - if ((fp = fopen(outfilename, WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s for writing\n", progname, outfilename); - exit(EXIT_FAILURE); - } - } else { - /* default output file is stdout */ - fp = write_stdout(); - } - - /* Adjust default compression parameters by re-parsing the options */ - file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE); - - /* Specify data destination for compression */ - jpeg_stdio_dest(&dstinfo, fp); - - /* Start compressor (note no image data is actually written here) */ - jpeg_write_coefficients(&dstinfo, dst_coef_arrays); - - /* Copy to the output file any extra markers that we want to preserve */ - jcopy_markers_execute(&srcinfo, &dstinfo, copyoption); - - /* Execute image transformation, if any */ -#if TRANSFORMS_SUPPORTED - jtransform_execute_transformation(&srcinfo, &dstinfo, - src_coef_arrays, - &transformoption); -#endif - - /* Finish compression and release memory */ - jpeg_finish_compress(&dstinfo); - jpeg_destroy_compress(&dstinfo); -#if TRANSFORMS_SUPPORTED - if (dropfilename != NULL) { - (void) jpeg_finish_decompress(&dropinfo); - jpeg_destroy_decompress(&dropinfo); - } -#endif - (void) jpeg_finish_decompress(&srcinfo); - jpeg_destroy_decompress(&srcinfo); - - /* Close output file, if we opened it */ - if (fp != stdout) - fclose(fp); -#if TRANSFORMS_SUPPORTED - if (drop_file != NULL) - fclose(drop_file); -#endif - -#ifdef PROGRESS_REPORT - end_progress_monitor((j_common_ptr) &dstinfo); -#endif - - /* All done. */ -#if TRANSFORMS_SUPPORTED - if (dropfilename != NULL) - exit(jsrcerr.num_warnings + jdroperr.num_warnings + - jdsterr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); -#endif - exit(jsrcerr.num_warnings + jdsterr.num_warnings ? - EXIT_WARNING : EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/code/jpeg-9f/rdbmp.c b/code/jpeg-9f/rdbmp.c deleted file mode 100644 index 6749ea01..00000000 --- a/code/jpeg-9f/rdbmp.c +++ /dev/null @@ -1,469 +0,0 @@ -/* - * rdbmp.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * Modified 2009-2019 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in Microsoft "BMP" - * format (MS Windows 3.x, OS/2 1.x, and OS/2 2.x flavors). - * Currently, only 8-, 24-, and 32-bit images are supported, not 1-bit or - * 4-bit (feeding such low-depth images into JPEG would be silly anyway). - * Also, we don't support RLE-compressed files. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed BMP format). - * - * This code contributed by James Arthur Boucher. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef BMP_SUPPORTED - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -typedef char U_CHAR; -#ifdef CHAR_IS_UNSIGNED -#define UCH(x) ((int) (x)) -#else -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -/* Private version of data source object */ - -typedef struct _bmp_source_struct * bmp_source_ptr; - -typedef struct _bmp_source_struct { - struct cjpeg_source_struct pub; /* public fields */ - - j_compress_ptr cinfo; /* back link saves passing separate parm */ - - JSAMPARRAY colormap; /* BMP colormap (converted to my format) */ - - jvirt_sarray_ptr whole_image; /* Needed to reverse row order */ - JDIMENSION source_row; /* Current source row number */ - JDIMENSION row_width; /* Physical width of scanlines in file */ - - int bits_per_pixel; /* remembers 8-, 24-, or 32-bit format */ - int cmap_length; /* colormap length */ -} bmp_source_struct; - - -LOCAL(int) -read_byte (bmp_source_ptr sinfo) -/* Read next byte from BMP file */ -{ - register FILE *infile = sinfo->pub.input_file; - register int c; - - if ((c = getc(infile)) == EOF) - ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); - return c; -} - - -LOCAL(void) -read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize) -/* Read the colormap from a BMP file */ -{ - int i; - - switch (mapentrysize) { - case 3: - /* BGR format (occurs in OS/2 files) */ - for (i = 0; i < cmaplen; i++) { - sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); - } - break; - case 4: - /* BGR0 format (occurs in MS Windows files) */ - for (i = 0; i < cmaplen; i++) { - sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); - (void) read_byte(sinfo); - } - break; - default: - ERREXIT(sinfo->cinfo, JERR_BMP_BADCMAP); - } -} - - -/* - * Read one row of pixels. - * The image has been read into the whole_image array, but is otherwise - * unprocessed. We must read it out in top-to-bottom row order, and if - * it is an 8-bit image, we must expand colormapped pixels to 24bit format. - */ - -METHODDEF(JDIMENSION) -get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 8-bit colormap indexes */ -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - register JSAMPROW inptr, outptr; - register JSAMPARRAY colormap; - register JDIMENSION col; - register int t; - int cmaplen; - - /* Fetch next row from virtual array */ - source->source_row--; - inptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, - source->whole_image, source->source_row, (JDIMENSION) 1, FALSE); - - /* Expand the colormap indexes to real data */ - outptr = source->pub.buffer[0]; - colormap = source->colormap; - cmaplen = source->cmap_length; - for (col = cinfo->image_width; col > 0; col--) { - t = GETJSAMPLE(*inptr++); - if (t >= cmaplen) - ERREXIT(cinfo, JERR_BMP_OUTOFRANGE); - *outptr++ = colormap[0][t]; /* can omit GETJSAMPLE() safely */ - *outptr++ = colormap[1][t]; - *outptr++ = colormap[2][t]; - } - - return 1; -} - -METHODDEF(JDIMENSION) -get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 24-bit pixels */ -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - - /* Fetch next row from virtual array */ - source->source_row--; - inptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, - source->whole_image, source->source_row, (JDIMENSION) 1, FALSE); - - /* Transfer data. Note source values are in BGR order - * (even though Microsoft's own documents say the opposite). - */ - outptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ - outptr[1] = *inptr++; - outptr[0] = *inptr++; - outptr += 3; - } - - return 1; -} - -METHODDEF(JDIMENSION) -get_32bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 32-bit pixels */ -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - - /* Fetch next row from virtual array */ - source->source_row--; - inptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, - source->whole_image, source->source_row, (JDIMENSION) 1, FALSE); - - /* Transfer data. Note source values are in BGR order - * (even though Microsoft's own documents say the opposite). - */ - outptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ - outptr[1] = *inptr++; - outptr[0] = *inptr++; - inptr++; /* skip the 4th byte (Alpha channel) */ - outptr += 3; - } - - return 1; -} - - -/* - * This method loads the image into whole_image during the first call on - * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call - * get_8bit_row, get_24bit_row, or get_32bit_row on subsequent calls. - */ - -METHODDEF(JDIMENSION) -preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - register FILE *infile = source->pub.input_file; - register int c; - register JSAMPROW out_ptr; - JDIMENSION row, col; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Read the data into a virtual array in input-file row order. */ - for (row = 0; row < cinfo->image_height; row++) { - if (progress != NULL) { - progress->pub.pass_counter = (long) row; - progress->pub.pass_limit = (long) cinfo->image_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - out_ptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, - source->whole_image, row, (JDIMENSION) 1, TRUE); - for (col = source->row_width; col > 0; col--) { - /* inline copy of read_byte() for speed */ - if ((c = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_INPUT_EOF); - *out_ptr++ = (JSAMPLE) c; - } - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Set up to read from the virtual array in top-to-bottom order */ - switch (source->bits_per_pixel) { - case 8: - source->pub.get_pixel_rows = get_8bit_row; - break; - case 24: - source->pub.get_pixel_rows = get_24bit_row; - break; - case 32: - source->pub.get_pixel_rows = get_32bit_row; - break; - default: - ERREXIT(cinfo, JERR_BMP_BADDEPTH); - } - source->source_row = cinfo->image_height; - - /* And read the first row */ - return (*source->pub.get_pixel_rows) (cinfo, sinfo); -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - bmp_source_ptr source = (bmp_source_ptr) sinfo; - U_CHAR bmpfileheader[14]; - U_CHAR bmpinfoheader[64]; -#define GET_2B(array, offset) ((unsigned int) UCH(array[offset]) + \ - (((unsigned int) UCH(array[offset+1])) << 8)) -#define GET_4B(array, offset) ((INT32) UCH(array[offset]) + \ - (((INT32) UCH(array[offset+1])) << 8) + \ - (((INT32) UCH(array[offset+2])) << 16) + \ - (((INT32) UCH(array[offset+3])) << 24)) - INT32 bfOffBits; - INT32 headerSize; - INT32 biWidth; - INT32 biHeight; - unsigned int biPlanes; - INT32 biCompression; - INT32 biXPelsPerMeter,biYPelsPerMeter; - INT32 biClrUsed = 0; - int mapentrysize = 0; /* 0 indicates no colormap */ - INT32 bPad; - JDIMENSION row_width; - - /* Read and verify the bitmap file header */ - if (! ReadOK(source->pub.input_file, bmpfileheader, 14)) - ERREXIT(cinfo, JERR_INPUT_EOF); - if (GET_2B(bmpfileheader, 0) != 0x4D42) /* 'BM' */ - ERREXIT(cinfo, JERR_BMP_NOT); - bfOffBits = GET_4B(bmpfileheader, 10); - /* We ignore the remaining fileheader fields */ - - /* The infoheader might be 12 bytes (OS/2 1.x), 40 bytes (Windows), - * or 64 bytes (OS/2 2.x). Check the first 4 bytes to find out which. - */ - if (! ReadOK(source->pub.input_file, bmpinfoheader, 4)) - ERREXIT(cinfo, JERR_INPUT_EOF); - headerSize = GET_4B(bmpinfoheader, 0); - if (headerSize < 12 || headerSize > 64) - ERREXIT(cinfo, JERR_BMP_BADHEADER); - if (! ReadOK(source->pub.input_file, bmpinfoheader + 4, headerSize - 4)) - ERREXIT(cinfo, JERR_INPUT_EOF); - - switch ((int) headerSize) { - case 12: - /* Decode OS/2 1.x header (Microsoft calls this a BITMAPCOREHEADER) */ - biWidth = (INT32) GET_2B(bmpinfoheader, 4); - biHeight = (INT32) GET_2B(bmpinfoheader, 6); - biPlanes = GET_2B(bmpinfoheader, 8); - source->bits_per_pixel = (int) GET_2B(bmpinfoheader, 10); - - switch (source->bits_per_pixel) { - case 8: /* colormapped image */ - mapentrysize = 3; /* OS/2 uses RGBTRIPLE colormap */ - TRACEMS2(cinfo, 1, JTRC_BMP_OS2_MAPPED, (int) biWidth, (int) biHeight); - break; - case 24: /* RGB image */ - case 32: /* RGB image + Alpha channel */ - TRACEMS3(cinfo, 1, JTRC_BMP_OS2, (int) biWidth, (int) biHeight, - source->bits_per_pixel); - break; - default: - ERREXIT(cinfo, JERR_BMP_BADDEPTH); - } - break; - case 40: - case 64: - /* Decode Windows 3.x header (Microsoft calls this a BITMAPINFOHEADER) */ - /* or OS/2 2.x header, which has additional fields that we ignore */ - biWidth = GET_4B(bmpinfoheader, 4); - biHeight = GET_4B(bmpinfoheader, 8); - biPlanes = GET_2B(bmpinfoheader, 12); - source->bits_per_pixel = (int) GET_2B(bmpinfoheader, 14); - biCompression = GET_4B(bmpinfoheader, 16); - biXPelsPerMeter = GET_4B(bmpinfoheader, 24); - biYPelsPerMeter = GET_4B(bmpinfoheader, 28); - biClrUsed = GET_4B(bmpinfoheader, 32); - /* biSizeImage, biClrImportant fields are ignored */ - - switch (source->bits_per_pixel) { - case 8: /* colormapped image */ - mapentrysize = 4; /* Windows uses RGBQUAD colormap */ - TRACEMS2(cinfo, 1, JTRC_BMP_MAPPED, (int) biWidth, (int) biHeight); - break; - case 24: /* RGB image */ - case 32: /* RGB image + Alpha channel */ - TRACEMS3(cinfo, 1, JTRC_BMP, (int) biWidth, (int) biHeight, - source->bits_per_pixel); - break; - default: - ERREXIT(cinfo, JERR_BMP_BADDEPTH); - } - if (biCompression != 0) - ERREXIT(cinfo, JERR_BMP_COMPRESSED); - - if (biXPelsPerMeter > 0 && biYPelsPerMeter > 0) { - /* Set JFIF density parameters from the BMP data */ - cinfo->X_density = (UINT16) (biXPelsPerMeter/100); /* 100 cm per meter */ - cinfo->Y_density = (UINT16) (biYPelsPerMeter/100); - cinfo->density_unit = 2; /* dots/cm */ - } - break; - default: - ERREXIT(cinfo, JERR_BMP_BADHEADER); - return; /* avoid compiler warnings for uninitialized variables */ - } - - if (biPlanes != 1) - ERREXIT(cinfo, JERR_BMP_BADPLANES); - /* Sanity check for buffer allocation below */ - if (biWidth <= 0 || biHeight <= 0 || (biWidth >> 24) || (biHeight >> 24)) - ERREXIT(cinfo, JERR_BMP_OUTOFRANGE); - - /* Compute distance to bitmap data --- will adjust for colormap below */ - bPad = bfOffBits - (headerSize + 14); - - /* Read the colormap, if any */ - if (mapentrysize > 0) { - if (biClrUsed <= 0) - biClrUsed = 256; /* assume it's 256 */ - else if (biClrUsed > 256) - ERREXIT(cinfo, JERR_BMP_BADCMAP); - /* Allocate space to store the colormap */ - source->colormap = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, - JPOOL_IMAGE, (JDIMENSION) biClrUsed, (JDIMENSION) 3); - source->cmap_length = (int) biClrUsed; - /* and read it from the file */ - read_colormap(source, (int) biClrUsed, mapentrysize); - /* account for size of colormap */ - bPad -= biClrUsed * mapentrysize; - } - - /* Skip any remaining pad bytes */ - if (bPad < 0) /* incorrect bfOffBits value? */ - ERREXIT(cinfo, JERR_BMP_BADHEADER); - while (--bPad >= 0) { - (void) read_byte(source); - } - - /* Compute row width in file, including padding to 4-byte boundary */ - if (source->bits_per_pixel == 24) - row_width = (JDIMENSION) (biWidth * 3); - else if (source->bits_per_pixel == 32) - row_width = (JDIMENSION) (biWidth * 4); - else - row_width = (JDIMENSION) biWidth; - while ((row_width & 3) != 0) row_width++; - source->row_width = row_width; - - /* Allocate space for inversion array, prepare for preload pass */ - source->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - row_width, (JDIMENSION) biHeight, (JDIMENSION) 1); - source->pub.get_pixel_rows = preload_image; - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - - /* Allocate one-row buffer for returned data */ - source->pub.buffer = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, - JPOOL_IMAGE, (JDIMENSION) (biWidth * 3), (JDIMENSION) 1); - source->pub.buffer_height = 1; - - cinfo->in_color_space = JCS_RGB; - cinfo->input_components = 3; - cinfo->data_precision = 8; - cinfo->image_width = (JDIMENSION) biWidth; - cinfo->image_height = (JDIMENSION) biHeight; -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_bmp (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for BMP format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_bmp (j_compress_ptr cinfo) -{ - bmp_source_ptr source; - - /* Create module interface object */ - source = (bmp_source_ptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(bmp_source_struct)); - source->cinfo = cinfo; /* make back link for subroutines */ - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_bmp; - source->pub.finish_input = finish_input_bmp; - - return &source->pub; -} - -#endif /* BMP_SUPPORTED */ diff --git a/code/jpeg-9f/rdcolmap.c b/code/jpeg-9f/rdcolmap.c deleted file mode 100644 index 42b34376..00000000 --- a/code/jpeg-9f/rdcolmap.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * rdcolmap.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file implements djpeg's "-map file" switch. It reads a source image - * and constructs a colormap to be supplied to the JPEG decompressor. - * - * Currently, these file formats are supported for the map file: - * GIF: the contents of the GIF's global colormap are used. - * PPM (either text or raw flavor): the entire file is read and - * each unique pixel value is entered in the map. - * Note that reading a large PPM file will be horrendously slow. - * Typically, a PPM-format map file should contain just one pixel - * of each desired color. Such a file can be extracted from an - * ordinary image PPM file with ppmtomap(1). - * - * Rescaling a PPM that has a maxval unequal to MAXJSAMPLE is not - * currently implemented. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ - -/* Portions of this code are based on the PBMPLUS library, which is: -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose and without fee is hereby granted, provided -** that the above copyright notice appear in all copies and that both that -** copyright notice and this permission notice appear in supporting -** documentation. This software is provided "as is" without express or -** implied warranty. -*/ - - -/* - * Add a (potentially) new color to the color map. - */ - -LOCAL(void) -add_map_entry (j_decompress_ptr cinfo, int R, int G, int B) -{ - JSAMPROW colormap0 = cinfo->colormap[0]; - JSAMPROW colormap1 = cinfo->colormap[1]; - JSAMPROW colormap2 = cinfo->colormap[2]; - int ncolors = cinfo->actual_number_of_colors; - int index; - - /* Check for duplicate color. */ - for (index = 0; index < ncolors; index++) { - if (GETJSAMPLE(colormap0[index]) == R && - GETJSAMPLE(colormap1[index]) == G && - GETJSAMPLE(colormap2[index]) == B) - return; /* color is already in map */ - } - - /* Check for map overflow. */ - if (ncolors >= (MAXJSAMPLE+1)) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE+1)); - - /* OK, add color to map. */ - colormap0[ncolors] = (JSAMPLE) R; - colormap1[ncolors] = (JSAMPLE) G; - colormap2[ncolors] = (JSAMPLE) B; - cinfo->actual_number_of_colors++; -} - - -/* - * Extract color map from a GIF file. - */ - -LOCAL(void) -read_gif_map (j_decompress_ptr cinfo, FILE * infile) -{ - int header[13]; - int i, colormaplen; - int R, G, B; - - /* Initial 'G' has already been read by read_color_map */ - /* Read the rest of the GIF header and logical screen descriptor */ - for (i = 1; i < 13; i++) { - if ((header[i] = getc(infile)) == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - } - - /* Verify GIF Header */ - if (header[1] != 'I' || header[2] != 'F') - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - /* There must be a global color map. */ - if ((header[10] & 0x80) == 0) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - /* OK, fetch it. */ - colormaplen = 2 << (header[10] & 0x07); - - for (i = 0; i < colormaplen; i++) { - R = getc(infile); - G = getc(infile); - B = getc(infile); - if (R == EOF || G == EOF || B == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - add_map_entry(cinfo, - R << (BITS_IN_JSAMPLE-8), - G << (BITS_IN_JSAMPLE-8), - B << (BITS_IN_JSAMPLE-8)); - } -} - - -/* Support routines for reading PPM */ - - -LOCAL(int) -pbm_getc (FILE * infile) -/* Read next char, skipping over any comments */ -/* A comment/newline sequence is returned as a newline */ -{ - register int ch; - - ch = getc(infile); - if (ch == '#') { - do { - ch = getc(infile); - } while (ch != '\n' && ch != EOF); - } - return ch; -} - - -LOCAL(unsigned int) -read_pbm_integer (j_decompress_ptr cinfo, FILE * infile) -/* Read an unsigned decimal integer from the PPM file */ -/* Swallows one trailing character after the integer */ -/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ -/* This should not be a problem in practice. */ -{ - register int ch; - register unsigned int val; - - /* Skip any leading whitespace */ - do { - ch = pbm_getc(infile); - if (ch == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); - - if (ch < '0' || ch > '9') - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - val = ch - '0'; - while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { - val *= 10; - val += ch - '0'; - } - return val; -} - - -/* - * Extract color map from a PPM file. - */ - -LOCAL(void) -read_ppm_map (j_decompress_ptr cinfo, FILE * infile) -{ - int c; - unsigned int w, h, maxval, row, col; - int R, G, B; - - /* Initial 'P' has already been read by read_color_map */ - c = getc(infile); /* save format discriminator for a sec */ - - /* while we fetch the remaining header info */ - w = read_pbm_integer(cinfo, infile); - h = read_pbm_integer(cinfo, infile); - maxval = read_pbm_integer(cinfo, infile); - - if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - /* For now, we don't support rescaling from an unusual maxval. */ - if (maxval != (unsigned int) MAXJSAMPLE) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - - switch (c) { - case '3': /* it's a text-format PPM file */ - for (row = 0; row < h; row++) { - for (col = 0; col < w; col++) { - R = read_pbm_integer(cinfo, infile); - G = read_pbm_integer(cinfo, infile); - B = read_pbm_integer(cinfo, infile); - add_map_entry(cinfo, R, G, B); - } - } - break; - - case '6': /* it's a raw-format PPM file */ - for (row = 0; row < h; row++) { - for (col = 0; col < w; col++) { - R = getc(infile); - G = getc(infile); - B = getc(infile); - if (R == EOF || G == EOF || B == EOF) - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - add_map_entry(cinfo, R, G, B); - } - } - break; - - default: - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - break; - } -} - - -/* - * Main entry point from djpeg.c. - * Input: opened input file (from file name argument on command line). - * Output: colormap and actual_number_of_colors fields are set in cinfo. - */ - -GLOBAL(void) -read_color_map (j_decompress_ptr cinfo, FILE * infile) -{ - /* Allocate space for a color map of maximum supported size. */ - cinfo->colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (MAXJSAMPLE+1), (JDIMENSION) 3); - cinfo->actual_number_of_colors = 0; /* initialize map to empty */ - - /* Read first byte to determine file format */ - switch (getc(infile)) { - case 'G': - read_gif_map(cinfo, infile); - break; - case 'P': - read_ppm_map(cinfo, infile); - break; - default: - ERREXIT(cinfo, JERR_BAD_CMAP_FILE); - break; - } -} - -#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/code/jpeg-9f/rdgif.c b/code/jpeg-9f/rdgif.c deleted file mode 100644 index 5d2339ca..00000000 --- a/code/jpeg-9f/rdgif.c +++ /dev/null @@ -1,679 +0,0 @@ -/* - * rdgif.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * Modified 2019-2020 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in GIF format. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed GIF format). - */ - -/* - * This code is loosely based on giftoppm from the PBMPLUS distribution - * of Feb. 1991. That file contains the following copyright notice: - * +-------------------------------------------------------------------+ - * | Copyright 1990, David Koblas. | - * | Permission to use, copy, modify, and distribute this software | - * | and its documentation for any purpose and without fee is hereby | - * | granted, provided that the above copyright notice appear in all | - * | copies and that both that copyright notice and this permission | - * | notice appear in supporting documentation. This software is | - * | provided "as is" without express or implied warranty. | - * +-------------------------------------------------------------------+ - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef GIF_SUPPORTED - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -typedef char U_CHAR; -#ifdef CHAR_IS_UNSIGNED -#define UCH(x) ((int) (x)) -#else -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -#define MAXCOLORMAPSIZE 256 /* max # of colors in a GIF colormap */ -#define NUMCOLORS 3 /* # of colors */ -#define CM_RED 0 /* color component numbers */ -#define CM_GREEN 1 -#define CM_BLUE 2 - -#define MAX_LZW_BITS 12 /* maximum LZW code size */ -#define LZW_TABLE_SIZE (1< table of prefix symbols */ - UINT8 FAR *symbol_tail; /* => table of suffix bytes */ - UINT8 FAR *symbol_stack; /* => stack for symbol expansions */ - UINT8 FAR *sp; /* stack pointer */ - - /* State for interlaced image processing */ - boolean is_interlaced; /* TRUE if have interlaced image */ - jvirt_sarray_ptr interlaced_image; /* full image in interlaced order */ - JDIMENSION cur_row_number; /* need to know actual row number */ - JDIMENSION pass2_offset; /* # of pixel rows in pass 1 */ - JDIMENSION pass3_offset; /* # of pixel rows in passes 1&2 */ - JDIMENSION pass4_offset; /* # of pixel rows in passes 1,2,3 */ -} gif_source_struct; - -typedef gif_source_struct * gif_source_ptr; - - -/* Forward declarations */ -METHODDEF(JDIMENSION) get_pixel_rows - JPP((j_compress_ptr cinfo, cjpeg_source_ptr sinfo)); -METHODDEF(JDIMENSION) load_interlaced_image - JPP((j_compress_ptr cinfo, cjpeg_source_ptr sinfo)); -METHODDEF(JDIMENSION) get_interlaced_row - JPP((j_compress_ptr cinfo, cjpeg_source_ptr sinfo)); - - -LOCAL(int) -ReadByte (gif_source_ptr sinfo) -/* Read next byte from GIF file */ -{ - register FILE *infile = sinfo->pub.input_file; - register int c; - - if ((c = getc(infile)) == EOF) - ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); - return c; -} - - -LOCAL(int) -GetDataBlock (gif_source_ptr sinfo, U_CHAR *buf) -/* Read a GIF data block, which has a leading count byte */ -/* A zero-length block marks the end of a data block sequence */ -{ - int count; - - count = ReadByte(sinfo); - if (count > 0) { - if (! ReadOK(sinfo->pub.input_file, buf, count)) - ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); - } - return count; -} - - -LOCAL(void) -SkipDataBlocks (gif_source_ptr sinfo) -/* Skip a series of data blocks, until a block terminator is found */ -{ - U_CHAR buf[256]; - - while (GetDataBlock(sinfo, buf) > 0) - /* skip */; -} - - -LOCAL(void) -ReInitLZW (gif_source_ptr sinfo) -/* (Re)initialize LZW state; shared code for startup and Clear processing */ -{ - sinfo->code_size = sinfo->input_code_size + 1; - sinfo->limit_code = sinfo->clear_code << 1; /* 2^code_size */ - sinfo->max_code = sinfo->clear_code + 2; /* first unused code value */ - sinfo->sp = sinfo->symbol_stack; /* init stack to empty */ -} - - -LOCAL(void) -InitLZWCode (gif_source_ptr sinfo) -/* Initialize for a series of LZWReadByte (and hence GetCode) calls */ -{ - /* GetCode initialization */ - sinfo->last_byte = 2; /* make safe to "recopy last two bytes" */ - sinfo->code_buf[0] = 0; - sinfo->code_buf[1] = 0; - sinfo->last_bit = 0; /* nothing in the buffer */ - sinfo->cur_bit = 0; /* force buffer load on first call */ - sinfo->first_time = TRUE; - sinfo->out_of_blocks = FALSE; - - /* LZWReadByte initialization: */ - /* compute special code values (note that these do not change later) */ - sinfo->clear_code = 1 << sinfo->input_code_size; - sinfo->end_code = sinfo->clear_code + 1; - ReInitLZW(sinfo); -} - - -LOCAL(int) -GetCode (gif_source_ptr sinfo) -/* Fetch the next code_size bits from the GIF data */ -/* We assume code_size is less than 16 */ -{ - register INT32 accum; - int offs, count; - - while (sinfo->cur_bit + sinfo->code_size > sinfo->last_bit) { - /* Time to reload the buffer */ - /* First time, share code with Clear case */ - if (sinfo->first_time) { - sinfo->first_time = FALSE; - return sinfo->clear_code; - } - if (sinfo->out_of_blocks) { - WARNMS(sinfo->cinfo, JWRN_GIF_NOMOREDATA); - return sinfo->end_code; /* fake something useful */ - } - /* preserve last two bytes of what we have -- assume code_size <= 16 */ - sinfo->code_buf[0] = sinfo->code_buf[sinfo->last_byte-2]; - sinfo->code_buf[1] = sinfo->code_buf[sinfo->last_byte-1]; - /* Load more bytes; set flag if we reach the terminator block */ - if ((count = GetDataBlock(sinfo, &sinfo->code_buf[2])) == 0) { - sinfo->out_of_blocks = TRUE; - WARNMS(sinfo->cinfo, JWRN_GIF_NOMOREDATA); - return sinfo->end_code; /* fake something useful */ - } - /* Reset counters */ - sinfo->cur_bit = (sinfo->cur_bit - sinfo->last_bit) + 16; - sinfo->last_byte = 2 + count; - sinfo->last_bit = sinfo->last_byte * 8; - } - - /* Form up next 24 bits in accum */ - offs = sinfo->cur_bit >> 3; /* byte containing cur_bit */ - accum = (INT32) UCH(sinfo->code_buf[offs+2]); - accum <<= 8; - accum |= (INT32) UCH(sinfo->code_buf[offs+1]); - accum <<= 8; - accum |= (INT32) UCH(sinfo->code_buf[offs]); - - /* Right-align cur_bit in accum, then mask off desired number of bits */ - accum >>= (sinfo->cur_bit & 7); - sinfo->cur_bit += sinfo->code_size; - return ((int) accum) & ((1 << sinfo->code_size) - 1); -} - - -LOCAL(int) -LZWReadByte (gif_source_ptr sinfo) -/* Read an LZW-compressed byte */ -{ - register int code; /* current working code */ - int incode; /* saves actual input code */ - - /* If any codes are stacked from a previously read symbol, return them */ - if (sinfo->sp > sinfo->symbol_stack) - return (int) *(-- sinfo->sp); - - /* Time to read a new symbol */ - code = GetCode(sinfo); - - if (code == sinfo->clear_code) { - /* Reinit state, swallow any extra Clear codes, and */ - /* return next code, which is expected to be a raw byte. */ - ReInitLZW(sinfo); - do { - code = GetCode(sinfo); - } while (code == sinfo->clear_code); - if (code > sinfo->clear_code) { /* make sure it is a raw byte */ - WARNMS(sinfo->cinfo, JWRN_GIF_BADDATA); - code = 0; /* use something valid */ - } - /* make firstcode, oldcode valid! */ - sinfo->firstcode = sinfo->oldcode = code; - return code; - } - - if (code == sinfo->end_code) { - /* Skip the rest of the image, unless GetCode already read terminator */ - if (! sinfo->out_of_blocks) { - SkipDataBlocks(sinfo); - sinfo->out_of_blocks = TRUE; - } - /* Complain that there's not enough data */ - WARNMS(sinfo->cinfo, JWRN_GIF_ENDCODE); - /* Pad data with 0's */ - return 0; /* fake something usable */ - } - - /* Got normal raw byte or LZW symbol */ - incode = code; /* save for a moment */ - - if (code >= sinfo->max_code) { /* special case for not-yet-defined symbol */ - /* code == max_code is OK; anything bigger is bad data */ - if (code > sinfo->max_code) { - WARNMS(sinfo->cinfo, JWRN_GIF_BADDATA); - incode = 0; /* prevent creation of loops in symbol table */ - } - /* this symbol will be defined as oldcode/firstcode */ - *(sinfo->sp++) = (UINT8) sinfo->firstcode; - code = sinfo->oldcode; - } - - /* If it's a symbol, expand it into the stack */ - while (code >= sinfo->clear_code) { - *(sinfo->sp++) = sinfo->symbol_tail[code]; /* tail is a byte value */ - code = sinfo->symbol_head[code]; /* head is another LZW symbol */ - } - /* At this point code just represents a raw byte */ - sinfo->firstcode = code; /* save for possible future use */ - - /* If there's room in table... */ - if ((code = sinfo->max_code) < LZW_TABLE_SIZE) { - /* Define a new symbol = prev sym + head of this sym's expansion */ - sinfo->symbol_head[code] = (UINT16) sinfo->oldcode; - sinfo->symbol_tail[code] = (UINT8) sinfo->firstcode; - sinfo->max_code++; - /* Is it time to increase code_size? */ - if (sinfo->max_code >= sinfo->limit_code && - sinfo->code_size < MAX_LZW_BITS) { - sinfo->code_size++; - sinfo->limit_code <<= 1; /* keep equal to 2^code_size */ - } - } - - sinfo->oldcode = incode; /* save last input symbol for future use */ - return sinfo->firstcode; /* return first byte of symbol's expansion */ -} - - -LOCAL(void) -ReadColorMap (gif_source_ptr sinfo, int cmaplen, JSAMPARRAY cmap) -/* Read a GIF colormap */ -{ - int i; - - for (i = 0; i < cmaplen; i++) { -#if BITS_IN_JSAMPLE == 8 -#define UPSCALE(x) (x) -#else -#define UPSCALE(x) ((x) << (BITS_IN_JSAMPLE-8)) -#endif - cmap[CM_RED ][i] = (JSAMPLE) UPSCALE(ReadByte(sinfo)); - cmap[CM_GREEN][i] = (JSAMPLE) UPSCALE(ReadByte(sinfo)); - cmap[CM_BLUE ][i] = (JSAMPLE) UPSCALE(ReadByte(sinfo)); - } -} - - -LOCAL(void) -DoExtension (gif_source_ptr sinfo) -/* Process an extension block */ -/* Currently we ignore 'em all */ -{ - int extlabel; - - /* Read extension label byte */ - extlabel = ReadByte(sinfo); - TRACEMS1(sinfo->cinfo, 1, JTRC_GIF_EXTENSION, extlabel); - /* Skip the data block(s) associated with the extension */ - SkipDataBlocks(sinfo); -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_gif (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - gif_source_ptr source = (gif_source_ptr) sinfo; - U_CHAR hdrbuf[10]; /* workspace for reading control blocks */ - unsigned int width, height; /* image dimensions */ - int colormaplen, aspectRatio; - int c; - - /* Read and verify GIF Header */ - if (! ReadOK(source->pub.input_file, hdrbuf, 6)) - ERREXIT(cinfo, JERR_GIF_NOT); - if (hdrbuf[0] != 'G' || hdrbuf[1] != 'I' || hdrbuf[2] != 'F') - ERREXIT(cinfo, JERR_GIF_NOT); - /* Check for expected version numbers. - * If unknown version, give warning and try to process anyway; - * this is per recommendation in GIF89a standard. - */ - if ((hdrbuf[3] != '8' || hdrbuf[4] != '7' || hdrbuf[5] != 'a') && - (hdrbuf[3] != '8' || hdrbuf[4] != '9' || hdrbuf[5] != 'a')) - TRACEMS3(cinfo, 1, JTRC_GIF_BADVERSION, hdrbuf[3], hdrbuf[4], hdrbuf[5]); - - /* Read and decipher Logical Screen Descriptor */ - if (! ReadOK(source->pub.input_file, hdrbuf, 7)) - ERREXIT(cinfo, JERR_INPUT_EOF); - width = LM_to_uint(hdrbuf, 0); - height = LM_to_uint(hdrbuf, 2); - /* we ignore the color resolution, sort flag, and background color index */ - aspectRatio = UCH(hdrbuf[6]); - if (aspectRatio != 0 && aspectRatio != 49) - TRACEMS(cinfo, 1, JTRC_GIF_NONSQUARE); - - /* Allocate space to store the colormap */ - source->colormap = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, - JPOOL_IMAGE, (JDIMENSION) MAXCOLORMAPSIZE, (JDIMENSION) NUMCOLORS); - colormaplen = 0; /* indicate initialization */ - - /* Read global colormap if header indicates it is present */ - if (BitSet(hdrbuf[4], COLORMAPFLAG)) { - colormaplen = 2 << (hdrbuf[4] & 0x07); - ReadColorMap(source, colormaplen, source->colormap); - } - - /* Scan until we reach start of desired image. - * We don't currently support skipping images, but could add it easily. - */ - for (;;) { - c = ReadByte(source); - - if (c == ';') /* GIF terminator?? */ - ERREXIT(cinfo, JERR_GIF_IMAGENOTFOUND); - - if (c == '!') { /* Extension */ - DoExtension(source); - continue; - } - - if (c != ',') { /* Not an image separator? */ - WARNMS1(cinfo, JWRN_GIF_CHAR, c); - continue; - } - - /* Read and decipher Local Image Descriptor */ - if (! ReadOK(source->pub.input_file, hdrbuf, 9)) - ERREXIT(cinfo, JERR_INPUT_EOF); - /* we ignore top/left position info, also sort flag */ - width = LM_to_uint(hdrbuf, 4); - height = LM_to_uint(hdrbuf, 6); - if (width <= 0 || height <= 0) - ERREXIT(cinfo, JERR_GIF_OUTOFRANGE); - source->is_interlaced = (BitSet(hdrbuf[8], INTERLACE) != 0); - - /* Read local colormap if header indicates it is present */ - /* Note: if we wanted to support skipping images, */ - /* we'd need to skip rather than read colormap for ignored images */ - if (BitSet(hdrbuf[8], COLORMAPFLAG)) { - colormaplen = 2 << (hdrbuf[8] & 0x07); - ReadColorMap(source, colormaplen, source->colormap); - } - - source->input_code_size = ReadByte(source); /* get min-code-size byte */ - if (source->input_code_size < 2 || source->input_code_size > 8) - ERREXIT1(cinfo, JERR_GIF_CODESIZE, source->input_code_size); - - /* Reached desired image, so break out of loop */ - /* If we wanted to skip this image, */ - /* we'd call SkipDataBlocks and then continue the loop */ - break; - } - - /* Prepare to read selected image: first initialize LZW decompressor */ - source->symbol_head = (UINT16 FAR *) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, LZW_TABLE_SIZE * SIZEOF(UINT16)); - source->symbol_tail = (UINT8 FAR *) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, LZW_TABLE_SIZE * SIZEOF(UINT8)); - source->symbol_stack = (UINT8 FAR *) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, LZW_TABLE_SIZE * SIZEOF(UINT8)); - InitLZWCode(source); - - /* - * If image is interlaced, we read it into a full-size sample array, - * decompressing as we go; then get_interlaced_row selects rows from the - * sample array in the proper order. - */ - if (source->is_interlaced) { - /* We request the virtual array now, but can't access it until virtual - * arrays have been allocated. Hence, the actual work of reading the - * image is postponed until the first call to get_pixel_rows. - */ - source->interlaced_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) width, (JDIMENSION) height, (JDIMENSION) 1); - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - source->pub.get_pixel_rows = load_interlaced_image; - } else { - source->pub.get_pixel_rows = get_pixel_rows; - } - - /* Create compressor input buffer. */ - source->pub.buffer = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, - JPOOL_IMAGE, (JDIMENSION) width * NUMCOLORS, (JDIMENSION) 1); - source->pub.buffer_height = 1; - - /* Pad colormap for safety. */ - for (c = colormaplen; c < source->clear_code; c++) { - source->colormap[CM_RED ][c] = - source->colormap[CM_GREEN][c] = - source->colormap[CM_BLUE ][c] = CENTERJSAMPLE; - } - - /* Return info about the image. */ - cinfo->in_color_space = JCS_RGB; - cinfo->input_components = NUMCOLORS; - cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ - cinfo->image_width = width; - cinfo->image_height = height; - - TRACEMS3(cinfo, 1, JTRC_GIF, width, height, colormaplen); -} - - -/* - * Read one row of pixels. - * This version is used for noninterlaced GIF images: - * we read directly from the GIF file. - */ - -METHODDEF(JDIMENSION) -get_pixel_rows (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - gif_source_ptr source = (gif_source_ptr) sinfo; - register int c; - register JSAMPROW ptr; - register JDIMENSION col; - register JSAMPARRAY colormap = source->colormap; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - c = LZWReadByte(source); - *ptr++ = colormap[CM_RED ][c]; - *ptr++ = colormap[CM_GREEN][c]; - *ptr++ = colormap[CM_BLUE ][c]; - } - return 1; -} - - -/* - * Read one row of pixels. - * This version is used for the first call on get_pixel_rows when - * reading an interlaced GIF file: we read the whole image into memory. - */ - -METHODDEF(JDIMENSION) -load_interlaced_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - gif_source_ptr source = (gif_source_ptr) sinfo; - register JSAMPROW sptr; - register JDIMENSION col; - JDIMENSION row; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Read the interlaced image into the virtual array we've created. */ - for (row = 0; row < cinfo->image_height; row++) { - if (progress != NULL) { - progress->pub.pass_counter = (long) row; - progress->pub.pass_limit = (long) cinfo->image_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - sptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, - source->interlaced_image, row, (JDIMENSION) 1, TRUE); - for (col = cinfo->image_width; col > 0; col--) { - *sptr++ = (JSAMPLE) LZWReadByte(source); - } - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Replace method pointer so subsequent calls don't come here. */ - source->pub.get_pixel_rows = get_interlaced_row; - /* Initialize for get_interlaced_row, and perform first call on it. */ - source->cur_row_number = 0; - source->pass2_offset = (cinfo->image_height + 7) / 8; - source->pass3_offset = source->pass2_offset + (cinfo->image_height + 3) / 8; - source->pass4_offset = source->pass3_offset + (cinfo->image_height + 1) / 4; - - return get_interlaced_row(cinfo, sinfo); -} - - -/* - * Read one row of pixels. - * This version is used for interlaced GIF images: - * we read from the virtual array. - */ - -METHODDEF(JDIMENSION) -get_interlaced_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - gif_source_ptr source = (gif_source_ptr) sinfo; - register int c; - register JSAMPROW sptr, ptr; - register JDIMENSION col; - register JSAMPARRAY colormap = source->colormap; - JDIMENSION irow; - - /* Figure out which row of interlaced image is needed, and access it. */ - switch ((int) (source->cur_row_number & 7)) { - case 0: /* first-pass row */ - irow = source->cur_row_number >> 3; - break; - case 4: /* second-pass row */ - irow = (source->cur_row_number >> 3) + source->pass2_offset; - break; - case 2: /* third-pass row */ - case 6: - irow = (source->cur_row_number >> 2) + source->pass3_offset; - break; - default: /* fourth-pass row */ - irow = (source->cur_row_number >> 1) + source->pass4_offset; - } - sptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, - source->interlaced_image, irow, (JDIMENSION) 1, FALSE); - /* Scan the row, expand colormap, and output */ - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - c = GETJSAMPLE(*sptr++); - *ptr++ = colormap[CM_RED ][c]; - *ptr++ = colormap[CM_GREEN][c]; - *ptr++ = colormap[CM_BLUE ][c]; - } - source->cur_row_number++; /* for next time */ - return 1; -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_gif (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for GIF format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_gif (j_compress_ptr cinfo) -{ - gif_source_ptr source; - - /* Create module interface object */ - source = (gif_source_ptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(gif_source_struct)); - source->cinfo = cinfo; /* make back link for subroutines */ - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_gif; - source->pub.finish_input = finish_input_gif; - - return &source->pub; -} - -#endif /* GIF_SUPPORTED */ diff --git a/code/jpeg-9f/rdjpgcom.c b/code/jpeg-9f/rdjpgcom.c deleted file mode 100644 index 37191547..00000000 --- a/code/jpeg-9f/rdjpgcom.c +++ /dev/null @@ -1,515 +0,0 @@ -/* - * rdjpgcom.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * Modified 2009 by Bill Allombert, Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a very simple stand-alone application that displays - * the text in COM (comment) markers in a JFIF file. - * This may be useful as an example of the minimum logic needed to parse - * JPEG markers. - */ - -#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ -#include "jinclude.h" /* get auto-config symbols, */ - -#ifdef HAVE_LOCALE_H -#include /* Bill Allombert: use locale for isprint */ -#endif -#include /* to declare isupper(), tolower() */ -#ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ -#endif - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#endif -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#ifdef VMS -#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ -#else -#define EXIT_SUCCESS 0 -#endif -#endif - - -/* - * These macros are used to read the input file. - * To reuse this code in another application, you might need to change these. - */ - -static FILE * infile; /* input JPEG file */ - -/* Return next input byte, or EOF if no more */ -#define NEXTBYTE() getc(infile) - - -/* Error exit handler */ -#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) - - -/* Read one byte, testing for EOF */ -static int -read_1_byte (void) -{ - int c; - - c = NEXTBYTE(); - if (c == EOF) - ERREXIT("Premature EOF in JPEG file"); - return c; -} - -/* Read 2 bytes, convert to unsigned int */ -/* All 2-byte quantities in JPEG markers are MSB first */ -static unsigned int -read_2_bytes (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - if (c1 == EOF) - ERREXIT("Premature EOF in JPEG file"); - c2 = NEXTBYTE(); - if (c2 == EOF) - ERREXIT("Premature EOF in JPEG file"); - return (((unsigned int) c1) << 8) + ((unsigned int) c2); -} - - -/* - * JPEG markers consist of one or more 0xFF bytes, followed by a marker - * code byte (which is not an FF). Here are the marker codes of interest - * in this program. (See jdmarker.c for a more complete list.) - */ - -#define M_SOF0 0xC0 /* Start Of Frame N */ -#define M_SOF1 0xC1 /* N indicates which compression process */ -#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ -#define M_SOF3 0xC3 -#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ -#define M_SOF6 0xC6 -#define M_SOF7 0xC7 -#define M_SOF9 0xC9 -#define M_SOF10 0xCA -#define M_SOF11 0xCB -#define M_SOF13 0xCD -#define M_SOF14 0xCE -#define M_SOF15 0xCF -#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ -#define M_EOI 0xD9 /* End Of Image (end of datastream) */ -#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ -#define M_APP0 0xE0 /* Application-specific marker, type N */ -#define M_APP12 0xEC /* (we don't bother to list all 16 APPn's) */ -#define M_COM 0xFE /* COMment */ - - -/* - * Find the next JPEG marker and return its marker code. - * We expect at least one FF byte, possibly more if the compressor used FFs - * to pad the file. - * There could also be non-FF garbage between markers. The treatment of such - * garbage is unspecified; we choose to skip over it but emit a warning msg. - * NB: this routine must not be used after seeing SOS marker, since it will - * not deal correctly with FF/00 sequences in the compressed image data... - */ - -static int -next_marker (void) -{ - int c; - int discarded_bytes = 0; - - /* Find 0xFF byte; count and skip any non-FFs. */ - c = read_1_byte(); - while (c != 0xFF) { - discarded_bytes++; - c = read_1_byte(); - } - /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs - * are legal as pad bytes, so don't count them in discarded_bytes. - */ - do { - c = read_1_byte(); - } while (c == 0xFF); - - if (discarded_bytes != 0) { - fprintf(stderr, "Warning: garbage data found in JPEG file\n"); - } - - return c; -} - - -/* - * Read the initial marker, which should be SOI. - * For a JFIF file, the first two bytes of the file should be literally - * 0xFF M_SOI. To be more general, we could use next_marker, but if the - * input file weren't actually JPEG at all, next_marker might read the whole - * file and then return a misleading error message... - */ - -static int -first_marker (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - c2 = NEXTBYTE(); - if (c1 != 0xFF || c2 != M_SOI) - ERREXIT("Not a JPEG file"); - return c2; -} - - -/* - * Most types of marker are followed by a variable-length parameter segment. - * This routine skips over the parameters for any marker we don't otherwise - * want to process. - * Note that we MUST skip the parameter segment explicitly in order not to - * be fooled by 0xFF bytes that might appear within the parameter segment; - * such bytes do NOT introduce new markers. - */ - -static void -skip_variable (void) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - unsigned int length; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - /* Skip over the remaining bytes */ - while (length > 0) { - (void) read_1_byte(); - length--; - } -} - - -/* - * Process a COM marker. - * We want to print out the marker contents as legible text; - * we must guard against non-text junk and varying newline representations. - */ - -static void -process_COM (int raw) -{ - unsigned int length; - int ch; - int lastch = 0; - - /* Bill Allombert: set locale properly for isprint */ -#ifdef HAVE_LOCALE_H - setlocale(LC_CTYPE, ""); -#endif - - /* Get the marker parameter length count */ - length = read_2_bytes(); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - - while (length > 0) { - ch = read_1_byte(); - if (raw) { - putc(ch, stdout); - /* Emit the character in a readable form. - * Nonprintables are converted to \nnn form, - * while \ is converted to \\. - * Newlines in CR, CR/LF, or LF form will be printed as one newline. - */ - } else if (ch == '\r') { - printf("\n"); - } else if (ch == '\n') { - if (lastch != '\r') - printf("\n"); - } else if (ch == '\\') { - printf("\\\\"); - } else if (isprint(ch)) { - putc(ch, stdout); - } else { - printf("\\%03o", ch); - } - lastch = ch; - length--; - } - printf("\n"); - - /* Bill Allombert: revert to C locale */ -#ifdef HAVE_LOCALE_H - setlocale(LC_CTYPE, "C"); -#endif -} - - -/* - * Process a SOFn marker. - * This code is only needed if you want to know the image dimensions... - */ - -static void -process_SOFn (int marker) -{ - unsigned int length; - unsigned int image_height, image_width; - int data_precision, num_components; - const char * process; - int ci; - - length = read_2_bytes(); /* usual parameter length count */ - - data_precision = read_1_byte(); - image_height = read_2_bytes(); - image_width = read_2_bytes(); - num_components = read_1_byte(); - - switch (marker) { - case M_SOF0: process = "Baseline"; break; - case M_SOF1: process = "Extended sequential"; break; - case M_SOF2: process = "Progressive"; break; - case M_SOF3: process = "Lossless"; break; - case M_SOF5: process = "Differential sequential"; break; - case M_SOF6: process = "Differential progressive"; break; - case M_SOF7: process = "Differential lossless"; break; - case M_SOF9: process = "Extended sequential, arithmetic coding"; break; - case M_SOF10: process = "Progressive, arithmetic coding"; break; - case M_SOF11: process = "Lossless, arithmetic coding"; break; - case M_SOF13: process = "Differential sequential, arithmetic coding"; break; - case M_SOF14: process = "Differential progressive, arithmetic coding"; break; - case M_SOF15: process = "Differential lossless, arithmetic coding"; break; - default: process = "Unknown"; break; - } - - printf("JPEG image is %uw * %uh, %d color components, %d bits per sample\n", - image_width, image_height, num_components, data_precision); - printf("JPEG process: %s\n", process); - - if (length != (unsigned int) (8 + num_components * 3)) - ERREXIT("Bogus SOF marker length"); - - for (ci = 0; ci < num_components; ci++) { - (void) read_1_byte(); /* Component ID code */ - (void) read_1_byte(); /* H, V sampling factors */ - (void) read_1_byte(); /* Quantization table number */ - } -} - - -/* - * Parse the marker stream until SOS or EOI is seen; - * display any COM markers. - * While the companion program wrjpgcom will always insert COM markers before - * SOFn, other implementations might not, so we scan to SOS before stopping. - * If we were only interested in the image dimensions, we would stop at SOFn. - * (Conversely, if we only cared about COM markers, there would be no need - * for special code to handle SOFn; we could treat it like other markers.) - */ - -static int -scan_JPEG_header (int verbose, int raw) -{ - int marker; - - /* Expect SOI at start of file */ - if (first_marker() != M_SOI) - ERREXIT("Expected SOI marker first"); - - /* Scan miscellaneous markers until we reach SOS. */ - for (;;) { - marker = next_marker(); - switch (marker) { - /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, - * treated as SOFn. C4 in particular is actually DHT. - */ - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - case M_SOF2: /* Progressive, Huffman */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_SOF9: /* Extended sequential, arithmetic */ - case M_SOF10: /* Progressive, arithmetic */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - if (verbose) - process_SOFn(marker); - else - skip_variable(); - break; - - case M_SOS: /* stop before hitting compressed data */ - return marker; - - case M_EOI: /* in case it's a tables-only JPEG stream */ - return marker; - - case M_COM: - process_COM(raw); - break; - - case M_APP12: - /* Some digital camera makers put useful textual information into - * APP12 markers, so we print those out too when in -verbose mode. - */ - if (verbose) { - printf("APP12 contains:\n"); - process_COM(raw); - } else - skip_variable(); - break; - - default: /* Anything else just gets skipped */ - skip_variable(); /* we assume it has a parameter count... */ - break; - } - } /* end loop */ -} - - -/* Command line parsing code */ - -static const char * progname; /* program name for error messages */ - - -static void -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "rdjpgcom displays any textual comments in a JPEG file.\n"); - - fprintf(stderr, "Usage: %s [switches] [inputfile]\n", progname); - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -raw Display non-printable characters in comments (unsafe)\n"); - fprintf(stderr, " -verbose Also display dimensions of JPEG image\n"); - - exit(EXIT_FAILURE); -} - - -static int -keymatch (char * arg, const char * keyword, int minchars) -/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ -/* keyword is the constant keyword (must be lower case already), */ -/* minchars is length of minimum legal abbreviation. */ -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return 0; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return 0; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return 0; - return 1; /* A-OK */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - int argn; - char * arg; - int verbose = 0, raw = 0; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "rdjpgcom"; /* in case C library doesn't provide it */ - - /* Parse switches, if any */ - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (arg[0] != '-') - break; /* not switch, must be file name */ - arg++; /* advance over '-' */ - if (keymatch(arg, "verbose", 1)) { - verbose++; - } else if (keymatch(arg, "raw", 1)) { - raw = 1; - } else - usage(); - } - - /* Open the input file. */ - /* Unix style: expect zero or one file name */ - if (argn < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } - if (argn < argc) { - if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open stdin\n", progname); - exit(EXIT_FAILURE); - } -#else - infile = stdin; -#endif - } - - /* Scan the JPEG headers. */ - (void) scan_JPEG_header(verbose, raw); - - /* All done. */ - exit(EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/code/jpeg-9f/rdppm.c b/code/jpeg-9f/rdppm.c deleted file mode 100644 index ca638678..00000000 --- a/code/jpeg-9f/rdppm.c +++ /dev/null @@ -1,501 +0,0 @@ -/* - * rdppm.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * Modified 2009-2020 by Bill Allombert, Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in PPM/PGM format. - * The extended 2-byte-per-sample raw PPM/PGM formats are supported. - * The PBMPLUS library is NOT required to compile this software - * (but it is highly useful as a set of PPM image manipulation programs). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed PPM format). - */ - -/* Portions of this code are based on the PBMPLUS library, which is: -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose and without fee is hereby granted, provided -** that the above copyright notice appear in all copies and that both that -** copyright notice and this permission notice appear in supporting -** documentation. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef PPM_SUPPORTED - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -typedef char U_CHAR; -#ifdef CHAR_IS_UNSIGNED -#define UCH(x) ((int) (x)) -#else -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -/* - * On most systems, reading individual bytes with getc() is drastically less - * efficient than buffering a row at a time with fread(). On PCs, we must - * allocate the buffer in near data space, because we are assuming small-data - * memory model, wherein fread() can't reach far memory. If you need to - * process very wide images on a PC, you might have to compile in large-memory - * model, or else replace fread() with a getc() loop --- which will be much - * slower. - */ - - -/* Private version of data source object */ - -typedef struct { - struct cjpeg_source_struct pub; /* public fields */ - - /* Usually these two pointers point to the same place: */ - U_CHAR *iobuffer; /* fread's I/O buffer */ - JSAMPROW pixrow; /* compressor input buffer */ - size_t buffer_width; /* width of I/O buffer */ - JSAMPLE *rescale; /* => maxval-remapping array, or NULL */ - unsigned int maxval; -} ppm_source_struct; - -typedef ppm_source_struct * ppm_source_ptr; - - -LOCAL(int) -pbm_getc (FILE * infile) -/* Read next char, skipping over any comments */ -/* A comment/newline sequence is returned as a newline */ -{ - register int ch; - - ch = getc(infile); - if (ch == '#') { - do { - ch = getc(infile); - } while (ch != '\n' && ch != EOF); - } - return ch; -} - - -LOCAL(unsigned int) -read_pbm_integer (j_compress_ptr cinfo, FILE * infile) -/* Read an unsigned decimal integer from the PPM file */ -/* Swallows one trailing character after the integer */ -/* Note that on a 16-bit-int machine, only values up to 64k can be read. */ -/* This should not be a problem in practice. */ -{ - register int ch; - register unsigned int val; - - /* Skip any leading whitespace */ - do { - ch = pbm_getc(infile); - if (ch == EOF) - ERREXIT(cinfo, JERR_INPUT_EOF); - } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); - - if (ch < '0' || ch > '9') - ERREXIT(cinfo, JERR_PPM_NONNUMERIC); - - val = ch - '0'; - while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { - val *= 10; - val += ch - '0'; - } - return val; -} - - -/* - * Read one row of pixels. - * - * We provide several different versions depending on input file format. - * In all cases, input is scaled to the size of JSAMPLE. - * - * A really fast path is provided for reading byte/sample raw files with - * maxval = MAXJSAMPLE, which is the normal case for 8-bit data. - */ - - -METHODDEF(JDIMENSION) -get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading text-format PGM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - FILE * infile = source->pub.input_file; - register JSAMPROW ptr; - register JSAMPLE *rescale = source->rescale; - unsigned int maxval = source->maxval; - JDIMENSION col; - - ptr = source->pixrow; - for (col = cinfo->image_width; col > 0; col--) { - register unsigned int temp; - temp = read_pbm_integer(cinfo, infile); - if (temp > maxval) - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - *ptr++ = rescale[temp]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_text_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading text-format PPM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - FILE * infile = source->pub.input_file; - register JSAMPROW ptr; - register JSAMPLE *rescale = source->rescale; - unsigned int maxval = source->maxval; - JDIMENSION col; - - ptr = source->pixrow; - for (col = cinfo->image_width; col > 0; col--) { - register unsigned int temp; - temp = read_pbm_integer(cinfo, infile); - if (temp > maxval) - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - *ptr++ = rescale[temp]; - temp = read_pbm_integer(cinfo, infile); - if (temp > maxval) - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - *ptr++ = rescale[temp]; - temp = read_pbm_integer(cinfo, infile); - if (temp > maxval) - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - *ptr++ = rescale[temp]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_scaled_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-byte-format PGM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - unsigned int maxval = source->maxval; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pixrow; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - register unsigned int temp; - temp = (unsigned int) UCH(*bufferptr++); - if (temp > maxval) - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - *ptr++ = rescale[temp]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_scaled_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-byte-format PPM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - unsigned int maxval = source->maxval; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pixrow; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - register unsigned int temp; - temp = (unsigned int) UCH(*bufferptr++); - if (temp > maxval) - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - *ptr++ = rescale[temp]; - temp = (unsigned int) UCH(*bufferptr++); - if (temp > maxval) - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - *ptr++ = rescale[temp]; - temp = (unsigned int) UCH(*bufferptr++); - if (temp > maxval) - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - *ptr++ = rescale[temp]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_raw_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-byte-format files with maxval = MAXJSAMPLE. - * In this case we just read right into the JSAMPLE buffer! - * Note that same code works for PPM and PGM files. - */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - return 1; -} - - -METHODDEF(JDIMENSION) -get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-word-format PGM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - unsigned int maxval = source->maxval; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pixrow; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - register unsigned int temp; - temp = ((unsigned int) UCH(*bufferptr++)) << 8; - temp |= (unsigned int) UCH(*bufferptr++); - if (temp > maxval) - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - *ptr++ = rescale[temp]; - } - return 1; -} - - -METHODDEF(JDIMENSION) -get_word_rgb_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading raw-word-format PPM files with any maxval */ -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - register JSAMPROW ptr; - register U_CHAR * bufferptr; - register JSAMPLE *rescale = source->rescale; - unsigned int maxval = source->maxval; - JDIMENSION col; - - if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) - ERREXIT(cinfo, JERR_INPUT_EOF); - ptr = source->pixrow; - bufferptr = source->iobuffer; - for (col = cinfo->image_width; col > 0; col--) { - register unsigned int temp; - temp = ((unsigned int) UCH(*bufferptr++)) << 8; - temp |= (unsigned int) UCH(*bufferptr++); - if (temp > maxval) - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - *ptr++ = rescale[temp]; - temp = ((unsigned int) UCH(*bufferptr++)) << 8; - temp |= (unsigned int) UCH(*bufferptr++); - if (temp > maxval) - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - *ptr++ = rescale[temp]; - temp = ((unsigned int) UCH(*bufferptr++)) << 8; - temp |= (unsigned int) UCH(*bufferptr++); - if (temp > maxval) - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - *ptr++ = rescale[temp]; - } - return 1; -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - ppm_source_ptr source = (ppm_source_ptr) sinfo; - int c; - unsigned int w, h, maxval; - boolean need_iobuffer, use_raw_buffer, need_rescale; - - if (getc(source->pub.input_file) != 'P') - ERREXIT(cinfo, JERR_PPM_NOT); - - c = getc(source->pub.input_file); /* subformat discriminator character */ - - /* detect unsupported variants (ie, PBM) before trying to read header */ - switch (c) { - case '2': /* it's a text-format PGM file */ - case '3': /* it's a text-format PPM file */ - case '5': /* it's a raw-format PGM file */ - case '6': /* it's a raw-format PPM file */ - break; - default: - ERREXIT(cinfo, JERR_PPM_NOT); - } - - /* fetch the remaining header info */ - w = read_pbm_integer(cinfo, source->pub.input_file); - h = read_pbm_integer(cinfo, source->pub.input_file); - maxval = read_pbm_integer(cinfo, source->pub.input_file); - - if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ - ERREXIT(cinfo, JERR_PPM_NOT); - - if (((long) w >> 24) || /* sanity check for buffer allocation below */ - ((long) maxval >> 16)) /* support max 16-bit (2-byte) sample values */ - ERREXIT(cinfo, JERR_PPM_OUTOFRANGE); - - cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ - cinfo->image_width = (JDIMENSION) w; - cinfo->image_height = (JDIMENSION) h; - source->maxval = maxval; - - /* initialize flags to most common settings */ - need_iobuffer = TRUE; /* do we need an I/O buffer? */ - use_raw_buffer = FALSE; /* do we map input buffer onto I/O buffer? */ - need_rescale = TRUE; /* do we need a rescale array? */ - - switch (c) { - case '2': /* it's a text-format PGM file */ - cinfo->input_components = 1; - cinfo->in_color_space = JCS_GRAYSCALE; - TRACEMS2(cinfo, 1, JTRC_PGM_TEXT, w, h); - source->pub.get_pixel_rows = get_text_gray_row; - need_iobuffer = FALSE; - break; - - case '3': /* it's a text-format PPM file */ - cinfo->input_components = 3; - cinfo->in_color_space = JCS_RGB; - TRACEMS2(cinfo, 1, JTRC_PPM_TEXT, w, h); - source->pub.get_pixel_rows = get_text_rgb_row; - need_iobuffer = FALSE; - break; - - case '5': /* it's a raw-format PGM file */ - cinfo->input_components = 1; - cinfo->in_color_space = JCS_GRAYSCALE; - TRACEMS2(cinfo, 1, JTRC_PGM, w, h); - if (maxval > 255) { - source->pub.get_pixel_rows = get_word_gray_row; - } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { - source->pub.get_pixel_rows = get_raw_row; - use_raw_buffer = TRUE; - need_rescale = FALSE; - } else { - source->pub.get_pixel_rows = get_scaled_gray_row; - } - break; - - case '6': /* it's a raw-format PPM file */ - cinfo->input_components = 3; - cinfo->in_color_space = JCS_RGB; - TRACEMS2(cinfo, 1, JTRC_PPM, w, h); - if (maxval > 255) { - source->pub.get_pixel_rows = get_word_rgb_row; - } else if (maxval == MAXJSAMPLE && SIZEOF(JSAMPLE) == SIZEOF(U_CHAR)) { - source->pub.get_pixel_rows = get_raw_row; - use_raw_buffer = TRUE; - need_rescale = FALSE; - } else { - source->pub.get_pixel_rows = get_scaled_rgb_row; - } - break; - } - - /* Allocate space for I/O buffer: 1 or 3 bytes or words/pixel. */ - if (need_iobuffer) { - source->buffer_width = (size_t) w * (size_t) cinfo->input_components * - ((maxval <= 255) ? SIZEOF(U_CHAR) : (2 * SIZEOF(U_CHAR))); - source->iobuffer = (U_CHAR *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, source->buffer_width); - } - - /* Create compressor input buffer. */ - if (use_raw_buffer) { - /* For unscaled raw-input case, we can just map it onto the I/O buffer. */ - /* Cast here implies near->far pointer conversion on PCs */ - source->pixrow = (JSAMPROW) source->iobuffer; - } else { - /* Need to translate anyway, so make a separate sample buffer. */ - source->pixrow = (JSAMPROW) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, (size_t) w * - (size_t) cinfo->input_components * SIZEOF(JSAMPLE)); - } - /* Synthesize a JSAMPARRAY pointer structure */ - source->pub.buffer = & source->pixrow; - source->pub.buffer_height = 1; - - /* Compute the rescaling array if required. */ - if (need_rescale) { - INT32 val, half_maxval; - - /* On 16-bit-int machines we have to be careful of maxval = 65535 */ - source->rescale = (JSAMPLE *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, - JPOOL_IMAGE, ((size_t) maxval + (size_t) 1) * SIZEOF(JSAMPLE)); - half_maxval = maxval / 2; - for (val = 0; val <= (INT32) maxval; val++) { - /* The multiplication here must be done in 32 bits to avoid overflow */ - source->rescale[val] = (JSAMPLE) ((val * MAXJSAMPLE + half_maxval) / maxval); - } - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_ppm (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for PPM format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_ppm (j_compress_ptr cinfo) -{ - ppm_source_ptr source; - - /* Create module interface object */ - source = (ppm_source_ptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(ppm_source_struct)); - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_ppm; - source->pub.finish_input = finish_input_ppm; - - return &source->pub; -} - -#endif /* PPM_SUPPORTED */ diff --git a/code/jpeg-9f/rdrle.c b/code/jpeg-9f/rdrle.c deleted file mode 100644 index 06f2e8aa..00000000 --- a/code/jpeg-9f/rdrle.c +++ /dev/null @@ -1,380 +0,0 @@ -/* - * rdrle.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * Modified 2019 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in Utah RLE format. - * The Utah Raster Toolkit library is required (version 3.1 or later). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed RLE format). - * - * Based on code contributed by Mike Lijewski, - * with updates from Robert Hutchinson. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef RLE_SUPPORTED - -/* rle.h is provided by the Utah Raster Toolkit. */ - -#include - -/* - * We assume that JSAMPLE has the same representation as rle_pixel, - * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - -/* - * We support the following types of RLE files: - * - * GRAYSCALE - 8 bits, no colormap - * MAPPEDGRAY - 8 bits, 1 channel colomap - * PSEUDOCOLOR - 8 bits, 3 channel colormap - * TRUECOLOR - 24 bits, 3 channel colormap - * DIRECTCOLOR - 24 bits, no colormap - * - * For now, we ignore any alpha channel in the image. - */ - -typedef enum - { GRAYSCALE, MAPPEDGRAY, PSEUDOCOLOR, TRUECOLOR, DIRECTCOLOR } rle_kind; - - -/* - * Since RLE stores scanlines bottom-to-top, we have to invert the image - * to conform to JPEG's top-to-bottom order. To do this, we read the - * incoming image into a virtual array on the first get_pixel_rows call, - * then fetch the required row from the virtual array on subsequent calls. - */ - -typedef struct _rle_source_struct * rle_source_ptr; - -typedef struct _rle_source_struct { - struct cjpeg_source_struct pub; /* public fields */ - - rle_kind visual; /* actual type of input file */ - jvirt_sarray_ptr image; /* virtual array to hold the image */ - JDIMENSION row; /* current row # in the virtual array */ - rle_hdr header; /* Input file information */ - rle_pixel **rle_row; /* holds a row returned by rle_getrow() */ - -} rle_source_struct; - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - JDIMENSION width, height; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* Use RLE library routine to get the header info */ - source->header = *rle_hdr_init(NULL); - source->header.rle_file = source->pub.input_file; - switch (rle_get_setup(&(source->header))) { - case RLE_SUCCESS: - /* A-OK */ - break; - case RLE_NOT_RLE: - ERREXIT(cinfo, JERR_RLE_NOT); - case RLE_NO_SPACE: - ERREXIT(cinfo, JERR_RLE_MEM); - case RLE_EMPTY: - ERREXIT(cinfo, JERR_RLE_EMPTY); - case RLE_EOF: - ERREXIT(cinfo, JERR_RLE_EOF); - default: - ERREXIT(cinfo, JERR_RLE_BADERROR); - } - - /* Figure out what we have, set private vars and return values accordingly */ - - width = source->header.xmax - source->header.xmin + 1; - height = source->header.ymax - source->header.ymin + 1; - source->header.xmin = 0; /* realign horizontally */ - source->header.xmax = width-1; - - cinfo->image_width = width; - cinfo->image_height = height; - cinfo->data_precision = 8; /* we can only handle 8 bit data */ - - if (source->header.ncolors == 1 && source->header.ncmap == 0) { - source->visual = GRAYSCALE; - TRACEMS2(cinfo, 1, JTRC_RLE_GRAY, width, height); - } else if (source->header.ncolors == 1 && source->header.ncmap == 1) { - source->visual = MAPPEDGRAY; - TRACEMS3(cinfo, 1, JTRC_RLE_MAPGRAY, width, height, - 1 << source->header.cmaplen); - } else if (source->header.ncolors == 1 && source->header.ncmap == 3) { - source->visual = PSEUDOCOLOR; - TRACEMS3(cinfo, 1, JTRC_RLE_MAPPED, width, height, - 1 << source->header.cmaplen); - } else if (source->header.ncolors == 3 && source->header.ncmap == 3) { - source->visual = TRUECOLOR; - TRACEMS3(cinfo, 1, JTRC_RLE_FULLMAP, width, height, - 1 << source->header.cmaplen); - } else if (source->header.ncolors == 3 && source->header.ncmap == 0) { - source->visual = DIRECTCOLOR; - TRACEMS2(cinfo, 1, JTRC_RLE, width, height); - } else - ERREXIT(cinfo, JERR_RLE_UNSUPPORTED); - - if (source->visual == GRAYSCALE || source->visual == MAPPEDGRAY) { - cinfo->in_color_space = JCS_GRAYSCALE; - cinfo->input_components = 1; - } else { - cinfo->in_color_space = JCS_RGB; - cinfo->input_components = 3; - } - - /* - * A place to hold each scanline while it's converted. - * (GRAYSCALE scanlines don't need converting) - */ - if (source->visual != GRAYSCALE) { - source->rle_row = (rle_pixel **) (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - width, (JDIMENSION) cinfo->input_components); - } - - /* request a virtual array to hold the image */ - source->image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - width * (JDIMENSION) source->header.ncolors, height, (JDIMENSION) 1); - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - /* count file input as separate pass */ - progress->total_extra_passes++; - } -#endif - - source->pub.buffer_height = 1; -} - - -/* - * Read one row of pixels. - * Called only after load_image has read the image into the virtual array. - * Used for GRAYSCALE, MAPPEDGRAY, TRUECOLOR, and DIRECTCOLOR images. - */ - -METHODDEF(JDIMENSION) -get_rle_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - - source->row--; - source->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); - - return 1; -} - -/* - * Read one row of pixels. - * Called only after load_image has read the image into the virtual array. - * Used for PSEUDOCOLOR images. - */ - -METHODDEF(JDIMENSION) -get_pseudocolor_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - JSAMPROW src_row, dest_row; - JDIMENSION col; - rle_map *colormap; - int val; - - colormap = source->header.cmap; - dest_row = source->pub.buffer[0]; - source->row--; - src_row = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, source->row, (JDIMENSION) 1, FALSE); - - for (col = cinfo->image_width; col > 0; col--) { - val = GETJSAMPLE(*src_row++); - *dest_row++ = (JSAMPLE) (colormap[val ] >> 8); - *dest_row++ = (JSAMPLE) (colormap[val + 256] >> 8); - *dest_row++ = (JSAMPLE) (colormap[val + 512] >> 8); - } - - return 1; -} - - -/* - * Load the image into a virtual array. We have to do this because RLE - * files start at the lower left while the JPEG standard has them starting - * in the upper left. This is called the first time we want to get a row - * of input. What we do is load the RLE data into the array and then call - * the appropriate routine to read one row from the array. Before returning, - * we set source->pub.get_pixel_rows so that subsequent calls go straight to - * the appropriate row-reading routine. - */ - -METHODDEF(JDIMENSION) -load_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - rle_source_ptr source = (rle_source_ptr) sinfo; - JDIMENSION row, col; - JSAMPROW scanline, red_ptr, green_ptr, blue_ptr; - rle_pixel **rle_row; - rle_map *colormap; - char channel; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* Read the RLE data into our virtual array. - * We assume here that (a) rle_pixel is represented the same as JSAMPLE, - * and (b) we are not on a machine where FAR pointers differ from regular. - */ - RLE_CLR_BIT(source->header, RLE_ALPHA); /* don't read the alpha channel */ - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_limit = cinfo->image_height; - progress->pub.pass_counter = 0; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - - switch (source->visual) { - - case GRAYSCALE: - case PSEUDOCOLOR: - for (row = 0; row < cinfo->image_height; row++) { - rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); - rle_getrow(&source->header, rle_row); -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - break; - - case MAPPEDGRAY: - case TRUECOLOR: - rle_row = source->rle_row; - colormap = source->header.cmap; - for (row = 0; row < cinfo->image_height; row++) { - rle_getrow(&source->header, rle_row); - scanline = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); - - for (col = 0; col < cinfo->image_width; col++) { - for (channel = 0; channel < source->header.ncolors; channel++) { - *scanline++ = (JSAMPLE) - (colormap[GETJSAMPLE(rle_row[channel][col]) + 256 * channel] >> 8); - } - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - break; - - case DIRECTCOLOR: - rle_row = source->rle_row; - for (row = 0; row < cinfo->image_height; row++) { - rle_getrow(&source->header, rle_row); - scanline = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->image, row, (JDIMENSION) 1, TRUE); - - red_ptr = rle_row[0]; - green_ptr = rle_row[1]; - blue_ptr = rle_row[2]; - - for (col = cinfo->image_width; col > 0; col--) { - *scanline++ = *red_ptr++; - *scanline++ = *green_ptr++; - *scanline++ = *blue_ptr++; - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) - progress->completed_extra_passes++; -#endif - - /* Set up to call proper row-extraction routine in future */ - if (source->visual == PSEUDOCOLOR) { - source->pub.buffer = source->rle_row; - source->pub.get_pixel_rows = get_pseudocolor_row; - } else { - source->pub.get_pixel_rows = get_rle_row; - } - source->row = cinfo->image_height; - - /* And fetch the topmost (bottommost) row */ - return (*source->pub.get_pixel_rows) (cinfo, sinfo); -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_rle (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for RLE format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_rle (j_compress_ptr cinfo) -{ - rle_source_ptr source; - - /* Create module interface object */ - source = (rle_source_ptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(rle_source_struct)); - /* Fill in method ptrs */ - source->pub.start_input = start_input_rle; - source->pub.finish_input = finish_input_rle; - source->pub.get_pixel_rows = load_image; - - return &source->pub; -} - -#endif /* RLE_SUPPORTED */ diff --git a/code/jpeg-9f/rdswitch.c b/code/jpeg-9f/rdswitch.c deleted file mode 100644 index 8a6675db..00000000 --- a/code/jpeg-9f/rdswitch.c +++ /dev/null @@ -1,363 +0,0 @@ -/* - * rdswitch.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * Modified 2003-2020 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to process some of cjpeg's more complicated - * command-line switches. Switches processed here are: - * -qtables file Read quantization tables from text file - * -scans file Read scan script from text file - * -quality N[,N,...] Set quality ratings - * -qslots N[,N,...] Set component quantization table selectors - * -sample HxV[,HxV,...] Set component sampling factors - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ -#include /* to declare isdigit(), isspace() */ - - -LOCAL(int) -text_getc (FILE * file) -/* Read next char, skipping over any comments (# to end of line) */ -/* A comment/newline sequence is returned as a newline */ -{ - register int ch; - - ch = getc(file); - if (ch == '#') { - do { - ch = getc(file); - } while (ch != '\n' && ch != EOF); - } - return ch; -} - - -LOCAL(boolean) -read_text_integer (FILE * file, long * result, int * termchar) -/* Read an unsigned decimal integer from a file, store it in result */ -/* Reads one trailing character after the integer; returns it in termchar */ -{ - register int ch; - register long val; - - /* Skip any leading whitespace, detect EOF */ - do { - ch = text_getc(file); - if (ch == EOF) { - *termchar = ch; - return FALSE; - } - } while (isspace(ch)); - - if (! isdigit(ch)) { - *termchar = ch; - return FALSE; - } - - val = ch - '0'; - while ((ch = text_getc(file)) != EOF) { - if (! isdigit(ch)) - break; - val *= 10; - val += ch - '0'; - } - *result = val; - *termchar = ch; - return TRUE; -} - - -GLOBAL(boolean) -read_quant_tables (j_compress_ptr cinfo, char * filename, boolean force_baseline) -/* Read a set of quantization tables from the specified file. - * The file is plain ASCII text: decimal numbers with whitespace between. - * Comments preceded by '#' may be included in the file. - * There may be one to NUM_QUANT_TBLS tables in the file, each of 64 values. - * The tables are implicitly numbered 0,1,etc. - * NOTE: does not affect the qslots mapping, which will default to selecting - * table 0 for luminance (or primary) components, 1 for chrominance components. - * You must use -qslots if you want a different component->table mapping. - */ -{ - FILE * fp; - int tblno, i, termchar; - long val; - unsigned int table[DCTSIZE2]; - - if ((fp = fopen(filename, "r")) == NULL) { - fprintf(stderr, "Can't open table file %s\n", filename); - return FALSE; - } - tblno = 0; - - while (read_text_integer(fp, &val, &termchar)) { /* read 1st element of table */ - if (tblno >= NUM_QUANT_TBLS) { - fprintf(stderr, "Too many tables in file %s\n", filename); - fclose(fp); - return FALSE; - } - table[0] = (unsigned int) val; - for (i = 1; i < DCTSIZE2; i++) { - if (! read_text_integer(fp, &val, &termchar)) { - fprintf(stderr, "Invalid table data in file %s\n", filename); - fclose(fp); - return FALSE; - } - table[i] = (unsigned int) val; - } - jpeg_add_quant_table(cinfo, tblno, table, cinfo->q_scale_factor[tblno], - force_baseline); - tblno++; - } - - if (termchar != EOF) { - fprintf(stderr, "Non-numeric data in file %s\n", filename); - fclose(fp); - return FALSE; - } - - fclose(fp); - return TRUE; -} - - -#ifdef C_MULTISCAN_FILES_SUPPORTED - -LOCAL(boolean) -read_scan_integer (FILE * file, long * result, int * termchar) -/* Variant of read_text_integer that always looks for a non-space termchar; - * this simplifies parsing of punctuation in scan scripts. - */ -{ - register int ch; - - if (! read_text_integer(file, result, termchar)) - return FALSE; - ch = *termchar; - while (ch != EOF && isspace(ch)) - ch = text_getc(file); - if (isdigit(ch)) { /* oops, put it back */ - if (ungetc(ch, file) == EOF) - return FALSE; - ch = ' '; - } else { - /* Any separators other than ';' and ':' are ignored; - * this allows user to insert commas, etc, if desired. - */ - if (ch != EOF && ch != ';' && ch != ':') - ch = ' '; - } - *termchar = ch; - return TRUE; -} - - -GLOBAL(boolean) -read_scan_script (j_compress_ptr cinfo, char * filename) -/* Read a scan script from the specified text file. - * Each entry in the file defines one scan to be emitted. - * Entries are separated by semicolons ';'. - * An entry contains one to four component indexes, - * optionally followed by a colon ':' and four progressive-JPEG parameters. - * The component indexes denote which component(s) are to be transmitted - * in the current scan. The first component has index 0. - * Sequential JPEG is used if the progressive-JPEG parameters are omitted. - * The file is free format text: any whitespace may appear between numbers - * and the ':' and ';' punctuation marks. Also, other punctuation (such - * as commas or dashes) can be placed between numbers if desired. - * Comments preceded by '#' may be included in the file. - * Note: we do very little validity checking here; - * jcmaster.c will validate the script parameters. - */ -{ - FILE * fp; - int scanno, ncomps, termchar; - long val; - jpeg_scan_info * scanptr; -#define MAX_SCANS 100 /* quite arbitrary limit */ - jpeg_scan_info scans[MAX_SCANS]; - - if ((fp = fopen(filename, "r")) == NULL) { - fprintf(stderr, "Can't open scan definition file %s\n", filename); - return FALSE; - } - scanptr = scans; - scanno = 0; - - while (read_scan_integer(fp, &val, &termchar)) { - if (scanno >= MAX_SCANS) { - fprintf(stderr, "Too many scans defined in file %s\n", filename); - fclose(fp); - return FALSE; - } - scanptr->component_index[0] = (int) val; - ncomps = 1; - while (termchar == ' ') { - if (ncomps >= MAX_COMPS_IN_SCAN) { - fprintf(stderr, "Too many components in one scan in file %s\n", - filename); - fclose(fp); - return FALSE; - } - if (! read_scan_integer(fp, &val, &termchar)) - goto bogus; - scanptr->component_index[ncomps] = (int) val; - ncomps++; - } - scanptr->comps_in_scan = ncomps; - if (termchar == ':') { - if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') - goto bogus; - scanptr->Ss = (int) val; - if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') - goto bogus; - scanptr->Se = (int) val; - if (! read_scan_integer(fp, &val, &termchar) || termchar != ' ') - goto bogus; - scanptr->Ah = (int) val; - if (! read_scan_integer(fp, &val, &termchar)) - goto bogus; - scanptr->Al = (int) val; - } else { - /* set non-progressive parameters */ - scanptr->Ss = 0; - scanptr->Se = DCTSIZE2-1; - scanptr->Ah = 0; - scanptr->Al = 0; - } - if (termchar != ';' && termchar != EOF) { -bogus: - fprintf(stderr, "Invalid scan entry format in file %s\n", filename); - fclose(fp); - return FALSE; - } - scanptr++, scanno++; - } - - if (termchar != EOF) { - fprintf(stderr, "Non-numeric data in file %s\n", filename); - fclose(fp); - return FALSE; - } - - if (scanno > 0) { - /* Stash completed scan list in cinfo structure. - * NOTE: for cjpeg's use, JPOOL_IMAGE is the right lifetime for this data, - * but if you want to compress multiple images you'd want JPOOL_PERMANENT. - */ - scanptr = (jpeg_scan_info *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, scanno * SIZEOF(jpeg_scan_info)); - MEMCOPY(scanptr, scans, scanno * SIZEOF(jpeg_scan_info)); - cinfo->scan_info = scanptr; - cinfo->num_scans = scanno; - } - - fclose(fp); - return TRUE; -} - -#endif /* C_MULTISCAN_FILES_SUPPORTED */ - - -GLOBAL(boolean) -set_quality_ratings (j_compress_ptr cinfo, char *arg, boolean force_baseline) -/* Process a quality-ratings parameter string, of the form - * N[,N,...] - * If there are more q-table slots than parameters, the last value is replicated. - */ -{ - int val = 75; /* default value */ - int tblno; - char ch; - - for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { - if (*arg) { - ch = ','; /* if not set by sscanf, will be ',' */ - if (sscanf(arg, "%d%c", &val, &ch) < 1) - return FALSE; - if (ch != ',') /* syntax check */ - return FALSE; - /* Convert user 0-100 rating to percentage scaling */ - cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val); - while (*arg && *arg++ != ','); /* advance to next segment of arg string */ - } else { - /* reached end of parameter, set remaining factors to last value */ - cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val); - } - } - jpeg_default_qtables(cinfo, force_baseline); - return TRUE; -} - - -GLOBAL(boolean) -set_quant_slots (j_compress_ptr cinfo, char *arg) -/* Process a quantization-table-selectors parameter string, of the form - * N[,N,...] - * If there are more components than parameters, the last value is replicated. - */ -{ - int val = 0; /* default table # */ - int ci; - char ch; - - for (ci = 0; ci < MAX_COMPONENTS; ci++) { - if (*arg) { - ch = ','; /* if not set by sscanf, will be ',' */ - if (sscanf(arg, "%d%c", &val, &ch) < 1) - return FALSE; - if (ch != ',') /* syntax check */ - return FALSE; - if (val < 0 || val >= NUM_QUANT_TBLS) { - fprintf(stderr, "JPEG quantization tables are numbered 0..%d\n", - NUM_QUANT_TBLS-1); - return FALSE; - } - cinfo->comp_info[ci].quant_tbl_no = val; - while (*arg && *arg++ != ','); /* advance to next segment of arg string */ - } else { - /* reached end of parameter, set remaining components to last table */ - cinfo->comp_info[ci].quant_tbl_no = val; - } - } - return TRUE; -} - - -GLOBAL(boolean) -set_sample_factors (j_compress_ptr cinfo, char *arg) -/* Process a sample-factors parameter string, of the form - * HxV[,HxV,...] - * If there are more components than parameters, "1x1" is assumed for the rest. - */ -{ - int ci, val1, val2; - char ch1, ch2; - - for (ci = 0; ci < MAX_COMPONENTS; ci++) { - if (*arg) { - ch2 = ','; /* if not set by sscanf, will be ',' */ - if (sscanf(arg, "%d%c%d%c", &val1, &ch1, &val2, &ch2) < 3) - return FALSE; - if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */ - return FALSE; - if (val1 <= 0 || val1 > MAX_SAMP_FACTOR || - val2 <= 0 || val2 > MAX_SAMP_FACTOR) { - fprintf(stderr, "JPEG sampling factors must be 1..%d\n", MAX_SAMP_FACTOR); - return FALSE; - } - cinfo->comp_info[ci].h_samp_factor = val1; - cinfo->comp_info[ci].v_samp_factor = val2; - while (*arg && *arg++ != ','); /* advance to next segment of arg string */ - } else { - /* reached end of parameter, set remaining components to 1x1 sampling */ - cinfo->comp_info[ci].h_samp_factor = 1; - cinfo->comp_info[ci].v_samp_factor = 1; - } - } - return TRUE; -} diff --git a/code/jpeg-9f/rdtarga.c b/code/jpeg-9f/rdtarga.c deleted file mode 100644 index c72ad73f..00000000 --- a/code/jpeg-9f/rdtarga.c +++ /dev/null @@ -1,500 +0,0 @@ -/* - * rdtarga.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * Modified 2017-2019 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to read input images in Targa format. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume input from - * an ordinary stdio stream. They further assume that reading begins - * at the start of the file; start_input may need work if the - * user interface has already read some data (e.g., to determine that - * the file is indeed Targa format). - * - * Based on code contributed by Lee Daniel Crocker. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef TARGA_SUPPORTED - - -/* Macros to deal with unsigned chars as efficiently as compiler allows */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char U_CHAR; -#define UCH(x) ((int) (x)) -#else /* !HAVE_UNSIGNED_CHAR */ -typedef char U_CHAR; -#ifdef CHAR_IS_UNSIGNED -#define UCH(x) ((int) (x)) -#else -#define UCH(x) ((int) (x) & 0xFF) -#endif -#endif /* HAVE_UNSIGNED_CHAR */ - - -#define ReadOK(file,buffer,len) (JFREAD(file,buffer,len) == ((size_t) (len))) - - -/* Private version of data source object */ - -typedef struct _tga_source_struct * tga_source_ptr; - -typedef struct _tga_source_struct { - struct cjpeg_source_struct pub; /* public fields */ - - j_compress_ptr cinfo; /* back link saves passing separate parm */ - - JSAMPARRAY colormap; /* Targa colormap (converted to my format) */ - - jvirt_sarray_ptr whole_image; /* Needed if funny input row order */ - JDIMENSION current_row; /* Current logical row number to read */ - - /* Pointer to routine to extract next Targa pixel from input file */ - JMETHOD(void, read_pixel, (tga_source_ptr sinfo)); - - /* Result of read_pixel is delivered here: */ - U_CHAR tga_pixel[4]; - - int pixel_size; /* Bytes per Targa pixel (1 to 4) */ - int cmap_length; /* colormap length */ - - /* State info for reading RLE-coded pixels; both counts must be init to 0 */ - int block_count; /* # of pixels remaining in RLE block */ - int dup_pixel_count; /* # of times to duplicate previous pixel */ - - /* This saves the correct pixel-row-expansion method for preload_image */ - JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, - cjpeg_source_ptr sinfo)); -} tga_source_struct; - - -/* For expanding 5-bit pixel values to 8-bit with best rounding */ - -static const UINT8 c5to8bits[32] = { - 0, 8, 16, 25, 33, 41, 49, 58, - 66, 74, 82, 90, 99, 107, 115, 123, - 132, 140, 148, 156, 165, 173, 181, 189, - 197, 206, 214, 222, 230, 239, 247, 255 -}; - - - -LOCAL(int) -read_byte (tga_source_ptr sinfo) -/* Read next byte from Targa file */ -{ - register FILE *infile = sinfo->pub.input_file; - register int c; - - if ((c = getc(infile)) == EOF) - ERREXIT(sinfo->cinfo, JERR_INPUT_EOF); - return c; -} - - -LOCAL(void) -read_colormap (tga_source_ptr sinfo, int cmaplen, int mapentrysize) -/* Read the colormap from a Targa file */ -{ - int i; - - /* Presently only handles 24-bit BGR format */ - if (mapentrysize != 24) - ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP); - - for (i = 0; i < cmaplen; i++) { - sinfo->colormap[2][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[1][i] = (JSAMPLE) read_byte(sinfo); - sinfo->colormap[0][i] = (JSAMPLE) read_byte(sinfo); - } -} - - -/* - * read_pixel methods: get a single pixel from Targa file into tga_pixel[] - */ - -METHODDEF(void) -read_non_rle_pixel (tga_source_ptr sinfo) -/* Read one Targa pixel from the input file; no RLE expansion */ -{ - register int i; - - for (i = 0; i < sinfo->pixel_size; i++) { - sinfo->tga_pixel[i] = (U_CHAR) read_byte(sinfo); - } -} - -METHODDEF(void) -read_rle_pixel (tga_source_ptr sinfo) -/* Read one Targa pixel from the input file, expanding RLE data as needed */ -{ - register int i; - - /* Duplicate previously read pixel? */ - if (sinfo->dup_pixel_count > 0) { - sinfo->dup_pixel_count--; - return; - } - - /* Time to read RLE block header? */ - if (--sinfo->block_count < 0) { /* decrement pixels remaining in block */ - i = read_byte(sinfo); - if (i & 0x80) { /* Start of duplicate-pixel block? */ - sinfo->dup_pixel_count = i & 0x7F; /* number of dups after this one */ - sinfo->block_count = 0; /* then read new block header */ - } else { - sinfo->block_count = i & 0x7F; /* number of pixels after this one */ - } - } - - /* Read next pixel */ - for (i = 0; i < sinfo->pixel_size; i++) { - sinfo->tga_pixel[i] = (U_CHAR) read_byte(sinfo); - } -} - - -/* - * Read one row of pixels. - * - * We provide several different versions depending on input file format. - */ - -METHODDEF(JDIMENSION) -get_8bit_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 8-bit grayscale pixels */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); - } - return 1; -} - -METHODDEF(JDIMENSION) -get_8bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 8-bit colormap indexes */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register JSAMPROW ptr; - register JSAMPARRAY colormap; - register JDIMENSION col; - register int t; - int cmaplen; - - ptr = source->pub.buffer[0]; - colormap = source->colormap; - cmaplen = source->cmap_length; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - t = UCH(source->tga_pixel[0]); - if (t >= cmaplen) - ERREXIT(cinfo, JERR_TGA_BADPARMS); - *ptr++ = colormap[0][t]; - *ptr++ = colormap[1][t]; - *ptr++ = colormap[2][t]; - } - return 1; -} - -METHODDEF(JDIMENSION) -get_16bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 16-bit pixels */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register int t; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - t = UCH(source->tga_pixel[0]); - t += UCH(source->tga_pixel[1]) << 8; - /* We expand 5 bit data to 8 bit sample width. - * The format of the 16-bit (LSB first) input word is - * xRRRRRGGGGGBBBBB - */ - ptr[2] = (JSAMPLE) c5to8bits[t & 0x1F]; - t >>= 5; - ptr[1] = (JSAMPLE) c5to8bits[t & 0x1F]; - t >>= 5; - ptr[0] = (JSAMPLE) c5to8bits[t & 0x1F]; - ptr += 3; - } - return 1; -} - -METHODDEF(JDIMENSION) -get_24bit_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -/* This version is for reading 24-bit pixels */ -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = source->pub.buffer[0]; - for (col = cinfo->image_width; col > 0; col--) { - (*source->read_pixel) (source); /* Load next pixel into tga_pixel */ - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[2]); /* change BGR to RGB order */ - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[1]); - *ptr++ = (JSAMPLE) UCH(source->tga_pixel[0]); - } - return 1; -} - -/* - * Targa also defines a 32-bit pixel format with order B,G,R,A. - * We presently ignore the attribute byte, so the code for reading - * these pixels is identical to the 24-bit routine above. - * This works because the actual pixel length is only known to read_pixel. - */ - -#define get_32bit_row get_24bit_row - - -/* - * This method is for re-reading the input data in standard top-down - * row order. The entire image has already been read into whole_image - * with proper conversion of pixel format, but it's in a funny row order. - */ - -METHODDEF(JDIMENSION) -get_memory_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - JDIMENSION source_row; - - /* Compute row of source that maps to current_row of normal order */ - /* For now, assume image is bottom-up and not interlaced. */ - /* NEEDS WORK to support interlaced images! */ - source_row = cinfo->image_height - source->current_row - 1; - - /* Fetch that row from virtual array */ - source->pub.buffer = (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, - source->whole_image, source_row, (JDIMENSION) 1, FALSE); - - source->current_row++; - return 1; -} - - -/* - * This method loads the image into whole_image during the first call on - * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call - * get_memory_row on subsequent calls. - */ - -METHODDEF(JDIMENSION) -preload_image (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - JDIMENSION row; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Read the data into a virtual array in input-file row order. */ - for (row = 0; row < cinfo->image_height; row++) { - if (progress != NULL) { - progress->pub.pass_counter = (long) row; - progress->pub.pass_limit = (long) cinfo->image_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - source->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, source->whole_image, row, (JDIMENSION) 1, TRUE); - (*source->get_pixel_rows) (cinfo, sinfo); - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Set up to read from the virtual array in unscrambled order */ - source->pub.get_pixel_rows = get_memory_row; - source->current_row = 0; - /* And read the first row */ - return get_memory_row(cinfo, sinfo); -} - - -/* - * Read the file header; return image size and component count. - */ - -METHODDEF(void) -start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - tga_source_ptr source = (tga_source_ptr) sinfo; - U_CHAR targaheader[18]; - int idlen, cmaptype, subtype, flags, interlace_type, components; - unsigned int width, height, maplen; - boolean is_bottom_up; - -#define GET_2B(offset) ((unsigned int) UCH(targaheader[offset]) + \ - (((unsigned int) UCH(targaheader[offset+1])) << 8)) - - if (! ReadOK(source->pub.input_file, targaheader, 18)) - ERREXIT(cinfo, JERR_INPUT_EOF); - - /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */ - if (targaheader[16] == 15) - targaheader[16] = 16; - - idlen = UCH(targaheader[0]); - cmaptype = UCH(targaheader[1]); - subtype = UCH(targaheader[2]); - maplen = GET_2B(5); - width = GET_2B(12); - height = GET_2B(14); - source->pixel_size = UCH(targaheader[16]) >> 3; - flags = UCH(targaheader[17]); /* Image Descriptor byte */ - - is_bottom_up = ((flags & 0x20) == 0); /* bit 5 set => top-down */ - interlace_type = flags >> 6; /* bits 6/7 are interlace code */ - - if (cmaptype > 1 || /* cmaptype must be 0 or 1 */ - width <= 0 || height <= 0 || - source->pixel_size < 1 || source->pixel_size > 4 || - (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */ - interlace_type != 0) /* currently don't allow interlaced image */ - ERREXIT(cinfo, JERR_TGA_BADPARMS); - - if (subtype > 8) { - /* It's an RLE-coded file */ - source->read_pixel = read_rle_pixel; - source->block_count = source->dup_pixel_count = 0; - subtype -= 8; - } else { - /* Non-RLE file */ - source->read_pixel = read_non_rle_pixel; - } - - /* Now should have subtype 1, 2, or 3 */ - components = 3; /* until proven different */ - cinfo->in_color_space = JCS_RGB; - - switch (subtype) { - case 1: /* Colormapped image */ - if (source->pixel_size == 1 && cmaptype == 1) - source->get_pixel_rows = get_8bit_row; - else - ERREXIT(cinfo, JERR_TGA_BADPARMS); - TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height); - break; - case 2: /* RGB image */ - switch (source->pixel_size) { - case 2: - source->get_pixel_rows = get_16bit_row; - break; - case 3: - source->get_pixel_rows = get_24bit_row; - break; - case 4: - source->get_pixel_rows = get_32bit_row; - break; - default: - ERREXIT(cinfo, JERR_TGA_BADPARMS); - } - TRACEMS2(cinfo, 1, JTRC_TGA, width, height); - break; - case 3: /* Grayscale image */ - components = 1; - cinfo->in_color_space = JCS_GRAYSCALE; - if (source->pixel_size == 1) - source->get_pixel_rows = get_8bit_gray_row; - else - ERREXIT(cinfo, JERR_TGA_BADPARMS); - TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height); - break; - default: - ERREXIT(cinfo, JERR_TGA_BADPARMS); - } - - if (is_bottom_up) { - /* Create a virtual array to buffer the upside-down image. */ - source->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) width * components, (JDIMENSION) height, (JDIMENSION) 1); - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - /* source->pub.buffer will point to the virtual array. */ - source->pub.buffer_height = 1; /* in case anyone looks at it */ - source->pub.get_pixel_rows = preload_image; - } else { - /* Don't need a virtual array, but do need a one-row input buffer. */ - source->whole_image = NULL; - source->pub.buffer = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, - JPOOL_IMAGE, (JDIMENSION) width * components, (JDIMENSION) 1); - source->pub.buffer_height = 1; - source->pub.get_pixel_rows = source->get_pixel_rows; - } - - while (idlen--) /* Throw away ID field */ - (void) read_byte(source); - - if (maplen > 0) { - if (maplen > 256 || GET_2B(3) != 0) - ERREXIT(cinfo, JERR_TGA_BADCMAP); - /* Allocate space to store the colormap */ - source->colormap = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, - JPOOL_IMAGE, (JDIMENSION) maplen, (JDIMENSION) 3); - source->cmap_length = (int) maplen; - /* and read it from the file */ - read_colormap(source, (int) maplen, UCH(targaheader[7])); - } else { - if (cmaptype) /* but you promised a cmap! */ - ERREXIT(cinfo, JERR_TGA_BADPARMS); - source->colormap = NULL; - source->cmap_length = 0; - } - - cinfo->input_components = components; - cinfo->data_precision = 8; - cinfo->image_width = width; - cinfo->image_height = height; -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) -{ - /* no work */ -} - - -/* - * The module selection routine for Targa format input. - */ - -GLOBAL(cjpeg_source_ptr) -jinit_read_targa (j_compress_ptr cinfo) -{ - tga_source_ptr source; - - /* Create module interface object */ - source = (tga_source_ptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(tga_source_struct)); - source->cinfo = cinfo; /* make back link for subroutines */ - /* Fill in method ptrs, except get_pixel_rows which start_input sets */ - source->pub.start_input = start_input_tga; - source->pub.finish_input = finish_input_tga; - - return &source->pub; -} - -#endif /* TARGA_SUPPORTED */ diff --git a/code/jpeg-9f/transupp.c b/code/jpeg-9f/transupp.c deleted file mode 100644 index 6518936a..00000000 --- a/code/jpeg-9f/transupp.c +++ /dev/null @@ -1,2433 +0,0 @@ -/* - * transupp.c - * - * Copyright (C) 1997-2023, Thomas G. Lane, Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains image transformation routines and other utility code - * used by the jpegtran sample application. These are NOT part of the core - * JPEG library. But we keep these routines separate from jpegtran.c to - * ease the task of maintaining jpegtran-like programs that have other user - * interfaces. - */ - -/* Although this file really shouldn't have access to the library internals, - * it's helpful to let it call jround_up() and jcopy_block_row(). - * Also, the (switchable) virtual memory adaptation code for - * the drop feature has dependencies on library internals. - */ -#define JPEG_INTERNALS - -#include "jinclude.h" -#include "jpeglib.h" -#include "transupp.h" /* My own external interface */ -#include /* to declare isdigit() */ - - -#if TRANSFORMS_SUPPORTED - -/* - * Lossless image transformation routines. These routines work on DCT - * coefficient arrays and thus do not require any lossy decompression - * or recompression of the image. - * Thanks to Guido Vollbeding for the initial design and code of this feature, - * and to Ben Jackson for introducing the cropping feature. - * - * Horizontal flipping is done in-place, using a single top-to-bottom - * pass through the virtual source array. It will thus be much the - * fastest option for images larger than main memory. - * - * The other routines require a set of destination virtual arrays, so they - * need twice as much memory as jpegtran normally does. The destination - * arrays are always written in normal scan order (top to bottom) because - * the virtual array manager expects this. The source arrays will be scanned - * in the corresponding order, which means multiple passes through the source - * arrays for most of the transforms. That could result in much thrashing - * if the image is larger than main memory. - * - * If cropping or trimming is involved, the destination arrays may be smaller - * than the source arrays. Note it is not possible to do horizontal flip - * in-place when a nonzero Y crop offset is specified, since we'd have to move - * data from one block row to another but the virtual array manager doesn't - * guarantee we can touch more than one row at a time. So in that case, - * we have to use a separate destination array. - * - * Some notes about the operating environment of the individual transform - * routines: - * 1. Both the source and destination virtual arrays are allocated from the - * source JPEG object, and therefore should be manipulated by calling the - * source's memory manager. - * 2. The destination's component count should be used. It may be smaller - * than the source's when forcing to grayscale. - * 3. Likewise the destination's sampling factors should be used. When - * forcing to grayscale the destination's sampling factors will be all 1, - * and we may as well take that as the effective iMCU size. - * 4. When "trim" is in effect, the destination's dimensions will be the - * trimmed values but the source's will be untrimmed. - * 5. When "crop" is in effect, the destination's dimensions will be the - * cropped values but the source's will be uncropped. Each transform - * routine is responsible for picking up source data starting at the - * correct X and Y offset for the crop region. (The X and Y offsets - * passed to the transform routines are measured in iMCU blocks of the - * destination.) - * 6. All the routines assume that the source and destination buffers are - * padded out to a full iMCU boundary. This is true, although for the - * source buffer it is an undocumented property of jdcoefct.c. - */ - - -/* Drop code may be used with or without virtual memory adaptation code. - * This code has some dependencies on internal library behavior, so you - * may choose to disable it. For example, it doesn't make a difference - * if you only use jmemnobs anyway. - */ -#ifndef DROP_REQUEST_FROM_SRC -#define DROP_REQUEST_FROM_SRC 1 /* 0 disables adaptation */ -#endif - - -#if DROP_REQUEST_FROM_SRC -/* Force jpeg_read_coefficients to request - * the virtual coefficient arrays from - * the source decompression object. - */ -METHODDEF(jvirt_barray_ptr) -drop_request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero, - JDIMENSION blocksperrow, JDIMENSION numrows, - JDIMENSION maxaccess) -{ - j_common_ptr srcinfo = (j_common_ptr) cinfo->client_data; - - return (*srcinfo->mem->request_virt_barray) - (srcinfo, pool_id, pre_zero, - blocksperrow, numrows, maxaccess); -} - - -/* Force jpeg_read_coefficients to return - * after requesting and before accessing - * the virtual coefficient arrays. - */ -METHODDEF(int) -drop_consume_input (j_decompress_ptr cinfo) -{ - return JPEG_SUSPENDED; -} - - -METHODDEF(void) -drop_start_input_pass (j_decompress_ptr cinfo) -{ - cinfo->inputctl->consume_input = drop_consume_input; -} - - -LOCAL(void) -drop_request_from_src (j_decompress_ptr dropinfo, j_decompress_ptr srcinfo) -{ - void *save_client_data; - JMETHOD(jvirt_barray_ptr, save_request_virt_barray, - (j_common_ptr cinfo, int pool_id, boolean pre_zero, - JDIMENSION blocksperrow, JDIMENSION numrows, JDIMENSION maxaccess)); - JMETHOD(void, save_start_input_pass, (j_decompress_ptr cinfo)); - - /* Set custom method pointers, save original pointers */ - save_client_data = dropinfo->client_data; - dropinfo->client_data = (void *) srcinfo; - save_request_virt_barray = dropinfo->mem->request_virt_barray; - dropinfo->mem->request_virt_barray = drop_request_virt_barray; - save_start_input_pass = dropinfo->inputctl->start_input_pass; - dropinfo->inputctl->start_input_pass = drop_start_input_pass; - - /* Execute only initialization part. - * Requested coefficient arrays will be realized later by the srcinfo object. - * Next call to the same function will then do the actual data reading. - * NB: since we request the coefficient arrays from another object, - * the inherent realization call is effectively a no-op. - */ - (void) jpeg_read_coefficients(dropinfo); - - /* Reset method pointers */ - dropinfo->client_data = save_client_data; - dropinfo->mem->request_virt_barray = save_request_virt_barray; - dropinfo->inputctl->start_input_pass = save_start_input_pass; - /* Do input initialization for first scan now, - * which also resets the consume_input method. - */ - (*save_start_input_pass)(dropinfo); -} -#endif /* DROP_REQUEST_FROM_SRC */ - - -LOCAL(void) -dequant_comp (j_decompress_ptr cinfo, jpeg_component_info *compptr, - jvirt_barray_ptr coef_array, JQUANT_TBL *qtblptr1) -{ - JDIMENSION blk_x, blk_y; - int offset_y, k; - JQUANT_TBL *qtblptr; - JBLOCKARRAY buffer; - JBLOCKROW block; - JCOEFPTR ptr; - - qtblptr = compptr->quant_table; - for (blk_y = 0; blk_y < compptr->height_in_blocks; - blk_y += compptr->v_samp_factor) { - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef_array, blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - block = buffer[offset_y]; - for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) { - ptr = block[blk_x]; - for (k = 0; k < DCTSIZE2; k++) - if (qtblptr->quantval[k] != qtblptr1->quantval[k]) - ptr[k] *= qtblptr->quantval[k] / qtblptr1->quantval[k]; - } - } - } -} - - -LOCAL(void) -requant_comp (j_decompress_ptr cinfo, jpeg_component_info *compptr, - jvirt_barray_ptr coef_array, JQUANT_TBL *qtblptr1) -{ - JDIMENSION blk_x, blk_y; - int offset_y, k, temp, qval; - JQUANT_TBL *qtblptr; - JBLOCKARRAY buffer; - JBLOCKROW block; - JCOEFPTR ptr; - - qtblptr = compptr->quant_table; - for (blk_y = 0; blk_y < compptr->height_in_blocks; - blk_y += compptr->v_samp_factor) { - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef_array, blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - block = buffer[offset_y]; - for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) { - ptr = block[blk_x]; - for (k = 0; k < DCTSIZE2; k++) { - qval = qtblptr1->quantval[k]; - if (qval == 0) continue; - temp = qtblptr->quantval[k]; - if (temp == qval) continue; - temp *= ptr[k]; - /* The following quantization code is a copy from jcdctmgr.c */ -#ifdef FAST_DIVIDE -#define DIVIDE_BY(a,b) a /= b -#else -#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 -#endif - if (temp < 0) { - temp = -temp; - temp += qval>>1; /* for rounding */ - DIVIDE_BY(temp, qval); - temp = -temp; - } else { - temp += qval>>1; /* for rounding */ - DIVIDE_BY(temp, qval); - } - ptr[k] = (JCOEF) temp; - } - } - } - } -} - - -/* Calculate largest common denominator with Euclid's algorithm. - */ -LOCAL(JCOEF) -largest_common_denominator(JCOEF a, JCOEF b) -{ - JCOEF c; - - while (b) { - c = a % b; - a = b; - b = c; - } - - return a; -} - - -LOCAL(void) -adjust_quant(j_decompress_ptr srcinfo, jvirt_barray_ptr *src_coef_arrays, - j_decompress_ptr dropinfo, jvirt_barray_ptr *drop_coef_arrays, - boolean trim, j_compress_ptr dstinfo) -{ - jpeg_component_info *compptr1, *compptr2; - JQUANT_TBL *qtblptr1, *qtblptr2, *qtblptr3; - int ci, k; - - for (ci = 0; ci < dstinfo->num_components && - ci < dropinfo->num_components; ci++) { - compptr1 = srcinfo->comp_info + ci; - compptr2 = dropinfo->comp_info + ci; - qtblptr1 = compptr1->quant_table; - qtblptr2 = compptr2->quant_table; - for (k = 0; k < DCTSIZE2; k++) { - if (qtblptr1->quantval[k] != qtblptr2->quantval[k]) { - if (trim) - requant_comp(dropinfo, compptr2, drop_coef_arrays[ci], qtblptr1); - else { - qtblptr3 = dstinfo->quant_tbl_ptrs[compptr1->quant_tbl_no]; - for (k = 0; k < DCTSIZE2; k++) - if (qtblptr1->quantval[k] != qtblptr2->quantval[k]) - qtblptr3->quantval[k] = largest_common_denominator - (qtblptr1->quantval[k], qtblptr2->quantval[k]); - dequant_comp(srcinfo, compptr1, src_coef_arrays[ci], qtblptr3); - dequant_comp(dropinfo, compptr2, drop_coef_arrays[ci], qtblptr3); - } - break; - } - } - } -} - - -LOCAL(void) -do_drop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - j_decompress_ptr dropinfo, jvirt_barray_ptr *drop_coef_arrays, - JDIMENSION drop_width, JDIMENSION drop_height) -/* Drop. If the dropinfo component number is smaller than the destination's, - * we fill in the remaining components with zero. This provides the feature - * of dropping grayscale into (arbitrarily sampled) color images. - */ -{ - JDIMENSION comp_width, comp_height; - JDIMENSION blk_y, x_drop_blocks, y_drop_blocks; - int ci, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - jpeg_component_info *compptr; - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = drop_width * compptr->h_samp_factor; - comp_height = drop_height * compptr->v_samp_factor; - x_drop_blocks = x_crop_offset * compptr->h_samp_factor; - y_drop_blocks = y_crop_offset * compptr->v_samp_factor; - for (blk_y = 0; blk_y < comp_height; blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y + y_drop_blocks, - (JDIMENSION) compptr->v_samp_factor, TRUE); - if (ci < dropinfo->num_components) { -#if DROP_REQUEST_FROM_SRC - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, drop_coef_arrays[ci], blk_y, -#else - src_buffer = (*dropinfo->mem->access_virt_barray) - ((j_common_ptr) dropinfo, drop_coef_arrays[ci], blk_y, -#endif - (JDIMENSION) compptr->v_samp_factor, FALSE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - jcopy_block_row(src_buffer[offset_y], - dst_buffer[offset_y] + x_drop_blocks, - comp_width); - } - } else { - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - FMEMZERO(dst_buffer[offset_y] + x_drop_blocks, - comp_width * SIZEOF(JBLOCK)); - } - } - } - } -} - - -LOCAL(void) -do_crop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Crop. This is only used when no rotate/flip is requested with the crop. */ -{ - JDIMENSION dst_blk_y, x_crop_blocks, y_crop_blocks; - int ci, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - jpeg_component_info *compptr; - - /* We simply have to copy the right amount of data (the destination's - * image size) starting at the given X and Y offsets in the source. - */ - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - y_crop_blocks = y_crop_offset * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_y + y_crop_blocks, - (JDIMENSION) compptr->v_samp_factor, FALSE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - jcopy_block_row(src_buffer[offset_y] + x_crop_blocks, - dst_buffer[offset_y], - compptr->width_in_blocks); - } - } - } -} - - -LOCAL(void) -do_crop_ext_zero (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Crop. This is only used when no rotate/flip is requested with the crop. - * Extension: If the destination size is larger than the source, we fill in - * the extra area with zero (neutral gray). Note we also have to zero partial - * iMCUs at the right and bottom edge of the source image area in this case. - */ -{ - JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height; - JDIMENSION dst_blk_y, x_crop_blocks, y_crop_blocks; - int ci, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - jpeg_component_info *compptr; - - MCU_cols = srcinfo->output_width / - (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); - MCU_rows = srcinfo->output_height / - (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - comp_height = MCU_rows * compptr->v_samp_factor; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - y_crop_blocks = y_crop_offset * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - if (dstinfo->jpeg_height > srcinfo->output_height) { - if (dst_blk_y < y_crop_blocks || - dst_blk_y >= y_crop_blocks + comp_height) { - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - FMEMZERO(dst_buffer[offset_y], - compptr->width_in_blocks * SIZEOF(JBLOCK)); - } - continue; - } - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_y - y_crop_blocks, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } else { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_y + y_crop_blocks, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - if (dstinfo->jpeg_width > srcinfo->output_width) { - if (x_crop_blocks > 0) { - FMEMZERO(dst_buffer[offset_y], - x_crop_blocks * SIZEOF(JBLOCK)); - } - jcopy_block_row(src_buffer[offset_y], - dst_buffer[offset_y] + x_crop_blocks, - comp_width); - if (compptr->width_in_blocks > x_crop_blocks + comp_width) { - FMEMZERO(dst_buffer[offset_y] + - x_crop_blocks + comp_width, - (compptr->width_in_blocks - - x_crop_blocks - comp_width) * SIZEOF(JBLOCK)); - } - } else { - jcopy_block_row(src_buffer[offset_y] + x_crop_blocks, - dst_buffer[offset_y], - compptr->width_in_blocks); - } - } - } - } -} - - -LOCAL(void) -do_crop_ext_flat (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Crop. This is only used when no rotate/flip is requested with the crop. - * Extension: The destination width is larger than the source and we fill in - * the extra area with the DC of the adjacent block. Note we also have to - * fill partial iMCUs at the right and bottom edge of the source image area - * in this case. - */ -{ - JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height; - JDIMENSION dst_blk_x, dst_blk_y, x_crop_blocks, y_crop_blocks; - int ci, offset_y; - JCOEF dc; - JBLOCKARRAY src_buffer, dst_buffer; - jpeg_component_info *compptr; - - MCU_cols = srcinfo->output_width / - (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); - MCU_rows = srcinfo->output_height / - (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - comp_height = MCU_rows * compptr->v_samp_factor; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - y_crop_blocks = y_crop_offset * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - if (dstinfo->jpeg_height > srcinfo->output_height) { - if (dst_blk_y < y_crop_blocks || - dst_blk_y >= y_crop_blocks + comp_height) { - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - FMEMZERO(dst_buffer[offset_y], - compptr->width_in_blocks * SIZEOF(JBLOCK)); - } - continue; - } - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_y - y_crop_blocks, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } else { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_y + y_crop_blocks, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - if (x_crop_blocks > 0) { - FMEMZERO(dst_buffer[offset_y], - x_crop_blocks * SIZEOF(JBLOCK)); - dc = src_buffer[offset_y][0][0]; - for (dst_blk_x = 0; dst_blk_x < x_crop_blocks; dst_blk_x++) { - dst_buffer[offset_y][dst_blk_x][0] = dc; - } - } - jcopy_block_row(src_buffer[offset_y], - dst_buffer[offset_y] + x_crop_blocks, - comp_width); - if (compptr->width_in_blocks > x_crop_blocks + comp_width) { - FMEMZERO(dst_buffer[offset_y] + - x_crop_blocks + comp_width, - (compptr->width_in_blocks - - x_crop_blocks - comp_width) * SIZEOF(JBLOCK)); - dc = src_buffer[offset_y][comp_width - 1][0]; - for (dst_blk_x = x_crop_blocks + comp_width; - dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { - dst_buffer[offset_y][dst_blk_x][0] = dc; - } - } - } - } - } -} - - -LOCAL(void) -do_crop_ext_reflect (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Crop. This is only used when no rotate/flip is requested with the crop. - * Extension: The destination width is larger than the source and we fill in - * the extra area with repeated reflections of the source region. Note we - * also have to fill partial iMCUs at the right and bottom edge of the source - * image area in this case. - */ -{ - JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, src_blk_x; - JDIMENSION dst_blk_x, dst_blk_y, x_crop_blocks, y_crop_blocks; - int ci, k, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JBLOCKROW src_row_ptr, dst_row_ptr; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - MCU_cols = srcinfo->output_width / - (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); - MCU_rows = srcinfo->output_height / - (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - comp_height = MCU_rows * compptr->v_samp_factor; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - y_crop_blocks = y_crop_offset * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - if (dstinfo->jpeg_height > srcinfo->output_height) { - if (dst_blk_y < y_crop_blocks || - dst_blk_y >= y_crop_blocks + comp_height) { - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - FMEMZERO(dst_buffer[offset_y], - compptr->width_in_blocks * SIZEOF(JBLOCK)); - } - continue; - } - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_y - y_crop_blocks, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } else { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_y + y_crop_blocks, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - /* Copy source region */ - jcopy_block_row(src_buffer[offset_y], - dst_buffer[offset_y] + x_crop_blocks, - comp_width); - if (x_crop_blocks > 0) { - /* Reflect to left */ - dst_row_ptr = dst_buffer[offset_y] + x_crop_blocks; - for (dst_blk_x = x_crop_blocks; dst_blk_x > 0;) { - src_row_ptr = dst_row_ptr; /* (re)set axis of reflection */ - for (src_blk_x = comp_width; src_blk_x > 0 && dst_blk_x > 0; - src_blk_x--, dst_blk_x--) { - dst_ptr = *--dst_row_ptr; /* destination goes left */ - src_ptr = *src_row_ptr++; /* source goes right */ - /* this unrolled loop doesn't need to know which row it's on... */ - for (k = 0; k < DCTSIZE2; k += 2) { - *dst_ptr++ = *src_ptr++; /* copy even column */ - *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */ - } - } - } - } - if (compptr->width_in_blocks > x_crop_blocks + comp_width) { - /* Reflect to right */ - dst_row_ptr = dst_buffer[offset_y] + x_crop_blocks + comp_width; - for (dst_blk_x = compptr->width_in_blocks - x_crop_blocks - comp_width; - dst_blk_x > 0;) { - src_row_ptr = dst_row_ptr; /* (re)set axis of reflection */ - for (src_blk_x = comp_width; src_blk_x > 0 && dst_blk_x > 0; - src_blk_x--, dst_blk_x--) { - dst_ptr = *dst_row_ptr++; /* destination goes right */ - src_ptr = *--src_row_ptr; /* source goes left */ - /* this unrolled loop doesn't need to know which row it's on... */ - for (k = 0; k < DCTSIZE2; k += 2) { - *dst_ptr++ = *src_ptr++; /* copy even column */ - *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */ - } - } - } - } - } - } - } -} - - -LOCAL(void) -do_wipe (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - JDIMENSION drop_width, JDIMENSION drop_height) -/* Wipe - drop content of specified area, fill with zero (neutral gray) */ -{ - JDIMENSION x_wipe_blocks, wipe_width; - JDIMENSION y_wipe_blocks, wipe_bottom; - int ci, offset_y; - JBLOCKARRAY buffer; - jpeg_component_info *compptr; - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - x_wipe_blocks = x_crop_offset * compptr->h_samp_factor; - wipe_width = drop_width * compptr->h_samp_factor; - y_wipe_blocks = y_crop_offset * compptr->v_samp_factor; - wipe_bottom = drop_height * compptr->v_samp_factor + y_wipe_blocks; - for (; y_wipe_blocks < wipe_bottom; - y_wipe_blocks += compptr->v_samp_factor) { - buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], y_wipe_blocks, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - FMEMZERO(buffer[offset_y] + x_wipe_blocks, - wipe_width * SIZEOF(JBLOCK)); - } - } - } -} - - -LOCAL(void) -do_flatten (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - JDIMENSION drop_width, JDIMENSION drop_height) -/* Flatten - drop content of specified area, similar to wipe, - * but fill with average of adjacent blocks, instead of zero. - */ -{ - JDIMENSION x_wipe_blocks, wipe_width, wipe_right; - JDIMENSION y_wipe_blocks, wipe_bottom, blk_x; - int ci, offset_y, dc_left_value, dc_right_value, average; - JBLOCKARRAY buffer; - jpeg_component_info *compptr; - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - x_wipe_blocks = x_crop_offset * compptr->h_samp_factor; - wipe_width = drop_width * compptr->h_samp_factor; - wipe_right = wipe_width + x_wipe_blocks; - y_wipe_blocks = y_crop_offset * compptr->v_samp_factor; - wipe_bottom = drop_height * compptr->v_samp_factor + y_wipe_blocks; - for (; y_wipe_blocks < wipe_bottom; - y_wipe_blocks += compptr->v_samp_factor) { - buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], y_wipe_blocks, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - FMEMZERO(buffer[offset_y] + x_wipe_blocks, - wipe_width * SIZEOF(JBLOCK)); - if (x_wipe_blocks > 0) { - dc_left_value = buffer[offset_y][x_wipe_blocks - 1][0]; - if (wipe_right < compptr->width_in_blocks) { - dc_right_value = buffer[offset_y][wipe_right][0]; - average = (dc_left_value + dc_right_value) >> 1; - } else { - average = dc_left_value; - } - } else if (wipe_right < compptr->width_in_blocks) { - average = buffer[offset_y][wipe_right][0]; - } else continue; - for (blk_x = x_wipe_blocks; blk_x < wipe_right; blk_x++) { - buffer[offset_y][blk_x][0] = (JCOEF) average; - } - } - } - } -} - - -LOCAL(void) -do_reflect (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - JDIMENSION drop_width, JDIMENSION drop_height) -/* Reflect - drop content of specified area, similar to wipe, but - * fill with repeated reflections of the outside area, instead of zero. - * NB: y_crop_offset is assumed to be zero. - */ -{ - JDIMENSION x_wipe_blocks, wipe_width; - JDIMENSION y_wipe_blocks, wipe_bottom; - JDIMENSION src_blk_x, dst_blk_x; - int ci, k, offset_y; - JBLOCKARRAY buffer; - JBLOCKROW src_row_ptr, dst_row_ptr; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - x_wipe_blocks = x_crop_offset * compptr->h_samp_factor; - wipe_width = drop_width * compptr->h_samp_factor; - wipe_bottom = drop_height * compptr->v_samp_factor; - for (y_wipe_blocks = 0; y_wipe_blocks < wipe_bottom; - y_wipe_blocks += compptr->v_samp_factor) { - buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], y_wipe_blocks, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - if (x_wipe_blocks > 0) { - /* Reflect from left */ - dst_row_ptr = buffer[offset_y] + x_wipe_blocks; - for (dst_blk_x = wipe_width; dst_blk_x > 0;) { - src_row_ptr = dst_row_ptr; /* (re)set axis of reflection */ - for (src_blk_x = x_wipe_blocks; - src_blk_x > 0 && dst_blk_x > 0; src_blk_x--, dst_blk_x--) { - dst_ptr = *dst_row_ptr++; /* destination goes right */ - src_ptr = *--src_row_ptr; /* source goes left */ - /* this unrolled loop doesn't need to know which row it's on... */ - for (k = 0; k < DCTSIZE2; k += 2) { - *dst_ptr++ = *src_ptr++; /* copy even column */ - *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */ - } - } - } - } else if (compptr->width_in_blocks > x_wipe_blocks + wipe_width) { - /* Reflect from right */ - dst_row_ptr = buffer[offset_y] + x_wipe_blocks + wipe_width; - for (dst_blk_x = wipe_width; dst_blk_x > 0;) { - src_row_ptr = dst_row_ptr; /* (re)set axis of reflection */ - src_blk_x = compptr->width_in_blocks - x_wipe_blocks - wipe_width; - for (; src_blk_x > 0 && dst_blk_x > 0; src_blk_x--, dst_blk_x--) { - dst_ptr = *--dst_row_ptr; /* destination goes left */ - src_ptr = *src_row_ptr++; /* source goes right */ - /* this unrolled loop doesn't need to know which row it's on... */ - for (k = 0; k < DCTSIZE2; k += 2) { - *dst_ptr++ = *src_ptr++; /* copy even column */ - *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */ - } - } - } - } else { - FMEMZERO(buffer[offset_y] + x_wipe_blocks, - wipe_width * SIZEOF(JBLOCK)); - } - } - } - } -} - - -LOCAL(void) -do_flip_h_no_crop (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, - jvirt_barray_ptr *src_coef_arrays) -/* Horizontal flip; done in-place, so no separate dest array is required. - * NB: this only works when y_crop_offset is zero. - */ -{ - JDIMENSION MCU_cols, comp_width, blk_x, blk_y, x_crop_blocks; - int ci, k, offset_y; - JBLOCKARRAY buffer; - JCOEFPTR ptr1, ptr2; - JCOEF temp1, temp2; - jpeg_component_info *compptr; - - /* Horizontal mirroring of DCT blocks is accomplished by swapping - * pairs of blocks in-place. Within a DCT block, we perform horizontal - * mirroring by changing the signs of odd-numbered columns. - * Partial iMCUs at the right edge are left untouched. - */ - MCU_cols = srcinfo->output_width / - (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - for (blk_y = 0; blk_y < compptr->height_in_blocks; - blk_y += compptr->v_samp_factor) { - buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - /* Do the mirroring */ - for (blk_x = 0; blk_x * 2 < comp_width; blk_x++) { - ptr1 = buffer[offset_y][blk_x]; - ptr2 = buffer[offset_y][comp_width - blk_x - 1]; - /* this unrolled loop doesn't need to know which row it's on... */ - for (k = 0; k < DCTSIZE2; k += 2) { - temp1 = *ptr1; /* swap even column */ - temp2 = *ptr2; - *ptr1++ = temp2; - *ptr2++ = temp1; - temp1 = *ptr1; /* swap odd column with sign change */ - temp2 = *ptr2; - *ptr1++ = -temp2; - *ptr2++ = -temp1; - } - } - if (x_crop_blocks > 0) { - /* Now left-justify the portion of the data to be kept. - * We can't use a single jcopy_block_row() call because that routine - * depends on memcpy(), whose behavior is unspecified for overlapping - * source and destination areas. Sigh. - */ - for (blk_x = 0; blk_x < compptr->width_in_blocks; blk_x++) { - jcopy_block_row(buffer[offset_y] + blk_x + x_crop_blocks, - buffer[offset_y] + blk_x, - (JDIMENSION) 1); - } - } - } - } - } -} - - -LOCAL(void) -do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Horizontal flip in general cropping case */ -{ - JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; - JDIMENSION x_crop_blocks, y_crop_blocks; - int ci, k, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JBLOCKROW src_row_ptr, dst_row_ptr; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Here we must output into a separate array because we can't touch - * different rows of a single virtual array simultaneously. Otherwise, - * this is essentially the same as the routine above. - */ - MCU_cols = srcinfo->output_width / - (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - y_crop_blocks = y_crop_offset * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_y + y_crop_blocks, - (JDIMENSION) compptr->v_samp_factor, FALSE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - dst_row_ptr = dst_buffer[offset_y]; - src_row_ptr = src_buffer[offset_y]; - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { - if (x_crop_blocks + dst_blk_x < comp_width) { - /* Do the mirrorable blocks */ - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; - /* this unrolled loop doesn't need to know which row it's on... */ - for (k = 0; k < DCTSIZE2; k += 2) { - *dst_ptr++ = *src_ptr++; /* copy even column */ - *dst_ptr++ = - *src_ptr++; /* copy odd column with sign change */ - } - } else { - /* Copy last partial block(s) verbatim */ - jcopy_block_row(src_row_ptr + dst_blk_x + x_crop_blocks, - dst_row_ptr + dst_blk_x, - (JDIMENSION) 1); - } - } - } - } - } -} - - -LOCAL(void) -do_flip_v (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Vertical flip */ -{ - JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; - JDIMENSION x_crop_blocks, y_crop_blocks; - int ci, i, j, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JBLOCKROW src_row_ptr, dst_row_ptr; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* We output into a separate array because we can't touch different - * rows of the source virtual array simultaneously. Otherwise, this - * is a pretty straightforward analog of horizontal flip. - * Within a DCT block, vertical mirroring is done by changing the signs - * of odd-numbered rows. - * Partial iMCUs at the bottom edge are copied verbatim. - */ - MCU_rows = srcinfo->output_height / - (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_height = MCU_rows * compptr->v_samp_factor; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - y_crop_blocks = y_crop_offset * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - if (y_crop_blocks + dst_blk_y < comp_height) { - /* Row is within the mirrorable area. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - comp_height - y_crop_blocks - dst_blk_y - - (JDIMENSION) compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } else { - /* Bottom-edge blocks will be copied verbatim. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_y + y_crop_blocks, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - if (y_crop_blocks + dst_blk_y < comp_height) { - /* Row is within the mirrorable area. */ - dst_row_ptr = dst_buffer[offset_y]; - src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; - src_row_ptr += x_crop_blocks; - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[dst_blk_x]; - for (i = 0; i < DCTSIZE; i += 2) { - /* copy even row */ - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = *src_ptr++; - /* copy odd row with sign change */ - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = - *src_ptr++; - } - } - } else { - /* Just copy row verbatim. */ - jcopy_block_row(src_buffer[offset_y] + x_crop_blocks, - dst_buffer[offset_y], - compptr->width_in_blocks); - } - } - } - } -} - - -LOCAL(void) -do_transpose (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Transpose source into destination */ -{ - JDIMENSION dst_blk_x, dst_blk_y, x_crop_blocks, y_crop_blocks; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Transposing pixels within a block just requires transposing the - * DCT coefficients. - * Partial iMCUs at the edges require no special treatment; we simply - * process all the available DCT blocks for every component. - */ - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - y_crop_blocks = y_crop_offset * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_x + x_crop_blocks, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - src_ptr = src_buffer[offset_x][dst_blk_y + offset_y + y_crop_blocks]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } -} - - -LOCAL(void) -do_rot_90 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* 90 degree rotation is equivalent to - * 1. Transposing the image; - * 2. Horizontal mirroring. - * These two steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y; - JDIMENSION x_crop_blocks, y_crop_blocks; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Because of the horizontal mirror step, we can't process partial iMCUs - * at the (output) right edge properly. They just get transposed and - * not mirrored. - */ - MCU_cols = srcinfo->output_height / - (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - y_crop_blocks = y_crop_offset * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - if (x_crop_blocks + dst_blk_x < comp_width) { - /* Block is within the mirrorable area. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - comp_width - x_crop_blocks - dst_blk_x - - (JDIMENSION) compptr->h_samp_factor, - (JDIMENSION) compptr->h_samp_factor, FALSE); - } else { - /* Edge blocks are transposed but not mirrored. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_x + x_crop_blocks, - (JDIMENSION) compptr->h_samp_factor, FALSE); - } - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - if (x_crop_blocks + dst_blk_x < comp_width) { - /* Block is within the mirrorable area. */ - src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1] - [dst_blk_y + offset_y + y_crop_blocks]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - i++; - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } else { - /* Edge blocks are transposed but not mirrored. */ - src_ptr = src_buffer[offset_x] - [dst_blk_y + offset_y + y_crop_blocks]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } - } -} - - -LOCAL(void) -do_rot_270 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* 270 degree rotation is equivalent to - * 1. Horizontal mirroring; - * 2. Transposing the image. - * These two steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y; - JDIMENSION x_crop_blocks, y_crop_blocks; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - /* Because of the horizontal mirror step, we can't process partial iMCUs - * at the (output) bottom edge properly. They just get transposed and - * not mirrored. - */ - MCU_rows = srcinfo->output_width / - (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_height = MCU_rows * compptr->v_samp_factor; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - y_crop_blocks = y_crop_offset * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_x + x_crop_blocks, - (JDIMENSION) compptr->h_samp_factor, FALSE); - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - if (y_crop_blocks + dst_blk_y < comp_height) { - /* Block is within the mirrorable area. */ - src_ptr = src_buffer[offset_x] - [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } - } else { - /* Edge blocks are transposed but not mirrored. */ - src_ptr = src_buffer[offset_x] - [dst_blk_y + offset_y + y_crop_blocks]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } - } -} - - -LOCAL(void) -do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* 180 degree rotation is equivalent to - * 1. Vertical mirroring; - * 2. Horizontal mirroring. - * These two steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; - JDIMENSION x_crop_blocks, y_crop_blocks; - int ci, i, j, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JBLOCKROW src_row_ptr, dst_row_ptr; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - MCU_cols = srcinfo->output_width / - (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); - MCU_rows = srcinfo->output_height / - (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - comp_height = MCU_rows * compptr->v_samp_factor; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - y_crop_blocks = y_crop_offset * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - if (y_crop_blocks + dst_blk_y < comp_height) { - /* Row is within the vertically mirrorable area. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - comp_height - y_crop_blocks - dst_blk_y - - (JDIMENSION) compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } else { - /* Bottom-edge rows are only mirrored horizontally. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_y + y_crop_blocks, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - dst_row_ptr = dst_buffer[offset_y]; - if (y_crop_blocks + dst_blk_y < comp_height) { - /* Row is within the mirrorable area. */ - src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1]; - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { - dst_ptr = dst_row_ptr[dst_blk_x]; - if (x_crop_blocks + dst_blk_x < comp_width) { - /* Process the blocks that can be mirrored both ways. */ - src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; - for (i = 0; i < DCTSIZE; i += 2) { - /* For even row, negate every odd column. */ - for (j = 0; j < DCTSIZE; j += 2) { - *dst_ptr++ = *src_ptr++; - *dst_ptr++ = - *src_ptr++; - } - /* For odd row, negate every even column. */ - for (j = 0; j < DCTSIZE; j += 2) { - *dst_ptr++ = - *src_ptr++; - *dst_ptr++ = *src_ptr++; - } - } - } else { - /* Any remaining right-edge blocks are only mirrored vertically. */ - src_ptr = src_row_ptr[x_crop_blocks + dst_blk_x]; - for (i = 0; i < DCTSIZE; i += 2) { - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = *src_ptr++; - for (j = 0; j < DCTSIZE; j++) - *dst_ptr++ = - *src_ptr++; - } - } - } - } else { - /* Remaining rows are just mirrored horizontally. */ - src_row_ptr = src_buffer[offset_y]; - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) { - if (x_crop_blocks + dst_blk_x < comp_width) { - /* Process the blocks that can be mirrored. */ - dst_ptr = dst_row_ptr[dst_blk_x]; - src_ptr = src_row_ptr[comp_width - x_crop_blocks - dst_blk_x - 1]; - for (i = 0; i < DCTSIZE2; i += 2) { - *dst_ptr++ = *src_ptr++; - *dst_ptr++ = - *src_ptr++; - } - } else { - /* Any remaining right-edge blocks are only copied. */ - jcopy_block_row(src_row_ptr + dst_blk_x + x_crop_blocks, - dst_row_ptr + dst_blk_x, - (JDIMENSION) 1); - } - } - } - } - } - } -} - - -LOCAL(void) -do_transverse (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JDIMENSION x_crop_offset, JDIMENSION y_crop_offset, - jvirt_barray_ptr *src_coef_arrays, - jvirt_barray_ptr *dst_coef_arrays) -/* Transverse transpose is equivalent to - * 1. 180 degree rotation; - * 2. Transposition; - * or - * 1. Horizontal mirroring; - * 2. Transposition; - * 3. Horizontal mirroring. - * These steps are merged into a single processing routine. - */ -{ - JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y; - JDIMENSION x_crop_blocks, y_crop_blocks; - int ci, i, j, offset_x, offset_y; - JBLOCKARRAY src_buffer, dst_buffer; - JCOEFPTR src_ptr, dst_ptr; - jpeg_component_info *compptr; - - MCU_cols = srcinfo->output_height / - (dstinfo->max_h_samp_factor * dstinfo->min_DCT_h_scaled_size); - MCU_rows = srcinfo->output_width / - (dstinfo->max_v_samp_factor * dstinfo->min_DCT_v_scaled_size); - - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - comp_width = MCU_cols * compptr->h_samp_factor; - comp_height = MCU_rows * compptr->v_samp_factor; - x_crop_blocks = x_crop_offset * compptr->h_samp_factor; - y_crop_blocks = y_crop_offset * compptr->v_samp_factor; - for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks; - dst_blk_y += compptr->v_samp_factor) { - dst_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y, - (JDIMENSION) compptr->v_samp_factor, TRUE); - for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { - for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks; - dst_blk_x += compptr->h_samp_factor) { - if (x_crop_blocks + dst_blk_x < comp_width) { - /* Block is within the mirrorable area. */ - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - comp_width - x_crop_blocks - dst_blk_x - - (JDIMENSION) compptr->h_samp_factor, - (JDIMENSION) compptr->h_samp_factor, FALSE); - } else { - src_buffer = (*srcinfo->mem->access_virt_barray) - ((j_common_ptr) srcinfo, src_coef_arrays[ci], - dst_blk_x + x_crop_blocks, - (JDIMENSION) compptr->h_samp_factor, FALSE); - } - for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) { - dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x]; - if (y_crop_blocks + dst_blk_y < comp_height) { - if (x_crop_blocks + dst_blk_x < comp_width) { - /* Block is within the mirrorable area. */ - src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1] - [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - i++; - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } else { - /* Right-edge blocks are mirrored in y only */ - src_ptr = src_buffer[offset_x] - [comp_height - y_crop_blocks - dst_blk_y - offset_y - 1]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) { - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - j++; - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } - } - } else { - if (x_crop_blocks + dst_blk_x < comp_width) { - /* Bottom-edge blocks are mirrored in x only */ - src_ptr = src_buffer[compptr->h_samp_factor - offset_x - 1] - [dst_blk_y + offset_y + y_crop_blocks]; - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - i++; - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j]; - } - } else { - /* At lower right corner, just transpose, no mirroring */ - src_ptr = src_buffer[offset_x] - [dst_blk_y + offset_y + y_crop_blocks]; - for (i = 0; i < DCTSIZE; i++) - for (j = 0; j < DCTSIZE; j++) - dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j]; - } - } - } - } - } - } - } -} - - -/* Parse an unsigned integer: subroutine for jtransform_parse_crop_spec. - * Returns TRUE if valid integer found, FALSE if not. - * *strptr is advanced over the digit string, and *result is set to its value. - */ - -LOCAL(boolean) -jt_read_integer (const char ** strptr, JDIMENSION * result) -{ - const char * ptr = *strptr; - JDIMENSION val = 0; - - for (; isdigit(*ptr); ptr++) { - val = val * 10 + (JDIMENSION) (*ptr - '0'); - } - *result = val; - if (ptr == *strptr) - return FALSE; /* oops, no digits */ - *strptr = ptr; - return TRUE; -} - - -/* Parse a crop specification (written in X11 geometry style). - * The routine returns TRUE if the spec string is valid, FALSE if not. - * - * The crop spec string should have the format - * [{fr}]x[{fr}]{+-}{+-} - * where width, height, xoffset, and yoffset are unsigned integers. - * Each of the elements can be omitted to indicate a default value. - * (A weakness of this style is that it is not possible to omit xoffset - * while specifying yoffset, since they look alike.) - * - * This code is loosely based on XParseGeometry from the X11 distribution. - */ - -GLOBAL(boolean) -jtransform_parse_crop_spec (jpeg_transform_info *info, const char *spec) -{ - info->crop = FALSE; - info->crop_width_set = JCROP_UNSET; - info->crop_height_set = JCROP_UNSET; - info->crop_xoffset_set = JCROP_UNSET; - info->crop_yoffset_set = JCROP_UNSET; - - if (isdigit(*spec)) { - /* fetch width */ - if (! jt_read_integer(&spec, &info->crop_width)) - return FALSE; - if (*spec == 'f' || *spec == 'F') { - spec++; - info->crop_width_set = JCROP_FORCE; - } else if (*spec == 'r' || *spec == 'R') { - spec++; - info->crop_width_set = JCROP_REFLECT; - } else - info->crop_width_set = JCROP_POS; - } - if (*spec == 'x' || *spec == 'X') { - /* fetch height */ - spec++; - if (! jt_read_integer(&spec, &info->crop_height)) - return FALSE; - if (*spec == 'f' || *spec == 'F') { - spec++; - info->crop_height_set = JCROP_FORCE; - } else if (*spec == 'r' || *spec == 'R') { - spec++; - info->crop_height_set = JCROP_REFLECT; - } else - info->crop_height_set = JCROP_POS; - } - if (*spec == '+' || *spec == '-') { - /* fetch xoffset */ - info->crop_xoffset_set = (*spec == '-') ? JCROP_NEG : JCROP_POS; - spec++; - if (! jt_read_integer(&spec, &info->crop_xoffset)) - return FALSE; - } - if (*spec == '+' || *spec == '-') { - /* fetch yoffset */ - info->crop_yoffset_set = (*spec == '-') ? JCROP_NEG : JCROP_POS; - spec++; - if (! jt_read_integer(&spec, &info->crop_yoffset)) - return FALSE; - } - /* We had better have gotten to the end of the string. */ - if (*spec != '\0') - return FALSE; - info->crop = TRUE; - return TRUE; -} - - -/* Trim off any partial iMCUs on the indicated destination edge */ - -LOCAL(void) -trim_right_edge (jpeg_transform_info *info, JDIMENSION full_width) -{ - JDIMENSION MCU_cols; - - MCU_cols = info->output_width / info->iMCU_sample_width; - if (MCU_cols > 0 && info->x_crop_offset + MCU_cols == - full_width / info->iMCU_sample_width) - info->output_width = MCU_cols * info->iMCU_sample_width; -} - -LOCAL(void) -trim_bottom_edge (jpeg_transform_info *info, JDIMENSION full_height) -{ - JDIMENSION MCU_rows; - - MCU_rows = info->output_height / info->iMCU_sample_height; - if (MCU_rows > 0 && info->y_crop_offset + MCU_rows == - full_height / info->iMCU_sample_height) - info->output_height = MCU_rows * info->iMCU_sample_height; -} - - -/* Request any required workspace. - * - * This routine figures out the size that the output image will be - * (which implies that all the transform parameters must be set before - * it is called). - * - * We allocate the workspace virtual arrays from the source decompression - * object, so that all the arrays (both the original data and the workspace) - * will be taken into account while making memory management decisions. - * Hence, this routine must be called after jpeg_read_header (which reads - * the image dimensions) and before jpeg_read_coefficients (which realizes - * the source's virtual arrays). - * - * This function returns FALSE right away if -perfect is given - * and transformation is not perfect. Otherwise returns TRUE. - */ - -GLOBAL(boolean) -jtransform_request_workspace (j_decompress_ptr srcinfo, - jpeg_transform_info *info) -{ - jvirt_barray_ptr *coef_arrays; - boolean need_workspace, transpose_it; - jpeg_component_info *compptr; - JDIMENSION xoffset, yoffset, dtemp; - JDIMENSION width_in_iMCUs, height_in_iMCUs; - JDIMENSION width_in_blocks, height_in_blocks; - int itemp, ci, h_samp_factor, v_samp_factor; - - /* Determine number of components in output image */ - if (info->force_grayscale && - (srcinfo->jpeg_color_space == JCS_YCbCr || - srcinfo->jpeg_color_space == JCS_BG_YCC) && - srcinfo->num_components == 3) - /* We'll only process the first component */ - info->num_components = 1; - else - /* Process all the components */ - info->num_components = srcinfo->num_components; - - /* Compute output image dimensions and related values. */ - jpeg_core_output_dimensions(srcinfo); - - /* Return right away if -perfect is given and transformation is not perfect. - */ - if (info->perfect) { - if (info->num_components == 1) { - if (!jtransform_perfect_transform(srcinfo->output_width, - srcinfo->output_height, - srcinfo->min_DCT_h_scaled_size, - srcinfo->min_DCT_v_scaled_size, - info->transform)) - return FALSE; - } else { - if (!jtransform_perfect_transform(srcinfo->output_width, - srcinfo->output_height, - srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size, - srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size, - info->transform)) - return FALSE; - } - } - - /* If there is only one output component, force the iMCU size to be 1; - * else use the source iMCU size. (This allows us to do the right thing - * when reducing color to grayscale, and also provides a handy way of - * cleaning up "funny" grayscale images whose sampling factors are not 1x1.) - */ - switch (info->transform) { - case JXFORM_TRANSPOSE: - case JXFORM_TRANSVERSE: - case JXFORM_ROT_90: - case JXFORM_ROT_270: - info->output_width = srcinfo->output_height; - info->output_height = srcinfo->output_width; - if (info->num_components == 1) { - info->iMCU_sample_width = srcinfo->min_DCT_v_scaled_size; - info->iMCU_sample_height = srcinfo->min_DCT_h_scaled_size; - } else { - info->iMCU_sample_width = - srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size; - info->iMCU_sample_height = - srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size; - } - break; - default: - info->output_width = srcinfo->output_width; - info->output_height = srcinfo->output_height; - if (info->num_components == 1) { - info->iMCU_sample_width = srcinfo->min_DCT_h_scaled_size; - info->iMCU_sample_height = srcinfo->min_DCT_v_scaled_size; - } else { - info->iMCU_sample_width = - srcinfo->max_h_samp_factor * srcinfo->min_DCT_h_scaled_size; - info->iMCU_sample_height = - srcinfo->max_v_samp_factor * srcinfo->min_DCT_v_scaled_size; - } - } - - /* If cropping has been requested, compute the crop area's position and - * dimensions, ensuring that its upper left corner falls at an iMCU boundary. - */ - if (info->crop) { - /* Insert default values for unset crop parameters */ - if (info->crop_xoffset_set == JCROP_UNSET) - info->crop_xoffset = 0; /* default to +0 */ - if (info->crop_yoffset_set == JCROP_UNSET) - info->crop_yoffset = 0; /* default to +0 */ - if (info->crop_width_set == JCROP_UNSET) { - if (info->crop_xoffset >= info->output_width) - ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); - info->crop_width = info->output_width - info->crop_xoffset; - } else { - /* Check for crop extension */ - if (info->crop_width > info->output_width) { - /* Crop extension does not work when transforming! */ - if (info->transform != JXFORM_NONE || - info->crop_xoffset >= info->crop_width || - info->crop_xoffset > info->crop_width - info->output_width) - ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); - } else { - if (info->crop_xoffset >= info->output_width || - info->crop_width <= 0 || - info->crop_xoffset > info->output_width - info->crop_width) - ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); - } - } - if (info->crop_height_set == JCROP_UNSET) { - if (info->crop_yoffset >= info->output_height) - ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); - info->crop_height = info->output_height - info->crop_yoffset; - } else { - /* Check for crop extension */ - if (info->crop_height > info->output_height) { - /* Crop extension does not work when transforming! */ - if (info->transform != JXFORM_NONE || - info->crop_yoffset >= info->crop_height || - info->crop_yoffset > info->crop_height - info->output_height) - ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); - } else { - if (info->crop_yoffset >= info->output_height || - info->crop_height <= 0 || - info->crop_yoffset > info->output_height - info->crop_height) - ERREXIT(srcinfo, JERR_BAD_CROP_SPEC); - } - } - /* Convert negative crop offsets into regular offsets */ - if (info->crop_xoffset_set != JCROP_NEG) - xoffset = info->crop_xoffset; - else if (info->crop_width > info->output_width) /* crop extension */ - xoffset = info->crop_width - info->output_width - info->crop_xoffset; - else - xoffset = info->output_width - info->crop_width - info->crop_xoffset; - if (info->crop_yoffset_set != JCROP_NEG) - yoffset = info->crop_yoffset; - else if (info->crop_height > info->output_height) /* crop extension */ - yoffset = info->crop_height - info->output_height - info->crop_yoffset; - else - yoffset = info->output_height - info->crop_height - info->crop_yoffset; - /* Now adjust so that upper left corner falls at an iMCU boundary */ - switch (info->transform) { - case JXFORM_DROP: - /* Ensure the effective drop region will not exceed the requested */ - itemp = info->iMCU_sample_width; - dtemp = itemp - 1 - ((xoffset + itemp - 1) % itemp); - xoffset += dtemp; - if (info->crop_width <= dtemp) - info->drop_width = 0; - else if (xoffset + info->crop_width - dtemp == info->output_width) - /* Matching right edge: include partial iMCU */ - info->drop_width = (info->crop_width - dtemp + itemp - 1) / itemp; - else - info->drop_width = (info->crop_width - dtemp) / itemp; - itemp = info->iMCU_sample_height; - dtemp = itemp - 1 - ((yoffset + itemp - 1) % itemp); - yoffset += dtemp; - if (info->crop_height <= dtemp) - info->drop_height = 0; - else if (yoffset + info->crop_height - dtemp == info->output_height) - /* Matching bottom edge: include partial iMCU */ - info->drop_height = (info->crop_height - dtemp + itemp - 1) / itemp; - else - info->drop_height = (info->crop_height - dtemp) / itemp; - /* Check if sampling factors match for dropping */ - if (info->drop_width != 0 && info->drop_height != 0) - for (ci = 0; ci < info->num_components && - ci < info->drop_ptr->num_components; ci++) { - if (info->drop_ptr->comp_info[ci].h_samp_factor * - srcinfo->max_h_samp_factor != - srcinfo->comp_info[ci].h_samp_factor * - info->drop_ptr->max_h_samp_factor) - ERREXIT6(srcinfo, JERR_BAD_DROP_SAMPLING, ci, - info->drop_ptr->comp_info[ci].h_samp_factor, - info->drop_ptr->max_h_samp_factor, - srcinfo->comp_info[ci].h_samp_factor, - srcinfo->max_h_samp_factor, 'h'); - if (info->drop_ptr->comp_info[ci].v_samp_factor * - srcinfo->max_v_samp_factor != - srcinfo->comp_info[ci].v_samp_factor * - info->drop_ptr->max_v_samp_factor) - ERREXIT6(srcinfo, JERR_BAD_DROP_SAMPLING, ci, - info->drop_ptr->comp_info[ci].v_samp_factor, - info->drop_ptr->max_v_samp_factor, - srcinfo->comp_info[ci].v_samp_factor, - srcinfo->max_v_samp_factor, 'v'); - } - break; - case JXFORM_WIPE: - /* Ensure the effective wipe region will cover the requested */ - info->drop_width = (JDIMENSION) jdiv_round_up - ((long) (info->crop_width + (xoffset % info->iMCU_sample_width)), - (long) info->iMCU_sample_width); - info->drop_height = (JDIMENSION) jdiv_round_up - ((long) (info->crop_height + (yoffset % info->iMCU_sample_height)), - (long) info->iMCU_sample_height); - break; - default: - /* Ensure the effective crop region will cover the requested */ - if (info->crop_width_set == JCROP_FORCE || - info->crop_width > info->output_width) - info->output_width = info->crop_width; - else - info->output_width = - info->crop_width + (xoffset % info->iMCU_sample_width); - if (info->crop_height_set == JCROP_FORCE || - info->crop_height > info->output_height) - info->output_height = info->crop_height; - else - info->output_height = - info->crop_height + (yoffset % info->iMCU_sample_height); - } - /* Save x/y offsets measured in iMCUs */ - info->x_crop_offset = xoffset / info->iMCU_sample_width; - info->y_crop_offset = yoffset / info->iMCU_sample_height; - } else { - info->x_crop_offset = 0; - info->y_crop_offset = 0; - } - - /* Figure out whether we need workspace arrays, - * and if so whether they are transposed relative to the source. - */ - need_workspace = FALSE; - transpose_it = FALSE; - switch (info->transform) { - case JXFORM_NONE: - if (info->x_crop_offset != 0 || info->y_crop_offset != 0 || - info->output_width > srcinfo->output_width || - info->output_height > srcinfo->output_height) - need_workspace = TRUE; - /* No workspace needed if neither cropping nor transforming */ - break; - case JXFORM_FLIP_H: - if (info->trim) - trim_right_edge(info, srcinfo->output_width); - if (info->y_crop_offset != 0) - need_workspace = TRUE; - /* do_flip_h_no_crop doesn't need a workspace array */ - break; - case JXFORM_FLIP_V: - if (info->trim) - trim_bottom_edge(info, srcinfo->output_height); - /* Need workspace arrays having same dimensions as source image. */ - need_workspace = TRUE; - break; - case JXFORM_TRANSPOSE: - /* transpose does NOT have to trim anything */ - /* Need workspace arrays having transposed dimensions. */ - need_workspace = TRUE; - transpose_it = TRUE; - break; - case JXFORM_TRANSVERSE: - if (info->trim) { - trim_right_edge(info, srcinfo->output_height); - trim_bottom_edge(info, srcinfo->output_width); - } - /* Need workspace arrays having transposed dimensions. */ - need_workspace = TRUE; - transpose_it = TRUE; - break; - case JXFORM_ROT_90: - if (info->trim) - trim_right_edge(info, srcinfo->output_height); - /* Need workspace arrays having transposed dimensions. */ - need_workspace = TRUE; - transpose_it = TRUE; - break; - case JXFORM_ROT_180: - if (info->trim) { - trim_right_edge(info, srcinfo->output_width); - trim_bottom_edge(info, srcinfo->output_height); - } - /* Need workspace arrays having same dimensions as source image. */ - need_workspace = TRUE; - break; - case JXFORM_ROT_270: - if (info->trim) - trim_bottom_edge(info, srcinfo->output_width); - /* Need workspace arrays having transposed dimensions. */ - need_workspace = TRUE; - transpose_it = TRUE; - break; - case JXFORM_WIPE: - break; - case JXFORM_DROP: -#if DROP_REQUEST_FROM_SRC - drop_request_from_src(info->drop_ptr, srcinfo); -#endif - break; - } - - /* Allocate workspace if needed. - * Note that we allocate arrays padded out to the next iMCU boundary, - * so that transform routines need not worry about missing edge blocks. - */ - if (need_workspace) { - coef_arrays = (jvirt_barray_ptr *) (*srcinfo->mem->alloc_small) - ((j_common_ptr) srcinfo, JPOOL_IMAGE, - SIZEOF(jvirt_barray_ptr) * info->num_components); - width_in_iMCUs = (JDIMENSION) jdiv_round_up - ((long) info->output_width, (long) info->iMCU_sample_width); - height_in_iMCUs = (JDIMENSION) jdiv_round_up - ((long) info->output_height, (long) info->iMCU_sample_height); - for (ci = 0; ci < info->num_components; ci++) { - compptr = srcinfo->comp_info + ci; - if (info->num_components == 1) { - /* we're going to force samp factors to 1x1 in this case */ - h_samp_factor = v_samp_factor = 1; - } else if (transpose_it) { - h_samp_factor = compptr->v_samp_factor; - v_samp_factor = compptr->h_samp_factor; - } else { - h_samp_factor = compptr->h_samp_factor; - v_samp_factor = compptr->v_samp_factor; - } - width_in_blocks = width_in_iMCUs * h_samp_factor; - height_in_blocks = height_in_iMCUs * v_samp_factor; - coef_arrays[ci] = (*srcinfo->mem->request_virt_barray) - ((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE, - width_in_blocks, height_in_blocks, (JDIMENSION) v_samp_factor); - } - info->workspace_coef_arrays = coef_arrays; - } else - info->workspace_coef_arrays = NULL; - - return TRUE; -} - - -/* Transpose destination image parameters */ - -LOCAL(void) -transpose_critical_parameters (j_compress_ptr dstinfo) -{ - int tblno, i, j, ci, itemp; - jpeg_component_info *compptr; - JQUANT_TBL *qtblptr; - JDIMENSION jtemp; - UINT16 qtemp; - - /* Transpose image dimensions */ - jtemp = dstinfo->image_width; - dstinfo->image_width = dstinfo->image_height; - dstinfo->image_height = jtemp; - itemp = dstinfo->min_DCT_h_scaled_size; - dstinfo->min_DCT_h_scaled_size = dstinfo->min_DCT_v_scaled_size; - dstinfo->min_DCT_v_scaled_size = itemp; - - /* Transpose sampling factors */ - for (ci = 0; ci < dstinfo->num_components; ci++) { - compptr = dstinfo->comp_info + ci; - itemp = compptr->h_samp_factor; - compptr->h_samp_factor = compptr->v_samp_factor; - compptr->v_samp_factor = itemp; - } - - /* Transpose quantization tables */ - for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { - qtblptr = dstinfo->quant_tbl_ptrs[tblno]; - if (qtblptr != NULL) { - for (i = 0; i < DCTSIZE; i++) { - for (j = 0; j < i; j++) { - qtemp = qtblptr->quantval[i*DCTSIZE+j]; - qtblptr->quantval[i*DCTSIZE+j] = qtblptr->quantval[j*DCTSIZE+i]; - qtblptr->quantval[j*DCTSIZE+i] = qtemp; - } - } - } - } -} - - -/* Adjust Exif image parameters. - * - * We try to adjust the Tags ExifImageWidth and ExifImageHeight if possible. - */ - -LOCAL(void) -adjust_exif_parameters (JOCTET FAR * data, unsigned int length, - JDIMENSION new_width, JDIMENSION new_height) -{ - boolean is_motorola; /* Flag for byte order */ - unsigned int number_of_tags, tagnum; - unsigned int firstoffset, offset; - JDIMENSION new_value; - - if (length < 12) return; /* Length of an IFD entry */ - - /* Discover byte order */ - if (GETJOCTET(data[0]) == 0x49 && GETJOCTET(data[1]) == 0x49) - is_motorola = FALSE; - else if (GETJOCTET(data[0]) == 0x4D && GETJOCTET(data[1]) == 0x4D) - is_motorola = TRUE; - else - return; - - /* Check Tag Mark */ - if (is_motorola) { - if (GETJOCTET(data[2]) != 0) return; - if (GETJOCTET(data[3]) != 0x2A) return; - } else { - if (GETJOCTET(data[3]) != 0) return; - if (GETJOCTET(data[2]) != 0x2A) return; - } - - /* Get first IFD offset (offset to IFD0) */ - if (is_motorola) { - if (GETJOCTET(data[4]) != 0) return; - if (GETJOCTET(data[5]) != 0) return; - firstoffset = GETJOCTET(data[6]); - firstoffset <<= 8; - firstoffset += GETJOCTET(data[7]); - } else { - if (GETJOCTET(data[7]) != 0) return; - if (GETJOCTET(data[6]) != 0) return; - firstoffset = GETJOCTET(data[5]); - firstoffset <<= 8; - firstoffset += GETJOCTET(data[4]); - } - if (firstoffset > length - 2) return; /* check end of data segment */ - - /* Get the number of directory entries contained in this IFD */ - if (is_motorola) { - number_of_tags = GETJOCTET(data[firstoffset]); - number_of_tags <<= 8; - number_of_tags += GETJOCTET(data[firstoffset+1]); - } else { - number_of_tags = GETJOCTET(data[firstoffset+1]); - number_of_tags <<= 8; - number_of_tags += GETJOCTET(data[firstoffset]); - } - if (number_of_tags == 0) return; - firstoffset += 2; - - /* Search for ExifSubIFD offset Tag in IFD0 */ - for (;;) { - if (firstoffset > length - 12) return; /* check end of data segment */ - /* Get Tag number */ - if (is_motorola) { - tagnum = GETJOCTET(data[firstoffset]); - tagnum <<= 8; - tagnum += GETJOCTET(data[firstoffset+1]); - } else { - tagnum = GETJOCTET(data[firstoffset+1]); - tagnum <<= 8; - tagnum += GETJOCTET(data[firstoffset]); - } - if (tagnum == 0x8769) break; /* found ExifSubIFD offset Tag */ - if (--number_of_tags == 0) return; - firstoffset += 12; - } - - /* Get the ExifSubIFD offset */ - if (is_motorola) { - if (GETJOCTET(data[firstoffset+8]) != 0) return; - if (GETJOCTET(data[firstoffset+9]) != 0) return; - offset = GETJOCTET(data[firstoffset+10]); - offset <<= 8; - offset += GETJOCTET(data[firstoffset+11]); - } else { - if (GETJOCTET(data[firstoffset+11]) != 0) return; - if (GETJOCTET(data[firstoffset+10]) != 0) return; - offset = GETJOCTET(data[firstoffset+9]); - offset <<= 8; - offset += GETJOCTET(data[firstoffset+8]); - } - if (offset > length - 2) return; /* check end of data segment */ - - /* Get the number of directory entries contained in this SubIFD */ - if (is_motorola) { - number_of_tags = GETJOCTET(data[offset]); - number_of_tags <<= 8; - number_of_tags += GETJOCTET(data[offset+1]); - } else { - number_of_tags = GETJOCTET(data[offset+1]); - number_of_tags <<= 8; - number_of_tags += GETJOCTET(data[offset]); - } - if (number_of_tags < 2) return; - offset += 2; - - /* Search for ExifImageWidth and ExifImageHeight Tags in this SubIFD */ - do { - if (offset > length - 12) return; /* check end of data segment */ - /* Get Tag number */ - if (is_motorola) { - tagnum = GETJOCTET(data[offset]); - tagnum <<= 8; - tagnum += GETJOCTET(data[offset+1]); - } else { - tagnum = GETJOCTET(data[offset+1]); - tagnum <<= 8; - tagnum += GETJOCTET(data[offset]); - } - if (tagnum == 0xA002 || tagnum == 0xA003) { - if (tagnum == 0xA002) - new_value = new_width; /* ExifImageWidth Tag */ - else - new_value = new_height; /* ExifImageHeight Tag */ - if (is_motorola) { - data[offset+2] = 0; /* Format = unsigned long (4 octets) */ - data[offset+3] = 4; - data[offset+4] = 0; /* Number Of Components = 1 */ - data[offset+5] = 0; - data[offset+6] = 0; - data[offset+7] = 1; - data[offset+8] = 0; - data[offset+9] = 0; - data[offset+10] = (JOCTET)((new_value >> 8) & 0xFF); - data[offset+11] = (JOCTET)(new_value & 0xFF); - } else { - data[offset+2] = 4; /* Format = unsigned long (4 octets) */ - data[offset+3] = 0; - data[offset+4] = 1; /* Number Of Components = 1 */ - data[offset+5] = 0; - data[offset+6] = 0; - data[offset+7] = 0; - data[offset+8] = (JOCTET)(new_value & 0xFF); - data[offset+9] = (JOCTET)((new_value >> 8) & 0xFF); - data[offset+10] = 0; - data[offset+11] = 0; - } - } - offset += 12; - } while (--number_of_tags); -} - - -/* Adjust output image parameters as needed. - * - * This must be called after jpeg_copy_critical_parameters() - * and before jpeg_write_coefficients(). - * - * The return value is the set of virtual coefficient arrays to be written - * (either the ones allocated by jtransform_request_workspace, or the - * original source data arrays). The caller will need to pass this value - * to jpeg_write_coefficients(). - */ - -GLOBAL(jvirt_barray_ptr *) -jtransform_adjust_parameters (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info) -{ - /* If force-to-grayscale is requested, adjust destination parameters */ - if (info->force_grayscale) { - /* First, ensure we have YCC or grayscale data, and that the source's - * Y channel is full resolution. (No reasonable person would make Y - * be less than full resolution, so actually coping with that case - * isn't worth extra code space. But we check it to avoid crashing.) - */ - if ((((dstinfo->jpeg_color_space == JCS_YCbCr || - dstinfo->jpeg_color_space == JCS_BG_YCC) && - dstinfo->num_components == 3) || - (dstinfo->jpeg_color_space == JCS_GRAYSCALE && - dstinfo->num_components == 1)) && - srcinfo->comp_info[0].h_samp_factor == srcinfo->max_h_samp_factor && - srcinfo->comp_info[0].v_samp_factor == srcinfo->max_v_samp_factor) { - /* We use jpeg_set_colorspace to make sure subsidiary settings get fixed - * properly. Among other things, it sets the target h_samp_factor & - * v_samp_factor to 1, which typically won't match the source. - * We have to preserve the source's quantization table number, however. - */ - int sv_quant_tbl_no = dstinfo->comp_info[0].quant_tbl_no; - jpeg_set_colorspace(dstinfo, JCS_GRAYSCALE); - dstinfo->comp_info[0].quant_tbl_no = sv_quant_tbl_no; - } else { - /* Sorry, can't do it */ - ERREXIT(dstinfo, JERR_CONVERSION_NOTIMPL); - } - } else if (info->num_components == 1) { - /* For a single-component source, we force the destination sampling factors - * to 1x1, with or without force_grayscale. This is useful because some - * decoders choke on grayscale images with other sampling factors. - */ - dstinfo->comp_info[0].h_samp_factor = 1; - dstinfo->comp_info[0].v_samp_factor = 1; - } - - /* Correct the destination's image dimensions as necessary - * for rotate/flip, resize, and crop operations. - */ - dstinfo->jpeg_width = info->output_width; - dstinfo->jpeg_height = info->output_height; - - /* Transpose destination image parameters, adjust quantization */ - switch (info->transform) { - case JXFORM_TRANSPOSE: - case JXFORM_TRANSVERSE: - case JXFORM_ROT_90: - case JXFORM_ROT_270: - transpose_critical_parameters(dstinfo); - break; - case JXFORM_DROP: - if (info->drop_width != 0 && info->drop_height != 0) - adjust_quant(srcinfo, src_coef_arrays, - info->drop_ptr, info->drop_coef_arrays, - info->trim, dstinfo); - break; - default: - break; - } - - /* Adjust Exif properties */ - if (srcinfo->marker_list != NULL && - srcinfo->marker_list->marker == JPEG_APP0+1 && - srcinfo->marker_list->data_length >= 6 && - GETJOCTET(srcinfo->marker_list->data[0]) == 0x45 && - GETJOCTET(srcinfo->marker_list->data[1]) == 0x78 && - GETJOCTET(srcinfo->marker_list->data[2]) == 0x69 && - GETJOCTET(srcinfo->marker_list->data[3]) == 0x66 && - GETJOCTET(srcinfo->marker_list->data[4]) == 0 && - GETJOCTET(srcinfo->marker_list->data[5]) == 0) { - /* Suppress output of JFIF marker */ - dstinfo->write_JFIF_header = FALSE; - /* Adjust Exif image parameters */ - if (dstinfo->jpeg_width != srcinfo->image_width || - dstinfo->jpeg_height != srcinfo->image_height) - /* Align data segment to start of TIFF structure for parsing */ - adjust_exif_parameters(srcinfo->marker_list->data + 6, - srcinfo->marker_list->data_length - 6, - dstinfo->jpeg_width, dstinfo->jpeg_height); - } - - /* Return the appropriate output data set */ - if (info->workspace_coef_arrays != NULL) - return info->workspace_coef_arrays; - return src_coef_arrays; -} - - -/* Execute the actual transformation, if any. - * - * This must be called *after* jpeg_write_coefficients, because it depends - * on jpeg_write_coefficients to have computed subsidiary values such as - * the per-component width and height fields in the destination object. - * - * Note that some transformations will modify the source data arrays! - */ - -GLOBAL(void) -jtransform_execute_transform (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo, - jvirt_barray_ptr *src_coef_arrays, - jpeg_transform_info *info) -{ - jvirt_barray_ptr *dst_coef_arrays = info->workspace_coef_arrays; - - /* Note: conditions tested here should match those in switch statement - * in jtransform_request_workspace() - */ - switch (info->transform) { - case JXFORM_NONE: - if (info->output_width > srcinfo->output_width || - info->output_height > srcinfo->output_height) { - if (info->output_width > srcinfo->output_width && - info->crop_width_set == JCROP_REFLECT) - do_crop_ext_reflect(srcinfo, dstinfo, - info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); - else if (info->output_width > srcinfo->output_width && - info->crop_width_set == JCROP_FORCE) - do_crop_ext_flat(srcinfo, dstinfo, - info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); - else - do_crop_ext_zero(srcinfo, dstinfo, - info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); - } else if (info->x_crop_offset != 0 || info->y_crop_offset != 0) - do_crop(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_FLIP_H: - if (info->y_crop_offset != 0) - do_flip_h(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); - else - do_flip_h_no_crop(srcinfo, dstinfo, info->x_crop_offset, - src_coef_arrays); - break; - case JXFORM_FLIP_V: - do_flip_v(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_TRANSPOSE: - do_transpose(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_TRANSVERSE: - do_transverse(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_ROT_90: - do_rot_90(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_ROT_180: - do_rot_180(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_ROT_270: - do_rot_270(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, dst_coef_arrays); - break; - case JXFORM_WIPE: - if (info->crop_width_set == JCROP_REFLECT && - info->y_crop_offset == 0 && info->drop_height == - (JDIMENSION) jdiv_round_up - ((long) info->output_height, (long) info->iMCU_sample_height) && - (info->x_crop_offset == 0 || - info->x_crop_offset + info->drop_width == - (JDIMENSION) jdiv_round_up - ((long) info->output_width, (long) info->iMCU_sample_width))) - do_reflect(srcinfo, dstinfo, info->x_crop_offset, - src_coef_arrays, info->drop_width, info->drop_height); - else if (info->crop_width_set == JCROP_FORCE) - do_flatten(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, info->drop_width, info->drop_height); - else - do_wipe(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, info->drop_width, info->drop_height); - break; - case JXFORM_DROP: - if (info->drop_width != 0 && info->drop_height != 0) - do_drop(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset, - src_coef_arrays, info->drop_ptr, info->drop_coef_arrays, - info->drop_width, info->drop_height); - break; - } -} - -/* jtransform_perfect_transform - * - * Determine whether lossless transformation is perfectly - * possible for a specified image and transformation. - * - * Inputs: - * image_width, image_height: source image dimensions. - * MCU_width, MCU_height: pixel dimensions of MCU. - * transform: transformation identifier. - * Parameter sources from initialized jpeg_struct - * (after reading source header): - * image_width = cinfo.image_width - * image_height = cinfo.image_height - * MCU_width = cinfo.max_h_samp_factor * cinfo.block_size - * MCU_height = cinfo.max_v_samp_factor * cinfo.block_size - * Result: - * TRUE = perfect transformation possible - * FALSE = perfect transformation not possible - * (may use custom action then) - */ - -GLOBAL(boolean) -jtransform_perfect_transform(JDIMENSION image_width, JDIMENSION image_height, - int MCU_width, int MCU_height, - JXFORM_CODE transform) -{ - boolean result = TRUE; /* initialize TRUE */ - - switch (transform) { - case JXFORM_FLIP_H: - case JXFORM_ROT_270: - if (image_width % (JDIMENSION) MCU_width) - result = FALSE; - break; - case JXFORM_FLIP_V: - case JXFORM_ROT_90: - if (image_height % (JDIMENSION) MCU_height) - result = FALSE; - break; - case JXFORM_TRANSVERSE: - case JXFORM_ROT_180: - if (image_width % (JDIMENSION) MCU_width) - result = FALSE; - if (image_height % (JDIMENSION) MCU_height) - result = FALSE; - break; - default: - break; - } - - return result; -} - -#endif /* TRANSFORMS_SUPPORTED */ - - -/* Setup decompression object to save desired markers in memory. - * This must be called before jpeg_read_header() to have the desired effect. - */ - -GLOBAL(void) -jcopy_markers_setup (j_decompress_ptr srcinfo, JCOPY_OPTION option) -{ -#ifdef SAVE_MARKERS_SUPPORTED - int m; - - /* Save comments except under NONE option */ - if (option != JCOPYOPT_NONE) { - jpeg_save_markers(srcinfo, JPEG_COM, 0xFFFF); - } - /* Save all types of APPn markers iff ALL option */ - if (option == JCOPYOPT_ALL) { - for (m = 0; m < 16; m++) - jpeg_save_markers(srcinfo, JPEG_APP0 + m, 0xFFFF); - } -#endif /* SAVE_MARKERS_SUPPORTED */ -} - -/* Copy markers saved in the given source object to the destination object. - * This should be called just after jpeg_start_compress() or - * jpeg_write_coefficients(). - * Note that those routines will have written the SOI, and also the - * JFIF APP0 or Adobe APP14 markers if selected. - */ - -GLOBAL(void) -jcopy_markers_execute (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, - JCOPY_OPTION option) -{ - jpeg_saved_marker_ptr marker; - - /* In the current implementation, we don't actually need to examine the - * option flag here; we just copy everything that got saved. - * But to avoid confusion, we do not output JFIF and Adobe APP14 markers - * if the encoder library already wrote one. - */ - for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) { - if (dstinfo->write_JFIF_header && - marker->marker == JPEG_APP0 && - marker->data_length >= 5 && - GETJOCTET(marker->data[0]) == 0x4A && - GETJOCTET(marker->data[1]) == 0x46 && - GETJOCTET(marker->data[2]) == 0x49 && - GETJOCTET(marker->data[3]) == 0x46 && - GETJOCTET(marker->data[4]) == 0) - continue; /* reject duplicate JFIF */ - if (dstinfo->write_Adobe_marker && - marker->marker == JPEG_APP0+14 && - marker->data_length >= 5 && - GETJOCTET(marker->data[0]) == 0x41 && - GETJOCTET(marker->data[1]) == 0x64 && - GETJOCTET(marker->data[2]) == 0x6F && - GETJOCTET(marker->data[3]) == 0x62 && - GETJOCTET(marker->data[4]) == 0x65) - continue; /* reject duplicate Adobe */ -#ifdef NEED_FAR_POINTERS - /* We could use jpeg_write_marker if the data weren't FAR... */ - { - unsigned int i; - jpeg_write_m_header(dstinfo, marker->marker, marker->data_length); - for (i = 0; i < marker->data_length; i++) - jpeg_write_m_byte(dstinfo, marker->data[i]); - } -#else - jpeg_write_marker(dstinfo, marker->marker, - marker->data, marker->data_length); -#endif - } -} diff --git a/code/jpeg-9f/wrbmp.c b/code/jpeg-9f/wrbmp.c deleted file mode 100644 index bed699ff..00000000 --- a/code/jpeg-9f/wrbmp.c +++ /dev/null @@ -1,437 +0,0 @@ -/* - * wrbmp.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * Modified 2017-2019 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in Microsoft "BMP" - * format (MS Windows 3.x and OS/2 1.x flavors). - * Either 8-bit colormapped or 24-bit full-color format can be written. - * No compression is supported. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - * - * This code contributed by James Arthur Boucher. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef BMP_SUPPORTED - - -/* - * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. - * This is not yet implemented. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - -/* - * Since BMP stores scanlines bottom-to-top, we have to invert the image - * from JPEG's top-to-bottom order. To do this, we save the outgoing data - * in a virtual array during put_pixel_row calls, then actually emit the - * BMP file during finish_output. The virtual array contains one JSAMPLE per - * pixel if the output is grayscale or colormapped, three if it is full color. - */ - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - boolean is_os2; /* saves the OS2 format request flag */ - - jvirt_sarray_ptr whole_image; /* needed to reverse row order */ - JDIMENSION data_width; /* JSAMPLEs per row */ - JDIMENSION row_width; /* physical width of one row in the BMP file */ - int pad_bytes; /* number of padding bytes needed per row */ - JDIMENSION cur_output_row; /* next row# to write to virtual array */ -} bmp_dest_struct; - -typedef bmp_dest_struct * bmp_dest_ptr; - - -/* Forward declarations */ -LOCAL(void) write_colormap - JPP((j_decompress_ptr cinfo, bmp_dest_ptr dest, - int map_colors, int map_entry_size)); - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - */ - -METHODDEF(void) -put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* This version is for writing 24-bit pixels */ -{ - bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - int pad; - - /* Access next row in virtual array */ - outptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, - dest->whole_image, dest->cur_output_row, (JDIMENSION) 1, TRUE); - dest->cur_output_row++; - - /* Transfer data. Note destination values must be in BGR order - * (even though Microsoft's own documents say the opposite). - */ - inptr = dest->pub.buffer[0]; - for (col = cinfo->output_width; col > 0; col--) { - outptr[2] = *inptr++; /* can omit GETJSAMPLE() safely */ - outptr[1] = *inptr++; - outptr[0] = *inptr++; - outptr += 3; - } - - /* Zero out the pad bytes. */ - pad = dest->pad_bytes; - while (--pad >= 0) - *outptr++ = 0; -} - -METHODDEF(void) -put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* This version is for grayscale OR quantized color output */ -{ - bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; - register JSAMPROW inptr, outptr; - register JDIMENSION col; - int pad; - - /* Access next row in virtual array */ - outptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, - dest->whole_image, dest->cur_output_row, (JDIMENSION) 1, TRUE); - dest->cur_output_row++; - - /* Transfer data. */ - inptr = dest->pub.buffer[0]; - for (col = cinfo->output_width; col > 0; col--) { - *outptr++ = *inptr++; /* can omit GETJSAMPLE() safely */ - } - - /* Zero out the pad bytes. */ - pad = dest->pad_bytes; - while (--pad >= 0) - *outptr++ = 0; -} - - -/* - * Startup: normally writes the file header. - * In this module we may as well postpone everything until finish_output. - */ - -METHODDEF(void) -start_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* no work here */ -} - - -/* - * Finish up at the end of the file. - * - * Here is where we really output the BMP file. - * - * First, routines to write the Windows and OS/2 variants of the file header. - */ - -LOCAL(void) -write_bmp_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) -/* Write a Windows-style BMP file header, including colormap if needed */ -{ - char bmpfileheader[14]; - char bmpinfoheader[40]; -#define PUT_2B(array, offset, value) \ - (array[offset] = (char) ((value) & 0xFF), \ - array[offset+1] = (char) (((value) >> 8) & 0xFF)) -#define PUT_4B(array, offset, value) \ - (array[offset] = (char) ((value) & 0xFF), \ - array[offset+1] = (char) (((value) >> 8) & 0xFF), \ - array[offset+2] = (char) (((value) >> 16) & 0xFF), \ - array[offset+3] = (char) (((value) >> 24) & 0xFF)) - INT32 headersize, bfSize; - int bits_per_pixel, cmap_entries; - - /* Compute colormap size and total file size */ - if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) { - /* Colormapped RGB */ - bits_per_pixel = 8; - cmap_entries = 256; - } else { - /* Unquantized, full color RGB */ - bits_per_pixel = 24; - cmap_entries = 0; - } - } else { - /* Grayscale output. We need to fake a 256-entry colormap. */ - bits_per_pixel = 8; - cmap_entries = 256; - } - /* File size */ - headersize = 14 + 40 + cmap_entries * 4; /* Header and colormap */ - bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; - - /* Set unused fields of header to 0 */ - MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); - MEMZERO(bmpinfoheader, SIZEOF(bmpinfoheader)); - - /* Fill the file header */ - bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ - bmpfileheader[1] = 0x4D; - PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ - /* we leave bfReserved1 & bfReserved2 = 0 */ - PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ - - /* Fill the info header (Microsoft calls this a BITMAPINFOHEADER) */ - PUT_2B(bmpinfoheader, 0, 40); /* biSize */ - PUT_4B(bmpinfoheader, 4, cinfo->output_width); /* biWidth */ - PUT_4B(bmpinfoheader, 8, cinfo->output_height); /* biHeight */ - PUT_2B(bmpinfoheader, 12, 1); /* biPlanes - must be 1 */ - PUT_2B(bmpinfoheader, 14, bits_per_pixel); /* biBitCount */ - /* we leave biCompression = 0, for none */ - /* we leave biSizeImage = 0; this is correct for uncompressed data */ - if (cinfo->density_unit == 2) { /* if have density in dots/cm, then */ - PUT_4B(bmpinfoheader, 24, (INT32) (cinfo->X_density*100)); /* XPels/M */ - PUT_4B(bmpinfoheader, 28, (INT32) (cinfo->Y_density*100)); /* XPels/M */ - } - PUT_2B(bmpinfoheader, 32, cmap_entries); /* biClrUsed */ - /* we leave biClrImportant = 0 */ - - if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) - ERREXIT(cinfo, JERR_FILE_WRITE); - if (JFWRITE(dest->pub.output_file, bmpinfoheader, 40) != (size_t) 40) - ERREXIT(cinfo, JERR_FILE_WRITE); - - if (cmap_entries > 0) - write_colormap(cinfo, dest, cmap_entries, 4); -} - - -LOCAL(void) -write_os2_header (j_decompress_ptr cinfo, bmp_dest_ptr dest) -/* Write an OS2-style BMP file header, including colormap if needed */ -{ - char bmpfileheader[14]; - char bmpcoreheader[12]; - INT32 headersize, bfSize; - int bits_per_pixel, cmap_entries; - - /* Compute colormap size and total file size */ - if (cinfo->out_color_space == JCS_RGB) { - if (cinfo->quantize_colors) { - /* Colormapped RGB */ - bits_per_pixel = 8; - cmap_entries = 256; - } else { - /* Unquantized, full color RGB */ - bits_per_pixel = 24; - cmap_entries = 0; - } - } else { - /* Grayscale output. We need to fake a 256-entry colormap. */ - bits_per_pixel = 8; - cmap_entries = 256; - } - /* File size */ - headersize = 14 + 12 + cmap_entries * 3; /* Header and colormap */ - bfSize = headersize + (INT32) dest->row_width * (INT32) cinfo->output_height; - - /* Set unused fields of header to 0 */ - MEMZERO(bmpfileheader, SIZEOF(bmpfileheader)); - MEMZERO(bmpcoreheader, SIZEOF(bmpcoreheader)); - - /* Fill the file header */ - bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ - bmpfileheader[1] = 0x4D; - PUT_4B(bmpfileheader, 2, bfSize); /* bfSize */ - /* we leave bfReserved1 & bfReserved2 = 0 */ - PUT_4B(bmpfileheader, 10, headersize); /* bfOffBits */ - - /* Fill the info header (Microsoft calls this a BITMAPCOREHEADER) */ - PUT_2B(bmpcoreheader, 0, 12); /* bcSize */ - PUT_2B(bmpcoreheader, 4, cinfo->output_width); /* bcWidth */ - PUT_2B(bmpcoreheader, 6, cinfo->output_height); /* bcHeight */ - PUT_2B(bmpcoreheader, 8, 1); /* bcPlanes - must be 1 */ - PUT_2B(bmpcoreheader, 10, bits_per_pixel); /* bcBitCount */ - - if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t) 14) - ERREXIT(cinfo, JERR_FILE_WRITE); - if (JFWRITE(dest->pub.output_file, bmpcoreheader, 12) != (size_t) 12) - ERREXIT(cinfo, JERR_FILE_WRITE); - - if (cmap_entries > 0) - write_colormap(cinfo, dest, cmap_entries, 3); -} - - -/* - * Write the colormap. - * Windows uses BGR0 map entries; OS/2 uses BGR entries. - */ - -LOCAL(void) -write_colormap (j_decompress_ptr cinfo, bmp_dest_ptr dest, - int map_colors, int map_entry_size) -{ - JSAMPARRAY colormap = cinfo->colormap; - int num_colors = cinfo->actual_number_of_colors; - FILE * outfile = dest->pub.output_file; - int i; - - if (colormap != NULL) { - if (cinfo->out_color_components == 3) { - /* Normal case with RGB colormap */ - for (i = 0; i < num_colors; i++) { - putc(GETJSAMPLE(colormap[2][i]), outfile); - putc(GETJSAMPLE(colormap[1][i]), outfile); - putc(GETJSAMPLE(colormap[0][i]), outfile); - if (map_entry_size == 4) - putc(0, outfile); - } - } else { - /* Grayscale colormap (only happens with grayscale quantization) */ - for (i = 0; i < num_colors; i++) { - putc(GETJSAMPLE(colormap[0][i]), outfile); - putc(GETJSAMPLE(colormap[0][i]), outfile); - putc(GETJSAMPLE(colormap[0][i]), outfile); - if (map_entry_size == 4) - putc(0, outfile); - } - } - } else { - /* If no colormap, must be grayscale data. Generate a linear "map". */ - for (i = 0; i < 256; i++) { - putc(i, outfile); - putc(i, outfile); - putc(i, outfile); - if (map_entry_size == 4) - putc(0, outfile); - } - } - /* Pad colormap to ensure specified number of colormap entries */ - if (i > map_colors) - ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, i); - for (; i < map_colors; i++) { - putc(CENTERJSAMPLE, outfile); - putc(CENTERJSAMPLE, outfile); - putc(CENTERJSAMPLE, outfile); - if (map_entry_size == 4) - putc(0, outfile); - } -} - - -METHODDEF(void) -finish_output_bmp (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - bmp_dest_ptr dest = (bmp_dest_ptr) dinfo; - register FILE * outfile = dest->pub.output_file; - register JSAMPROW data_ptr; - JDIMENSION row; - register JDIMENSION col; - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - - /* Write the header and colormap */ - if (dest->is_os2) - write_os2_header(cinfo, dest); - else - write_bmp_header(cinfo, dest); - - /* Write the file body from our virtual array */ - for (row = cinfo->output_height; row > 0; row--) { - if (progress != NULL) { - progress->pub.pass_counter = (long) (cinfo->output_height - row); - progress->pub.pass_limit = (long) cinfo->output_height; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } - data_ptr = * (*cinfo->mem->access_virt_sarray) ((j_common_ptr) cinfo, - dest->whole_image, row - 1, (JDIMENSION) 1, FALSE); - for (col = dest->row_width; col > 0; col--) { - putc(GETJSAMPLE(*data_ptr), outfile); - data_ptr++; - } - } - if (progress != NULL) - progress->completed_extra_passes++; - - /* Make sure we wrote the output file OK */ - JFFLUSH(outfile); - if (JFERROR(outfile)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for BMP format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2) -{ - bmp_dest_ptr dest; - JDIMENSION row_width; - - /* Create module interface object, fill in method pointers */ - dest = (bmp_dest_ptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(bmp_dest_struct)); - dest->pub.start_output = start_output_bmp; - dest->pub.finish_output = finish_output_bmp; - dest->is_os2 = is_os2; - - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - dest->pub.put_pixel_rows = put_gray_rows; - break; - case JCS_RGB: - if (cinfo->quantize_colors) - dest->pub.put_pixel_rows = put_gray_rows; - else - dest->pub.put_pixel_rows = put_pixel_rows; - break; - default: - ERREXIT(cinfo, JERR_BMP_COLORSPACE); - } - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Determine width of rows in the BMP file (padded to 4-byte boundary). */ - row_width = cinfo->output_width * cinfo->output_components; - dest->data_width = row_width; - while ((row_width & 3) != 0) row_width++; - dest->row_width = row_width; - dest->pad_bytes = (int) (row_width - dest->data_width); - - /* Allocate space for inversion array, prepare for write pass */ - dest->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - row_width, cinfo->output_height, (JDIMENSION) 1); - dest->cur_output_row = 0; - if (cinfo->progress != NULL) { - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; - progress->total_extra_passes++; /* count file input as separate pass */ - } - - /* Create decompressor output buffer. */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, row_width, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - - return &dest->pub; -} - -#endif /* BMP_SUPPORTED */ diff --git a/code/jpeg-9f/wrgif.c b/code/jpeg-9f/wrgif.c deleted file mode 100644 index 9d472de1..00000000 --- a/code/jpeg-9f/wrgif.c +++ /dev/null @@ -1,566 +0,0 @@ -/* - * wrgif.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * Modified 2015-2019 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in GIF format. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - */ - -/* - * This code is loosely based on ppmtogif from the PBMPLUS distribution - * of Feb. 1991. That file contains the following copyright notice: - * Based on GIFENCODE by David Rowley . - * Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al. - * Copyright (C) 1989 by Jef Poskanzer. - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation. This software is provided "as is" without express or - * implied warranty. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef GIF_SUPPORTED - - -#define MAX_LZW_BITS 12 /* maximum LZW code size (4096 symbols) */ - -typedef INT16 code_int; /* must hold -1 .. 2**MAX_LZW_BITS */ - -#define LZW_TABLE_SIZE ((code_int) 1 << MAX_LZW_BITS) - -#define HSIZE 5003 /* hash table size for 80% occupancy */ - -typedef int hash_int; /* must hold -2*HSIZE..2*HSIZE */ - -#define MAXCODE(n_bits) (((code_int) 1 << (n_bits)) - 1) - - -/* - * The LZW hash table consists of two parallel arrays: - * hash_code[i] code of symbol in slot i, or 0 if empty slot - * hash_value[i] symbol's value; undefined if empty slot - * where slot values (i) range from 0 to HSIZE-1. The symbol value is - * its prefix symbol's code concatenated with its suffix character. - * - * Algorithm: use open addressing double hashing (no chaining) on the - * prefix code / suffix character combination. We do a variant of Knuth's - * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime - * secondary probe. - * - * The hash_value[] table is allocated from FAR heap space since it would - * use up rather a lot of the near data space in a PC. - */ - -typedef INT32 hash_entry; /* must hold (code_int<<8) | byte */ - -#define HASH_ENTRY(prefix, suffix) ((((hash_entry) (prefix)) << 8) | (suffix)) - - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - j_decompress_ptr cinfo; /* back link saves passing separate parm */ - - /* State for packing variable-width codes into a bitstream */ - int n_bits; /* current number of bits/code */ - code_int maxcode; /* maximum code, given n_bits */ - int init_bits; /* initial n_bits ... restored after clear */ - INT32 cur_accum; /* holds bits not yet output */ - int cur_bits; /* # of bits in cur_accum */ - - /* LZW string construction */ - code_int waiting_code; /* symbol not yet output; may be extendable */ - boolean first_byte; /* if TRUE, waiting_code is not valid */ - - /* State for GIF code assignment */ - code_int ClearCode; /* clear code (doesn't change) */ - code_int EOFCode; /* EOF code (ditto) */ - code_int free_code; /* LZW: first not-yet-used symbol code */ - code_int code_counter; /* not LZW: counts output symbols */ - - /* LZW hash table */ - code_int *hash_code; /* => hash table of symbol codes */ - hash_entry FAR *hash_value; /* => hash table of symbol values */ - - /* GIF data packet construction buffer */ - int bytesinpkt; /* # of bytes in current packet */ - char packetbuf[256]; /* workspace for accumulating packet */ - -} gif_dest_struct; - -typedef gif_dest_struct * gif_dest_ptr; - - -/* - * Routines to package finished data bytes into GIF data blocks. - * A data block consists of a count byte (1..255) and that many data bytes. - */ - -LOCAL(void) -flush_packet (gif_dest_ptr dinfo) -/* flush any accumulated data */ -{ - if (dinfo->bytesinpkt > 0) { /* never write zero-length packet */ - dinfo->packetbuf[0] = (char) dinfo->bytesinpkt++; - if (JFWRITE(dinfo->pub.output_file, dinfo->packetbuf, dinfo->bytesinpkt) - != (size_t) dinfo->bytesinpkt) - ERREXIT(dinfo->cinfo, JERR_FILE_WRITE); - dinfo->bytesinpkt = 0; - } -} - - -/* Add a character to current packet; flush to disk if necessary */ -#define CHAR_OUT(dinfo, c) \ - { (dinfo)->packetbuf[++(dinfo)->bytesinpkt] = (char) (c); \ - if ((dinfo)->bytesinpkt >= 255) \ - flush_packet(dinfo); \ - } - - -/* Routine to convert variable-width codes into a byte stream */ - -LOCAL(void) -output (gif_dest_ptr dinfo, code_int code) -/* Emit a code of n_bits bits */ -/* Uses cur_accum and cur_bits to reblock into 8-bit bytes */ -{ - dinfo->cur_accum |= ((INT32) code) << dinfo->cur_bits; - dinfo->cur_bits += dinfo->n_bits; - - while (dinfo->cur_bits >= 8) { - CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); - dinfo->cur_accum >>= 8; - dinfo->cur_bits -= 8; - } - - /* - * If the next entry is going to be too big for the code size, - * then increase it, if possible. We do this here to ensure - * that it's done in sync with the decoder's codesize increases. - */ - if (dinfo->free_code > dinfo->maxcode) { - dinfo->n_bits++; - if (dinfo->n_bits == MAX_LZW_BITS) - dinfo->maxcode = LZW_TABLE_SIZE; /* free_code will never exceed this */ - else - dinfo->maxcode = MAXCODE(dinfo->n_bits); - } -} - - -/* Compression initialization & termination */ - - -LOCAL(void) -clear_hash (gif_dest_ptr dinfo) -/* Fill the hash table with empty entries */ -{ - /* It's sufficient to zero hash_code[] */ - MEMZERO(dinfo->hash_code, HSIZE * SIZEOF(code_int)); -} - - -LOCAL(void) -clear_block (gif_dest_ptr dinfo) -/* Reset compressor and issue a Clear code */ -{ - clear_hash(dinfo); /* delete all the symbols */ - dinfo->free_code = dinfo->ClearCode + 2; - output(dinfo, dinfo->ClearCode); /* inform decoder */ - dinfo->n_bits = dinfo->init_bits; /* reset code size */ - dinfo->maxcode = MAXCODE(dinfo->n_bits); -} - - -LOCAL(void) -compress_init (gif_dest_ptr dinfo, int i_bits) -/* Initialize compressor */ -{ - /* init all the state variables */ - dinfo->n_bits = dinfo->init_bits = i_bits; - dinfo->maxcode = MAXCODE(dinfo->n_bits); - dinfo->ClearCode = ((code_int) 1 << (i_bits - 1)); - dinfo->EOFCode = dinfo->ClearCode + 1; - dinfo->code_counter = dinfo->free_code = dinfo->ClearCode + 2; - dinfo->first_byte = TRUE; /* no waiting symbol yet */ - /* init output buffering vars */ - dinfo->bytesinpkt = 0; - dinfo->cur_accum = 0; - dinfo->cur_bits = 0; - /* clear hash table */ - if (dinfo->hash_code != NULL) - clear_hash(dinfo); - /* GIF specifies an initial Clear code */ - output(dinfo, dinfo->ClearCode); -} - - -LOCAL(void) -compress_term (gif_dest_ptr dinfo) -/* Clean up at end */ -{ - /* Flush out the buffered LZW code */ - if (! dinfo->first_byte) - output(dinfo, dinfo->waiting_code); - /* Send an EOF code */ - output(dinfo, dinfo->EOFCode); - /* Flush the bit-packing buffer */ - if (dinfo->cur_bits > 0) { - CHAR_OUT(dinfo, dinfo->cur_accum & 0xFF); - } - /* Flush the packet buffer */ - flush_packet(dinfo); -} - - -/* GIF header construction */ - - -LOCAL(void) -put_word (gif_dest_ptr dinfo, unsigned int w) -/* Emit a 16-bit word, LSB first */ -{ - putc(w & 0xFF, dinfo->pub.output_file); - putc((w >> 8) & 0xFF, dinfo->pub.output_file); -} - - -LOCAL(void) -put_3bytes (gif_dest_ptr dinfo, int val) -/* Emit 3 copies of same byte value --- handy subr for colormap construction */ -{ - putc(val, dinfo->pub.output_file); - putc(val, dinfo->pub.output_file); - putc(val, dinfo->pub.output_file); -} - - -LOCAL(void) -emit_header (gif_dest_ptr dinfo, int num_colors, JSAMPARRAY colormap) -/* Output the GIF file header, including color map */ -/* If colormap == NULL, synthesize a grayscale colormap */ -{ - int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte; - int cshift = dinfo->cinfo->data_precision - 8; - int i; - - if (num_colors > 256) - ERREXIT1(dinfo->cinfo, JERR_TOO_MANY_COLORS, num_colors); - /* Compute bits/pixel and related values */ - BitsPerPixel = 1; - while (num_colors > (1 << BitsPerPixel)) - BitsPerPixel++; - ColorMapSize = 1 << BitsPerPixel; - if (BitsPerPixel <= 1) - InitCodeSize = 2; - else - InitCodeSize = BitsPerPixel; - /* - * Write the GIF header. - * Note that we generate a plain GIF87 header for maximum compatibility. - */ - putc('G', dinfo->pub.output_file); - putc('I', dinfo->pub.output_file); - putc('F', dinfo->pub.output_file); - putc('8', dinfo->pub.output_file); - putc('7', dinfo->pub.output_file); - putc('a', dinfo->pub.output_file); - /* Write the Logical Screen Descriptor */ - put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); - put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); - FlagByte = 0x80; /* Yes, there is a global color table */ - FlagByte |= (BitsPerPixel - 1) << 4; /* color resolution */ - FlagByte |= (BitsPerPixel - 1); /* size of global color table */ - putc(FlagByte, dinfo->pub.output_file); - putc(0, dinfo->pub.output_file); /* Background color index */ - putc(0, dinfo->pub.output_file); /* Reserved (aspect ratio in GIF89) */ - /* Write the Global Color Map */ - /* If the color map is more than 8 bits precision, */ - /* we reduce it to 8 bits by shifting */ - for (i = 0; i < ColorMapSize; i++) { - if (i < num_colors) { - if (colormap != NULL) { - if (dinfo->cinfo->out_color_space == JCS_RGB) { - /* Normal case: RGB color map */ - putc(GETJSAMPLE(colormap[0][i]) >> cshift, dinfo->pub.output_file); - putc(GETJSAMPLE(colormap[1][i]) >> cshift, dinfo->pub.output_file); - putc(GETJSAMPLE(colormap[2][i]) >> cshift, dinfo->pub.output_file); - } else { - /* Grayscale "color map": possible if quantizing grayscale image */ - put_3bytes(dinfo, GETJSAMPLE(colormap[0][i]) >> cshift); - } - } else { - /* Create a grayscale map of num_colors values, range 0..255 */ - put_3bytes(dinfo, (i * 255 + (num_colors - 1) / 2) / (num_colors - 1)); - } - } else { - /* fill out the map to a power of 2 */ - put_3bytes(dinfo, CENTERJSAMPLE >> cshift); - } - } - /* Write image separator and Image Descriptor */ - putc(',', dinfo->pub.output_file); /* separator */ - put_word(dinfo, 0); /* left/top offset */ - put_word(dinfo, 0); - put_word(dinfo, (unsigned int) dinfo->cinfo->output_width); /* image size */ - put_word(dinfo, (unsigned int) dinfo->cinfo->output_height); - /* flag byte: not interlaced, no local color map */ - putc(0x00, dinfo->pub.output_file); - /* Write Initial Code Size byte */ - putc(InitCodeSize, dinfo->pub.output_file); - - /* Initialize for compression of image data */ - compress_init(dinfo, InitCodeSize + 1); -} - - -/* - * Startup: write the file header. - */ - -METHODDEF(void) -start_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - - if (cinfo->quantize_colors) - emit_header(dest, cinfo->actual_number_of_colors, cinfo->colormap); - else - emit_header(dest, 256, (JSAMPARRAY) NULL); -} - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - */ - - -/* - * The LZW algorithm proper - */ - -METHODDEF(void) -put_LZW_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - register JSAMPROW ptr; - register JDIMENSION col; - code_int c; - register hash_int i; - register hash_int disp; - register hash_entry probe_value; - - ptr = dest->pub.buffer[0]; - for (col = cinfo->output_width; col > 0; col--) { - /* Accept and compress one 8-bit byte */ - c = (code_int) GETJSAMPLE(*ptr++); - - if (dest->first_byte) { /* need to initialize waiting_code */ - dest->waiting_code = c; - dest->first_byte = FALSE; - continue; - } - - /* Probe hash table to see if a symbol exists for - * waiting_code followed by c. - * If so, replace waiting_code by that symbol and continue. - */ - i = ((hash_int) c << (MAX_LZW_BITS-8)) + dest->waiting_code; - /* i is less than twice 2**MAX_LZW_BITS, therefore less than twice HSIZE */ - if (i >= HSIZE) - i -= HSIZE; - - probe_value = HASH_ENTRY(dest->waiting_code, c); - - if (dest->hash_code[i] == 0) { - /* hit empty slot; desired symbol not in table */ - output(dest, dest->waiting_code); - if (dest->free_code < LZW_TABLE_SIZE) { - dest->hash_code[i] = dest->free_code++; /* add symbol to hashtable */ - dest->hash_value[i] = probe_value; - } else - clear_block(dest); - dest->waiting_code = c; - continue; - } - if (dest->hash_value[i] == probe_value) { - dest->waiting_code = dest->hash_code[i]; - continue; - } - - if (i == 0) /* secondary hash (after G. Knott) */ - disp = 1; - else - disp = HSIZE - i; - for (;;) { - i -= disp; - if (i < 0) - i += HSIZE; - if (dest->hash_code[i] == 0) { - /* hit empty slot; desired symbol not in table */ - output(dest, dest->waiting_code); - if (dest->free_code < LZW_TABLE_SIZE) { - dest->hash_code[i] = dest->free_code++; /* add symbol to hashtable */ - dest->hash_value[i] = probe_value; - } else - clear_block(dest); - dest->waiting_code = c; - break; - } - if (dest->hash_value[i] == probe_value) { - dest->waiting_code = dest->hash_code[i]; - break; - } - } - } -} - - -/* - * The pseudo-compression algorithm. - * - * In this version we simply output each pixel value as a separate symbol; - * thus, no compression occurs. In fact, there is expansion of one bit per - * pixel, because we use a symbol width one bit wider than the pixel width. - * - * GIF ordinarily uses variable-width symbols, and the decoder will expect - * to ratchet up the symbol width after a fixed number of symbols. - * To simplify the logic and keep the expansion penalty down, we emit a - * GIF Clear code to reset the decoder just before the width would ratchet up. - * Thus, all the symbols in the output file will have the same bit width. - * Note that emitting the Clear codes at the right times is a mere matter of - * counting output symbols and is in no way dependent on the LZW algorithm. - * - * With a small basic pixel width (low color count), Clear codes will be - * needed very frequently, causing the file to expand even more. So this - * simplistic approach wouldn't work too well on bilevel images, for example. - * But for output of JPEG conversions the pixel width will usually be 8 bits - * (129 to 256 colors), so the overhead added by Clear symbols is only about - * one symbol in every 256. - */ - -METHODDEF(void) -put_raw_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - register JSAMPROW ptr; - register JDIMENSION col; - code_int c; - - ptr = dest->pub.buffer[0]; - for (col = cinfo->output_width; col > 0; col--) { - c = (code_int) GETJSAMPLE(*ptr++); - /* Accept and output one pixel value. - * The given value must be less than n_bits wide. - */ - - /* Output the given pixel value as a symbol. */ - output(dest, c); - /* Issue Clear codes often enough to keep the reader from ratcheting up - * its symbol size. - */ - if (dest->code_counter < dest->maxcode) { - dest->code_counter++; - } else { - output(dest, dest->ClearCode); - dest->code_counter = dest->ClearCode + 2; /* reset the counter */ - } - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - gif_dest_ptr dest = (gif_dest_ptr) dinfo; - - /* Flush compression mechanism */ - compress_term(dest); - /* Write a zero-length data block to end the series */ - putc(0, dest->pub.output_file); - /* Write the GIF terminator mark */ - putc(';', dest->pub.output_file); - /* Make sure we wrote the output file OK */ - JFFLUSH(dest->pub.output_file); - if (JFERROR(dest->pub.output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for GIF format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_gif (j_decompress_ptr cinfo, boolean is_lzw) -{ - gif_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (gif_dest_ptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(gif_dest_struct)); - dest->cinfo = cinfo; /* make back link for subroutines */ - dest->pub.start_output = start_output_gif; - dest->pub.finish_output = finish_output_gif; - - if (cinfo->out_color_space != JCS_GRAYSCALE && - cinfo->out_color_space != JCS_RGB) - ERREXIT(cinfo, JERR_GIF_COLORSPACE); - - /* Force quantization if color or if > 8 bits input */ - if (cinfo->out_color_space != JCS_GRAYSCALE || cinfo->data_precision > 8) { - /* Force quantization to at most 256 colors */ - cinfo->quantize_colors = TRUE; - if (cinfo->desired_number_of_colors > 256) - cinfo->desired_number_of_colors = 256; - } - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - if (cinfo->output_components != 1) /* safety check: just one component? */ - ERREXIT(cinfo, JERR_GIF_BUG); - - /* Create decompressor output buffer. */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - - if (is_lzw) { - dest->pub.put_pixel_rows = put_LZW_pixel_rows; - /* Allocate space for hash table */ - dest->hash_code = (code_int *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, HSIZE * SIZEOF(code_int)); - dest->hash_value = (hash_entry FAR *) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, HSIZE * SIZEOF(hash_entry)); - } else { - dest->pub.put_pixel_rows = put_raw_pixel_rows; - /* Mark tables unused */ - dest->hash_code = NULL; - dest->hash_value = NULL; - } - - return &dest->pub; -} - -#endif /* GIF_SUPPORTED */ diff --git a/code/jpeg-9f/wrjpgcom.c b/code/jpeg-9f/wrjpgcom.c deleted file mode 100644 index 571e9d07..00000000 --- a/code/jpeg-9f/wrjpgcom.c +++ /dev/null @@ -1,599 +0,0 @@ -/* - * wrjpgcom.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * Modified 2015-2017 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a very simple stand-alone application that inserts - * user-supplied text as a COM (comment) marker in a JFIF file. - * This may be useful as an example of the minimum logic needed to parse - * JPEG markers. - */ - -#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ -#include "jinclude.h" /* get auto-config symbols, */ - -#ifndef HAVE_STDLIB_H /* should declare malloc() */ -extern void * malloc (); -#endif -#include /* to declare isupper(), tolower() */ -#ifdef USE_SETMODE -#include /* to declare setmode()'s parameter macros */ -/* If you have setmode() but not , just delete this line: */ -#include /* to declare setmode() */ -#endif - -#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ -#ifdef __MWERKS__ -#include /* Metrowerks needs this */ -#include /* ... and this */ -#endif -#ifdef THINK_C -#include /* Think declares it here */ -#endif -#endif - -#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ -#define READ_BINARY "r" -#define WRITE_BINARY "w" -#else -#ifdef VMS /* VMS is very nonstandard */ -#define READ_BINARY "rb", "ctx=stm" -#define WRITE_BINARY "wb", "ctx=stm" -#else /* standard ANSI-compliant case */ -#define READ_BINARY "rb" -#define WRITE_BINARY "wb" -#endif -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif -#ifndef EXIT_SUCCESS -#ifdef VMS -#define EXIT_SUCCESS 1 /* VMS is very nonstandard */ -#else -#define EXIT_SUCCESS 0 -#endif -#endif - -/* Reduce this value if your malloc() can't allocate blocks up to 64K. - * On DOS, compiling in large model is usually a better solution. - */ - -#ifndef MAX_COM_LENGTH -#define MAX_COM_LENGTH 65000L /* must be <= 65533 in any case */ -#endif - - -/* - * These macros are used to read the input file and write the output file. - * To reuse this code in another application, you might need to change these. - */ - -static FILE * infile; /* input JPEG file */ - -/* Return next input byte, or EOF if no more */ -#define NEXTBYTE() getc(infile) - -static FILE * outfile; /* output JPEG file */ - -/* Emit an output byte */ -#define PUTBYTE(x) putc((x), outfile) - - -/* Error exit handler */ -#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) - - -/* Read one byte, testing for EOF */ -static int -read_1_byte (void) -{ - int c; - - c = NEXTBYTE(); - if (c == EOF) - ERREXIT("Premature EOF in JPEG file"); - return c; -} - -/* Read 2 bytes, convert to unsigned int */ -/* All 2-byte quantities in JPEG markers are MSB first */ -static unsigned int -read_2_bytes (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - if (c1 == EOF) - ERREXIT("Premature EOF in JPEG file"); - c2 = NEXTBYTE(); - if (c2 == EOF) - ERREXIT("Premature EOF in JPEG file"); - return (((unsigned int) c1) << 8) + ((unsigned int) c2); -} - - -/* Routines to write data to output file */ - -static void -write_1_byte (int c) -{ - PUTBYTE(c); -} - -static void -write_2_bytes (unsigned int val) -{ - PUTBYTE((val >> 8) & 0xFF); - PUTBYTE(val & 0xFF); -} - -static void -write_marker (int marker) -{ - PUTBYTE(0xFF); - PUTBYTE(marker); -} - -static void -copy_rest_of_file (void) -{ - int c; - - while ((c = NEXTBYTE()) != EOF) - PUTBYTE(c); -} - - -/* - * JPEG markers consist of one or more 0xFF bytes, followed by a marker - * code byte (which is not an FF). Here are the marker codes of interest - * in this program. (See jdmarker.c for a more complete list.) - */ - -#define M_SOF0 0xC0 /* Start Of Frame N */ -#define M_SOF1 0xC1 /* N indicates which compression process */ -#define M_SOF2 0xC2 /* Only SOF0-SOF2 are now in common use */ -#define M_SOF3 0xC3 -#define M_SOF5 0xC5 /* NB: codes C4 and CC are NOT SOF markers */ -#define M_SOF6 0xC6 -#define M_SOF7 0xC7 -#define M_SOF9 0xC9 -#define M_SOF10 0xCA -#define M_SOF11 0xCB -#define M_SOF13 0xCD -#define M_SOF14 0xCE -#define M_SOF15 0xCF -#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */ -#define M_EOI 0xD9 /* End Of Image (end of datastream) */ -#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */ -#define M_COM 0xFE /* COMment */ - - -/* - * Find the next JPEG marker and return its marker code. - * We expect at least one FF byte, possibly more if the compressor used FFs - * to pad the file. (Padding FFs will NOT be replicated in the output file.) - * There could also be non-FF garbage between markers. The treatment of such - * garbage is unspecified; we choose to skip over it but emit a warning msg. - * NB: this routine must not be used after seeing SOS marker, since it will - * not deal correctly with FF/00 sequences in the compressed image data... - */ - -static int -next_marker (void) -{ - int c; - int discarded_bytes = 0; - - /* Find 0xFF byte; count and skip any non-FFs. */ - c = read_1_byte(); - while (c != 0xFF) { - discarded_bytes++; - c = read_1_byte(); - } - /* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs - * are legal as pad bytes, so don't count them in discarded_bytes. - */ - do { - c = read_1_byte(); - } while (c == 0xFF); - - if (discarded_bytes != 0) { - fprintf(stderr, "Warning: garbage data found in JPEG file\n"); - } - - return c; -} - - -/* - * Read the initial marker, which should be SOI. - * For a JFIF file, the first two bytes of the file should be literally - * 0xFF M_SOI. To be more general, we could use next_marker, but if the - * input file weren't actually JPEG at all, next_marker might read the whole - * file and then return a misleading error message... - */ - -static int -first_marker (void) -{ - int c1, c2; - - c1 = NEXTBYTE(); - c2 = NEXTBYTE(); - if (c1 != 0xFF || c2 != M_SOI) - ERREXIT("Not a JPEG file"); - return c2; -} - - -/* - * Most types of marker are followed by a variable-length parameter segment. - * This routine skips over the parameters for any marker we don't otherwise - * want to process. - * Note that we MUST skip the parameter segment explicitly in order not to - * be fooled by 0xFF bytes that might appear within the parameter segment; - * such bytes do NOT introduce new markers. - */ - -static void -copy_variable (void) -/* Copy an unknown or uninteresting variable-length marker */ -{ - unsigned int length; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - write_2_bytes(length); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - /* Copy the remaining bytes */ - while (length > 0) { - write_1_byte(read_1_byte()); - length--; - } -} - -static void -skip_variable (void) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - unsigned int length; - - /* Get the marker parameter length count */ - length = read_2_bytes(); - /* Length includes itself, so must be at least 2 */ - if (length < 2) - ERREXIT("Erroneous JPEG marker length"); - length -= 2; - /* Skip over the remaining bytes */ - while (length > 0) { - (void) read_1_byte(); - length--; - } -} - - -/* - * Parse the marker stream until SOFn or EOI is seen; - * copy data to output, but discard COM markers unless keep_COM is true. - */ - -static int -scan_JPEG_header (int keep_COM) -{ - int marker; - - /* Expect SOI at start of file */ - if (first_marker() != M_SOI) - ERREXIT("Expected SOI marker first"); - write_marker(M_SOI); - - /* Scan miscellaneous markers until we reach SOFn. */ - for (;;) { - marker = next_marker(); - switch (marker) { - /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, - * treated as SOFn. C4 in particular is actually DHT. - */ - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - case M_SOF2: /* Progressive, Huffman */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_SOF9: /* Extended sequential, arithmetic */ - case M_SOF10: /* Progressive, arithmetic */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - return marker; - - case M_SOS: /* should not see compressed data before SOF */ - ERREXIT("SOS without prior SOFn"); - break; - - case M_EOI: /* in case it's a tables-only JPEG stream */ - return marker; - - case M_COM: /* Existing COM: conditionally discard */ - if (keep_COM) { - write_marker(marker); - copy_variable(); - } else { - skip_variable(); - } - break; - - default: /* Anything else just gets copied */ - write_marker(marker); - copy_variable(); /* we assume it has a parameter count... */ - break; - } - } /* end loop */ -} - - -/* Command line parsing code */ - -static const char * progname; /* program name for error messages */ - - -static void -usage (void) -/* complain about bad command line */ -{ - fprintf(stderr, "wrjpgcom inserts a textual comment in a JPEG file.\n"); - fprintf(stderr, "You can add to or replace any existing comment(s).\n"); - - fprintf(stderr, "Usage: %s [switches] ", progname); -#ifdef TWO_FILE_COMMANDLINE - fprintf(stderr, "inputfile outputfile\n"); -#else - fprintf(stderr, "[inputfile]\n"); -#endif - - fprintf(stderr, "Switches (names may be abbreviated):\n"); - fprintf(stderr, " -replace Delete any existing comments\n"); - fprintf(stderr, " -comment \"text\" Insert comment with given text\n"); - fprintf(stderr, " -cfile name Read comment from named file\n"); - fprintf(stderr, "Notice that you must put quotes around the comment text\n"); - fprintf(stderr, "when you use -comment.\n"); - fprintf(stderr, "If you do not give either -comment or -cfile on the command line,\n"); - fprintf(stderr, "then the comment text is read from standard input.\n"); - fprintf(stderr, "It can be multiple lines, up to %u characters total.\n", - (unsigned int) MAX_COM_LENGTH); -#ifndef TWO_FILE_COMMANDLINE - fprintf(stderr, "You must specify an input JPEG file name when supplying\n"); - fprintf(stderr, "comment text from standard input.\n"); -#endif - - exit(EXIT_FAILURE); -} - - -static int -keymatch (char * arg, const char * keyword, int minchars) -/* Case-insensitive matching of (possibly abbreviated) keyword switches. */ -/* keyword is the constant keyword (must be lower case already), */ -/* minchars is length of minimum legal abbreviation. */ -{ - register int ca, ck; - register int nmatched = 0; - - while ((ca = *arg++) != '\0') { - if ((ck = *keyword++) == '\0') - return 0; /* arg longer than keyword, no good */ - if (isupper(ca)) /* force arg to lcase (assume ck is already) */ - ca = tolower(ca); - if (ca != ck) - return 0; /* no good */ - nmatched++; /* count matched characters */ - } - /* reached end of argument; fail if it's too short for unique abbrev */ - if (nmatched < minchars) - return 0; - return 1; /* A-OK */ -} - - -/* - * The main program. - */ - -int -main (int argc, char **argv) -{ - int argn; - char * arg; - int keep_COM = 1; - char * comment_arg = NULL; - FILE * comment_file = NULL; - unsigned int comment_length = 0; - int marker; - - /* On Mac, fetch a command line. */ -#ifdef USE_CCOMMAND - argc = ccommand(&argv); -#endif - - progname = argv[0]; - if (progname == NULL || progname[0] == 0) - progname = "wrjpgcom"; /* in case C library doesn't provide it */ - - /* Parse switches, if any */ - for (argn = 1; argn < argc; argn++) { - arg = argv[argn]; - if (arg[0] != '-') - break; /* not switch, must be file name */ - arg++; /* advance over '-' */ - if (keymatch(arg, "replace", 1)) { - keep_COM = 0; - } else if (keymatch(arg, "cfile", 2)) { - if (++argn >= argc) usage(); - if ((comment_file = fopen(argv[argn], "r")) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - } else if (keymatch(arg, "comment", 1)) { - if (++argn >= argc) usage(); - comment_arg = argv[argn]; - /* If the comment text starts with '"', then we are probably running - * under MS-DOG and must parse out the quoted string ourselves. Sigh. - */ - if (comment_arg[0] == '"') { - comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); - if (comment_arg == NULL) - ERREXIT("Insufficient memory"); - if (strlen(argv[argn]+1) >= (size_t) MAX_COM_LENGTH) { - fprintf(stderr, "Comment text may not exceed %u bytes\n", - (unsigned int) MAX_COM_LENGTH); - exit(EXIT_FAILURE); - } - strcpy(comment_arg, argv[argn]+1); - for (;;) { - comment_length = (unsigned int) strlen(comment_arg); - if (comment_length > 0 && comment_arg[comment_length-1] == '"') { - comment_arg[comment_length-1] = '\0'; /* zap terminating quote */ - break; - } - if (++argn >= argc) - ERREXIT("Missing ending quote mark"); - if (strlen(comment_arg) + 1 + strlen(argv[argn]) >= - (size_t) MAX_COM_LENGTH) { - fprintf(stderr, "Comment text may not exceed %u bytes\n", - (unsigned int) MAX_COM_LENGTH); - exit(EXIT_FAILURE); - } - strcat(comment_arg, " "); - strcat(comment_arg, argv[argn]); - } - } else if (strlen(comment_arg) >= (size_t) MAX_COM_LENGTH) { - fprintf(stderr, "Comment text may not exceed %u bytes\n", - (unsigned int) MAX_COM_LENGTH); - exit(EXIT_FAILURE); - } - comment_length = (unsigned int) strlen(comment_arg); - } else - usage(); - } - - /* Cannot use both -comment and -cfile. */ - if (comment_arg != NULL && comment_file != NULL) - usage(); - /* If there is neither -comment nor -cfile, we will read the comment text - * from stdin; in this case there MUST be an input JPEG file name. - */ - if (comment_arg == NULL && comment_file == NULL && argn >= argc) - usage(); - - /* Open the input file. */ - if (argn < argc) { - if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]); - exit(EXIT_FAILURE); - } - } else { - /* default input file is stdin */ -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdin), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open stdin\n", progname); - exit(EXIT_FAILURE); - } -#else - infile = stdin; -#endif - } - - /* Open the output file. */ -#ifdef TWO_FILE_COMMANDLINE - /* Must have explicit output file name */ - if (argn != argc-2) { - fprintf(stderr, "%s: must name one input and one output file\n", - progname); - usage(); - } - if ((outfile = fopen(argv[argn+1], WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open %s\n", progname, argv[argn+1]); - exit(EXIT_FAILURE); - } -#else - /* Unix style: expect zero or one file name */ - if (argn < argc-1) { - fprintf(stderr, "%s: only one input file\n", progname); - usage(); - } - /* default output file is stdout */ -#ifdef USE_SETMODE /* need to hack file mode? */ - setmode(fileno(stdout), O_BINARY); -#endif -#ifdef USE_FDOPEN /* need to re-open in binary mode? */ - if ((outfile = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { - fprintf(stderr, "%s: can't open stdout\n", progname); - exit(EXIT_FAILURE); - } -#else - outfile = stdout; -#endif -#endif /* TWO_FILE_COMMANDLINE */ - - /* Collect comment text from comment_file or stdin, if necessary */ - if (comment_arg == NULL) { - FILE * src_file; - int c; - - comment_arg = (char *) malloc((size_t) MAX_COM_LENGTH); - if (comment_arg == NULL) - ERREXIT("Insufficient memory"); - comment_length = 0; - src_file = (comment_file != NULL ? comment_file : stdin); - while ((c = getc(src_file)) != EOF) { - if (comment_length >= (unsigned int) MAX_COM_LENGTH) { - fprintf(stderr, "Comment text may not exceed %u bytes\n", - (unsigned int) MAX_COM_LENGTH); - exit(EXIT_FAILURE); - } - comment_arg[comment_length++] = (char) c; - } - if (comment_file != NULL) - fclose(comment_file); - } - - /* Copy JPEG headers until SOFn marker; - * we will insert the new comment marker just before SOFn. - * This (a) causes the new comment to appear after, rather than before, - * existing comments; and (b) ensures that comments come after any JFIF - * or JFXX markers, as required by the JFIF specification. - */ - marker = scan_JPEG_header(keep_COM); - /* Insert the new COM marker, but only if nonempty text has been supplied */ - if (comment_length > 0) { - write_marker(M_COM); - write_2_bytes(comment_length + 2); - while (comment_length > 0) { - write_1_byte(*comment_arg++); - comment_length--; - } - } - /* Duplicate the remainder of the source file. - * Note that any COM markers occuring after SOF will not be touched. - */ - write_marker(marker); - copy_rest_of_file(); - - /* All done. */ - exit(EXIT_SUCCESS); - return 0; /* suppress no-return-value warnings */ -} diff --git a/code/jpeg-9f/wrppm.c b/code/jpeg-9f/wrppm.c deleted file mode 100644 index c9e03ad1..00000000 --- a/code/jpeg-9f/wrppm.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * wrppm.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * Modified 2009-2020 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in PPM/PGM format. - * The extended 2-byte-per-sample raw PPM/PGM formats are supported. - * The PBMPLUS library is NOT required to compile this software - * (but it is highly useful as a set of PPM image manipulation programs). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef PPM_SUPPORTED - - -/* - * For 12-bit JPEG data, we either downscale the values to 8 bits - * (to write standard byte-per-sample PPM/PGM files), or output - * nonstandard word-per-sample PPM/PGM files. Downscaling is done - * if PPM_NORAWWORD is defined (this can be done in the Makefile - * or in jconfig.h). - * (When the core library supports data precision reduction, a cleaner - * implementation will be to ask for that instead.) - */ - -#if BITS_IN_JSAMPLE == 8 -#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) (v) -#define BYTESPERSAMPLE 1 -#define PPM_MAXVAL 255 -#else -#ifdef PPM_NORAWWORD -#define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) ((v) >> (BITS_IN_JSAMPLE-8)) -#define BYTESPERSAMPLE 1 -#define PPM_MAXVAL 255 -#else -/* The word-per-sample format always puts the MSB first. */ -#define PUTPPMSAMPLE(ptr,v) \ - { register int val_ = v; \ - *ptr++ = (char) ((val_ >> 8) & 0xFF); \ - *ptr++ = (char) (val_ & 0xFF); \ - } -#define BYTESPERSAMPLE 2 -#define PPM_MAXVAL ((1<pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * This code is used when we have to copy the data and apply a pixel - * format translation. Typically this only happens in 12-bit mode. - */ - -METHODDEF(void) -copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - register char * bufferptr; - register JSAMPROW ptr; - register JDIMENSION col; - - ptr = dest->pixrow; - bufferptr = dest->iobuffer; - for (col = dest->samples_per_row; col > 0; col--) { - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(*ptr++)); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Write some pixel data when color quantization is in effect. - * We have to demap the color index values to straight data. - */ - -METHODDEF(void) -put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - register char * bufferptr; - register int pixval; - register JSAMPROW ptr; - register JSAMPROW color_map0 = cinfo->colormap[0]; - register JSAMPROW color_map1 = cinfo->colormap[1]; - register JSAMPROW color_map2 = cinfo->colormap[2]; - register JDIMENSION col; - - ptr = dest->pixrow; - bufferptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - pixval = GETJSAMPLE(*ptr++); - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map0[pixval])); - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map1[pixval])); - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map2[pixval])); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - -METHODDEF(void) -put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - ppm_dest_ptr dest = (ppm_dest_ptr) dinfo; - register char * bufferptr; - register JSAMPROW ptr; - register JSAMPROW color_map0 = cinfo->colormap[0]; - register JDIMENSION col; - - ptr = dest->pixrow; - bufferptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map0[GETJSAMPLE(*ptr++)])); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Startup: write the file header. - */ - -METHODDEF(void) -start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* Emit file header */ - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - /* emit header for raw PGM format */ - fprintf(dinfo->output_file, "P5\n%ld %ld\n%d\n", - (long) cinfo->output_width, (long) cinfo->output_height, - PPM_MAXVAL); - break; - case JCS_RGB: - /* emit header for raw PPM format */ - fprintf(dinfo->output_file, "P6\n%ld %ld\n%d\n", - (long) cinfo->output_width, (long) cinfo->output_height, - PPM_MAXVAL); - break; - default: - ERREXIT(cinfo, JERR_PPM_COLORSPACE); - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* Make sure we wrote the output file OK */ - JFFLUSH(dinfo->output_file); - if (JFERROR(dinfo->output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for PPM format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_ppm (j_decompress_ptr cinfo) -{ - ppm_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (ppm_dest_ptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(ppm_dest_struct)); - dest->pub.start_output = start_output_ppm; - dest->pub.finish_output = finish_output_ppm; - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Create physical I/O buffer. Note we make this near on a PC. */ - dest->samples_per_row = cinfo->output_width * cinfo->out_color_components; - dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * SIZEOF(char)); - dest->iobuffer = (char *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width); - - if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 || - SIZEOF(JSAMPLE) != SIZEOF(char)) { - /* When quantizing, we need an output buffer for colormap indexes - * that's separate from the physical I/O buffer. We also need a - * separate buffer if pixel format translation must take place. - */ - dest->pixrow = (JSAMPROW) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, (size_t) cinfo->output_width * - (size_t) cinfo->output_components * SIZEOF(JSAMPLE)); - if (! cinfo->quantize_colors) - dest->pub.put_pixel_rows = copy_pixel_rows; - else if (cinfo->out_color_space == JCS_GRAYSCALE) - dest->pub.put_pixel_rows = put_demapped_gray; - else - dest->pub.put_pixel_rows = put_demapped_rgb; - } else { - /* We will fwrite() directly from decompressor output buffer. */ - /* Cast here implies near->far pointer conversion on PCs */ - dest->pixrow = (JSAMPROW) dest->iobuffer; - dest->pub.put_pixel_rows = put_pixel_rows; - } - /* Synthesize a JSAMPARRAY pointer structure */ - dest->pub.buffer = & dest->pixrow; - dest->pub.buffer_height = 1; - - return &dest->pub; -} - -#endif /* PPM_SUPPORTED */ diff --git a/code/jpeg-9f/wrrle.c b/code/jpeg-9f/wrrle.c deleted file mode 100644 index dc2fadb8..00000000 --- a/code/jpeg-9f/wrrle.c +++ /dev/null @@ -1,306 +0,0 @@ -/* - * wrrle.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * Modified 2017-2019 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in RLE format. - * The Utah Raster Toolkit library is required (version 3.1 or later). - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - * - * Based on code contributed by Mike Lijewski, - * with updates from Robert Hutchinson. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef RLE_SUPPORTED - -/* rle.h is provided by the Utah Raster Toolkit. */ - -#include - -/* - * We assume that JSAMPLE has the same representation as rle_pixel, - * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - - -/* - * Since RLE stores scanlines bottom-to-top, we have to invert the image - * from JPEG's top-to-bottom order. To do this, we save the outgoing data - * in a virtual array during put_pixel_row calls, then actually emit the - * RLE file during finish_output. - */ - - -/* - * For now, if we emit an RLE color map then it is always 256 entries long, - * though not all of the entries need be used. - */ - -#define CMAPBITS 8 -#define CMAPLENGTH (1<<(CMAPBITS)) - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - jvirt_sarray_ptr image; /* virtual array to store the output image */ - rle_map *colormap; /* RLE-style color map, or NULL if none */ - rle_pixel **rle_row; /* To pass rows to rle_putrow() */ - -} rle_dest_struct; - -typedef rle_dest_struct * rle_dest_ptr; - - -/* Forward declarations */ -METHODDEF(void) rle_put_pixel_rows - JPP((j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied)); - - -/* - * Write the file header. - * - * In this module it's easier to wait till finish_output to write anything. - */ - -METHODDEF(void) -start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - rle_dest_ptr dest = (rle_dest_ptr) dinfo; - size_t cmapsize; - int ci, i; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* - * Make sure the image can be stored in RLE format. - * - * - RLE stores image dimensions as *signed* 16 bit integers. JPEG - * uses unsigned, so we have to check the width. - * - * - Colorspace is expected to be grayscale or RGB. - * - * - The number of channels (components) is expected to be 1 (grayscale/ - * pseudocolor) or 3 (truecolor/directcolor). - * (could be 2 or 4 if using an alpha channel, but we aren't) - */ - - if (cinfo->output_width > 32767 || cinfo->output_height > 32767) - ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width, - cinfo->output_height); - - if (cinfo->out_color_space != JCS_GRAYSCALE && - cinfo->out_color_space != JCS_RGB) - ERREXIT(cinfo, JERR_RLE_COLORSPACE); - - if (cinfo->output_components != 1 && cinfo->output_components != 3) - ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components); - - /* Convert colormap, if any, to RLE format. */ - - dest->colormap = NULL; - - if (cinfo->quantize_colors) { - /* Allocate storage for RLE-style cmap, zero any extra entries */ - cmapsize = cinfo->out_color_components * CMAPLENGTH * SIZEOF(rle_map); - dest->colormap = (rle_map *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize); - MEMZERO(dest->colormap, cmapsize); - - /* Save away data in RLE format --- note 8-bit left shift! */ - /* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */ - for (ci = 0; ci < cinfo->out_color_components; ci++) { - for (i = 0; i < cinfo->actual_number_of_colors; i++) { - dest->colormap[ci * CMAPLENGTH + i] = - GETJSAMPLE(cinfo->colormap[ci][i]) << 8; - } - } - } - - /* Set the output buffer to the first row */ - dest->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, (JDIMENSION) 0, (JDIMENSION) 1, TRUE); - dest->pub.buffer_height = 1; - - dest->pub.put_pixel_rows = rle_put_pixel_rows; - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->total_extra_passes++; /* count file writing as separate pass */ - } -#endif -} - - -/* - * Write some pixel data. - * - * This routine just saves the data away in a virtual array. - */ - -METHODDEF(void) -rle_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - rle_dest_ptr dest = (rle_dest_ptr) dinfo; - - if (cinfo->output_scanline < cinfo->output_height) { - dest->pub.buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, - cinfo->output_scanline, (JDIMENSION) 1, TRUE); - } -} - - -/* - * Finish up at the end of the file. - * - * Here is where we really output the RLE file. - */ - -METHODDEF(void) -finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - rle_dest_ptr dest = (rle_dest_ptr) dinfo; - rle_hdr header; /* Output file information */ - rle_pixel **rle_row, *red_ptr, *green_ptr, *blue_ptr; - JSAMPROW output_row; - char cmapcomment[80]; - int row, col; - int ci; -#ifdef PROGRESS_REPORT - cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress; -#endif - - /* Initialize the header info */ - header = *rle_hdr_init(NULL); - header.rle_file = dest->pub.output_file; - header.xmin = 0; - header.xmax = cinfo->output_width - 1; - header.ymin = 0; - header.ymax = cinfo->output_height - 1; - header.alpha = 0; - header.ncolors = cinfo->output_components; - for (ci = 0; ci < cinfo->output_components; ci++) { - RLE_SET_BIT(header, ci); - } - if (cinfo->quantize_colors) { - header.ncmap = cinfo->out_color_components; - header.cmaplen = CMAPBITS; - header.cmap = dest->colormap; - /* Add a comment to the output image with the true colormap length. */ - sprintf(cmapcomment, "color_map_length=%d", cinfo->actual_number_of_colors); - rle_putcom(cmapcomment, &header); - } - - /* Emit the RLE header and color map (if any) */ - rle_put_setup(&header); - - /* Now output the RLE data from our virtual array. - * We assume here that (a) rle_pixel is represented the same as JSAMPLE, - * and (b) we are not on a machine where FAR pointers differ from regular. - */ - -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_limit = cinfo->output_height; - progress->pub.pass_counter = 0; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - - if (cinfo->output_components == 1) { - for (row = cinfo->output_height - 1; row >= 0; row--) { - rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, - (JDIMENSION) row, (JDIMENSION) 1, FALSE); - rle_putrow(rle_row, (int) cinfo->output_width, &header); -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - } else { - for (row = cinfo->output_height - 1; row >= 0; row--) { - output_row = * (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, dest->image, - (JDIMENSION) row, (JDIMENSION) 1, FALSE); - rle_row = dest->rle_row; - red_ptr = rle_row[0]; - green_ptr = rle_row[1]; - blue_ptr = rle_row[2]; - for (col = cinfo->output_width; col > 0; col--) { - *red_ptr++ = GETJSAMPLE(*output_row++); - *green_ptr++ = GETJSAMPLE(*output_row++); - *blue_ptr++ = GETJSAMPLE(*output_row++); - } - rle_putrow(rle_row, (int) cinfo->output_width, &header); -#ifdef PROGRESS_REPORT - if (progress != NULL) { - progress->pub.pass_counter++; - (*progress->pub.progress_monitor) ((j_common_ptr) cinfo); - } -#endif - } - } - -#ifdef PROGRESS_REPORT - if (progress != NULL) - progress->completed_extra_passes++; -#endif - - /* Emit file trailer */ - rle_puteof(&header); - JFFLUSH(dest->pub.output_file); - if (JFERROR(dest->pub.output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for RLE format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_rle (j_decompress_ptr cinfo) -{ - rle_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (rle_dest_ptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(rle_dest_struct)); - dest->pub.start_output = start_output_rle; - dest->pub.finish_output = finish_output_rle; - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Allocate a work array for output to the RLE library. */ - dest->rle_row = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, - JPOOL_IMAGE, cinfo->output_width, (JDIMENSION) cinfo->output_components); - - /* Allocate a virtual array to hold the image. */ - dest->image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - cinfo->output_width * (JDIMENSION) cinfo->output_components, - cinfo->output_height, (JDIMENSION) 1); - - return &dest->pub; -} - -#endif /* RLE_SUPPORTED */ diff --git a/code/jpeg-9f/wrtarga.c b/code/jpeg-9f/wrtarga.c deleted file mode 100644 index 8ded5183..00000000 --- a/code/jpeg-9f/wrtarga.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * wrtarga.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * Modified 2015-2019 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write output images in Targa format. - * - * These routines may need modification for non-Unix environments or - * specialized applications. As they stand, they assume output to - * an ordinary stdio stream. - * - * Based on code contributed by Lee Daniel Crocker. - */ - -#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ - -#ifdef TARGA_SUPPORTED - - -/* - * To support 12-bit JPEG data, we'd have to scale output down to 8 bits. - * This is not yet implemented. - */ - -#if BITS_IN_JSAMPLE != 8 - Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */ -#endif - -/* - * The output buffer needs to be writable by fwrite(). On PCs, we must - * allocate the buffer in near data space, because we are assuming small-data - * memory model, wherein fwrite() can't reach far memory. If you need to - * process very wide images on a PC, you might have to compile in large-memory - * model, or else replace fwrite() with a putc() loop --- which will be much - * slower. - */ - - -/* Private version of data destination object */ - -typedef struct { - struct djpeg_dest_struct pub; /* public fields */ - - char *iobuffer; /* physical I/O buffer */ - JDIMENSION buffer_width; /* width of one row */ -} tga_dest_struct; - -typedef tga_dest_struct * tga_dest_ptr; - - -LOCAL(void) -write_header (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors) -/* Create and write a Targa header */ -{ - char targaheader[18]; - - /* Set unused fields of header to 0 */ - MEMZERO(targaheader, SIZEOF(targaheader)); - - if (num_colors > 0) { - targaheader[1] = 1; /* color map type 1 */ - targaheader[5] = (char) (num_colors & 0xFF); - targaheader[6] = (char) (num_colors >> 8); - targaheader[7] = 24; /* 24 bits per cmap entry */ - } - - targaheader[12] = (char) (cinfo->output_width & 0xFF); - targaheader[13] = (char) (cinfo->output_width >> 8); - targaheader[14] = (char) (cinfo->output_height & 0xFF); - targaheader[15] = (char) (cinfo->output_height >> 8); - targaheader[17] = 0x20; /* Top-down, non-interlaced */ - - if (cinfo->out_color_space == JCS_GRAYSCALE) { - targaheader[2] = 3; /* image type = uncompressed grayscale */ - targaheader[16] = 8; /* bits per pixel */ - } else { /* must be RGB */ - if (num_colors > 0) { - targaheader[2] = 1; /* image type = colormapped RGB */ - targaheader[16] = 8; - } else { - targaheader[2] = 2; /* image type = uncompressed RGB */ - targaheader[16] = 24; - } - } - - if (JFWRITE(dinfo->output_file, targaheader, 18) != (size_t) 18) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * Write some pixel data. - * In this module rows_supplied will always be 1. - */ - -METHODDEF(void) -put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* used for unquantized full-color output */ -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - register JSAMPROW inptr; - register char * outptr; - register JDIMENSION col; - - inptr = dest->pub.buffer[0]; - outptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - outptr[0] = (char) GETJSAMPLE(inptr[2]); /* RGB to BGR order */ - outptr[1] = (char) GETJSAMPLE(inptr[1]); - outptr[2] = (char) GETJSAMPLE(inptr[0]); - inptr += 3, outptr += 3; - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - -METHODDEF(void) -put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -/* used for grayscale OR quantized color output */ -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - register JSAMPROW inptr; - register char * outptr; - register JDIMENSION col; - - inptr = dest->pub.buffer[0]; - outptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - *outptr++ = (char) GETJSAMPLE(*inptr++); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Write some demapped pixel data when color quantization is in effect. - * For Targa, this is only applied to grayscale data. - */ - -METHODDEF(void) -put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, - JDIMENSION rows_supplied) -{ - tga_dest_ptr dest = (tga_dest_ptr) dinfo; - register JSAMPROW inptr; - register char * outptr; - register JSAMPROW color_map0 = cinfo->colormap[0]; - register JDIMENSION col; - - inptr = dest->pub.buffer[0]; - outptr = dest->iobuffer; - for (col = cinfo->output_width; col > 0; col--) { - *outptr++ = (char) GETJSAMPLE(color_map0[GETJSAMPLE(*inptr++)]); - } - (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); -} - - -/* - * Startup: write the file header. - */ - -METHODDEF(void) -start_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - int num_colors, i; - FILE *outfile; - - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - /* Targa doesn't have a mapped grayscale format, so we will */ - /* demap quantized gray output. Never emit a colormap. */ - write_header(cinfo, dinfo, 0); - if (cinfo->quantize_colors) - dinfo->put_pixel_rows = put_demapped_gray; - else - dinfo->put_pixel_rows = put_gray_rows; - break; - case JCS_RGB: - if (cinfo->quantize_colors) { - /* We only support 8-bit colormap indexes, so only 256 colors */ - num_colors = cinfo->actual_number_of_colors; - if (num_colors > 256) - ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, num_colors); - write_header(cinfo, dinfo, num_colors); - /* Write the colormap. Note Targa uses BGR byte order */ - outfile = dinfo->output_file; - for (i = 0; i < num_colors; i++) { - putc(GETJSAMPLE(cinfo->colormap[2][i]), outfile); - putc(GETJSAMPLE(cinfo->colormap[1][i]), outfile); - putc(GETJSAMPLE(cinfo->colormap[0][i]), outfile); - } - dinfo->put_pixel_rows = put_gray_rows; - } else { - write_header(cinfo, dinfo, 0); - dinfo->put_pixel_rows = put_pixel_rows; - } - break; - default: - ERREXIT(cinfo, JERR_TGA_COLORSPACE); - } -} - - -/* - * Finish up at the end of the file. - */ - -METHODDEF(void) -finish_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo) -{ - /* Make sure we wrote the output file OK */ - JFFLUSH(dinfo->output_file); - if (JFERROR(dinfo->output_file)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * The module selection routine for Targa format output. - */ - -GLOBAL(djpeg_dest_ptr) -jinit_write_targa (j_decompress_ptr cinfo) -{ - tga_dest_ptr dest; - - /* Create module interface object, fill in method pointers */ - dest = (tga_dest_ptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(tga_dest_struct)); - dest->pub.start_output = start_output_tga; - dest->pub.finish_output = finish_output_tga; - - /* Calculate output image dimensions so we can allocate space */ - jpeg_calc_output_dimensions(cinfo); - - /* Create I/O buffer. Note we make this near on a PC. */ - dest->buffer_width = cinfo->output_width * cinfo->output_components; - dest->iobuffer = (char *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, - JPOOL_IMAGE, (size_t) dest->buffer_width * SIZEOF(char)); - - /* Create decompressor output buffer. */ - dest->pub.buffer = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, - JPOOL_IMAGE, dest->buffer_width, (JDIMENSION) 1); - dest->pub.buffer_height = 1; - - return &dest->pub; -} - -#endif /* TARGA_SUPPORTED */ diff --git a/code/libs/win32/libcurl.a b/code/libs/win32/libcurl.a deleted file mode 100644 index 47f4d284..00000000 Binary files a/code/libs/win32/libcurl.a and /dev/null differ diff --git a/code/libs/win64/libcurl.a b/code/libs/win64/libcurl.a deleted file mode 100644 index d343d480..00000000 Binary files a/code/libs/win64/libcurl.a and /dev/null differ diff --git a/code/qcommon/CMakeLists.txt b/code/qcommon/CMakeLists.txt index e60a6a7f..342e1edc 100644 --- a/code/qcommon/CMakeLists.txt +++ b/code/qcommon/CMakeLists.txt @@ -98,7 +98,7 @@ target_compile_features(qcommon_standalone INTERFACE c_variadic_macros) target_link_libraries(qcommon_standalone INTERFACE omohtiki omohskeletor) if(USE_INTERNAL_ZLIB) - set(SOURCES_ZLIB_DIR "../zlib-1.3.1") + set(SOURCES_ZLIB_DIR "../thirdparty/zlib-1.3.1") add_library(zlib INTERFACE) target_sources(zlib INTERFACE diff --git a/code/renderercommon/CMakeLists.txt b/code/renderercommon/CMakeLists.txt index b6953f5e..defc9d0f 100644 --- a/code/renderercommon/CMakeLists.txt +++ b/code/renderercommon/CMakeLists.txt @@ -18,7 +18,7 @@ target_compile_definitions(omohrenderer_common PRIVATE USE_INTERNAL_JPEG=1) # Add JPEG if(USE_INTERNAL_JPEG) - set(SOURCES_JPEG_DIR "../jpeg-9f") + set(SOURCES_JPEG_DIR "../thirdparty/jpeg-9f") set(SOURCES_JPEG "${SOURCES_JPEG_DIR}/jaricom.c" "${SOURCES_JPEG_DIR}/jcapimin.c" diff --git a/code/sdl/CMakeLists.txt b/code/sdl/CMakeLists.txt index 992986ac..63934174 100644 --- a/code/sdl/CMakeLists.txt +++ b/code/sdl/CMakeLists.txt @@ -43,28 +43,28 @@ if(WIN32) else() message(WARNING "SDL2 not found, falling back to using SDL2 from the source tree") - target_include_directories(sdllib INTERFACE "../SDL2-2.32.8/include") + target_include_directories(sdllib INTERFACE "../thirdparty/SDL2-2.32.8/include") if (MSVC) if(CMAKE_SIZEOF_VOID_P EQUAL 8) add_library(sdl2 SHARED IMPORTED) set_target_properties(sdl2 PROPERTIES - IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/code/libs/win64/SDL2.lib" + IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/code/thirdparty/libs/win64/SDL2.lib" ) add_library(sdl2main SHARED IMPORTED) set_target_properties(sdl2main PROPERTIES - IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/code/libs/win64/SDL2main.lib" + IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/code/thirdparty/libs/win64/SDL2main.lib" ) else() add_library(sdl2 SHARED IMPORTED) set_target_properties(sdl2 PROPERTIES - IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/code/libs/win32/SDL2.lib" + IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/code/thirdparty/libs/win32/SDL2.lib" ) add_library(sdl2main SHARED IMPORTED) set_target_properties(sdl2main PROPERTIES - IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/code/libs/win32/SDL2main.lib" + IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/code/thirdparty/libs/win32/SDL2main.lib" ) endif() diff --git a/code/SDL2-2.32.8/include/SDL.h b/code/thirdparty/SDL2-2.32.8/include/SDL.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL.h rename to code/thirdparty/SDL2-2.32.8/include/SDL.h diff --git a/code/SDL2-2.32.8/include/SDL_assert.h b/code/thirdparty/SDL2-2.32.8/include/SDL_assert.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_assert.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_assert.h diff --git a/code/SDL2-2.32.8/include/SDL_atomic.h b/code/thirdparty/SDL2-2.32.8/include/SDL_atomic.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_atomic.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_atomic.h diff --git a/code/SDL2-2.32.8/include/SDL_audio.h b/code/thirdparty/SDL2-2.32.8/include/SDL_audio.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_audio.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_audio.h diff --git a/code/SDL2-2.32.8/include/SDL_bits.h b/code/thirdparty/SDL2-2.32.8/include/SDL_bits.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_bits.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_bits.h diff --git a/code/SDL2-2.32.8/include/SDL_blendmode.h b/code/thirdparty/SDL2-2.32.8/include/SDL_blendmode.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_blendmode.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_blendmode.h diff --git a/code/SDL2-2.32.8/include/SDL_clipboard.h b/code/thirdparty/SDL2-2.32.8/include/SDL_clipboard.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_clipboard.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_clipboard.h diff --git a/code/SDL2-2.32.8/include/SDL_config.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config.h diff --git a/code/SDL2-2.32.8/include/SDL_config_android.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config_android.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config_android.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config_android.h diff --git a/code/SDL2-2.32.8/include/SDL_config_emscripten.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config_emscripten.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config_emscripten.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config_emscripten.h diff --git a/code/SDL2-2.32.8/include/SDL_config_iphoneos.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config_iphoneos.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config_iphoneos.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config_iphoneos.h diff --git a/code/SDL2-2.32.8/include/SDL_config_macosx.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config_macosx.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config_macosx.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config_macosx.h diff --git a/code/SDL2-2.32.8/include/SDL_config_minimal.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config_minimal.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config_minimal.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config_minimal.h diff --git a/code/SDL2-2.32.8/include/SDL_config_ngage.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config_ngage.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config_ngage.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config_ngage.h diff --git a/code/SDL2-2.32.8/include/SDL_config_os2.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config_os2.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config_os2.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config_os2.h diff --git a/code/SDL2-2.32.8/include/SDL_config_pandora.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config_pandora.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config_pandora.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config_pandora.h diff --git a/code/SDL2-2.32.8/include/SDL_config_windows.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config_windows.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config_windows.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config_windows.h diff --git a/code/SDL2-2.32.8/include/SDL_config_wingdk.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config_wingdk.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config_wingdk.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config_wingdk.h diff --git a/code/SDL2-2.32.8/include/SDL_config_winrt.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config_winrt.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config_winrt.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config_winrt.h diff --git a/code/SDL2-2.32.8/include/SDL_config_xbox.h b/code/thirdparty/SDL2-2.32.8/include/SDL_config_xbox.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_config_xbox.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_config_xbox.h diff --git a/code/SDL2-2.32.8/include/SDL_copying.h b/code/thirdparty/SDL2-2.32.8/include/SDL_copying.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_copying.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_copying.h diff --git a/code/SDL2-2.32.8/include/SDL_cpuinfo.h b/code/thirdparty/SDL2-2.32.8/include/SDL_cpuinfo.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_cpuinfo.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_cpuinfo.h diff --git a/code/SDL2-2.32.8/include/SDL_egl.h b/code/thirdparty/SDL2-2.32.8/include/SDL_egl.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_egl.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_egl.h diff --git a/code/SDL2-2.32.8/include/SDL_endian.h b/code/thirdparty/SDL2-2.32.8/include/SDL_endian.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_endian.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_endian.h diff --git a/code/SDL2-2.32.8/include/SDL_error.h b/code/thirdparty/SDL2-2.32.8/include/SDL_error.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_error.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_error.h diff --git a/code/SDL2-2.32.8/include/SDL_events.h b/code/thirdparty/SDL2-2.32.8/include/SDL_events.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_events.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_events.h diff --git a/code/SDL2-2.32.8/include/SDL_filesystem.h b/code/thirdparty/SDL2-2.32.8/include/SDL_filesystem.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_filesystem.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_filesystem.h diff --git a/code/SDL2-2.32.8/include/SDL_gamecontroller.h b/code/thirdparty/SDL2-2.32.8/include/SDL_gamecontroller.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_gamecontroller.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_gamecontroller.h diff --git a/code/SDL2-2.32.8/include/SDL_gesture.h b/code/thirdparty/SDL2-2.32.8/include/SDL_gesture.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_gesture.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_gesture.h diff --git a/code/SDL2-2.32.8/include/SDL_guid.h b/code/thirdparty/SDL2-2.32.8/include/SDL_guid.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_guid.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_guid.h diff --git a/code/SDL2-2.32.8/include/SDL_haptic.h b/code/thirdparty/SDL2-2.32.8/include/SDL_haptic.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_haptic.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_haptic.h diff --git a/code/SDL2-2.32.8/include/SDL_hidapi.h b/code/thirdparty/SDL2-2.32.8/include/SDL_hidapi.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_hidapi.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_hidapi.h diff --git a/code/SDL2-2.32.8/include/SDL_hints.h b/code/thirdparty/SDL2-2.32.8/include/SDL_hints.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_hints.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_hints.h diff --git a/code/SDL2-2.32.8/include/SDL_joystick.h b/code/thirdparty/SDL2-2.32.8/include/SDL_joystick.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_joystick.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_joystick.h diff --git a/code/SDL2-2.32.8/include/SDL_keyboard.h b/code/thirdparty/SDL2-2.32.8/include/SDL_keyboard.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_keyboard.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_keyboard.h diff --git a/code/SDL2-2.32.8/include/SDL_keycode.h b/code/thirdparty/SDL2-2.32.8/include/SDL_keycode.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_keycode.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_keycode.h diff --git a/code/SDL2-2.32.8/include/SDL_loadso.h b/code/thirdparty/SDL2-2.32.8/include/SDL_loadso.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_loadso.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_loadso.h diff --git a/code/SDL2-2.32.8/include/SDL_locale.h b/code/thirdparty/SDL2-2.32.8/include/SDL_locale.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_locale.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_locale.h diff --git a/code/SDL2-2.32.8/include/SDL_log.h b/code/thirdparty/SDL2-2.32.8/include/SDL_log.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_log.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_log.h diff --git a/code/SDL2-2.32.8/include/SDL_main.h b/code/thirdparty/SDL2-2.32.8/include/SDL_main.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_main.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_main.h diff --git a/code/SDL2-2.32.8/include/SDL_messagebox.h b/code/thirdparty/SDL2-2.32.8/include/SDL_messagebox.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_messagebox.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_messagebox.h diff --git a/code/SDL2-2.32.8/include/SDL_metal.h b/code/thirdparty/SDL2-2.32.8/include/SDL_metal.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_metal.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_metal.h diff --git a/code/SDL2-2.32.8/include/SDL_misc.h b/code/thirdparty/SDL2-2.32.8/include/SDL_misc.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_misc.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_misc.h diff --git a/code/SDL2-2.32.8/include/SDL_mouse.h b/code/thirdparty/SDL2-2.32.8/include/SDL_mouse.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_mouse.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_mouse.h diff --git a/code/SDL2-2.32.8/include/SDL_mutex.h b/code/thirdparty/SDL2-2.32.8/include/SDL_mutex.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_mutex.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_mutex.h diff --git a/code/SDL2-2.32.8/include/SDL_name.h b/code/thirdparty/SDL2-2.32.8/include/SDL_name.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_name.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_name.h diff --git a/code/SDL2-2.32.8/include/SDL_opengl.h b/code/thirdparty/SDL2-2.32.8/include/SDL_opengl.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_opengl.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_opengl.h diff --git a/code/SDL2-2.32.8/include/SDL_opengl_glext.h b/code/thirdparty/SDL2-2.32.8/include/SDL_opengl_glext.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_opengl_glext.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_opengl_glext.h diff --git a/code/SDL2-2.32.8/include/SDL_opengles.h b/code/thirdparty/SDL2-2.32.8/include/SDL_opengles.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_opengles.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_opengles.h diff --git a/code/SDL2-2.32.8/include/SDL_opengles2.h b/code/thirdparty/SDL2-2.32.8/include/SDL_opengles2.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_opengles2.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_opengles2.h diff --git a/code/SDL2-2.32.8/include/SDL_opengles2_gl2.h b/code/thirdparty/SDL2-2.32.8/include/SDL_opengles2_gl2.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_opengles2_gl2.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_opengles2_gl2.h diff --git a/code/SDL2-2.32.8/include/SDL_opengles2_gl2ext.h b/code/thirdparty/SDL2-2.32.8/include/SDL_opengles2_gl2ext.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_opengles2_gl2ext.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_opengles2_gl2ext.h diff --git a/code/SDL2-2.32.8/include/SDL_opengles2_gl2platform.h b/code/thirdparty/SDL2-2.32.8/include/SDL_opengles2_gl2platform.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_opengles2_gl2platform.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_opengles2_gl2platform.h diff --git a/code/SDL2-2.32.8/include/SDL_opengles2_khrplatform.h b/code/thirdparty/SDL2-2.32.8/include/SDL_opengles2_khrplatform.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_opengles2_khrplatform.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_opengles2_khrplatform.h diff --git a/code/SDL2-2.32.8/include/SDL_pixels.h b/code/thirdparty/SDL2-2.32.8/include/SDL_pixels.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_pixels.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_pixels.h diff --git a/code/SDL2-2.32.8/include/SDL_platform.h b/code/thirdparty/SDL2-2.32.8/include/SDL_platform.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_platform.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_platform.h diff --git a/code/SDL2-2.32.8/include/SDL_power.h b/code/thirdparty/SDL2-2.32.8/include/SDL_power.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_power.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_power.h diff --git a/code/SDL2-2.32.8/include/SDL_quit.h b/code/thirdparty/SDL2-2.32.8/include/SDL_quit.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_quit.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_quit.h diff --git a/code/SDL2-2.32.8/include/SDL_rect.h b/code/thirdparty/SDL2-2.32.8/include/SDL_rect.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_rect.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_rect.h diff --git a/code/SDL2-2.32.8/include/SDL_render.h b/code/thirdparty/SDL2-2.32.8/include/SDL_render.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_render.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_render.h diff --git a/code/SDL2-2.32.8/include/SDL_revision.h b/code/thirdparty/SDL2-2.32.8/include/SDL_revision.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_revision.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_revision.h diff --git a/code/SDL2-2.32.8/include/SDL_rwops.h b/code/thirdparty/SDL2-2.32.8/include/SDL_rwops.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_rwops.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_rwops.h diff --git a/code/SDL2-2.32.8/include/SDL_scancode.h b/code/thirdparty/SDL2-2.32.8/include/SDL_scancode.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_scancode.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_scancode.h diff --git a/code/SDL2-2.32.8/include/SDL_sensor.h b/code/thirdparty/SDL2-2.32.8/include/SDL_sensor.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_sensor.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_sensor.h diff --git a/code/SDL2-2.32.8/include/SDL_shape.h b/code/thirdparty/SDL2-2.32.8/include/SDL_shape.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_shape.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_shape.h diff --git a/code/SDL2-2.32.8/include/SDL_stdinc.h b/code/thirdparty/SDL2-2.32.8/include/SDL_stdinc.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_stdinc.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_stdinc.h diff --git a/code/SDL2-2.32.8/include/SDL_surface.h b/code/thirdparty/SDL2-2.32.8/include/SDL_surface.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_surface.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_surface.h diff --git a/code/SDL2-2.32.8/include/SDL_system.h b/code/thirdparty/SDL2-2.32.8/include/SDL_system.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_system.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_system.h diff --git a/code/SDL2-2.32.8/include/SDL_syswm.h b/code/thirdparty/SDL2-2.32.8/include/SDL_syswm.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_syswm.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_syswm.h diff --git a/code/SDL2-2.32.8/include/SDL_test.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test.h diff --git a/code/SDL2-2.32.8/include/SDL_test_assert.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test_assert.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test_assert.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test_assert.h diff --git a/code/SDL2-2.32.8/include/SDL_test_common.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test_common.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test_common.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test_common.h diff --git a/code/SDL2-2.32.8/include/SDL_test_compare.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test_compare.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test_compare.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test_compare.h diff --git a/code/SDL2-2.32.8/include/SDL_test_crc32.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test_crc32.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test_crc32.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test_crc32.h diff --git a/code/SDL2-2.32.8/include/SDL_test_font.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test_font.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test_font.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test_font.h diff --git a/code/SDL2-2.32.8/include/SDL_test_fuzzer.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test_fuzzer.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test_fuzzer.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test_fuzzer.h diff --git a/code/SDL2-2.32.8/include/SDL_test_harness.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test_harness.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test_harness.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test_harness.h diff --git a/code/SDL2-2.32.8/include/SDL_test_images.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test_images.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test_images.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test_images.h diff --git a/code/SDL2-2.32.8/include/SDL_test_log.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test_log.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test_log.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test_log.h diff --git a/code/SDL2-2.32.8/include/SDL_test_md5.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test_md5.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test_md5.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test_md5.h diff --git a/code/SDL2-2.32.8/include/SDL_test_memory.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test_memory.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test_memory.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test_memory.h diff --git a/code/SDL2-2.32.8/include/SDL_test_random.h b/code/thirdparty/SDL2-2.32.8/include/SDL_test_random.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_test_random.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_test_random.h diff --git a/code/SDL2-2.32.8/include/SDL_thread.h b/code/thirdparty/SDL2-2.32.8/include/SDL_thread.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_thread.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_thread.h diff --git a/code/SDL2-2.32.8/include/SDL_timer.h b/code/thirdparty/SDL2-2.32.8/include/SDL_timer.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_timer.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_timer.h diff --git a/code/SDL2-2.32.8/include/SDL_touch.h b/code/thirdparty/SDL2-2.32.8/include/SDL_touch.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_touch.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_touch.h diff --git a/code/SDL2-2.32.8/include/SDL_types.h b/code/thirdparty/SDL2-2.32.8/include/SDL_types.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_types.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_types.h diff --git a/code/SDL2-2.32.8/include/SDL_version.h b/code/thirdparty/SDL2-2.32.8/include/SDL_version.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_version.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_version.h diff --git a/code/SDL2-2.32.8/include/SDL_video.h b/code/thirdparty/SDL2-2.32.8/include/SDL_video.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_video.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_video.h diff --git a/code/SDL2-2.32.8/include/SDL_vulkan.h b/code/thirdparty/SDL2-2.32.8/include/SDL_vulkan.h similarity index 100% rename from code/SDL2-2.32.8/include/SDL_vulkan.h rename to code/thirdparty/SDL2-2.32.8/include/SDL_vulkan.h diff --git a/code/SDL2-2.32.8/include/begin_code.h b/code/thirdparty/SDL2-2.32.8/include/begin_code.h similarity index 100% rename from code/SDL2-2.32.8/include/begin_code.h rename to code/thirdparty/SDL2-2.32.8/include/begin_code.h diff --git a/code/SDL2-2.32.8/include/close_code.h b/code/thirdparty/SDL2-2.32.8/include/close_code.h similarity index 100% rename from code/SDL2-2.32.8/include/close_code.h rename to code/thirdparty/SDL2-2.32.8/include/close_code.h diff --git a/code/curl-7.54.0/include/curl/curl.h b/code/thirdparty/curl-8.15.0/include/curl/curl.h similarity index 100% rename from code/curl-7.54.0/include/curl/curl.h rename to code/thirdparty/curl-8.15.0/include/curl/curl.h diff --git a/code/curl-7.54.0/include/curl/curlver.h b/code/thirdparty/curl-8.15.0/include/curl/curlver.h similarity index 100% rename from code/curl-7.54.0/include/curl/curlver.h rename to code/thirdparty/curl-8.15.0/include/curl/curlver.h diff --git a/code/curl-7.54.0/include/curl/easy.h b/code/thirdparty/curl-8.15.0/include/curl/easy.h similarity index 100% rename from code/curl-7.54.0/include/curl/easy.h rename to code/thirdparty/curl-8.15.0/include/curl/easy.h diff --git a/code/thirdparty/curl-8.15.0/include/curl/header.h b/code/thirdparty/curl-8.15.0/include/curl/header.h new file mode 100644 index 00000000..8df11e1e --- /dev/null +++ b/code/thirdparty/curl-8.15.0/include/curl/header.h @@ -0,0 +1,74 @@ +#ifndef CURLINC_HEADER_H +#define CURLINC_HEADER_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +struct curl_header { + char *name; /* this might not use the same case */ + char *value; + size_t amount; /* number of headers using this name */ + size_t index; /* ... of this instance, 0 or higher */ + unsigned int origin; /* see bits below */ + void *anchor; /* handle privately used by libcurl */ +}; + +/* 'origin' bits */ +#define CURLH_HEADER (1<<0) /* plain server header */ +#define CURLH_TRAILER (1<<1) /* trailers */ +#define CURLH_CONNECT (1<<2) /* CONNECT headers */ +#define CURLH_1XX (1<<3) /* 1xx headers */ +#define CURLH_PSEUDO (1<<4) /* pseudo headers */ + +typedef enum { + CURLHE_OK, + CURLHE_BADINDEX, /* header exists but not with this index */ + CURLHE_MISSING, /* no such header exists */ + CURLHE_NOHEADERS, /* no headers at all exist (yet) */ + CURLHE_NOREQUEST, /* no request with this number was used */ + CURLHE_OUT_OF_MEMORY, /* out of memory while processing */ + CURLHE_BAD_ARGUMENT, /* a function argument was not okay */ + CURLHE_NOT_BUILT_IN /* if API was disabled in the build */ +} CURLHcode; + +CURL_EXTERN CURLHcode curl_easy_header(CURL *easy, + const char *name, + size_t index, + unsigned int origin, + int request, + struct curl_header **hout); + +CURL_EXTERN struct curl_header *curl_easy_nextheader(CURL *easy, + unsigned int origin, + int request, + struct curl_header *prev); + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif /* CURLINC_HEADER_H */ diff --git a/code/curl-7.54.0/include/curl/mprintf.h b/code/thirdparty/curl-8.15.0/include/curl/mprintf.h similarity index 100% rename from code/curl-7.54.0/include/curl/mprintf.h rename to code/thirdparty/curl-8.15.0/include/curl/mprintf.h diff --git a/code/curl-7.54.0/include/curl/multi.h b/code/thirdparty/curl-8.15.0/include/curl/multi.h similarity index 100% rename from code/curl-7.54.0/include/curl/multi.h rename to code/thirdparty/curl-8.15.0/include/curl/multi.h diff --git a/code/thirdparty/curl-8.15.0/include/curl/options.h b/code/thirdparty/curl-8.15.0/include/curl/options.h new file mode 100644 index 00000000..1ed76a95 --- /dev/null +++ b/code/thirdparty/curl-8.15.0/include/curl/options.h @@ -0,0 +1,70 @@ +#ifndef CURLINC_OPTIONS_H +#define CURLINC_OPTIONS_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + CURLOT_LONG, /* long (a range of values) */ + CURLOT_VALUES, /* (a defined set or bitmask) */ + CURLOT_OFF_T, /* curl_off_t (a range of values) */ + CURLOT_OBJECT, /* pointer (void *) */ + CURLOT_STRING, /* (char * to null-terminated buffer) */ + CURLOT_SLIST, /* (struct curl_slist *) */ + CURLOT_CBPTR, /* (void * passed as-is to a callback) */ + CURLOT_BLOB, /* blob (struct curl_blob *) */ + CURLOT_FUNCTION /* function pointer */ +} curl_easytype; + +/* Flag bits */ + +/* "alias" means it is provided for old programs to remain functional, + we prefer another name */ +#define CURLOT_FLAG_ALIAS (1<<0) + +/* The CURLOPTTYPE_* id ranges can still be used to figure out what type/size + to use for curl_easy_setopt() for the given id */ +struct curl_easyoption { + const char *name; + CURLoption id; + curl_easytype type; + unsigned int flags; +}; + +CURL_EXTERN const struct curl_easyoption * +curl_easy_option_by_name(const char *name); + +CURL_EXTERN const struct curl_easyoption * +curl_easy_option_by_id(CURLoption id); + +CURL_EXTERN const struct curl_easyoption * +curl_easy_option_next(const struct curl_easyoption *prev); + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif +#endif /* CURLINC_OPTIONS_H */ diff --git a/code/curl-7.54.0/include/curl/stdcheaders.h b/code/thirdparty/curl-8.15.0/include/curl/stdcheaders.h similarity index 100% rename from code/curl-7.54.0/include/curl/stdcheaders.h rename to code/thirdparty/curl-8.15.0/include/curl/stdcheaders.h diff --git a/code/thirdparty/curl-8.15.0/include/curl/system.h b/code/thirdparty/curl-8.15.0/include/curl/system.h new file mode 100644 index 00000000..ebcdc5e4 --- /dev/null +++ b/code/thirdparty/curl-8.15.0/include/curl/system.h @@ -0,0 +1,402 @@ +#ifndef CURLINC_SYSTEM_H +#define CURLINC_SYSTEM_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +/* + * Try to keep one section per platform, compiler and architecture, otherwise, + * if an existing section is reused for a different one and later on the + * original is adjusted, probably the piggybacking one can be adversely + * changed. + * + * In order to differentiate between platforms/compilers/architectures use + * only compiler built-in predefined preprocessor symbols. + * + * curl_off_t + * ---------- + * + * For any given platform/compiler curl_off_t MUST be typedef'ed to a 64-bit + * wide signed integral data type. The width of this data type must remain + * constant and independent of any possible large file support settings. + * + * As a general rule, curl_off_t shall not be mapped to off_t. This rule shall + * only be violated if off_t is the only 64-bit data type available and the + * size of off_t is independent of large file support settings. Keep your + * build on the safe side avoiding an off_t gating. If you have a 64-bit + * off_t then take for sure that another 64-bit data type exists, dig deeper + * and you will find it. + * + */ + +#ifdef __DJGPP__ +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T int + +#elif defined(__BORLANDC__) +# define CURL_TYPEOF_CURL_OFF_T __int64 +# define CURL_FORMAT_CURL_OFF_T "I64d" +# define CURL_FORMAT_CURL_OFF_TU "I64u" +# define CURL_SUFFIX_CURL_OFF_T i64 +# define CURL_SUFFIX_CURL_OFF_TU ui64 +# define CURL_TYPEOF_CURL_SOCKLEN_T int + +#elif defined(__POCC__) +# if defined(_MSC_VER) +# define CURL_TYPEOF_CURL_OFF_T __int64 +# define CURL_FORMAT_CURL_OFF_T "I64d" +# define CURL_FORMAT_CURL_OFF_TU "I64u" +# define CURL_SUFFIX_CURL_OFF_T i64 +# define CURL_SUFFIX_CURL_OFF_TU ui64 +# else +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T int + +#elif defined(__LCC__) +# if defined(__MCST__) /* MCST eLbrus Compiler Collection */ +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 +# else /* Local (or Little) C Compiler */ +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# define CURL_TYPEOF_CURL_SOCKLEN_T int +# endif + +#elif defined(macintosh) +# include +# if TYPE_LONGLONG +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# else +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int + +#elif defined(__TANDEM) +# if !defined(__LP64) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T int +# else +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int +# endif + +#elif defined(UNDER_CE) +# if defined(__MINGW32CE__) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T int +# else +# define CURL_TYPEOF_CURL_OFF_T __int64 +# define CURL_FORMAT_CURL_OFF_T "I64d" +# define CURL_FORMAT_CURL_OFF_TU "I64u" +# define CURL_SUFFIX_CURL_OFF_T i64 +# define CURL_SUFFIX_CURL_OFF_TU ui64 +# define CURL_TYPEOF_CURL_SOCKLEN_T int +# endif + +#elif defined(__MINGW32__) +# include +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T PRId64 +# define CURL_FORMAT_CURL_OFF_TU PRIu64 +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T int +# define CURL_PULL_SYS_TYPES_H 1 + +#elif defined(__VMS) +# if defined(__VAX) +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# else +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int + +#elif defined(__OS400__) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +#elif defined(__MVS__) +# if defined(_LONG_LONG) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# else /* _LP64 and default */ +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +#elif defined(__370__) +# if defined(__IBMC__) || defined(__IBMCPP__) +# if defined(_LONG_LONG) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# else /* _LP64 and default */ +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 +# endif + +#elif defined(TPF) +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# define CURL_TYPEOF_CURL_SOCKLEN_T int + +#elif defined(__TINYC__) /* also known as tcc */ +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */ +# if !defined(__LP64) && (defined(__ILP32) || \ + defined(__i386) || \ + defined(__sparcv8) || \ + defined(__sparcv8plus)) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# elif defined(__LP64) || \ + defined(__amd64) || defined(__sparcv9) +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +#elif defined(__xlc__) /* IBM xlc compiler */ +# if !defined(_LP64) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# else +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +#elif defined(__hpux) /* HP aCC compiler */ +# if !defined(_LP64) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# else +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +/* ===================================== */ +/* KEEP MSVC THE PENULTIMATE ENTRY */ +/* ===================================== */ + +#elif defined(_MSC_VER) +# if (_MSC_VER >= 1800) +# include +# define CURL_FORMAT_CURL_OFF_T PRId64 +# define CURL_FORMAT_CURL_OFF_TU PRIu64 +# else +# define CURL_FORMAT_CURL_OFF_T "I64d" +# define CURL_FORMAT_CURL_OFF_TU "I64u" +# endif +# define CURL_TYPEOF_CURL_OFF_T __int64 +# define CURL_SUFFIX_CURL_OFF_T i64 +# define CURL_SUFFIX_CURL_OFF_TU ui64 +# define CURL_TYPEOF_CURL_SOCKLEN_T int + +/* ===================================== */ +/* KEEP GENERIC GCC THE LAST ENTRY */ +/* ===================================== */ + +#elif defined(__GNUC__) && !defined(_SCO_DS) +# if !defined(__LP64__) && \ + (defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \ + defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \ + defined(__sparc__) || defined(__mips__) || defined(__sh__) || \ + defined(__XTENSA__) || \ + (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \ + (defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L)) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_POPCOUNT64(x) __builtin_popcountll(x) +# define CURL_CTZ64(x) __builtin_ctzll(x) +# elif defined(__LP64__) || \ + defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \ + defined(__e2k__) || \ + (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \ + (defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L) +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# define CURL_POPCOUNT64(x) __builtin_popcountl(x) +# define CURL_CTZ64(x) __builtin_ctzl(x) +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + +#else +/* generic "safe guess" on old 32-bit style */ +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# define CURL_TYPEOF_CURL_SOCKLEN_T int +#endif + +#ifdef _AIX +/* AIX needs */ +#define CURL_PULL_SYS_POLL_H +#endif + +/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */ +/* sys/types.h is required here to properly make type definitions below. */ +#ifdef CURL_PULL_SYS_TYPES_H +# include +#endif + +/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ +/* sys/socket.h is required here to properly make type definitions below. */ +#ifdef CURL_PULL_SYS_SOCKET_H +# include +#endif + +/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */ +/* sys/poll.h is required here to properly make type definitions below. */ +#ifdef CURL_PULL_SYS_POLL_H +# include +#endif + +/* Data type definition of curl_socklen_t. */ +#ifdef CURL_TYPEOF_CURL_SOCKLEN_T + typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t; +#endif + +/* Data type definition of curl_off_t. */ + +#ifdef CURL_TYPEOF_CURL_OFF_T + typedef CURL_TYPEOF_CURL_OFF_T curl_off_t; +#endif + +#endif /* CURLINC_SYSTEM_H */ diff --git a/code/thirdparty/curl-8.15.0/include/curl/typecheck-gcc.h b/code/thirdparty/curl-8.15.0/include/curl/typecheck-gcc.h new file mode 100644 index 00000000..ca0c0ef9 --- /dev/null +++ b/code/thirdparty/curl-8.15.0/include/curl/typecheck-gcc.h @@ -0,0 +1,867 @@ +#ifndef CURLINC_TYPECHECK_GCC_H +#define CURLINC_TYPECHECK_GCC_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +/* wraps curl_easy_setopt() with typechecking */ + +/* To add a new kind of warning, add an + * if(curlcheck_sometype_option(_curl_opt)) + * if(!curlcheck_sometype(value)) + * _curl_easy_setopt_err_sometype(); + * block and define curlcheck_sometype_option, curlcheck_sometype and + * _curl_easy_setopt_err_sometype below + * + * NOTE: We use two nested 'if' statements here instead of the && operator, in + * order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x + * when compiling with -Wlogical-op. + * + * To add an option that uses the same type as an existing option, you will + * just need to extend the appropriate _curl_*_option macro + */ + +#define curl_easy_setopt(handle, option, value) \ + __extension__({ \ + if(__builtin_constant_p(option)) { \ + CURL_IGNORE_DEPRECATION( \ + if(curlcheck_long_option(option)) \ + if(!curlcheck_long(value)) \ + _curl_easy_setopt_err_long(); \ + if(curlcheck_off_t_option(option)) \ + if(!curlcheck_off_t(value)) \ + _curl_easy_setopt_err_curl_off_t(); \ + if(curlcheck_string_option(option)) \ + if(!curlcheck_string(value)) \ + _curl_easy_setopt_err_string(); \ + if((option) == CURLOPT_PRIVATE) { } \ + if(curlcheck_write_cb_option(option)) \ + if(!curlcheck_write_cb(value)) \ + _curl_easy_setopt_err_write_callback(); \ + if(curlcheck_curl_option(option)) \ + if(!curlcheck_curl(value)) \ + _curl_easy_setopt_err_curl(); \ + if((option) == CURLOPT_RESOLVER_START_FUNCTION) \ + if(!curlcheck_resolver_start_callback(value)) \ + _curl_easy_setopt_err_resolver_start_callback(); \ + if((option) == CURLOPT_READFUNCTION) \ + if(!curlcheck_read_cb(value)) \ + _curl_easy_setopt_err_read_cb(); \ + if((option) == CURLOPT_IOCTLFUNCTION) \ + if(!curlcheck_ioctl_cb(value)) \ + _curl_easy_setopt_err_ioctl_cb(); \ + if((option) == CURLOPT_SOCKOPTFUNCTION) \ + if(!curlcheck_sockopt_cb(value)) \ + _curl_easy_setopt_err_sockopt_cb(); \ + if((option) == CURLOPT_OPENSOCKETFUNCTION) \ + if(!curlcheck_opensocket_cb(value)) \ + _curl_easy_setopt_err_opensocket_cb(); \ + if((option) == CURLOPT_PROGRESSFUNCTION) \ + if(!curlcheck_progress_cb(value)) \ + _curl_easy_setopt_err_progress_cb(); \ + if((option) == CURLOPT_XFERINFOFUNCTION) \ + if(!curlcheck_xferinfo_cb(value)) \ + _curl_easy_setopt_err_xferinfo_cb(); \ + if((option) == CURLOPT_DEBUGFUNCTION) \ + if(!curlcheck_debug_cb(value)) \ + _curl_easy_setopt_err_debug_cb(); \ + if((option) == CURLOPT_SSL_CTX_FUNCTION) \ + if(!curlcheck_ssl_ctx_cb(value)) \ + _curl_easy_setopt_err_ssl_ctx_cb(); \ + if(curlcheck_conv_cb_option(option)) \ + if(!curlcheck_conv_cb(value)) \ + _curl_easy_setopt_err_conv_cb(); \ + if((option) == CURLOPT_SEEKFUNCTION) \ + if(!curlcheck_seek_cb(value)) \ + _curl_easy_setopt_err_seek_cb(); \ + if((option) == CURLOPT_CHUNK_BGN_FUNCTION) \ + if(!curlcheck_chunk_bgn_cb(value)) \ + _curl_easy_setopt_err_chunk_bgn_cb(); \ + if((option) == CURLOPT_CHUNK_END_FUNCTION) \ + if(!curlcheck_chunk_end_cb(value)) \ + _curl_easy_setopt_err_chunk_end_cb(); \ + if((option) == CURLOPT_CLOSESOCKETFUNCTION) \ + if(!curlcheck_close_socket_cb(value)) \ + _curl_easy_setopt_err_close_socket_cb(); \ + if((option) == CURLOPT_FNMATCH_FUNCTION) \ + if(!curlcheck_fnmatch_cb(value)) \ + _curl_easy_setopt_err_fnmatch_cb(); \ + if((option) == CURLOPT_HSTSREADFUNCTION) \ + if(!curlcheck_hstsread_cb(value)) \ + _curl_easy_setopt_err_hstsread_cb(); \ + if((option) == CURLOPT_HSTSWRITEFUNCTION) \ + if(!curlcheck_hstswrite_cb(value)) \ + _curl_easy_setopt_err_hstswrite_cb(); \ + if((option) == CURLOPT_SSH_HOSTKEYFUNCTION) \ + if(!curlcheck_ssh_hostkey_cb(value)) \ + _curl_easy_setopt_err_ssh_hostkey_cb(); \ + if((option) == CURLOPT_SSH_KEYFUNCTION) \ + if(!curlcheck_ssh_key_cb(value)) \ + _curl_easy_setopt_err_ssh_key_cb(); \ + if((option) == CURLOPT_INTERLEAVEFUNCTION) \ + if(!curlcheck_interleave_cb(value)) \ + _curl_easy_setopt_err_interleave_cb(); \ + if((option) == CURLOPT_PREREQFUNCTION) \ + if(!curlcheck_prereq_cb(value)) \ + _curl_easy_setopt_err_prereq_cb(); \ + if((option) == CURLOPT_TRAILERFUNCTION) \ + if(!curlcheck_trailer_cb(value)) \ + _curl_easy_setopt_err_trailer_cb(); \ + if(curlcheck_cb_data_option(option)) \ + if(!curlcheck_cb_data(value)) \ + _curl_easy_setopt_err_cb_data(); \ + if((option) == CURLOPT_ERRORBUFFER) \ + if(!curlcheck_error_buffer(value)) \ + _curl_easy_setopt_err_error_buffer(); \ + if((option) == CURLOPT_CURLU) \ + if(!curlcheck_ptr((value), CURLU)) \ + _curl_easy_setopt_err_curlu(); \ + if((option) == CURLOPT_STDERR) \ + if(!curlcheck_FILE(value)) \ + _curl_easy_setopt_err_FILE(); \ + if(curlcheck_postfields_option(option)) \ + if(!curlcheck_postfields(value)) \ + _curl_easy_setopt_err_postfields(); \ + if((option) == CURLOPT_HTTPPOST) \ + if(!curlcheck_arr((value), struct curl_httppost)) \ + _curl_easy_setopt_err_curl_httpost(); \ + if((option) == CURLOPT_MIMEPOST) \ + if(!curlcheck_ptr((value), curl_mime)) \ + _curl_easy_setopt_err_curl_mimepost(); \ + if(curlcheck_slist_option(option)) \ + if(!curlcheck_arr((value), struct curl_slist)) \ + _curl_easy_setopt_err_curl_slist(); \ + if((option) == CURLOPT_SHARE) \ + if(!curlcheck_ptr((value), CURLSH)) \ + _curl_easy_setopt_err_CURLSH(); \ + ) \ + } \ + curl_easy_setopt(handle, option, value); \ + }) + +/* wraps curl_easy_getinfo() with typechecking */ +#define curl_easy_getinfo(handle, info, arg) \ + __extension__({ \ + if(__builtin_constant_p(info)) { \ + CURL_IGNORE_DEPRECATION( \ + if(curlcheck_string_info(info)) \ + if(!curlcheck_arr((arg), char *)) \ + _curl_easy_getinfo_err_string(); \ + if(curlcheck_long_info(info)) \ + if(!curlcheck_arr((arg), long)) \ + _curl_easy_getinfo_err_long(); \ + if(curlcheck_double_info(info)) \ + if(!curlcheck_arr((arg), double)) \ + _curl_easy_getinfo_err_double(); \ + if(curlcheck_slist_info(info)) \ + if(!curlcheck_arr((arg), struct curl_slist *)) \ + _curl_easy_getinfo_err_curl_slist(); \ + if(curlcheck_tlssessioninfo_info(info)) \ + if(!curlcheck_arr((arg), struct curl_tlssessioninfo *)) \ + _curl_easy_getinfo_err_curl_tlssessioninfo(); \ + if(curlcheck_certinfo_info(info)) \ + if(!curlcheck_arr((arg), struct curl_certinfo *)) \ + _curl_easy_getinfo_err_curl_certinfo(); \ + if(curlcheck_socket_info(info)) \ + if(!curlcheck_arr((arg), curl_socket_t)) \ + _curl_easy_getinfo_err_curl_socket(); \ + if(curlcheck_off_t_info(info)) \ + if(!curlcheck_arr((arg), curl_off_t)) \ + _curl_easy_getinfo_err_curl_off_t(); \ + ) \ + } \ + curl_easy_getinfo(handle, info, arg); \ + }) + +/* + * For now, just make sure that the functions are called with three arguments + */ +#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param) +#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param) + +/* the actual warnings, triggered by calling the _curl_easy_setopt_err* + * functions */ + +/* To define a new warning, use _CURL_WARNING(identifier, "message") */ +#define CURLWARNING(id, message) \ + static void __attribute__((__warning__(message))) \ + __attribute__((__unused__)) __attribute__((__noinline__)) \ + id(void) { __asm__(""); } + +CURLWARNING(_curl_easy_setopt_err_long, + "curl_easy_setopt expects a long argument") +CURLWARNING(_curl_easy_setopt_err_curl_off_t, + "curl_easy_setopt expects a curl_off_t argument") +CURLWARNING(_curl_easy_setopt_err_string, + "curl_easy_setopt expects a " + "string ('char *' or char[]) argument") +CURLWARNING(_curl_easy_setopt_err_write_callback, + "curl_easy_setopt expects a curl_write_callback argument") +CURLWARNING(_curl_easy_setopt_err_resolver_start_callback, + "curl_easy_setopt expects a " + "curl_resolver_start_callback argument") +CURLWARNING(_curl_easy_setopt_err_read_cb, + "curl_easy_setopt expects a curl_read_callback argument") +CURLWARNING(_curl_easy_setopt_err_ioctl_cb, + "curl_easy_setopt expects a curl_ioctl_callback argument") +CURLWARNING(_curl_easy_setopt_err_sockopt_cb, + "curl_easy_setopt expects a curl_sockopt_callback argument") +CURLWARNING(_curl_easy_setopt_err_opensocket_cb, + "curl_easy_setopt expects a " + "curl_opensocket_callback argument") +CURLWARNING(_curl_easy_setopt_err_progress_cb, + "curl_easy_setopt expects a curl_progress_callback argument") +CURLWARNING(_curl_easy_setopt_err_xferinfo_cb, + "curl_easy_setopt expects a curl_xferinfo_callback argument") +CURLWARNING(_curl_easy_setopt_err_debug_cb, + "curl_easy_setopt expects a curl_debug_callback argument") +CURLWARNING(_curl_easy_setopt_err_ssl_ctx_cb, + "curl_easy_setopt expects a curl_ssl_ctx_callback argument") +CURLWARNING(_curl_easy_setopt_err_conv_cb, + "curl_easy_setopt expects a curl_conv_callback argument") +CURLWARNING(_curl_easy_setopt_err_seek_cb, + "curl_easy_setopt expects a curl_seek_callback argument") +CURLWARNING(_curl_easy_setopt_err_cb_data, + "curl_easy_setopt expects a " + "private data pointer as argument") +CURLWARNING(_curl_easy_setopt_err_chunk_bgn_cb, + "curl_easy_setopt expects a curl_chunk_bgn_callback argument") +CURLWARNING(_curl_easy_setopt_err_chunk_end_cb, + "curl_easy_setopt expects a curl_chunk_end_callback argument") +CURLWARNING(_curl_easy_setopt_err_close_socket_cb, + "curl_easy_setopt expects a curl_closesocket_callback argument") +CURLWARNING(_curl_easy_setopt_err_fnmatch_cb, + "curl_easy_setopt expects a curl_fnmatch_callback argument") +CURLWARNING(_curl_easy_setopt_err_hstsread_cb, + "curl_easy_setopt expects a curl_hstsread_callback argument") +CURLWARNING(_curl_easy_setopt_err_hstswrite_cb, + "curl_easy_setopt expects a curl_hstswrite_callback argument") +CURLWARNING(_curl_easy_setopt_err_ssh_key_cb, + "curl_easy_setopt expects a curl_sshkeycallback argument") +CURLWARNING(_curl_easy_setopt_err_ssh_hostkey_cb, + "curl_easy_setopt expects a curl_sshhostkeycallback argument") +CURLWARNING(_curl_easy_setopt_err_interleave_cb, + "curl_easy_setopt expects a curl_interleave_callback argument") +CURLWARNING(_curl_easy_setopt_err_prereq_cb, + "curl_easy_setopt expects a curl_prereq_callback argument") +CURLWARNING(_curl_easy_setopt_err_trailer_cb, + "curl_easy_setopt expects a curl_trailerfunc_ok argument") +CURLWARNING(_curl_easy_setopt_err_error_buffer, + "curl_easy_setopt expects a " + "char buffer of CURL_ERROR_SIZE as argument") +CURLWARNING(_curl_easy_setopt_err_curlu, + "curl_easy_setopt expects a 'CURLU *' argument") +CURLWARNING(_curl_easy_setopt_err_curl, + "curl_easy_setopt expects a 'CURL *' argument") +CURLWARNING(_curl_easy_setopt_err_FILE, + "curl_easy_setopt expects a 'FILE *' argument") +CURLWARNING(_curl_easy_setopt_err_postfields, + "curl_easy_setopt expects a 'void *' or 'char *' argument") +CURLWARNING(_curl_easy_setopt_err_curl_httpost, + "curl_easy_setopt expects a 'struct curl_httppost *' " + "argument") +CURLWARNING(_curl_easy_setopt_err_curl_mimepost, + "curl_easy_setopt expects a 'curl_mime *' " + "argument") +CURLWARNING(_curl_easy_setopt_err_curl_slist, + "curl_easy_setopt expects a 'struct curl_slist *' argument") +CURLWARNING(_curl_easy_setopt_err_CURLSH, + "curl_easy_setopt expects a CURLSH* argument") +CURLWARNING(_curl_easy_getinfo_err_string, + "curl_easy_getinfo expects a pointer to 'char *'") +CURLWARNING(_curl_easy_getinfo_err_long, + "curl_easy_getinfo expects a pointer to long") +CURLWARNING(_curl_easy_getinfo_err_double, + "curl_easy_getinfo expects a pointer to double") +CURLWARNING(_curl_easy_getinfo_err_curl_slist, + "curl_easy_getinfo expects a pointer to 'struct curl_slist *'") +CURLWARNING(_curl_easy_getinfo_err_curl_tlssessioninfo, + "curl_easy_getinfo expects a pointer to " + "'struct curl_tlssessioninfo *'") +CURLWARNING(_curl_easy_getinfo_err_curl_certinfo, + "curl_easy_getinfo expects a pointer to " + "'struct curl_certinfo *'") +CURLWARNING(_curl_easy_getinfo_err_curl_socket, + "curl_easy_getinfo expects a pointer to curl_socket_t") +CURLWARNING(_curl_easy_getinfo_err_curl_off_t, + "curl_easy_getinfo expects a pointer to curl_off_t") + +/* groups of curl_easy_setops options that take the same type of argument */ + +/* evaluates to true if option takes a long argument */ +#define curlcheck_long_option(option) \ + (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT) + +#define curlcheck_off_t_option(option) \ + (((option) > CURLOPTTYPE_OFF_T) && ((option) < CURLOPTTYPE_BLOB)) + +/* option takes a CURL * argument */ +#define curlcheck_curl_option(option) \ + ((option) == CURLOPT_STREAM_DEPENDS || \ + (option) == CURLOPT_STREAM_DEPENDS_E || \ + 0) + +/* evaluates to true if option takes a char* argument */ +#define curlcheck_string_option(option) \ + ((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \ + (option) == CURLOPT_ACCEPT_ENCODING || \ + (option) == CURLOPT_ALTSVC || \ + (option) == CURLOPT_CAINFO || \ + (option) == CURLOPT_CAPATH || \ + (option) == CURLOPT_COOKIE || \ + (option) == CURLOPT_COOKIEFILE || \ + (option) == CURLOPT_COOKIEJAR || \ + (option) == CURLOPT_COOKIELIST || \ + (option) == CURLOPT_CRLFILE || \ + (option) == CURLOPT_CUSTOMREQUEST || \ + (option) == CURLOPT_DEFAULT_PROTOCOL || \ + (option) == CURLOPT_DNS_INTERFACE || \ + (option) == CURLOPT_DNS_LOCAL_IP4 || \ + (option) == CURLOPT_DNS_LOCAL_IP6 || \ + (option) == CURLOPT_DNS_SERVERS || \ + (option) == CURLOPT_DOH_URL || \ + (option) == CURLOPT_ECH || \ + (option) == CURLOPT_EGDSOCKET || \ + (option) == CURLOPT_FTP_ACCOUNT || \ + (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \ + (option) == CURLOPT_FTPPORT || \ + (option) == CURLOPT_HAPROXY_CLIENT_IP || \ + (option) == CURLOPT_HSTS || \ + (option) == CURLOPT_INTERFACE || \ + (option) == CURLOPT_ISSUERCERT || \ + (option) == CURLOPT_KEYPASSWD || \ + (option) == CURLOPT_KRBLEVEL || \ + (option) == CURLOPT_LOGIN_OPTIONS || \ + (option) == CURLOPT_MAIL_AUTH || \ + (option) == CURLOPT_MAIL_FROM || \ + (option) == CURLOPT_NETRC_FILE || \ + (option) == CURLOPT_NOPROXY || \ + (option) == CURLOPT_PASSWORD || \ + (option) == CURLOPT_PINNEDPUBLICKEY || \ + (option) == CURLOPT_PRE_PROXY || \ + (option) == CURLOPT_PROTOCOLS_STR || \ + (option) == CURLOPT_PROXY || \ + (option) == CURLOPT_PROXY_CAINFO || \ + (option) == CURLOPT_PROXY_CAPATH || \ + (option) == CURLOPT_PROXY_CRLFILE || \ + (option) == CURLOPT_PROXY_ISSUERCERT || \ + (option) == CURLOPT_PROXY_KEYPASSWD || \ + (option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \ + (option) == CURLOPT_PROXY_SERVICE_NAME || \ + (option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \ + (option) == CURLOPT_PROXY_SSLCERT || \ + (option) == CURLOPT_PROXY_SSLCERTTYPE || \ + (option) == CURLOPT_PROXY_SSLKEY || \ + (option) == CURLOPT_PROXY_SSLKEYTYPE || \ + (option) == CURLOPT_PROXY_TLS13_CIPHERS || \ + (option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \ + (option) == CURLOPT_PROXY_TLSAUTH_TYPE || \ + (option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \ + (option) == CURLOPT_PROXYPASSWORD || \ + (option) == CURLOPT_PROXYUSERNAME || \ + (option) == CURLOPT_PROXYUSERPWD || \ + (option) == CURLOPT_RANDOM_FILE || \ + (option) == CURLOPT_RANGE || \ + (option) == CURLOPT_REDIR_PROTOCOLS_STR || \ + (option) == CURLOPT_REFERER || \ + (option) == CURLOPT_REQUEST_TARGET || \ + (option) == CURLOPT_RTSP_SESSION_ID || \ + (option) == CURLOPT_RTSP_STREAM_URI || \ + (option) == CURLOPT_RTSP_TRANSPORT || \ + (option) == CURLOPT_SASL_AUTHZID || \ + (option) == CURLOPT_SERVICE_NAME || \ + (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \ + (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \ + (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 || \ + (option) == CURLOPT_SSH_KNOWNHOSTS || \ + (option) == CURLOPT_SSH_PRIVATE_KEYFILE || \ + (option) == CURLOPT_SSH_PUBLIC_KEYFILE || \ + (option) == CURLOPT_SSLCERT || \ + (option) == CURLOPT_SSLCERTTYPE || \ + (option) == CURLOPT_SSLENGINE || \ + (option) == CURLOPT_SSLKEY || \ + (option) == CURLOPT_SSLKEYTYPE || \ + (option) == CURLOPT_SSL_CIPHER_LIST || \ + (option) == CURLOPT_SSL_EC_CURVES || \ + (option) == CURLOPT_SSL_SIGNATURE_ALGORITHMS || \ + (option) == CURLOPT_TLS13_CIPHERS || \ + (option) == CURLOPT_TLSAUTH_PASSWORD || \ + (option) == CURLOPT_TLSAUTH_TYPE || \ + (option) == CURLOPT_TLSAUTH_USERNAME || \ + (option) == CURLOPT_UNIX_SOCKET_PATH || \ + (option) == CURLOPT_URL || \ + (option) == CURLOPT_USERAGENT || \ + (option) == CURLOPT_USERNAME || \ + (option) == CURLOPT_AWS_SIGV4 || \ + (option) == CURLOPT_USERPWD || \ + (option) == CURLOPT_XOAUTH2_BEARER || \ + 0) + +/* evaluates to true if option takes a curl_write_callback argument */ +#define curlcheck_write_cb_option(option) \ + ((option) == CURLOPT_HEADERFUNCTION || \ + (option) == CURLOPT_WRITEFUNCTION) + +/* evaluates to true if option takes a curl_conv_callback argument */ +#define curlcheck_conv_cb_option(option) \ + ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \ + (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \ + (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION) + +/* evaluates to true if option takes a data argument to pass to a callback */ +#define curlcheck_cb_data_option(option) \ + ((option) == CURLOPT_CHUNK_DATA || \ + (option) == CURLOPT_CLOSESOCKETDATA || \ + (option) == CURLOPT_DEBUGDATA || \ + (option) == CURLOPT_FNMATCH_DATA || \ + (option) == CURLOPT_HEADERDATA || \ + (option) == CURLOPT_HSTSREADDATA || \ + (option) == CURLOPT_HSTSWRITEDATA || \ + (option) == CURLOPT_INTERLEAVEDATA || \ + (option) == CURLOPT_IOCTLDATA || \ + (option) == CURLOPT_OPENSOCKETDATA || \ + (option) == CURLOPT_PREREQDATA || \ + (option) == CURLOPT_XFERINFODATA || \ + (option) == CURLOPT_READDATA || \ + (option) == CURLOPT_SEEKDATA || \ + (option) == CURLOPT_SOCKOPTDATA || \ + (option) == CURLOPT_SSH_KEYDATA || \ + (option) == CURLOPT_SSL_CTX_DATA || \ + (option) == CURLOPT_WRITEDATA || \ + (option) == CURLOPT_RESOLVER_START_DATA || \ + (option) == CURLOPT_TRAILERDATA || \ + (option) == CURLOPT_SSH_HOSTKEYDATA || \ + 0) + +/* evaluates to true if option takes a POST data argument (void* or char*) */ +#define curlcheck_postfields_option(option) \ + ((option) == CURLOPT_POSTFIELDS || \ + (option) == CURLOPT_COPYPOSTFIELDS || \ + 0) + +/* evaluates to true if option takes a struct curl_slist * argument */ +#define curlcheck_slist_option(option) \ + ((option) == CURLOPT_HTTP200ALIASES || \ + (option) == CURLOPT_HTTPHEADER || \ + (option) == CURLOPT_MAIL_RCPT || \ + (option) == CURLOPT_POSTQUOTE || \ + (option) == CURLOPT_PREQUOTE || \ + (option) == CURLOPT_PROXYHEADER || \ + (option) == CURLOPT_QUOTE || \ + (option) == CURLOPT_RESOLVE || \ + (option) == CURLOPT_TELNETOPTIONS || \ + (option) == CURLOPT_CONNECT_TO || \ + 0) + +/* groups of curl_easy_getinfo infos that take the same type of argument */ + +/* evaluates to true if info expects a pointer to char * argument */ +#define curlcheck_string_info(info) \ + (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG && \ + (info) != CURLINFO_PRIVATE) + +/* evaluates to true if info expects a pointer to long argument */ +#define curlcheck_long_info(info) \ + (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE) + +/* evaluates to true if info expects a pointer to double argument */ +#define curlcheck_double_info(info) \ + (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST) + +/* true if info expects a pointer to struct curl_slist * argument */ +#define curlcheck_slist_info(info) \ + (((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST)) + +/* true if info expects a pointer to struct curl_tlssessioninfo * argument */ +#define curlcheck_tlssessioninfo_info(info) \ + (((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION)) + +/* true if info expects a pointer to struct curl_certinfo * argument */ +#define curlcheck_certinfo_info(info) ((info) == CURLINFO_CERTINFO) + +/* true if info expects a pointer to struct curl_socket_t argument */ +#define curlcheck_socket_info(info) \ + (CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T) + +/* true if info expects a pointer to curl_off_t argument */ +#define curlcheck_off_t_info(info) \ + (CURLINFO_OFF_T < (info)) + + +/* typecheck helpers -- check whether given expression has requested type */ + +/* For pointers, you can use the curlcheck_ptr/curlcheck_arr macros, + * otherwise define a new macro. Search for __builtin_types_compatible_p + * in the GCC manual. + * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is + * the actual expression passed to the curl_easy_setopt macro. This + * means that you can only apply the sizeof and __typeof__ operators, no + * == or whatsoever. + */ + +/* XXX: should evaluate to true if expr is a pointer */ +#define curlcheck_any_ptr(expr) \ + (sizeof(expr) == sizeof(void *)) + +/* evaluates to true if expr is NULL */ +/* XXX: must not evaluate expr, so this check is not accurate */ +#define curlcheck_NULL(expr) \ + (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL))) + +/* evaluates to true if expr is type*, const type* or NULL */ +#define curlcheck_ptr(expr, type) \ + (curlcheck_NULL(expr) || \ + __builtin_types_compatible_p(__typeof__(expr), type *) || \ + __builtin_types_compatible_p(__typeof__(expr), const type *)) + +/* evaluates to true if expr is one of type[], type*, NULL or const type* */ +#define curlcheck_arr(expr, type) \ + (curlcheck_ptr((expr), type) || \ + __builtin_types_compatible_p(__typeof__(expr), type [])) + +/* evaluates to true if expr is a string */ +#define curlcheck_string(expr) \ + (curlcheck_arr((expr), char) || \ + curlcheck_arr((expr), signed char) || \ + curlcheck_arr((expr), unsigned char)) + +/* evaluates to true if expr is a CURL * */ +#define curlcheck_curl(expr) \ + (curlcheck_NULL(expr) || \ + __builtin_types_compatible_p(__typeof__(expr), CURL *)) + + +/* evaluates to true if expr is a long (no matter the signedness) + * XXX: for now, int is also accepted (and therefore short and char, which + * are promoted to int when passed to a variadic function) */ +#define curlcheck_long(expr) \ + ( \ + ((sizeof(long) != sizeof(int)) && \ + (__builtin_types_compatible_p(__typeof__(expr), long) || \ + __builtin_types_compatible_p(__typeof__(expr), signed long) || \ + __builtin_types_compatible_p(__typeof__(expr), unsigned long))) \ + || \ + ((sizeof(long) == sizeof(int)) && \ + (__builtin_types_compatible_p(__typeof__(expr), long) || \ + __builtin_types_compatible_p(__typeof__(expr), signed long) || \ + __builtin_types_compatible_p(__typeof__(expr), unsigned long) || \ + __builtin_types_compatible_p(__typeof__(expr), int) || \ + __builtin_types_compatible_p(__typeof__(expr), signed int) || \ + __builtin_types_compatible_p(__typeof__(expr), unsigned int) || \ + __builtin_types_compatible_p(__typeof__(expr), short) || \ + __builtin_types_compatible_p(__typeof__(expr), signed short) || \ + __builtin_types_compatible_p(__typeof__(expr), unsigned short) || \ + __builtin_types_compatible_p(__typeof__(expr), char) || \ + __builtin_types_compatible_p(__typeof__(expr), signed char) || \ + __builtin_types_compatible_p(__typeof__(expr), unsigned char))) \ + ) + +/* evaluates to true if expr is of type curl_off_t */ +#define curlcheck_off_t(expr) \ + (__builtin_types_compatible_p(__typeof__(expr), curl_off_t)) + +/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */ +/* XXX: also check size of an char[] array? */ +#define curlcheck_error_buffer(expr) \ + (curlcheck_NULL(expr) || \ + __builtin_types_compatible_p(__typeof__(expr), char *) || \ + __builtin_types_compatible_p(__typeof__(expr), char[])) + +/* evaluates to true if expr is of type (const) void* or (const) FILE* */ +#if 0 +#define curlcheck_cb_data(expr) \ + (curlcheck_ptr((expr), void) || \ + curlcheck_ptr((expr), FILE)) +#else /* be less strict */ +#define curlcheck_cb_data(expr) \ + curlcheck_any_ptr(expr) +#endif + +/* evaluates to true if expr is of type FILE* */ +#define curlcheck_FILE(expr) \ + (curlcheck_NULL(expr) || \ + (__builtin_types_compatible_p(__typeof__(expr), FILE *))) + +/* evaluates to true if expr can be passed as POST data (void* or char*) */ +#define curlcheck_postfields(expr) \ + (curlcheck_ptr((expr), void) || \ + curlcheck_arr((expr), char) || \ + curlcheck_arr((expr), unsigned char)) + +/* helper: __builtin_types_compatible_p distinguishes between functions and + * function pointers, hide it */ +#define curlcheck_cb_compatible(func, type) \ + (__builtin_types_compatible_p(__typeof__(func), type) || \ + __builtin_types_compatible_p(__typeof__(func) *, type)) + +/* evaluates to true if expr is of type curl_resolver_start_callback */ +#define curlcheck_resolver_start_callback(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_resolver_start_callback)) + +/* evaluates to true if expr is of type curl_read_callback or "similar" */ +#define curlcheck_read_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), __typeof__(fread) *) || \ + curlcheck_cb_compatible((expr), curl_read_callback) || \ + curlcheck_cb_compatible((expr), _curl_read_callback1) || \ + curlcheck_cb_compatible((expr), _curl_read_callback2) || \ + curlcheck_cb_compatible((expr), _curl_read_callback3) || \ + curlcheck_cb_compatible((expr), _curl_read_callback4) || \ + curlcheck_cb_compatible((expr), _curl_read_callback5) || \ + curlcheck_cb_compatible((expr), _curl_read_callback6)) +typedef size_t (*_curl_read_callback1)(char *, size_t, size_t, void *); +typedef size_t (*_curl_read_callback2)(char *, size_t, size_t, const void *); +typedef size_t (*_curl_read_callback3)(char *, size_t, size_t, FILE *); +typedef size_t (*_curl_read_callback4)(void *, size_t, size_t, void *); +typedef size_t (*_curl_read_callback5)(void *, size_t, size_t, const void *); +typedef size_t (*_curl_read_callback6)(void *, size_t, size_t, FILE *); + +/* evaluates to true if expr is of type curl_write_callback or "similar" */ +#define curlcheck_write_cb(expr) \ + (curlcheck_read_cb(expr) || \ + curlcheck_cb_compatible((expr), __typeof__(fwrite) *) || \ + curlcheck_cb_compatible((expr), curl_write_callback) || \ + curlcheck_cb_compatible((expr), _curl_write_callback1) || \ + curlcheck_cb_compatible((expr), _curl_write_callback2) || \ + curlcheck_cb_compatible((expr), _curl_write_callback3) || \ + curlcheck_cb_compatible((expr), _curl_write_callback4) || \ + curlcheck_cb_compatible((expr), _curl_write_callback5) || \ + curlcheck_cb_compatible((expr), _curl_write_callback6)) +typedef size_t (*_curl_write_callback1)(const char *, size_t, size_t, void *); +typedef size_t (*_curl_write_callback2)(const char *, size_t, size_t, + const void *); +typedef size_t (*_curl_write_callback3)(const char *, size_t, size_t, FILE *); +typedef size_t (*_curl_write_callback4)(const void *, size_t, size_t, void *); +typedef size_t (*_curl_write_callback5)(const void *, size_t, size_t, + const void *); +typedef size_t (*_curl_write_callback6)(const void *, size_t, size_t, FILE *); + +/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */ +#define curlcheck_ioctl_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_ioctl_callback) || \ + curlcheck_cb_compatible((expr), _curl_ioctl_callback1) || \ + curlcheck_cb_compatible((expr), _curl_ioctl_callback2) || \ + curlcheck_cb_compatible((expr), _curl_ioctl_callback3) || \ + curlcheck_cb_compatible((expr), _curl_ioctl_callback4)) +typedef curlioerr (*_curl_ioctl_callback1)(CURL *, int, void *); +typedef curlioerr (*_curl_ioctl_callback2)(CURL *, int, const void *); +typedef curlioerr (*_curl_ioctl_callback3)(CURL *, curliocmd, void *); +typedef curlioerr (*_curl_ioctl_callback4)(CURL *, curliocmd, const void *); + +/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */ +#define curlcheck_sockopt_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_sockopt_callback) || \ + curlcheck_cb_compatible((expr), _curl_sockopt_callback1) || \ + curlcheck_cb_compatible((expr), _curl_sockopt_callback2)) +typedef int (*_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype); +typedef int (*_curl_sockopt_callback2)(const void *, curl_socket_t, + curlsocktype); + +/* evaluates to true if expr is of type curl_opensocket_callback or + "similar" */ +#define curlcheck_opensocket_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_opensocket_callback) || \ + curlcheck_cb_compatible((expr), _curl_opensocket_callback1) || \ + curlcheck_cb_compatible((expr), _curl_opensocket_callback2) || \ + curlcheck_cb_compatible((expr), _curl_opensocket_callback3) || \ + curlcheck_cb_compatible((expr), _curl_opensocket_callback4)) +typedef curl_socket_t (*_curl_opensocket_callback1) + (void *, curlsocktype, struct curl_sockaddr *); +typedef curl_socket_t (*_curl_opensocket_callback2) + (void *, curlsocktype, const struct curl_sockaddr *); +typedef curl_socket_t (*_curl_opensocket_callback3) + (const void *, curlsocktype, struct curl_sockaddr *); +typedef curl_socket_t (*_curl_opensocket_callback4) + (const void *, curlsocktype, const struct curl_sockaddr *); + +/* evaluates to true if expr is of type curl_progress_callback or "similar" */ +#define curlcheck_progress_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_progress_callback) || \ + curlcheck_cb_compatible((expr), _curl_progress_callback1) || \ + curlcheck_cb_compatible((expr), _curl_progress_callback2)) +typedef int (*_curl_progress_callback1)(void *, + double, double, double, double); +typedef int (*_curl_progress_callback2)(const void *, + double, double, double, double); + +/* evaluates to true if expr is of type curl_xferinfo_callback */ +#define curlcheck_xferinfo_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_xferinfo_callback)) + +/* evaluates to true if expr is of type curl_debug_callback or "similar" */ +#define curlcheck_debug_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_debug_callback) || \ + curlcheck_cb_compatible((expr), _curl_debug_callback1) || \ + curlcheck_cb_compatible((expr), _curl_debug_callback2) || \ + curlcheck_cb_compatible((expr), _curl_debug_callback3) || \ + curlcheck_cb_compatible((expr), _curl_debug_callback4) || \ + curlcheck_cb_compatible((expr), _curl_debug_callback5) || \ + curlcheck_cb_compatible((expr), _curl_debug_callback6) || \ + curlcheck_cb_compatible((expr), _curl_debug_callback7) || \ + curlcheck_cb_compatible((expr), _curl_debug_callback8)) +typedef int (*_curl_debug_callback1) (CURL *, + curl_infotype, char *, size_t, void *); +typedef int (*_curl_debug_callback2) (CURL *, + curl_infotype, char *, size_t, const void *); +typedef int (*_curl_debug_callback3) (CURL *, + curl_infotype, const char *, size_t, void *); +typedef int (*_curl_debug_callback4) (CURL *, + curl_infotype, const char *, size_t, const void *); +typedef int (*_curl_debug_callback5) (CURL *, + curl_infotype, unsigned char *, size_t, void *); +typedef int (*_curl_debug_callback6) (CURL *, + curl_infotype, unsigned char *, size_t, const void *); +typedef int (*_curl_debug_callback7) (CURL *, + curl_infotype, const unsigned char *, size_t, void *); +typedef int (*_curl_debug_callback8) (CURL *, + curl_infotype, const unsigned char *, size_t, const void *); + +/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */ +/* this is getting even messier... */ +#define curlcheck_ssl_ctx_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_ssl_ctx_callback) || \ + curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback1) || \ + curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback2) || \ + curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback3) || \ + curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback4) || \ + curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback5) || \ + curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback6) || \ + curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback7) || \ + curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback8)) +typedef CURLcode (*_curl_ssl_ctx_callback1)(CURL *, void *, void *); +typedef CURLcode (*_curl_ssl_ctx_callback2)(CURL *, void *, const void *); +typedef CURLcode (*_curl_ssl_ctx_callback3)(CURL *, const void *, void *); +typedef CURLcode (*_curl_ssl_ctx_callback4)(CURL *, const void *, + const void *); +#ifdef HEADER_SSL_H +/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX + * this will of course break if we are included before OpenSSL headers... + */ +typedef CURLcode (*_curl_ssl_ctx_callback5)(CURL *, SSL_CTX *, void *); +typedef CURLcode (*_curl_ssl_ctx_callback6)(CURL *, SSL_CTX *, const void *); +typedef CURLcode (*_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX *, void *); +typedef CURLcode (*_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX *, + const void *); +#else +typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5; +typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6; +typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7; +typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8; +#endif + +/* evaluates to true if expr is of type curl_conv_callback or "similar" */ +#define curlcheck_conv_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_conv_callback) || \ + curlcheck_cb_compatible((expr), _curl_conv_callback1) || \ + curlcheck_cb_compatible((expr), _curl_conv_callback2) || \ + curlcheck_cb_compatible((expr), _curl_conv_callback3) || \ + curlcheck_cb_compatible((expr), _curl_conv_callback4)) +typedef CURLcode (*_curl_conv_callback1)(char *, size_t length); +typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length); +typedef CURLcode (*_curl_conv_callback3)(void *, size_t length); +typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length); + +/* evaluates to true if expr is of type curl_seek_callback or "similar" */ +#define curlcheck_seek_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_seek_callback) || \ + curlcheck_cb_compatible((expr), _curl_seek_callback1) || \ + curlcheck_cb_compatible((expr), _curl_seek_callback2)) +typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int); +typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int); + +/* evaluates to true if expr is of type curl_chunk_bgn_callback */ +#define curlcheck_chunk_bgn_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_chunk_bgn_callback) || \ + curlcheck_cb_compatible((expr), _curl_chunk_bgn_callback1) || \ + curlcheck_cb_compatible((expr), _curl_chunk_bgn_callback2)) +typedef long (*_curl_chunk_bgn_callback1)(struct curl_fileinfo *, + void *, int); +typedef long (*_curl_chunk_bgn_callback2)(void *, void *, int); + +/* evaluates to true if expr is of type curl_chunk_end_callback */ +#define curlcheck_chunk_end_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_chunk_end_callback)) + +/* evaluates to true if expr is of type curl_closesocket_callback */ +#define curlcheck_close_socket_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_closesocket_callback)) + +/* evaluates to true if expr is of type curl_fnmatch_callback */ +#define curlcheck_fnmatch_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_fnmatch_callback)) + +/* evaluates to true if expr is of type curl_hstsread_callback */ +#define curlcheck_hstsread_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_hstsread_callback)) + +/* evaluates to true if expr is of type curl_hstswrite_callback */ +#define curlcheck_hstswrite_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_hstswrite_callback)) + +/* evaluates to true if expr is of type curl_sshhostkeycallback */ +#define curlcheck_ssh_hostkey_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_sshhostkeycallback)) + +/* evaluates to true if expr is of type curl_sshkeycallback */ +#define curlcheck_ssh_key_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_sshkeycallback)) + +/* evaluates to true if expr is of type curl_interleave_callback */ +#define curlcheck_interleave_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), _curl_interleave_callback1) || \ + curlcheck_cb_compatible((expr), _curl_interleave_callback2)) +typedef size_t (*_curl_interleave_callback1)(void *p, size_t s, + size_t n, void *u); +typedef size_t (*_curl_interleave_callback2)(char *p, size_t s, + size_t n, void *u); + +/* evaluates to true if expr is of type curl_prereq_callback */ +#define curlcheck_prereq_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_prereq_callback)) + +/* evaluates to true if expr is of type curl_trailer_callback */ +#define curlcheck_trailer_cb(expr) \ + (curlcheck_NULL(expr) || \ + curlcheck_cb_compatible((expr), curl_trailer_callback)) + +#endif /* CURLINC_TYPECHECK_GCC_H */ diff --git a/code/thirdparty/curl-8.15.0/include/curl/urlapi.h b/code/thirdparty/curl-8.15.0/include/curl/urlapi.h new file mode 100644 index 00000000..b4a6e5d5 --- /dev/null +++ b/code/thirdparty/curl-8.15.0/include/curl/urlapi.h @@ -0,0 +1,155 @@ +#ifndef CURLINC_URLAPI_H +#define CURLINC_URLAPI_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#include "curl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* the error codes for the URL API */ +typedef enum { + CURLUE_OK, + CURLUE_BAD_HANDLE, /* 1 */ + CURLUE_BAD_PARTPOINTER, /* 2 */ + CURLUE_MALFORMED_INPUT, /* 3 */ + CURLUE_BAD_PORT_NUMBER, /* 4 */ + CURLUE_UNSUPPORTED_SCHEME, /* 5 */ + CURLUE_URLDECODE, /* 6 */ + CURLUE_OUT_OF_MEMORY, /* 7 */ + CURLUE_USER_NOT_ALLOWED, /* 8 */ + CURLUE_UNKNOWN_PART, /* 9 */ + CURLUE_NO_SCHEME, /* 10 */ + CURLUE_NO_USER, /* 11 */ + CURLUE_NO_PASSWORD, /* 12 */ + CURLUE_NO_OPTIONS, /* 13 */ + CURLUE_NO_HOST, /* 14 */ + CURLUE_NO_PORT, /* 15 */ + CURLUE_NO_QUERY, /* 16 */ + CURLUE_NO_FRAGMENT, /* 17 */ + CURLUE_NO_ZONEID, /* 18 */ + CURLUE_BAD_FILE_URL, /* 19 */ + CURLUE_BAD_FRAGMENT, /* 20 */ + CURLUE_BAD_HOSTNAME, /* 21 */ + CURLUE_BAD_IPV6, /* 22 */ + CURLUE_BAD_LOGIN, /* 23 */ + CURLUE_BAD_PASSWORD, /* 24 */ + CURLUE_BAD_PATH, /* 25 */ + CURLUE_BAD_QUERY, /* 26 */ + CURLUE_BAD_SCHEME, /* 27 */ + CURLUE_BAD_SLASHES, /* 28 */ + CURLUE_BAD_USER, /* 29 */ + CURLUE_LACKS_IDN, /* 30 */ + CURLUE_TOO_LARGE, /* 31 */ + CURLUE_LAST +} CURLUcode; + +typedef enum { + CURLUPART_URL, + CURLUPART_SCHEME, + CURLUPART_USER, + CURLUPART_PASSWORD, + CURLUPART_OPTIONS, + CURLUPART_HOST, + CURLUPART_PORT, + CURLUPART_PATH, + CURLUPART_QUERY, + CURLUPART_FRAGMENT, + CURLUPART_ZONEID /* added in 7.65.0 */ +} CURLUPart; + +#define CURLU_DEFAULT_PORT (1<<0) /* return default port number */ +#define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set, + if the port number matches the + default for the scheme */ +#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if + missing */ +#define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */ +#define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */ +#define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */ +#define CURLU_URLDECODE (1<<6) /* URL decode on get */ +#define CURLU_URLENCODE (1<<7) /* URL encode on set */ +#define CURLU_APPENDQUERY (1<<8) /* append a form style part */ +#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */ +#define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the + scheme is unknown. */ +#define CURLU_ALLOW_SPACE (1<<11) /* Allow spaces in the URL */ +#define CURLU_PUNYCODE (1<<12) /* get the hostname in punycode */ +#define CURLU_PUNY2IDN (1<<13) /* punycode => IDN conversion */ +#define CURLU_GET_EMPTY (1<<14) /* allow empty queries and fragments + when extracting the URL or the + components */ +#define CURLU_NO_GUESS_SCHEME (1<<15) /* for get, do not accept a guess */ + +typedef struct Curl_URL CURLU; + +/* + * curl_url() creates a new CURLU handle and returns a pointer to it. + * Must be freed with curl_url_cleanup(). + */ +CURL_EXTERN CURLU *curl_url(void); + +/* + * curl_url_cleanup() frees the CURLU handle and related resources used for + * the URL parsing. It will not free strings previously returned with the URL + * API. + */ +CURL_EXTERN void curl_url_cleanup(CURLU *handle); + +/* + * curl_url_dup() duplicates a CURLU handle and returns a new copy. The new + * handle must also be freed with curl_url_cleanup(). + */ +CURL_EXTERN CURLU *curl_url_dup(const CURLU *in); + +/* + * curl_url_get() extracts a specific part of the URL from a CURLU + * handle. Returns error code. The returned pointer MUST be freed with + * curl_free() afterwards. + */ +CURL_EXTERN CURLUcode curl_url_get(const CURLU *handle, CURLUPart what, + char **part, unsigned int flags); + +/* + * curl_url_set() sets a specific part of the URL in a CURLU handle. Returns + * error code. The passed in string will be copied. Passing a NULL instead of + * a part string, clears that part. + */ +CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what, + const char *part, unsigned int flags); + +/* + * curl_url_strerror() turns a CURLUcode value into the equivalent human + * readable error string. This is useful for printing meaningful error + * messages. + */ +CURL_EXTERN const char *curl_url_strerror(CURLUcode); + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif /* CURLINC_URLAPI_H */ diff --git a/code/thirdparty/curl-8.15.0/include/curl/websockets.h b/code/thirdparty/curl-8.15.0/include/curl/websockets.h new file mode 100644 index 00000000..afb86b4e --- /dev/null +++ b/code/thirdparty/curl-8.15.0/include/curl/websockets.h @@ -0,0 +1,85 @@ +#ifndef CURLINC_WEBSOCKETS_H +#define CURLINC_WEBSOCKETS_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +struct curl_ws_frame { + int age; /* zero */ + int flags; /* See the CURLWS_* defines */ + curl_off_t offset; /* the offset of this data into the frame */ + curl_off_t bytesleft; /* number of pending bytes left of the payload */ + size_t len; /* size of the current data chunk */ +}; + +/* flag bits */ +#define CURLWS_TEXT (1<<0) +#define CURLWS_BINARY (1<<1) +#define CURLWS_CONT (1<<2) +#define CURLWS_CLOSE (1<<3) +#define CURLWS_PING (1<<4) +#define CURLWS_OFFSET (1<<5) + +/* + * NAME curl_ws_recv() + * + * DESCRIPTION + * + * Receives data from the websocket connection. Use after successful + * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. + */ +CURL_EXTERN CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen, + size_t *recv, + const struct curl_ws_frame **metap); + +/* flags for curl_ws_send() */ +#define CURLWS_PONG (1<<6) + +/* + * NAME curl_ws_send() + * + * DESCRIPTION + * + * Sends data over the websocket connection. Use after successful + * curl_easy_perform() with CURLOPT_CONNECT_ONLY option. + */ +CURL_EXTERN CURLcode curl_ws_send(CURL *curl, const void *buffer, + size_t buflen, size_t *sent, + curl_off_t fragsize, + unsigned int flags); + +/* bits for the CURLOPT_WS_OPTIONS bitmask: */ +#define CURLWS_RAW_MODE (1<<0) +#define CURLWS_NOAUTOPONG (1<<1) + +CURL_EXTERN const struct curl_ws_frame *curl_ws_meta(CURL *curl); + +#ifdef __cplusplus +} +#endif + +#endif /* CURLINC_WEBSOCKETS_H */ diff --git a/code/jpeg-9f/cderror.h b/code/thirdparty/jpeg-9f/cderror.h similarity index 100% rename from code/jpeg-9f/cderror.h rename to code/thirdparty/jpeg-9f/cderror.h diff --git a/code/jpeg-9f/cdjpeg.h b/code/thirdparty/jpeg-9f/cdjpeg.h similarity index 100% rename from code/jpeg-9f/cdjpeg.h rename to code/thirdparty/jpeg-9f/cdjpeg.h diff --git a/code/jpeg-9f/jaricom.c b/code/thirdparty/jpeg-9f/jaricom.c similarity index 100% rename from code/jpeg-9f/jaricom.c rename to code/thirdparty/jpeg-9f/jaricom.c diff --git a/code/jpeg-9f/jcapimin.c b/code/thirdparty/jpeg-9f/jcapimin.c similarity index 100% rename from code/jpeg-9f/jcapimin.c rename to code/thirdparty/jpeg-9f/jcapimin.c diff --git a/code/jpeg-9f/jcapistd.c b/code/thirdparty/jpeg-9f/jcapistd.c similarity index 100% rename from code/jpeg-9f/jcapistd.c rename to code/thirdparty/jpeg-9f/jcapistd.c diff --git a/code/jpeg-9f/jcarith.c b/code/thirdparty/jpeg-9f/jcarith.c similarity index 100% rename from code/jpeg-9f/jcarith.c rename to code/thirdparty/jpeg-9f/jcarith.c diff --git a/code/jpeg-9f/jccoefct.c b/code/thirdparty/jpeg-9f/jccoefct.c similarity index 100% rename from code/jpeg-9f/jccoefct.c rename to code/thirdparty/jpeg-9f/jccoefct.c diff --git a/code/jpeg-9f/jccolor.c b/code/thirdparty/jpeg-9f/jccolor.c similarity index 100% rename from code/jpeg-9f/jccolor.c rename to code/thirdparty/jpeg-9f/jccolor.c diff --git a/code/jpeg-9f/jcdctmgr.c b/code/thirdparty/jpeg-9f/jcdctmgr.c similarity index 100% rename from code/jpeg-9f/jcdctmgr.c rename to code/thirdparty/jpeg-9f/jcdctmgr.c diff --git a/code/jpeg-9f/jchuff.c b/code/thirdparty/jpeg-9f/jchuff.c similarity index 100% rename from code/jpeg-9f/jchuff.c rename to code/thirdparty/jpeg-9f/jchuff.c diff --git a/code/jpeg-9f/jcinit.c b/code/thirdparty/jpeg-9f/jcinit.c similarity index 100% rename from code/jpeg-9f/jcinit.c rename to code/thirdparty/jpeg-9f/jcinit.c diff --git a/code/jpeg-9f/jcmainct.c b/code/thirdparty/jpeg-9f/jcmainct.c similarity index 100% rename from code/jpeg-9f/jcmainct.c rename to code/thirdparty/jpeg-9f/jcmainct.c diff --git a/code/jpeg-9f/jcmarker.c b/code/thirdparty/jpeg-9f/jcmarker.c similarity index 100% rename from code/jpeg-9f/jcmarker.c rename to code/thirdparty/jpeg-9f/jcmarker.c diff --git a/code/jpeg-9f/jcmaster.c b/code/thirdparty/jpeg-9f/jcmaster.c similarity index 100% rename from code/jpeg-9f/jcmaster.c rename to code/thirdparty/jpeg-9f/jcmaster.c diff --git a/code/jpeg-9f/jcomapi.c b/code/thirdparty/jpeg-9f/jcomapi.c similarity index 100% rename from code/jpeg-9f/jcomapi.c rename to code/thirdparty/jpeg-9f/jcomapi.c diff --git a/code/jpeg-9f/jconfig.h b/code/thirdparty/jpeg-9f/jconfig.h similarity index 100% rename from code/jpeg-9f/jconfig.h rename to code/thirdparty/jpeg-9f/jconfig.h diff --git a/code/jpeg-9f/jcparam.c b/code/thirdparty/jpeg-9f/jcparam.c similarity index 100% rename from code/jpeg-9f/jcparam.c rename to code/thirdparty/jpeg-9f/jcparam.c diff --git a/code/jpeg-9f/jcprepct.c b/code/thirdparty/jpeg-9f/jcprepct.c similarity index 100% rename from code/jpeg-9f/jcprepct.c rename to code/thirdparty/jpeg-9f/jcprepct.c diff --git a/code/jpeg-9f/jcsample.c b/code/thirdparty/jpeg-9f/jcsample.c similarity index 100% rename from code/jpeg-9f/jcsample.c rename to code/thirdparty/jpeg-9f/jcsample.c diff --git a/code/jpeg-9f/jctrans.c b/code/thirdparty/jpeg-9f/jctrans.c similarity index 100% rename from code/jpeg-9f/jctrans.c rename to code/thirdparty/jpeg-9f/jctrans.c diff --git a/code/jpeg-9f/jdapimin.c b/code/thirdparty/jpeg-9f/jdapimin.c similarity index 100% rename from code/jpeg-9f/jdapimin.c rename to code/thirdparty/jpeg-9f/jdapimin.c diff --git a/code/jpeg-9f/jdapistd.c b/code/thirdparty/jpeg-9f/jdapistd.c similarity index 100% rename from code/jpeg-9f/jdapistd.c rename to code/thirdparty/jpeg-9f/jdapistd.c diff --git a/code/jpeg-9f/jdarith.c b/code/thirdparty/jpeg-9f/jdarith.c similarity index 100% rename from code/jpeg-9f/jdarith.c rename to code/thirdparty/jpeg-9f/jdarith.c diff --git a/code/jpeg-9f/jdatadst.c b/code/thirdparty/jpeg-9f/jdatadst.c similarity index 100% rename from code/jpeg-9f/jdatadst.c rename to code/thirdparty/jpeg-9f/jdatadst.c diff --git a/code/jpeg-9f/jdatasrc.c b/code/thirdparty/jpeg-9f/jdatasrc.c similarity index 100% rename from code/jpeg-9f/jdatasrc.c rename to code/thirdparty/jpeg-9f/jdatasrc.c diff --git a/code/jpeg-9f/jdcoefct.c b/code/thirdparty/jpeg-9f/jdcoefct.c similarity index 100% rename from code/jpeg-9f/jdcoefct.c rename to code/thirdparty/jpeg-9f/jdcoefct.c diff --git a/code/jpeg-9f/jdcolor.c b/code/thirdparty/jpeg-9f/jdcolor.c similarity index 100% rename from code/jpeg-9f/jdcolor.c rename to code/thirdparty/jpeg-9f/jdcolor.c diff --git a/code/jpeg-9f/jdct.h b/code/thirdparty/jpeg-9f/jdct.h similarity index 100% rename from code/jpeg-9f/jdct.h rename to code/thirdparty/jpeg-9f/jdct.h diff --git a/code/jpeg-9f/jddctmgr.c b/code/thirdparty/jpeg-9f/jddctmgr.c similarity index 100% rename from code/jpeg-9f/jddctmgr.c rename to code/thirdparty/jpeg-9f/jddctmgr.c diff --git a/code/jpeg-9f/jdhuff.c b/code/thirdparty/jpeg-9f/jdhuff.c similarity index 100% rename from code/jpeg-9f/jdhuff.c rename to code/thirdparty/jpeg-9f/jdhuff.c diff --git a/code/jpeg-9f/jdinput.c b/code/thirdparty/jpeg-9f/jdinput.c similarity index 100% rename from code/jpeg-9f/jdinput.c rename to code/thirdparty/jpeg-9f/jdinput.c diff --git a/code/jpeg-9f/jdmainct.c b/code/thirdparty/jpeg-9f/jdmainct.c similarity index 100% rename from code/jpeg-9f/jdmainct.c rename to code/thirdparty/jpeg-9f/jdmainct.c diff --git a/code/jpeg-9f/jdmarker.c b/code/thirdparty/jpeg-9f/jdmarker.c similarity index 100% rename from code/jpeg-9f/jdmarker.c rename to code/thirdparty/jpeg-9f/jdmarker.c diff --git a/code/jpeg-9f/jdmaster.c b/code/thirdparty/jpeg-9f/jdmaster.c similarity index 100% rename from code/jpeg-9f/jdmaster.c rename to code/thirdparty/jpeg-9f/jdmaster.c diff --git a/code/jpeg-9f/jdmerge.c b/code/thirdparty/jpeg-9f/jdmerge.c similarity index 100% rename from code/jpeg-9f/jdmerge.c rename to code/thirdparty/jpeg-9f/jdmerge.c diff --git a/code/jpeg-9f/jdpostct.c b/code/thirdparty/jpeg-9f/jdpostct.c similarity index 100% rename from code/jpeg-9f/jdpostct.c rename to code/thirdparty/jpeg-9f/jdpostct.c diff --git a/code/jpeg-9f/jdsample.c b/code/thirdparty/jpeg-9f/jdsample.c similarity index 100% rename from code/jpeg-9f/jdsample.c rename to code/thirdparty/jpeg-9f/jdsample.c diff --git a/code/jpeg-9f/jdtrans.c b/code/thirdparty/jpeg-9f/jdtrans.c similarity index 100% rename from code/jpeg-9f/jdtrans.c rename to code/thirdparty/jpeg-9f/jdtrans.c diff --git a/code/jpeg-9f/jerror.c b/code/thirdparty/jpeg-9f/jerror.c similarity index 100% rename from code/jpeg-9f/jerror.c rename to code/thirdparty/jpeg-9f/jerror.c diff --git a/code/jpeg-9f/jerror.h b/code/thirdparty/jpeg-9f/jerror.h similarity index 100% rename from code/jpeg-9f/jerror.h rename to code/thirdparty/jpeg-9f/jerror.h diff --git a/code/jpeg-9f/jfdctflt.c b/code/thirdparty/jpeg-9f/jfdctflt.c similarity index 100% rename from code/jpeg-9f/jfdctflt.c rename to code/thirdparty/jpeg-9f/jfdctflt.c diff --git a/code/jpeg-9f/jfdctfst.c b/code/thirdparty/jpeg-9f/jfdctfst.c similarity index 100% rename from code/jpeg-9f/jfdctfst.c rename to code/thirdparty/jpeg-9f/jfdctfst.c diff --git a/code/jpeg-9f/jfdctint.c b/code/thirdparty/jpeg-9f/jfdctint.c similarity index 100% rename from code/jpeg-9f/jfdctint.c rename to code/thirdparty/jpeg-9f/jfdctint.c diff --git a/code/jpeg-9f/jidctflt.c b/code/thirdparty/jpeg-9f/jidctflt.c similarity index 100% rename from code/jpeg-9f/jidctflt.c rename to code/thirdparty/jpeg-9f/jidctflt.c diff --git a/code/jpeg-9f/jidctfst.c b/code/thirdparty/jpeg-9f/jidctfst.c similarity index 100% rename from code/jpeg-9f/jidctfst.c rename to code/thirdparty/jpeg-9f/jidctfst.c diff --git a/code/jpeg-9f/jidctint.c b/code/thirdparty/jpeg-9f/jidctint.c similarity index 100% rename from code/jpeg-9f/jidctint.c rename to code/thirdparty/jpeg-9f/jidctint.c diff --git a/code/jpeg-9f/jinclude.h b/code/thirdparty/jpeg-9f/jinclude.h similarity index 100% rename from code/jpeg-9f/jinclude.h rename to code/thirdparty/jpeg-9f/jinclude.h diff --git a/code/jpeg-9f/jmemmgr.c b/code/thirdparty/jpeg-9f/jmemmgr.c similarity index 100% rename from code/jpeg-9f/jmemmgr.c rename to code/thirdparty/jpeg-9f/jmemmgr.c diff --git a/code/jpeg-9f/jmemnobs.c b/code/thirdparty/jpeg-9f/jmemnobs.c similarity index 100% rename from code/jpeg-9f/jmemnobs.c rename to code/thirdparty/jpeg-9f/jmemnobs.c diff --git a/code/jpeg-9f/jmemsys.h b/code/thirdparty/jpeg-9f/jmemsys.h similarity index 100% rename from code/jpeg-9f/jmemsys.h rename to code/thirdparty/jpeg-9f/jmemsys.h diff --git a/code/jpeg-9f/jmorecfg.h b/code/thirdparty/jpeg-9f/jmorecfg.h similarity index 100% rename from code/jpeg-9f/jmorecfg.h rename to code/thirdparty/jpeg-9f/jmorecfg.h diff --git a/code/jpeg-9f/jpegint.h b/code/thirdparty/jpeg-9f/jpegint.h similarity index 100% rename from code/jpeg-9f/jpegint.h rename to code/thirdparty/jpeg-9f/jpegint.h diff --git a/code/jpeg-9f/jpeglib.h b/code/thirdparty/jpeg-9f/jpeglib.h similarity index 100% rename from code/jpeg-9f/jpeglib.h rename to code/thirdparty/jpeg-9f/jpeglib.h diff --git a/code/jpeg-9f/jquant1.c b/code/thirdparty/jpeg-9f/jquant1.c similarity index 100% rename from code/jpeg-9f/jquant1.c rename to code/thirdparty/jpeg-9f/jquant1.c diff --git a/code/jpeg-9f/jquant2.c b/code/thirdparty/jpeg-9f/jquant2.c similarity index 100% rename from code/jpeg-9f/jquant2.c rename to code/thirdparty/jpeg-9f/jquant2.c diff --git a/code/jpeg-9f/jutils.c b/code/thirdparty/jpeg-9f/jutils.c similarity index 100% rename from code/jpeg-9f/jutils.c rename to code/thirdparty/jpeg-9f/jutils.c diff --git a/code/jpeg-9f/jversion.h b/code/thirdparty/jpeg-9f/jversion.h similarity index 100% rename from code/jpeg-9f/jversion.h rename to code/thirdparty/jpeg-9f/jversion.h diff --git a/code/jpeg-9f/transupp.h b/code/thirdparty/jpeg-9f/transupp.h similarity index 100% rename from code/jpeg-9f/transupp.h rename to code/thirdparty/jpeg-9f/transupp.h diff --git a/code/libmad/.github/workflows/build.yml b/code/thirdparty/libmad/.github/workflows/build.yml similarity index 100% rename from code/libmad/.github/workflows/build.yml rename to code/thirdparty/libmad/.github/workflows/build.yml diff --git a/code/libmad/.gitignore b/code/thirdparty/libmad/.gitignore similarity index 100% rename from code/libmad/.gitignore rename to code/thirdparty/libmad/.gitignore diff --git a/code/libmad/CHANGES b/code/thirdparty/libmad/CHANGES similarity index 100% rename from code/libmad/CHANGES rename to code/thirdparty/libmad/CHANGES diff --git a/code/libmad/CMakeLists.txt b/code/thirdparty/libmad/CMakeLists.txt similarity index 100% rename from code/libmad/CMakeLists.txt rename to code/thirdparty/libmad/CMakeLists.txt diff --git a/code/libmad/COPYING b/code/thirdparty/libmad/COPYING similarity index 100% rename from code/libmad/COPYING rename to code/thirdparty/libmad/COPYING diff --git a/code/libmad/COPYRIGHT b/code/thirdparty/libmad/COPYRIGHT similarity index 100% rename from code/libmad/COPYRIGHT rename to code/thirdparty/libmad/COPYRIGHT diff --git a/code/libmad/CREDITS b/code/thirdparty/libmad/CREDITS similarity index 100% rename from code/libmad/CREDITS rename to code/thirdparty/libmad/CREDITS diff --git a/code/libmad/D.dat b/code/thirdparty/libmad/D.dat similarity index 100% rename from code/libmad/D.dat rename to code/thirdparty/libmad/D.dat diff --git a/code/libmad/README.md b/code/thirdparty/libmad/README.md similarity index 100% rename from code/libmad/README.md rename to code/thirdparty/libmad/README.md diff --git a/code/libmad/TODO b/code/thirdparty/libmad/TODO similarity index 100% rename from code/libmad/TODO rename to code/thirdparty/libmad/TODO diff --git a/code/libmad/bit.c b/code/thirdparty/libmad/bit.c similarity index 100% rename from code/libmad/bit.c rename to code/thirdparty/libmad/bit.c diff --git a/code/libmad/decoder.c b/code/thirdparty/libmad/decoder.c similarity index 100% rename from code/libmad/decoder.c rename to code/thirdparty/libmad/decoder.c diff --git a/code/libmad/fixed.c b/code/thirdparty/libmad/fixed.c similarity index 100% rename from code/libmad/fixed.c rename to code/thirdparty/libmad/fixed.c diff --git a/code/libmad/frame.c b/code/thirdparty/libmad/frame.c similarity index 100% rename from code/libmad/frame.c rename to code/thirdparty/libmad/frame.c diff --git a/code/libmad/global.h b/code/thirdparty/libmad/global.h similarity index 100% rename from code/libmad/global.h rename to code/thirdparty/libmad/global.h diff --git a/code/libmad/huffman.c b/code/thirdparty/libmad/huffman.c similarity index 100% rename from code/libmad/huffman.c rename to code/thirdparty/libmad/huffman.c diff --git a/code/libmad/huffman.h b/code/thirdparty/libmad/huffman.h similarity index 100% rename from code/libmad/huffman.h rename to code/thirdparty/libmad/huffman.h diff --git a/code/libmad/imdct_l_arm.S b/code/thirdparty/libmad/imdct_l_arm.S similarity index 100% rename from code/libmad/imdct_l_arm.S rename to code/thirdparty/libmad/imdct_l_arm.S diff --git a/code/libmad/imdct_s.dat b/code/thirdparty/libmad/imdct_s.dat similarity index 100% rename from code/libmad/imdct_s.dat rename to code/thirdparty/libmad/imdct_s.dat diff --git a/code/libmad/layer12.c b/code/thirdparty/libmad/layer12.c similarity index 100% rename from code/libmad/layer12.c rename to code/thirdparty/libmad/layer12.c diff --git a/code/libmad/layer12.h b/code/thirdparty/libmad/layer12.h similarity index 100% rename from code/libmad/layer12.h rename to code/thirdparty/libmad/layer12.h diff --git a/code/libmad/layer3.c b/code/thirdparty/libmad/layer3.c similarity index 100% rename from code/libmad/layer3.c rename to code/thirdparty/libmad/layer3.c diff --git a/code/libmad/layer3.h b/code/thirdparty/libmad/layer3.h similarity index 100% rename from code/libmad/layer3.h rename to code/thirdparty/libmad/layer3.h diff --git a/code/libmad/mad.h.in b/code/thirdparty/libmad/mad.h.in similarity index 100% rename from code/libmad/mad.h.in rename to code/thirdparty/libmad/mad.h.in diff --git a/code/libmad/minimad.c b/code/thirdparty/libmad/minimad.c similarity index 100% rename from code/libmad/minimad.c rename to code/thirdparty/libmad/minimad.c diff --git a/code/libmad/packaging/mad.pc.in b/code/thirdparty/libmad/packaging/mad.pc.in similarity index 100% rename from code/libmad/packaging/mad.pc.in rename to code/thirdparty/libmad/packaging/mad.pc.in diff --git a/code/libmad/packaging/madConfig.cmake.in b/code/thirdparty/libmad/packaging/madConfig.cmake.in similarity index 100% rename from code/libmad/packaging/madConfig.cmake.in rename to code/thirdparty/libmad/packaging/madConfig.cmake.in diff --git a/code/libmad/qc_table.dat b/code/thirdparty/libmad/qc_table.dat similarity index 100% rename from code/libmad/qc_table.dat rename to code/thirdparty/libmad/qc_table.dat diff --git a/code/libmad/rq_table.dat b/code/thirdparty/libmad/rq_table.dat similarity index 100% rename from code/libmad/rq_table.dat rename to code/thirdparty/libmad/rq_table.dat diff --git a/code/libmad/sf_table.dat b/code/thirdparty/libmad/sf_table.dat similarity index 100% rename from code/libmad/sf_table.dat rename to code/thirdparty/libmad/sf_table.dat diff --git a/code/libmad/stream.c b/code/thirdparty/libmad/stream.c similarity index 100% rename from code/libmad/stream.c rename to code/thirdparty/libmad/stream.c diff --git a/code/libmad/synth.c b/code/thirdparty/libmad/synth.c similarity index 100% rename from code/libmad/synth.c rename to code/thirdparty/libmad/synth.c diff --git a/code/libmad/timer.c b/code/thirdparty/libmad/timer.c similarity index 100% rename from code/libmad/timer.c rename to code/thirdparty/libmad/timer.c diff --git a/code/libmad/version.c b/code/thirdparty/libmad/version.c similarity index 100% rename from code/libmad/version.c rename to code/thirdparty/libmad/version.c diff --git a/code/libogg-1.3.6/include/ogg/config_types.h b/code/thirdparty/libogg-1.3.6/include/ogg/config_types.h similarity index 100% rename from code/libogg-1.3.6/include/ogg/config_types.h rename to code/thirdparty/libogg-1.3.6/include/ogg/config_types.h diff --git a/code/libogg-1.3.6/include/ogg/ogg.h b/code/thirdparty/libogg-1.3.6/include/ogg/ogg.h similarity index 100% rename from code/libogg-1.3.6/include/ogg/ogg.h rename to code/thirdparty/libogg-1.3.6/include/ogg/ogg.h diff --git a/code/libogg-1.3.6/include/ogg/os_types.h b/code/thirdparty/libogg-1.3.6/include/ogg/os_types.h similarity index 100% rename from code/libogg-1.3.6/include/ogg/os_types.h rename to code/thirdparty/libogg-1.3.6/include/ogg/os_types.h diff --git a/code/libogg-1.3.6/src/bitwise.c b/code/thirdparty/libogg-1.3.6/src/bitwise.c similarity index 100% rename from code/libogg-1.3.6/src/bitwise.c rename to code/thirdparty/libogg-1.3.6/src/bitwise.c diff --git a/code/libogg-1.3.6/src/crctable.h b/code/thirdparty/libogg-1.3.6/src/crctable.h similarity index 100% rename from code/libogg-1.3.6/src/crctable.h rename to code/thirdparty/libogg-1.3.6/src/crctable.h diff --git a/code/libogg-1.3.6/src/framing.c b/code/thirdparty/libogg-1.3.6/src/framing.c similarity index 100% rename from code/libogg-1.3.6/src/framing.c rename to code/thirdparty/libogg-1.3.6/src/framing.c diff --git a/code/libs/macos/libSDL2-2.0.0.dylib b/code/thirdparty/libs/macos/libSDL2-2.0.0.dylib similarity index 100% rename from code/libs/macos/libSDL2-2.0.0.dylib rename to code/thirdparty/libs/macos/libSDL2-2.0.0.dylib diff --git a/code/libs/macos/libSDL2main.a b/code/thirdparty/libs/macos/libSDL2main.a similarity index 100% rename from code/libs/macos/libSDL2main.a rename to code/thirdparty/libs/macos/libSDL2main.a diff --git a/code/libs/win32/SDL2.dll b/code/thirdparty/libs/win32/SDL2.dll similarity index 100% rename from code/libs/win32/SDL2.dll rename to code/thirdparty/libs/win32/SDL2.dll diff --git a/code/libs/win32/SDL2.lib b/code/thirdparty/libs/win32/SDL2.lib similarity index 100% rename from code/libs/win32/SDL2.lib rename to code/thirdparty/libs/win32/SDL2.lib diff --git a/code/libs/win32/SDL2main.lib b/code/thirdparty/libs/win32/SDL2main.lib similarity index 100% rename from code/libs/win32/SDL2main.lib rename to code/thirdparty/libs/win32/SDL2main.lib diff --git a/code/libs/win32/libSDL2.dll.a b/code/thirdparty/libs/win32/libSDL2.dll.a similarity index 100% rename from code/libs/win32/libSDL2.dll.a rename to code/thirdparty/libs/win32/libSDL2.dll.a diff --git a/code/libs/win32/libSDL2main.a b/code/thirdparty/libs/win32/libSDL2main.a similarity index 100% rename from code/libs/win32/libSDL2main.a rename to code/thirdparty/libs/win32/libSDL2main.a diff --git a/code/libs/win64/SDL2.dll b/code/thirdparty/libs/win64/SDL2.dll similarity index 100% rename from code/libs/win64/SDL2.dll rename to code/thirdparty/libs/win64/SDL2.dll diff --git a/code/libs/win64/SDL2.lib b/code/thirdparty/libs/win64/SDL2.lib similarity index 100% rename from code/libs/win64/SDL2.lib rename to code/thirdparty/libs/win64/SDL2.lib diff --git a/code/libs/win64/SDL2main.lib b/code/thirdparty/libs/win64/SDL2main.lib similarity index 100% rename from code/libs/win64/SDL2main.lib rename to code/thirdparty/libs/win64/SDL2main.lib diff --git a/code/libs/win64/libSDL2.dll.a b/code/thirdparty/libs/win64/libSDL2.dll.a similarity index 100% rename from code/libs/win64/libSDL2.dll.a rename to code/thirdparty/libs/win64/libSDL2.dll.a diff --git a/code/libs/win64/libSDL2main.a b/code/thirdparty/libs/win64/libSDL2main.a similarity index 100% rename from code/libs/win64/libSDL2main.a rename to code/thirdparty/libs/win64/libSDL2main.a diff --git a/code/libvorbis-1.3.7/include/vorbis/codec.h b/code/thirdparty/libvorbis-1.3.7/include/vorbis/codec.h similarity index 100% rename from code/libvorbis-1.3.7/include/vorbis/codec.h rename to code/thirdparty/libvorbis-1.3.7/include/vorbis/codec.h diff --git a/code/libvorbis-1.3.7/include/vorbis/vorbisenc.h b/code/thirdparty/libvorbis-1.3.7/include/vorbis/vorbisenc.h similarity index 100% rename from code/libvorbis-1.3.7/include/vorbis/vorbisenc.h rename to code/thirdparty/libvorbis-1.3.7/include/vorbis/vorbisenc.h diff --git a/code/libvorbis-1.3.7/include/vorbis/vorbisfile.h b/code/thirdparty/libvorbis-1.3.7/include/vorbis/vorbisfile.h similarity index 100% rename from code/libvorbis-1.3.7/include/vorbis/vorbisfile.h rename to code/thirdparty/libvorbis-1.3.7/include/vorbis/vorbisfile.h diff --git a/code/libvorbis-1.3.7/lib/analysis.c b/code/thirdparty/libvorbis-1.3.7/lib/analysis.c similarity index 100% rename from code/libvorbis-1.3.7/lib/analysis.c rename to code/thirdparty/libvorbis-1.3.7/lib/analysis.c diff --git a/code/libvorbis-1.3.7/lib/backends.h b/code/thirdparty/libvorbis-1.3.7/lib/backends.h similarity index 100% rename from code/libvorbis-1.3.7/lib/backends.h rename to code/thirdparty/libvorbis-1.3.7/lib/backends.h diff --git a/code/libvorbis-1.3.7/lib/bitrate.c b/code/thirdparty/libvorbis-1.3.7/lib/bitrate.c similarity index 100% rename from code/libvorbis-1.3.7/lib/bitrate.c rename to code/thirdparty/libvorbis-1.3.7/lib/bitrate.c diff --git a/code/libvorbis-1.3.7/lib/bitrate.h b/code/thirdparty/libvorbis-1.3.7/lib/bitrate.h similarity index 100% rename from code/libvorbis-1.3.7/lib/bitrate.h rename to code/thirdparty/libvorbis-1.3.7/lib/bitrate.h diff --git a/code/libvorbis-1.3.7/lib/block.c b/code/thirdparty/libvorbis-1.3.7/lib/block.c similarity index 100% rename from code/libvorbis-1.3.7/lib/block.c rename to code/thirdparty/libvorbis-1.3.7/lib/block.c diff --git a/code/libvorbis-1.3.7/lib/books/coupled/res_books_51.h b/code/thirdparty/libvorbis-1.3.7/lib/books/coupled/res_books_51.h similarity index 100% rename from code/libvorbis-1.3.7/lib/books/coupled/res_books_51.h rename to code/thirdparty/libvorbis-1.3.7/lib/books/coupled/res_books_51.h diff --git a/code/libvorbis-1.3.7/lib/books/coupled/res_books_stereo.h b/code/thirdparty/libvorbis-1.3.7/lib/books/coupled/res_books_stereo.h similarity index 100% rename from code/libvorbis-1.3.7/lib/books/coupled/res_books_stereo.h rename to code/thirdparty/libvorbis-1.3.7/lib/books/coupled/res_books_stereo.h diff --git a/code/libvorbis-1.3.7/lib/books/floor/floor_books.h b/code/thirdparty/libvorbis-1.3.7/lib/books/floor/floor_books.h similarity index 100% rename from code/libvorbis-1.3.7/lib/books/floor/floor_books.h rename to code/thirdparty/libvorbis-1.3.7/lib/books/floor/floor_books.h diff --git a/code/libvorbis-1.3.7/lib/books/uncoupled/res_books_uncoupled.h b/code/thirdparty/libvorbis-1.3.7/lib/books/uncoupled/res_books_uncoupled.h similarity index 100% rename from code/libvorbis-1.3.7/lib/books/uncoupled/res_books_uncoupled.h rename to code/thirdparty/libvorbis-1.3.7/lib/books/uncoupled/res_books_uncoupled.h diff --git a/code/libvorbis-1.3.7/lib/codebook.c b/code/thirdparty/libvorbis-1.3.7/lib/codebook.c similarity index 100% rename from code/libvorbis-1.3.7/lib/codebook.c rename to code/thirdparty/libvorbis-1.3.7/lib/codebook.c diff --git a/code/libvorbis-1.3.7/lib/codebook.h b/code/thirdparty/libvorbis-1.3.7/lib/codebook.h similarity index 100% rename from code/libvorbis-1.3.7/lib/codebook.h rename to code/thirdparty/libvorbis-1.3.7/lib/codebook.h diff --git a/code/libvorbis-1.3.7/lib/codec_internal.h b/code/thirdparty/libvorbis-1.3.7/lib/codec_internal.h similarity index 100% rename from code/libvorbis-1.3.7/lib/codec_internal.h rename to code/thirdparty/libvorbis-1.3.7/lib/codec_internal.h diff --git a/code/libvorbis-1.3.7/lib/envelope.c b/code/thirdparty/libvorbis-1.3.7/lib/envelope.c similarity index 100% rename from code/libvorbis-1.3.7/lib/envelope.c rename to code/thirdparty/libvorbis-1.3.7/lib/envelope.c diff --git a/code/libvorbis-1.3.7/lib/envelope.h b/code/thirdparty/libvorbis-1.3.7/lib/envelope.h similarity index 100% rename from code/libvorbis-1.3.7/lib/envelope.h rename to code/thirdparty/libvorbis-1.3.7/lib/envelope.h diff --git a/code/libvorbis-1.3.7/lib/floor0.c b/code/thirdparty/libvorbis-1.3.7/lib/floor0.c similarity index 100% rename from code/libvorbis-1.3.7/lib/floor0.c rename to code/thirdparty/libvorbis-1.3.7/lib/floor0.c diff --git a/code/libvorbis-1.3.7/lib/floor1.c b/code/thirdparty/libvorbis-1.3.7/lib/floor1.c similarity index 100% rename from code/libvorbis-1.3.7/lib/floor1.c rename to code/thirdparty/libvorbis-1.3.7/lib/floor1.c diff --git a/code/libvorbis-1.3.7/lib/highlevel.h b/code/thirdparty/libvorbis-1.3.7/lib/highlevel.h similarity index 100% rename from code/libvorbis-1.3.7/lib/highlevel.h rename to code/thirdparty/libvorbis-1.3.7/lib/highlevel.h diff --git a/code/libvorbis-1.3.7/lib/info.c b/code/thirdparty/libvorbis-1.3.7/lib/info.c similarity index 100% rename from code/libvorbis-1.3.7/lib/info.c rename to code/thirdparty/libvorbis-1.3.7/lib/info.c diff --git a/code/libvorbis-1.3.7/lib/lookup.c b/code/thirdparty/libvorbis-1.3.7/lib/lookup.c similarity index 100% rename from code/libvorbis-1.3.7/lib/lookup.c rename to code/thirdparty/libvorbis-1.3.7/lib/lookup.c diff --git a/code/libvorbis-1.3.7/lib/lookup.h b/code/thirdparty/libvorbis-1.3.7/lib/lookup.h similarity index 100% rename from code/libvorbis-1.3.7/lib/lookup.h rename to code/thirdparty/libvorbis-1.3.7/lib/lookup.h diff --git a/code/libvorbis-1.3.7/lib/lookup_data.h b/code/thirdparty/libvorbis-1.3.7/lib/lookup_data.h similarity index 100% rename from code/libvorbis-1.3.7/lib/lookup_data.h rename to code/thirdparty/libvorbis-1.3.7/lib/lookup_data.h diff --git a/code/libvorbis-1.3.7/lib/lpc.c b/code/thirdparty/libvorbis-1.3.7/lib/lpc.c similarity index 100% rename from code/libvorbis-1.3.7/lib/lpc.c rename to code/thirdparty/libvorbis-1.3.7/lib/lpc.c diff --git a/code/libvorbis-1.3.7/lib/lpc.h b/code/thirdparty/libvorbis-1.3.7/lib/lpc.h similarity index 100% rename from code/libvorbis-1.3.7/lib/lpc.h rename to code/thirdparty/libvorbis-1.3.7/lib/lpc.h diff --git a/code/libvorbis-1.3.7/lib/lsp.c b/code/thirdparty/libvorbis-1.3.7/lib/lsp.c similarity index 100% rename from code/libvorbis-1.3.7/lib/lsp.c rename to code/thirdparty/libvorbis-1.3.7/lib/lsp.c diff --git a/code/libvorbis-1.3.7/lib/lsp.h b/code/thirdparty/libvorbis-1.3.7/lib/lsp.h similarity index 100% rename from code/libvorbis-1.3.7/lib/lsp.h rename to code/thirdparty/libvorbis-1.3.7/lib/lsp.h diff --git a/code/libvorbis-1.3.7/lib/mapping0.c b/code/thirdparty/libvorbis-1.3.7/lib/mapping0.c similarity index 100% rename from code/libvorbis-1.3.7/lib/mapping0.c rename to code/thirdparty/libvorbis-1.3.7/lib/mapping0.c diff --git a/code/libvorbis-1.3.7/lib/masking.h b/code/thirdparty/libvorbis-1.3.7/lib/masking.h similarity index 100% rename from code/libvorbis-1.3.7/lib/masking.h rename to code/thirdparty/libvorbis-1.3.7/lib/masking.h diff --git a/code/libvorbis-1.3.7/lib/mdct.c b/code/thirdparty/libvorbis-1.3.7/lib/mdct.c similarity index 100% rename from code/libvorbis-1.3.7/lib/mdct.c rename to code/thirdparty/libvorbis-1.3.7/lib/mdct.c diff --git a/code/libvorbis-1.3.7/lib/mdct.h b/code/thirdparty/libvorbis-1.3.7/lib/mdct.h similarity index 100% rename from code/libvorbis-1.3.7/lib/mdct.h rename to code/thirdparty/libvorbis-1.3.7/lib/mdct.h diff --git a/code/libvorbis-1.3.7/lib/misc.h b/code/thirdparty/libvorbis-1.3.7/lib/misc.h similarity index 100% rename from code/libvorbis-1.3.7/lib/misc.h rename to code/thirdparty/libvorbis-1.3.7/lib/misc.h diff --git a/code/libvorbis-1.3.7/lib/modes/floor_all.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/floor_all.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/floor_all.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/floor_all.h diff --git a/code/libvorbis-1.3.7/lib/modes/psych_11.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/psych_11.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/psych_11.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/psych_11.h diff --git a/code/libvorbis-1.3.7/lib/modes/psych_16.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/psych_16.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/psych_16.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/psych_16.h diff --git a/code/libvorbis-1.3.7/lib/modes/psych_44.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/psych_44.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/psych_44.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/psych_44.h diff --git a/code/libvorbis-1.3.7/lib/modes/psych_8.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/psych_8.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/psych_8.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/psych_8.h diff --git a/code/libvorbis-1.3.7/lib/modes/residue_16.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/residue_16.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/residue_16.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/residue_16.h diff --git a/code/libvorbis-1.3.7/lib/modes/residue_44.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/residue_44.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/residue_44.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/residue_44.h diff --git a/code/libvorbis-1.3.7/lib/modes/residue_44p51.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/residue_44p51.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/residue_44p51.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/residue_44p51.h diff --git a/code/libvorbis-1.3.7/lib/modes/residue_44u.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/residue_44u.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/residue_44u.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/residue_44u.h diff --git a/code/libvorbis-1.3.7/lib/modes/residue_8.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/residue_8.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/residue_8.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/residue_8.h diff --git a/code/libvorbis-1.3.7/lib/modes/setup_11.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/setup_11.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/setup_11.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/setup_11.h diff --git a/code/libvorbis-1.3.7/lib/modes/setup_16.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/setup_16.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/setup_16.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/setup_16.h diff --git a/code/libvorbis-1.3.7/lib/modes/setup_22.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/setup_22.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/setup_22.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/setup_22.h diff --git a/code/libvorbis-1.3.7/lib/modes/setup_32.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/setup_32.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/setup_32.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/setup_32.h diff --git a/code/libvorbis-1.3.7/lib/modes/setup_44.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/setup_44.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/setup_44.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/setup_44.h diff --git a/code/libvorbis-1.3.7/lib/modes/setup_44p51.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/setup_44p51.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/setup_44p51.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/setup_44p51.h diff --git a/code/libvorbis-1.3.7/lib/modes/setup_44u.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/setup_44u.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/setup_44u.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/setup_44u.h diff --git a/code/libvorbis-1.3.7/lib/modes/setup_8.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/setup_8.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/setup_8.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/setup_8.h diff --git a/code/libvorbis-1.3.7/lib/modes/setup_X.h b/code/thirdparty/libvorbis-1.3.7/lib/modes/setup_X.h similarity index 100% rename from code/libvorbis-1.3.7/lib/modes/setup_X.h rename to code/thirdparty/libvorbis-1.3.7/lib/modes/setup_X.h diff --git a/code/libvorbis-1.3.7/lib/os.h b/code/thirdparty/libvorbis-1.3.7/lib/os.h similarity index 100% rename from code/libvorbis-1.3.7/lib/os.h rename to code/thirdparty/libvorbis-1.3.7/lib/os.h diff --git a/code/libvorbis-1.3.7/lib/psy.c b/code/thirdparty/libvorbis-1.3.7/lib/psy.c similarity index 100% rename from code/libvorbis-1.3.7/lib/psy.c rename to code/thirdparty/libvorbis-1.3.7/lib/psy.c diff --git a/code/libvorbis-1.3.7/lib/psy.h b/code/thirdparty/libvorbis-1.3.7/lib/psy.h similarity index 100% rename from code/libvorbis-1.3.7/lib/psy.h rename to code/thirdparty/libvorbis-1.3.7/lib/psy.h diff --git a/code/libvorbis-1.3.7/lib/registry.c b/code/thirdparty/libvorbis-1.3.7/lib/registry.c similarity index 100% rename from code/libvorbis-1.3.7/lib/registry.c rename to code/thirdparty/libvorbis-1.3.7/lib/registry.c diff --git a/code/libvorbis-1.3.7/lib/registry.h b/code/thirdparty/libvorbis-1.3.7/lib/registry.h similarity index 100% rename from code/libvorbis-1.3.7/lib/registry.h rename to code/thirdparty/libvorbis-1.3.7/lib/registry.h diff --git a/code/libvorbis-1.3.7/lib/res0.c b/code/thirdparty/libvorbis-1.3.7/lib/res0.c similarity index 100% rename from code/libvorbis-1.3.7/lib/res0.c rename to code/thirdparty/libvorbis-1.3.7/lib/res0.c diff --git a/code/libvorbis-1.3.7/lib/scales.h b/code/thirdparty/libvorbis-1.3.7/lib/scales.h similarity index 100% rename from code/libvorbis-1.3.7/lib/scales.h rename to code/thirdparty/libvorbis-1.3.7/lib/scales.h diff --git a/code/libvorbis-1.3.7/lib/sharedbook.c b/code/thirdparty/libvorbis-1.3.7/lib/sharedbook.c similarity index 100% rename from code/libvorbis-1.3.7/lib/sharedbook.c rename to code/thirdparty/libvorbis-1.3.7/lib/sharedbook.c diff --git a/code/libvorbis-1.3.7/lib/smallft.c b/code/thirdparty/libvorbis-1.3.7/lib/smallft.c similarity index 100% rename from code/libvorbis-1.3.7/lib/smallft.c rename to code/thirdparty/libvorbis-1.3.7/lib/smallft.c diff --git a/code/libvorbis-1.3.7/lib/smallft.h b/code/thirdparty/libvorbis-1.3.7/lib/smallft.h similarity index 100% rename from code/libvorbis-1.3.7/lib/smallft.h rename to code/thirdparty/libvorbis-1.3.7/lib/smallft.h diff --git a/code/libvorbis-1.3.7/lib/synthesis.c b/code/thirdparty/libvorbis-1.3.7/lib/synthesis.c similarity index 100% rename from code/libvorbis-1.3.7/lib/synthesis.c rename to code/thirdparty/libvorbis-1.3.7/lib/synthesis.c diff --git a/code/libvorbis-1.3.7/lib/vorbisenc.c b/code/thirdparty/libvorbis-1.3.7/lib/vorbisenc.c similarity index 100% rename from code/libvorbis-1.3.7/lib/vorbisenc.c rename to code/thirdparty/libvorbis-1.3.7/lib/vorbisenc.c diff --git a/code/libvorbis-1.3.7/lib/vorbisfile.c b/code/thirdparty/libvorbis-1.3.7/lib/vorbisfile.c similarity index 100% rename from code/libvorbis-1.3.7/lib/vorbisfile.c rename to code/thirdparty/libvorbis-1.3.7/lib/vorbisfile.c diff --git a/code/libvorbis-1.3.7/lib/window.c b/code/thirdparty/libvorbis-1.3.7/lib/window.c similarity index 100% rename from code/libvorbis-1.3.7/lib/window.c rename to code/thirdparty/libvorbis-1.3.7/lib/window.c diff --git a/code/libvorbis-1.3.7/lib/window.h b/code/thirdparty/libvorbis-1.3.7/lib/window.h similarity index 100% rename from code/libvorbis-1.3.7/lib/window.h rename to code/thirdparty/libvorbis-1.3.7/lib/window.h diff --git a/code/openal-soft-1.24.3/include/AL/al.h b/code/thirdparty/openal-soft-1.24.3/include/AL/al.h similarity index 100% rename from code/openal-soft-1.24.3/include/AL/al.h rename to code/thirdparty/openal-soft-1.24.3/include/AL/al.h diff --git a/code/openal-soft-1.24.3/include/AL/alc.h b/code/thirdparty/openal-soft-1.24.3/include/AL/alc.h similarity index 100% rename from code/openal-soft-1.24.3/include/AL/alc.h rename to code/thirdparty/openal-soft-1.24.3/include/AL/alc.h diff --git a/code/openal-soft-1.24.3/include/AL/alext.h b/code/thirdparty/openal-soft-1.24.3/include/AL/alext.h similarity index 100% rename from code/openal-soft-1.24.3/include/AL/alext.h rename to code/thirdparty/openal-soft-1.24.3/include/AL/alext.h diff --git a/code/openal-soft-1.24.3/include/AL/efx-creative.h b/code/thirdparty/openal-soft-1.24.3/include/AL/efx-creative.h similarity index 100% rename from code/openal-soft-1.24.3/include/AL/efx-creative.h rename to code/thirdparty/openal-soft-1.24.3/include/AL/efx-creative.h diff --git a/code/openal-soft-1.24.3/include/AL/efx-presets.h b/code/thirdparty/openal-soft-1.24.3/include/AL/efx-presets.h similarity index 100% rename from code/openal-soft-1.24.3/include/AL/efx-presets.h rename to code/thirdparty/openal-soft-1.24.3/include/AL/efx-presets.h diff --git a/code/openal-soft-1.24.3/include/AL/efx.h b/code/thirdparty/openal-soft-1.24.3/include/AL/efx.h similarity index 100% rename from code/openal-soft-1.24.3/include/AL/efx.h rename to code/thirdparty/openal-soft-1.24.3/include/AL/efx.h diff --git a/code/opus-1.5.2/celt/_kiss_fft_guts.h b/code/thirdparty/opus-1.5.2/celt/_kiss_fft_guts.h similarity index 100% rename from code/opus-1.5.2/celt/_kiss_fft_guts.h rename to code/thirdparty/opus-1.5.2/celt/_kiss_fft_guts.h diff --git a/code/opus-1.5.2/celt/arch.h b/code/thirdparty/opus-1.5.2/celt/arch.h similarity index 100% rename from code/opus-1.5.2/celt/arch.h rename to code/thirdparty/opus-1.5.2/celt/arch.h diff --git a/code/opus-1.5.2/celt/bands.c b/code/thirdparty/opus-1.5.2/celt/bands.c similarity index 100% rename from code/opus-1.5.2/celt/bands.c rename to code/thirdparty/opus-1.5.2/celt/bands.c diff --git a/code/opus-1.5.2/celt/bands.h b/code/thirdparty/opus-1.5.2/celt/bands.h similarity index 100% rename from code/opus-1.5.2/celt/bands.h rename to code/thirdparty/opus-1.5.2/celt/bands.h diff --git a/code/opus-1.5.2/celt/celt.c b/code/thirdparty/opus-1.5.2/celt/celt.c similarity index 100% rename from code/opus-1.5.2/celt/celt.c rename to code/thirdparty/opus-1.5.2/celt/celt.c diff --git a/code/opus-1.5.2/celt/celt.h b/code/thirdparty/opus-1.5.2/celt/celt.h similarity index 100% rename from code/opus-1.5.2/celt/celt.h rename to code/thirdparty/opus-1.5.2/celt/celt.h diff --git a/code/opus-1.5.2/celt/celt_decoder.c b/code/thirdparty/opus-1.5.2/celt/celt_decoder.c similarity index 100% rename from code/opus-1.5.2/celt/celt_decoder.c rename to code/thirdparty/opus-1.5.2/celt/celt_decoder.c diff --git a/code/opus-1.5.2/celt/celt_encoder.c b/code/thirdparty/opus-1.5.2/celt/celt_encoder.c similarity index 100% rename from code/opus-1.5.2/celt/celt_encoder.c rename to code/thirdparty/opus-1.5.2/celt/celt_encoder.c diff --git a/code/opus-1.5.2/celt/celt_lpc.c b/code/thirdparty/opus-1.5.2/celt/celt_lpc.c similarity index 100% rename from code/opus-1.5.2/celt/celt_lpc.c rename to code/thirdparty/opus-1.5.2/celt/celt_lpc.c diff --git a/code/opus-1.5.2/celt/celt_lpc.h b/code/thirdparty/opus-1.5.2/celt/celt_lpc.h similarity index 100% rename from code/opus-1.5.2/celt/celt_lpc.h rename to code/thirdparty/opus-1.5.2/celt/celt_lpc.h diff --git a/code/opus-1.5.2/celt/cpu_support.h b/code/thirdparty/opus-1.5.2/celt/cpu_support.h similarity index 100% rename from code/opus-1.5.2/celt/cpu_support.h rename to code/thirdparty/opus-1.5.2/celt/cpu_support.h diff --git a/code/opus-1.5.2/celt/cwrs.c b/code/thirdparty/opus-1.5.2/celt/cwrs.c similarity index 100% rename from code/opus-1.5.2/celt/cwrs.c rename to code/thirdparty/opus-1.5.2/celt/cwrs.c diff --git a/code/opus-1.5.2/celt/cwrs.h b/code/thirdparty/opus-1.5.2/celt/cwrs.h similarity index 100% rename from code/opus-1.5.2/celt/cwrs.h rename to code/thirdparty/opus-1.5.2/celt/cwrs.h diff --git a/code/opus-1.5.2/celt/ecintrin.h b/code/thirdparty/opus-1.5.2/celt/ecintrin.h similarity index 100% rename from code/opus-1.5.2/celt/ecintrin.h rename to code/thirdparty/opus-1.5.2/celt/ecintrin.h diff --git a/code/opus-1.5.2/celt/entcode.c b/code/thirdparty/opus-1.5.2/celt/entcode.c similarity index 100% rename from code/opus-1.5.2/celt/entcode.c rename to code/thirdparty/opus-1.5.2/celt/entcode.c diff --git a/code/opus-1.5.2/celt/entcode.h b/code/thirdparty/opus-1.5.2/celt/entcode.h similarity index 100% rename from code/opus-1.5.2/celt/entcode.h rename to code/thirdparty/opus-1.5.2/celt/entcode.h diff --git a/code/opus-1.5.2/celt/entdec.c b/code/thirdparty/opus-1.5.2/celt/entdec.c similarity index 100% rename from code/opus-1.5.2/celt/entdec.c rename to code/thirdparty/opus-1.5.2/celt/entdec.c diff --git a/code/opus-1.5.2/celt/entdec.h b/code/thirdparty/opus-1.5.2/celt/entdec.h similarity index 100% rename from code/opus-1.5.2/celt/entdec.h rename to code/thirdparty/opus-1.5.2/celt/entdec.h diff --git a/code/opus-1.5.2/celt/entenc.c b/code/thirdparty/opus-1.5.2/celt/entenc.c similarity index 100% rename from code/opus-1.5.2/celt/entenc.c rename to code/thirdparty/opus-1.5.2/celt/entenc.c diff --git a/code/opus-1.5.2/celt/entenc.h b/code/thirdparty/opus-1.5.2/celt/entenc.h similarity index 100% rename from code/opus-1.5.2/celt/entenc.h rename to code/thirdparty/opus-1.5.2/celt/entenc.h diff --git a/code/opus-1.5.2/celt/float_cast.h b/code/thirdparty/opus-1.5.2/celt/float_cast.h similarity index 100% rename from code/opus-1.5.2/celt/float_cast.h rename to code/thirdparty/opus-1.5.2/celt/float_cast.h diff --git a/code/opus-1.5.2/celt/kiss_fft.c b/code/thirdparty/opus-1.5.2/celt/kiss_fft.c similarity index 100% rename from code/opus-1.5.2/celt/kiss_fft.c rename to code/thirdparty/opus-1.5.2/celt/kiss_fft.c diff --git a/code/opus-1.5.2/celt/kiss_fft.h b/code/thirdparty/opus-1.5.2/celt/kiss_fft.h similarity index 100% rename from code/opus-1.5.2/celt/kiss_fft.h rename to code/thirdparty/opus-1.5.2/celt/kiss_fft.h diff --git a/code/opus-1.5.2/celt/laplace.c b/code/thirdparty/opus-1.5.2/celt/laplace.c similarity index 100% rename from code/opus-1.5.2/celt/laplace.c rename to code/thirdparty/opus-1.5.2/celt/laplace.c diff --git a/code/opus-1.5.2/celt/laplace.h b/code/thirdparty/opus-1.5.2/celt/laplace.h similarity index 100% rename from code/opus-1.5.2/celt/laplace.h rename to code/thirdparty/opus-1.5.2/celt/laplace.h diff --git a/code/opus-1.5.2/celt/mathops.c b/code/thirdparty/opus-1.5.2/celt/mathops.c similarity index 100% rename from code/opus-1.5.2/celt/mathops.c rename to code/thirdparty/opus-1.5.2/celt/mathops.c diff --git a/code/opus-1.5.2/celt/mathops.h b/code/thirdparty/opus-1.5.2/celt/mathops.h similarity index 100% rename from code/opus-1.5.2/celt/mathops.h rename to code/thirdparty/opus-1.5.2/celt/mathops.h diff --git a/code/opus-1.5.2/celt/mdct.c b/code/thirdparty/opus-1.5.2/celt/mdct.c similarity index 100% rename from code/opus-1.5.2/celt/mdct.c rename to code/thirdparty/opus-1.5.2/celt/mdct.c diff --git a/code/opus-1.5.2/celt/mdct.h b/code/thirdparty/opus-1.5.2/celt/mdct.h similarity index 100% rename from code/opus-1.5.2/celt/mdct.h rename to code/thirdparty/opus-1.5.2/celt/mdct.h diff --git a/code/opus-1.5.2/celt/mfrngcod.h b/code/thirdparty/opus-1.5.2/celt/mfrngcod.h similarity index 100% rename from code/opus-1.5.2/celt/mfrngcod.h rename to code/thirdparty/opus-1.5.2/celt/mfrngcod.h diff --git a/code/opus-1.5.2/celt/modes.c b/code/thirdparty/opus-1.5.2/celt/modes.c similarity index 100% rename from code/opus-1.5.2/celt/modes.c rename to code/thirdparty/opus-1.5.2/celt/modes.c diff --git a/code/opus-1.5.2/celt/modes.h b/code/thirdparty/opus-1.5.2/celt/modes.h similarity index 100% rename from code/opus-1.5.2/celt/modes.h rename to code/thirdparty/opus-1.5.2/celt/modes.h diff --git a/code/opus-1.5.2/celt/os_support.h b/code/thirdparty/opus-1.5.2/celt/os_support.h similarity index 100% rename from code/opus-1.5.2/celt/os_support.h rename to code/thirdparty/opus-1.5.2/celt/os_support.h diff --git a/code/opus-1.5.2/celt/pitch.c b/code/thirdparty/opus-1.5.2/celt/pitch.c similarity index 100% rename from code/opus-1.5.2/celt/pitch.c rename to code/thirdparty/opus-1.5.2/celt/pitch.c diff --git a/code/opus-1.5.2/celt/pitch.h b/code/thirdparty/opus-1.5.2/celt/pitch.h similarity index 100% rename from code/opus-1.5.2/celt/pitch.h rename to code/thirdparty/opus-1.5.2/celt/pitch.h diff --git a/code/opus-1.5.2/celt/quant_bands.c b/code/thirdparty/opus-1.5.2/celt/quant_bands.c similarity index 100% rename from code/opus-1.5.2/celt/quant_bands.c rename to code/thirdparty/opus-1.5.2/celt/quant_bands.c diff --git a/code/opus-1.5.2/celt/quant_bands.h b/code/thirdparty/opus-1.5.2/celt/quant_bands.h similarity index 100% rename from code/opus-1.5.2/celt/quant_bands.h rename to code/thirdparty/opus-1.5.2/celt/quant_bands.h diff --git a/code/opus-1.5.2/celt/rate.c b/code/thirdparty/opus-1.5.2/celt/rate.c similarity index 100% rename from code/opus-1.5.2/celt/rate.c rename to code/thirdparty/opus-1.5.2/celt/rate.c diff --git a/code/opus-1.5.2/celt/rate.h b/code/thirdparty/opus-1.5.2/celt/rate.h similarity index 100% rename from code/opus-1.5.2/celt/rate.h rename to code/thirdparty/opus-1.5.2/celt/rate.h diff --git a/code/opus-1.5.2/celt/stack_alloc.h b/code/thirdparty/opus-1.5.2/celt/stack_alloc.h similarity index 100% rename from code/opus-1.5.2/celt/stack_alloc.h rename to code/thirdparty/opus-1.5.2/celt/stack_alloc.h diff --git a/code/opus-1.5.2/celt/static_modes_float.h b/code/thirdparty/opus-1.5.2/celt/static_modes_float.h similarity index 100% rename from code/opus-1.5.2/celt/static_modes_float.h rename to code/thirdparty/opus-1.5.2/celt/static_modes_float.h diff --git a/code/opus-1.5.2/celt/vq.c b/code/thirdparty/opus-1.5.2/celt/vq.c similarity index 100% rename from code/opus-1.5.2/celt/vq.c rename to code/thirdparty/opus-1.5.2/celt/vq.c diff --git a/code/opus-1.5.2/celt/vq.h b/code/thirdparty/opus-1.5.2/celt/vq.h similarity index 100% rename from code/opus-1.5.2/celt/vq.h rename to code/thirdparty/opus-1.5.2/celt/vq.h diff --git a/code/opus-1.5.2/include/opus.h b/code/thirdparty/opus-1.5.2/include/opus.h similarity index 100% rename from code/opus-1.5.2/include/opus.h rename to code/thirdparty/opus-1.5.2/include/opus.h diff --git a/code/opus-1.5.2/include/opus_custom.h b/code/thirdparty/opus-1.5.2/include/opus_custom.h similarity index 100% rename from code/opus-1.5.2/include/opus_custom.h rename to code/thirdparty/opus-1.5.2/include/opus_custom.h diff --git a/code/opus-1.5.2/include/opus_defines.h b/code/thirdparty/opus-1.5.2/include/opus_defines.h similarity index 100% rename from code/opus-1.5.2/include/opus_defines.h rename to code/thirdparty/opus-1.5.2/include/opus_defines.h diff --git a/code/opus-1.5.2/include/opus_multistream.h b/code/thirdparty/opus-1.5.2/include/opus_multistream.h similarity index 100% rename from code/opus-1.5.2/include/opus_multistream.h rename to code/thirdparty/opus-1.5.2/include/opus_multistream.h diff --git a/code/opus-1.5.2/include/opus_projection.h b/code/thirdparty/opus-1.5.2/include/opus_projection.h similarity index 100% rename from code/opus-1.5.2/include/opus_projection.h rename to code/thirdparty/opus-1.5.2/include/opus_projection.h diff --git a/code/opus-1.5.2/include/opus_types.h b/code/thirdparty/opus-1.5.2/include/opus_types.h similarity index 100% rename from code/opus-1.5.2/include/opus_types.h rename to code/thirdparty/opus-1.5.2/include/opus_types.h diff --git a/code/opus-1.5.2/silk/A2NLSF.c b/code/thirdparty/opus-1.5.2/silk/A2NLSF.c similarity index 100% rename from code/opus-1.5.2/silk/A2NLSF.c rename to code/thirdparty/opus-1.5.2/silk/A2NLSF.c diff --git a/code/opus-1.5.2/silk/API.h b/code/thirdparty/opus-1.5.2/silk/API.h similarity index 100% rename from code/opus-1.5.2/silk/API.h rename to code/thirdparty/opus-1.5.2/silk/API.h diff --git a/code/opus-1.5.2/silk/CNG.c b/code/thirdparty/opus-1.5.2/silk/CNG.c similarity index 100% rename from code/opus-1.5.2/silk/CNG.c rename to code/thirdparty/opus-1.5.2/silk/CNG.c diff --git a/code/opus-1.5.2/silk/HP_variable_cutoff.c b/code/thirdparty/opus-1.5.2/silk/HP_variable_cutoff.c similarity index 100% rename from code/opus-1.5.2/silk/HP_variable_cutoff.c rename to code/thirdparty/opus-1.5.2/silk/HP_variable_cutoff.c diff --git a/code/opus-1.5.2/silk/Inlines.h b/code/thirdparty/opus-1.5.2/silk/Inlines.h similarity index 100% rename from code/opus-1.5.2/silk/Inlines.h rename to code/thirdparty/opus-1.5.2/silk/Inlines.h diff --git a/code/opus-1.5.2/silk/LPC_analysis_filter.c b/code/thirdparty/opus-1.5.2/silk/LPC_analysis_filter.c similarity index 100% rename from code/opus-1.5.2/silk/LPC_analysis_filter.c rename to code/thirdparty/opus-1.5.2/silk/LPC_analysis_filter.c diff --git a/code/opus-1.5.2/silk/LPC_fit.c b/code/thirdparty/opus-1.5.2/silk/LPC_fit.c similarity index 100% rename from code/opus-1.5.2/silk/LPC_fit.c rename to code/thirdparty/opus-1.5.2/silk/LPC_fit.c diff --git a/code/opus-1.5.2/silk/LPC_inv_pred_gain.c b/code/thirdparty/opus-1.5.2/silk/LPC_inv_pred_gain.c similarity index 100% rename from code/opus-1.5.2/silk/LPC_inv_pred_gain.c rename to code/thirdparty/opus-1.5.2/silk/LPC_inv_pred_gain.c diff --git a/code/opus-1.5.2/silk/LP_variable_cutoff.c b/code/thirdparty/opus-1.5.2/silk/LP_variable_cutoff.c similarity index 100% rename from code/opus-1.5.2/silk/LP_variable_cutoff.c rename to code/thirdparty/opus-1.5.2/silk/LP_variable_cutoff.c diff --git a/code/opus-1.5.2/silk/MacroCount.h b/code/thirdparty/opus-1.5.2/silk/MacroCount.h similarity index 100% rename from code/opus-1.5.2/silk/MacroCount.h rename to code/thirdparty/opus-1.5.2/silk/MacroCount.h diff --git a/code/opus-1.5.2/silk/MacroDebug.h b/code/thirdparty/opus-1.5.2/silk/MacroDebug.h similarity index 100% rename from code/opus-1.5.2/silk/MacroDebug.h rename to code/thirdparty/opus-1.5.2/silk/MacroDebug.h diff --git a/code/opus-1.5.2/silk/NLSF2A.c b/code/thirdparty/opus-1.5.2/silk/NLSF2A.c similarity index 100% rename from code/opus-1.5.2/silk/NLSF2A.c rename to code/thirdparty/opus-1.5.2/silk/NLSF2A.c diff --git a/code/opus-1.5.2/silk/NLSF_VQ.c b/code/thirdparty/opus-1.5.2/silk/NLSF_VQ.c similarity index 100% rename from code/opus-1.5.2/silk/NLSF_VQ.c rename to code/thirdparty/opus-1.5.2/silk/NLSF_VQ.c diff --git a/code/opus-1.5.2/silk/NLSF_VQ_weights_laroia.c b/code/thirdparty/opus-1.5.2/silk/NLSF_VQ_weights_laroia.c similarity index 100% rename from code/opus-1.5.2/silk/NLSF_VQ_weights_laroia.c rename to code/thirdparty/opus-1.5.2/silk/NLSF_VQ_weights_laroia.c diff --git a/code/opus-1.5.2/silk/NLSF_decode.c b/code/thirdparty/opus-1.5.2/silk/NLSF_decode.c similarity index 100% rename from code/opus-1.5.2/silk/NLSF_decode.c rename to code/thirdparty/opus-1.5.2/silk/NLSF_decode.c diff --git a/code/opus-1.5.2/silk/NLSF_del_dec_quant.c b/code/thirdparty/opus-1.5.2/silk/NLSF_del_dec_quant.c similarity index 100% rename from code/opus-1.5.2/silk/NLSF_del_dec_quant.c rename to code/thirdparty/opus-1.5.2/silk/NLSF_del_dec_quant.c diff --git a/code/opus-1.5.2/silk/NLSF_encode.c b/code/thirdparty/opus-1.5.2/silk/NLSF_encode.c similarity index 100% rename from code/opus-1.5.2/silk/NLSF_encode.c rename to code/thirdparty/opus-1.5.2/silk/NLSF_encode.c diff --git a/code/opus-1.5.2/silk/NLSF_stabilize.c b/code/thirdparty/opus-1.5.2/silk/NLSF_stabilize.c similarity index 100% rename from code/opus-1.5.2/silk/NLSF_stabilize.c rename to code/thirdparty/opus-1.5.2/silk/NLSF_stabilize.c diff --git a/code/opus-1.5.2/silk/NLSF_unpack.c b/code/thirdparty/opus-1.5.2/silk/NLSF_unpack.c similarity index 100% rename from code/opus-1.5.2/silk/NLSF_unpack.c rename to code/thirdparty/opus-1.5.2/silk/NLSF_unpack.c diff --git a/code/opus-1.5.2/silk/NSQ.c b/code/thirdparty/opus-1.5.2/silk/NSQ.c similarity index 100% rename from code/opus-1.5.2/silk/NSQ.c rename to code/thirdparty/opus-1.5.2/silk/NSQ.c diff --git a/code/opus-1.5.2/silk/NSQ.h b/code/thirdparty/opus-1.5.2/silk/NSQ.h similarity index 100% rename from code/opus-1.5.2/silk/NSQ.h rename to code/thirdparty/opus-1.5.2/silk/NSQ.h diff --git a/code/opus-1.5.2/silk/NSQ_del_dec.c b/code/thirdparty/opus-1.5.2/silk/NSQ_del_dec.c similarity index 100% rename from code/opus-1.5.2/silk/NSQ_del_dec.c rename to code/thirdparty/opus-1.5.2/silk/NSQ_del_dec.c diff --git a/code/opus-1.5.2/silk/PLC.c b/code/thirdparty/opus-1.5.2/silk/PLC.c similarity index 100% rename from code/opus-1.5.2/silk/PLC.c rename to code/thirdparty/opus-1.5.2/silk/PLC.c diff --git a/code/opus-1.5.2/silk/PLC.h b/code/thirdparty/opus-1.5.2/silk/PLC.h similarity index 100% rename from code/opus-1.5.2/silk/PLC.h rename to code/thirdparty/opus-1.5.2/silk/PLC.h diff --git a/code/opus-1.5.2/silk/SigProc_FIX.h b/code/thirdparty/opus-1.5.2/silk/SigProc_FIX.h similarity index 100% rename from code/opus-1.5.2/silk/SigProc_FIX.h rename to code/thirdparty/opus-1.5.2/silk/SigProc_FIX.h diff --git a/code/opus-1.5.2/silk/VAD.c b/code/thirdparty/opus-1.5.2/silk/VAD.c similarity index 100% rename from code/opus-1.5.2/silk/VAD.c rename to code/thirdparty/opus-1.5.2/silk/VAD.c diff --git a/code/opus-1.5.2/silk/VQ_WMat_EC.c b/code/thirdparty/opus-1.5.2/silk/VQ_WMat_EC.c similarity index 100% rename from code/opus-1.5.2/silk/VQ_WMat_EC.c rename to code/thirdparty/opus-1.5.2/silk/VQ_WMat_EC.c diff --git a/code/opus-1.5.2/silk/ana_filt_bank_1.c b/code/thirdparty/opus-1.5.2/silk/ana_filt_bank_1.c similarity index 100% rename from code/opus-1.5.2/silk/ana_filt_bank_1.c rename to code/thirdparty/opus-1.5.2/silk/ana_filt_bank_1.c diff --git a/code/opus-1.5.2/silk/biquad_alt.c b/code/thirdparty/opus-1.5.2/silk/biquad_alt.c similarity index 100% rename from code/opus-1.5.2/silk/biquad_alt.c rename to code/thirdparty/opus-1.5.2/silk/biquad_alt.c diff --git a/code/opus-1.5.2/silk/bwexpander.c b/code/thirdparty/opus-1.5.2/silk/bwexpander.c similarity index 100% rename from code/opus-1.5.2/silk/bwexpander.c rename to code/thirdparty/opus-1.5.2/silk/bwexpander.c diff --git a/code/opus-1.5.2/silk/bwexpander_32.c b/code/thirdparty/opus-1.5.2/silk/bwexpander_32.c similarity index 100% rename from code/opus-1.5.2/silk/bwexpander_32.c rename to code/thirdparty/opus-1.5.2/silk/bwexpander_32.c diff --git a/code/opus-1.5.2/silk/check_control_input.c b/code/thirdparty/opus-1.5.2/silk/check_control_input.c similarity index 100% rename from code/opus-1.5.2/silk/check_control_input.c rename to code/thirdparty/opus-1.5.2/silk/check_control_input.c diff --git a/code/opus-1.5.2/silk/code_signs.c b/code/thirdparty/opus-1.5.2/silk/code_signs.c similarity index 100% rename from code/opus-1.5.2/silk/code_signs.c rename to code/thirdparty/opus-1.5.2/silk/code_signs.c diff --git a/code/opus-1.5.2/silk/control.h b/code/thirdparty/opus-1.5.2/silk/control.h similarity index 100% rename from code/opus-1.5.2/silk/control.h rename to code/thirdparty/opus-1.5.2/silk/control.h diff --git a/code/opus-1.5.2/silk/control_SNR.c b/code/thirdparty/opus-1.5.2/silk/control_SNR.c similarity index 100% rename from code/opus-1.5.2/silk/control_SNR.c rename to code/thirdparty/opus-1.5.2/silk/control_SNR.c diff --git a/code/opus-1.5.2/silk/control_audio_bandwidth.c b/code/thirdparty/opus-1.5.2/silk/control_audio_bandwidth.c similarity index 100% rename from code/opus-1.5.2/silk/control_audio_bandwidth.c rename to code/thirdparty/opus-1.5.2/silk/control_audio_bandwidth.c diff --git a/code/opus-1.5.2/silk/control_codec.c b/code/thirdparty/opus-1.5.2/silk/control_codec.c similarity index 100% rename from code/opus-1.5.2/silk/control_codec.c rename to code/thirdparty/opus-1.5.2/silk/control_codec.c diff --git a/code/opus-1.5.2/silk/debug.c b/code/thirdparty/opus-1.5.2/silk/debug.c similarity index 100% rename from code/opus-1.5.2/silk/debug.c rename to code/thirdparty/opus-1.5.2/silk/debug.c diff --git a/code/opus-1.5.2/silk/debug.h b/code/thirdparty/opus-1.5.2/silk/debug.h similarity index 100% rename from code/opus-1.5.2/silk/debug.h rename to code/thirdparty/opus-1.5.2/silk/debug.h diff --git a/code/opus-1.5.2/silk/dec_API.c b/code/thirdparty/opus-1.5.2/silk/dec_API.c similarity index 100% rename from code/opus-1.5.2/silk/dec_API.c rename to code/thirdparty/opus-1.5.2/silk/dec_API.c diff --git a/code/opus-1.5.2/silk/decode_core.c b/code/thirdparty/opus-1.5.2/silk/decode_core.c similarity index 100% rename from code/opus-1.5.2/silk/decode_core.c rename to code/thirdparty/opus-1.5.2/silk/decode_core.c diff --git a/code/opus-1.5.2/silk/decode_frame.c b/code/thirdparty/opus-1.5.2/silk/decode_frame.c similarity index 100% rename from code/opus-1.5.2/silk/decode_frame.c rename to code/thirdparty/opus-1.5.2/silk/decode_frame.c diff --git a/code/opus-1.5.2/silk/decode_indices.c b/code/thirdparty/opus-1.5.2/silk/decode_indices.c similarity index 100% rename from code/opus-1.5.2/silk/decode_indices.c rename to code/thirdparty/opus-1.5.2/silk/decode_indices.c diff --git a/code/opus-1.5.2/silk/decode_parameters.c b/code/thirdparty/opus-1.5.2/silk/decode_parameters.c similarity index 100% rename from code/opus-1.5.2/silk/decode_parameters.c rename to code/thirdparty/opus-1.5.2/silk/decode_parameters.c diff --git a/code/opus-1.5.2/silk/decode_pitch.c b/code/thirdparty/opus-1.5.2/silk/decode_pitch.c similarity index 100% rename from code/opus-1.5.2/silk/decode_pitch.c rename to code/thirdparty/opus-1.5.2/silk/decode_pitch.c diff --git a/code/opus-1.5.2/silk/decode_pulses.c b/code/thirdparty/opus-1.5.2/silk/decode_pulses.c similarity index 100% rename from code/opus-1.5.2/silk/decode_pulses.c rename to code/thirdparty/opus-1.5.2/silk/decode_pulses.c diff --git a/code/opus-1.5.2/silk/decoder_set_fs.c b/code/thirdparty/opus-1.5.2/silk/decoder_set_fs.c similarity index 100% rename from code/opus-1.5.2/silk/decoder_set_fs.c rename to code/thirdparty/opus-1.5.2/silk/decoder_set_fs.c diff --git a/code/opus-1.5.2/silk/define.h b/code/thirdparty/opus-1.5.2/silk/define.h similarity index 100% rename from code/opus-1.5.2/silk/define.h rename to code/thirdparty/opus-1.5.2/silk/define.h diff --git a/code/opus-1.5.2/silk/enc_API.c b/code/thirdparty/opus-1.5.2/silk/enc_API.c similarity index 100% rename from code/opus-1.5.2/silk/enc_API.c rename to code/thirdparty/opus-1.5.2/silk/enc_API.c diff --git a/code/opus-1.5.2/silk/encode_indices.c b/code/thirdparty/opus-1.5.2/silk/encode_indices.c similarity index 100% rename from code/opus-1.5.2/silk/encode_indices.c rename to code/thirdparty/opus-1.5.2/silk/encode_indices.c diff --git a/code/opus-1.5.2/silk/encode_pulses.c b/code/thirdparty/opus-1.5.2/silk/encode_pulses.c similarity index 100% rename from code/opus-1.5.2/silk/encode_pulses.c rename to code/thirdparty/opus-1.5.2/silk/encode_pulses.c diff --git a/code/opus-1.5.2/silk/errors.h b/code/thirdparty/opus-1.5.2/silk/errors.h similarity index 100% rename from code/opus-1.5.2/silk/errors.h rename to code/thirdparty/opus-1.5.2/silk/errors.h diff --git a/code/opus-1.5.2/silk/float/LPC_analysis_filter_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/LPC_analysis_filter_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/LPC_analysis_filter_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/LPC_analysis_filter_FLP.c diff --git a/code/opus-1.5.2/silk/float/LPC_inv_pred_gain_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/LPC_inv_pred_gain_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/LPC_inv_pred_gain_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/LPC_inv_pred_gain_FLP.c diff --git a/code/opus-1.5.2/silk/float/LTP_analysis_filter_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/LTP_analysis_filter_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/LTP_analysis_filter_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/LTP_analysis_filter_FLP.c diff --git a/code/opus-1.5.2/silk/float/LTP_scale_ctrl_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/LTP_scale_ctrl_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/LTP_scale_ctrl_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/LTP_scale_ctrl_FLP.c diff --git a/code/opus-1.5.2/silk/float/SigProc_FLP.h b/code/thirdparty/opus-1.5.2/silk/float/SigProc_FLP.h similarity index 100% rename from code/opus-1.5.2/silk/float/SigProc_FLP.h rename to code/thirdparty/opus-1.5.2/silk/float/SigProc_FLP.h diff --git a/code/opus-1.5.2/silk/float/apply_sine_window_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/apply_sine_window_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/apply_sine_window_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/apply_sine_window_FLP.c diff --git a/code/opus-1.5.2/silk/float/autocorrelation_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/autocorrelation_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/autocorrelation_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/autocorrelation_FLP.c diff --git a/code/opus-1.5.2/silk/float/burg_modified_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/burg_modified_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/burg_modified_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/burg_modified_FLP.c diff --git a/code/opus-1.5.2/silk/float/bwexpander_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/bwexpander_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/bwexpander_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/bwexpander_FLP.c diff --git a/code/opus-1.5.2/silk/float/corrMatrix_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/corrMatrix_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/corrMatrix_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/corrMatrix_FLP.c diff --git a/code/opus-1.5.2/silk/float/encode_frame_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/encode_frame_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/encode_frame_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/encode_frame_FLP.c diff --git a/code/opus-1.5.2/silk/float/energy_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/energy_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/energy_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/energy_FLP.c diff --git a/code/opus-1.5.2/silk/float/find_LPC_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/find_LPC_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/find_LPC_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/find_LPC_FLP.c diff --git a/code/opus-1.5.2/silk/float/find_LTP_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/find_LTP_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/find_LTP_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/find_LTP_FLP.c diff --git a/code/opus-1.5.2/silk/float/find_pitch_lags_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/find_pitch_lags_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/find_pitch_lags_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/find_pitch_lags_FLP.c diff --git a/code/opus-1.5.2/silk/float/find_pred_coefs_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/find_pred_coefs_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/find_pred_coefs_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/find_pred_coefs_FLP.c diff --git a/code/opus-1.5.2/silk/float/inner_product_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/inner_product_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/inner_product_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/inner_product_FLP.c diff --git a/code/opus-1.5.2/silk/float/k2a_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/k2a_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/k2a_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/k2a_FLP.c diff --git a/code/opus-1.5.2/silk/float/main_FLP.h b/code/thirdparty/opus-1.5.2/silk/float/main_FLP.h similarity index 100% rename from code/opus-1.5.2/silk/float/main_FLP.h rename to code/thirdparty/opus-1.5.2/silk/float/main_FLP.h diff --git a/code/opus-1.5.2/silk/float/noise_shape_analysis_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/noise_shape_analysis_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/noise_shape_analysis_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/noise_shape_analysis_FLP.c diff --git a/code/opus-1.5.2/silk/float/pitch_analysis_core_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/pitch_analysis_core_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/pitch_analysis_core_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/pitch_analysis_core_FLP.c diff --git a/code/opus-1.5.2/silk/float/process_gains_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/process_gains_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/process_gains_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/process_gains_FLP.c diff --git a/code/opus-1.5.2/silk/float/regularize_correlations_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/regularize_correlations_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/regularize_correlations_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/regularize_correlations_FLP.c diff --git a/code/opus-1.5.2/silk/float/residual_energy_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/residual_energy_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/residual_energy_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/residual_energy_FLP.c diff --git a/code/opus-1.5.2/silk/float/scale_copy_vector_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/scale_copy_vector_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/scale_copy_vector_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/scale_copy_vector_FLP.c diff --git a/code/opus-1.5.2/silk/float/scale_vector_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/scale_vector_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/scale_vector_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/scale_vector_FLP.c diff --git a/code/opus-1.5.2/silk/float/schur_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/schur_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/schur_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/schur_FLP.c diff --git a/code/opus-1.5.2/silk/float/sort_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/sort_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/sort_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/sort_FLP.c diff --git a/code/opus-1.5.2/silk/float/structs_FLP.h b/code/thirdparty/opus-1.5.2/silk/float/structs_FLP.h similarity index 100% rename from code/opus-1.5.2/silk/float/structs_FLP.h rename to code/thirdparty/opus-1.5.2/silk/float/structs_FLP.h diff --git a/code/opus-1.5.2/silk/float/warped_autocorrelation_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/warped_autocorrelation_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/warped_autocorrelation_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/warped_autocorrelation_FLP.c diff --git a/code/opus-1.5.2/silk/float/wrappers_FLP.c b/code/thirdparty/opus-1.5.2/silk/float/wrappers_FLP.c similarity index 100% rename from code/opus-1.5.2/silk/float/wrappers_FLP.c rename to code/thirdparty/opus-1.5.2/silk/float/wrappers_FLP.c diff --git a/code/opus-1.5.2/silk/gain_quant.c b/code/thirdparty/opus-1.5.2/silk/gain_quant.c similarity index 100% rename from code/opus-1.5.2/silk/gain_quant.c rename to code/thirdparty/opus-1.5.2/silk/gain_quant.c diff --git a/code/opus-1.5.2/silk/init_decoder.c b/code/thirdparty/opus-1.5.2/silk/init_decoder.c similarity index 100% rename from code/opus-1.5.2/silk/init_decoder.c rename to code/thirdparty/opus-1.5.2/silk/init_decoder.c diff --git a/code/opus-1.5.2/silk/init_encoder.c b/code/thirdparty/opus-1.5.2/silk/init_encoder.c similarity index 100% rename from code/opus-1.5.2/silk/init_encoder.c rename to code/thirdparty/opus-1.5.2/silk/init_encoder.c diff --git a/code/opus-1.5.2/silk/inner_prod_aligned.c b/code/thirdparty/opus-1.5.2/silk/inner_prod_aligned.c similarity index 100% rename from code/opus-1.5.2/silk/inner_prod_aligned.c rename to code/thirdparty/opus-1.5.2/silk/inner_prod_aligned.c diff --git a/code/opus-1.5.2/silk/interpolate.c b/code/thirdparty/opus-1.5.2/silk/interpolate.c similarity index 100% rename from code/opus-1.5.2/silk/interpolate.c rename to code/thirdparty/opus-1.5.2/silk/interpolate.c diff --git a/code/opus-1.5.2/silk/lin2log.c b/code/thirdparty/opus-1.5.2/silk/lin2log.c similarity index 100% rename from code/opus-1.5.2/silk/lin2log.c rename to code/thirdparty/opus-1.5.2/silk/lin2log.c diff --git a/code/opus-1.5.2/silk/log2lin.c b/code/thirdparty/opus-1.5.2/silk/log2lin.c similarity index 100% rename from code/opus-1.5.2/silk/log2lin.c rename to code/thirdparty/opus-1.5.2/silk/log2lin.c diff --git a/code/opus-1.5.2/silk/macros.h b/code/thirdparty/opus-1.5.2/silk/macros.h similarity index 100% rename from code/opus-1.5.2/silk/macros.h rename to code/thirdparty/opus-1.5.2/silk/macros.h diff --git a/code/opus-1.5.2/silk/main.h b/code/thirdparty/opus-1.5.2/silk/main.h similarity index 100% rename from code/opus-1.5.2/silk/main.h rename to code/thirdparty/opus-1.5.2/silk/main.h diff --git a/code/opus-1.5.2/silk/pitch_est_defines.h b/code/thirdparty/opus-1.5.2/silk/pitch_est_defines.h similarity index 100% rename from code/opus-1.5.2/silk/pitch_est_defines.h rename to code/thirdparty/opus-1.5.2/silk/pitch_est_defines.h diff --git a/code/opus-1.5.2/silk/pitch_est_tables.c b/code/thirdparty/opus-1.5.2/silk/pitch_est_tables.c similarity index 100% rename from code/opus-1.5.2/silk/pitch_est_tables.c rename to code/thirdparty/opus-1.5.2/silk/pitch_est_tables.c diff --git a/code/opus-1.5.2/silk/process_NLSFs.c b/code/thirdparty/opus-1.5.2/silk/process_NLSFs.c similarity index 100% rename from code/opus-1.5.2/silk/process_NLSFs.c rename to code/thirdparty/opus-1.5.2/silk/process_NLSFs.c diff --git a/code/opus-1.5.2/silk/quant_LTP_gains.c b/code/thirdparty/opus-1.5.2/silk/quant_LTP_gains.c similarity index 100% rename from code/opus-1.5.2/silk/quant_LTP_gains.c rename to code/thirdparty/opus-1.5.2/silk/quant_LTP_gains.c diff --git a/code/opus-1.5.2/silk/resampler.c b/code/thirdparty/opus-1.5.2/silk/resampler.c similarity index 100% rename from code/opus-1.5.2/silk/resampler.c rename to code/thirdparty/opus-1.5.2/silk/resampler.c diff --git a/code/opus-1.5.2/silk/resampler_down2.c b/code/thirdparty/opus-1.5.2/silk/resampler_down2.c similarity index 100% rename from code/opus-1.5.2/silk/resampler_down2.c rename to code/thirdparty/opus-1.5.2/silk/resampler_down2.c diff --git a/code/opus-1.5.2/silk/resampler_down2_3.c b/code/thirdparty/opus-1.5.2/silk/resampler_down2_3.c similarity index 100% rename from code/opus-1.5.2/silk/resampler_down2_3.c rename to code/thirdparty/opus-1.5.2/silk/resampler_down2_3.c diff --git a/code/opus-1.5.2/silk/resampler_private.h b/code/thirdparty/opus-1.5.2/silk/resampler_private.h similarity index 100% rename from code/opus-1.5.2/silk/resampler_private.h rename to code/thirdparty/opus-1.5.2/silk/resampler_private.h diff --git a/code/opus-1.5.2/silk/resampler_private_AR2.c b/code/thirdparty/opus-1.5.2/silk/resampler_private_AR2.c similarity index 100% rename from code/opus-1.5.2/silk/resampler_private_AR2.c rename to code/thirdparty/opus-1.5.2/silk/resampler_private_AR2.c diff --git a/code/opus-1.5.2/silk/resampler_private_IIR_FIR.c b/code/thirdparty/opus-1.5.2/silk/resampler_private_IIR_FIR.c similarity index 100% rename from code/opus-1.5.2/silk/resampler_private_IIR_FIR.c rename to code/thirdparty/opus-1.5.2/silk/resampler_private_IIR_FIR.c diff --git a/code/opus-1.5.2/silk/resampler_private_down_FIR.c b/code/thirdparty/opus-1.5.2/silk/resampler_private_down_FIR.c similarity index 100% rename from code/opus-1.5.2/silk/resampler_private_down_FIR.c rename to code/thirdparty/opus-1.5.2/silk/resampler_private_down_FIR.c diff --git a/code/opus-1.5.2/silk/resampler_private_up2_HQ.c b/code/thirdparty/opus-1.5.2/silk/resampler_private_up2_HQ.c similarity index 100% rename from code/opus-1.5.2/silk/resampler_private_up2_HQ.c rename to code/thirdparty/opus-1.5.2/silk/resampler_private_up2_HQ.c diff --git a/code/opus-1.5.2/silk/resampler_rom.c b/code/thirdparty/opus-1.5.2/silk/resampler_rom.c similarity index 100% rename from code/opus-1.5.2/silk/resampler_rom.c rename to code/thirdparty/opus-1.5.2/silk/resampler_rom.c diff --git a/code/opus-1.5.2/silk/resampler_rom.h b/code/thirdparty/opus-1.5.2/silk/resampler_rom.h similarity index 100% rename from code/opus-1.5.2/silk/resampler_rom.h rename to code/thirdparty/opus-1.5.2/silk/resampler_rom.h diff --git a/code/opus-1.5.2/silk/resampler_structs.h b/code/thirdparty/opus-1.5.2/silk/resampler_structs.h similarity index 100% rename from code/opus-1.5.2/silk/resampler_structs.h rename to code/thirdparty/opus-1.5.2/silk/resampler_structs.h diff --git a/code/opus-1.5.2/silk/shell_coder.c b/code/thirdparty/opus-1.5.2/silk/shell_coder.c similarity index 100% rename from code/opus-1.5.2/silk/shell_coder.c rename to code/thirdparty/opus-1.5.2/silk/shell_coder.c diff --git a/code/opus-1.5.2/silk/sigm_Q15.c b/code/thirdparty/opus-1.5.2/silk/sigm_Q15.c similarity index 100% rename from code/opus-1.5.2/silk/sigm_Q15.c rename to code/thirdparty/opus-1.5.2/silk/sigm_Q15.c diff --git a/code/opus-1.5.2/silk/sort.c b/code/thirdparty/opus-1.5.2/silk/sort.c similarity index 100% rename from code/opus-1.5.2/silk/sort.c rename to code/thirdparty/opus-1.5.2/silk/sort.c diff --git a/code/opus-1.5.2/silk/stereo_LR_to_MS.c b/code/thirdparty/opus-1.5.2/silk/stereo_LR_to_MS.c similarity index 100% rename from code/opus-1.5.2/silk/stereo_LR_to_MS.c rename to code/thirdparty/opus-1.5.2/silk/stereo_LR_to_MS.c diff --git a/code/opus-1.5.2/silk/stereo_MS_to_LR.c b/code/thirdparty/opus-1.5.2/silk/stereo_MS_to_LR.c similarity index 100% rename from code/opus-1.5.2/silk/stereo_MS_to_LR.c rename to code/thirdparty/opus-1.5.2/silk/stereo_MS_to_LR.c diff --git a/code/opus-1.5.2/silk/stereo_decode_pred.c b/code/thirdparty/opus-1.5.2/silk/stereo_decode_pred.c similarity index 100% rename from code/opus-1.5.2/silk/stereo_decode_pred.c rename to code/thirdparty/opus-1.5.2/silk/stereo_decode_pred.c diff --git a/code/opus-1.5.2/silk/stereo_encode_pred.c b/code/thirdparty/opus-1.5.2/silk/stereo_encode_pred.c similarity index 100% rename from code/opus-1.5.2/silk/stereo_encode_pred.c rename to code/thirdparty/opus-1.5.2/silk/stereo_encode_pred.c diff --git a/code/opus-1.5.2/silk/stereo_find_predictor.c b/code/thirdparty/opus-1.5.2/silk/stereo_find_predictor.c similarity index 100% rename from code/opus-1.5.2/silk/stereo_find_predictor.c rename to code/thirdparty/opus-1.5.2/silk/stereo_find_predictor.c diff --git a/code/opus-1.5.2/silk/stereo_quant_pred.c b/code/thirdparty/opus-1.5.2/silk/stereo_quant_pred.c similarity index 100% rename from code/opus-1.5.2/silk/stereo_quant_pred.c rename to code/thirdparty/opus-1.5.2/silk/stereo_quant_pred.c diff --git a/code/opus-1.5.2/silk/structs.h b/code/thirdparty/opus-1.5.2/silk/structs.h similarity index 100% rename from code/opus-1.5.2/silk/structs.h rename to code/thirdparty/opus-1.5.2/silk/structs.h diff --git a/code/opus-1.5.2/silk/sum_sqr_shift.c b/code/thirdparty/opus-1.5.2/silk/sum_sqr_shift.c similarity index 100% rename from code/opus-1.5.2/silk/sum_sqr_shift.c rename to code/thirdparty/opus-1.5.2/silk/sum_sqr_shift.c diff --git a/code/opus-1.5.2/silk/table_LSF_cos.c b/code/thirdparty/opus-1.5.2/silk/table_LSF_cos.c similarity index 100% rename from code/opus-1.5.2/silk/table_LSF_cos.c rename to code/thirdparty/opus-1.5.2/silk/table_LSF_cos.c diff --git a/code/opus-1.5.2/silk/tables.h b/code/thirdparty/opus-1.5.2/silk/tables.h similarity index 100% rename from code/opus-1.5.2/silk/tables.h rename to code/thirdparty/opus-1.5.2/silk/tables.h diff --git a/code/opus-1.5.2/silk/tables_LTP.c b/code/thirdparty/opus-1.5.2/silk/tables_LTP.c similarity index 100% rename from code/opus-1.5.2/silk/tables_LTP.c rename to code/thirdparty/opus-1.5.2/silk/tables_LTP.c diff --git a/code/opus-1.5.2/silk/tables_NLSF_CB_NB_MB.c b/code/thirdparty/opus-1.5.2/silk/tables_NLSF_CB_NB_MB.c similarity index 100% rename from code/opus-1.5.2/silk/tables_NLSF_CB_NB_MB.c rename to code/thirdparty/opus-1.5.2/silk/tables_NLSF_CB_NB_MB.c diff --git a/code/opus-1.5.2/silk/tables_NLSF_CB_WB.c b/code/thirdparty/opus-1.5.2/silk/tables_NLSF_CB_WB.c similarity index 100% rename from code/opus-1.5.2/silk/tables_NLSF_CB_WB.c rename to code/thirdparty/opus-1.5.2/silk/tables_NLSF_CB_WB.c diff --git a/code/opus-1.5.2/silk/tables_gain.c b/code/thirdparty/opus-1.5.2/silk/tables_gain.c similarity index 100% rename from code/opus-1.5.2/silk/tables_gain.c rename to code/thirdparty/opus-1.5.2/silk/tables_gain.c diff --git a/code/opus-1.5.2/silk/tables_other.c b/code/thirdparty/opus-1.5.2/silk/tables_other.c similarity index 100% rename from code/opus-1.5.2/silk/tables_other.c rename to code/thirdparty/opus-1.5.2/silk/tables_other.c diff --git a/code/opus-1.5.2/silk/tables_pitch_lag.c b/code/thirdparty/opus-1.5.2/silk/tables_pitch_lag.c similarity index 100% rename from code/opus-1.5.2/silk/tables_pitch_lag.c rename to code/thirdparty/opus-1.5.2/silk/tables_pitch_lag.c diff --git a/code/opus-1.5.2/silk/tables_pulses_per_block.c b/code/thirdparty/opus-1.5.2/silk/tables_pulses_per_block.c similarity index 100% rename from code/opus-1.5.2/silk/tables_pulses_per_block.c rename to code/thirdparty/opus-1.5.2/silk/tables_pulses_per_block.c diff --git a/code/opus-1.5.2/silk/tuning_parameters.h b/code/thirdparty/opus-1.5.2/silk/tuning_parameters.h similarity index 100% rename from code/opus-1.5.2/silk/tuning_parameters.h rename to code/thirdparty/opus-1.5.2/silk/tuning_parameters.h diff --git a/code/opus-1.5.2/silk/typedef.h b/code/thirdparty/opus-1.5.2/silk/typedef.h similarity index 100% rename from code/opus-1.5.2/silk/typedef.h rename to code/thirdparty/opus-1.5.2/silk/typedef.h diff --git a/code/opus-1.5.2/src/analysis.c b/code/thirdparty/opus-1.5.2/src/analysis.c similarity index 100% rename from code/opus-1.5.2/src/analysis.c rename to code/thirdparty/opus-1.5.2/src/analysis.c diff --git a/code/opus-1.5.2/src/analysis.h b/code/thirdparty/opus-1.5.2/src/analysis.h similarity index 100% rename from code/opus-1.5.2/src/analysis.h rename to code/thirdparty/opus-1.5.2/src/analysis.h diff --git a/code/opus-1.5.2/src/extensions.c b/code/thirdparty/opus-1.5.2/src/extensions.c similarity index 100% rename from code/opus-1.5.2/src/extensions.c rename to code/thirdparty/opus-1.5.2/src/extensions.c diff --git a/code/opus-1.5.2/src/mapping_matrix.c b/code/thirdparty/opus-1.5.2/src/mapping_matrix.c similarity index 100% rename from code/opus-1.5.2/src/mapping_matrix.c rename to code/thirdparty/opus-1.5.2/src/mapping_matrix.c diff --git a/code/opus-1.5.2/src/mapping_matrix.h b/code/thirdparty/opus-1.5.2/src/mapping_matrix.h similarity index 100% rename from code/opus-1.5.2/src/mapping_matrix.h rename to code/thirdparty/opus-1.5.2/src/mapping_matrix.h diff --git a/code/opus-1.5.2/src/mlp.c b/code/thirdparty/opus-1.5.2/src/mlp.c similarity index 100% rename from code/opus-1.5.2/src/mlp.c rename to code/thirdparty/opus-1.5.2/src/mlp.c diff --git a/code/opus-1.5.2/src/mlp.h b/code/thirdparty/opus-1.5.2/src/mlp.h similarity index 100% rename from code/opus-1.5.2/src/mlp.h rename to code/thirdparty/opus-1.5.2/src/mlp.h diff --git a/code/opus-1.5.2/src/mlp_data.c b/code/thirdparty/opus-1.5.2/src/mlp_data.c similarity index 100% rename from code/opus-1.5.2/src/mlp_data.c rename to code/thirdparty/opus-1.5.2/src/mlp_data.c diff --git a/code/opus-1.5.2/src/opus.c b/code/thirdparty/opus-1.5.2/src/opus.c similarity index 100% rename from code/opus-1.5.2/src/opus.c rename to code/thirdparty/opus-1.5.2/src/opus.c diff --git a/code/opus-1.5.2/src/opus_decoder.c b/code/thirdparty/opus-1.5.2/src/opus_decoder.c similarity index 100% rename from code/opus-1.5.2/src/opus_decoder.c rename to code/thirdparty/opus-1.5.2/src/opus_decoder.c diff --git a/code/opus-1.5.2/src/opus_encoder.c b/code/thirdparty/opus-1.5.2/src/opus_encoder.c similarity index 100% rename from code/opus-1.5.2/src/opus_encoder.c rename to code/thirdparty/opus-1.5.2/src/opus_encoder.c diff --git a/code/opus-1.5.2/src/opus_multistream.c b/code/thirdparty/opus-1.5.2/src/opus_multistream.c similarity index 100% rename from code/opus-1.5.2/src/opus_multistream.c rename to code/thirdparty/opus-1.5.2/src/opus_multistream.c diff --git a/code/opus-1.5.2/src/opus_multistream_decoder.c b/code/thirdparty/opus-1.5.2/src/opus_multistream_decoder.c similarity index 100% rename from code/opus-1.5.2/src/opus_multistream_decoder.c rename to code/thirdparty/opus-1.5.2/src/opus_multistream_decoder.c diff --git a/code/opus-1.5.2/src/opus_multistream_encoder.c b/code/thirdparty/opus-1.5.2/src/opus_multistream_encoder.c similarity index 100% rename from code/opus-1.5.2/src/opus_multistream_encoder.c rename to code/thirdparty/opus-1.5.2/src/opus_multistream_encoder.c diff --git a/code/opus-1.5.2/src/opus_private.h b/code/thirdparty/opus-1.5.2/src/opus_private.h similarity index 100% rename from code/opus-1.5.2/src/opus_private.h rename to code/thirdparty/opus-1.5.2/src/opus_private.h diff --git a/code/opus-1.5.2/src/opus_projection_decoder.c b/code/thirdparty/opus-1.5.2/src/opus_projection_decoder.c similarity index 100% rename from code/opus-1.5.2/src/opus_projection_decoder.c rename to code/thirdparty/opus-1.5.2/src/opus_projection_decoder.c diff --git a/code/opus-1.5.2/src/opus_projection_encoder.c b/code/thirdparty/opus-1.5.2/src/opus_projection_encoder.c similarity index 100% rename from code/opus-1.5.2/src/opus_projection_encoder.c rename to code/thirdparty/opus-1.5.2/src/opus_projection_encoder.c diff --git a/code/opus-1.5.2/src/repacketizer.c b/code/thirdparty/opus-1.5.2/src/repacketizer.c similarity index 100% rename from code/opus-1.5.2/src/repacketizer.c rename to code/thirdparty/opus-1.5.2/src/repacketizer.c diff --git a/code/opusfile-0.12/include/opusfile.h b/code/thirdparty/opusfile-0.12/include/opusfile.h similarity index 100% rename from code/opusfile-0.12/include/opusfile.h rename to code/thirdparty/opusfile-0.12/include/opusfile.h diff --git a/code/opusfile-0.12/src/http.c b/code/thirdparty/opusfile-0.12/src/http.c similarity index 100% rename from code/opusfile-0.12/src/http.c rename to code/thirdparty/opusfile-0.12/src/http.c diff --git a/code/opusfile-0.12/src/info.c b/code/thirdparty/opusfile-0.12/src/info.c similarity index 100% rename from code/opusfile-0.12/src/info.c rename to code/thirdparty/opusfile-0.12/src/info.c diff --git a/code/opusfile-0.12/src/internal.c b/code/thirdparty/opusfile-0.12/src/internal.c similarity index 100% rename from code/opusfile-0.12/src/internal.c rename to code/thirdparty/opusfile-0.12/src/internal.c diff --git a/code/opusfile-0.12/src/internal.h b/code/thirdparty/opusfile-0.12/src/internal.h similarity index 100% rename from code/opusfile-0.12/src/internal.h rename to code/thirdparty/opusfile-0.12/src/internal.h diff --git a/code/opusfile-0.12/src/opusfile.c b/code/thirdparty/opusfile-0.12/src/opusfile.c similarity index 100% rename from code/opusfile-0.12/src/opusfile.c rename to code/thirdparty/opusfile-0.12/src/opusfile.c diff --git a/code/opusfile-0.12/src/stream.c b/code/thirdparty/opusfile-0.12/src/stream.c similarity index 100% rename from code/opusfile-0.12/src/stream.c rename to code/thirdparty/opusfile-0.12/src/stream.c diff --git a/code/opusfile-0.12/src/wincerts.c b/code/thirdparty/opusfile-0.12/src/wincerts.c similarity index 100% rename from code/opusfile-0.12/src/wincerts.c rename to code/thirdparty/opusfile-0.12/src/wincerts.c diff --git a/code/opusfile-0.12/src/winerrno.h b/code/thirdparty/opusfile-0.12/src/winerrno.h similarity index 100% rename from code/opusfile-0.12/src/winerrno.h rename to code/thirdparty/opusfile-0.12/src/winerrno.h diff --git a/code/recastnavigation/.editorconfig b/code/thirdparty/recastnavigation/.editorconfig similarity index 100% rename from code/recastnavigation/.editorconfig rename to code/thirdparty/recastnavigation/.editorconfig diff --git a/code/recastnavigation/.github/workflows/Build.yaml b/code/thirdparty/recastnavigation/.github/workflows/Build.yaml similarity index 100% rename from code/recastnavigation/.github/workflows/Build.yaml rename to code/thirdparty/recastnavigation/.github/workflows/Build.yaml diff --git a/code/recastnavigation/.github/workflows/Docs.yaml b/code/thirdparty/recastnavigation/.github/workflows/Docs.yaml similarity index 100% rename from code/recastnavigation/.github/workflows/Docs.yaml rename to code/thirdparty/recastnavigation/.github/workflows/Docs.yaml diff --git a/code/recastnavigation/.github/workflows/Tests.yaml b/code/thirdparty/recastnavigation/.github/workflows/Tests.yaml similarity index 100% rename from code/recastnavigation/.github/workflows/Tests.yaml rename to code/thirdparty/recastnavigation/.github/workflows/Tests.yaml diff --git a/code/recastnavigation/.gitignore b/code/thirdparty/recastnavigation/.gitignore similarity index 100% rename from code/recastnavigation/.gitignore rename to code/thirdparty/recastnavigation/.gitignore diff --git a/code/recastnavigation/CHANGELOG.md b/code/thirdparty/recastnavigation/CHANGELOG.md similarity index 100% rename from code/recastnavigation/CHANGELOG.md rename to code/thirdparty/recastnavigation/CHANGELOG.md diff --git a/code/recastnavigation/CMakeLists.txt b/code/thirdparty/recastnavigation/CMakeLists.txt similarity index 100% rename from code/recastnavigation/CMakeLists.txt rename to code/thirdparty/recastnavigation/CMakeLists.txt diff --git a/code/recastnavigation/CODE_OF_CONDUCT.md b/code/thirdparty/recastnavigation/CODE_OF_CONDUCT.md similarity index 100% rename from code/recastnavigation/CODE_OF_CONDUCT.md rename to code/thirdparty/recastnavigation/CODE_OF_CONDUCT.md diff --git a/code/recastnavigation/CONTRIBUTING.md b/code/thirdparty/recastnavigation/CONTRIBUTING.md similarity index 100% rename from code/recastnavigation/CONTRIBUTING.md rename to code/thirdparty/recastnavigation/CONTRIBUTING.md diff --git a/code/recastnavigation/DebugUtils/CMakeLists.txt b/code/thirdparty/recastnavigation/DebugUtils/CMakeLists.txt similarity index 100% rename from code/recastnavigation/DebugUtils/CMakeLists.txt rename to code/thirdparty/recastnavigation/DebugUtils/CMakeLists.txt diff --git a/code/recastnavigation/DebugUtils/Include/DebugDraw.h b/code/thirdparty/recastnavigation/DebugUtils/Include/DebugDraw.h similarity index 100% rename from code/recastnavigation/DebugUtils/Include/DebugDraw.h rename to code/thirdparty/recastnavigation/DebugUtils/Include/DebugDraw.h diff --git a/code/recastnavigation/DebugUtils/Include/DetourDebugDraw.h b/code/thirdparty/recastnavigation/DebugUtils/Include/DetourDebugDraw.h similarity index 100% rename from code/recastnavigation/DebugUtils/Include/DetourDebugDraw.h rename to code/thirdparty/recastnavigation/DebugUtils/Include/DetourDebugDraw.h diff --git a/code/recastnavigation/DebugUtils/Include/RecastDebugDraw.h b/code/thirdparty/recastnavigation/DebugUtils/Include/RecastDebugDraw.h similarity index 100% rename from code/recastnavigation/DebugUtils/Include/RecastDebugDraw.h rename to code/thirdparty/recastnavigation/DebugUtils/Include/RecastDebugDraw.h diff --git a/code/recastnavigation/DebugUtils/Include/RecastDump.h b/code/thirdparty/recastnavigation/DebugUtils/Include/RecastDump.h similarity index 100% rename from code/recastnavigation/DebugUtils/Include/RecastDump.h rename to code/thirdparty/recastnavigation/DebugUtils/Include/RecastDump.h diff --git a/code/recastnavigation/DebugUtils/Source/DebugDraw.cpp b/code/thirdparty/recastnavigation/DebugUtils/Source/DebugDraw.cpp similarity index 100% rename from code/recastnavigation/DebugUtils/Source/DebugDraw.cpp rename to code/thirdparty/recastnavigation/DebugUtils/Source/DebugDraw.cpp diff --git a/code/recastnavigation/DebugUtils/Source/DetourDebugDraw.cpp b/code/thirdparty/recastnavigation/DebugUtils/Source/DetourDebugDraw.cpp similarity index 100% rename from code/recastnavigation/DebugUtils/Source/DetourDebugDraw.cpp rename to code/thirdparty/recastnavigation/DebugUtils/Source/DetourDebugDraw.cpp diff --git a/code/recastnavigation/DebugUtils/Source/RecastDebugDraw.cpp b/code/thirdparty/recastnavigation/DebugUtils/Source/RecastDebugDraw.cpp similarity index 100% rename from code/recastnavigation/DebugUtils/Source/RecastDebugDraw.cpp rename to code/thirdparty/recastnavigation/DebugUtils/Source/RecastDebugDraw.cpp diff --git a/code/recastnavigation/DebugUtils/Source/RecastDump.cpp b/code/thirdparty/recastnavigation/DebugUtils/Source/RecastDump.cpp similarity index 100% rename from code/recastnavigation/DebugUtils/Source/RecastDump.cpp rename to code/thirdparty/recastnavigation/DebugUtils/Source/RecastDump.cpp diff --git a/code/recastnavigation/Detour/CMakeLists.txt b/code/thirdparty/recastnavigation/Detour/CMakeLists.txt similarity index 100% rename from code/recastnavigation/Detour/CMakeLists.txt rename to code/thirdparty/recastnavigation/Detour/CMakeLists.txt diff --git a/code/recastnavigation/Detour/Include/DetourAlloc.h b/code/thirdparty/recastnavigation/Detour/Include/DetourAlloc.h similarity index 100% rename from code/recastnavigation/Detour/Include/DetourAlloc.h rename to code/thirdparty/recastnavigation/Detour/Include/DetourAlloc.h diff --git a/code/recastnavigation/Detour/Include/DetourAssert.h b/code/thirdparty/recastnavigation/Detour/Include/DetourAssert.h similarity index 100% rename from code/recastnavigation/Detour/Include/DetourAssert.h rename to code/thirdparty/recastnavigation/Detour/Include/DetourAssert.h diff --git a/code/recastnavigation/Detour/Include/DetourCommon.h b/code/thirdparty/recastnavigation/Detour/Include/DetourCommon.h similarity index 100% rename from code/recastnavigation/Detour/Include/DetourCommon.h rename to code/thirdparty/recastnavigation/Detour/Include/DetourCommon.h diff --git a/code/recastnavigation/Detour/Include/DetourMath.h b/code/thirdparty/recastnavigation/Detour/Include/DetourMath.h similarity index 100% rename from code/recastnavigation/Detour/Include/DetourMath.h rename to code/thirdparty/recastnavigation/Detour/Include/DetourMath.h diff --git a/code/recastnavigation/Detour/Include/DetourNavMesh.h b/code/thirdparty/recastnavigation/Detour/Include/DetourNavMesh.h similarity index 100% rename from code/recastnavigation/Detour/Include/DetourNavMesh.h rename to code/thirdparty/recastnavigation/Detour/Include/DetourNavMesh.h diff --git a/code/recastnavigation/Detour/Include/DetourNavMeshBuilder.h b/code/thirdparty/recastnavigation/Detour/Include/DetourNavMeshBuilder.h similarity index 100% rename from code/recastnavigation/Detour/Include/DetourNavMeshBuilder.h rename to code/thirdparty/recastnavigation/Detour/Include/DetourNavMeshBuilder.h diff --git a/code/recastnavigation/Detour/Include/DetourNavMeshQuery.h b/code/thirdparty/recastnavigation/Detour/Include/DetourNavMeshQuery.h similarity index 100% rename from code/recastnavigation/Detour/Include/DetourNavMeshQuery.h rename to code/thirdparty/recastnavigation/Detour/Include/DetourNavMeshQuery.h diff --git a/code/recastnavigation/Detour/Include/DetourNode.h b/code/thirdparty/recastnavigation/Detour/Include/DetourNode.h similarity index 100% rename from code/recastnavigation/Detour/Include/DetourNode.h rename to code/thirdparty/recastnavigation/Detour/Include/DetourNode.h diff --git a/code/recastnavigation/Detour/Include/DetourStatus.h b/code/thirdparty/recastnavigation/Detour/Include/DetourStatus.h similarity index 100% rename from code/recastnavigation/Detour/Include/DetourStatus.h rename to code/thirdparty/recastnavigation/Detour/Include/DetourStatus.h diff --git a/code/recastnavigation/Detour/Source/DetourAlloc.cpp b/code/thirdparty/recastnavigation/Detour/Source/DetourAlloc.cpp similarity index 100% rename from code/recastnavigation/Detour/Source/DetourAlloc.cpp rename to code/thirdparty/recastnavigation/Detour/Source/DetourAlloc.cpp diff --git a/code/recastnavigation/Detour/Source/DetourAssert.cpp b/code/thirdparty/recastnavigation/Detour/Source/DetourAssert.cpp similarity index 100% rename from code/recastnavigation/Detour/Source/DetourAssert.cpp rename to code/thirdparty/recastnavigation/Detour/Source/DetourAssert.cpp diff --git a/code/recastnavigation/Detour/Source/DetourCommon.cpp b/code/thirdparty/recastnavigation/Detour/Source/DetourCommon.cpp similarity index 100% rename from code/recastnavigation/Detour/Source/DetourCommon.cpp rename to code/thirdparty/recastnavigation/Detour/Source/DetourCommon.cpp diff --git a/code/recastnavigation/Detour/Source/DetourNavMesh.cpp b/code/thirdparty/recastnavigation/Detour/Source/DetourNavMesh.cpp similarity index 100% rename from code/recastnavigation/Detour/Source/DetourNavMesh.cpp rename to code/thirdparty/recastnavigation/Detour/Source/DetourNavMesh.cpp diff --git a/code/recastnavigation/Detour/Source/DetourNavMeshBuilder.cpp b/code/thirdparty/recastnavigation/Detour/Source/DetourNavMeshBuilder.cpp similarity index 100% rename from code/recastnavigation/Detour/Source/DetourNavMeshBuilder.cpp rename to code/thirdparty/recastnavigation/Detour/Source/DetourNavMeshBuilder.cpp diff --git a/code/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp b/code/thirdparty/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp similarity index 100% rename from code/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp rename to code/thirdparty/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp diff --git a/code/recastnavigation/Detour/Source/DetourNode.cpp b/code/thirdparty/recastnavigation/Detour/Source/DetourNode.cpp similarity index 100% rename from code/recastnavigation/Detour/Source/DetourNode.cpp rename to code/thirdparty/recastnavigation/Detour/Source/DetourNode.cpp diff --git a/code/recastnavigation/DetourCrowd/CMakeLists.txt b/code/thirdparty/recastnavigation/DetourCrowd/CMakeLists.txt similarity index 100% rename from code/recastnavigation/DetourCrowd/CMakeLists.txt rename to code/thirdparty/recastnavigation/DetourCrowd/CMakeLists.txt diff --git a/code/recastnavigation/DetourCrowd/Include/DetourCrowd.h b/code/thirdparty/recastnavigation/DetourCrowd/Include/DetourCrowd.h similarity index 100% rename from code/recastnavigation/DetourCrowd/Include/DetourCrowd.h rename to code/thirdparty/recastnavigation/DetourCrowd/Include/DetourCrowd.h diff --git a/code/recastnavigation/DetourCrowd/Include/DetourLocalBoundary.h b/code/thirdparty/recastnavigation/DetourCrowd/Include/DetourLocalBoundary.h similarity index 100% rename from code/recastnavigation/DetourCrowd/Include/DetourLocalBoundary.h rename to code/thirdparty/recastnavigation/DetourCrowd/Include/DetourLocalBoundary.h diff --git a/code/recastnavigation/DetourCrowd/Include/DetourObstacleAvoidance.h b/code/thirdparty/recastnavigation/DetourCrowd/Include/DetourObstacleAvoidance.h similarity index 100% rename from code/recastnavigation/DetourCrowd/Include/DetourObstacleAvoidance.h rename to code/thirdparty/recastnavigation/DetourCrowd/Include/DetourObstacleAvoidance.h diff --git a/code/recastnavigation/DetourCrowd/Include/DetourPathCorridor.h b/code/thirdparty/recastnavigation/DetourCrowd/Include/DetourPathCorridor.h similarity index 100% rename from code/recastnavigation/DetourCrowd/Include/DetourPathCorridor.h rename to code/thirdparty/recastnavigation/DetourCrowd/Include/DetourPathCorridor.h diff --git a/code/recastnavigation/DetourCrowd/Include/DetourPathQueue.h b/code/thirdparty/recastnavigation/DetourCrowd/Include/DetourPathQueue.h similarity index 100% rename from code/recastnavigation/DetourCrowd/Include/DetourPathQueue.h rename to code/thirdparty/recastnavigation/DetourCrowd/Include/DetourPathQueue.h diff --git a/code/recastnavigation/DetourCrowd/Include/DetourProximityGrid.h b/code/thirdparty/recastnavigation/DetourCrowd/Include/DetourProximityGrid.h similarity index 100% rename from code/recastnavigation/DetourCrowd/Include/DetourProximityGrid.h rename to code/thirdparty/recastnavigation/DetourCrowd/Include/DetourProximityGrid.h diff --git a/code/recastnavigation/DetourCrowd/Source/DetourCrowd.cpp b/code/thirdparty/recastnavigation/DetourCrowd/Source/DetourCrowd.cpp similarity index 100% rename from code/recastnavigation/DetourCrowd/Source/DetourCrowd.cpp rename to code/thirdparty/recastnavigation/DetourCrowd/Source/DetourCrowd.cpp diff --git a/code/recastnavigation/DetourCrowd/Source/DetourLocalBoundary.cpp b/code/thirdparty/recastnavigation/DetourCrowd/Source/DetourLocalBoundary.cpp similarity index 100% rename from code/recastnavigation/DetourCrowd/Source/DetourLocalBoundary.cpp rename to code/thirdparty/recastnavigation/DetourCrowd/Source/DetourLocalBoundary.cpp diff --git a/code/recastnavigation/DetourCrowd/Source/DetourObstacleAvoidance.cpp b/code/thirdparty/recastnavigation/DetourCrowd/Source/DetourObstacleAvoidance.cpp similarity index 100% rename from code/recastnavigation/DetourCrowd/Source/DetourObstacleAvoidance.cpp rename to code/thirdparty/recastnavigation/DetourCrowd/Source/DetourObstacleAvoidance.cpp diff --git a/code/recastnavigation/DetourCrowd/Source/DetourPathCorridor.cpp b/code/thirdparty/recastnavigation/DetourCrowd/Source/DetourPathCorridor.cpp similarity index 100% rename from code/recastnavigation/DetourCrowd/Source/DetourPathCorridor.cpp rename to code/thirdparty/recastnavigation/DetourCrowd/Source/DetourPathCorridor.cpp diff --git a/code/recastnavigation/DetourCrowd/Source/DetourPathQueue.cpp b/code/thirdparty/recastnavigation/DetourCrowd/Source/DetourPathQueue.cpp similarity index 100% rename from code/recastnavigation/DetourCrowd/Source/DetourPathQueue.cpp rename to code/thirdparty/recastnavigation/DetourCrowd/Source/DetourPathQueue.cpp diff --git a/code/recastnavigation/DetourCrowd/Source/DetourProximityGrid.cpp b/code/thirdparty/recastnavigation/DetourCrowd/Source/DetourProximityGrid.cpp similarity index 100% rename from code/recastnavigation/DetourCrowd/Source/DetourProximityGrid.cpp rename to code/thirdparty/recastnavigation/DetourCrowd/Source/DetourProximityGrid.cpp diff --git a/code/recastnavigation/DetourTileCache/CMakeLists.txt b/code/thirdparty/recastnavigation/DetourTileCache/CMakeLists.txt similarity index 100% rename from code/recastnavigation/DetourTileCache/CMakeLists.txt rename to code/thirdparty/recastnavigation/DetourTileCache/CMakeLists.txt diff --git a/code/recastnavigation/DetourTileCache/Include/DetourTileCache.h b/code/thirdparty/recastnavigation/DetourTileCache/Include/DetourTileCache.h similarity index 100% rename from code/recastnavigation/DetourTileCache/Include/DetourTileCache.h rename to code/thirdparty/recastnavigation/DetourTileCache/Include/DetourTileCache.h diff --git a/code/recastnavigation/DetourTileCache/Include/DetourTileCacheBuilder.h b/code/thirdparty/recastnavigation/DetourTileCache/Include/DetourTileCacheBuilder.h similarity index 100% rename from code/recastnavigation/DetourTileCache/Include/DetourTileCacheBuilder.h rename to code/thirdparty/recastnavigation/DetourTileCache/Include/DetourTileCacheBuilder.h diff --git a/code/recastnavigation/DetourTileCache/Source/DetourTileCache.cpp b/code/thirdparty/recastnavigation/DetourTileCache/Source/DetourTileCache.cpp similarity index 100% rename from code/recastnavigation/DetourTileCache/Source/DetourTileCache.cpp rename to code/thirdparty/recastnavigation/DetourTileCache/Source/DetourTileCache.cpp diff --git a/code/recastnavigation/DetourTileCache/Source/DetourTileCacheBuilder.cpp b/code/thirdparty/recastnavigation/DetourTileCache/Source/DetourTileCacheBuilder.cpp similarity index 100% rename from code/recastnavigation/DetourTileCache/Source/DetourTileCacheBuilder.cpp rename to code/thirdparty/recastnavigation/DetourTileCache/Source/DetourTileCacheBuilder.cpp diff --git a/code/recastnavigation/Docs/DoxygenLayout.xml b/code/thirdparty/recastnavigation/Docs/DoxygenLayout.xml similarity index 100% rename from code/recastnavigation/Docs/DoxygenLayout.xml rename to code/thirdparty/recastnavigation/Docs/DoxygenLayout.xml diff --git a/code/recastnavigation/Docs/Extern/Recast_api.txt b/code/thirdparty/recastnavigation/Docs/Extern/Recast_api.txt similarity index 100% rename from code/recastnavigation/Docs/Extern/Recast_api.txt rename to code/thirdparty/recastnavigation/Docs/Extern/Recast_api.txt diff --git a/code/recastnavigation/Docs/Images/screenshot.png b/code/thirdparty/recastnavigation/Docs/Images/screenshot.png similarity index 100% rename from code/recastnavigation/Docs/Images/screenshot.png rename to code/thirdparty/recastnavigation/Docs/Images/screenshot.png diff --git a/code/recastnavigation/Docs/Readme.txt b/code/thirdparty/recastnavigation/Docs/Readme.txt similarity index 100% rename from code/recastnavigation/Docs/Readme.txt rename to code/thirdparty/recastnavigation/Docs/Readme.txt diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/LICENSE b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/LICENSE similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/LICENSE rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/LICENSE diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/README.md b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/README.md similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/README.md rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/README.md diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-darkmode-toggle.js b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-darkmode-toggle.js similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-darkmode-toggle.js rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-darkmode-toggle.js diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-fragment-copy-button.js b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-fragment-copy-button.js similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-fragment-copy-button.js rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-fragment-copy-button.js diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-interactive-toc.js b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-interactive-toc.js similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-interactive-toc.js rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-interactive-toc.js diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-paragraph-link.js b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-paragraph-link.js similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-paragraph-link.js rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-paragraph-link.js diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-sidebar-only-darkmode-toggle.css b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-sidebar-only-darkmode-toggle.css similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-sidebar-only-darkmode-toggle.css rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-sidebar-only-darkmode-toggle.css diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-sidebar-only.css b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-sidebar-only.css similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-sidebar-only.css rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome-sidebar-only.css diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome.css b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome.css similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome.css rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-awesome.css diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/custom-alternative.css b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/custom-alternative.css similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/custom-alternative.css rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/custom-alternative.css diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/custom.css b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/custom.css similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/custom.css rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/custom.css diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/header.html b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/header.html similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/header.html rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/header.html diff --git a/code/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/toggle-alternative-theme.js b/code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/toggle-alternative-theme.js similarity index 100% rename from code/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/toggle-alternative-theme.js rename to code/thirdparty/recastnavigation/Docs/doxygen-awesome-css/doxygen-custom/toggle-alternative-theme.js diff --git a/code/recastnavigation/Docs/footer.html b/code/thirdparty/recastnavigation/Docs/footer.html similarity index 100% rename from code/recastnavigation/Docs/footer.html rename to code/thirdparty/recastnavigation/Docs/footer.html diff --git a/code/recastnavigation/Docs/header.html b/code/thirdparty/recastnavigation/Docs/header.html similarity index 100% rename from code/recastnavigation/Docs/header.html rename to code/thirdparty/recastnavigation/Docs/header.html diff --git a/code/recastnavigation/Doxyfile b/code/thirdparty/recastnavigation/Doxyfile similarity index 100% rename from code/recastnavigation/Doxyfile rename to code/thirdparty/recastnavigation/Doxyfile diff --git a/code/recastnavigation/License.txt b/code/thirdparty/recastnavigation/License.txt similarity index 100% rename from code/recastnavigation/License.txt rename to code/thirdparty/recastnavigation/License.txt diff --git a/code/recastnavigation/README.md b/code/thirdparty/recastnavigation/README.md similarity index 100% rename from code/recastnavigation/README.md rename to code/thirdparty/recastnavigation/README.md diff --git a/code/recastnavigation/Recast/CMakeLists.txt b/code/thirdparty/recastnavigation/Recast/CMakeLists.txt similarity index 100% rename from code/recastnavigation/Recast/CMakeLists.txt rename to code/thirdparty/recastnavigation/Recast/CMakeLists.txt diff --git a/code/recastnavigation/Recast/Include/Recast.h b/code/thirdparty/recastnavigation/Recast/Include/Recast.h similarity index 100% rename from code/recastnavigation/Recast/Include/Recast.h rename to code/thirdparty/recastnavigation/Recast/Include/Recast.h diff --git a/code/recastnavigation/Recast/Include/RecastAlloc.h b/code/thirdparty/recastnavigation/Recast/Include/RecastAlloc.h similarity index 100% rename from code/recastnavigation/Recast/Include/RecastAlloc.h rename to code/thirdparty/recastnavigation/Recast/Include/RecastAlloc.h diff --git a/code/recastnavigation/Recast/Include/RecastAssert.h b/code/thirdparty/recastnavigation/Recast/Include/RecastAssert.h similarity index 100% rename from code/recastnavigation/Recast/Include/RecastAssert.h rename to code/thirdparty/recastnavigation/Recast/Include/RecastAssert.h diff --git a/code/recastnavigation/Recast/Source/Recast.cpp b/code/thirdparty/recastnavigation/Recast/Source/Recast.cpp similarity index 100% rename from code/recastnavigation/Recast/Source/Recast.cpp rename to code/thirdparty/recastnavigation/Recast/Source/Recast.cpp diff --git a/code/recastnavigation/Recast/Source/RecastAlloc.cpp b/code/thirdparty/recastnavigation/Recast/Source/RecastAlloc.cpp similarity index 100% rename from code/recastnavigation/Recast/Source/RecastAlloc.cpp rename to code/thirdparty/recastnavigation/Recast/Source/RecastAlloc.cpp diff --git a/code/recastnavigation/Recast/Source/RecastArea.cpp b/code/thirdparty/recastnavigation/Recast/Source/RecastArea.cpp similarity index 100% rename from code/recastnavigation/Recast/Source/RecastArea.cpp rename to code/thirdparty/recastnavigation/Recast/Source/RecastArea.cpp diff --git a/code/recastnavigation/Recast/Source/RecastAssert.cpp b/code/thirdparty/recastnavigation/Recast/Source/RecastAssert.cpp similarity index 100% rename from code/recastnavigation/Recast/Source/RecastAssert.cpp rename to code/thirdparty/recastnavigation/Recast/Source/RecastAssert.cpp diff --git a/code/recastnavigation/Recast/Source/RecastContour.cpp b/code/thirdparty/recastnavigation/Recast/Source/RecastContour.cpp similarity index 100% rename from code/recastnavigation/Recast/Source/RecastContour.cpp rename to code/thirdparty/recastnavigation/Recast/Source/RecastContour.cpp diff --git a/code/recastnavigation/Recast/Source/RecastFilter.cpp b/code/thirdparty/recastnavigation/Recast/Source/RecastFilter.cpp similarity index 100% rename from code/recastnavigation/Recast/Source/RecastFilter.cpp rename to code/thirdparty/recastnavigation/Recast/Source/RecastFilter.cpp diff --git a/code/recastnavigation/Recast/Source/RecastLayers.cpp b/code/thirdparty/recastnavigation/Recast/Source/RecastLayers.cpp similarity index 100% rename from code/recastnavigation/Recast/Source/RecastLayers.cpp rename to code/thirdparty/recastnavigation/Recast/Source/RecastLayers.cpp diff --git a/code/recastnavigation/Recast/Source/RecastMesh.cpp b/code/thirdparty/recastnavigation/Recast/Source/RecastMesh.cpp similarity index 100% rename from code/recastnavigation/Recast/Source/RecastMesh.cpp rename to code/thirdparty/recastnavigation/Recast/Source/RecastMesh.cpp diff --git a/code/recastnavigation/Recast/Source/RecastMeshDetail.cpp b/code/thirdparty/recastnavigation/Recast/Source/RecastMeshDetail.cpp similarity index 100% rename from code/recastnavigation/Recast/Source/RecastMeshDetail.cpp rename to code/thirdparty/recastnavigation/Recast/Source/RecastMeshDetail.cpp diff --git a/code/recastnavigation/Recast/Source/RecastRasterization.cpp b/code/thirdparty/recastnavigation/Recast/Source/RecastRasterization.cpp similarity index 100% rename from code/recastnavigation/Recast/Source/RecastRasterization.cpp rename to code/thirdparty/recastnavigation/Recast/Source/RecastRasterization.cpp diff --git a/code/recastnavigation/Recast/Source/RecastRegion.cpp b/code/thirdparty/recastnavigation/Recast/Source/RecastRegion.cpp similarity index 100% rename from code/recastnavigation/Recast/Source/RecastRegion.cpp rename to code/thirdparty/recastnavigation/Recast/Source/RecastRegion.cpp diff --git a/code/recastnavigation/RecastDemo/Bin/.gitignore b/code/thirdparty/recastnavigation/RecastDemo/Bin/.gitignore similarity index 100% rename from code/recastnavigation/RecastDemo/Bin/.gitignore rename to code/thirdparty/recastnavigation/RecastDemo/Bin/.gitignore diff --git a/code/recastnavigation/RecastDemo/Bin/DroidSans.ttf b/code/thirdparty/recastnavigation/RecastDemo/Bin/DroidSans.ttf similarity index 100% rename from code/recastnavigation/RecastDemo/Bin/DroidSans.ttf rename to code/thirdparty/recastnavigation/RecastDemo/Bin/DroidSans.ttf diff --git a/code/recastnavigation/RecastDemo/Bin/TestCases/movement_test.txt b/code/thirdparty/recastnavigation/RecastDemo/Bin/TestCases/movement_test.txt similarity index 100% rename from code/recastnavigation/RecastDemo/Bin/TestCases/movement_test.txt rename to code/thirdparty/recastnavigation/RecastDemo/Bin/TestCases/movement_test.txt diff --git a/code/recastnavigation/RecastDemo/Bin/TestCases/nav_mesh_test.txt b/code/thirdparty/recastnavigation/RecastDemo/Bin/TestCases/nav_mesh_test.txt similarity index 100% rename from code/recastnavigation/RecastDemo/Bin/TestCases/nav_mesh_test.txt rename to code/thirdparty/recastnavigation/RecastDemo/Bin/TestCases/nav_mesh_test.txt diff --git a/code/recastnavigation/RecastDemo/Bin/TestCases/raycast_test.txt b/code/thirdparty/recastnavigation/RecastDemo/Bin/TestCases/raycast_test.txt similarity index 100% rename from code/recastnavigation/RecastDemo/Bin/TestCases/raycast_test.txt rename to code/thirdparty/recastnavigation/RecastDemo/Bin/TestCases/raycast_test.txt diff --git a/code/recastnavigation/RecastDemo/CMakeLists.txt b/code/thirdparty/recastnavigation/RecastDemo/CMakeLists.txt similarity index 100% rename from code/recastnavigation/RecastDemo/CMakeLists.txt rename to code/thirdparty/recastnavigation/RecastDemo/CMakeLists.txt diff --git a/code/recastnavigation/RecastDemo/Contrib/fastlz/README.TXT b/code/thirdparty/recastnavigation/RecastDemo/Contrib/fastlz/README.TXT similarity index 100% rename from code/recastnavigation/RecastDemo/Contrib/fastlz/README.TXT rename to code/thirdparty/recastnavigation/RecastDemo/Contrib/fastlz/README.TXT diff --git a/code/recastnavigation/RecastDemo/Contrib/fastlz/fastlz.c b/code/thirdparty/recastnavigation/RecastDemo/Contrib/fastlz/fastlz.c similarity index 100% rename from code/recastnavigation/RecastDemo/Contrib/fastlz/fastlz.c rename to code/thirdparty/recastnavigation/RecastDemo/Contrib/fastlz/fastlz.c diff --git a/code/recastnavigation/RecastDemo/Contrib/fastlz/fastlz.h b/code/thirdparty/recastnavigation/RecastDemo/Contrib/fastlz/fastlz.h similarity index 100% rename from code/recastnavigation/RecastDemo/Contrib/fastlz/fastlz.h rename to code/thirdparty/recastnavigation/RecastDemo/Contrib/fastlz/fastlz.h diff --git a/code/recastnavigation/RecastDemo/Contrib/readme-sdl.txt b/code/thirdparty/recastnavigation/RecastDemo/Contrib/readme-sdl.txt similarity index 100% rename from code/recastnavigation/RecastDemo/Contrib/readme-sdl.txt rename to code/thirdparty/recastnavigation/RecastDemo/Contrib/readme-sdl.txt diff --git a/code/recastnavigation/RecastDemo/Contrib/stb_truetype.h b/code/thirdparty/recastnavigation/RecastDemo/Contrib/stb_truetype.h similarity index 100% rename from code/recastnavigation/RecastDemo/Contrib/stb_truetype.h rename to code/thirdparty/recastnavigation/RecastDemo/Contrib/stb_truetype.h diff --git a/code/recastnavigation/RecastDemo/Include/ChunkyTriMesh.h b/code/thirdparty/recastnavigation/RecastDemo/Include/ChunkyTriMesh.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/ChunkyTriMesh.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/ChunkyTriMesh.h diff --git a/code/recastnavigation/RecastDemo/Include/ConvexVolumeTool.h b/code/thirdparty/recastnavigation/RecastDemo/Include/ConvexVolumeTool.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/ConvexVolumeTool.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/ConvexVolumeTool.h diff --git a/code/recastnavigation/RecastDemo/Include/CrowdTool.h b/code/thirdparty/recastnavigation/RecastDemo/Include/CrowdTool.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/CrowdTool.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/CrowdTool.h diff --git a/code/recastnavigation/RecastDemo/Include/Filelist.h b/code/thirdparty/recastnavigation/RecastDemo/Include/Filelist.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/Filelist.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/Filelist.h diff --git a/code/recastnavigation/RecastDemo/Include/InputGeom.h b/code/thirdparty/recastnavigation/RecastDemo/Include/InputGeom.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/InputGeom.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/InputGeom.h diff --git a/code/recastnavigation/RecastDemo/Include/MeshLoaderObj.h b/code/thirdparty/recastnavigation/RecastDemo/Include/MeshLoaderObj.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/MeshLoaderObj.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/MeshLoaderObj.h diff --git a/code/recastnavigation/RecastDemo/Include/NavMeshPruneTool.h b/code/thirdparty/recastnavigation/RecastDemo/Include/NavMeshPruneTool.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/NavMeshPruneTool.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/NavMeshPruneTool.h diff --git a/code/recastnavigation/RecastDemo/Include/NavMeshTesterTool.h b/code/thirdparty/recastnavigation/RecastDemo/Include/NavMeshTesterTool.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/NavMeshTesterTool.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/NavMeshTesterTool.h diff --git a/code/recastnavigation/RecastDemo/Include/OffMeshConnectionTool.h b/code/thirdparty/recastnavigation/RecastDemo/Include/OffMeshConnectionTool.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/OffMeshConnectionTool.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/OffMeshConnectionTool.h diff --git a/code/recastnavigation/RecastDemo/Include/PerfTimer.h b/code/thirdparty/recastnavigation/RecastDemo/Include/PerfTimer.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/PerfTimer.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/PerfTimer.h diff --git a/code/recastnavigation/RecastDemo/Include/Sample.h b/code/thirdparty/recastnavigation/RecastDemo/Include/Sample.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/Sample.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/Sample.h diff --git a/code/recastnavigation/RecastDemo/Include/SampleInterfaces.h b/code/thirdparty/recastnavigation/RecastDemo/Include/SampleInterfaces.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/SampleInterfaces.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/SampleInterfaces.h diff --git a/code/recastnavigation/RecastDemo/Include/Sample_Debug.h b/code/thirdparty/recastnavigation/RecastDemo/Include/Sample_Debug.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/Sample_Debug.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/Sample_Debug.h diff --git a/code/recastnavigation/RecastDemo/Include/Sample_SoloMesh.h b/code/thirdparty/recastnavigation/RecastDemo/Include/Sample_SoloMesh.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/Sample_SoloMesh.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/Sample_SoloMesh.h diff --git a/code/recastnavigation/RecastDemo/Include/Sample_TempObstacles.h b/code/thirdparty/recastnavigation/RecastDemo/Include/Sample_TempObstacles.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/Sample_TempObstacles.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/Sample_TempObstacles.h diff --git a/code/recastnavigation/RecastDemo/Include/Sample_TileMesh.h b/code/thirdparty/recastnavigation/RecastDemo/Include/Sample_TileMesh.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/Sample_TileMesh.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/Sample_TileMesh.h diff --git a/code/recastnavigation/RecastDemo/Include/TestCase.h b/code/thirdparty/recastnavigation/RecastDemo/Include/TestCase.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/TestCase.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/TestCase.h diff --git a/code/recastnavigation/RecastDemo/Include/ValueHistory.h b/code/thirdparty/recastnavigation/RecastDemo/Include/ValueHistory.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/ValueHistory.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/ValueHistory.h diff --git a/code/recastnavigation/RecastDemo/Include/imgui.h b/code/thirdparty/recastnavigation/RecastDemo/Include/imgui.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/imgui.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/imgui.h diff --git a/code/recastnavigation/RecastDemo/Include/imguiRenderGL.h b/code/thirdparty/recastnavigation/RecastDemo/Include/imguiRenderGL.h similarity index 100% rename from code/recastnavigation/RecastDemo/Include/imguiRenderGL.h rename to code/thirdparty/recastnavigation/RecastDemo/Include/imguiRenderGL.h diff --git a/code/recastnavigation/RecastDemo/Source/ChunkyTriMesh.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/ChunkyTriMesh.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/ChunkyTriMesh.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/ChunkyTriMesh.cpp diff --git a/code/recastnavigation/RecastDemo/Source/ConvexVolumeTool.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/ConvexVolumeTool.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/ConvexVolumeTool.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/ConvexVolumeTool.cpp diff --git a/code/recastnavigation/RecastDemo/Source/CrowdTool.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/CrowdTool.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/CrowdTool.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/CrowdTool.cpp diff --git a/code/recastnavigation/RecastDemo/Source/Filelist.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/Filelist.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/Filelist.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/Filelist.cpp diff --git a/code/recastnavigation/RecastDemo/Source/InputGeom.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/InputGeom.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/InputGeom.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/InputGeom.cpp diff --git a/code/recastnavigation/RecastDemo/Source/MeshLoaderObj.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/MeshLoaderObj.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/MeshLoaderObj.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/MeshLoaderObj.cpp diff --git a/code/recastnavigation/RecastDemo/Source/NavMeshPruneTool.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/NavMeshPruneTool.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/NavMeshPruneTool.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/NavMeshPruneTool.cpp diff --git a/code/recastnavigation/RecastDemo/Source/NavMeshTesterTool.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/NavMeshTesterTool.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/NavMeshTesterTool.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/NavMeshTesterTool.cpp diff --git a/code/recastnavigation/RecastDemo/Source/OffMeshConnectionTool.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/OffMeshConnectionTool.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/OffMeshConnectionTool.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/OffMeshConnectionTool.cpp diff --git a/code/recastnavigation/RecastDemo/Source/PerfTimer.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/PerfTimer.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/PerfTimer.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/PerfTimer.cpp diff --git a/code/recastnavigation/RecastDemo/Source/Sample.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/Sample.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/Sample.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/Sample.cpp diff --git a/code/recastnavigation/RecastDemo/Source/SampleInterfaces.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/SampleInterfaces.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/SampleInterfaces.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/SampleInterfaces.cpp diff --git a/code/recastnavigation/RecastDemo/Source/Sample_Debug.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/Sample_Debug.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/Sample_Debug.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/Sample_Debug.cpp diff --git a/code/recastnavigation/RecastDemo/Source/Sample_SoloMesh.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/Sample_SoloMesh.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/Sample_SoloMesh.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/Sample_SoloMesh.cpp diff --git a/code/recastnavigation/RecastDemo/Source/Sample_TempObstacles.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/Sample_TempObstacles.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/Sample_TempObstacles.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/Sample_TempObstacles.cpp diff --git a/code/recastnavigation/RecastDemo/Source/Sample_TileMesh.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/Sample_TileMesh.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/Sample_TileMesh.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/Sample_TileMesh.cpp diff --git a/code/recastnavigation/RecastDemo/Source/TestCase.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/TestCase.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/TestCase.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/TestCase.cpp diff --git a/code/recastnavigation/RecastDemo/Source/ValueHistory.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/ValueHistory.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/ValueHistory.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/ValueHistory.cpp diff --git a/code/recastnavigation/RecastDemo/Source/imgui.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/imgui.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/imgui.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/imgui.cpp diff --git a/code/recastnavigation/RecastDemo/Source/imguiRenderGL.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/imguiRenderGL.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/imguiRenderGL.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/imguiRenderGL.cpp diff --git a/code/recastnavigation/RecastDemo/Source/main.cpp b/code/thirdparty/recastnavigation/RecastDemo/Source/main.cpp similarity index 100% rename from code/recastnavigation/RecastDemo/Source/main.cpp rename to code/thirdparty/recastnavigation/RecastDemo/Source/main.cpp diff --git a/code/recastnavigation/RecastDemo/cmake/FindSDL2.cmake b/code/thirdparty/recastnavigation/RecastDemo/cmake/FindSDL2.cmake similarity index 100% rename from code/recastnavigation/RecastDemo/cmake/FindSDL2.cmake rename to code/thirdparty/recastnavigation/RecastDemo/cmake/FindSDL2.cmake diff --git a/code/recastnavigation/RecastDemo/premake5.lua b/code/thirdparty/recastnavigation/RecastDemo/premake5.lua similarity index 100% rename from code/recastnavigation/RecastDemo/premake5.lua rename to code/thirdparty/recastnavigation/RecastDemo/premake5.lua diff --git a/code/recastnavigation/Roadmap.md b/code/thirdparty/recastnavigation/Roadmap.md similarity index 100% rename from code/recastnavigation/Roadmap.md rename to code/thirdparty/recastnavigation/Roadmap.md diff --git a/code/recastnavigation/Tests/CMakeLists.txt b/code/thirdparty/recastnavigation/Tests/CMakeLists.txt similarity index 100% rename from code/recastnavigation/Tests/CMakeLists.txt rename to code/thirdparty/recastnavigation/Tests/CMakeLists.txt diff --git a/code/recastnavigation/Tests/Contrib/catch2/catch_all.hpp b/code/thirdparty/recastnavigation/Tests/Contrib/catch2/catch_all.hpp similarity index 100% rename from code/recastnavigation/Tests/Contrib/catch2/catch_all.hpp rename to code/thirdparty/recastnavigation/Tests/Contrib/catch2/catch_all.hpp diff --git a/code/recastnavigation/Tests/Contrib/catch2/catch_amalgamated.cpp b/code/thirdparty/recastnavigation/Tests/Contrib/catch2/catch_amalgamated.cpp similarity index 100% rename from code/recastnavigation/Tests/Contrib/catch2/catch_amalgamated.cpp rename to code/thirdparty/recastnavigation/Tests/Contrib/catch2/catch_amalgamated.cpp diff --git a/code/recastnavigation/Tests/Detour/Tests_Detour.cpp b/code/thirdparty/recastnavigation/Tests/Detour/Tests_Detour.cpp similarity index 100% rename from code/recastnavigation/Tests/Detour/Tests_Detour.cpp rename to code/thirdparty/recastnavigation/Tests/Detour/Tests_Detour.cpp diff --git a/code/recastnavigation/Tests/Recast/Tests_Recast.cpp b/code/thirdparty/recastnavigation/Tests/Recast/Tests_Recast.cpp similarity index 100% rename from code/recastnavigation/Tests/Recast/Tests_Recast.cpp rename to code/thirdparty/recastnavigation/Tests/Recast/Tests_Recast.cpp diff --git a/code/recastnavigation/recastnavigation-config.cmake.in b/code/thirdparty/recastnavigation/recastnavigation-config.cmake.in similarity index 100% rename from code/recastnavigation/recastnavigation-config.cmake.in rename to code/thirdparty/recastnavigation/recastnavigation-config.cmake.in diff --git a/code/recastnavigation/recastnavigation.pc.in b/code/thirdparty/recastnavigation/recastnavigation.pc.in similarity index 100% rename from code/recastnavigation/recastnavigation.pc.in rename to code/thirdparty/recastnavigation/recastnavigation.pc.in diff --git a/code/recastnavigation/version.h.in b/code/thirdparty/recastnavigation/version.h.in similarity index 100% rename from code/recastnavigation/version.h.in rename to code/thirdparty/recastnavigation/version.h.in diff --git a/code/zlib-1.3.1/adler32.c b/code/thirdparty/zlib-1.3.1/adler32.c similarity index 100% rename from code/zlib-1.3.1/adler32.c rename to code/thirdparty/zlib-1.3.1/adler32.c diff --git a/code/zlib-1.3.1/compress.c b/code/thirdparty/zlib-1.3.1/compress.c similarity index 100% rename from code/zlib-1.3.1/compress.c rename to code/thirdparty/zlib-1.3.1/compress.c diff --git a/code/zlib-1.3.1/crc32.c b/code/thirdparty/zlib-1.3.1/crc32.c similarity index 100% rename from code/zlib-1.3.1/crc32.c rename to code/thirdparty/zlib-1.3.1/crc32.c diff --git a/code/zlib-1.3.1/crc32.h b/code/thirdparty/zlib-1.3.1/crc32.h similarity index 100% rename from code/zlib-1.3.1/crc32.h rename to code/thirdparty/zlib-1.3.1/crc32.h diff --git a/code/zlib-1.3.1/deflate.c b/code/thirdparty/zlib-1.3.1/deflate.c similarity index 100% rename from code/zlib-1.3.1/deflate.c rename to code/thirdparty/zlib-1.3.1/deflate.c diff --git a/code/zlib-1.3.1/deflate.h b/code/thirdparty/zlib-1.3.1/deflate.h similarity index 100% rename from code/zlib-1.3.1/deflate.h rename to code/thirdparty/zlib-1.3.1/deflate.h diff --git a/code/zlib-1.3.1/gzguts.h b/code/thirdparty/zlib-1.3.1/gzguts.h similarity index 100% rename from code/zlib-1.3.1/gzguts.h rename to code/thirdparty/zlib-1.3.1/gzguts.h diff --git a/code/zlib-1.3.1/infback.c b/code/thirdparty/zlib-1.3.1/infback.c similarity index 100% rename from code/zlib-1.3.1/infback.c rename to code/thirdparty/zlib-1.3.1/infback.c diff --git a/code/zlib-1.3.1/inffast.c b/code/thirdparty/zlib-1.3.1/inffast.c similarity index 100% rename from code/zlib-1.3.1/inffast.c rename to code/thirdparty/zlib-1.3.1/inffast.c diff --git a/code/zlib-1.3.1/inffast.h b/code/thirdparty/zlib-1.3.1/inffast.h similarity index 100% rename from code/zlib-1.3.1/inffast.h rename to code/thirdparty/zlib-1.3.1/inffast.h diff --git a/code/zlib-1.3.1/inffixed.h b/code/thirdparty/zlib-1.3.1/inffixed.h similarity index 100% rename from code/zlib-1.3.1/inffixed.h rename to code/thirdparty/zlib-1.3.1/inffixed.h diff --git a/code/zlib-1.3.1/inflate.c b/code/thirdparty/zlib-1.3.1/inflate.c similarity index 100% rename from code/zlib-1.3.1/inflate.c rename to code/thirdparty/zlib-1.3.1/inflate.c diff --git a/code/zlib-1.3.1/inflate.h b/code/thirdparty/zlib-1.3.1/inflate.h similarity index 100% rename from code/zlib-1.3.1/inflate.h rename to code/thirdparty/zlib-1.3.1/inflate.h diff --git a/code/zlib-1.3.1/inftrees.c b/code/thirdparty/zlib-1.3.1/inftrees.c similarity index 100% rename from code/zlib-1.3.1/inftrees.c rename to code/thirdparty/zlib-1.3.1/inftrees.c diff --git a/code/zlib-1.3.1/inftrees.h b/code/thirdparty/zlib-1.3.1/inftrees.h similarity index 100% rename from code/zlib-1.3.1/inftrees.h rename to code/thirdparty/zlib-1.3.1/inftrees.h diff --git a/code/zlib-1.3.1/trees.c b/code/thirdparty/zlib-1.3.1/trees.c similarity index 100% rename from code/zlib-1.3.1/trees.c rename to code/thirdparty/zlib-1.3.1/trees.c diff --git a/code/zlib-1.3.1/trees.h b/code/thirdparty/zlib-1.3.1/trees.h similarity index 100% rename from code/zlib-1.3.1/trees.h rename to code/thirdparty/zlib-1.3.1/trees.h diff --git a/code/zlib-1.3.1/uncompr.c b/code/thirdparty/zlib-1.3.1/uncompr.c similarity index 100% rename from code/zlib-1.3.1/uncompr.c rename to code/thirdparty/zlib-1.3.1/uncompr.c diff --git a/code/zlib-1.3.1/zconf.h b/code/thirdparty/zlib-1.3.1/zconf.h similarity index 100% rename from code/zlib-1.3.1/zconf.h rename to code/thirdparty/zlib-1.3.1/zconf.h diff --git a/code/zlib-1.3.1/zlib.h b/code/thirdparty/zlib-1.3.1/zlib.h similarity index 100% rename from code/zlib-1.3.1/zlib.h rename to code/thirdparty/zlib-1.3.1/zlib.h diff --git a/code/zlib-1.3.1/zutil.c b/code/thirdparty/zlib-1.3.1/zutil.c similarity index 100% rename from code/zlib-1.3.1/zutil.c rename to code/thirdparty/zlib-1.3.1/zutil.c diff --git a/code/zlib-1.3.1/zutil.h b/code/thirdparty/zlib-1.3.1/zutil.h similarity index 100% rename from code/zlib-1.3.1/zutil.h rename to code/thirdparty/zlib-1.3.1/zutil.h diff --git a/code/zlib-1.3.1/gzclose.c b/code/zlib-1.3.1/gzclose.c deleted file mode 100644 index 48d6a86f..00000000 --- a/code/zlib-1.3.1/gzclose.c +++ /dev/null @@ -1,23 +0,0 @@ -/* gzclose.c -- zlib gzclose() function - * Copyright (C) 2004, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "gzguts.h" - -/* gzclose() is in a separate file so that it is linked in only if it is used. - That way the other gzclose functions can be used instead to avoid linking in - unneeded compression or decompression routines. */ -int ZEXPORT gzclose(gzFile file) { -#ifndef NO_GZCOMPRESS - gz_statep state; - - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - - return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); -#else - return gzclose_r(file); -#endif -} diff --git a/code/zlib-1.3.1/gzlib.c b/code/zlib-1.3.1/gzlib.c deleted file mode 100644 index 983153cc..00000000 --- a/code/zlib-1.3.1/gzlib.c +++ /dev/null @@ -1,582 +0,0 @@ -/* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004-2024 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "gzguts.h" - -#if defined(_WIN32) && !defined(__BORLANDC__) -# define LSEEK _lseeki64 -#else -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 -# define LSEEK lseek64 -#else -# define LSEEK lseek -#endif -#endif - -#if defined UNDER_CE - -/* Map the Windows error number in ERROR to a locale-dependent error message - string and return a pointer to it. Typically, the values for ERROR come - from GetLastError. - - The string pointed to shall not be modified by the application, but may be - overwritten by a subsequent call to gz_strwinerror - - The gz_strwinerror function does not change the current setting of - GetLastError. */ -char ZLIB_INTERNAL *gz_strwinerror(DWORD error) { - static char buf[1024]; - - wchar_t *msgbuf; - DWORD lasterr = GetLastError(); - DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM - | FORMAT_MESSAGE_ALLOCATE_BUFFER, - NULL, - error, - 0, /* Default language */ - (LPVOID)&msgbuf, - 0, - NULL); - if (chars != 0) { - /* If there is an \r\n appended, zap it. */ - if (chars >= 2 - && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') { - chars -= 2; - msgbuf[chars] = 0; - } - - if (chars > sizeof (buf) - 1) { - chars = sizeof (buf) - 1; - msgbuf[chars] = 0; - } - - wcstombs(buf, msgbuf, chars + 1); - LocalFree(msgbuf); - } - else { - sprintf(buf, "unknown win32 error (%ld)", error); - } - - SetLastError(lasterr); - return buf; -} - -#endif /* UNDER_CE */ - -/* Reset gzip file state */ -local void gz_reset(gz_statep state) { - state->x.have = 0; /* no output data available */ - if (state->mode == GZ_READ) { /* for reading ... */ - state->eof = 0; /* not at end of file */ - state->past = 0; /* have not read past end yet */ - state->how = LOOK; /* look for gzip header */ - } - else /* for writing ... */ - state->reset = 0; /* no deflateReset pending */ - state->seek = 0; /* no seek request pending */ - gz_error(state, Z_OK, NULL); /* clear error */ - state->x.pos = 0; /* no uncompressed data yet */ - state->strm.avail_in = 0; /* no input data yet */ -} - -/* Open a gzip file either by name or file descriptor. */ -local gzFile gz_open(const void *path, int fd, const char *mode) { - gz_statep state; - z_size_t len; - int oflag; -#ifdef O_CLOEXEC - int cloexec = 0; -#endif -#ifdef O_EXCL - int exclusive = 0; -#endif - - /* check input */ - if (path == NULL) - return NULL; - - /* allocate gzFile structure to return */ - state = (gz_statep)malloc(sizeof(gz_state)); - if (state == NULL) - return NULL; - state->size = 0; /* no buffers allocated yet */ - state->want = GZBUFSIZE; /* requested buffer size */ - state->msg = NULL; /* no error message yet */ - - /* interpret mode */ - state->mode = GZ_NONE; - state->level = Z_DEFAULT_COMPRESSION; - state->strategy = Z_DEFAULT_STRATEGY; - state->direct = 0; - while (*mode) { - if (*mode >= '0' && *mode <= '9') - state->level = *mode - '0'; - else - switch (*mode) { - case 'r': - state->mode = GZ_READ; - break; -#ifndef NO_GZCOMPRESS - case 'w': - state->mode = GZ_WRITE; - break; - case 'a': - state->mode = GZ_APPEND; - break; -#endif - case '+': /* can't read and write at the same time */ - free(state); - return NULL; - case 'b': /* ignore -- will request binary anyway */ - break; -#ifdef O_CLOEXEC - case 'e': - cloexec = 1; - break; -#endif -#ifdef O_EXCL - case 'x': - exclusive = 1; - break; -#endif - case 'f': - state->strategy = Z_FILTERED; - break; - case 'h': - state->strategy = Z_HUFFMAN_ONLY; - break; - case 'R': - state->strategy = Z_RLE; - break; - case 'F': - state->strategy = Z_FIXED; - break; - case 'T': - state->direct = 1; - break; - default: /* could consider as an error, but just ignore */ - ; - } - mode++; - } - - /* must provide an "r", "w", or "a" */ - if (state->mode == GZ_NONE) { - free(state); - return NULL; - } - - /* can't force transparent read */ - if (state->mode == GZ_READ) { - if (state->direct) { - free(state); - return NULL; - } - state->direct = 1; /* for empty file */ - } - - /* save the path name for error messages */ -#ifdef WIDECHAR - if (fd == -2) { - len = wcstombs(NULL, path, 0); - if (len == (z_size_t)-1) - len = 0; - } - else -#endif - len = strlen((const char *)path); - state->path = (char *)malloc(len + 1); - if (state->path == NULL) { - free(state); - return NULL; - } -#ifdef WIDECHAR - if (fd == -2) - if (len) - wcstombs(state->path, path, len + 1); - else - *(state->path) = 0; - else -#endif -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - (void)snprintf(state->path, len + 1, "%s", (const char *)path); -#else - strcpy(state->path, path); -#endif - - /* compute the flags for open() */ - oflag = -#ifdef O_LARGEFILE - O_LARGEFILE | -#endif -#ifdef O_BINARY - O_BINARY | -#endif -#ifdef O_CLOEXEC - (cloexec ? O_CLOEXEC : 0) | -#endif - (state->mode == GZ_READ ? - O_RDONLY : - (O_WRONLY | O_CREAT | -#ifdef O_EXCL - (exclusive ? O_EXCL : 0) | -#endif - (state->mode == GZ_WRITE ? - O_TRUNC : - O_APPEND))); - - /* open the file with the appropriate flags (or just use fd) */ - state->fd = fd > -1 ? fd : ( -#ifdef WIDECHAR - fd == -2 ? _wopen(path, oflag, 0666) : -#endif - open((const char *)path, oflag, 0666)); - if (state->fd == -1) { - free(state->path); - free(state); - return NULL; - } - if (state->mode == GZ_APPEND) { - LSEEK(state->fd, 0, SEEK_END); /* so gzoffset() is correct */ - state->mode = GZ_WRITE; /* simplify later checks */ - } - - /* save the current position for rewinding (only if reading) */ - if (state->mode == GZ_READ) { - state->start = LSEEK(state->fd, 0, SEEK_CUR); - if (state->start == -1) state->start = 0; - } - - /* initialize stream */ - gz_reset(state); - - /* return stream */ - return (gzFile)state; -} - -/* -- see zlib.h -- */ -gzFile ZEXPORT gzopen(const char *path, const char *mode) { - return gz_open(path, -1, mode); -} - -/* -- see zlib.h -- */ -gzFile ZEXPORT gzopen64(const char *path, const char *mode) { - return gz_open(path, -1, mode); -} - -/* -- see zlib.h -- */ -gzFile ZEXPORT gzdopen(int fd, const char *mode) { - char *path; /* identifier for error messages */ - gzFile gz; - - if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) - return NULL; -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - (void)snprintf(path, 7 + 3 * sizeof(int), "", fd); -#else - sprintf(path, "", fd); /* for debugging */ -#endif - gz = gz_open(path, fd, mode); - free(path); - return gz; -} - -/* -- see zlib.h -- */ -#ifdef WIDECHAR -gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) { - return gz_open(path, -2, mode); -} -#endif - -/* -- see zlib.h -- */ -int ZEXPORT gzbuffer(gzFile file, unsigned size) { - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return -1; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return -1; - - /* make sure we haven't already allocated memory */ - if (state->size != 0) - return -1; - - /* check and set requested size */ - if ((size << 1) < size) - return -1; /* need to be able to double it */ - if (size < 8) - size = 8; /* needed to behave well with flushing */ - state->want = size; - return 0; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzrewind(gzFile file) { - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're reading and that there's no error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* back up and start over */ - if (LSEEK(state->fd, state->start, SEEK_SET) == -1) - return -1; - gz_reset(state); - return 0; -} - -/* -- see zlib.h -- */ -z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) { - unsigned n; - z_off64_t ret; - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return -1; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return -1; - - /* check that there's no error */ - if (state->err != Z_OK && state->err != Z_BUF_ERROR) - return -1; - - /* can only seek from start or relative to current position */ - if (whence != SEEK_SET && whence != SEEK_CUR) - return -1; - - /* normalize offset to a SEEK_CUR specification */ - if (whence == SEEK_SET) - offset -= state->x.pos; - else if (state->seek) - offset += state->skip; - state->seek = 0; - - /* if within raw area while reading, just go there */ - if (state->mode == GZ_READ && state->how == COPY && - state->x.pos + offset >= 0) { - ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR); - if (ret == -1) - return -1; - state->x.have = 0; - state->eof = 0; - state->past = 0; - state->seek = 0; - gz_error(state, Z_OK, NULL); - state->strm.avail_in = 0; - state->x.pos += offset; - return state->x.pos; - } - - /* calculate skip amount, rewinding if needed for back seek when reading */ - if (offset < 0) { - if (state->mode != GZ_READ) /* writing -- can't go backwards */ - return -1; - offset += state->x.pos; - if (offset < 0) /* before start of file! */ - return -1; - if (gzrewind(file) == -1) /* rewind, then skip to offset */ - return -1; - } - - /* if reading, skip what's in output buffer (one less gzgetc() check) */ - if (state->mode == GZ_READ) { - n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ? - (unsigned)offset : state->x.have; - state->x.have -= n; - state->x.next += n; - state->x.pos += n; - offset -= n; - } - - /* request skip (if not zero) */ - if (offset) { - state->seek = 1; - state->skip = offset; - } - return state->x.pos + offset; -} - -/* -- see zlib.h -- */ -z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) { - z_off64_t ret; - - ret = gzseek64(file, (z_off64_t)offset, whence); - return ret == (z_off_t)ret ? (z_off_t)ret : -1; -} - -/* -- see zlib.h -- */ -z_off64_t ZEXPORT gztell64(gzFile file) { - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return -1; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return -1; - - /* return position */ - return state->x.pos + (state->seek ? state->skip : 0); -} - -/* -- see zlib.h -- */ -z_off_t ZEXPORT gztell(gzFile file) { - z_off64_t ret; - - ret = gztell64(file); - return ret == (z_off_t)ret ? (z_off_t)ret : -1; -} - -/* -- see zlib.h -- */ -z_off64_t ZEXPORT gzoffset64(gzFile file) { - z_off64_t offset; - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return -1; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return -1; - - /* compute and return effective offset in file */ - offset = LSEEK(state->fd, 0, SEEK_CUR); - if (offset == -1) - return -1; - if (state->mode == GZ_READ) /* reading */ - offset -= state->strm.avail_in; /* don't count buffered input */ - return offset; -} - -/* -- see zlib.h -- */ -z_off_t ZEXPORT gzoffset(gzFile file) { - z_off64_t ret; - - ret = gzoffset64(file); - return ret == (z_off_t)ret ? (z_off_t)ret : -1; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzeof(gzFile file) { - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return 0; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return 0; - - /* return end-of-file state */ - return state->mode == GZ_READ ? state->past : 0; -} - -/* -- see zlib.h -- */ -const char * ZEXPORT gzerror(gzFile file, int *errnum) { - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return NULL; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return NULL; - - /* return error information */ - if (errnum != NULL) - *errnum = state->err; - return state->err == Z_MEM_ERROR ? "out of memory" : - (state->msg == NULL ? "" : state->msg); -} - -/* -- see zlib.h -- */ -void ZEXPORT gzclearerr(gzFile file) { - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return; - - /* clear error and end-of-file */ - if (state->mode == GZ_READ) { - state->eof = 0; - state->past = 0; - } - gz_error(state, Z_OK, NULL); -} - -/* Create an error message in allocated memory and set state->err and - state->msg accordingly. Free any previous error message already there. Do - not try to free or allocate space if the error is Z_MEM_ERROR (out of - memory). Simply save the error message as a static string. If there is an - allocation failure constructing the error message, then convert the error to - out of memory. */ -void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) { - /* free previously allocated message and clear */ - if (state->msg != NULL) { - if (state->err != Z_MEM_ERROR) - free(state->msg); - state->msg = NULL; - } - - /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */ - if (err != Z_OK && err != Z_BUF_ERROR) - state->x.have = 0; - - /* set error code, and if no message, then done */ - state->err = err; - if (msg == NULL) - return; - - /* for an out of memory error, return literal string when requested */ - if (err == Z_MEM_ERROR) - return; - - /* construct error message with path */ - if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) == - NULL) { - state->err = Z_MEM_ERROR; - return; - } -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - (void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3, - "%s%s%s", state->path, ": ", msg); -#else - strcpy(state->msg, state->path); - strcat(state->msg, ": "); - strcat(state->msg, msg); -#endif -} - -/* portably return maximum value for an int (when limits.h presumed not - available) -- we need to do this to cover cases where 2's complement not - used, since C standard permits 1's complement and sign-bit representations, - otherwise we could just use ((unsigned)-1) >> 1 */ -unsigned ZLIB_INTERNAL gz_intmax(void) { -#ifdef INT_MAX - return INT_MAX; -#else - unsigned p = 1, q; - do { - q = p; - p <<= 1; - p++; - } while (p > q); - return q >> 1; -#endif -} diff --git a/code/zlib-1.3.1/gzread.c b/code/zlib-1.3.1/gzread.c deleted file mode 100644 index 4168cbc8..00000000 --- a/code/zlib-1.3.1/gzread.c +++ /dev/null @@ -1,602 +0,0 @@ -/* gzread.c -- zlib functions for reading gzip files - * Copyright (C) 2004-2017 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "gzguts.h" - -/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from - state->fd, and update state->eof, state->err, and state->msg as appropriate. - This function needs to loop on read(), since read() is not guaranteed to - read the number of bytes requested, depending on the type of descriptor. */ -local int gz_load(gz_statep state, unsigned char *buf, unsigned len, - unsigned *have) { - int ret; - unsigned get, max = ((unsigned)-1 >> 2) + 1; - - *have = 0; - do { - get = len - *have; - if (get > max) - get = max; - ret = read(state->fd, buf + *have, get); - if (ret <= 0) - break; - *have += (unsigned)ret; - } while (*have < len); - if (ret < 0) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; - } - if (ret == 0) - state->eof = 1; - return 0; -} - -/* Load up input buffer and set eof flag if last data loaded -- return -1 on - error, 0 otherwise. Note that the eof flag is set when the end of the input - file is reached, even though there may be unused data in the buffer. Once - that data has been used, no more attempts will be made to read the file. - If strm->avail_in != 0, then the current data is moved to the beginning of - the input buffer, and then the remainder of the buffer is loaded with the - available data from the input file. */ -local int gz_avail(gz_statep state) { - unsigned got; - z_streamp strm = &(state->strm); - - if (state->err != Z_OK && state->err != Z_BUF_ERROR) - return -1; - if (state->eof == 0) { - if (strm->avail_in) { /* copy what's there to the start */ - unsigned char *p = state->in; - unsigned const char *q = strm->next_in; - unsigned n = strm->avail_in; - do { - *p++ = *q++; - } while (--n); - } - if (gz_load(state, state->in + strm->avail_in, - state->size - strm->avail_in, &got) == -1) - return -1; - strm->avail_in += got; - strm->next_in = state->in; - } - return 0; -} - -/* Look for gzip header, set up for inflate or copy. state->x.have must be 0. - If this is the first time in, allocate required memory. state->how will be - left unchanged if there is no more input data available, will be set to COPY - if there is no gzip header and direct copying will be performed, or it will - be set to GZIP for decompression. If direct copying, then leftover input - data from the input buffer will be copied to the output buffer. In that - case, all further file reads will be directly to either the output buffer or - a user buffer. If decompressing, the inflate state will be initialized. - gz_look() will return 0 on success or -1 on failure. */ -local int gz_look(gz_statep state) { - z_streamp strm = &(state->strm); - - /* allocate read buffers and inflate memory */ - if (state->size == 0) { - /* allocate buffers */ - state->in = (unsigned char *)malloc(state->want); - state->out = (unsigned char *)malloc(state->want << 1); - if (state->in == NULL || state->out == NULL) { - free(state->out); - free(state->in); - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - state->size = state->want; - - /* allocate inflate memory */ - state->strm.zalloc = Z_NULL; - state->strm.zfree = Z_NULL; - state->strm.opaque = Z_NULL; - state->strm.avail_in = 0; - state->strm.next_in = Z_NULL; - if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) { /* gunzip */ - free(state->out); - free(state->in); - state->size = 0; - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - } - - /* get at least the magic bytes in the input buffer */ - if (strm->avail_in < 2) { - if (gz_avail(state) == -1) - return -1; - if (strm->avail_in == 0) - return 0; - } - - /* look for gzip magic bytes -- if there, do gzip decoding (note: there is - a logical dilemma here when considering the case of a partially written - gzip file, to wit, if a single 31 byte is written, then we cannot tell - whether this is a single-byte file, or just a partially written gzip - file -- for here we assume that if a gzip file is being written, then - the header will be written in a single operation, so that reading a - single byte is sufficient indication that it is not a gzip file) */ - if (strm->avail_in > 1 && - strm->next_in[0] == 31 && strm->next_in[1] == 139) { - inflateReset(strm); - state->how = GZIP; - state->direct = 0; - return 0; - } - - /* no gzip header -- if we were decoding gzip before, then this is trailing - garbage. Ignore the trailing garbage and finish. */ - if (state->direct == 0) { - strm->avail_in = 0; - state->eof = 1; - state->x.have = 0; - return 0; - } - - /* doing raw i/o, copy any leftover input to output -- this assumes that - the output buffer is larger than the input buffer, which also assures - space for gzungetc() */ - state->x.next = state->out; - memcpy(state->x.next, strm->next_in, strm->avail_in); - state->x.have = strm->avail_in; - strm->avail_in = 0; - state->how = COPY; - state->direct = 1; - return 0; -} - -/* Decompress from input to the provided next_out and avail_out in the state. - On return, state->x.have and state->x.next point to the just decompressed - data. If the gzip stream completes, state->how is reset to LOOK to look for - the next gzip stream or raw data, once state->x.have is depleted. Returns 0 - on success, -1 on failure. */ -local int gz_decomp(gz_statep state) { - int ret = Z_OK; - unsigned had; - z_streamp strm = &(state->strm); - - /* fill output buffer up to end of deflate stream */ - had = strm->avail_out; - do { - /* get more input for inflate() */ - if (strm->avail_in == 0 && gz_avail(state) == -1) - return -1; - if (strm->avail_in == 0) { - gz_error(state, Z_BUF_ERROR, "unexpected end of file"); - break; - } - - /* decompress and handle errors */ - ret = inflate(strm, Z_NO_FLUSH); - if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) { - gz_error(state, Z_STREAM_ERROR, - "internal error: inflate stream corrupt"); - return -1; - } - if (ret == Z_MEM_ERROR) { - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - if (ret == Z_DATA_ERROR) { /* deflate stream invalid */ - gz_error(state, Z_DATA_ERROR, - strm->msg == NULL ? "compressed data error" : strm->msg); - return -1; - } - } while (strm->avail_out && ret != Z_STREAM_END); - - /* update available output */ - state->x.have = had - strm->avail_out; - state->x.next = strm->next_out - state->x.have; - - /* if the gzip stream completed successfully, look for another */ - if (ret == Z_STREAM_END) - state->how = LOOK; - - /* good decompression */ - return 0; -} - -/* Fetch data and put it in the output buffer. Assumes state->x.have is 0. - Data is either copied from the input file or decompressed from the input - file depending on state->how. If state->how is LOOK, then a gzip header is - looked for to determine whether to copy or decompress. Returns -1 on error, - otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the - end of the input file has been reached and all data has been processed. */ -local int gz_fetch(gz_statep state) { - z_streamp strm = &(state->strm); - - do { - switch(state->how) { - case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ - if (gz_look(state) == -1) - return -1; - if (state->how == LOOK) - return 0; - break; - case COPY: /* -> COPY */ - if (gz_load(state, state->out, state->size << 1, &(state->x.have)) - == -1) - return -1; - state->x.next = state->out; - return 0; - case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */ - strm->avail_out = state->size << 1; - strm->next_out = state->out; - if (gz_decomp(state) == -1) - return -1; - } - } while (state->x.have == 0 && (!state->eof || strm->avail_in)); - return 0; -} - -/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ -local int gz_skip(gz_statep state, z_off64_t len) { - unsigned n; - - /* skip over len bytes or reach end-of-file, whichever comes first */ - while (len) - /* skip over whatever is in output buffer */ - if (state->x.have) { - n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ? - (unsigned)len : state->x.have; - state->x.have -= n; - state->x.next += n; - state->x.pos += n; - len -= n; - } - - /* output buffer empty -- return if we're at the end of the input */ - else if (state->eof && state->strm.avail_in == 0) - break; - - /* need more data to skip -- load up output buffer */ - else { - /* get more output, looking for header if required */ - if (gz_fetch(state) == -1) - return -1; - } - return 0; -} - -/* Read len bytes into buf from file, or less than len up to the end of the - input. Return the number of bytes read. If zero is returned, either the - end of file was reached, or there was an error. state->err must be - consulted in that case to determine which. */ -local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) { - z_size_t got; - unsigned n; - - /* if len is zero, avoid unnecessary operations */ - if (len == 0) - return 0; - - /* process a skip request */ - if (state->seek) { - state->seek = 0; - if (gz_skip(state, state->skip) == -1) - return 0; - } - - /* get len bytes to buf, or less than len if at the end */ - got = 0; - do { - /* set n to the maximum amount of len that fits in an unsigned int */ - n = (unsigned)-1; - if (n > len) - n = (unsigned)len; - - /* first just try copying data from the output buffer */ - if (state->x.have) { - if (state->x.have < n) - n = state->x.have; - memcpy(buf, state->x.next, n); - state->x.next += n; - state->x.have -= n; - } - - /* output buffer empty -- return if we're at the end of the input */ - else if (state->eof && state->strm.avail_in == 0) { - state->past = 1; /* tried to read past end */ - break; - } - - /* need output data -- for small len or new stream load up our output - buffer */ - else if (state->how == LOOK || n < (state->size << 1)) { - /* get more output, looking for header if required */ - if (gz_fetch(state) == -1) - return 0; - continue; /* no progress yet -- go back to copy above */ - /* the copy above assures that we will leave with space in the - output buffer, allowing at least one gzungetc() to succeed */ - } - - /* large len -- read directly into user buffer */ - else if (state->how == COPY) { /* read directly */ - if (gz_load(state, (unsigned char *)buf, n, &n) == -1) - return 0; - } - - /* large len -- decompress directly into user buffer */ - else { /* state->how == GZIP */ - state->strm.avail_out = n; - state->strm.next_out = (unsigned char *)buf; - if (gz_decomp(state) == -1) - return 0; - n = state->x.have; - state->x.have = 0; - } - - /* update progress */ - len -= n; - buf = (char *)buf + n; - got += n; - state->x.pos += n; - } while (len); - - /* return number of bytes read into user buffer */ - return got; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) { - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* since an int is returned, make sure len fits in one, otherwise return - with an error (this avoids a flaw in the interface) */ - if ((int)len < 0) { - gz_error(state, Z_STREAM_ERROR, "request does not fit in an int"); - return -1; - } - - /* read len or fewer bytes to buf */ - len = (unsigned)gz_read(state, buf, len); - - /* check for an error */ - if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR) - return -1; - - /* return the number of bytes read (this is assured to fit in an int) */ - return (int)len; -} - -/* -- see zlib.h -- */ -z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) { - z_size_t len; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return 0; - state = (gz_statep)file; - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return 0; - - /* compute bytes to read -- error on overflow */ - len = nitems * size; - if (size && len / size != nitems) { - gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); - return 0; - } - - /* read len or fewer bytes to buf, return the number of full items read */ - return len ? gz_read(state, buf, len) / size : 0; -} - -/* -- see zlib.h -- */ -#ifdef Z_PREFIX_SET -# undef z_gzgetc -#else -# undef gzgetc -#endif -int ZEXPORT gzgetc(gzFile file) { - unsigned char buf[1]; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* try output buffer (no need to check for skip request) */ - if (state->x.have) { - state->x.have--; - state->x.pos++; - return *(state->x.next)++; - } - - /* nothing there -- try gz_read() */ - return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; -} - -int ZEXPORT gzgetc_(gzFile file) { - return gzgetc(file); -} - -/* -- see zlib.h -- */ -int ZEXPORT gzungetc(int c, gzFile file) { - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* in case this was just opened, set up the input buffer */ - if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) - (void)gz_look(state); - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* process a skip request */ - if (state->seek) { - state->seek = 0; - if (gz_skip(state, state->skip) == -1) - return -1; - } - - /* can't push EOF */ - if (c < 0) - return -1; - - /* if output buffer empty, put byte at end (allows more pushing) */ - if (state->x.have == 0) { - state->x.have = 1; - state->x.next = state->out + (state->size << 1) - 1; - state->x.next[0] = (unsigned char)c; - state->x.pos--; - state->past = 0; - return c; - } - - /* if no room, give up (must have already done a gzungetc()) */ - if (state->x.have == (state->size << 1)) { - gz_error(state, Z_DATA_ERROR, "out of room to push characters"); - return -1; - } - - /* slide output data if needed and insert byte before existing data */ - if (state->x.next == state->out) { - unsigned char *src = state->out + state->x.have; - unsigned char *dest = state->out + (state->size << 1); - while (src > state->out) - *--dest = *--src; - state->x.next = dest; - } - state->x.have++; - state->x.next--; - state->x.next[0] = (unsigned char)c; - state->x.pos--; - state->past = 0; - return c; -} - -/* -- see zlib.h -- */ -char * ZEXPORT gzgets(gzFile file, char *buf, int len) { - unsigned left, n; - char *str; - unsigned char *eol; - gz_statep state; - - /* check parameters and get internal structure */ - if (file == NULL || buf == NULL || len < 1) - return NULL; - state = (gz_statep)file; - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return NULL; - - /* process a skip request */ - if (state->seek) { - state->seek = 0; - if (gz_skip(state, state->skip) == -1) - return NULL; - } - - /* copy output bytes up to new line or len - 1, whichever comes first -- - append a terminating zero to the string (we don't check for a zero in - the contents, let the user worry about that) */ - str = buf; - left = (unsigned)len - 1; - if (left) do { - /* assure that something is in the output buffer */ - if (state->x.have == 0 && gz_fetch(state) == -1) - return NULL; /* error */ - if (state->x.have == 0) { /* end of file */ - state->past = 1; /* read past end */ - break; /* return what we have */ - } - - /* look for end-of-line in current output buffer */ - n = state->x.have > left ? left : state->x.have; - eol = (unsigned char *)memchr(state->x.next, '\n', n); - if (eol != NULL) - n = (unsigned)(eol - state->x.next) + 1; - - /* copy through end-of-line, or remainder if not found */ - memcpy(buf, state->x.next, n); - state->x.have -= n; - state->x.next += n; - state->x.pos += n; - left -= n; - buf += n; - } while (left && eol == NULL); - - /* return terminated string, or if nothing, end of file */ - if (buf == str) - return NULL; - buf[0] = 0; - return str; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzdirect(gzFile file) { - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return 0; - state = (gz_statep)file; - - /* if the state is not known, but we can find out, then do so (this is - mainly for right after a gzopen() or gzdopen()) */ - if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) - (void)gz_look(state); - - /* return 1 if transparent, 0 if processing a gzip stream */ - return state->direct; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzclose_r(gzFile file) { - int ret, err; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - - /* check that we're reading */ - if (state->mode != GZ_READ) - return Z_STREAM_ERROR; - - /* free memory and close file */ - if (state->size) { - inflateEnd(&(state->strm)); - free(state->out); - free(state->in); - } - err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK; - gz_error(state, Z_OK, NULL); - free(state->path); - ret = close(state->fd); - free(state); - return ret ? Z_ERRNO : err; -} diff --git a/code/zlib-1.3.1/gzwrite.c b/code/zlib-1.3.1/gzwrite.c deleted file mode 100644 index 435b4621..00000000 --- a/code/zlib-1.3.1/gzwrite.c +++ /dev/null @@ -1,631 +0,0 @@ -/* gzwrite.c -- zlib functions for writing gzip files - * Copyright (C) 2004-2019 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "gzguts.h" - -/* Initialize state for writing a gzip file. Mark initialization by setting - state->size to non-zero. Return -1 on a memory allocation failure, or 0 on - success. */ -local int gz_init(gz_statep state) { - int ret; - z_streamp strm = &(state->strm); - - /* allocate input buffer (double size for gzprintf) */ - state->in = (unsigned char *)malloc(state->want << 1); - if (state->in == NULL) { - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - - /* only need output buffer and deflate state if compressing */ - if (!state->direct) { - /* allocate output buffer */ - state->out = (unsigned char *)malloc(state->want); - if (state->out == NULL) { - free(state->in); - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - - /* allocate deflate memory, set up for gzip compression */ - strm->zalloc = Z_NULL; - strm->zfree = Z_NULL; - strm->opaque = Z_NULL; - ret = deflateInit2(strm, state->level, Z_DEFLATED, - MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); - if (ret != Z_OK) { - free(state->out); - free(state->in); - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - strm->next_in = NULL; - } - - /* mark state as initialized */ - state->size = state->want; - - /* initialize write buffer if compressing */ - if (!state->direct) { - strm->avail_out = state->size; - strm->next_out = state->out; - state->x.next = strm->next_out; - } - return 0; -} - -/* Compress whatever is at avail_in and next_in and write to the output file. - Return -1 if there is an error writing to the output file or if gz_init() - fails to allocate memory, otherwise 0. flush is assumed to be a valid - deflate() flush value. If flush is Z_FINISH, then the deflate() state is - reset to start a new gzip stream. If gz->direct is true, then simply write - to the output file without compressing, and ignore flush. */ -local int gz_comp(gz_statep state, int flush) { - int ret, writ; - unsigned have, put, max = ((unsigned)-1 >> 2) + 1; - z_streamp strm = &(state->strm); - - /* allocate memory if this is the first time through */ - if (state->size == 0 && gz_init(state) == -1) - return -1; - - /* write directly if requested */ - if (state->direct) { - while (strm->avail_in) { - put = strm->avail_in > max ? max : strm->avail_in; - writ = write(state->fd, strm->next_in, put); - if (writ < 0) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; - } - strm->avail_in -= (unsigned)writ; - strm->next_in += writ; - } - return 0; - } - - /* check for a pending reset */ - if (state->reset) { - /* don't start a new gzip member unless there is data to write */ - if (strm->avail_in == 0) - return 0; - deflateReset(strm); - state->reset = 0; - } - - /* run deflate() on provided input until it produces no more output */ - ret = Z_OK; - do { - /* write out current buffer contents if full, or if flushing, but if - doing Z_FINISH then don't write until we get to Z_STREAM_END */ - if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && - (flush != Z_FINISH || ret == Z_STREAM_END))) { - while (strm->next_out > state->x.next) { - put = strm->next_out - state->x.next > (int)max ? max : - (unsigned)(strm->next_out - state->x.next); - writ = write(state->fd, state->x.next, put); - if (writ < 0) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; - } - state->x.next += writ; - } - if (strm->avail_out == 0) { - strm->avail_out = state->size; - strm->next_out = state->out; - state->x.next = state->out; - } - } - - /* compress */ - have = strm->avail_out; - ret = deflate(strm, flush); - if (ret == Z_STREAM_ERROR) { - gz_error(state, Z_STREAM_ERROR, - "internal error: deflate stream corrupt"); - return -1; - } - have -= strm->avail_out; - } while (have); - - /* if that completed a deflate stream, allow another to start */ - if (flush == Z_FINISH) - state->reset = 1; - - /* all done, no errors */ - return 0; -} - -/* Compress len zeros to output. Return -1 on a write error or memory - allocation failure by gz_comp(), or 0 on success. */ -local int gz_zero(gz_statep state, z_off64_t len) { - int first; - unsigned n; - z_streamp strm = &(state->strm); - - /* consume whatever's left in the input buffer */ - if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) - return -1; - - /* compress len zeros (len guaranteed > 0) */ - first = 1; - while (len) { - n = GT_OFF(state->size) || (z_off64_t)state->size > len ? - (unsigned)len : state->size; - if (first) { - memset(state->in, 0, n); - first = 0; - } - strm->avail_in = n; - strm->next_in = state->in; - state->x.pos += n; - if (gz_comp(state, Z_NO_FLUSH) == -1) - return -1; - len -= n; - } - return 0; -} - -/* Write len bytes from buf to file. Return the number of bytes written. If - the returned value is less than len, then there was an error. */ -local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) { - z_size_t put = len; - - /* if len is zero, avoid unnecessary operations */ - if (len == 0) - return 0; - - /* allocate memory if this is the first time through */ - if (state->size == 0 && gz_init(state) == -1) - return 0; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return 0; - } - - /* for small len, copy to input buffer, otherwise compress directly */ - if (len < state->size) { - /* copy to input buffer, compress when full */ - do { - unsigned have, copy; - - if (state->strm.avail_in == 0) - state->strm.next_in = state->in; - have = (unsigned)((state->strm.next_in + state->strm.avail_in) - - state->in); - copy = state->size - have; - if (copy > len) - copy = (unsigned)len; - memcpy(state->in + have, buf, copy); - state->strm.avail_in += copy; - state->x.pos += copy; - buf = (const char *)buf + copy; - len -= copy; - if (len && gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - } while (len); - } - else { - /* consume whatever's left in the input buffer */ - if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - - /* directly compress user buffer to file */ - state->strm.next_in = (z_const Bytef *)buf; - do { - unsigned n = (unsigned)-1; - if (n > len) - n = (unsigned)len; - state->strm.avail_in = n; - state->x.pos += n; - if (gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - len -= n; - } while (len); - } - - /* input was all buffered or compressed */ - return put; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) { - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return 0; - state = (gz_statep)file; - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; - - /* since an int is returned, make sure len fits in one, otherwise return - with an error (this avoids a flaw in the interface) */ - if ((int)len < 0) { - gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); - return 0; - } - - /* write len bytes from buf (the return value will fit in an int) */ - return (int)gz_write(state, buf, len); -} - -/* -- see zlib.h -- */ -z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems, - gzFile file) { - z_size_t len; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return 0; - state = (gz_statep)file; - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; - - /* compute bytes to read -- error on overflow */ - len = nitems * size; - if (size && len / size != nitems) { - gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); - return 0; - } - - /* write len bytes to buf, return the number of full items written */ - return len ? gz_write(state, buf, len) / size : 0; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzputc(gzFile file, int c) { - unsigned have; - unsigned char buf[1]; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return -1; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return -1; - } - - /* try writing to input buffer for speed (state->size == 0 if buffer not - initialized) */ - if (state->size) { - if (strm->avail_in == 0) - strm->next_in = state->in; - have = (unsigned)((strm->next_in + strm->avail_in) - state->in); - if (have < state->size) { - state->in[have] = (unsigned char)c; - strm->avail_in++; - state->x.pos++; - return c & 0xff; - } - } - - /* no room in buffer or not initialized, use gz_write() */ - buf[0] = (unsigned char)c; - if (gz_write(state, buf, 1) != 1) - return -1; - return c & 0xff; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzputs(gzFile file, const char *s) { - z_size_t len, put; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return -1; - - /* write string */ - len = strlen(s); - if ((int)len < 0 || (unsigned)len != len) { - gz_error(state, Z_STREAM_ERROR, "string length does not fit in int"); - return -1; - } - put = gz_write(state, s, len); - return put < len ? -1 : (int)len; -} - -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -#include - -/* -- see zlib.h -- */ -int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { - int len; - unsigned left; - char *next; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return Z_STREAM_ERROR; - - /* make sure we have some buffer space */ - if (state->size == 0 && gz_init(state) == -1) - return state->err; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return state->err; - } - - /* do the printf() into the input buffer, put length in len -- the input - buffer is double-sized just for this function, so there is guaranteed to - be state->size bytes available after the current contents */ - if (strm->avail_in == 0) - strm->next_in = state->in; - next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in); - next[state->size - 1] = 0; -#ifdef NO_vsnprintf -# ifdef HAS_vsprintf_void - (void)vsprintf(next, format, va); - for (len = 0; len < state->size; len++) - if (next[len] == 0) break; -# else - len = vsprintf(next, format, va); -# endif -#else -# ifdef HAS_vsnprintf_void - (void)vsnprintf(next, state->size, format, va); - len = strlen(next); -# else - len = vsnprintf(next, state->size, format, va); -# endif -#endif - - /* check that printf() results fit in buffer */ - if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0) - return 0; - - /* update buffer and position, compress first half if past that */ - strm->avail_in += (unsigned)len; - state->x.pos += len; - if (strm->avail_in >= state->size) { - left = strm->avail_in - state->size; - strm->avail_in = state->size; - if (gz_comp(state, Z_NO_FLUSH) == -1) - return state->err; - memmove(state->in, state->in + state->size, left); - strm->next_in = state->in; - strm->avail_in = left; - } - return len; -} - -int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) { - va_list va; - int ret; - - va_start(va, format); - ret = gzvprintf(file, format, va); - va_end(va); - return ret; -} - -#else /* !STDC && !Z_HAVE_STDARG_H */ - -/* -- see zlib.h -- */ -int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3, - int a4, int a5, int a6, int a7, int a8, int a9, int a10, - int a11, int a12, int a13, int a14, int a15, int a16, - int a17, int a18, int a19, int a20) { - unsigned len, left; - char *next; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that can really pass pointer in ints */ - if (sizeof(int) != sizeof(void *)) - return Z_STREAM_ERROR; - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return Z_STREAM_ERROR; - - /* make sure we have some buffer space */ - if (state->size == 0 && gz_init(state) == -1) - return state->error; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return state->error; - } - - /* do the printf() into the input buffer, put length in len -- the input - buffer is double-sized just for this function, so there is guaranteed to - be state->size bytes available after the current contents */ - if (strm->avail_in == 0) - strm->next_in = state->in; - next = (char *)(strm->next_in + strm->avail_in); - next[state->size - 1] = 0; -#ifdef NO_snprintf -# ifdef HAS_sprintf_void - sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, - a13, a14, a15, a16, a17, a18, a19, a20); - for (len = 0; len < size; len++) - if (next[len] == 0) - break; -# else - len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, - a12, a13, a14, a15, a16, a17, a18, a19, a20); -# endif -#else -# ifdef HAS_snprintf_void - snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, - a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - len = strlen(next); -# else - len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -# endif -#endif - - /* check that printf() results fit in buffer */ - if (len == 0 || len >= state->size || next[state->size - 1] != 0) - return 0; - - /* update buffer and position, compress first half if past that */ - strm->avail_in += len; - state->x.pos += len; - if (strm->avail_in >= state->size) { - left = strm->avail_in - state->size; - strm->avail_in = state->size; - if (gz_comp(state, Z_NO_FLUSH) == -1) - return state->err; - memmove(state->in, state->in + state->size, left); - strm->next_in = state->in; - strm->avail_in = left; - } - return (int)len; -} - -#endif - -/* -- see zlib.h -- */ -int ZEXPORT gzflush(gzFile file, int flush) { - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return Z_STREAM_ERROR; - - /* check flush parameter */ - if (flush < 0 || flush > Z_FINISH) - return Z_STREAM_ERROR; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return state->err; - } - - /* compress remaining data with requested flush */ - (void)gz_comp(state, flush); - return state->err; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzsetparams(gzFile file, int level, int strategy) { - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct) - return Z_STREAM_ERROR; - - /* if no change is requested, then do nothing */ - if (level == state->level && strategy == state->strategy) - return Z_OK; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return state->err; - } - - /* change compression parameters for subsequent input */ - if (state->size) { - /* flush previous input with previous parameters before changing */ - if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1) - return state->err; - deflateParams(strm, level, strategy); - } - state->level = level; - state->strategy = strategy; - return Z_OK; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzclose_w(gzFile file) { - int ret = Z_OK; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - - /* check that we're writing */ - if (state->mode != GZ_WRITE) - return Z_STREAM_ERROR; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - ret = state->err; - } - - /* flush, free memory, and close file */ - if (gz_comp(state, Z_FINISH) == -1) - ret = state->err; - if (state->size) { - if (!state->direct) { - (void)deflateEnd(&(state->strm)); - free(state->out); - } - free(state->in); - } - gz_error(state, Z_OK, NULL); - free(state->path); - if (close(state->fd) == -1) - ret = Z_ERRNO; - free(state); - return ret; -} diff --git a/misc/update-libs.sh b/misc/update-libs.sh index 5485face..6519bfa2 100755 --- a/misc/update-libs.sh +++ b/misc/update-libs.sh @@ -7,7 +7,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" . ${SCRIPT_DIR}/lib-versions.sh ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" -CODE="${ROOT}/code" +CODE="${ROOT}/code/thirdparty" prepare() {