CNCSError JP2UUID3DNBox::Parse(class CNCSJP2File &JP2File, CNCSJPCIOStream &Stream)
{
    CNCSError Error;

//See NCSJPCIOStream.h to get an understanding of these macros
    NCSJP2_CHECKIO_BEGIN(Error, Stream);
    NCSJP2_CHECKIO(Read(m_UUID.m_UUID, sizeof(m_UUID.m_UUID)));


    if (m_UUID == sm_UUID)
    {
        Stream.ReadIEEE8(_OrigMaxVal);
        Stream.ReadIEEE8(_OrigMinVal);
        Stream.ReadUINT32(_NormalizedMaxVal);
        Stream.ReadUINT32(_NormalizedMinVal);
    } // if
    NCSJP2_CHECKIO_END();

    return(Error);
} // JP2UUID3DNBox::Parse
Beispiel #2
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);
}