From 7d67356c44422fb748b0d2d4aee85872bae17768 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Wed, 21 Aug 2019 15:18:42 +0800 Subject: [PATCH] Fix the compatible for libavif 1.0.4 version. Which use YUV as default and no RGB plane is decoded, unless you call. --- Cartfile.resolved | 4 ++-- Example/Podfile.lock | 20 +++++++++---------- README.md | 4 ++-- SDWebImageAVIFCoder.podspec | 2 +- .../Classes/SDImageAVIFCoder.m | 3 +++ 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 50f039f..443d988 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,3 @@ -github "SDWebImage/SDWebImage" "5.0.2" +github "SDWebImage/SDWebImage" "5.1.0" github "SDWebImage/libaom-Xcode" "1.0.1" -github "SDWebImage/libavif-Xcode" "0.1.3" +github "SDWebImage/libavif-Xcode" "0.1.4" diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 46a1186..7331700 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,12 +1,12 @@ PODS: - libaom (1.0.1) - - libavif (0.1.3): + - libavif (0.1.4): - libaom (>= 1.0.1) - - SDWebImage (5.0.2): - - SDWebImage/Core (= 5.0.2) - - SDWebImage/Core (5.0.2) - - SDWebImageAVIFCoder (0.1.0): - - libavif (>= 0.1.3) + - SDWebImage (5.1.0): + - SDWebImage/Core (= 5.1.0) + - SDWebImage/Core (5.1.0) + - SDWebImageAVIFCoder (0.2.0): + - libavif (~> 0.1.4) - SDWebImage (~> 5.0) DEPENDENCIES: @@ -24,10 +24,10 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: libaom: 1e48c68559b8d6191c1a9f266e0bee83b2dd21fd - libavif: b6de15e6a91a347806b2fcc1fccd471c821f6d6a - SDWebImage: 6764b5fa0f73c203728052955dbefa2bf1f33282 - SDWebImageAVIFCoder: 1e80598038f37e20a83a7a790cb192e0b362a557 + libavif: 4f94ed672d45d6651ee0f784f5faf11b95449716 + SDWebImage: fb387001955223213dde14bc08c8b73f371f8d8f + SDWebImageAVIFCoder: ec08ff2cf12552223b51b7253c8201d264ecbbac PODFILE CHECKSUM: cb60778bff8fb5ce4fbc8792f6079317b7a897be -COCOAPODS: 1.6.1 +COCOAPODS: 1.7.5 diff --git a/README.md b/README.md index f459bcf..b07b8a1 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## What's for -This is a [SDWebImage](https://github.com/rs/SDWebImage) coder plugin to add [AV1 Image File Format (AVIF)](https://aomediacodec.github.io/av1-avif/) support. Which is built based on the open-sourced [libavif](https://github.com/joedrago/avif) codec. +This is a [SDWebImage](https://github.com/rs/SDWebImage) coder plugin to add [AV1 Image File Format (AVIF)](https://aomediacodec.github.io/av1-avif/) support. Which is built based on the open-sourced [libavif](https://github.com/AOMediaCodec/libavif) codec. This AVIF coder plugin currently support AVIF still image **decoding**. Including alpha channel, as well as 10bit/12bit HDR images. @@ -92,7 +92,7 @@ SDWebImageAVIFCoder is available under the MIT license. See the LICENSE file for ## Thanks -+ [libavif](https://github.com/joedrago/avif) ++ [libavif](https://github.com/AOMediaCodec/libavif) + [aom](https://aomedia.googlesource.com/aom/) + [AVIFQuickLook](https://github.com/dreampiggy/AVIFQuickLook) + [avif.js](https://github.com/Kagami/avif.js) diff --git a/SDWebImageAVIFCoder.podspec b/SDWebImageAVIFCoder.podspec index d99c9e9..577117b 100644 --- a/SDWebImageAVIFCoder.podspec +++ b/SDWebImageAVIFCoder.podspec @@ -36,5 +36,5 @@ Which is built based on the open-sourced libavif codec. s.source_files = 'SDWebImageAVIFCoder/Classes/**/*', 'SDWebImageAVIFCoder/Module/SDWebImageAVIFCoder.h' s.dependency 'SDWebImage', '~> 5.0' - s.dependency 'libavif', '>= 0.1.3' + s.dependency 'libavif', '~> 0.1.4' end diff --git a/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m b/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m index 559c871..768d8b4 100644 --- a/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m +++ b/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m @@ -134,6 +134,9 @@ - (nullable CGImageRef)sd_createAVIFImageWithData:(nonnull NSData *)data CF_RETU return nil; } + // use RGB instead of YUV + avifImageYUVToRGB(avif); + int width = avif->width; int height = avif->height; BOOL hasAlpha = avif->alphaPlane != NULL;