diff options
Diffstat (limited to 'src/renderer')
-rw-r--r-- | src/renderer/tr_image.c | 10 | ||||
-rw-r--r-- | src/renderer/tr_init.c | 20 |
2 files changed, 20 insertions, 10 deletions
diff --git a/src/renderer/tr_image.c b/src/renderer/tr_image.c index d4beacd8..bd51ff2d 100644 --- a/src/renderer/tr_image.c +++ b/src/renderer/tr_image.c @@ -1817,6 +1817,11 @@ void SaveJPG(char * filename, int quality, int image_width, int image_height, un * Here we just illustrate the use of quality (quantization table) scaling: */ jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); + /* If quality is set high, disable chroma subsampling */ + if (quality >= 85) { + cinfo.comp_info[0].h_samp_factor = 1; + cinfo.comp_info[0].v_samp_factor = 1; + } /* Step 4: Start compressor */ @@ -1891,6 +1896,11 @@ int SaveJPGToBuffer( byte *buffer, int quality, jpeg_set_defaults(&cinfo); jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); + /* If quality is set high, disable chroma subsampling */ + if (quality >= 85) { + cinfo.comp_info[0].h_samp_factor = 1; + cinfo.comp_info[0].v_samp_factor = 1; + } /* Step 4: Start compressor */ jpeg_start_compress(&cinfo, TRUE); diff --git a/src/renderer/tr_init.c b/src/renderer/tr_init.c index b027a3c8..96fa5b4d 100644 --- a/src/renderer/tr_init.c +++ b/src/renderer/tr_init.c @@ -511,7 +511,7 @@ void RB_TakeScreenshotJPEG( int x, int y, int width, int height, char *fileName } ri.FS_WriteFile( fileName, buffer, 1 ); // create path - SaveJPG( fileName, 95, glConfig.vidWidth, glConfig.vidHeight, buffer); + SaveJPG( fileName, 90, glConfig.vidWidth, glConfig.vidHeight, buffer); ri.Hunk_FreeTempMemory( buffer ); } @@ -815,23 +815,23 @@ const void *RB_TakeVideoFrameCmd( const void *data ) if( cmd->motionJpeg ) { - frameSize = SaveJPGToBuffer( cmd->encodeBuffer, 95, + frameSize = SaveJPGToBuffer( cmd->encodeBuffer, 90, cmd->width, cmd->height, cmd->captureBuffer ); + ri.CL_WriteAVIVideoFrame( cmd->encodeBuffer, frameSize ); } else { - frameSize = cmd->width * cmd->height * 4; + frameSize = cmd->width * cmd->height; - // Vertically flip the image - for( i = 0; i < cmd->height; i++ ) + for( i = 0; i < frameSize; i++) // Pack to 24bpp and swap R and B { - Com_Memcpy( &cmd->encodeBuffer[ i * ( cmd->width * 4 ) ], - &cmd->captureBuffer[ ( cmd->height - i - 1 ) * ( cmd->width * 4 ) ], - cmd->width * 4 ); + cmd->encodeBuffer[ i*3 ] = cmd->captureBuffer[ i*4 + 2 ]; + cmd->encodeBuffer[ i*3 + 1 ] = cmd->captureBuffer[ i*4 + 1 ]; + cmd->encodeBuffer[ i*3 + 2 ] = cmd->captureBuffer[ i*4 ]; } - } - ri.CL_WriteAVIVideoFrame( cmd->encodeBuffer, frameSize ); + ri.CL_WriteAVIVideoFrame( cmd->encodeBuffer, frameSize * 3 ); + } return (const void *)(cmd + 1); } |