Skip to content

Commit 0606c3e

Browse files
committed
Update the readme about codecChoice
1 parent 7861ff0 commit 0606c3e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,31 @@ git lfs install
7070

7171
From v0.8.3, libavif can built with STV-AV1. For For CocoaPods user, you can simply use the subspec for this.
7272

73+
## Choose codec at runtime
74+
75+
Although libavif has a automatic detection of installed AVIF codec, but for example, `aom` supports both decoding and encoding, but slower than `rav1e` on encoding.
76+
77+
You can force to use the `aom` for decoding and `rav1e` for encoding like this:
78+
79+
+ Objective-C
80+
81+
```objective-c
82+
NSDictionary *decodeOptions = [SDImageCoderAVIFDecodeCodecChoice: @(AVIF_CODEC_CHOICE_AOM)];
83+
NSDictionary *encodeOptions = [SDImageCoderAVIFEncodeCodecChoice: @(AVIF_CODEC_CHOICE_RAV1E)];
84+
85+
// Pass from UI level options
86+
[imageView sd_setImageWithURL:url placeholderImage:nil options:0 context:@{SDWebImageContextImageDecodeOptions: decodeOptions, SDWebImageContextImageEncodeOptions: encodeOptions} progress:nil completed:nil];
87+
```
88+
89+
+ Swift
90+
91+
```swift
92+
let decodeOptions: [SDImageCoderOption: Any] = [.avifDecodeCodecChoice: AVIF_CODEC_CHOICE_AOM.rawValue]
93+
let encodeOptions = [SDImageCoderOption: Any] = [.avifEncodeCodecChoice: AVIF_CODEC_CHOICE_RAV1E.rawValue]
94+
95+
// Pass from UI level options
96+
imageView.sd_setImage(with: url, placeholderImage: nil, options: [], context: [.imageDecodeOptions: decodeOptions, .imageEncodeOptions: encodeOptions], progress: nil, completed: nil)
97+
```
7398

7499
## Requirements
75100

0 commit comments

Comments
 (0)