58 #define MAX_HEADER_LENGTH 8192
72 m_pTempBuffer =
new unsigned char[1];
95 m_file = fopen(pFileName,
"rb");
100 if (!ParseUncompressedAVIHeader())
107 m_nBytesToRead = m_nImageWidth * m_nImageHeight * 3;
111 delete [] m_pTempBuffer;
113 m_pTempBuffer =
new unsigned char[m_nBytesToRead];
123 if (fread(m_pTempBuffer, m_nBytesToRead, 1, m_file) != 1)
126 const int width_bytes = 3 * m_nImageWidth;
128 unsigned char *pHelper1 = m_pImage->
pixels;
129 unsigned char *pHelper2 = m_pTempBuffer + m_nBytesToRead - width_bytes;
132 for (
int i = 0; i < m_nImageHeight; i++)
134 for (
int j = 0; j < width_bytes; j += 3)
136 pHelper1[j] = pHelper2[j + 2];
137 pHelper1[j + 1] = pHelper2[j + 1];
138 pHelper1[j + 2] = pHelper2[j];
141 pHelper1 += width_bytes;
142 pHelper2 -= width_bytes;
145 fseek(m_file, 8, SEEK_CUR);
165 return *((
unsigned int *) pCode);
168 bool CVideoReader::ParseUncompressedAVIHeader()
170 if (fread(header, 8192, 1, m_file) != 1)
173 unsigned int length, *p = (
unsigned int *) header;
175 #ifdef IVT_BIG_ENDIAN
205 p = (
unsigned int *) (((
unsigned char *) p) + length);
224 p = (
unsigned int *) (((
unsigned char *) p) + length);
232 p = (
unsigned int *) (((
unsigned char *) p) + length);
237 unsigned int offset = (
unsigned int) ((
unsigned char *) p - header);
238 fseek(m_file, offset, SEEK_SET);
244 fseek(m_file, length + 8, SEEK_CUR);
247 if (fread(header, 20, 1, m_file) != 1)
250 p = (
unsigned int *) header;
288 m_nImageWidth = p[9];
289 m_nImageHeight = p[10];
296 p = (
unsigned int *) (((
unsigned char *) p) + length);
315 p = (
unsigned int *) (((
unsigned char *) p) + length);
323 p = (
unsigned int *) (((
unsigned char *) p) + length);
328 unsigned int offset = (
unsigned int) ((
unsigned char *) p - header);
329 fseek(m_file, offset, SEEK_SET);
335 fseek(m_file, length + 8, SEEK_CUR);
338 if (fread(header, 20, 1, m_file) != 1)
341 p = (
unsigned int *) header;
355 if (*p != (
unsigned int) (m_nImageWidth * m_nImageHeight * 3))
CByteImage * ReadNextFrame()
unsigned int invert_byte_order_int(unsigned int x)
#define MAX_HEADER_LENGTH
unsigned char * pixels
The pointer to the the pixels.
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
static unsigned int ConvertFourByteCode(const char *pCode)
bool OpenUncompressedAVI(const char *pFileName)