// UnParse the marker out to the stream. CNCSError CNCSJPCMarker::UnParse(CNCSJPC &JPC, CNCSJPCIOStream &Stream) { &JPC;//Keep compiler happy m_nOffset = Stream.Tell(); Stream.WriteUINT16((UINT16)m_eMarker); return(Stream.GetError()); }
// Parse the marker in from the JP2 file. CNCSError CNCSJPCMarker::Parse(CNCSJPC &JPC, CNCSJPCIOStream &Stream) { &JPC;//Keep compiler happy // Marker. UINT16 t16; m_nOffset = Stream.Tell(); if(Stream.ReadUINT16(t16)) { m_eMarker = (Type)t16; m_bHaveMarker = true; } return(Stream.GetError()); }
// Parse the box in from the JP2 file. CNCSError CNCSJP2Box::Parse(class CNCSJP2File &JP2File, CNCSJPCIOStream &Stream) { CNCSError Error; CNCSJP2BoxList::iterator pCur = m_Prev.begin(); while(pCur != m_Prev.end()) { // Make sure box follows the correct box(es) if((*pCur)->m_bHaveBox == false) { Error = NCS_FILE_INVALID; break; } pCur++; } if(Error == NCS_SUCCESS) { // Make sure box proceeds the correct box(es) pCur = m_Next.begin(); while(pCur != m_Next.end()) { if((*pCur)->m_bHaveBox == true) { Error = NCS_FILE_INVALID; break; } pCur++; } if(Error == NCS_SUCCESS) { if(Stream.Mark()) { // Mark the stream, so we can rewind on an error. UINT32 nLen; // Store absolute offset of box in stream m_nBoxOffset = Stream.Tell(); // Box length. if(Stream.ReadUINT32(nLen)) { // Box type if(Stream.ReadUINT32(m_nTBox)) { // // If the 32 bit nLen is equal to 1, then there is a 64bit length field present. // if(nLen == 1) { // Read in the 64bit length if(Stream.ReadUINT64(m_nXLBox)) { // Calculate the Data length within the box. m_nLDBox = m_nXLBox - 16; } } else { if(nLen == 0) { // Box consists of the rest of the stream m_nXLBox = 8 + Stream.Size() - Stream.Tell(); } else { // No 64bit length present m_nXLBox = nLen; } m_nLDBox = m_nXLBox - 8; } if(Stream.GetError() == NCS_SUCCESS) { m_nDBoxOffset = Stream.Tell(); // The type matches, or we don't care. Unmark the stream. Stream.UnMark(); // Got the box, so set the flag indicating we have it. m_bHaveBox = true; } } } } Error = Stream.GetError(); } } return(Error); }