@@ -33,6 +33,7 @@ static void CalcColorSpaceMono(avifImage * avif, CGColorSpaceRef* ref, BOOL* sho
33
33
static void CalcColorSpaceRGB (avifImage * avif, CGColorSpaceRef* ref, BOOL * shouldRelease) {
34
34
static CGColorSpaceRef defaultColorSpace = NULL ;
35
35
static CGColorSpaceRef sRGB = NULL ;
36
+ static CGColorSpaceRef sRGBlinear = NULL ;
36
37
static CGColorSpaceRef bt709 = NULL ;
37
38
static CGColorSpaceRef bt2020 = NULL ;
38
39
static CGColorSpaceRef bt2020hlg = NULL ;
@@ -64,6 +65,11 @@ static void CalcColorSpaceRGB(avifImage * avif, CGColorSpaceRef* ref, BOOL* shou
64
65
} else {
65
66
p3 = defaultColorSpace;
66
67
}
68
+ if (@available (macOS 10.12 , iOS 10.0 , tvOS 10.0 , *)) {
69
+ sRGBlinear = CGColorSpaceCreateWithName (kCGColorSpaceLinearSRGB );
70
+ } else {
71
+ sRGBlinear = defaultColorSpace;
72
+ }
67
73
if (@available (macOS 10.14.3 , iOS 12.3 , tvOS 12.3 , *)) {
68
74
p3linear = CGColorSpaceCreateWithName (kCGColorSpaceExtendedLinearDisplayP3 );
69
75
bt2020linear = CGColorSpaceCreateWithName (kCGColorSpaceExtendedLinearITUR_2020 );
@@ -111,6 +117,12 @@ static void CalcColorSpaceRGB(avifImage * avif, CGColorSpaceRef* ref, BOOL* shou
111
117
*shouldRelease = FALSE ;
112
118
return ;
113
119
}
120
+ if (colorPrimaries == AVIF_NCLX_COLOUR_PRIMARIES_SRGB &&
121
+ transferCharacteristics == AVIF_NCLX_TRANSFER_CHARACTERISTICS_LINEAR) {
122
+ *ref = sRGBlinear ;
123
+ *shouldRelease = FALSE ;
124
+ return ;
125
+ }
114
126
if (colorPrimaries == AVIF_NCLX_COLOUR_PRIMARIES_BT2020 &&
115
127
(transferCharacteristics == AVIF_NCLX_TRANSFER_CHARACTERISTICS_BT2020_10BIT ||
116
128
transferCharacteristics == AVIF_NCLX_TRANSFER_CHARACTERISTICS_BT2020_12BIT)) {
0 commit comments