From: Daekwang Ryu Date: Tue, 26 Apr 2022 01:46:38 +0000 (+0900) Subject: Revert "[Tizen] Webp-loading, Fix svace issue and change the way to get animation... X-Git-Tag: accepted/tizen/unified/20220429.003436~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=e7626ab85651f67bbf40baf7ced57b2d7b0dccf5 Revert "[Tizen] Webp-loading, Fix svace issue and change the way to get animation flag" This reverts commit 6447b60d3ab65fea8111ef8342913fc5c56f7f23. --- diff --git a/dali/internal/imaging/common/webp-loading.cpp b/dali/internal/imaging/common/webp-loading.cpp index a5b8dab..0cb8932 100644 --- a/dali/internal/imaging/common/webp-loading.cpp +++ b/dali/internal/imaging/common/webp-loading.cpp @@ -113,30 +113,12 @@ public: // mFrameCount will be 1 if the input image is non-animated image or animated image with single frame. if(DALI_LIKELY(ReadWebPInformation())) { -#ifdef DALI_WEBP_AVAILABLE - WebPDataInit(&mWebPData); - mWebPData.size = mBufferSize; - mWebPData.bytes = mBuffer; - - WebPDemuxer* demuxer = WebPDemux(&mWebPData); - uint32_t flags = WebPDemuxGetI(demuxer, WEBP_FF_FORMAT_FLAGS); - if(flags & ANIMATION_FLAG) - { - mIsAnimatedImage = true; - } - - if(!mIsAnimatedImage) - { - int32_t imageWidth, imageHeight; - if(WebPGetInfo(mBuffer, mBufferSize, &imageWidth, &imageHeight)) - { - mImageSize = ImageDimensions(imageWidth, imageHeight); - } - } -#endif #ifdef DALI_ANIMATED_WEBP_ENABLED if(mIsAnimatedImage) { + WebPDataInit(&mWebPData); + mWebPData.size = mBufferSize; + mWebPData.bytes = mBuffer; WebPAnimDecoderOptions webPAnimDecoderOptions; WebPAnimDecoderOptionsInit(&webPAnimDecoderOptions); webPAnimDecoderOptions.color_mode = MODE_RGBA; @@ -147,6 +129,16 @@ public: mImageSize = ImageDimensions(mWebPAnimInfo.canvas_width, mWebPAnimInfo.canvas_height); } #endif +#ifdef DALI_WEBP_AVAILABLE + if(!mIsAnimatedImage) + { + int32_t imageWidth, imageHeight; + if(WebPGetInfo(mBuffer, mBufferSize, &imageWidth, &imageHeight)) + { + mImageSize = ImageDimensions(imageWidth, imageHeight); + } + } +#endif mLoadSucceeded = true; } else @@ -186,14 +178,32 @@ public: } } - if(fileReader) - { - fp = fileReader->GetFile(); - } + fp = fileReader->GetFile(); } if(DALI_LIKELY(fp != nullptr)) { + if(DALI_LIKELY(!fseek(fp, 12, SEEK_SET))) + { + uint8_t mHeaderBuffer[5]; + fread(mHeaderBuffer, sizeof(WebPByteType), 5, fp); + unsigned char VP8X[4] = {'V', 'P', '8', 'X'}; + bool isExtended = true; + for(uint32_t i = 0; i < 4; ++i) + { + if(mHeaderBuffer[i] != VP8X[i]) + { + isExtended = false; + break; + } + } + if(isExtended) + { + unsigned char extension = mHeaderBuffer[4]; + mIsAnimatedImage = ((extension >> 1) & 1) ? true : false; + } + } + if(mBufferSize == 0) { if(DALI_UNLIKELY(fseek(fp, 0, SEEK_END) <= -1)) @@ -215,16 +225,14 @@ public: void ReleaseResource() { -#ifdef DALI_WEBP_AVAILABLE - if(&mWebPData != nullptr) - { - mWebPData.bytes = nullptr; - WebPDataInit(&mWebPData); - } -#endif #ifdef DALI_ANIMATED_WEBP_ENABLED if(mIsAnimatedImage) { + if(&mWebPData != nullptr) + { + mWebPData.bytes = nullptr; + WebPDataInit(&mWebPData); + } if(mWebPAnimDecoder != nullptr) { WebPAnimDecoderDelete(mWebPAnimDecoder); @@ -265,11 +273,8 @@ public: bool mIsAnimatedImage; bool mIsLocalResource; -#ifdef DALI_WEBP_AVAILABLE - WebPData mWebPData{0}; -#endif - #ifdef DALI_ANIMATED_WEBP_ENABLED + WebPData mWebPData{0}; WebPAnimDecoder* mWebPAnimDecoder{nullptr}; WebPAnimInfo mWebPAnimInfo{0}; Dali::Devel::PixelBuffer mPreLoadedFrame{};