OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ossimJ2kInfo Class Reference

TIFF info class. More...

#include <ossimJ2kInfo.h>

Inheritance diagram for ossimJ2kInfo:
ossimInfoBase ossimReferenced ossimJp2Info

Public Member Functions

 ossimJ2kInfo ()
 default constructor More...
 
virtual ~ossimJ2kInfo ()
 virtual destructor More...
 
virtual bool open (const ossimFilename &file)
 open method. More...
 
virtual std::ostream & print (std::ostream &out) const
 Print method. More...
 
- Public Member Functions inherited from ossimInfoBase
 ossimInfoBase ()
 default constructor More...
 
virtual bool open (std::shared_ptr< ossim::istream > &str, const std::string &connectionString)
 open method. More...
 
void setProcessOverviewFlag (bool flag)
 Sets the overview flag. More...
 
bool getProcessOverviewFlag () const
 Method to get the overview flag. More...
 
virtual bool getKeywordlist (ossimKeywordlist &kwl) const
 Method to dump info to a keyword list. More...
 
virtual bool getKeywordlist (ossimKeywordlist &kwl, ossim_uint32 entryIndex) const
 Method to dump info to a keyword list. More...
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Protected Member Functions

void readUInt16 (ossim_uint16 &s, std::ifstream &str) const
 Initializes s reference. More...
 
std::ostream & printCodMarker (std::ostream &out, const std::string &prefix, std::ifstream &str) const
 Prints 0xff52 COD_MARKER (0xff52). More...
 
std::ostream & printSizMarker (std::ostream &out, const std::string &prefix, std::ifstream &str) const
 Prints 0xff51 SIZ_MARKER (0xff51). More...
 
std::ostream & printSotMarker (std::ostream &out, const std::string &prefix, std::ifstream &str) const
 Prints 0xff90 SOT_MARKER (0xff90) More...
 
std::ostream & printUnknownMarker (std::ostream &out, const std::string &prefix, std::ifstream &str, ossim_uint16 marker) const
 Prints unhandle segment. More...
 
- Protected Member Functions inherited from ossimInfoBase
virtual ~ossimInfoBase ()
 virtual destructor More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

ossimFilename m_file
 
ossimEndianm_endian
 
- Protected Attributes inherited from ossimInfoBase
bool theOverviewFlag
 

Detailed Description

TIFF info class.

Encapsulates the listgeo functionality.

Definition at line 27 of file ossimJ2kInfo.h.

Constructor & Destructor Documentation

◆ ossimJ2kInfo()

ossimJ2kInfo::ossimJ2kInfo ( )

default constructor

Definition at line 32 of file ossimJ2kInfo.cpp.

References ossim::byteOrder(), m_endian, and OSSIM_LITTLE_ENDIAN.

33  : ossimInfoBase(),
34  m_file(),
35  m_endian(0)
36 {
37  // See if we need to byte swap. J2k, JP2 boxes are big endian.
39  {
40  m_endian = new ossimEndian();
41  }
42 }
ossimFilename m_file
Definition: ossimJ2kInfo.h:120
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
ossimEndian * m_endian
Definition: ossimJ2kInfo.h:121
ossimInfoBase()
default constructor

◆ ~ossimJ2kInfo()

ossimJ2kInfo::~ossimJ2kInfo ( )
virtual

virtual destructor

Definition at line 44 of file ossimJ2kInfo.cpp.

References m_endian.

45 {
46  if (m_endian)
47  {
48  delete m_endian;
49  m_endian = 0;
50  }
51 }
ossimEndian * m_endian
Definition: ossimJ2kInfo.h:121

Member Function Documentation

◆ open()

bool ossimJ2kInfo::open ( const ossimFilename file)
virtual

open method.

Parameters
fileFile name to open.
Returns
true on success false on error.

Reimplemented from ossimInfoBase.

Reimplemented in ossimJp2Info.

Definition at line 53 of file ossimJ2kInfo.cpp.

References ossimString::c_str(), and readUInt16().

54 {
55  bool result = false;
56 
57  //---
58  // Open the file.
59  //---
60  std::ifstream str(file.c_str(), std::ios_base::binary|std::ios_base::in);
61  if (str.good())
62  {
63  //---
64  // Check for the Start Of Codestream (SOC) and Size (SIZ) markers which
65  // are required as first and second fields in the main header.
66  //---
67  ossim_uint16 soc;
68  ossim_uint16 siz;
69  readUInt16(soc, str);
70  readUInt16(siz, str);
71 
72  const ossim_uint16 SOC_MARKER = 0xff4f; // start of codestream marker
73  const ossim_uint16 SIZ_MARKER = 0xff51; // size maker
74 
75  if ( (soc == SOC_MARKER) && (siz == SIZ_MARKER) )
76  {
77  result = true; // Is a j2k...
78  }
79  }
80 
81  if (result)
82  {
83 
84  m_file = file;
85  }
86  else
87  {
88  m_file.clear();
89  if (m_endian)
90  {
91  delete m_endian;
92  m_endian = 0;
93  }
94  }
95 
96  return result;
97 }
void clear()
Erases the entire container.
Definition: ossimString.h:432
void readUInt16(ossim_uint16 &s, std::ifstream &str) const
Initializes s reference.
ossimFilename m_file
Definition: ossimJ2kInfo.h:120
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
ossimEndian * m_endian
Definition: ossimJ2kInfo.h:121
unsigned short ossim_uint16
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396

◆ print()

std::ostream & ossimJ2kInfo::print ( std::ostream &  out) const
virtual

Print method.

Parameters
outStream to print to.
Returns
std::ostream&

Implements ossimInfoBase.

Reimplemented in ossimJp2Info.

Definition at line 99 of file ossimJ2kInfo.cpp.

100 {
101  static const char MODULE[] = "ossimJ2kInfo::print";
102 
103  if (traceDebug())
104  {
106  << MODULE << " DEBUG Entered...\n";
107  }
108 
109  if ( m_file.size() )
110  {
111  // Open the file.
112  std::ifstream str(m_file.c_str(), std::ios_base::binary|std::ios_base::in);
113  if (str.good())
114  {
115  ossim_uint16 marker;
116  readUInt16(marker, str); // SOC
117  readUInt16(marker, str); // SIZ
118 
119  std::string prefix = "j2k.";
120 
121  // SIZ marker required next.
122  printSizMarker(out, prefix, str);
123 
124  readUInt16(marker, str);
125 
126  const ossim_uint16 COD_MARKER = 0xff52; // cod maker
127  const ossim_uint16 EOC_MARKER = 0xffd9; // End of codestream marker.
128  const ossim_uint16 SOT_MARKER = 0xff90; // start of tile marker
129 
130  while ( str.good() && (marker != EOC_MARKER) )
131  {
132  switch(marker)
133  {
134  case COD_MARKER:
135  {
136  printCodMarker(out, prefix, str);
137  break;
138  }
139  case SOT_MARKER:
140  {
141  printSotMarker(out, prefix, str);
142  break;
143  }
144  default:
145  {
146  printUnknownMarker(out, prefix, str, marker);
147  }
148  }
149 
150  readUInt16(marker, str);
151 
152  }
153  }
154  }
155 
156  return out;
157 }
void readUInt16(ossim_uint16 &s, std::ifstream &str) const
Initializes s reference.
ossimFilename m_file
Definition: ossimJ2kInfo.h:120
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
unsigned short ossim_uint16
std::string::size_type size() const
Definition: ossimString.h:405
std::ostream & printCodMarker(std::ostream &out, const std::string &prefix, std::ifstream &str) const
Prints 0xff52 COD_MARKER (0xff52).
std::ostream & printUnknownMarker(std::ostream &out, const std::string &prefix, std::ifstream &str, ossim_uint16 marker) const
Prints unhandle segment.
std::ostream & printSizMarker(std::ostream &out, const std::string &prefix, std::ifstream &str) const
Prints 0xff51 SIZ_MARKER (0xff51).
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::ostream & printSotMarker(std::ostream &out, const std::string &prefix, std::ifstream &str) const
Prints 0xff90 SOT_MARKER (0xff90)

◆ printCodMarker()

std::ostream & ossimJ2kInfo::printCodMarker ( std::ostream &  out,
const std::string &  prefix,
std::ifstream &  str 
) const
protected

Prints 0xff52 COD_MARKER (0xff52).

Parameters
outStream to output to.
prefixThis will be prepended to key. e.g. Where prefix = "j2k." and key is "file_name" key becomes: "j2k.file_name:"
strInput stream to pass to j2k record for parsing. Should be just pass the marker.
Returns
output stream.

Definition at line 168 of file ossimJ2kInfo.cpp.

References ossimJ2kCodRecord::parseStream(), and ossimJ2kCodRecord::print().

171 {
172  ossimJ2kCodRecord siz;
173  siz.parseStream(str);
174  siz.print(out, prefix);
175  return out;
176 }
void parseStream(std::istream &in)
Parse method.
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.

◆ printSizMarker()

std::ostream & ossimJ2kInfo::printSizMarker ( std::ostream &  out,
const std::string &  prefix,
std::ifstream &  str 
) const
protected

Prints 0xff51 SIZ_MARKER (0xff51).

Parameters
outStream to output to.
prefixThis will be prepended to key. e.g. Where prefix = "j2k." and key is "file_name" key becomes: "j2k.file_name:"
strInput stream to pass to j2k record for parsing. Should be just pass the marker.
Returns
output stream.

Definition at line 178 of file ossimJ2kInfo.cpp.

References ossimJ2kSizRecord::parseStream(), and ossimJ2kSizRecord::print().

181 {
182  ossimJ2kSizRecord siz;
183  siz.parseStream(str);
184  siz.print(out, prefix);
185  return out;
186 }
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 parseStream(ossim::istream &in)
Parse method.

◆ printSotMarker()

std::ostream & ossimJ2kInfo::printSotMarker ( std::ostream &  out,
const std::string &  prefix,
std::ifstream &  str 
) const
protected

Prints 0xff90 SOT_MARKER (0xff90)

Parameters
outStream to output to.
prefixThis will be prepended to key. e.g. Where prefix = "j2k." and key is "file_name" key becomes: "j2k.file_name:"
strInput stream to pass to j2k record for parsing. Should be just pass the marker.
Returns
output stream.

Definition at line 188 of file ossimJ2kInfo.cpp.

References ossimJ2kSotRecord::parseStream(), ossimJ2kSotRecord::print(), and ossimJ2kSotRecord::thePsot.

191 {
192  // Get the stream posistion.
193  std::streamoff pos = str.tellg();
194 
195  ossimJ2kSotRecord sot;
196  sot.parseStream(str);
197  pos += sot.thePsot - 2;
198 
199  // Seek past the tile to the next marker.
200  str.seekg(pos, std::ios_base::beg);
201 
202  sot.print(out,prefix);
203  return out;
204 }
void parseStream(ossim::istream &in)
Parse method.
ossim_uint32 thePsot
The length in bytes of this record including the SOT marker.
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.

◆ printUnknownMarker()

std::ostream & ossimJ2kInfo::printUnknownMarker ( std::ostream &  out,
const std::string &  prefix,
std::ifstream &  str,
ossim_uint16  marker 
) const
protected

Prints unhandle segment.

This will only print the marker and record length.

Parameters
outStream to output to.
prefixThis will be prepended to key. e.g. Where prefix = "j2k." and key is "file_name" key becomes: "j2k.file_name:"
strInput stream to pass to j2k record for parsing. Should be just pass the marker.
marker.The marker.
Returns
output stream.

Definition at line 207 of file ossimJ2kInfo.cpp.

References readUInt16().

211 {
212  // Capture the original flags.
213  std::ios_base::fmtflags f = out.flags();
214 
215  ossim_uint16 segmentLength;
216  readUInt16(segmentLength, str);
217 
218  std::string pfx = prefix;
219  pfx += "unknown.";
220 
221  out.setf(std::ios_base::hex, std::ios_base::basefield);
222  out << pfx << "marker: 0x" << std::setfill('0') << std::setw(4)
223  << marker << "\n";
224  out.setf(std::ios_base::fmtflags(0), std::ios_base::basefield);
225 
226  out << pfx << "length: " << segmentLength
227  << std::endl;
228 
229  // Reset flags.
230  out.setf(f);
231 
232  // Seek to the next marker.
233  str.seekg( (segmentLength-2), std::ios_base::cur);
234 
235  return out;
236 }
void readUInt16(ossim_uint16 &s, std::ifstream &str) const
Initializes s reference.
unsigned short ossim_uint16

◆ readUInt16()

void ossimJ2kInfo::readUInt16 ( ossim_uint16 s,
std::ifstream &  str 
) const
protected

Initializes s reference.

Does byte swapping as needed.

Definition at line 159 of file ossimJ2kInfo.cpp.

References m_endian, and ossimEndian::swap().

Referenced by open(), and printUnknownMarker().

160 {
161  str.read((char*)&s, 2);
162  if (m_endian)
163  {
164  m_endian->swap(s);
165  }
166 }
ossimEndian * m_endian
Definition: ossimJ2kInfo.h:121
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26

Member Data Documentation

◆ m_endian

ossimEndian* ossimJ2kInfo::m_endian
protected

◆ m_file

ossimFilename ossimJ2kInfo::m_file
protected

Definition at line 120 of file ossimJ2kInfo.h.

Referenced by ossimJp2Info::getBox(), ossimJp2Info::open(), and ossimJp2Info::print().


The documentation for this class was generated from the following files: