@@ -164,45 +164,37 @@ static void CalcTransferFunction(uint16_t const transferCharacteristics, vImageT
164164 }
165165}
166166CGColorSpaceRef SDAVIFCreateColorSpaceMono (avifColorPrimaries const colorPrimaries, avifTransferCharacteristics const transferCharacteristics) {
167- if (@available (macOS 10.10 , iOS 8.0 , tvOS 8.0 , *)) {
168- vImage_Error err;
169- vImageWhitePoint white;
170- vImageTransferFunction transfer;
171- CalcWhitePoint (colorPrimaries, &white);
172- CalcTransferFunction (transferCharacteristics, &transfer);
173- CGColorSpaceRef colorSpace = vImageCreateMonochromeColorSpaceWithWhitePointAndTransferFunction (&white, &transfer, kCGRenderingIntentDefault , kvImagePrintDiagnosticsToConsole, &err);
174- if (err != kvImageNoError) {
175- NSLog (@" [BUG] Failed to create monochrome color space: %ld " , err);
176- if (colorSpace != NULL ) {
177- CGColorSpaceRelease (colorSpace);
178- }
179- return NULL ;
167+ vImage_Error err;
168+ vImageWhitePoint white;
169+ vImageTransferFunction transfer;
170+ CalcWhitePoint (colorPrimaries, &white);
171+ CalcTransferFunction (transferCharacteristics, &transfer);
172+ CGColorSpaceRef colorSpace = vImageCreateMonochromeColorSpaceWithWhitePointAndTransferFunction (&white, &transfer, kCGRenderingIntentDefault , kvImagePrintDiagnosticsToConsole, &err);
173+ if (err != kvImageNoError) {
174+ NSLog (@" [BUG] Failed to create monochrome color space: %ld " , err);
175+ if (colorSpace != NULL ) {
176+ CGColorSpaceRelease (colorSpace);
180177 }
181- return colorSpace;
182- }else {
183178 return NULL ;
184179 }
180+ return colorSpace;
185181}
186182
187183CGColorSpaceRef SDAVIFCreateColorSpaceRGB (avifColorPrimaries const colorPrimaries, avifTransferCharacteristics const transferCharacteristics) {
188- if (@available (macOS 10.10 , iOS 8.0 , tvOS 8.0 , *)) {
189- vImage_Error err;
190- vImageRGBPrimaries primaries;
191- vImageTransferFunction transfer;
192- CalcRGBPrimaries (colorPrimaries, &primaries);
193- CalcTransferFunction (transferCharacteristics, &transfer);
194- CGColorSpaceRef colorSpace = vImageCreateRGBColorSpaceWithPrimariesAndTransferFunction (&primaries, &transfer, kCGRenderingIntentDefault , kvImagePrintDiagnosticsToConsole, &err);
195- if (err != kvImageNoError) {
196- NSLog (@" [BUG] Failed to create monochrome color space: %ld " , err);
197- if (colorSpace != NULL ) {
198- CGColorSpaceRelease (colorSpace);
199- }
200- return NULL ;
184+ vImage_Error err;
185+ vImageRGBPrimaries primaries;
186+ vImageTransferFunction transfer;
187+ CalcRGBPrimaries (colorPrimaries, &primaries);
188+ CalcTransferFunction (transferCharacteristics, &transfer);
189+ CGColorSpaceRef colorSpace = vImageCreateRGBColorSpaceWithPrimariesAndTransferFunction (&primaries, &transfer, kCGRenderingIntentDefault , kvImagePrintDiagnosticsToConsole, &err);
190+ if (err != kvImageNoError) {
191+ NSLog (@" [BUG] Failed to create monochrome color space: %ld " , err);
192+ if (colorSpace != NULL ) {
193+ CGColorSpaceRelease (colorSpace);
201194 }
202- return colorSpace;
203- }else {
204195 return NULL ;
205196 }
197+ return colorSpace;
206198}
207199
208200void SDAVIFCalcColorSpaceMono (avifImage * avif, CGColorSpaceRef* ref, BOOL * shouldRelease) {
@@ -214,7 +206,7 @@ void SDAVIFCalcColorSpaceMono(avifImage * avif, CGColorSpaceRef* ref, BOOL* shou
214206 });
215207 }
216208 if (avif->icc .data && avif->icc .size ) {
217- if (@available (macOS 10.12 , iOS 10.0 , tvOS 10.0 , *)) {
209+ if (@available (macOS 10.12 , iOS 10.0 , tvOS 10.0 , watchOS 3.0 , *)) {
218210 CFDataRef iccData = CFDataCreate (kCFAllocatorDefault , avif->icc .data , avif->icc .size );
219211 *ref = CGColorSpaceCreateWithICCData (iccData);
220212 CFRelease (iccData);
@@ -312,7 +304,7 @@ void SDAVIFCalcColorSpaceRGB(avifImage * avif, CGColorSpaceRef* ref, BOOL* shoul
312304 });
313305 }
314306 if (avif->icc .data && avif->icc .size ) {
315- if (@available (macOS 10.12 , iOS 10.0 , tvOS 10.0 , *)) {
307+ if (@available (macOS 10.12 , iOS 10.0 , tvOS 10.0 , watchOS 3.0 , *)) {
316308 CFDataRef iccData = CFDataCreate (kCFAllocatorDefault , avif->icc .data , avif->icc .size );
317309 *ref = CGColorSpaceCreateWithICCData (iccData);
318310 CFRelease (iccData);
@@ -339,7 +331,7 @@ void SDAVIFCalcColorSpaceRGB(avifImage * avif, CGColorSpaceRef* ref, BOOL* shoul
339331 static CGColorSpaceRef bt709 = NULL ;
340332 static dispatch_once_t onceToken;
341333 dispatch_once (&onceToken, ^{
342- if (@available (macOS 10.11 , iOS 9.0 , tvOS 9.0 , *)) {
334+ if (@available (macOS 10.11 , iOS 9.0 , tvOS 9.0 , watchOS 2.0 , *)) {
343335 bt709 = CGColorSpaceCreateWithName (kCGColorSpaceITUR_709 );
344336 } else {
345337 bt709 = defaultColorSpace;
@@ -354,7 +346,7 @@ void SDAVIFCalcColorSpaceRGB(avifImage * avif, CGColorSpaceRef* ref, BOOL* shoul
354346 static CGColorSpaceRef sRGB = NULL ;
355347 static dispatch_once_t onceToken;
356348 dispatch_once (&onceToken, ^{
357- if (@available (macOS 10.5 , iOS 9.0 , tvOS 9.0 , *)) {
349+ if (@available (macOS 10.5 , iOS 9.0 , tvOS 9.0 , watchOS 2.0 , *)) {
358350 sRGB = CGColorSpaceCreateWithName (kCGColorSpaceSRGB );
359351 } else {
360352 sRGB = defaultColorSpace;
@@ -369,7 +361,7 @@ void SDAVIFCalcColorSpaceRGB(avifImage * avif, CGColorSpaceRef* ref, BOOL* shoul
369361 static CGColorSpaceRef sRGBlinear = NULL ;
370362 static dispatch_once_t onceToken;
371363 dispatch_once (&onceToken, ^{
372- if (@available (macOS 10.12 , iOS 10.0 , tvOS 10.0 , *)) {
364+ if (@available (macOS 10.12 , iOS 10.0 , tvOS 10.0 , watchOS 3.0 , *)) {
373365 sRGBlinear = CGColorSpaceCreateWithName (kCGColorSpaceLinearSRGB );
374366 } else {
375367 sRGBlinear = defaultColorSpace;
@@ -385,7 +377,7 @@ void SDAVIFCalcColorSpaceRGB(avifImage * avif, CGColorSpaceRef* ref, BOOL* shoul
385377 static CGColorSpaceRef bt2020 = NULL ;
386378 static dispatch_once_t onceToken;
387379 dispatch_once (&onceToken, ^{
388- if (@available (macOS 10.11 , iOS 9.0 , tvOS 9.0 , *)) {
380+ if (@available (macOS 10.11 , iOS 9.0 , tvOS 9.0 , watchOS 2.0 , *)) {
389381 bt2020 = CGColorSpaceCreateWithName (kCGColorSpaceITUR_2020 );
390382 } else {
391383 bt2020 = defaultColorSpace;
@@ -445,7 +437,7 @@ void SDAVIFCalcColorSpaceRGB(avifImage * avif, CGColorSpaceRef* ref, BOOL* shoul
445437 static CGColorSpaceRef bt2020linear = NULL ;
446438 static dispatch_once_t onceToken;
447439 dispatch_once (&onceToken, ^{
448- if (@available (macOS 10.14.3 , iOS 12.3 , tvOS 12.3 , *)) {
440+ if (@available (macOS 10.14.3 , iOS 12.3 , tvOS 12.3 , watchOS 5.0 , *)) {
449441 bt2020linear = CGColorSpaceCreateWithName (kCGColorSpaceExtendedLinearITUR_2020 );
450442 } else {
451443 bt2020linear = defaultColorSpace;
@@ -460,7 +452,7 @@ void SDAVIFCalcColorSpaceRGB(avifImage * avif, CGColorSpaceRef* ref, BOOL* shoul
460452 static CGColorSpaceRef p3 = NULL ;
461453 static dispatch_once_t onceToken;
462454 dispatch_once (&onceToken, ^{
463- if (@available (macOS 10.11.2 , iOS 9.3 , tvOS 9.3 , *)) {
455+ if (@available (macOS 10.11.2 , iOS 9.3 , tvOS 9.3 , watchOS 2.2 , *)) {
464456 p3 = CGColorSpaceCreateWithName (kCGColorSpaceDisplayP3 );
465457 } else {
466458 p3 = defaultColorSpace;
@@ -496,7 +488,7 @@ void SDAVIFCalcColorSpaceRGB(avifImage * avif, CGColorSpaceRef* ref, BOOL* shoul
496488 static CGColorSpaceRef p3hlg = NULL ;
497489 static dispatch_once_t onceToken;
498490 dispatch_once (&onceToken, ^{
499- if (@available (macOS 10.14.6 , iOS 13.0 , tvOS 13.0 , *)) {
491+ if (@available (macOS 10.14.6 , iOS 13.0 , tvOS 13.0 , watchOS 5.0 , *)) {
500492 p3hlg = CGColorSpaceCreateWithName (kCGColorSpaceDisplayP3_HLG );
501493 } else {
502494 p3hlg = defaultColorSpace;
@@ -512,7 +504,7 @@ void SDAVIFCalcColorSpaceRGB(avifImage * avif, CGColorSpaceRef* ref, BOOL* shoul
512504 static CGColorSpaceRef p3linear = NULL ;
513505 static dispatch_once_t onceToken;
514506 dispatch_once (&onceToken, ^{
515- if (@available (macOS 10.14.3 , iOS 12.3 , tvOS 12.3 , *)) {
507+ if (@available (macOS 10.14.3 , iOS 12.3 , tvOS 12.3 , watchOS 5.0 , *)) {
516508 p3linear = CGColorSpaceCreateWithName (kCGColorSpaceExtendedLinearDisplayP3 );
517509 } else {
518510 p3linear = defaultColorSpace;
0 commit comments