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
JOCTET
*
buffer
;
/* start of buffer */
}
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
)
{
...
...
@@ -281,7 +281,7 @@ JPEGReader::JPEGReader( SvStream& rStm, void* /*pCallData*/, sal_Bool bSetLS ) :
nLastLines
(
0
),
bSetLogSize
(
bSetLS
)
{
maUpperName
=
rtl
::
OUString
(
"SVIJPEG"
);
maUpperName
=
OUString
(
"SVIJPEG"
);
nFormerPos
=
nLastPos
;
}
...
...
@@ -483,10 +483,10 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
long
nEndPos
;
long
nLines
;
ReadState
eReadState
;
sal_Bool
bRet
=
sal_False
;
sal_uInt8
cDummy
;
sal_Bool
bRet
=
sal_False
;
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
rIStm
.
Seek
(
STREAM_SEEK_TO_END
);
rIStm
>>
cDummy
;
...
...
@@ -505,7 +505,7 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
// seek back to the original position
rIStm
.
Seek
(
nLastPos
);
#endif
Size
aPreviewSize
=
GetPreviewSize
();
SetJpegPreviewSizeHint
(
aPreviewSize
.
Width
(),
aPreviewSize
.
Height
()
);
...
...
@@ -526,16 +526,20 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
pAcc
=
NULL
;
if
(
rIStm
.
GetError
()
==
ERRCODE_IO_PENDING
)
{
rGraphic
=
CreateIntermediateGraphic
(
aBmp
,
nLines
);
}
else
{
rGraphic
=
aBmp
;
}
bRet
=
sal_True
;
}
else
if
(
rIStm
.
GetError
()
==
ERRCODE_IO_PENDING
)
bRet
=
sal_True
;
// S
tatus setzen ( Pending hat immer Vorrang
)
// S
et status ( Pending has priority
)
if
(
rIStm
.
GetError
()
==
ERRCODE_IO_PENDING
)
{
eReadState
=
JPEGREAD_NEED_MORE
;
...
...
@@ -553,13 +557,13 @@ ReadState JPEGReader::Read( Graphic& rGraphic )
return
eReadState
;
}
JPEGWriter
::
JPEGWriter
(
SvStream
&
rStm
,
const
uno
::
Sequence
<
beans
::
PropertyValue
>*
pFilterData
,
bool
*
pExportWasGrey
)
:
rOStm
(
rStm
),
JPEGWriter
::
JPEGWriter
(
SvStream
&
rSt
rea
m
,
const
uno
::
Sequence
<
beans
::
PropertyValue
>*
pFilterData
,
bool
*
pExportWasGrey
)
:
rOStm
(
rSt
rea
m
),
pAcc
(
NULL
),
pBuffer
(
NULL
),
pExpWasGrey
(
pExportWasGrey
)
{
FilterConfigItem
aConfigItem
(
(
uno
::
Sequence
<
beans
::
PropertyValue
>*
)
pFilterData
);
FilterConfigItem
aConfigItem
(
(
uno
::
Sequence
<
beans
::
PropertyValue
>*
)
pFilterData
);
bGreys
=
aConfigItem
.
ReadInt32
(
"ColorMode"
,
0
)
!=
0
;
nQuality
=
aConfigItem
.
ReadInt32
(
"Quality"
,
75
);
aChromaSubsampling
=
aConfigItem
.
ReadInt32
(
"ChromaSubsamplingMode"
,
0
);
...
...
@@ -586,12 +590,14 @@ void* JPEGWriter::GetScanline( long nY )
if
(
pAcc
)
{
if
(
bNative
)
{
pScanline
=
pAcc
->
GetScanline
(
nY
);
}
else
if
(
pBuffer
)
{
BitmapColor
aColor
;
long
nWidth
=
pAcc
->
Width
();
sal_uInt8
*
pTmp
=
pBuffer
;
sal_uInt8
*
pTmp
=
pBuffer
;
if
(
pAcc
->
HasPalette
()
)
{
...
...
@@ -599,10 +605,11 @@ void* JPEGWriter::GetScanline( long nY )
{
aColor
=
pAcc
->
GetPaletteColor
(
(
sal_uInt8
)
pAcc
->
GetPixel
(
nY
,
nX
)
);
*
pTmp
++
=
aColor
.
GetRed
();
if
(
bGreys
)
continue
;
*
pTmp
++
=
aColor
.
GetGreen
();
*
pTmp
++
=
aColor
.
GetBlue
();
if
(
!
bGreys
)
{
*
pTmp
++
=
aColor
.
GetGreen
();
*
pTmp
++
=
aColor
.
GetBlue
();
}
}
}
else
...
...
@@ -611,10 +618,11 @@ void* JPEGWriter::GetScanline( long nY )
{
aColor
=
pAcc
->
GetPixel
(
nY
,
nX
);
*
pTmp
++
=
aColor
.
GetRed
();
if
(
bGreys
)
continue
;
*
pTmp
++
=
aColor
.
GetGreen
();
*
pTmp
++
=
aColor
.
GetBlue
();
if
(
!
bGreys
)
{
*
pTmp
++
=
aColor
.
GetGreen
();
*
pTmp
++
=
aColor
.
GetBlue
();
}
}
}
...
...
@@ -631,7 +639,7 @@ sal_Bool JPEGWriter::Write( const Graphic& rGraphic )
if
(
xStatusIndicator
.
is
()
)
{
rtl
::
OUString
aMsg
;
OUString
aMsg
;
xStatusIndicator
->
start
(
aMsg
,
100
);
}
...
...
vcl/source/filter/jpeg/jpeg.hxx
Dosyayı görüntüle @
a05ebaa1
...
...
@@ -56,9 +56,6 @@ public:
void
*
CreateBitmap
(
void
*
JPEGCreateBitmapParam
);
public
:
JPEGReader
(
SvStream
&
rStm
,
void
*
pCallData
,
sal_Bool
bSetLogSize
);
virtual
~
JPEGReader
();
...
...
@@ -84,24 +81,25 @@ class JPEGWriter
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
,
bool
*
pExportWasGrey
=
NULL
);
~
JPEGWriter
()
{};
~
JPEGWriter
()
{};
sal_Bool
Write
(
const
Graphic
&
rGraphic
);
sal_Bool
Write
(
const
Graphic
&
rGraphic
);
};
#endif // _JPEGPRIVATE
sal_Bool
ImportJPEG
(
SvStream
&
rStream
,
Graphic
&
rGraphic
,
void
*
pCallerData
,
sal_Int32
nImportFlags
);
sal_Bool
ExportJPEG
(
SvStream
&
rStream
,
const
Graphic
&
rGraphic
,
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>*
pFilterData
,
bool
*
pExportWasGrey
=
NULL
);
sal_Bool
ExportJPEG
(
SvStream
&
rStream
,
const
Graphic
&
rGraphic
,
const
::
com
::
sun
::
star
::
uno
::
Sequence
<
::
com
::
sun
::
star
::
beans
::
PropertyValue
>*
pFilterData
,
bool
*
pExportWasGrey
=
NULL
);
#endif // _JPEG_HXX
...
...
vcl/source/filter/jpeg/jpegc.c
Dosyayı görüntüle @
a05ebaa1
...
...
@@ -35,8 +35,7 @@ struct my_error_mgr
void
jpeg_svstream_src
(
j_decompress_ptr
cinfo
,
void
*
infile
);
void
jpeg_svstream_dest
(
j_compress_ptr
cinfo
,
void
*
outfile
);
METHODDEF
(
void
)
my_error_exit
(
j_common_ptr
cinfo
)
METHODDEF
(
void
)
my_error_exit
(
j_common_ptr
cinfo
)
{
my_error_ptr
myerr
=
(
my_error_ptr
)
cinfo
->
err
;
(
*
cinfo
->
err
->
output_message
)
(
cinfo
);
...
...
@@ -44,8 +43,7 @@ my_error_exit (j_common_ptr cinfo)
}
METHODDEF
(
void
)
my_output_message
(
j_common_ptr
cinfo
)
METHODDEF
(
void
)
my_output_message
(
j_common_ptr
cinfo
)
{
char
buffer
[
JMSG_LENGTH_MAX
];
(
*
cinfo
->
err
->
format_message
)
(
cinfo
,
buffer
);
...
...
@@ -76,7 +74,10 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
long
nScanLineBufferComponents
=
0
;
if
(
setjmp
(
jerr
.
setjmp_buffer
)
)
{
jpeg_destroy_decompress
(
&
cinfo
);
return
;
}
cinfo
.
err
=
jpeg_std_error
(
&
jerr
.
pub
);
jerr
.
pub
.
error_exit
=
my_error_exit
;
...
...
@@ -144,7 +145,7 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
if
(
cinfo
.
out_color_space
==
JCS_CMYK
)
{
nScanLineBufferComponents
=
cinfo
.
output_width
*
4
;
nScanLineBufferComponents
=
cinfo
.
output_width
*
4
;
pScanLineBuffer
=
rtl_allocateMemory
(
nScanLineBufferComponents
);
}
...
...
@@ -187,14 +188,12 @@ void ReadJPEG( void* pJPEGReader, void* pIStm, long* pLines )
}
if
(
pDIB
)
{
jpeg_finish_decompress
(
&
cinfo
);
}
else
{
jpeg_abort_decompress
(
&
cinfo
);
}
if
(
pScanLineBuffer
!=
NULL
)
{
if
(
pScanLineBuffer
!=
NULL
)
{
rtl_freeMemory
(
pScanLineBuffer
);
pScanLineBuffer
=
NULL
;
}
...
...
@@ -212,7 +211,10 @@ long WriteJPEG( void* pJPEGWriter, void* pOStm,
long
nY
;
if
(
setjmp
(
jerr
.
setjmp_buffer
)
)
{
jpeg_destroy_compress
(
&
cinfo
);
return
0
;
}
cinfo
.
err
=
jpeg_std_error
(
&
jerr
.
pub
);
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