]>
Commit | Line | Data |
---|---|---|
c9c08280 JB |
1 | --- gdal-1.9.2/configure.in.orig 2013-01-06 15:03:02.347950440 +0100 |
2 | +++ gdal-1.9.2/configure.in 2013-01-06 15:06:03.784613325 +0100 | |
3 | @@ -1644,20 +1644,20 @@ | |
4 | ||
5 | elif test "$with_openjpeg" = "yes" -o "$with_openjpeg" = "" ; then | |
6 | ||
7 | - AC_CHECK_LIB(openjpeg,opj_decode_tile_data,HAVE_OPENJPEG=yes,HAVE_OPENJPEG=no,) | |
8 | - AC_CHECK_HEADERS(openjpeg.h) | |
9 | + AC_CHECK_LIB(openjp2,opj_decode_tile_data,HAVE_OPENJPEG=yes,HAVE_OPENJPEG=no,) | |
10 | + AC_CHECK_HEADERS(openjpeg-2.0/openjpeg.h) | |
11 | ||
12 | - if test "$ac_cv_header_openjpeg_h" = "no"; then | |
13 | + if test "$ac_cv_header_openjpeg_2_0_openjpeg_h" = "no"; then | |
14 | HAVE_OPENJPEG=no | |
15 | fi | |
16 | ||
17 | if test "$HAVE_OPENJPEG" = "yes" ; then | |
18 | - LIBS="-lopenjpeg $LIBS" | |
19 | + LIBS="-lopenjp2 $LIBS" | |
20 | fi | |
21 | else | |
22 | ||
23 | HAVE_OPENJPEG=yes | |
24 | - LIBS="-L$with_openjpeg -L$with_openjpeg/lib -lopenjpeg $LIBS" | |
25 | + LIBS="-L$with_openjpeg -L$with_openjpeg/lib -lopenjp2 $LIBS" | |
26 | if test -r $with_openjpeg/include/openjpeg-2.0/openjpeg.h ; then | |
27 | EXTRA_INCLUDES="-I$with_openjpeg/include/openjpeg-2.0 $EXTRA_INCLUDES" | |
28 | elif test -r $with_openjpeg/include/openjpeg.h ; then | |
29 | @@ -1668,7 +1668,7 @@ | |
30 | AC_MSG_ERROR([openjpeg.h not found in $with_openjpeg/include or $with_openjpeg/include/openjpeg-2.0]) | |
31 | fi | |
32 | ||
33 | - AC_CHECK_LIB(openjpeg,opj_decode_tile_data,HAVE_OPENJPEG=yes,HAVE_OPENJPEG=no,) | |
34 | + AC_CHECK_LIB(openjp2,opj_decode_tile_data,HAVE_OPENJPEG=yes,HAVE_OPENJPEG=no,) | |
35 | ||
36 | if test "$HAVE_OPENJPEG" = "yes" ; then | |
37 | AC_MSG_NOTICE([using OpenJPEG library from $with_openjpeg.]) | |
38 | --- gdal-1.9.2/frmts/openjpeg/openjpegdataset.cpp.orig 2012-10-09 02:58:27.000000000 +0200 | |
2d0a5069 | 39 | +++ gdal-1.9.2/frmts/openjpeg/openjpegdataset.cpp 2013-01-07 20:31:31.410092737 +0100 |
c9c08280 JB |
40 | @@ -37,7 +37,7 @@ |
41 | /* and when calling openjpeg API from the driver, we have to replace bool by int also */ | |
42 | #define bool int | |
43 | #define GDAL_OPENJPEG_BOOL int | |
44 | -#include <openjpeg.h> | |
45 | +#include <openjpeg-2.0/openjpeg.h> | |
46 | #undef bool /* undef now, so that later includes are happy */ | |
47 | ||
48 | #include "gdal_pam.h" | |
2d0a5069 JB |
49 | @@ -77,7 +77,7 @@ |
50 | /* JP2OpenJPEGDataset_Read() */ | |
51 | /************************************************************************/ | |
52 | ||
53 | -static OPJ_UINT32 JP2OpenJPEGDataset_Read(void* pBuffer, OPJ_UINT32 nBytes, | |
54 | +static OPJ_SIZE_T JP2OpenJPEGDataset_Read(void* pBuffer, OPJ_SIZE_T nBytes, | |
55 | void *pUserData) | |
56 | { | |
57 | int nRet = VSIFReadL(pBuffer, 1, nBytes, (VSILFILE*)pUserData); | |
58 | @@ -93,7 +93,7 @@ | |
59 | /* JP2OpenJPEGDataset_Write() */ | |
60 | /************************************************************************/ | |
61 | ||
62 | -static OPJ_UINT32 JP2OpenJPEGDataset_Write(void* pBuffer, OPJ_UINT32 nBytes, | |
63 | +static OPJ_SIZE_T JP2OpenJPEGDataset_Write(void* pBuffer, OPJ_SIZE_T nBytes, | |
64 | void *pUserData) | |
65 | { | |
66 | int nRet = VSIFWriteL(pBuffer, 1, nBytes, (VSILFILE*)pUserData); | |
c9c08280 JB |
67 | @@ -107,7 +107,7 @@ |
68 | /* JP2OpenJPEGDataset_Seek() */ | |
69 | /************************************************************************/ | |
70 | ||
71 | -static GDAL_OPENJPEG_BOOL JP2OpenJPEGDataset_Seek(OPJ_SIZE_T nBytes, void * pUserData) | |
72 | +static GDAL_OPENJPEG_BOOL JP2OpenJPEGDataset_Seek(OPJ_OFF_T nBytes, void * pUserData) | |
73 | { | |
74 | #ifdef DEBUG | |
75 | CPLDebug("OPENJPEG", "JP2OpenJPEGDataset_Seek(%d)", nBytes); | |
76 | @@ -119,7 +119,7 @@ | |
77 | /* JP2OpenJPEGDataset_Skip() */ | |
78 | /************************************************************************/ | |
79 | ||
80 | -static OPJ_SIZE_T JP2OpenJPEGDataset_Skip(OPJ_SIZE_T nBytes, void * pUserData) | |
81 | +static OPJ_OFF_T JP2OpenJPEGDataset_Skip(OPJ_OFF_T nBytes, void * pUserData) | |
82 | { | |
83 | vsi_l_offset nOffset = VSIFTellL((VSILFILE*)pUserData); | |
84 | nOffset += nBytes; | |
85 | @@ -332,10 +332,7 @@ | |
86 | opj_stream_set_user_data(pStream, poGDS->fp); | |
87 | ||
88 | opj_image_t * psImage = NULL; | |
89 | - OPJ_INT32 nX0,nY0; | |
90 | - OPJ_UINT32 nTileW,nTileH,nTilesX,nTilesY; | |
91 | - if(!opj_read_header(pCodec, &psImage, &nX0, &nY0, &nTileW, &nTileH, | |
92 | - &nTilesX, &nTilesY, pStream)) | |
93 | + if(!opj_read_header(pStream, pCodec, &psImage)) | |
94 | { | |
95 | CPLError(CE_Failure, CPLE_AppDefined, "opj_read_header() failed"); | |
96 | opj_destroy_codec(pCodec); | |
97 | @@ -343,7 +340,7 @@ | |
98 | return CE_Failure; | |
99 | } | |
100 | ||
101 | - if (!opj_set_decode_area(pCodec, | |
102 | + if (!opj_set_decode_area(pCodec, psImage, | |
103 | nBlockXOff * nBlockXSize, | |
104 | nBlockYOff * nBlockYSize, | |
105 | nBlockXOff * nBlockXSize + nWidthToRead, | |
106 | @@ -378,9 +375,9 @@ | |
107 | ||
108 | do | |
109 | { | |
110 | - if (!opj_read_tile_header(pCodec, &nTileIndex, &nRequiredSize, | |
111 | + if (!opj_read_tile_header(pCodec, pStream, &nTileIndex, &nRequiredSize, | |
112 | &nTileX0, &nTileY0, &nTileX1, &nTileY1, | |
113 | - &nCompCount, &bDataToUncompress, pStream)) | |
114 | + &nCompCount, &bDataToUncompress)) | |
115 | { | |
116 | CPLError(CE_Failure, CPLE_AppDefined, "opj_read_tile_header() failed"); | |
117 | CPLFree(pTempBuffer); | |
118 | @@ -494,7 +491,7 @@ | |
119 | { | |
120 | JP2OpenJPEGDataset *poGDS = (JP2OpenJPEGDataset *) poDS; | |
121 | ||
122 | - if (poGDS->eColorSpace == CLRSPC_GRAY) | |
123 | + if (poGDS->eColorSpace == OPJ_CLRSPC_GRAY) | |
124 | return GCI_GrayIndex; | |
125 | else if (poGDS->nBands == 3 || poGDS->nBands == 4) | |
126 | { | |
127 | @@ -541,8 +538,8 @@ | |
128 | adfGeoTransform[4] = 0.0; | |
129 | adfGeoTransform[5] = 1.0; | |
130 | bLoadingOtherBands = FALSE; | |
131 | - eCodecFormat = CODEC_UNKNOWN; | |
132 | - eColorSpace = CLRSPC_UNKNOWN; | |
133 | + eCodecFormat = OPJ_CODEC_UNKNOWN; | |
134 | + eColorSpace = OPJ_CLRSPC_UNKNOWN; | |
135 | bIs420 = FALSE; | |
136 | pFullBuffer = NULL; | |
137 | } | |
138 | @@ -676,9 +673,9 @@ | |
139 | static const unsigned char jpc_header[] = {0xff,0x4f}; | |
140 | if (memcmp( poOpenInfo->pabyHeader, jpc_header, | |
141 | sizeof(jpc_header) ) == 0) | |
142 | - eCodecFormat = CODEC_J2K; | |
143 | + eCodecFormat = OPJ_CODEC_J2K; | |
144 | else | |
145 | - eCodecFormat = CODEC_JP2; | |
146 | + eCodecFormat = OPJ_CODEC_JP2; | |
147 | ||
148 | opj_codec_t* pCodec = opj_create_decompress(eCodecFormat); | |
149 | ||
150 | @@ -703,10 +700,8 @@ | |
151 | opj_stream_set_user_data(pStream, fp); | |
152 | ||
153 | opj_image_t * psImage = NULL; | |
154 | - OPJ_INT32 nX0,nY0; | |
155 | - OPJ_UINT32 nTileW,nTileH,nTilesX,nTilesY; | |
156 | - if(!opj_read_header(pCodec, &psImage, &nX0, &nY0, &nTileW, &nTileH, | |
157 | - &nTilesX, &nTilesY, pStream)) | |
158 | + OPJ_UINT32 nTileW,nTileH; | |
159 | + if(!opj_read_header(pStream, pCodec, &psImage)) | |
160 | { | |
161 | CPLError(CE_Failure, CPLE_AppDefined, "opj_read_header() failed"); | |
162 | opj_destroy_codec(pCodec); | |
163 | @@ -725,10 +720,21 @@ | |
164 | return NULL; | |
165 | } | |
166 | ||
167 | + opj_codestream_info_v2_t *csinfo = opj_get_cstr_info(pCodec); | |
168 | + if (csinfo == NULL) | |
169 | + { | |
170 | + opj_destroy_codec(pCodec); | |
171 | + opj_stream_destroy(pStream); | |
172 | + opj_image_destroy(psImage); | |
173 | + VSIFCloseL(fp); | |
174 | + return NULL; | |
175 | + } | |
176 | + nTileW = csinfo->tdx; | |
177 | + nTileH = csinfo->tdy; | |
178 | + opj_destroy_cstr_info(&csinfo); | |
179 | + | |
180 | #ifdef DEBUG | |
181 | int i; | |
182 | - CPLDebug("OPENJPEG", "nX0 = %d", nX0); | |
183 | - CPLDebug("OPENJPEG", "nY0 = %d", nY0); | |
184 | CPLDebug("OPENJPEG", "nTileW = %d", nTileW); | |
185 | CPLDebug("OPENJPEG", "nTileH = %d", nTileH); | |
186 | CPLDebug("OPENJPEG", "psImage->x0 = %d", psImage->x0); | |
187 | @@ -780,7 +786,7 @@ | |
188 | eDataType = GDT_UInt16; | |
189 | } | |
190 | ||
191 | - int bIs420 = (psImage->color_space != CLRSPC_SRGB && | |
192 | + int bIs420 = (psImage->color_space != OPJ_CLRSPC_SRGB && | |
193 | eDataType == GDT_Byte && | |
194 | psImage->numcomps == 3 && | |
195 | psImage->comps[1].w == psImage->comps[0].w / 2 && | |
196 | @@ -932,14 +938,14 @@ | |
197 | /* -------------------------------------------------------------------- */ | |
198 | /* Analyze creation options. */ | |
199 | /* -------------------------------------------------------------------- */ | |
200 | - OPJ_CODEC_FORMAT eCodecFormat = CODEC_J2K; | |
201 | + OPJ_CODEC_FORMAT eCodecFormat = OPJ_CODEC_J2K; | |
202 | const char* pszCodec = CSLFetchNameValueDef(papszOptions, "CODEC", NULL); | |
203 | if (pszCodec) | |
204 | { | |
205 | if (EQUAL(pszCodec, "JP2")) | |
206 | - eCodecFormat = CODEC_JP2; | |
207 | + eCodecFormat = OPJ_CODEC_JP2; | |
208 | else if (EQUAL(pszCodec, "J2K")) | |
209 | - eCodecFormat = CODEC_J2K; | |
210 | + eCodecFormat = OPJ_CODEC_J2K; | |
211 | else | |
212 | { | |
213 | CPLError(CE_Warning, CPLE_NotSupported, | |
214 | @@ -952,7 +958,7 @@ | |
215 | if (strlen(pszFilename) > 4 && | |
216 | EQUAL(pszFilename + strlen(pszFilename) - 4, ".JP2")) | |
217 | { | |
218 | - eCodecFormat = CODEC_JP2; | |
219 | + eCodecFormat = OPJ_CODEC_JP2; | |
220 | } | |
221 | } | |
222 | ||
223 | @@ -971,19 +977,19 @@ | |
224 | if (nYSize < nBlockYSize) | |
225 | nBlockYSize = nYSize; | |
226 | ||
227 | - OPJ_PROG_ORDER eProgOrder = LRCP; | |
228 | + OPJ_PROG_ORDER eProgOrder = OPJ_LRCP; | |
229 | const char* pszPROGORDER = | |
230 | CSLFetchNameValueDef(papszOptions, "PROGRESSION", "LRCP"); | |
231 | if (EQUAL(pszPROGORDER, "LRCP")) | |
232 | - eProgOrder = LRCP; | |
233 | + eProgOrder = OPJ_LRCP; | |
234 | else if (EQUAL(pszPROGORDER, "RLCP")) | |
235 | - eProgOrder = RLCP; | |
236 | + eProgOrder = OPJ_RLCP; | |
237 | else if (EQUAL(pszPROGORDER, "RPCL")) | |
238 | - eProgOrder = RPCL; | |
239 | + eProgOrder = OPJ_RPCL; | |
240 | else if (EQUAL(pszPROGORDER, "PCRL")) | |
241 | - eProgOrder = PCRL; | |
242 | + eProgOrder = OPJ_PCRL; | |
243 | else if (EQUAL(pszPROGORDER, "CPRL")) | |
244 | - eProgOrder = CPRL; | |
245 | + eProgOrder = OPJ_CPRL; | |
246 | else | |
247 | { | |
248 | CPLError(CE_Warning, CPLE_NotSupported, | |
249 | @@ -1097,7 +1103,7 @@ | |
250 | opj_set_warning_handler(pCodec, JP2OpenJPEGDataset_WarningCallback,NULL); | |
251 | opj_set_error_handler(pCodec, JP2OpenJPEGDataset_ErrorCallback,NULL); | |
252 | ||
253 | - OPJ_COLOR_SPACE eColorSpace = (bResample) ? CLRSPC_SYCC : (nBands == 3) ? CLRSPC_SRGB : CLRSPC_GRAY; | |
254 | + OPJ_COLOR_SPACE eColorSpace = (bResample) ? OPJ_CLRSPC_SYCC : (nBands == 3) ? OPJ_CLRSPC_SRGB : OPJ_CLRSPC_GRAY; | |
255 | opj_image_t* psImage = opj_image_tile_create(nBands,pasBandParams, | |
256 | eColorSpace); | |
257 | CPLFree(pasBandParams); |