r824 - in trunk/code: client renderer

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Jul 31 09:05:15 EDT 2006


Author: thilo
Date: 2006-07-31 09:05:15 -0400 (Mon, 31 Jul 2006)
New Revision: 824

Modified:
   trunk/code/client/cl_avi.c
   trunk/code/renderer/tr_init.c
Log:
Fix from the VirtualDub people which should make avi files created with the video command playable with numerous windows players.


Modified: trunk/code/client/cl_avi.c
===================================================================
--- trunk/code/client/cl_avi.c	2006-07-30 14:42:15 UTC (rev 823)
+++ trunk/code/client/cl_avi.c	2006-07-31 13:05:15 UTC (rev 824)
@@ -168,7 +168,7 @@
   afd.chunkStackTop--;
   bufIndex = afd.chunkStack[ afd.chunkStackTop ];
   bufIndex += 4;
-  WRITE_4BYTES( endIndex - bufIndex - 1 );
+  WRITE_4BYTES( endIndex - bufIndex - 4 );
   bufIndex = endIndex;
   bufIndex = PAD( bufIndex, 2 );
 }
@@ -223,7 +223,7 @@
           if( afd.motionJpeg )
             WRITE_STRING( "MJPG" );
           else
-            WRITE_STRING( " BGR" );
+            WRITE_4BYTES( 0 );                  // BI_RGB
 
           WRITE_4BYTES( 0 );                    //dwFlags
           WRITE_4BYTES( 0 );                    //dwPriority
@@ -248,15 +248,18 @@
           WRITE_4BYTES( afd.width );            //biWidth
           WRITE_4BYTES( afd.height );           //biHeight
           WRITE_2BYTES( 1 );                    //biPlanes
-          WRITE_2BYTES( 24 );                   //biBitCount
+          WRITE_2BYTES( 32 );                   //biBitCount
 
-          if( afd.motionJpeg )                        //biCompression
+          if( afd.motionJpeg )   {              //biCompression
             WRITE_STRING( "MJPG" );
-          else
-            WRITE_STRING( " BGR" );
+            WRITE_4BYTES( afd.width *
+              afd.height );                     //biSizeImage
+          } else {
+            WRITE_4BYTES( 0 );                  // BI_RGB
+            WRITE_4BYTES( afd.width *
+            afd.height*4 );                     //biSizeImage
+          }
 
-          WRITE_4BYTES( afd.width *
-              afd.height );                     //biSizeImage
           WRITE_4BYTES( 0 );                    //biXPelsPetMeter
           WRITE_4BYTES( 0 );                    //biYPelsPetMeter
           WRITE_4BYTES( 0 );                    //biClrUsed
@@ -485,7 +488,7 @@
   // Index
   bufIndex = 0;
   WRITE_STRING( "00dc" );           //dwIdentifier
-  WRITE_4BYTES( 0 );                //dwFlags
+  WRITE_4BYTES( 0x00000010 );       //dwFlags (all frames are KeyFrames)
   WRITE_4BYTES( chunkOffset );      //dwOffset
   WRITE_4BYTES( size );             //dwLength
   SafeFS_Write( buffer, 16, afd.idxF );

Modified: trunk/code/renderer/tr_init.c
===================================================================
--- trunk/code/renderer/tr_init.c	2006-07-30 14:42:15 UTC (rev 823)
+++ trunk/code/renderer/tr_init.c	2006-07-31 13:05:15 UTC (rev 824)
@@ -715,6 +715,7 @@
 	const videoFrameCommand_t	*cmd;
 	int												frameSize;
 	int												i;
+	char												swapper;
 	
 	cmd = (const videoFrameCommand_t *)data;
 	
@@ -729,22 +730,22 @@
 	{
 		frameSize = SaveJPGToBuffer( cmd->encodeBuffer, 95,
 				cmd->width, cmd->height, cmd->captureBuffer );
+		ri.CL_WriteAVIVideoFrame( cmd->encodeBuffer, frameSize );
 	}
 	else
 	{
 		frameSize = cmd->width * cmd->height * 4;
 
-		// Vertically flip the image
-		for( i = 0; i < cmd->height; i++ )
+		for( i = 0; i < frameSize; i = i + 4)          // Swap R and B
 		{
-			Com_Memcpy( &cmd->encodeBuffer[ i * ( cmd->width * 4 ) ],
-					&cmd->captureBuffer[ ( cmd->height - i - 1 ) * ( cmd->width * 4 ) ],
-					cmd->width * 4 );
+			swapper = cmd->captureBuffer[ i ];
+			cmd->captureBuffer[ i ] = cmd->captureBuffer[ i + 2 ];
+			cmd->captureBuffer[ i + 2 ] = swapper;
+
 		}
+		ri.CL_WriteAVIVideoFrame( cmd->captureBuffer, frameSize );
 	}
 
-	ri.CL_WriteAVIVideoFrame( cmd->encodeBuffer, frameSize );
-
 	return (const void *)(cmd + 1);	
 }
 




More information about the quake3-commits mailing list