OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimJ2kCodRecord.cpp
Go to the documentation of this file.
1 //---
2 //
3 // License: MIT
4 //
5 // Author: David Burken
6 //
7 // Description: Container class for J2K Coding style default (COD) record.
8 //
9 // See document BPJ2K01.00 Table 7-7 Image and tile size (15444-1 Annex A5.1)
10 //
11 //---
12 // $Id$
13 
16 #include <ossim/base/ossimCommon.h>
17 #include <ossim/base/ossimEndian.h>
18 
19 #include <iostream>
20 #include <iomanip>
21 
22 
24  :
25  m_marker(0xff52),
26  m_lcod(0),
27  m_scod(0),
28  m_progressionOrder(0),
29  m_numberOfLayers(0),
30  m_multipleComponentTransform(0),
31  m_numberOfDecompositionLevels(0),
32  m_codeBlockWidth(0),
33  m_codeBlockHeight(0),
34  m_codeBlockStyle(0),
35  m_transformation(0),
36  m_precinctSize(0)
37 {
38 }
39 
41 {
42 }
43 
45 {
46  // Get the stream posistion.
47  std::streamoff pos = in.tellg();
48 
49  // Note: Marker is not read.
50  in.read((char*)&m_lcod, 2);
51  in.read((char*)&m_scod, 1);
52  in.read((char*)&m_progressionOrder, 1);
53  in.read((char*)&m_numberOfLayers, 2);
54  in.read((char*)&m_multipleComponentTransform, 1);
55  in.read((char*)&m_numberOfDecompositionLevels, 1);
56  in.read((char*)&m_codeBlockWidth, 1);
57  in.read((char*)&m_codeBlockHeight, 1);
58  in.read((char*)&m_codeBlockStyle, 1);
59  in.read((char*)&m_transformation, 1);
60 
61  //---
62  // SPcod - precinct size (only is defined, Scod = xxxx xxx1)
63  //---
64  if ( 0 )
65  {
66  in.read((char*)&m_precinctSize, 1);
67  }
68 
70  {
71  // Stored big endian, must swap.
72  ossimEndian s;
73  s.swap(m_lcod);
75  }
76 
77  //---
78  // Seek to next record. This is needed because there are sometimes extra
79  // bytes.
80  //---
81  in.seekg(pos + m_lcod, std::ios_base::beg);
82 }
83 
85  const std::string& prefix) const
86 {
87  // Capture the original flags.
88  std::ios_base::fmtflags f = out.flags();
89 
90  std::string pfx = prefix;
91  pfx += "cod.";
92 
93  out.setf(std::ios_base::hex, std::ios_base::basefield);
94  out << pfx << "marker: 0xff90\n";
95  out.setf(std::ios_base::fmtflags(0), std::ios_base::basefield);
96 
97  out << pfx << "Lcod: " << m_lcod << "\n"
98  << pfx << "Scod: " << int(m_scod) << "\n"
99  << pfx << "SGcod_progression_order: "
101  << pfx << "SGcod_number_of_layers: " << m_numberOfLayers << "\n"
102  << pfx << "SGcod_multiple_component_transform: "
103  << int(m_multipleComponentTransform) << "\n"
104  << pfx << "SPcod_mumber_of_decomposition_levels: "
105  << int(m_numberOfDecompositionLevels) << "\n"
106  << pfx << "SPcod_code_block_width: " << int(m_codeBlockWidth) << "\n"
107  << pfx << "SPcod_code_block_height: " << int(m_codeBlockHeight) << "\n"
108  << pfx << "SPcod_code_block_style: " << int(m_codeBlockStyle) << "\n"
109  << pfx << "SPcod_transformation: " << int(m_transformation) << "\n"
110  << pfx << "SPcod_precinct_size: " << int(m_precinctSize)
111  << std::endl;
112 
113  // Reset flags.
114  out.setf(f);
115 
116  return out;
117 }
118 
119 std::string ossimJ2kCodRecord::getProgressionOrderAsString( ossim_uint8 progressionOrder ) const
120 {
121  std::string result;
122 
123  if ( progressionOrder == 0x00 )
124  {
125  result = "LRCP";
126  }
127  else if ( progressionOrder == 0x01 )
128  {
129  result = "RLCP";
130  }
131  else if ( progressionOrder == 0x02 )
132  {
133  result = "RPCL";
134  }
135  else if ( progressionOrder == 0x03 )
136  {
137  result = "PCRL";
138  }
139  else if ( progressionOrder == 0x04 )
140  {
141  result = "CPRL";
142  }
143  else
144  {
145  result = "unknown";
146  }
147 
148  return result;
149 }
150 
152 {
153  return m_progressionOrder;
154 }
155 
157 {
158  return obj.print(out);
159 }
std::ostream & operator<<(std::ostream &out, const ossimJ2kCodRecord &obj)
ossim_uint8 getProgressionOrder() const
ossim_uint8 m_multipleComponentTransform
SGcod - Multiple component transform.
void parseStream(std::istream &in)
Parse method.
ossim_uint8 m_precinctSize
SPcod - precinct size (only is defined, Scod = xxxx xxx1)
ossim_uint8 m_codeBlockStyle
SPcod - Code-block height.
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
~ossimJ2kCodRecord()
destructor
std::string getProgressionOrderAsString(ossim_uint8 progressionOrder) const
ossim_uint8 m_transformation
SPcod - transformation (wavelet filter)
ossim_uint16 m_lcod
length of segment minus marker
ossim_uint8 m_progressionOrder
SGcod - Progression order.
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.
ossim_uint8 m_numberOfDecompositionLevels
SPcod - Number of decomposition levels.
ossim_uint8 m_codeBlockHeight
SPcod - Code-block height.
ossim_uint16 m_numberOfLayers
SGcod - Number of layers.
ossim_uint8 m_scod
Coding style.
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
ossim_uint8 m_codeBlockWidth
SPcod - Code-block width.
ossimJ2kCodRecord()
default constructor
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
unsigned char ossim_uint8
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23