Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
a05ebaa1
Kaydet (Commit)
a05ebaa1
authored
Nis 02, 2013
tarafından
Tomaž Vajngerl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Jpeg filter: destroy cinfo at setjmp + minor code clenups
Change-Id: Iceaaf6cf98a4c64a17e88e4d3191cd7649940e82
üst
6709d973
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
43 deletions
+51
-43
jpeg.cxx
vcl/source/filter/jpeg/jpeg.cxx
+28
-20
jpeg.hxx
vcl/source/filter/jpeg/jpeg.hxx
+11
-13
jpegc.c
vcl/source/filter/jpeg/jpegc.c
+12
-10
No files found.
vcl/source/filter/jpeg/jpeg.cxx
Dosyayı görüntüle @
a05ebaa1
...
@@ -73,7 +73,7 @@ typedef struct
...
@@ -73,7 +73,7 @@ typedef struct
JOCTET
*
buffer
;
/* start of buffer */
JOCTET
*
buffer
;
/* start of buffer */
}
my_destination_mgr
;
}
my_destination_mgr
;
typedef
my_destination_mgr
*
my_dest_ptr
;
typedef
my_destination_mgr
*
my_dest_ptr
;
extern
"C"
void
init_destination
(
j_compress_ptr
cinfo
)
extern
"C"
void
init_destination
(
j_compress_ptr
cinfo
)
{
{
...
@@ -281,7 +281,7 @@ JPEGReader::JPEGReader( SvStream& rStm, void* /*pCallData*/, sal_Bool bSetLS ) :
...
@@ -281,7 +281,7 @@ JPEGReader::JPEGReader( SvStream& rStm, void* /*pCallData*/, sal_Bool bSetLS ) :
nLastLines
(
0
),
nLastLines
(
0
),
bSetLogSize
(
bSetLS
)
bSetLogSize
(
bSetLS
)
{
{
maUpperName
=
rtl
::
OUString
(
"SVIJPEG"
);
maUpperName
=
OUString
(
"SVIJPEG"
);
nFormerPos
=
nLastPos
;
nFormerPos
=
nLastPos
;
}
}
...
@@ -483,10 +483,10 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
...
@@ -483,10 +483,10 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
long
nEndPos
;
long
nEndPos
;
long
nLines
;
long
nLines
;
ReadState
eReadState
;
ReadState
eReadState
;
sal_Bool
bRet
=
sal_False
;
sal_Bool
bRet
=
sal_False
;
sal_uInt8
cDummy
;
sal_uInt8
cDummy
;
#if 1
// TODO: is it possible to get rid of this seek to the end?
// TODO: is it possible to get rid of this seek to the end?
// check if the stream's end is already available
// check if the stream's end is already available
rIStm
.
Seek
(
STREAM_SEEK_TO_END
);
rIStm
.
Seek
(
STREAM_SEEK_TO_END
);
rIStm
>>
cDummy
;
rIStm
>>
cDummy
;
...
@@ -505,7 +505,7 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
...
@@ -505,7 +505,7 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
// seek back to the original position
// seek back to the original position
rIStm
.
Seek
(
nLastPos
);
rIStm
.
Seek
(
nLastPos
);
#endif
Size
aPreviewSize
=
GetPreviewSize
();
Size
aPreviewSize
=
GetPreviewSize
();
SetJpegPreviewSizeHint
(
aPreviewSize
.
Width
(),
aPreviewSize
.
Height
()
);
SetJpegPreviewSizeHint
(
aPreviewSize
.
Width
(),
aPreviewSize
.
Height
()
);
...
@@ -526,16 +526,20 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
...
@@ -526,16 +526,20 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
pAcc
=
NULL
;
pAcc
=
NULL
;
if
(
rIStm
.
GetError
()
==
ERRCODE_IO_PENDING
)
if
(
rIStm
.
GetError
()
==
ERRCODE_IO_PENDING
)
{
rGraphic
=
CreateIntermediateGraphic
(
aBmp
,
nLines
);
rGraphic
=
CreateIntermediateGraphic
(
aBmp
,
nLines
);
}
else
else
{
rGraphic
=
aBmp
;
rGraphic
=
aBmp
;
}
bRet
=
sal_True
;
bRet
=
sal_True
;
}
}
else
if
(
rIStm
.
GetError
()
==
ERRCODE_IO_PENDING
)
else
if
(
rIStm
.
GetError
()
==
ERRCODE_IO_PENDING
)
bRet
=
sal_True
;
bRet
=
sal_True
;
// S
tatus setzen ( Pending hat immer Vorrang
)
// S
et status ( Pending has priority
)
if
(
rIStm
.
GetError
()
==
ERRCODE_IO_PENDING
)
if
(
rIStm
.
GetError
()
==
ERRCODE_IO_PENDING
)
{
{
eReadState
=
JPEGREAD_NEED_MORE
;
eReadState
=
JPEGREAD_NEED_MORE
;
...
@@ -553,13 +557,13 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
...
@@ -553,13 +557,13 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
return
eReadState
;
return
eReadState
;
}
}
JPEGWriter
::
JPEGWriter
(
SvStream
&
rStm
,
const
uno
::
Sequence
<
beans
::
PropertyValue
>*
pFilterData
,
bool
*
pExportWasGrey
)
:
JPEGWriter
::
JPEGWriter
(
SvStream
&
rSt
rea
m
,
const
uno
::
Sequence
<
beans
::
PropertyValue
>*
pFilterData
,
bool
*
pExportWasGrey
)
:
rOStm
(
rStm
),
rOStm
(
rSt
rea
m
),
pAcc
(
NULL
),
pAcc
(
NULL
),
pBuffer
(
NULL
),
pBuffer
(
NULL
),
pExpWasGrey
(
pExportWasGrey
)
pExpWasGrey
(
pExportWasGrey
)
{
{
FilterConfigItem
aConfigItem
(
(
uno
::
Sequence
<
beans
::
PropertyValue
>*
)
pFilterData
);
FilterConfigItem
aConfigItem
(
(
uno
::
Sequence
<
beans
::
PropertyValue
>*
)
pFilterData
);
bGreys
=
aConfigItem
.
ReadInt32
(
"ColorMode"
,
0
)
!=
0
;
bGreys
=
aConfigItem
.
ReadInt32
(
"ColorMode"
,
0
)
!=
0
;
nQuality
=
aConfigItem
.
ReadInt32
(
"Quality"
,
75
);
nQuality
=
aConfigItem
.
ReadInt32
(
"Quality"
,
75
);
aChromaSubsampling
=
aConfigItem
.
ReadInt32
(
"ChromaSubsamplingMode"
,
0
);
aChromaSubsampling
=
aConfigItem
.
ReadInt32
(
"ChromaSubsamplingMode"
,
0
);
...
@@ -586,12 +590,14 @@ void* JPEGWriter::GetScanline( long nY )
...
@@ -586,12 +590,14 @@ void* JPEGWriter::GetScanline( long nY )
if
(
pAcc
)
if
(
pAcc
)
{
{
if
(
bNative
)
if
(
bNative
)
{
pScanline
=
pAcc
->
GetScanline
(
nY
);
pScanline
=
pAcc
->
GetScanline
(
nY
);
}
else
if
(
pBuffer
)
else
if
(
pBuffer
)
{
{
BitmapColor
aColor
;
BitmapColor
aColor
;
long
nWidth
=
pAcc
->
Width
();
long
nWidth
=
pAcc
->
Width
();
sal_uInt8
*
pTmp
=
pBuffer
;
sal_uInt8
*
pTmp
=
pBuffer
;
if
(
pAcc
->
HasPalette
()
)
if
(
pAcc
->
HasPalette
()
)
{
{
...
@@ -599,10 +605,11 @@ void* JPEGWriter::GetScanline( long nY )
...
@@ -599,10 +605,11 @@ void* JPEGWriter::GetScanline( long nY )
{
{
aColor
=
pAcc
->
GetPaletteColor
(
(
sal_uInt8
)
pAcc
->
GetPixel
(
nY
,
nX
)
);
aColor
=
pAcc
->
GetPaletteColor
(
(
sal_uInt8
)
pAcc
->
GetPixel
(
nY
,
nX
)
);
*
pTmp
++
=
aColor
.
GetRed
();
*
pTmp
++
=
aColor
.
GetRed
();
if
(
bGreys
)
if
(
!
bGreys
)
continue
;
{
*
pTmp
++
=
aColor
.
GetGreen
();
*
pTmp
++
=
aColor
.
GetGreen
();
*
pTmp
++
=
aColor
.
GetBlue
();
*
pTmp
++
=
aColor
.
GetBlue
();
}
}
}
}
}
else
else
...
@@ -611,10 +618,11 @@ void* JPEGWriter::GetScanline( long nY )
...
@@ -611,10 +618,11 @@ void* JPEGWriter::GetScanline( long nY )
{
{
aColor
=
pAcc
->
GetPixel
(
nY
,
nX
);
aColor
=
pAcc
->
GetPixel
(
nY
,
nX
);
*
pTmp
++
=
aColor
.
GetRed
();
*
pTmp
++
=
aColor
.
GetRed
();
if
(
bGreys
)
if
(
!
bGreys
)
continue
;
{
*
pTmp
++
=
aColor
.
GetGreen
();
*
pTmp
++
=
aColor
.
GetGreen
();
*
pTmp
++
=
aColor
.
GetBlue
();
*
pTmp
++
=
aColor
.
GetBlue
();
}
}
}
}
}
...
@@ -631,7 +639,7 @@ sal_Bool JPEGWriter::Write( const Graphic& rGraphic )
...
@@ -631,7 +639,7 @@ sal_Bool JPEGWriter::Write( const Graphic& rGraphic )
if
(
xStatusIndicator
.
is
()
)
if
(
xStatusIndicator
.
is
()
)
{
{
rtl
::
OUString
aMsg
;
OUString
aMsg
;
xStatusIndicator
->
start
(
aMsg
,
100
);
xStatusIndicator
->
start
(
aMsg
,
100
);
}
}
...
...
vcl/source/filter/jpeg/jpeg.hxx
Dosyayı görüntüle @
a05ebaa1
...
@@ -56,9 +56,6 @@ public:
...
@@ -56,9 +56,6 @@ public:
void
*
CreateBitmap
(
void
*
JPEGCreateBitmapParam
);
void
*
CreateBitmap
(
void
*
JPEGCreateBitmapParam
);
public
:
public
:
JPEGReader
(
SvStream
&
rStm
,
void
*
pCallData
,
sal_Bool
bSetLogSize
);
JPEGReader
(
SvStream
&
rStm
,
void
*
pCallData
,
sal_Bool
bSetLogSize
);
virtual
~
JPEGReader
();
virtual
~
JPEGReader
();
...
@@ -84,24 +81,25 @@ class JPEGWriter
...
@@ -84,24 +81,25 @@ class JPEGWriter
public
:
public
:
void
*
GetScanline
(
long
nY
);
void
*
GetScanline
(
long
nY
);
JPEGWriter
(
SvStream
&
rOStm
,
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>*
pFilterData
,
bool
*
pExportWasGrey
=
NULL
);
JPEGWriter
(
SvStream
&
rOStm
,
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>*
pFilterData
,
~
JPEGWriter
()
{};
bool
*
pExportWasGrey
=
NULL
);
~
JPEGWriter
()
{};
sal_Bool
Write
(
const
Graphic
&
rGraphic
);
sal_Bool
Write
(
const
Graphic
&
rGraphic
);
};
};
#endif // _JPEGPRIVATE
#endif // _JPEGPRIVATE
sal_Bool
ImportJPEG
(
SvStream
&
rStream
,
Graphic
&
rGraphic
,
void
*
pCallerData
,
sal_Int32
nImportFlags
);
sal_Bool
ImportJPEG
(
SvStream
&
rStream
,
Graphic
&
rGraphic
,
void
*
pCallerData
,
sal_Int32
nImportFlags
);
sal_Bool
ExportJPEG
(
SvStream
&
rStream
,
sal_Bool
ExportJPEG
(
SvStream
&
rStream
,
const
Graphic
&
rGraphic
,
const
Graphic
&
rGraphic
,
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>*
pFilterData
,
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>*
pFilterData
,
bool
*
pExportWasGrey
=
NULL
bool
*
pExportWasGrey
=
NULL
);
);
#endif // _JPEG_HXX
#endif // _JPEG_HXX
...
...
vcl/source/filter/jpeg/jpegc.c
Dosyayı görüntüle @
a05ebaa1
...
@@ -35,8 +35,7 @@ struct my_error_mgr
...
@@ -35,8 +35,7 @@ struct my_error_mgr
void
jpeg_svstream_src
(
j_decompress_ptr
cinfo
,
void
*
infile
);
void
jpeg_svstream_src
(
j_decompress_ptr
cinfo
,
void
*
infile
);
void
jpeg_svstream_dest
(
j_compress_ptr
cinfo
,
void
*
outfile
);
void
jpeg_svstream_dest
(
j_compress_ptr
cinfo
,
void
*
outfile
);
METHODDEF
(
void
)
METHODDEF
(
void
)
my_error_exit
(
j_common_ptr
cinfo
)
my_error_exit
(
j_common_ptr
cinfo
)
{
{
my_error_ptr
myerr
=
(
my_error_ptr
)
cinfo
->
err
;
my_error_ptr
myerr
=
(
my_error_ptr
)
cinfo
->
err
;
(
*
cinfo
->
err
->
output_message
)
(
cinfo
);
(
*
cinfo
->
err
->
output_message
)
(
cinfo
);
...
@@ -44,8 +43,7 @@ my_error_exit (j_common_ptr cinfo)
...
@@ -44,8 +43,7 @@ my_error_exit (j_common_ptr cinfo)
}
}
METHODDEF
(
void
)
METHODDEF
(
void
)
my_output_message
(
j_common_ptr
cinfo
)
my_output_message
(
j_common_ptr
cinfo
)
{
{
char
buffer
[
JMSG_LENGTH_MAX
];
char
buffer
[
JMSG_LENGTH_MAX
];
(
*
cinfo
->
err
->
format_message
)
(
cinfo
,
buffer
);
(
*
cinfo
->
err
->
format_message
)
(
cinfo
,
buffer
);
...
@@ -76,7 +74,10 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
...
@@ -76,7 +74,10 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
long
nScanLineBufferComponents
=
0
;
long
nScanLineBufferComponents
=
0
;
if
(
setjmp
(
jerr
.
setjmp_buffer
)
)
if
(
setjmp
(
jerr
.
setjmp_buffer
)
)
{
jpeg_destroy_decompress
(
&
cinfo
);
return
;
return
;
}
cinfo
.
err
=
jpeg_std_error
(
&
jerr
.
pub
);
cinfo
.
err
=
jpeg_std_error
(
&
jerr
.
pub
);
jerr
.
pub
.
error_exit
=
my_error_exit
;
jerr
.
pub
.
error_exit
=
my_error_exit
;
...
@@ -144,7 +145,7 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
...
@@ -144,7 +145,7 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
if
(
cinfo
.
out_color_space
==
JCS_CMYK
)
if
(
cinfo
.
out_color_space
==
JCS_CMYK
)
{
{
nScanLineBufferComponents
=
cinfo
.
output_width
*
4
;
nScanLineBufferComponents
=
cinfo
.
output_width
*
4
;
pScanLineBuffer
=
rtl_allocateMemory
(
nScanLineBufferComponents
);
pScanLineBuffer
=
rtl_allocateMemory
(
nScanLineBufferComponents
);
}
}
...
@@ -187,14 +188,12 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
...
@@ -187,14 +188,12 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
}
}
if
(
pDIB
)
if
(
pDIB
)
{
jpeg_finish_decompress
(
&
cinfo
);
jpeg_finish_decompress
(
&
cinfo
);
}
else
else
{
jpeg_abort_decompress
(
&
cinfo
);
jpeg_abort_decompress
(
&
cinfo
);
}
if
(
pScanLineBuffer
!=
NULL
)
{
if
(
pScanLineBuffer
!=
NULL
)
{
rtl_freeMemory
(
pScanLineBuffer
);
rtl_freeMemory
(
pScanLineBuffer
);
pScanLineBuffer
=
NULL
;
pScanLineBuffer
=
NULL
;
}
}
...
@@ -212,7 +211,10 @@ long WriteJPEG( void* pJPEGWriter, void* pOStm,
...
@@ -212,7 +211,10 @@ long WriteJPEG( void* pJPEGWriter, void* pOStm,
long
nY
;
long
nY
;
if
(
setjmp
(
jerr
.
setjmp_buffer
)
)
if
(
setjmp
(
jerr
.
setjmp_buffer
)
)
{
jpeg_destroy_compress
(
&
cinfo
);
return
0
;
return
0
;
}
cinfo
.
err
=
jpeg_std_error
(
&
jerr
.
pub
);
cinfo
.
err
=
jpeg_std_error
(
&
jerr
.
pub
);
jerr
.
pub
.
error_exit
=
my_error_exit
;
jerr
.
pub
.
error_exit
=
my_error_exit
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment