Beispiel #1
0
// 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());
}
Beispiel #2
0
// UnParse the box out to the stream.
CNCSError CNCSJP2Box::UnParse(class CNCSJP2File &JP2File, CNCSJPCIOStream &Stream)
{
	CNCSError Error;

	// If length is > 2^32, need to write out the 64bit XLBox field.
	if(m_nXLBox > 0xffffffff) {
		// Will be writing XLBox, so write out 1 for the LBox field.
		Stream.WriteUINT32(1);
	} else {
		Stream.WriteUINT32((UINT32)m_nXLBox);
	}
	if(Stream.GetError() == NCS_SUCCESS) {
		// Write out the box type;
		if(Stream.WriteUINT32(m_nTBox) && m_nXLBox > 0xffffffff) {
			// Write out the XLBox field.
			Stream.WriteUINT64(m_nXLBox);
		}
		Error = Stream.GetError();
	}
	return(Error);
}
Beispiel #3
0
// 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());
}
Beispiel #4
0
// 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);
}