[Libreoffice-commits] core.git: 2 commits - vcl/source
Tomaž Vajngerl
quikee at gmail.com
Sun Mar 31 04:59:56 PDT 2013
vcl/source/filter/jpeg/jpeg.cxx | 3 +-
vcl/source/filter/jpeg/jpeg.h | 2 -
vcl/source/filter/jpeg/jpeg.hxx | 5 ++-
vcl/source/filter/jpeg/jpegc.c | 60 ++++++++++++++++++----------------------
4 files changed, 34 insertions(+), 36 deletions(-)
New commits:
commit 2c04523b33335bb8b36509789a536542d0f89e02
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Fri Mar 29 18:54:36 2013 +0100
We are in 2013 - remove "goto" in jpeg filter.
Change-Id: I39cea3e90f0ac57168e1cd2d4a9af9199e1416fb
diff --git a/vcl/source/filter/jpeg/jpegc.c b/vcl/source/filter/jpeg/jpegc.c
index 929c216..a18f197 100644
--- a/vcl/source/filter/jpeg/jpegc.c
+++ b/vcl/source/filter/jpeg/jpegc.c
@@ -74,23 +74,15 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
JSAMPLE * range_limit;
HPBYTE pScanLineBuffer = NULL;
long nScanLineBufferComponents = 0;
- // declare bDecompCreated volatile because of gcc
- // warning: variable 'bDecompCreated' might be clobbered by `longjmp' or `vfork'
- volatile long bDecompCreated = 0;
-
- /* Falls der Stream nicht ausreicht (IO_PENDING)
- wird ueber ein longjmp in der Schleife nach Exit
- gesprungen, wir geben dann die Anzahl
- der bisher bearbeiteten Scanlines zurueck*/
+
if ( setjmp( jerr.setjmp_buffer ) )
- goto Exit;
+ return;
cinfo.err = jpeg_std_error( &jerr.pub );
jerr.pub.error_exit = my_error_exit;
jerr.pub.output_message = my_output_message;
jpeg_create_decompress( &cinfo );
- bDecompCreated = 1;
jpeg_svstream_src( &cinfo, pIStm );
jpeg_read_header( &cinfo, sal_True );
@@ -207,10 +199,7 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
pScanLineBuffer=NULL;
}
-Exit:
-
- if( bDecompCreated )
- jpeg_destroy_decompress( &cinfo );
+ jpeg_destroy_decompress( &cinfo );
}
long WriteJPEG( void* pJPEGWriter, void* pOStm,
@@ -221,21 +210,15 @@ long WriteJPEG( void* pJPEGWriter, void* pOStm,
struct my_error_mgr jerr;
void* pScanline;
long nY;
- // declare bCompCreated, bRet volatile because of gcc
- // warning: variable 'bCompCreated' might be clobbered by `longjmp' or `vfork'
- volatile long bCompCreated = 0;
- volatile long bRet = 0;
if ( setjmp( jerr.setjmp_buffer ) )
- goto Exit;
+ return 0;
cinfo.err = jpeg_std_error( &jerr.pub );
jerr.pub.error_exit = my_error_exit;
jerr.pub.output_message = my_output_message;
jpeg_create_compress( &cinfo );
- bCompCreated = 1;
-
jpeg_svstream_dest( &cinfo, pOStm );
cinfo.image_width = (JDIMENSION) nWidth;
@@ -283,19 +266,16 @@ long WriteJPEG( void* pJPEGWriter, void* pOStm,
jpeg_write_scanlines( &cinfo, (JSAMPARRAY) &pScanline, 1 );
if( JPEGCallback( pCallbackData, nY * 100L / nHeight ) )
- goto Exit;
+ {
+ jpeg_destroy_compress( &cinfo );
+ return 0;
+ }
}
- bRet = 1;
-
jpeg_finish_compress(&cinfo);
+ jpeg_destroy_compress( &cinfo );
-Exit:
-
- if ( bCompCreated )
- jpeg_destroy_compress( &cinfo );
-
- return bRet;
+ return 1;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit dc10b3d739ed3a8b6a2a6b54f748f2bac0edf205
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Fri Mar 29 18:04:54 2013 +0100
Add Chroma subsampling options to jpeg writer.
Change-Id: I247a261bb96b0c437a43922070777892cdcbc1f6
diff --git a/vcl/source/filter/jpeg/jpeg.cxx b/vcl/source/filter/jpeg/jpeg.cxx
index 206c92d..837e7c5 100644
--- a/vcl/source/filter/jpeg/jpeg.cxx
+++ b/vcl/source/filter/jpeg/jpeg.cxx
@@ -562,6 +562,7 @@ JPEGWriter::JPEGWriter( SvStream& rStm, const uno::Sequence< beans::PropertyValu
FilterConfigItem aConfigItem( (uno::Sequence< beans::PropertyValue >*)pFilterData );
bGreys = aConfigItem.ReadInt32( "ColorMode", 0 ) != 0;
nQuality = aConfigItem.ReadInt32( "Quality", 75 );
+ aChromaSubsampling = aConfigItem.ReadInt32( "ChromaSubsamplingMode", 0 );
if ( pFilterData )
{
@@ -676,7 +677,7 @@ sal_Bool JPEGWriter::Write( const Graphic& rGraphic )
JPEGCallbackStruct aCallbackData;
aCallbackData.xStatusIndicator = xStatusIndicator;
- bRet = (sal_Bool) WriteJPEG( this, &rOStm, pAcc->Width(), pAcc->Height(), bGreys, nQuality, &aCallbackData );
+ bRet = (sal_Bool) WriteJPEG( this, &rOStm, pAcc->Width(), pAcc->Height(), bGreys, nQuality, aChromaSubsampling, &aCallbackData );
delete[] pBuffer;
pBuffer = NULL;
diff --git a/vcl/source/filter/jpeg/jpeg.h b/vcl/source/filter/jpeg/jpeg.h
index a6b5f0f..cebf81c 100644
--- a/vcl/source/filter/jpeg/jpeg.h
+++ b/vcl/source/filter/jpeg/jpeg.h
@@ -49,7 +49,7 @@ void JPEGFree( void *ptr );
long JPEGCallback( void* pCallbackData, long nPercent );
long WriteJPEG( void* pJPEGWriter, void* pOStm, long nWidth, long nHeight, long bGreyScale,
- long nQualityPercent, void* pCallbackData );
+ long nQualityPercent, long aChromaSubsampling, void* pCallbackData );
void* GetScanline( void* pJPEGWriter, long nY );
void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines );
diff --git a/vcl/source/filter/jpeg/jpeg.hxx b/vcl/source/filter/jpeg/jpeg.hxx
index bd1adae..b77f6c3 100644
--- a/vcl/source/filter/jpeg/jpeg.hxx
+++ b/vcl/source/filter/jpeg/jpeg.hxx
@@ -71,11 +71,12 @@ class JPEGWriter
SvStream& rOStm;
Bitmap aBmp;
BitmapReadAccess* pAcc;
- sal_uInt8* pBuffer;
- sal_Bool bNative;
+ sal_uInt8* pBuffer;
+ sal_Bool bNative;
sal_Bool bGreys;
sal_Int32 nQuality;
+ sal_Int32 aChromaSubsampling;
bool* pExpWasGrey;
diff --git a/vcl/source/filter/jpeg/jpegc.c b/vcl/source/filter/jpeg/jpegc.c
index 16711d9..929c216 100644
--- a/vcl/source/filter/jpeg/jpegc.c
+++ b/vcl/source/filter/jpeg/jpegc.c
@@ -91,7 +91,7 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
jpeg_create_decompress( &cinfo );
bDecompCreated = 1;
- jpeg_svstream_src( &cinfo, pIStm );
+ jpeg_svstream_src( &cinfo, pIStm );
jpeg_read_header( &cinfo, sal_True );
cinfo.scale_num = 1;
@@ -215,7 +215,7 @@ Exit:
long WriteJPEG( void* pJPEGWriter, void* pOStm,
long nWidth, long nHeight, long bGreys,
- long nQualityPercent, void* pCallbackData )
+ long nQualityPercent, long aChromaSubsampling, void* pCallbackData )
{
struct jpeg_compress_struct cinfo;
struct my_error_mgr jerr;
@@ -257,6 +257,22 @@ long WriteJPEG( void* pJPEGWriter, void* pOStm,
if ( ( nWidth > 128 ) || ( nHeight > 128 ) )
jpeg_simple_progression( &cinfo );
+ if (aChromaSubsampling == 1) // YUV 4:4:4
+ {
+ cinfo.comp_info[0].h_samp_factor = 1;
+ cinfo.comp_info[0].v_samp_factor = 1;
+ }
+ else if (aChromaSubsampling == 2) // YUV 4:2:2
+ {
+ cinfo.comp_info[0].h_samp_factor = 2;
+ cinfo.comp_info[0].v_samp_factor = 1;
+ }
+ else if (aChromaSubsampling == 3) // YUV 4:2:0
+ {
+ cinfo.comp_info[0].h_samp_factor = 2;
+ cinfo.comp_info[0].v_samp_factor = 2;
+ }
+
jpeg_start_compress( &cinfo, sal_True );
for( nY = 0; nY < nHeight; nY++ )
More information about the Libreoffice-commits
mailing list