diff options
Diffstat (limited to 'src/client/cl_avi.c')
-rw-r--r-- | src/client/cl_avi.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/client/cl_avi.c b/src/client/cl_avi.c index c9680522..7f673fa8 100644 --- a/src/client/cl_avi.c +++ b/src/client/cl_avi.c @@ -368,8 +368,13 @@ qboolean CL_OpenAVIForWriting( const char *fileName ) else afd.motionJpeg = qfalse; - afd.cBuffer = Z_Malloc( afd.width * afd.height * 4 ); - afd.eBuffer = Z_Malloc( afd.width * afd.height * 4 ); + // 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; @@ -467,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 ) @@ -541,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; |