diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-01-25 16:41:25 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-01-25 21:32:41 +0100 |
commit | 2839be08281b4c6b23b9ecdbb4da2032788b6223 (patch) | |
tree | 3e6abb75f0ba3f0ca715f1fcd2a6152be0fec6ac /vcl | |
parent | 80ac1dc53ba2aac97bce067495f7f60c6acabadd (diff) |
ofz: cache animation size to avoid timeout
Change-Id: Iede591487782a941a9915123b83537ddadd1b4c5
Reviewed-on: https://gerrit.libreoffice.org/48629
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/filter/igif/gifread.cxx | 17 |
1 files changed, 9 insertions, 8 deletions
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 ) |