[Libreoffice-commits] core.git: vcl/source
Caolán McNamara
caolanm at redhat.com
Thu Jan 25 20:33:07 UTC 2018
vcl/source/filter/igif/gifread.cxx | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
New commits:
commit 2839be08281b4c6b23b9ecdbb4da2032788b6223
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Jan 25 16:41:25 2018 +0000
ofz: cache animation size to avoid timeout
Change-Id: Iede591487782a941a9915123b83537ddadd1b4c5
Reviewed-on: https://gerrit.libreoffice.org/48629
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx
index 2afaa92d16d2..78ed3036e67f 100644
--- a/vcl/source/filter/igif/gifread.cxx
+++ b/vcl/source/filter/igif/gifread.cxx
@@ -50,6 +50,8 @@ class SvStream;
class GIFReader : public GraphicReader
{
Animation aAnimation;
+ sal_uInt64 nAnimationByteSize;
+ sal_uInt64 nAnimationMinFileData;
Bitmap aBmp8;
Bitmap aBmp1;
BitmapPalette aGPalette;
@@ -109,7 +111,9 @@ public:
};
GIFReader::GIFReader( SvStream& rStm )
- : aGPalette ( 256 )
+ : nAnimationByteSize(0)
+ , nAnimationMinFileData(0)
+ , aGPalette ( 256 )
, aLPalette ( 256 )
, rIStm ( rStm )
, nYAcc ( 0 )
@@ -167,13 +171,8 @@ void GIFReader::CreateBitmaps( long nWidth, long nHeight, BitmapPalette* pPal,
// 1:1472.88 [184.11 x 8] is more realistic)
sal_uInt64 nMinFileData = nWidth * nHeight / 2560;
- for (size_t i = 0; i < aAnimation.Count(); ++i)
- {
- const AnimationBitmap& rBitmap = aAnimation.Get(i);
- const Size& rSize = rBitmap.aSizePix;
- nMinFileData += rSize.Width() * rSize.Height() / 2560;
- nCombinedPixSize += rBitmap.aBmpEx.GetSizeBytes();
- }
+ nMinFileData += nAnimationMinFileData;
+ nCombinedPixSize += nAnimationByteSize;
if (nMaxStreamData < nMinFileData)
{
@@ -662,6 +661,8 @@ void GIFReader::CreateNewBitmaps()
else
aAnimBmp.eDisposal = Disposal::Not;
+ nAnimationByteSize += aAnimBmp.aBmpEx.GetSizeBytes();
+ nAnimationMinFileData += nImageWidth * nImageHeight / 2560;
aAnimation.Insert( aAnimBmp );
if( aAnimation.Count() == 1 )
More information about the Libreoffice-commits
mailing list