- Fix data alignment issue with glReadPixel call, reported by Guillaume Bougard (#4954)

- Fix data alignment issue in raw AVI recording for weird resolutions (like 1366x768)
This commit is contained in:
Thilo Schulz 2011-04-18 16:06:10 +00:00
parent 5769bed4a3
commit 6a203bc8e9
6 changed files with 170 additions and 66 deletions

View file

@ -368,9 +368,13 @@ qboolean CL_OpenAVIForWriting( const char *fileName )
else
afd.motionJpeg = qfalse;
// Buffers only need to store RGB pixels
afd.cBuffer = Z_Malloc(afd.width * afd.height * 3);
afd.eBuffer = Z_Malloc(afd.width * afd.height * 3);
// Buffers only need to store RGB pixels.
// Allocate a bit more space for the capture buffer to account for possible
// padding at the end of pixel lines, and padding for alignment
#define MAX_PACK_LEN 16
afd.cBuffer = Z_Malloc((afd.width * 3 + MAX_PACK_LEN - 1) * afd.height + MAX_PACK_LEN - 1);
// raw avi files have pixel lines start on 4-byte boundaries
afd.eBuffer = Z_Malloc(PAD(afd.width * 3, AVI_LINE_PADDING) * afd.height);
afd.a.rate = dma.speed;
afd.a.format = WAV_FORMAT_PCM;
@ -468,7 +472,7 @@ void CL_WriteAVIVideoFrame( const byte *imageBuffer, int size )
{
int chunkOffset = afd.fileSize - afd.moviOffset - 8;
int chunkSize = 8 + size;
int paddingSize = PAD( size, 2 ) - size;
int paddingSize = PADLEN(size, 2);
byte padding[ 4 ] = { 0 };
if( !afd.fileOpen )
@ -542,7 +546,7 @@ void CL_WriteAVIAudioFrame( const byte *pcmBuffer, int size )
{
int chunkOffset = afd.fileSize - afd.moviOffset - 8;
int chunkSize = 8 + bytesInBuffer;
int paddingSize = PAD( bytesInBuffer, 2 ) - bytesInBuffer;
int paddingSize = PADLEN(bytesInBuffer, 2);
byte padding[ 4 ] = { 0 };
bufIndex = 0;