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

#include <ossimJ2kTlmRecord.h>

Public Member Functions

 ossimJ2kTlmRecord ()
 default constructor More...
 
 ~ossimJ2kTlmRecord ()
 destructor More...
 
void parseStream (ossim::istream &in)
 Parse method. More...
 
void writeStream (std::ostream &out)
 Write method. More...
 
ossim_uint8 getZtlm () const
 
ossim_uint8 getSt () const
 Get the ST portion of STLM field( bits 5 and 6). More...
 
bool setSt (ossim_uint8 bits)
 Set the ST bits of STLM field. More...
 
ossim_uint8 getSp () const
 
bool setSp (ossim_uint8 bit)
 Set the SP bit of Stlm field. More...
 
ossim_uint16 getTileCount () const
 
bool getTileLength (ossim_int32 index, ossim_uint32 &length) const
 Get the tile length for tile at index from ptlm array. More...
 
bool setTileLength (ossim_int32 index, ossim_uint32 length)
 Sets the tile length for tile at x,y in ptlm array. More...
 
bool accumulate (ossim_int32 first, ossim_int32 last, std::streampos &init) const
 Adds Ptlm array from first to last. More...
 
bool initPtlmArray (ossim_uint8 spBit, ossim_uint16 count)
 Sets SP bit, initializes ptlm array, and ltlm(size). More...
 
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. More...
 

Private Member Functions

void clear ()
 Deletes m_Ttlm and m_Ptlm arrays. More...
 
void clearTtlm ()
 Deletes m_Ttlm array. More...
 
void clearPtlm ()
 Deletes m_Ptlm array. More...
 
ossim_uint16 computeLength (ossim_uint16 tileCount) const
 Computes length of this segment minus marker itself. More...
 

Private Attributes

ossim_uint16 m_Ltlm
 NOTE: tml segmet marker 0xff55 not stored. More...
 
ossim_uint8 m_Ztlm
 Index of marker segment relative to all other TLM marker segments present in the current header. More...
 
ossim_uint8 m_Stlm
 Indicator for Ttlm and Ptlm field sizes. More...
 
void * m_Ttlm
 Tile index for tile-parts. More...
 
void * m_Ptlm
 The length, in bytes, from the beginning of the SOT marker of the tile-part to the end of the codestream data for that tile-part. More...
 

Friends

OSSIM_DLL std::ostream & operator<< (std::ostream &out, const ossimJ2kTlmRecord &obj)
 operator<< More...
 

Detailed Description

Definition at line 20 of file ossimJ2kTlmRecord.h.

Constructor & Destructor Documentation

◆ ossimJ2kTlmRecord()

ossimJ2kTlmRecord::ossimJ2kTlmRecord ( )

default constructor

Definition at line 24 of file ossimJ2kTlmRecord.cpp.

25  :
26  m_Ltlm(0),
27  m_Ztlm(0),
28  m_Stlm(0x40), // Tiles in order 32 bit Ptlm
29  m_Ttlm(0),
30  m_Ptlm(0)
31 {
32 }
ossim_uint8 m_Stlm
Indicator for Ttlm and Ptlm field sizes.
void * m_Ptlm
The length, in bytes, from the beginning of the SOT marker of the tile-part to the end of the codestr...
ossim_uint16 m_Ltlm
NOTE: tml segmet marker 0xff55 not stored.
void * m_Ttlm
Tile index for tile-parts.
ossim_uint8 m_Ztlm
Index of marker segment relative to all other TLM marker segments present in the current header...

◆ ~ossimJ2kTlmRecord()

ossimJ2kTlmRecord::~ossimJ2kTlmRecord ( )

destructor

Definition at line 34 of file ossimJ2kTlmRecord.cpp.

References clear().

35 {
36  clear();
37 }
void clear()
Deletes m_Ttlm and m_Ptlm arrays.

Member Function Documentation

◆ accumulate()

bool ossimJ2kTlmRecord::accumulate ( ossim_int32  first,
ossim_int32  last,
std::streampos &  init 
) const

Adds Ptlm array from first to last.

The range used is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.

Parameters
firstarray index
lastarray index
initInitialized by this. This is added to so whatever it starts with you get that plus the accumlated indexes.
Returns
true on success; false, on errors.

Definition at line 426 of file ossimJ2kTlmRecord.cpp.

References getSp(), getTileCount(), m_Ptlm, and status.

428 {
429  bool status = false;
430  if ( (first >= 0) && (last>first) && (last <= getTileCount()) )
431  {
432  ossim_uint8 sp = getSp();
433  if ( sp == 0 )
434  {
436  for ( ossim_int32 i = first; i < last; ++i )
437  {
438  init += p[i];
439  status = true;
440  }
441  }
442  else if ( sp == 1 )
443  {
445  for ( ossim_int32 i = first; i < last; ++i )
446  {
447  init += p[i];
448  status = true;
449  }
450  }
451  }
452  return status;
453 }
void * m_Ptlm
The length, in bytes, from the beginning of the SOT marker of the tile-part to the end of the codestr...
unsigned short ossim_uint16
ossim_uint8 getSp() const
ossim_uint16 getTileCount() const
unsigned int ossim_uint32
return status
unsigned char ossim_uint8
int ossim_int32

◆ clear()

void ossimJ2kTlmRecord::clear ( )
private

Deletes m_Ttlm and m_Ptlm arrays.

Definition at line 39 of file ossimJ2kTlmRecord.cpp.

References clearPtlm(), and clearTtlm().

Referenced by parseStream(), and ~ossimJ2kTlmRecord().

40 {
41  clearTtlm();
42  clearPtlm();
43 }
void clearPtlm()
Deletes m_Ptlm array.
void clearTtlm()
Deletes m_Ttlm array.

◆ clearPtlm()

void ossimJ2kTlmRecord::clearPtlm ( )
private

Deletes m_Ptlm array.

Definition at line 64 of file ossimJ2kTlmRecord.cpp.

References getSp(), and m_Ptlm.

Referenced by clear(), and initPtlmArray().

65 {
66  if ( m_Ptlm )
67  {
68  ossim_uint8 sp = getSp();
69  if ( sp == 0 )
70  {
72  delete [] p;
73  }
74  else if ( sp == 1 )
75  {
77  delete [] p;
78  }
79  m_Ptlm = 0;
80  }
81 }
void * m_Ptlm
The length, in bytes, from the beginning of the SOT marker of the tile-part to the end of the codestr...
unsigned short ossim_uint16
ossim_uint8 getSp() const
unsigned int ossim_uint32
unsigned char ossim_uint8

◆ clearTtlm()

void ossimJ2kTlmRecord::clearTtlm ( )
private

Deletes m_Ttlm array.

Definition at line 45 of file ossimJ2kTlmRecord.cpp.

References getSt(), and m_Ttlm.

Referenced by clear().

46 {
47  if ( m_Ttlm )
48  {
49  ossim_uint8 st = getSt();
50  if ( st == 1 )
51  {
53  delete [] p;
54  }
55  else if ( st == 2 )
56  {
58  delete [] p;
59  }
60  m_Ttlm = 0;
61  }
62 }
ossim_uint8 getSt() const
Get the ST portion of STLM field( bits 5 and 6).
unsigned short ossim_uint16
void * m_Ttlm
Tile index for tile-parts.
unsigned char ossim_uint8

◆ computeLength()

ossim_uint16 ossimJ2kTlmRecord::computeLength ( ossim_uint16  tileCount) const
private

Computes length of this segment minus marker itself.

Returns
Length of this segment.

Definition at line 455 of file ossimJ2kTlmRecord.cpp.

References getSp(), and getSt().

Referenced by initPtlmArray().

456 {
457  return 4 + ( getSt() + (getSp()==1?4:2) ) * tileCount;
458 }
ossim_uint8 getSt() const
Get the ST portion of STLM field( bits 5 and 6).
ossim_uint8 getSp() const

◆ getSp()

ossim_uint8 ossimJ2kTlmRecord::getSp ( ) const
Returns
The higher order 4 bits of m_Stlm as an unsigned char.

Definition at line 312 of file ossimJ2kTlmRecord.cpp.

References m_Stlm.

Referenced by accumulate(), clearPtlm(), computeLength(), getTileCount(), getTileLength(), parseStream(), print(), setTileLength(), and writeStream().

313 {
314  // Last two bits.
315  return m_Stlm >> 6;
316 }
ossim_uint8 m_Stlm
Indicator for Ttlm and Ptlm field sizes.

◆ getSt()

ossim_uint8 ossimJ2kTlmRecord::getSt ( ) const

Get the ST portion of STLM field( bits 5 and 6).

Returns
ST bits as an unsigned char.

Definition at line 273 of file ossimJ2kTlmRecord.cpp.

References m_Stlm.

Referenced by clearTtlm(), computeLength(), getTileCount(), parseStream(), print(), and writeStream().

274 {
275  // 5th and 6th bits.
276  return (m_Stlm & 0x30) >> 4;
277 }
ossim_uint8 m_Stlm
Indicator for Ttlm and Ptlm field sizes.

◆ getTileCount()

ossim_uint16 ossimJ2kTlmRecord::getTileCount ( ) const
Returns
The tile count derived from m_Ltml, sd and sp.

Definition at line 362 of file ossimJ2kTlmRecord.cpp.

References getSp(), getSt(), m_Ltlm, and x.

Referenced by accumulate(), getTileLength(), parseStream(), print(), setTileLength(), and writeStream().

363 {
364  // See Table 7-21 BPJ2K01.10:
365  ossim_uint16 result = 0;
366  if ( m_Ltlm )
367  {
368  ossim_uint8 st = getSt();
369  ossim_uint8 sp = getSp();
370  ossim_uint16 x = st + (sp==0?2:4);
371  if ( x )
372  {
373  result = (m_Ltlm - 4) / x;
374  }
375  }
376  return result;
377 }
ossim_uint32 x
ossim_uint8 getSt() const
Get the ST portion of STLM field( bits 5 and 6).
unsigned short ossim_uint16
ossim_uint16 m_Ltlm
NOTE: tml segmet marker 0xff55 not stored.
ossim_uint8 getSp() const
unsigned char ossim_uint8

◆ getTileLength()

bool ossimJ2kTlmRecord::getTileLength ( ossim_int32  index,
ossim_uint32 length 
) const

Get the tile length for tile at index from ptlm array.

Parameters
index
lengthInitialized by this to of tile legnth or 0 out of array bounds.
Returns
true on success, false if out of bounds.

Definition at line 379 of file ossimJ2kTlmRecord.cpp.

References getSp(), getTileCount(), m_Ptlm, and status.

380 {
381  bool status = false;
382  if ( (index >= 0) && ( index < getTileCount() ) )
383  {
384  ossim_uint8 sp = getSp();
385  if ( sp == 0 )
386  {
388  length = p[index];
389  status = true;
390  }
391  else if ( sp == 1 )
392  {
394  length = p[index];
395  status = true;
396  }
397  }
398 
399  return status;
400 }
void * m_Ptlm
The length, in bytes, from the beginning of the SOT marker of the tile-part to the end of the codestr...
unsigned short ossim_uint16
ossim_uint8 getSp() const
ossim_uint16 getTileCount() const
unsigned int ossim_uint32
return status
unsigned char ossim_uint8

◆ getZtlm()

ossim_uint8 ossimJ2kTlmRecord::getZtlm ( ) const
Returns
Index of this marker segment relative to other marker segments in the header.

Definition at line 307 of file ossimJ2kTlmRecord.cpp.

References m_Ztlm.

308 {
309  return m_Ztlm;
310 }
ossim_uint8 m_Ztlm
Index of marker segment relative to all other TLM marker segments present in the current header...

◆ initPtlmArray()

bool ossimJ2kTlmRecord::initPtlmArray ( ossim_uint8  spBit,
ossim_uint16  count 
)

Sets SP bit, initializes ptlm array, and ltlm(size).

Note: Ptlm array is cleared on this call.

Parameters
spBit0 = 16 bit Ptlm parameter, 1 = 32 bit Ptlm parameter.
countof ptlm array or tiles.

Definition at line 340 of file ossimJ2kTlmRecord.cpp.

References clearPtlm(), computeLength(), m_Ltlm, m_Ptlm, and setSp().

341 {
342  bool result = setSp( spBit );
343 
344  clearPtlm();
345 
346  if ( spBit == 0 )
347  {
348  m_Ptlm = new ossim_uint16[count];
349  std::memset( m_Ptlm, 0, count*2 );
350  }
351  else if ( spBit == 1 )
352  {
353  m_Ptlm = new ossim_uint32[count];
354  std::memset( m_Ptlm, 0, count*4 );
355  }
356 
357  m_Ltlm = computeLength( count );
358 
359  return result;
360 }
void * m_Ptlm
The length, in bytes, from the beginning of the SOT marker of the tile-part to the end of the codestr...
unsigned short ossim_uint16
void clearPtlm()
Deletes m_Ptlm array.
ossim_uint16 m_Ltlm
NOTE: tml segmet marker 0xff55 not stored.
ossim_uint16 computeLength(ossim_uint16 tileCount) const
Computes length of this segment minus marker itself.
unsigned int ossim_uint32
bool setSp(ossim_uint8 bit)
Set the SP bit of Stlm field.

◆ parseStream()

void ossimJ2kTlmRecord::parseStream ( ossim::istream in)

Parse method.

Performs byte swapping as needed.

Parameters
inStream to parse.
Note
SIZ Marker (0xff51) is not read.

Definition at line 83 of file ossimJ2kTlmRecord.cpp.

References ossim::byteOrder(), clear(), getSp(), getSt(), getTileCount(), m_Ltlm, m_Ptlm, m_Stlm, m_Ttlm, m_Ztlm, OSSIM_LITTLE_ENDIAN, ossimNotify(), ossimNotifyLevel_WARN, and ossimEndian::swap().

Referenced by ossimKakaduNitfReader::dumpTiles().

84 {
85  clear(); // Deletes m_Ttlm and m_Ptlm arrays if they exist.
86 
87  ossimEndian* endian = 0;
89  {
90  // Stored big endian, must swap.
91  endian = new ossimEndian();
92  }
93 
94  // Get the stream posistion.
95  std::streamoff pos = in.tellg();
96 
97  // Note: Marker is not read.
98 
99  // Length of segment minus marker.
100  in.read((char*)&m_Ltlm, 2);
101  if ( endian )
102  {
103  endian->swap(m_Ltlm);
104  }
105 
106  // Index of marker segment relative to all other TLM marker segments.
107  in.read((char*)&m_Ztlm, 1);
108 
109  // Stlm contains two variables in one byte, ST and SP.
110  in.read((char*)&m_Stlm, 1);
111 
112  ossim_uint16 tile_count = getTileCount();
113  if ( tile_count )
114  {
115  ossim_uint8 st = getSt();
116 
117  //---
118  // Get the Ttlm array if any:
119  // st value of 0 means tiles are in order and no Ttlm array.
120  //---
121  if ( st == 1 ) // 8 bit
122  {
123  ossim_uint8* p = new ossim_uint8[tile_count];
124  in.read((char*)p, tile_count);
125  m_Ttlm = p;
126  }
127  else if ( st == 2 ) // 16 bit
128  {
129  ossim_uint16* p = new ossim_uint16[tile_count];
130  in.read((char*)p, tile_count*2);
131  if ( endian )
132  {
133  endian->swap(p, tile_count);
134  }
135  m_Ttlm = p;
136  }
137  else if ( st > 2 )
138  {
140  << "ossimJ2kTlmRecord::parseStream(...) Bad tlm ST value!"
141  << std::endl;
142  }
143 
144  // Get the Ptlm array:
145  ossim_uint8 sp = getSp();
146  if ( sp == 0 ) // 16 bit
147  {
148  ossim_uint16* p = new ossim_uint16[tile_count];
149  in.read((char*)p, tile_count*2);
150  if ( endian )
151  {
152  endian->swap(p, tile_count);
153  }
154  m_Ptlm = p;
155  }
156  else if ( sp == 1 ) // 32 bit
157  {
158  ossim_uint32* p = new ossim_uint32[tile_count];
159  in.read((char*)p, tile_count*4);
160  if ( endian )
161  {
162  endian->swap(p, tile_count);
163  }
164  m_Ptlm = p;
165  }
166  else
167  {
169  << "ossimJ2kTlmRecord::parseStream(...) Bad tlm SP value!"
170  << std::endl;
171  }
172  }
173 
174  // Clean up::
175  if ( endian )
176  {
177  delete endian;
178  endian = 0;
179  }
180 
181  //---
182  // Seek to next record in case there was a parse error and we didn't read
183  // all bytes.
184  //---
185  in.seekg(pos + m_Ltlm, std::ios_base::beg);
186 }
ossim_uint8 m_Stlm
Indicator for Ttlm and Ptlm field sizes.
ossim_uint8 getSt() const
Get the ST portion of STLM field( bits 5 and 6).
void * m_Ptlm
The length, in bytes, from the beginning of the SOT marker of the tile-part to the end of the codestr...
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
unsigned short ossim_uint16
ossim_uint16 m_Ltlm
NOTE: tml segmet marker 0xff55 not stored.
void clear()
Deletes m_Ttlm and m_Ptlm arrays.
ossim_uint8 getSp() const
void * m_Ttlm
Tile index for tile-parts.
ossim_uint16 getTileCount() const
unsigned int ossim_uint32
ossim_uint8 m_Ztlm
Index of marker segment relative to all other TLM marker segments present in the current header...
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ print()

std::ostream & ossimJ2kTlmRecord::print ( std::ostream &  out,
const std::string &  prefix = std::string() 
) const

print method that outputs a key/value type format adding prefix to keys.

Parameters
outString to output to.
prefixThis will be prepended to key. e.g. Where prefix = "nitf." and key is "file_name" key becomes: "nitf.file_name:"
Returns
output stream.

Definition at line 460 of file ossimJ2kTlmRecord.cpp.

References getSp(), getSt(), getTileCount(), m_Ltlm, m_Ptlm, m_Stlm, m_Ttlm, and m_Ztlm.

Referenced by ossimKakaduNitfReader::dumpTiles(), and operator<<().

462 {
463  // Capture the original flags.
464  std::ios_base::fmtflags f = out.flags();
465 
466  std::string pfx = prefix;
467  pfx += "tlm.";
468 
469  out << pfx << "marker: 0xff55\n"
470  << pfx << "Ltlm: " << m_Ltlm << "\n"
471  << pfx << "Ztlm: " << int(m_Ztlm) << "\n";
472 
473  out.setf(std::ios_base::hex, std::ios_base::basefield);
474  out << pfx << "Stlm: 0x" << int(m_Stlm) << "\n";
475  out.setf(std::ios_base::fmtflags(0), std::ios_base::basefield);
476  out << pfx << "Stlm.ST: " << int(getSt()) << "\n"
477  << pfx << "Stlm.SP: " << int(getSp()) << "\n";
478 
479  ossim_uint16 tile_count = getTileCount();
480  if ( tile_count )
481  {
482  ossim_uint8 st = getSt();
483  if ( m_Ttlm == 0 )
484  {
485  out << pfx << "Ttlm: null\n";
486  }
487  else if ( st == 1 ) // 8 bit
488  {
490  for ( ossim_uint16 i = 0; i < tile_count; ++i )
491  {
492  out << pfx << "Ttlm[" << i << "]: " << (int)p[i] << "\n";
493  }
494  }
495  else if ( st == 2 ) // 16 bit
496  {
498  for ( ossim_uint16 i = 0; i < tile_count; ++i )
499  {
500  out << pfx << "Ttlm[" << i << "]: " << p[i] << "\n";
501  }
502  }
503 
504  ossim_uint8 sp = getSp();
505  if ( sp == 0 ) // 16 bit
506  {
508  for ( ossim_uint16 i = 0; i < tile_count; ++i )
509  {
510  out << pfx << "Ptlm[" << i << "]: " << p[i] << "\n";
511  }
512  }
513  else if ( sp == 1 ) // 32 bit
514  {
516  for ( ossim_uint16 i = 0; i < tile_count; ++i )
517  {
518  out << pfx << "Ptlm[" << i << "]: " << p[i] << "\n";
519  }
520  }
521  }
522 
523  out.flush();
524 
525  // Reset flags.
526  out.setf(f);
527 
528  return out;
529 }
ossim_uint8 m_Stlm
Indicator for Ttlm and Ptlm field sizes.
ossim_uint8 getSt() const
Get the ST portion of STLM field( bits 5 and 6).
void * m_Ptlm
The length, in bytes, from the beginning of the SOT marker of the tile-part to the end of the codestr...
unsigned short ossim_uint16
ossim_uint16 m_Ltlm
NOTE: tml segmet marker 0xff55 not stored.
ossim_uint8 getSp() const
void * m_Ttlm
Tile index for tile-parts.
ossim_uint16 getTileCount() const
unsigned int ossim_uint32
ossim_uint8 m_Ztlm
Index of marker segment relative to all other TLM marker segments present in the current header...
unsigned char ossim_uint8

◆ setSp()

bool ossimJ2kTlmRecord::setSp ( ossim_uint8  bit)

Set the SP bit of Stlm field.

Parameters
bitEither 0 or 1.

0 = Ptlm parameter 16 bits 1 = Ptlm parameter 32 bits

Returns
true if in range; false, if not.

Definition at line 318 of file ossimJ2kTlmRecord.cpp.

References m_Stlm.

Referenced by initPtlmArray().

319 {
320  bool result = true;
321 
322  // 7th bit
323  if ( bit == 0 )
324  {
325  // Clear the 7th bit:
326  m_Stlm = m_Stlm & 0xbf;
327  }
328  else if ( bit == 1 )
329  {
330  // Set the 7th bit.
331  m_Stlm = m_Stlm | 0x40;
332  }
333  else
334  {
335  result = false;
336  }
337  return result;
338 }
ossim_uint8 m_Stlm
Indicator for Ttlm and Ptlm field sizes.

◆ setSt()

bool ossimJ2kTlmRecord::setSt ( ossim_uint8  bits)

Set the ST bits of STLM field.

Parameters
bitsEither 0, 1, or 2.

0 = Ttlm parameter is not present. Tiles are in order. 1 = Ttlm parameter 8 bits. 2 = Ttlm parameter 16 bits.

Returns
true if in range; false, if not.

Definition at line 279 of file ossimJ2kTlmRecord.cpp.

References m_Stlm.

280 {
281  bool result = true;
282 
283  // 5th and 6th bits
284  if ( bits == 0 )
285  {
286  // Clear both 5th and 6th bit.
287  m_Stlm = m_Stlm & 0xcf;
288  }
289  else if ( bits == 1 )
290  {
291  // Set the 5th bit clear the 6th bit.
292  m_Stlm = (m_Stlm & 0xdf) | 0x10;
293  }
294  else if ( bits == 2 )
295  {
296  // Set the 6th bit, clear the 5th bit.
297  m_Stlm = (m_Stlm & 0xef) | 0x20;
298  }
299  else
300  {
301  result = false;
302  }
303 
304  return result;
305 }
ossim_uint8 m_Stlm
Indicator for Ttlm and Ptlm field sizes.

◆ setTileLength()

bool ossimJ2kTlmRecord::setTileLength ( ossim_int32  index,
ossim_uint32  length 
)

Sets the tile length for tile at x,y in ptlm array.

Parameters
index
lengthof tile
Returns
true on success, false if out of bounds.

Definition at line 402 of file ossimJ2kTlmRecord.cpp.

References getSp(), getTileCount(), m_Ptlm, and status.

404 {
405  bool status = false;
406  if ( (index >= 0) && ( index < getTileCount() ) )
407  {
408  ossim_uint8 sp = getSp();
409  if ( sp == 0 )
410  {
412  p[index] = static_cast<ossim_uint16>(length);
413  status = true;
414  }
415  else if ( sp == 1 )
416  {
418  p[index] = length;
419  status = true;
420  }
421  }
422 
423  return status;
424 }
void * m_Ptlm
The length, in bytes, from the beginning of the SOT marker of the tile-part to the end of the codestr...
unsigned short ossim_uint16
ossim_uint8 getSp() const
ossim_uint16 getTileCount() const
unsigned int ossim_uint32
return status
unsigned char ossim_uint8

◆ writeStream()

void ossimJ2kTlmRecord::writeStream ( std::ostream &  out)

Write method.

Note: Write include two marker bytes.

Parameters
outStream to write to.

Definition at line 188 of file ossimJ2kTlmRecord.cpp.

References ossim::byteOrder(), getSp(), getSt(), getTileCount(), m_Ltlm, m_Ptlm, m_Stlm, m_Ttlm, m_Ztlm, OSSIM_LITTLE_ENDIAN, and ossimEndian::swap().

189 {
190  ossim_uint16 tileCount = getTileCount();
191  ossim_uint8 st = getSt();
192  ossim_uint8 sp = getSp();
193 
194  ossimEndian* endian = 0;
196  {
197  // Stored in file big endian, must swap.
198  endian = new ossimEndian();
199  endian->swap( m_Ltlm );
200 
201  // Conditional ttlm array:
202  if ( st == 2 )
203  {
204  endian->swap( (ossim_uint16*)m_Ttlm, tileCount );
205  }
206 
207  // Conditional ptlm array:
208  if (sp == 0 )
209  {
210  endian->swap( (ossim_uint16*)m_Ptlm, tileCount );
211  }
212  else if ( sp == 1 )
213  {
214  endian->swap( (ossim_uint32*)m_Ptlm, tileCount );
215  }
216  }
217 
218  // Marker 0xff55:
219  out.put( 0xff );
220  out.put( 0x55 );
221 
222  out.write( (char*)&m_Ltlm, 2);
223  out.write( (char*)&m_Ztlm, 1);
224  out.write( (char*)&m_Stlm, 1);
225 
226  // Conditional array of tile indexes:
227  if ( st == 1 ) // 8 bit array
228  {
229  out.write( (char*)m_Ttlm, tileCount );
230  }
231  else if ( st == 2 ) // 16 bit array
232  {
233  out.write( (char*)m_Ttlm, tileCount*2 );
234  }
235 
236  // Conditional array of tile byte counts:
237  if ( sp == 0 ) // 16 bit array
238  {
239  out.write( (char*)m_Ptlm, tileCount*2 );
240  }
241  else if ( sp == 1 ) // 32 bit array
242  {
243  out.write( (char*)m_Ptlm, tileCount*4 );
244  }
245 
246  if ( endian )
247  {
248  // Swap back to native:
249  endian->swap( m_Ltlm );
250 
251  // Conditional ttlm array:
252  if ( st == 2 )
253  {
254  endian->swap( (ossim_uint16*)m_Ttlm, tileCount );
255  }
256 
257  // Conditional ptlm array:
258  if (sp == 0 )
259  {
260  endian->swap( (ossim_uint16*)m_Ptlm, tileCount );
261  }
262  else if ( sp == 1 )
263  {
264  endian->swap( (ossim_uint32*)m_Ptlm, tileCount );
265  }
266 
267  // Cleanup:
268  delete endian;
269  endian = 0;
270  }
271 }
ossim_uint8 m_Stlm
Indicator for Ttlm and Ptlm field sizes.
ossim_uint8 getSt() const
Get the ST portion of STLM field( bits 5 and 6).
void * m_Ptlm
The length, in bytes, from the beginning of the SOT marker of the tile-part to the end of the codestr...
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
unsigned short ossim_uint16
ossim_uint16 m_Ltlm
NOTE: tml segmet marker 0xff55 not stored.
ossim_uint8 getSp() const
void * m_Ttlm
Tile index for tile-parts.
ossim_uint16 getTileCount() const
unsigned int ossim_uint32
ossim_uint8 m_Ztlm
Index of marker segment relative to all other TLM marker segments present in the current header...
void swap(ossim_sint8 &)
Definition: ossimEndian.h:26
unsigned char ossim_uint8

Friends And Related Function Documentation

◆ operator<<

OSSIM_DLL std::ostream& operator<< ( std::ostream &  out,
const ossimJ2kTlmRecord obj 
)
friend

operator<<

Definition at line 531 of file ossimJ2kTlmRecord.cpp.

532 {
533  return obj.print(out);
534 }
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.

Member Data Documentation

◆ m_Ltlm

ossim_uint16 ossimJ2kTlmRecord::m_Ltlm
private

NOTE: tml segmet marker 0xff55 not stored.

Length of segment minus marker.

Definition at line 172 of file ossimJ2kTlmRecord.h.

Referenced by getTileCount(), initPtlmArray(), parseStream(), print(), and writeStream().

◆ m_Ptlm

void* ossimJ2kTlmRecord::m_Ptlm
private

The length, in bytes, from the beginning of the SOT marker of the tile-part to the end of the codestream data for that tile-part.

There should be one Ptlm for every tile-part.

16 bits if SP = 0, range 14 - 65535 32 bits if SP = 1, range 14 - (2^32-1)

Definition at line 213 of file ossimJ2kTlmRecord.h.

Referenced by accumulate(), clearPtlm(), getTileLength(), initPtlmArray(), parseStream(), print(), setTileLength(), and writeStream().

◆ m_Stlm

ossim_uint8 ossimJ2kTlmRecord::m_Stlm
private

Indicator for Ttlm and Ptlm field sizes.

Two variable in one byte.

ST Ttlm is lower order bytes.

0 = Ttlm size = 0 bits, tiles in order. Ttlm size = 0 bits 1 = Ttlm size = 8 bits, range 0 - 254 2 = Ttlm size = 16 bits, range 0 - 65535

SP Ptlm is upper order bytes.

16 bits if SP = 0, range 14 - 65535 32 bits if SP = 1, range 14 - (2^31-1)

Definition at line 194 of file ossimJ2kTlmRecord.h.

Referenced by getSp(), getSt(), parseStream(), print(), setSp(), setSt(), and writeStream().

◆ m_Ttlm

void* ossimJ2kTlmRecord::m_Ttlm
private

Tile index for tile-parts.

Either none or one value for every tile-part. 0 bits if ST = 0 8 bits if ST = 1, range 0 - 254 16 bits if ST = 2, range 0 - 65534

Definition at line 202 of file ossimJ2kTlmRecord.h.

Referenced by clearTtlm(), parseStream(), print(), and writeStream().

◆ m_Ztlm

ossim_uint8 ossimJ2kTlmRecord::m_Ztlm
private

Index of marker segment relative to all other TLM marker segments present in the current header.

0 - 255

Definition at line 178 of file ossimJ2kTlmRecord.h.

Referenced by getZtlm(), parseStream(), print(), and writeStream().


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