1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
--- openarena-engine-source-0.8.8/Makefile
+++ openarena-engine-source-0.8.8/Makefile
@@ -1406,41 +1406,7 @@
$(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 \
--- openarena-engine-source-0.8.8/code/jpeg-6b/jdatasrc.c
+++ openarena-engine-source-0.8.8/code/jpeg-6b/jdatasrc.c
@@ -15,9 +15,15 @@
*/
/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
-#include "jinclude.h"
-#include "jpeglib.h"
-#include "jerror.h"
+#include <stdio.h>
+#include <string.h>
+#include <jpeglib.h>
+#include <jerror.h>
+#undef METHODDEF
+#define METHODDEF static
+#undef GLOBAL
+#define GLOBAL
+#define SIZEOF(object) ((size_t) sizeof(object))
#ifndef MIN
#define MIN(a, b) ((a)<(b)?(a):(b))
@@ -44,7 +50,7 @@
* before any data is actually read.
*/
-METHODDEF(void)
+METHODDEF void
init_source (j_decompress_ptr cinfo)
{
my_src_ptr src = (my_src_ptr) cinfo->src;
@@ -90,7 +96,7 @@
* the front of the buffer rather than discarding it.
*/
-METHODDEF(boolean)
+METHODDEF boolean
fill_input_buffer (j_decompress_ptr cinfo)
{
my_src_ptr src = (my_src_ptr) cinfo->src;
@@ -129,7 +135,7 @@
* buffer is the application writer's problem.
*/
-METHODDEF(void)
+METHODDEF void
skip_input_data (j_decompress_ptr cinfo, long num_bytes)
{
my_src_ptr src = (my_src_ptr) cinfo->src;
@@ -170,7 +176,7 @@
* for error exit.
*/
-METHODDEF(void)
+METHODDEF void
term_source (j_decompress_ptr cinfo)
{
/* no work necessary here */
@@ -183,8 +189,8 @@
* for closing it after finishing decompression.
*/
-GLOBAL(void)
-jpeg_mem_src (j_decompress_ptr cinfo, unsigned char *inbuf, size_t size)
+GLOBAL void
+jpeg_mem_src (j_decompress_ptr cinfo, unsigned char *inbuf, unsigned long size)
{
my_src_ptr src;
--- openarena-engine-source-0.8.8/code/renderer/tr_image_jpg.c
+++ openarena-engine-source-0.8.8/code/renderer/tr_image_jpg.c
@@ -31,7 +31,7 @@
*/
#define JPEG_INTERNALS
-#include "../jpeg-6b/jpeglib.h"
+#include <jpeglib.h>
void R_LoadJPG( const char *filename, unsigned char **pic, int *width, int *height ) {
/* This struct contains the JPEG decompression parameters and pointers to
@@ -131,7 +131,10 @@
}
memcount = pixelcount * 4;
- row_stride = cinfo.output_width * cinfo.output_components;
+ if (3 == cinfo.output_components)
+ row_stride = cinfo.output_width * 4;
+ else
+ row_stride = cinfo.output_width * cinfo.output_components;
out = ri.Malloc(memcount);
@@ -144,14 +147,26 @@
/* 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.
*/
+ buf = out;
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.
*/
- buf = ((out+(row_stride*cinfo.output_scanline)));
buffer = &buf;
(void) jpeg_read_scanlines(&cinfo, buffer, 1);
+ if (3 == cinfo.output_components) {
+ /* turn RGB into RGBA */
+ int ioffset = cinfo.output_width * 3 - 1;
+ int ooffset = cinfo.output_width * 4 - 1;
+ do {
+ buf[ooffset--] = 255;
+ buf[ooffset--] = buf[ioffset--];
+ buf[ooffset--] = buf[ioffset--];
+ buf[ooffset--] = buf[ioffset--];
+ } while (ioffset > 0);
+ }
+ buf += row_stride;
}
buf = out;
@@ -176,7 +191,7 @@
buf[--dindex] = greyshade;
} while(sindex);
}
- else
+ else if (4 == cinfo.output_components)
{
// clear all the alphas to 255
int i;
|