Static WebP decoding a little enhancement. Do not need create WebP iterator for static images.
This commit is contained in:
parent
e59d34fdb7
commit
756e59a995
|
@ -50,15 +50,7 @@ static void FreeImageData(void *info, const void *data, size_t size) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebPIterator iter;
|
|
||||||
if (!WebPDemuxGetFrame(demuxer, 1, &iter)) {
|
|
||||||
WebPDemuxReleaseIterator(&iter);
|
|
||||||
WebPDemuxDelete(demuxer);
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t flags = WebPDemuxGetI(demuxer, WEBP_FF_FORMAT_FLAGS);
|
uint32_t flags = WebPDemuxGetI(demuxer, WEBP_FF_FORMAT_FLAGS);
|
||||||
|
|
||||||
#if SD_UIKIT || SD_WATCH
|
#if SD_UIKIT || SD_WATCH
|
||||||
int loopCount = WebPDemuxGetI(demuxer, WEBP_FF_LOOP_COUNT);
|
int loopCount = WebPDemuxGetI(demuxer, WEBP_FF_LOOP_COUNT);
|
||||||
int frameCount = WebPDemuxGetI(demuxer, WEBP_FF_FRAME_COUNT);
|
int frameCount = WebPDemuxGetI(demuxer, WEBP_FF_FRAME_COUNT);
|
||||||
|
@ -73,7 +65,6 @@ static void FreeImageData(void *info, const void *data, size_t size) {
|
||||||
}
|
}
|
||||||
CGContextRef canvas = CGBitmapContextCreate(NULL, canvasWidth, canvasHeight, 8, 0, SDCGColorSpaceGetDeviceRGB(), bitmapInfo);
|
CGContextRef canvas = CGBitmapContextCreate(NULL, canvasWidth, canvasHeight, 8, 0, SDCGColorSpaceGetDeviceRGB(), bitmapInfo);
|
||||||
if (!canvas) {
|
if (!canvas) {
|
||||||
WebPDemuxReleaseIterator(&iter);
|
|
||||||
WebPDemuxDelete(demuxer);
|
WebPDemuxDelete(demuxer);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -95,13 +86,20 @@ static void FreeImageData(void *info, const void *data, size_t size) {
|
||||||
#endif
|
#endif
|
||||||
CGImageRelease(newImageRef);
|
CGImageRelease(newImageRef);
|
||||||
}
|
}
|
||||||
WebPDemuxReleaseIterator(&iter);
|
|
||||||
WebPDemuxDelete(demuxer);
|
WebPDemuxDelete(demuxer);
|
||||||
CGContextRelease(canvas);
|
CGContextRelease(canvas);
|
||||||
return staticImage;
|
return staticImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for animated webp image
|
// for animated webp image
|
||||||
|
WebPIterator iter;
|
||||||
|
if (!WebPDemuxGetFrame(demuxer, 1, &iter)) {
|
||||||
|
WebPDemuxReleaseIterator(&iter);
|
||||||
|
WebPDemuxDelete(demuxer);
|
||||||
|
CGContextRelease(canvas);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
NSMutableArray<UIImage *> *images = [NSMutableArray array];
|
NSMutableArray<UIImage *> *images = [NSMutableArray array];
|
||||||
#if SD_UIKIT || SD_WATCH
|
#if SD_UIKIT || SD_WATCH
|
||||||
NSTimeInterval totalDuration = 0;
|
NSTimeInterval totalDuration = 0;
|
||||||
|
|
Loading…
Reference in New Issue