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 @@
5 elif test "$with_openjpeg" = "yes" -o "$with_openjpeg" = "" ; then
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)
12 - if test "$ac_cv_header_openjpeg_h" = "no"; then
13 + if test "$ac_cv_header_openjpeg_2_0_openjpeg_h" = "no"; then
17 if test "$HAVE_OPENJPEG" = "yes" ; then
18 - LIBS="-lopenjpeg $LIBS"
19 + LIBS="-lopenjp2 $LIBS"
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
30 AC_MSG_ERROR([openjpeg.h not found in $with_openjpeg/include or $with_openjpeg/include/openjpeg-2.0])
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,)
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
39 +++ gdal-1.9.2/frmts/openjpeg/openjpegdataset.cpp 2013-01-07 20:31:31.410092737 +0100
41 /* and when calling openjpeg API from the driver, we have to replace bool by int also */
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 */
50 /* JP2OpenJPEGDataset_Read() */
51 /************************************************************************/
53 -static OPJ_UINT32 JP2OpenJPEGDataset_Read(void* pBuffer, OPJ_UINT32 nBytes,
54 +static OPJ_SIZE_T JP2OpenJPEGDataset_Read(void* pBuffer, OPJ_SIZE_T nBytes,
57 int nRet = VSIFReadL(pBuffer, 1, nBytes, (VSILFILE*)pUserData);
59 /* JP2OpenJPEGDataset_Write() */
60 /************************************************************************/
62 -static OPJ_UINT32 JP2OpenJPEGDataset_Write(void* pBuffer, OPJ_UINT32 nBytes,
63 +static OPJ_SIZE_T JP2OpenJPEGDataset_Write(void* pBuffer, OPJ_SIZE_T nBytes,
66 int nRet = VSIFWriteL(pBuffer, 1, nBytes, (VSILFILE*)pUserData);
68 /* JP2OpenJPEGDataset_Seek() */
69 /************************************************************************/
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)
75 CPLDebug("OPENJPEG", "JP2OpenJPEGDataset_Seek(%d)", nBytes);
77 /* JP2OpenJPEGDataset_Skip() */
78 /************************************************************************/
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)
83 vsi_l_offset nOffset = VSIFTellL((VSILFILE*)pUserData);
86 opj_stream_set_user_data(pStream, poGDS->fp);
88 opj_image_t * psImage = NULL;
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))
95 CPLError(CE_Failure, CPLE_AppDefined, "opj_read_header() failed");
96 opj_destroy_codec(pCodec);
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,
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))
116 CPLError(CE_Failure, CPLE_AppDefined, "opj_read_tile_header() failed");
117 CPLFree(pTempBuffer);
120 JP2OpenJPEGDataset *poGDS = (JP2OpenJPEGDataset *) poDS;
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)
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;
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;
145 - eCodecFormat = CODEC_JP2;
146 + eCodecFormat = OPJ_CODEC_JP2;
148 opj_codec_t* pCodec = opj_create_decompress(eCodecFormat);
151 opj_stream_set_user_data(pStream, fp);
153 opj_image_t * psImage = NULL;
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))
161 CPLError(CE_Failure, CPLE_AppDefined, "opj_read_header() failed");
162 opj_destroy_codec(pCodec);
163 @@ -725,10 +720,21 @@
167 + opj_codestream_info_v2_t *csinfo = opj_get_cstr_info(pCodec);
168 + if (csinfo == NULL)
170 + opj_destroy_codec(pCodec);
171 + opj_stream_destroy(pStream);
172 + opj_image_destroy(psImage);
176 + nTileW = csinfo->tdx;
177 + nTileH = csinfo->tdy;
178 + opj_destroy_cstr_info(&csinfo);
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);
188 eDataType = GDT_UInt16;
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);
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;
213 CPLError(CE_Warning, CPLE_NotSupported,
215 if (strlen(pszFilename) > 4 &&
216 EQUAL(pszFilename + strlen(pszFilename) - 4, ".JP2"))
218 - eCodecFormat = CODEC_JP2;
219 + eCodecFormat = OPJ_CODEC_JP2;
223 @@ -971,19 +977,19 @@
224 if (nYSize < nBlockYSize)
225 nBlockYSize = nYSize;
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"))
233 + eProgOrder = OPJ_LRCP;
234 else if (EQUAL(pszPROGORDER, "RLCP"))
236 + eProgOrder = OPJ_RLCP;
237 else if (EQUAL(pszPROGORDER, "RPCL"))
239 + eProgOrder = OPJ_RPCL;
240 else if (EQUAL(pszPROGORDER, "PCRL"))
242 + eProgOrder = OPJ_PCRL;
243 else if (EQUAL(pszPROGORDER, "CPRL"))
245 + eProgOrder = OPJ_CPRL;
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);
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,
257 CPLFree(pasBandParams);