Merge pull request #192 from coldtobi/fix_183_libjpeg

Fix 183 libjpeg
This commit is contained in:
Robert Beckebans 2014-11-09 11:12:13 +01:00
commit 63b6934ad6
8 changed files with 177 additions and 84 deletions

View file

@ -53,8 +53,8 @@ If you have questions concerning this license or the applicable additional terms
#include "w_wad.h"
#include "d_main.h"
#include "doomdef.h"
#include "../timidity/timidity.h"
#include "../timidity/controls.h"
#include "libs/timidity/timidity.h"
#include "libs/timidity/controls.h"
#include "sound/snd_local.h"

View file

@ -21,6 +21,15 @@ option(FFMPEG
option(ONATIVE
"Optimize for the host CPU" OFF)
option(USE_SYSTEM_ZLIB
"Use the system zlib instead of the bundled one" OFF)
option(USE_SYSTEM_LIBPNG
"Use the system libpng instead of the bundled one" OFF)
option(USE_SYSTEM_LIBJPEG
"Use the system libjpeg instead of the bundled one" OFF)
if(UNIX)
set(OPENAL TRUE)
endif()
@ -183,6 +192,44 @@ endif()
# add_definitions(-DSTANDALONE)
#endif()
if (USE_SYSTEM_ZLIB)
find_package(ZLIB REQUIRED)
endif(USE_SYSTEM_ZLIB)
if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
set(ZLIB_LIBRARY ${ZLIB_LIBRARIES})
else (ZLIB_FOUND)
include_directories("libs/zlib")
set(ZLIB_LIBRARY "" )
endif (ZLIB_FOUND)
if(USE_SYSTEM_LIBPNG)
find_package(PNG REQUIRED)
endif (USE_SYSTEM_LIBPNG)
if (PNG_FOUND)
include_directories(${PNG_INCLUDE_DIRS})
set(PNG_LIBRARY ${PNG_LIBRARIES})
else (PNG_FOUND)
include_directories("libs/png")
set(PNG_LIBRARY "" )
endif (PNG_FOUND)
if(USE_SYSTEM_LIBJPEG)
find_package(JPEG REQUIRED)
endif(USE_SYSTEM_LIBJPEG)
if (JPEG_FOUND)
include_directories(${JPEG_INCLUDE_DIRS})
set(JPEG_LIBRARY ${JPEG_LIBRARIES})
add_definitions(-DUSE_NEWER_JPEG)
else (JPEG_FOUND)
include_directories("libs/jpeg-6")
set(JPEG_LIBRARY "" )
endif (JPEG_FOUND)
add_subdirectory(idlib)
file(GLOB AAS_INCLUDES aas/*.h)
@ -316,75 +363,91 @@ file(GLOB RENDERER_OPENGL_SOURCES renderer/OpenGL/*.cpp)
file(GLOB IRRXML_INCLUDES libs/irrxml/src/*.h)
file(GLOB IRRXML_SOURCES libs/irrxml/src/*.cpp)
set(JPEG_INCLUDES
libs/jpeg-6/jchuff.h
libs/jpeg-6/jconfig.h
libs/jpeg-6/jdct.h
libs/jpeg-6/jdhuff.h
libs/jpeg-6/jerror.h
libs/jpeg-6/jinclude.h
libs/jpeg-6/jmemsys.h
libs/jpeg-6/jmorecfg.h
libs/jpeg-6/jpegint.h
libs/jpeg-6/jpeglib.h
libs/jpeg-6/jversion.h)
set(JPEG_SOURCES
libs/jpeg-6/jcapimin.cpp
libs/jpeg-6/jcapistd.cpp
libs/jpeg-6/jccoefct.cpp
libs/jpeg-6/jccolor.cpp
libs/jpeg-6/jcdctmgr.cpp
libs/jpeg-6/jchuff.cpp
libs/jpeg-6/jcinit.cpp
libs/jpeg-6/jcmainct.cpp
libs/jpeg-6/jcmarker.cpp
libs/jpeg-6/jcmaster.cpp
libs/jpeg-6/jcomapi.cpp
libs/jpeg-6/jcparam.cpp
libs/jpeg-6/jcphuff.cpp
libs/jpeg-6/jcprepct.cpp
libs/jpeg-6/jcsample.cpp
libs/jpeg-6/jctrans.cpp
libs/jpeg-6/jdapimin.cpp
libs/jpeg-6/jdapistd.cpp
libs/jpeg-6/jdatadst.cpp
libs/jpeg-6/jdatasrc.cpp
libs/jpeg-6/jdcoefct.cpp
libs/jpeg-6/jdcolor.cpp
libs/jpeg-6/jddctmgr.cpp
libs/jpeg-6/jdhuff.cpp
libs/jpeg-6/jdinput.cpp
libs/jpeg-6/jdmainct.cpp
libs/jpeg-6/jdmarker.cpp
libs/jpeg-6/jdmaster.cpp
libs/jpeg-6/jdmerge.cpp
libs/jpeg-6/jdphuff.cpp
libs/jpeg-6/jdpostct.cpp
libs/jpeg-6/jdsample.cpp
libs/jpeg-6/jdtrans.cpp
libs/jpeg-6/jerror.cpp
libs/jpeg-6/jfdctflt.cpp
libs/jpeg-6/jfdctfst.cpp
libs/jpeg-6/jfdctint.cpp
libs/jpeg-6/jidctflt.cpp
libs/jpeg-6/jidctfst.cpp
libs/jpeg-6/jidctint.cpp
libs/jpeg-6/jidctred.cpp
#libs/jpeg-6/jload.cpp
libs/jpeg-6/jmemmgr.cpp
libs/jpeg-6/jmemnobs.cpp
#libs/jpeg-6/jpegtran.cpp
libs/jpeg-6/jquant1.cpp
libs/jpeg-6/jquant2.cpp
libs/jpeg-6/jutils.cpp)
file(GLOB PNG_INCLUDES libs/png/*.h)
file(GLOB PNG_SOURCES libs/png/*.c)
if (NOT JPEG_FOUND)
set(JPEG_INCLUDES
libs/jpeg-6/jchuff.h
libs/jpeg-6/jconfig.h
libs/jpeg-6/jdct.h
libs/jpeg-6/jdhuff.h
libs/jpeg-6/jerror.h
libs/jpeg-6/jinclude.h
libs/jpeg-6/jmemsys.h
libs/jpeg-6/jmorecfg.h
libs/jpeg-6/jpegint.h
libs/jpeg-6/jpeglib.h
libs/jpeg-6/jversion.h)
set(JPEG_SOURCES
libs/jpeg-6/jcapimin.cpp
libs/jpeg-6/jcapistd.cpp
libs/jpeg-6/jccoefct.cpp
libs/jpeg-6/jccolor.cpp
libs/jpeg-6/jcdctmgr.cpp
libs/jpeg-6/jchuff.cpp
libs/jpeg-6/jcinit.cpp
libs/jpeg-6/jcmainct.cpp
libs/jpeg-6/jcmarker.cpp
libs/jpeg-6/jcmaster.cpp
libs/jpeg-6/jcomapi.cpp
libs/jpeg-6/jcparam.cpp
libs/jpeg-6/jcphuff.cpp
libs/jpeg-6/jcprepct.cpp
libs/jpeg-6/jcsample.cpp
libs/jpeg-6/jctrans.cpp
libs/jpeg-6/jdapimin.cpp
libs/jpeg-6/jdapistd.cpp
libs/jpeg-6/jdatadst.cpp
libs/jpeg-6/jdatasrc.cpp
libs/jpeg-6/jdcoefct.cpp
libs/jpeg-6/jdcolor.cpp
libs/jpeg-6/jddctmgr.cpp
libs/jpeg-6/jdhuff.cpp
libs/jpeg-6/jdinput.cpp
libs/jpeg-6/jdmainct.cpp
libs/jpeg-6/jdmarker.cpp
libs/jpeg-6/jdmaster.cpp
libs/jpeg-6/jdmerge.cpp
libs/jpeg-6/jdphuff.cpp
libs/jpeg-6/jdpostct.cpp
libs/jpeg-6/jdsample.cpp
libs/jpeg-6/jdtrans.cpp
libs/jpeg-6/jerror.cpp
libs/jpeg-6/jfdctflt.cpp
libs/jpeg-6/jfdctfst.cpp
libs/jpeg-6/jfdctint.cpp
libs/jpeg-6/jidctflt.cpp
libs/jpeg-6/jidctfst.cpp
libs/jpeg-6/jidctint.cpp
libs/jpeg-6/jidctred.cpp
#libs/jpeg-6/jload.cpp
libs/jpeg-6/jmemmgr.cpp
libs/jpeg-6/jmemnobs.cpp
#libs/jpeg-6/jpegtran.cpp
libs/jpeg-6/jquant1.cpp
libs/jpeg-6/jquant2.cpp
libs/jpeg-6/jutils.cpp)
else (NOT JPEG_FOUND)
set(JPEG_INCLUDES "")
set(JPEG_SOURCES "")
endif (NOT JPEG_FOUND)
if (NOT PNG_FOUND)
file(GLOB PNG_INCLUDES libs/png/*.h)
file(GLOB PNG_SOURCES libs/png/*.c)
else (NOT PNG_FOUND)
set(PNG_INCLUDES "")
set(PNG_SOURCES "")
endif (NOT PNG_FOUND)
if (NOT ZLIB_FOUND)
file(GLOB ZLIB_INCLUDES libs/zlib/*.h)
file(GLOB ZLIB_SOURCES libs/zlib/*.c)
else (NOT ZLIB_FOUND)
set(ZLIB_INCLUDES "")
set(ZLIB_SOURCES "")
endif (NOT ZLIB_FOUND)
file(GLOB MINIZIP_INCLUDES libs/zlib/minizip/*.h)
file(GLOB MINIZIP_SOURCES libs/zlib/minizip/*.c libs/zlib/minizip/*.cpp)
@ -1138,7 +1201,7 @@ include_directories(
#libs/openal/include
libs/glew/include
#libs/freetype/include
libs/zlib)
)
#link_directories(
# ${CMAKE_CURRENT_SOURCE_DIR}/libs/curl/lib
@ -1318,6 +1381,9 @@ if(MSVC)
wsock32.lib
${OpenAL_LIBRARIES}
${FFmpeg_LIBRARIES}
${ZLIB_LIBRARY}
${PNG_LIBRARY}
${JPEG_LIBRARY}
)
#CMAKE_BINARY_DIR
@ -1479,6 +1545,9 @@ else()
${SDLx_LIBRARY}
${OPENAL_LIBRARY}
${FFMPEG_LIBRARIES}
${ZLIB_LIBRARY}
${PNG_LIBRARY}
${JPEG_LIBRARY}
)
endif()

View file

@ -28,7 +28,7 @@ If you have questions concerning this license or the applicable additional terms
#ifndef __FILE_SAVEGAME_H__
#define __FILE_SAVEGAME_H__
#include "../libs/zlib/zlib.h"
#include <zlib.h>
// Listing of the types of files within a savegame package
enum saveGameType_t

View file

@ -28,10 +28,10 @@ If you have questions concerning this license or the applicable additional terms
#ifndef __ZIP_H__
#define __ZIP_H__
#include "../libs/zlib/zlib.h"
#include <zlib.h>
// DG: all the zip access stuff from minizip is now in minizip/zip.h
#include "minizip/zip.h"
#include "libs/zlib/minizip/zip.h"
/*

View file

@ -36,7 +36,7 @@ extern idCVar s_noSound;
#define JPEG_INTERNALS
//extern "C" {
#include "../libs/jpeg-6/jpeglib.h"
#include <jpeglib.h>
//}
#include "tr_local.h"
@ -2046,8 +2046,12 @@ struct jpeg_error_mgr jerr;
* the front of the buffer rather than discarding it.
*/
METHODDEF boolean fill_input_buffer( j_decompress_ptr cinfo )
#ifdef USE_NEWER_JPEG
METHODDEF(boolean)
#else
METHODDEF boolean
#endif
fill_input_buffer( j_decompress_ptr cinfo )
{
my_src_ptr src = ( my_src_ptr ) cinfo->src;
int nbytes;
@ -2078,8 +2082,12 @@ METHODDEF boolean fill_input_buffer( j_decompress_ptr cinfo )
* before any data is actually read.
*/
METHODDEF void init_source( j_decompress_ptr cinfo )
#ifdef USE_NEWER_JPEG
METHODDEF(void)
#else
METHODDEF void
#endif
init_source( j_decompress_ptr cinfo )
{
my_src_ptr src = ( my_src_ptr ) cinfo->src;
@ -2102,7 +2110,11 @@ METHODDEF void init_source( j_decompress_ptr cinfo )
* buffer is the application writer's problem.
*/
#ifdef USE_NEWER_JPEG
METHODDEF(void)
#else
METHODDEF void
#endif
skip_input_data( j_decompress_ptr cinfo, long num_bytes )
{
my_src_ptr src = ( my_src_ptr ) cinfo->src;
@ -2138,14 +2150,22 @@ skip_input_data( j_decompress_ptr cinfo, long num_bytes )
* for error exit.
*/
#ifdef USE_NEWER_JPEG
METHODDEF(void)
#else
METHODDEF void
#endif
term_source( j_decompress_ptr cinfo )
{
cinfo = cinfo;
/* no work necessary here */
}
#ifdef USE_NEWER_JPEG
GLOBAL(void)
#else
GLOBAL void
#endif
jpeg_memory_src( j_decompress_ptr cinfo, byte* infile, int size )
{
my_src_ptr src;

View file

@ -49,7 +49,8 @@ void R_LoadImage( const char *name, byte **pic, int *width, int *height, bool ma
* You may also wish to include "jerror.h".
*/
#include "../libs/jpeg-6/jpeglib.h"
#include <jpeglib.h>
#include <jerror.h>
// hooks from jpeg lib to our system
@ -453,7 +454,8 @@ static void LoadJPG( const char* filename, unsigned char** pic, int* width, int*
unsigned char* out;
byte* fbuffer;
byte* bbuf;
int len;
/* 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
@ -467,7 +469,6 @@ static void LoadJPG( const char* filename, unsigned char** pic, int* width, int*
*pic = NULL; // until proven otherwise
}
{
int len;
idFile* f;
f = fileSystem->OpenFileRead( filename );
@ -505,8 +506,11 @@ static void LoadJPG( const char* filename, unsigned char** pic, int* width, int*
/* Step 2: specify data source (eg, a file) */
jpeg_stdio_src( &cinfo, fbuffer );
#ifdef USE_NEWER_JPEG
jpeg_mem_src( &cinfo, fbuffer, len );
#else
jpeg_stdio_src( &cinfo, fbuffer );
#endif
/* Step 3: read file parameters with jpeg_read_header() */
jpeg_read_header( &cinfo, true );
@ -617,7 +621,7 @@ PNG LOADING
extern "C"
{
#include "../libs/png/png.h"
#include <png.h>
static void png_Error( png_structp pngPtr, png_const_charp msg )

View file

@ -29,7 +29,7 @@ If you have questions concerning this license or the applicable additional terms
#include "precompiled.h"
#include "../renderer/Image.h"
//#include "../../renderer/ImageTools/ImageProcess.h"
#include "../libs/jpeg-6/jpeglib.h"
#include <jpeglib.h>
/*
========================

View file

@ -27,7 +27,7 @@ If you have questions concerning this license or the applicable additional terms
*/
#pragma hdrstop
#include "precompiled.h"
#include "../libs/zlib/zlib.h"
#include <zlib.h>
/*
========================