26 static ossimTrace traceDebug(
"ossimJp2Info:debug");
42 str.open( file.
c_str(), std::ios_base::in | std::ios_base::binary);
47 {0x00,0x00,0x00,0x0c,0x6a,0x50,0x20,0x20,0x0d,0x0a,0x87,0x0a};
57 if (box[i] != J2K_SIGNATURE_BOX[i])
104 0xb1, 0x4b, 0xf8, 0xbd,
105 0x08, 0x3d, 0x4b, 0x43,
106 0xa5, 0xae, 0x8c, 0xd7,
107 0xd5, 0xa6, 0xce, 0x03
112 std::streamoff boxPos = str.tellg();
125 <<
"jp2.lbox: " << std::dec << lbox <<
"\n" 126 <<
"jp2.tbox: " << std::hex << tbox << std::dec <<
"\n";
135 if (tbox == UUID_TYPE)
148 if (geotiffUuid[i] != GEOTIFF_UUID[i])
181 if ( kwl.parseStream(in) )
186 out << kwl << std::endl;
202 boxPos += (std::streamoff)xlbox;
206 boxPos += (std::streamoff)lbox;
210 str.seekg(boxPos, std::ios_base::beg);
226 str.read((
char*)&i, 4);
235 str.read((
char*)&i, 8);
246 std::streamoff boxPos = 0;
247 std::streamoff dataPosOfType = 0;
254 std::streamoff offsetToDbox = 0;
258 boxPos = str.tellg();
276 <<
"jp2.lbox: " << std::dec << lbox <<
"\n" 277 <<
"jp2.tbox: " << std::hex << tbox << std::dec <<
"\n";
288 dataPosOfType = boxPos + offsetToDbox;
299 std::streamoff nextBoxPos = boxPos;
302 nextBoxPos+= (std::streamoff)xlbox;
306 nextBoxPos+= (std::streamoff)lbox;
310 str.seekg(nextBoxPos, std::ios_base::beg);
316 return dataPosOfType;
321 std::vector<ossim_uint8>& box )
const 323 std::streamoff boxPos = 0;
331 boxPos =
getBox( type, includeAll, str, box ) ;
344 std::vector<ossim_uint8>& box )
const 346 std::streamoff boxPos = 0;
347 std::streamoff boxPosOfType = 0;
355 std::streamoff offsetToDbox = 0;
359 boxPos = str.tellg();
385 <<
"jp2.lbox: " << std::dec << lbox <<
"\n" 386 <<
"jp2.tbox: " << std::hex << tbox << std::dec <<
"\n";
401 std::streamoff boxSize = 0;
405 str.seekg( 0, std::ios_base::end );
406 boxSize = str.tellg() - boxPos;
408 else if ( lbox == 1 )
416 boxSize -= offsetToDbox;
419 str.seekg( boxPos + offsetToDbox, std::ios_base::beg );
424 box.resize( boxSize );
425 str.read( (
char*)&box.front(), boxSize );
427 catch( std::exception& e )
430 errMsg <<
"ossimJp2Info::getBox caught exception on resize:\n" 431 <<
"Buffer size in bytes: " << boxSize
432 <<
"\n" << e.what() << std::endl;
436 boxPosOfType = boxPos;
446 std::streamoff nextBoxPos = boxPos;
449 nextBoxPos+= (std::streamoff)xlbox;
453 nextBoxPos+= (std::streamoff)lbox;
457 str.seekg(nextBoxPos, std::ios_base::beg);
470 std::streamoff boxPos = 0;
475 boxPos =
getBox( UUID_TYPE,
false, str, box );
480 0xb1, 0x4b, 0xf8, 0xbd,
481 0x08, 0x3d, 0x4b, 0x43,
482 0xa5, 0xae, 0x8c, 0xd7,
483 0xd5, 0xa6, 0xce, 0x03
499 std::streamoff boxPos = 0;
507 std::streamoff dataPosAsoc0 =
findBoxData( ASOC_TBOX_ID, str, asoc0_data_length );
509 if ( dataPosAsoc0 > 0 && asoc0_data_length > 0 )
512 std::streamoff dataPosLbl0 =
findBoxData( LBL_TBOX_ID, str, lbl0_data_length );
514 if ( dataPosLbl0 > 0 && lbl0_data_length > 0 )
516 std::string gmlDataStr;
517 gmlDataStr.resize( lbl0_data_length );
521 str.read( (
char*)&gmlDataStr[0], lbl0_data_length );
524 if ( gmlDataStr.compare( 0, 8,
"gml.data" ) == 0 )
527 str.seekg( dataPosAsoc0, std::ios_base::beg );
530 std::streamoff dataPosAsoc1 =
findBoxData( ASOC_TBOX_ID, str, asoc1_data_length );
532 if ( dataPosAsoc1 > 0 && asoc1_data_length > 0 )
535 std::streamoff dataPosLbl1 =
findBoxData( LBL_TBOX_ID, str, lbl1_data_length );
537 if ( dataPosLbl1 > 0 && lbl1_data_length > 0 )
539 std::string gmlRootInstanceStr;
540 gmlRootInstanceStr.resize( lbl1_data_length );
543 str.read( (
char*)&gmlRootInstanceStr[0], lbl1_data_length );
546 if ( gmlRootInstanceStr.compare( 0, 17,
"gml.root-instance" ) == 0 )
549 str.seekg( dataPosAsoc1, std::ios_base::beg );
551 boxPos =
getBox( XML_TBOX_ID,
false, str, box );
589 boxType =
"jp2_assoc";
594 boxType =
"jp2_label";
679 boxType =
"unhandled";
684 out <<
"jp2.box_type: " << boxType <<
"\n";
virtual std::ostream & print(std::ostream &out) const
Print method.
void setProcessOverviewFlag(bool flag)
Sets the overview flag.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
virtual bool open(const ossimFilename &file)
open method.
Represents serializable keyword/value map.
std::basic_ifstream< char > ifstream
Class for char input file streams.
ossimJp2Info()
default constructor
std::streamoff getBox(const ossim_uint32 type, bool includeAll, std::vector< ossim_uint8 > &box) const
This gets a box of type and stuffs in box.
void readUInt64(ossim_uint64 &i, std::ifstream &str) const
Initializes i reference.
virtual ~ossimJp2Info()
virtual destructor
std::string::size_type size() const
unsigned long long ossim_uint64
unsigned int ossim_uint32
void readUInt32(ossim_uint32 &i, std::ifstream &str) const
Initializes i reference.
void printTboxType(ossim_uint32 tbox, std::ostream &out) const
Print tbox type as string if known.
virtual std::ostream & print(std::ostream &out) const
Print method.
void addPrefixToAll(const ossimString &prefix)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
std::basic_istringstream< char > istringstream
Class for char input memory streams.
std::streamoff getGmlBox(std::ifstream &str, std::vector< ossim_uint8 > &box) const
Method to get the embedded JP2 GML Box.
std::streamoff getGeotiffBox(std::ifstream &str, std::vector< ossim_uint8 > &box) const
Method to get the embedded JP2 GeoTIFF box.
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
std::streamoff findBoxData(const ossim_uint32 &type, std::ifstream &str, ossim_uint32 &length) const
This finds a box of type and returns the location of its data.