From: Jaehyun Cho Date: Thu, 21 Apr 2022 09:19:44 +0000 (+0900) Subject: [Tizen] Webp-loading, Fix svace issue and change the way to get animation flag X-Git-Tag: accepted/tizen/unified/20220422.021308^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=6447b60d3ab65fea8111ef8342913fc5c56f7f23 [Tizen] Webp-loading, Fix svace issue and change the way to get animation flag This reverts commit 4b6d3354de5664bf233b002041f2317855749d5f. --- diff --git a/dali/internal/imaging/common/webp-loading.cpp b/dali/internal/imaging/common/webp-loading.cpp index 0cb8932..a5b8dab 100644 --- a/dali/internal/imaging/common/webp-loading.cpp +++ b/dali/internal/imaging/common/webp-loading.cpp @@ -113,12 +113,30 @@ 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; @@ -129,16 +147,6 @@ 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 @@ -178,32 +186,14 @@ public: } } - fp = fileReader->GetFile(); + if(fileReader) + { + 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)) @@ -225,14 +215,16 @@ 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); @@ -273,8 +265,11 @@ public: bool mIsAnimatedImage; bool mIsLocalResource; -#ifdef DALI_ANIMATED_WEBP_ENABLED +#ifdef DALI_WEBP_AVAILABLE WebPData mWebPData{0}; +#endif + +#ifdef DALI_ANIMATED_WEBP_ENABLED WebPAnimDecoder* mWebPAnimDecoder{nullptr}; WebPAnimInfo mWebPAnimInfo{0}; Dali::Devel::PixelBuffer mPreLoadedFrame{};