OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimJ2kSotRecord.cpp
Go to the documentation of this file.
1 //---
2 //
3 // License: MIT
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: David Burken
8 //
9 // Description: Container class for J2K "Start Of Tile" (SOT) record.
10 //
11 // marker: FF90
12 //
13 // See document BPJ2K01.00 Table 7-3 Image and tile size (15444-1 Annex A.4.2)
14 //
15 //---
16 // $Id$
17 
19 #include <ossim/base/ossimCommon.h>
20 #include <ossim/base/ossimEndian.h>
21 
22 #include <iostream>
23 #include <iomanip>
24 
26  :
27  theLsot(0),
28  theIsot(0),
29  thePsot(0),
30  theTpsot(0),
31  theTnsot(0)
32 {
33 }
34 
36 {
37 }
38 
40 {
41  // Note: marker not read...
42 
43  in.read((char*)&theLsot, 2);
44  in.read((char*)&theIsot, 2);
45  in.read((char*)&thePsot, 4);
46  in.read((char*)&theTpsot, 1);
47  in.read((char*)&theTnsot, 1);
48 
50  {
51  // Stored big endian, must swap.
52  ossimEndian endian;
53  endian.swap(theLsot);
54  endian.swap(theIsot);
55  endian.swap(thePsot);
56  }
57 }
58 
60 {
61  ossimEndian* endian = 0;
63  {
64  // Stored in file big endian, must swap.
65  endian = new ossimEndian();
66  endian->swap( theLsot );
67  endian->swap( theIsot );
68  endian->swap( thePsot );
69  }
70 
71  // Marker 0xff90:
72  out.put( 0xff );
73  out.put( 0x90 );
74 
75  out.write( (char*)&theLsot, 2);
76  out.write( (char*)&theIsot, 2);
77  out.write( (char*)&thePsot, 4);
78  out.write( (char*)&theTpsot, 1);
79  out.write( (char*)&theTnsot, 1);
80 
81  if ( endian )
82  {
83  // Swap back to native:
84  endian->swap(theLsot);
85  endian->swap(theIsot);
86  endian->swap(thePsot);
87 
88  delete endian;
89  endian = 0;
90  }
91 }
92 
94 {
95  theIsot = isot;
96 }
97 
99  const std::string& prefix) const
100 {
101  // Capture the original flags.
102  std::ios_base::fmtflags f = out.flags();
103 
104  std::string pfx = prefix;
105  pfx += "sot.";
106 
107  out.setf(std::ios_base::hex, std::ios_base::basefield);
108  out << pfx << "marker: 0xff90\n";
109  out.setf(std::ios_base::fmtflags(0), std::ios_base::basefield);
110 
111  out << pfx << "Lsot: " << theLsot << "\n"
112  << pfx << "Isot: " << theIsot << "\n"
113  << pfx << "Psot: " << thePsot << "\n"
114  << pfx << "Tpsot: " << int(theTpsot) << "\n"
115  << pfx << "Tnsot: " << int(theTnsot)
116  << std::endl;
117 
118  // Reset flags.
119  out.setf(f);
120 
121  return out;
122 }
123 
125 {
126  return obj.print(out);
127 }
ossim_uint8 theTnsot
0 = Number of tile-parts of this tile in the codestream is not defined in this header.
void setIsot(ossim_uint16 isot)
Sets the tile index.
void parseStream(ossim::istream &in)
Parse method.
ossim_uint8 theTpsot
Tile-Part index.
ossim_uint16 theIsot
Tile index.
void writeStream(std::ostream &out)
Write method.
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
ossim_uint16 theLsot
Length in bytes of the marker segment.
unsigned short ossim_uint16
std::ostream & operator<<(std::ostream &out, const ossimJ2kSotRecord &obj)
ossim_uint32 thePsot
The length in bytes of this record including the SOT marker.
~ossimJ2kSotRecord()
destructor
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
print method that outputs a key/value type format adding prefix to keys.
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
ossimJ2kSotRecord()
default constructor
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23