Changeset 13921
- Timestamp:
- 03/03/08 18:02:42 (4 months ago)
- Files:
-
- branches/1.5/gdal/frmts/jp2kak/jp2kakdataset.cpp (modified) (8 diffs)
- branches/1.5/gdal/frmts/jp2kak/subfile_source.h (modified) (4 diffs)
- branches/1.5/gdal/frmts/jp2kak/vsil_target.h (copied) (copied from sandbox/warmerdam/1.4-esri/gdal/frmts/jp2kak/vsil_target.h)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.5/gdal/frmts/jp2kak/jp2kakdataset.cpp
r13206 r13921 43 43 44 44 #include "subfile_source.h" 45 #include "vsil_target.h" 45 46 46 47 // Application level includes … … 1167 1168 try 1168 1169 { 1169 poRawInput = new subfile_source( poOpenInfo->pszFilename ); 1170 poRawInput = new subfile_source(); 1171 poRawInput->open( poOpenInfo->pszFilename ); 1170 1172 poRawInput->seek( 0 ); 1171 1173 … … 1192 1194 KakaduInitialize(); 1193 1195 1196 /* -------------------------------------------------------------------- */ 1197 /* If we think this should be access via vsil, then open it */ 1198 /* accordingly. */ 1199 /* -------------------------------------------------------------------- */ 1200 if( poOpenInfo->fp == NULL 1201 && poRawInput == NULL 1202 && !bIsJPIP ) 1203 { 1204 try 1205 { 1206 poRawInput = new subfile_source; 1207 poRawInput->open( poOpenInfo->pszFilename ); 1208 poRawInput->seek( 0 ); 1209 } 1210 catch( ... ) 1211 { 1212 return NULL; 1213 } 1214 } 1215 1194 1216 /* -------------------------------------------------------------------- */ 1195 1217 /* If the header is a JP2 header, mark this as a JP2 dataset. */ … … 2353 2375 kdu_codestream oCodeStream; 2354 2376 2377 vsil_target oVSILTarget; 2378 2355 2379 if( !pfnProgress( 0.0, NULL, pProgressData ) ) 2356 2380 return NULL; … … 2358 2382 try 2359 2383 { 2384 oVSILTarget.open( pszFilename, "w" ); 2385 2360 2386 if( bIsJP2 ) 2361 2387 { 2362 2388 #ifdef KAKADU4 2363 family.open( pszFilename);2389 family.open( &oVSILTarget ); 2364 2390 2365 2391 jp2_out.open( &family ); … … 2372 2398 else if( bIsJPX ) 2373 2399 { 2374 jpx_family.open( pszFilename);2400 jpx_family.open( &oVSILTarget ); 2375 2401 2376 2402 jpx_out.open( &jpx_family ); … … 2380 2406 else 2381 2407 { 2382 jpc_out.open( pszFilename ); 2383 poOutputFile = &jpc_out; 2408 poOutputFile = &oVSILTarget; 2384 2409 } 2385 2410 … … 2709 2734 poOutputFile->close(); 2710 2735 } 2736 2737 oVSILTarget.close(); 2711 2738 2712 2739 if( !pfnProgress( 1.0, NULL, pProgressData ) ) branches/1.5/gdal/frmts/jp2kak/subfile_source.h
r10645 r13921 39 39 public: 40 40 subfile_source() { file = NULL; } 41 subfile_source(const char *fname, bool allow_seeks=true)42 { file = NULL; open(fname,allow_seeks); }43 44 45 41 ~subfile_source() { close(); } 46 42 … … 50 46 bool operator!() { return (file == NULL); } 51 47 52 void open(const char *fname , bool allow_seeks=true)48 void open(const char *fname ) 53 49 { 54 50 const char *real_filename; 55 51 close(); 56 52 57 if( sscanf( fname, "J2K_SUBFILE:%d,%d", 58 &subfile_offset, &subfile_size ) != 2 ) 53 if( EQUALN( fname, "J2K_SUBFILE:",12) ) 59 54 { 60 kdu_error e; 61 62 e << "Corrupt subfile definition:" << fname; 63 return; 55 if( sscanf( fname, "J2K_SUBFILE:%d,%d", 56 &subfile_offset, &subfile_size ) != 2 ) 57 { 58 kdu_error e; 59 60 e << "Corrupt subfile definition:" << fname; 61 return; 62 } 63 real_filename = strstr(fname,","); 64 if( real_filename != NULL ) 65 real_filename = strstr(real_filename+1,","); 66 if( real_filename != NULL ) 67 real_filename++; 68 else 69 { 70 kdu_error e; 71 72 e << "Could not find filename in subfile definition." << fname; 73 return; 74 } 75 } 76 else 77 { 78 real_filename = fname; 79 subfile_offset = 0; 80 subfile_size = 0; 64 81 } 65 82 66 real_filename = strstr(fname,","); 67 if( real_filename != NULL ) 68 real_filename = strstr(real_filename+1,","); 69 if( real_filename != NULL ) 70 real_filename++; 71 else 72 { 73 kdu_error e; 74 75 e << "Could not find filename in subfile definition." << fname; 76 return; 77 } 78 79 file = VSIFOpenL( real_filename, "rb" ); 83 file = VSIFOpenL( real_filename, "r"); 80 84 if( file == NULL ) 81 85 { … … 86 90 } 87 91 88 capabilities = KDU_SOURCE_CAP_SEQUENTIAL; 89 if (allow_seeks) 90 capabilities |= KDU_SOURCE_CAP_SEEKABLE; 92 capabilities = KDU_SOURCE_CAP_SEQUENTIAL | KDU_SOURCE_CAP_SEEKABLE; 91 93 92 94 seek_origin = subfile_offset; … … 122 124 { 123 125 if (file == NULL) return -1; 124 kdu_long result = VSIFTell ( file );126 kdu_long result = VSIFTellL( file ); 125 127 if (!absolute) 126 128 result -= seek_origin;
