Skip to content

Commit 7fa46ad

Browse files
committed
Upgrade the libavif to v0.3.0, fix the API changes. Use dav1d if available
1 parent e75bb2b commit 7fa46ad

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

Example/Podfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
target 'SDWebImageAVIFCoder_Example' do
44
platform :ios, '8.0'
55
pod 'SDWebImageAVIFCoder', :path => '../'
6+
pod 'libavif', :subspecs => ['libaom', 'libdav1d']
67

78
target 'SDWebImageAVIFCoder_Tests' do
89
inherit! :search_paths
@@ -14,4 +15,5 @@ end
1415
target 'SDWebImageAVIFCoder_Example macOS' do
1516
platform :osx, '10.10'
1617
pod 'SDWebImageAVIFCoder', :path => '../'
18+
pod 'libavif', :subspecs => ['libaom', 'libdav1d']
1719
end

Example/Podfile.lock

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
PODS:
22
- libaom (1.0.1)
3-
- libavif (0.2.0):
3+
- libavif (0.3.0):
4+
- libavif/libaom (= 0.3.0)
5+
- libavif/libaom (0.3.0):
46
- libaom (>= 1.0.1)
5-
- SDWebImage (5.1.0):
6-
- SDWebImage/Core (= 5.1.0)
7-
- SDWebImage/Core (5.1.0)
8-
- SDWebImageAVIFCoder (0.2.1):
9-
- libavif (~> 0.2.0)
7+
- libavif/libdav1d (0.3.0):
8+
- libavif/libaom
9+
- libdav1d (>= 0.4.0)
10+
- libdav1d (0.4.0)
11+
- SDWebImage (5.2.2):
12+
- SDWebImage/Core (= 5.2.2)
13+
- SDWebImage/Core (5.2.2)
14+
- SDWebImageAVIFCoder (0.3.0):
15+
- libavif (~> 0.3.0)
1016
- SDWebImage (~> 5.0)
1117

1218
DEPENDENCIES:
19+
- libavif/libaom
20+
- libavif/libdav1d
1321
- SDWebImageAVIFCoder (from `../`)
1422

1523
SPEC REPOS:
1624
https://github.com/cocoapods/specs.git:
1725
- libaom
1826
- libavif
27+
- libdav1d
1928
- SDWebImage
2029

2130
EXTERNAL SOURCES:
@@ -24,10 +33,11 @@ EXTERNAL SOURCES:
2433

2534
SPEC CHECKSUMS:
2635
libaom: 1e48c68559b8d6191c1a9f266e0bee83b2dd21fd
27-
libavif: 251b8a20baa5b05467cc64c3b844eaa7b5cf3a62
28-
SDWebImage: fb387001955223213dde14bc08c8b73f371f8d8f
29-
SDWebImageAVIFCoder: 0cc05dc868739b68d6b61856ef11e1aea6af68eb
36+
libavif: 8ae7eca52a4ba56592c63991a30697a9a24244e7
37+
libdav1d: 097f791c93d050b1cb6c0788fbe6c9024ceb3d7e
38+
SDWebImage: 5fcdb02cc35e05fc35791ec514b191d27189f872
39+
SDWebImageAVIFCoder: f994b0bf9e8748a837bd18ec8491228690c16612
3040

31-
PODFILE CHECKSUM: cb60778bff8fb5ce4fbc8792f6079317b7a897be
41+
PODFILE CHECKSUM: 1daaa635bd369cbbf21bf2dd090f9adae3a762dc
3242

3343
COCOAPODS: 1.7.5

SDWebImageAVIFCoder.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ Which is built based on the open-sourced libavif codec.
3636
s.source_files = 'SDWebImageAVIFCoder/Classes/**/*', 'SDWebImageAVIFCoder/Module/SDWebImageAVIFCoder.h'
3737

3838
s.dependency 'SDWebImage', '~> 5.0'
39-
s.dependency 'libavif', '~> 0.2.0'
39+
s.dependency 'libavif', '~> 0.3.0'
4040
end

SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,12 @@ - (nullable NSData *)encodedDataWithImage:(nullable UIImage *)image format:(SDIm
278278
if (options[SDImageCoderEncodeCompressionQuality]) {
279279
compressionQuality = [options[SDImageCoderEncodeCompressionQuality] doubleValue];
280280
}
281-
int rescaledQuality = AVIF_WORST_QUALITY - (int)((compressionQuality) * AVIF_WORST_QUALITY);
281+
int rescaledQuality = AVIF_QUANTIZER_WORST_QUALITY - (int)((compressionQuality) * AVIF_QUANTIZER_WORST_QUALITY);
282282

283283
avifRawData raw = AVIF_RAW_DATA_EMPTY;
284284
avifEncoder *encoder = avifEncoderCreate();
285-
encoder->quality = rescaledQuality;
285+
encoder->minQuantizer = rescaledQuality;
286+
encoder->maxQuantizer = rescaledQuality;
286287
encoder->maxThreads = 2;
287288
avifResult result = avifEncoderWrite(encoder, avif, &raw);
288289

0 commit comments

Comments
 (0)