Skip to content

Commit b27dda6

Browse files
committed
handle unknown color spcaces properly
1 parent 53e5f15 commit b27dda6

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,22 @@ static void CalcColorSpaceRGB(avifImage * avif, CGColorSpaceRef* ref, BOOL* shou
3838
defaultColorSpace = CGColorSpaceCreateDeviceRGB();
3939
});
4040
}
41-
42-
if((avif->profileFormat == AVIF_PROFILE_FORMAT_ICC) && avif->icc.data && avif->icc.size) {
43-
if (@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)) {
44-
*ref = CGColorSpaceCreateWithICCData(avif->icc.data);
45-
*shouldRelease = TRUE;
46-
return;
41+
if(avif->profileFormat == AVIF_PROFILE_FORMAT_NONE) {
42+
*ref = defaultColorSpace;
43+
*shouldRelease = FALSE;
44+
return;
45+
}
46+
if(avif->profileFormat == AVIF_PROFILE_FORMAT_ICC) {
47+
if(avif->icc.data && avif->icc.size) {
48+
if(@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)) {
49+
*ref = CGColorSpaceCreateWithICCData(avif->icc.data);
50+
*shouldRelease = TRUE;
51+
return;
52+
}
4753
}
54+
*ref = defaultColorSpace;
55+
*shouldRelease = FALSE;
56+
return;
4857
}
4958
uint16_t colorPrimaries = avif->nclx.colourPrimaries;
5059
uint16_t transferCharacteristics = avif->nclx.transferCharacteristics;

0 commit comments

Comments
 (0)