diff -up quake3-1.36/code/jpeg-6b/jmemnobs.c.syslibs quake3-1.36/code/jpeg-6b/jmemnobs.c --- quake3-1.36/code/jpeg-6b/jmemnobs.c.syslibs 2010-05-12 20:55:03.000000000 +0200 +++ quake3-1.36/code/jpeg-6b/jmemnobs.c 2010-05-13 13:11:58.000000000 +0200 @@ -17,11 +17,26 @@ #include "../renderer/tr_local.h" +#ifdef USE_SYSTEM_JPEG +#include <stdio.h> +#include <stdlib.h> +#include <jpeglib.h> + +#undef GLOBAL +#define GLOBAL(x) x +#define FAR + +typedef void * backing_store_ptr; + +#else + #define JPEG_INTERNALS #include "jinclude.h" #include "jpeglib.h" #include "jmemsys.h" /* import the system-dependent declarations */ +#endif + /* * Memory allocation and freeing are controlled by the regular library * routines ri.Malloc() and ri.Free(). @@ -83,7 +98,13 @@ GLOBAL(void) jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, long total_bytes_needed) { +#ifdef USE_SYSTEM_JPEG + fprintf(stderr, + "jmemnobs.c: jpeg_open_backing_store() call, this should never happen!\n"); + exit(1); +#else ERREXIT(cinfo, JERR_NO_BACKING_STORE); +#endif } diff -up quake3-1.36/code/renderer/tr_image_jpg.c.syslibs quake3-1.36/code/renderer/tr_image_jpg.c --- quake3-1.36/code/renderer/tr_image_jpg.c.syslibs 2010-05-12 20:55:06.000000000 +0200 +++ quake3-1.36/code/renderer/tr_image_jpg.c 2010-05-13 14:02:09.000000000 +0200 @@ -30,8 +30,13 @@ Foundation, Inc., 51 Franklin St, Fifth * You may also wish to include "jerror.h". */ +#ifdef USE_SYSTEM_JPEG +#include <jpeglib.h> +#include "jpeg_memsrc.h" +#else #define JPEG_INTERNALS #include "../jpeg-6b/jpeglib.h" +#endif void R_LoadJPG( const char *filename, unsigned char **pic, int *width, int *height ) { /* This struct contains the JPEG decompression parameters and pointers to @@ -62,6 +67,10 @@ void R_LoadJPG( const char *filename, un void *v; } fbuffer; byte *buf; +#ifdef USE_SYSTEM_JPEG + int i,j; + byte *inptr, *outptr; +#endif /* 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. @@ -131,7 +140,7 @@ void R_LoadJPG( const char *filename, un } memcount = pixelcount * 4; - row_stride = cinfo.output_width * cinfo.output_components; + row_stride = cinfo.output_width * 4; out = ri.Malloc(memcount); @@ -152,6 +161,21 @@ void R_LoadJPG( const char *filename, un buf = ((out+(row_stride*cinfo.output_scanline))); buffer = &buf; (void) jpeg_read_scanlines(&cinfo, buffer, 1); +#ifdef USE_SYSTEM_JPEG + /* we have RGB data, we need to expand this out to ARGB */ + inptr = buf + cinfo.output_width * 3 - 1; + outptr = buf + row_stride - 1; + + for (i = 0; i < cinfo.output_width; i++) { + /* endian dependent? maybe for big endian this must be done after the + color/pixel copy? */ + *outptr-- = 255; + for (j = 0; j < 3; j++) { + JOCTET color = *inptr--; + *outptr-- = color; + } + } +#endif } buf = out; diff -up quake3-1.36/Makefile.syslibs quake3-1.36/Makefile --- quake3-1.36/Makefile.syslibs 2010-05-12 20:55:16.000000000 +0200 +++ quake3-1.36/Makefile 2010-05-13 12:58:08.000000000 +0200 @@ -107,6 +107,10 @@ ifndef GENERATE_DEPENDENCIES GENERATE_DEPENDENCIES=1 endif +ifndef USE_SYSTEM_JPEG +USE_SYSTEM_JPEG=1 +endif + ifndef USE_OPENAL USE_OPENAL=1 endif @@ -257,11 +261,14 @@ ifeq ($(PLATFORM),linux) endif endif - BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ - -pipe -DUSE_ICON + BASE_CFLAGS = -DUSE_ICON $(shell sdl-config --cflags) CLIENT_CFLAGS = $(SDL_CFLAGS) SERVER_CFLAGS = + ifeq ($(USE_SYSTEM_JPEG),1) + BASE_CFLAGS += -DUSE_SYSTEM_JPEG=1 -ljpeg + endif + ifeq ($(USE_OPENAL),1) CLIENT_CFLAGS += -DUSE_OPENAL ifeq ($(USE_OPENAL_DLOPEN),1) @@ -1391,41 +1398,7 @@ Q3OBJ = \ $(B)/client/l_script.o \ $(B)/client/l_struct.o \ \ - $(B)/client/jcapimin.o \ - $(B)/client/jcapistd.o \ - $(B)/client/jccoefct.o \ - $(B)/client/jccolor.o \ - $(B)/client/jcdctmgr.o \ - $(B)/client/jchuff.o \ - $(B)/client/jcinit.o \ - $(B)/client/jcmainct.o \ - $(B)/client/jcmarker.o \ - $(B)/client/jcmaster.o \ - $(B)/client/jcomapi.o \ - $(B)/client/jcparam.o \ - $(B)/client/jcphuff.o \ - $(B)/client/jcprepct.o \ - $(B)/client/jcsample.o \ - $(B)/client/jdapimin.o \ - $(B)/client/jdapistd.o \ - $(B)/client/jdatasrc.o \ - $(B)/client/jdcoefct.o \ - $(B)/client/jdcolor.o \ - $(B)/client/jddctmgr.o \ - $(B)/client/jdhuff.o \ - $(B)/client/jdinput.o \ - $(B)/client/jdmainct.o \ - $(B)/client/jdmarker.o \ - $(B)/client/jdmaster.o \ - $(B)/client/jdpostct.o \ - $(B)/client/jdsample.o \ - $(B)/client/jdtrans.o \ - $(B)/client/jerror.o \ - $(B)/client/jfdctflt.o \ - $(B)/client/jidctflt.o \ - $(B)/client/jmemmgr.o \ $(B)/client/jmemnobs.o \ - $(B)/client/jutils.o \ \ $(B)/client/tr_animation.o \ $(B)/client/tr_backend.o \ @@ -1464,6 +1437,46 @@ Q3OBJ = \ $(B)/client/con_log.o \ $(B)/client/sys_main.o +ifneq ($(USE_SYSTEM_JPEG),1) + Q3OBJ += \ + $(B)/client/jcapimin.o \ + $(B)/client/jcapistd.o \ + $(B)/client/jccoefct.o \ + $(B)/client/jccolor.o \ + $(B)/client/jcdctmgr.o \ + $(B)/client/jchuff.o \ + $(B)/client/jcinit.o \ + $(B)/client/jcmainct.o \ + $(B)/client/jcmarker.o \ + $(B)/client/jcmaster.o \ + $(B)/client/jcomapi.o \ + $(B)/client/jcparam.o \ + $(B)/client/jcphuff.o \ + $(B)/client/jcprepct.o \ + $(B)/client/jcsample.o \ + $(B)/client/jdapimin.o \ + $(B)/client/jdapistd.o \ + $(B)/client/jdatasrc.o \ + $(B)/client/jdcoefct.o \ + $(B)/client/jdcolor.o \ + $(B)/client/jddctmgr.o \ + $(B)/client/jdhuff.o \ + $(B)/client/jdinput.o \ + $(B)/client/jdmainct.o \ + $(B)/client/jdmarker.o \ + $(B)/client/jdmaster.o \ + $(B)/client/jdpostct.o \ + $(B)/client/jdsample.o \ + $(B)/client/jdtrans.o \ + $(B)/client/jerror.o \ + $(B)/client/jfdctflt.o \ + $(B)/client/jidctflt.o \ + $(B)/client/jmemmgr.o \ + $(B)/client/jutils.o +else + Q3OBJ += $(B)/client/jpeg_memsrc.o +endif + ifeq ($(ARCH),i386) Q3OBJ += \ $(B)/client/snd_mixa.o \