From 8050582aee9121ca7fc229bd37e66383a00ae956 Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 18:57:49 +0900 Subject: [PATCH 01/13] add CI Test Runner --- Example/Podfile | 6 + .../project.pbxproj | 187 ++++++++++++++++++ .../SDWebImageAVIFCoder_CITestRunner.xcscheme | 78 ++++++++ ...ebImageAVIFCoder_CITestRunner.entitlements | 5 + .../SDWebImageAVIFCoder_CITestRunner/main.m | 33 ++++ 5 files changed, 309 insertions(+) create mode 100644 Example/SDWebImageAVIFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImageAVIFCoder_CITestRunner.xcscheme create mode 100644 Example/SDWebImageAVIFCoder_CITestRunner/SDWebImageAVIFCoder_CITestRunner.entitlements create mode 100644 Example/SDWebImageAVIFCoder_CITestRunner/main.m diff --git a/Example/Podfile b/Example/Podfile index 2b4db0d..1e9498d 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -17,3 +17,9 @@ target 'SDWebImageAVIFCoder_Example macOS' do pod 'SDWebImageAVIFCoder', :path => '../' pod 'libavif', :subspecs => ['librav1e', 'libdav1d'] end + +target 'SDWebImageAVIFCoder_CITestRunner' do + platform :osx, '10.10' + pod 'SDWebImageAVIFCoder', :path => '../' + pod 'libavif', :subspecs => ['librav1e', 'libdav1d'] +end diff --git a/Example/SDWebImageAVIFCoder.xcodeproj/project.pbxproj b/Example/SDWebImageAVIFCoder.xcodeproj/project.pbxproj index 14eab56..bccc569 100644 --- a/Example/SDWebImageAVIFCoder.xcodeproj/project.pbxproj +++ b/Example/SDWebImageAVIFCoder.xcodeproj/project.pbxproj @@ -25,11 +25,13 @@ 6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; 6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; }; 6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; }; + 6D37314123E88F6B007F654B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D37314023E88F6B007F654B /* main.m */; }; 71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */; }; 8011C06C17A1599DD88EBB28 /* libPods-SDWebImageAVIFCoder_Example macOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D35147990C9781C1E45F4DE7 /* libPods-SDWebImageAVIFCoder_Example macOS.a */; }; 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; }; CA030C0A0B57F891DD84371D /* libPods-SDWebImageAVIFCoder_Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2783F1D7B48DB3ED9ADFF864 /* libPods-SDWebImageAVIFCoder_Example.a */; }; EDB2D182F827BB685E80048E /* libPods-SDWebImageAVIFCoder_Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4691BEB7EC16961149D74E32 /* libPods-SDWebImageAVIFCoder_Tests.a */; }; + FBEC96B43FCD1067ED8BFC2C /* libPods-SDWebImageAVIFCoder_CITestRunner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0FE85F829ACFB2B42D56FE26 /* libPods-SDWebImageAVIFCoder_CITestRunner.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -42,8 +44,22 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + 6D37313C23E88F6B007F654B /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 01396E21D67B93E6F560157A /* Pods-SDWebImageAVIFCoder_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Tests.release.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Tests/Pods-SDWebImageAVIFCoder_Tests.release.xcconfig"; sourceTree = ""; }; + 0FE85F829ACFB2B42D56FE26 /* libPods-SDWebImageAVIFCoder_CITestRunner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SDWebImageAVIFCoder_CITestRunner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 115925287E4C4F7663BAC4E1 /* Pods-SDWebImageAVIFCoder_CITestRunner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_CITestRunner.release.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_CITestRunner/Pods-SDWebImageAVIFCoder_CITestRunner.release.xcconfig"; sourceTree = ""; }; 13CE9906000ABBFFA89F3F10 /* SDWebImageAVIFCoder.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SDWebImageAVIFCoder.podspec; path = ../SDWebImageAVIFCoder.podspec; sourceTree = ""; }; 207C633217DCC3D0312C335C /* Pods-SDWebImageAVIFCoder_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Example.release.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Example/Pods-SDWebImageAVIFCoder_Example.release.xcconfig"; sourceTree = ""; }; 2783F1D7B48DB3ED9ADFF864 /* libPods-SDWebImageAVIFCoder_Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SDWebImageAVIFCoder_Example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -79,11 +95,15 @@ 6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = ""; }; 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = ""; }; + 6D37313E23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SDWebImageAVIFCoder_CITestRunner; sourceTree = BUILT_PRODUCTS_DIR; }; + 6D37314023E88F6B007F654B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 6D37314523E89499007F654B /* SDWebImageAVIFCoder_CITestRunner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SDWebImageAVIFCoder_CITestRunner.entitlements; sourceTree = ""; }; 71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 7FE45EC1A1A0874CE3C32260 /* Pods-SDWebImageAVIFCoder_Example macOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Example macOS.debug.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Example macOS/Pods-SDWebImageAVIFCoder_Example macOS.debug.xcconfig"; sourceTree = ""; }; 86EFB0D9CB82C3418B27F7C3 /* Pods-SDWebImageAVIFCoder_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Tests.debug.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Tests/Pods-SDWebImageAVIFCoder_Tests.debug.xcconfig"; sourceTree = ""; }; 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = ""; }; D35147990C9781C1E45F4DE7 /* libPods-SDWebImageAVIFCoder_Example macOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SDWebImageAVIFCoder_Example macOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + EE94D01985EEE3F097BB72FA /* Pods-SDWebImageAVIFCoder_CITestRunner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_CITestRunner.debug.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_CITestRunner/Pods-SDWebImageAVIFCoder_CITestRunner.debug.xcconfig"; sourceTree = ""; }; EFA18806A2B2331D243CEBFE /* Pods-SDWebImageAVIFCoder_Example macOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Example macOS.release.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Example macOS/Pods-SDWebImageAVIFCoder_Example macOS.release.xcconfig"; sourceTree = ""; }; F6B54596AE0C8ECC6DFE1DD6 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; F85182AD5D4FF8570F90A7BC /* Pods-SDWebImageAVIFCoder_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Example.debug.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Example/Pods-SDWebImageAVIFCoder_Example.debug.xcconfig"; sourceTree = ""; }; @@ -120,6 +140,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6D37313B23E88F6B007F654B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + FBEC96B43FCD1067ED8BFC2C /* libPods-SDWebImageAVIFCoder_CITestRunner.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -147,6 +175,7 @@ 6003F593195388D20070C39A /* Example for SDWebImageAVIFCoder */, 6003F5B5195388D20070C39A /* Tests */, 32D32639226344EC001B208C /* SDWebImageAVIFCoder_Example macOS */, + 6D37313F23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */, 6003F58C195388D20070C39A /* Frameworks */, 6003F58B195388D20070C39A /* Products */, E40A1283864141E18825AD7D /* Pods */, @@ -159,6 +188,7 @@ 6003F58A195388D20070C39A /* SDWebImageAVIFCoder_Example.app */, 6003F5AE195388D20070C39A /* SDWebImageAVIFCoder_Tests.xctest */, 32D32638226344EC001B208C /* SDWebImageAVIFCoder_Example macOS.app */, + 6D37313E23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */, ); name = Products; sourceTree = ""; @@ -173,6 +203,7 @@ 2783F1D7B48DB3ED9ADFF864 /* libPods-SDWebImageAVIFCoder_Example.a */, D35147990C9781C1E45F4DE7 /* libPods-SDWebImageAVIFCoder_Example macOS.a */, 4691BEB7EC16961149D74E32 /* libPods-SDWebImageAVIFCoder_Tests.a */, + 0FE85F829ACFB2B42D56FE26 /* libPods-SDWebImageAVIFCoder_CITestRunner.a */, ); name = Frameworks; sourceTree = ""; @@ -233,6 +264,15 @@ name = "Podspec Metadata"; sourceTree = ""; }; + 6D37313F23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */ = { + isa = PBXGroup; + children = ( + 6D37314523E89499007F654B /* SDWebImageAVIFCoder_CITestRunner.entitlements */, + 6D37314023E88F6B007F654B /* main.m */, + ); + path = SDWebImageAVIFCoder_CITestRunner; + sourceTree = ""; + }; E40A1283864141E18825AD7D /* Pods */ = { isa = PBXGroup; children = ( @@ -242,6 +282,8 @@ 01396E21D67B93E6F560157A /* Pods-SDWebImageAVIFCoder_Tests.release.xcconfig */, 7FE45EC1A1A0874CE3C32260 /* Pods-SDWebImageAVIFCoder_Example macOS.debug.xcconfig */, EFA18806A2B2331D243CEBFE /* Pods-SDWebImageAVIFCoder_Example macOS.release.xcconfig */, + EE94D01985EEE3F097BB72FA /* Pods-SDWebImageAVIFCoder_CITestRunner.debug.xcconfig */, + 115925287E4C4F7663BAC4E1 /* Pods-SDWebImageAVIFCoder_CITestRunner.release.xcconfig */, ); path = Pods; sourceTree = ""; @@ -304,6 +346,24 @@ productReference = 6003F5AE195388D20070C39A /* SDWebImageAVIFCoder_Tests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + 6D37313D23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6D37314423E88F6B007F654B /* Build configuration list for PBXNativeTarget "SDWebImageAVIFCoder_CITestRunner" */; + buildPhases = ( + E590E76A0606D9D1813727F4 /* [CP] Check Pods Manifest.lock */, + 6D37313A23E88F6B007F654B /* Sources */, + 6D37313B23E88F6B007F654B /* Frameworks */, + 6D37313C23E88F6B007F654B /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SDWebImageAVIFCoder_CITestRunner; + productName = SDWebImageAVIFCoder_CITestRunner; + productReference = 6D37313E23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */; + productType = "com.apple.product-type.tool"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -326,6 +386,10 @@ 6003F5AD195388D20070C39A = { TestTargetID = 6003F589195388D20070C39A; }; + 6D37313D23E88F6B007F654B = { + CreatedOnToolsVersion = 11.3.1; + ProvisioningStyle = Manual; + }; }; }; buildConfigurationList = 6003F585195388D10070C39A /* Build configuration list for PBXProject "SDWebImageAVIFCoder" */; @@ -345,6 +409,7 @@ 6003F589195388D20070C39A /* SDWebImageAVIFCoder_Example */, 6003F5AD195388D20070C39A /* SDWebImageAVIFCoder_Tests */, 32D32637226344EC001B208C /* SDWebImageAVIFCoder_Example macOS */, + 6D37313D23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */, ); }; /* End PBXProject section */ @@ -447,6 +512,28 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + E590E76A0606D9D1813727F4 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-SDWebImageAVIFCoder_CITestRunner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -478,6 +565,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6D37313A23E88F6B007F654B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D37314123E88F6B007F654B /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -754,6 +849,89 @@ }; name = Release; }; + 6D37314223E88F6B007F654B /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = EE94D01985EEE3F097BB72FA /* Pods-SDWebImageAVIFCoder_CITestRunner.debug.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CODE_SIGN_ENTITLEMENTS = SDWebImageAVIFCoder_CITestRunner/SDWebImageAVIFCoder_CITestRunner.entitlements; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Manual; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = ""; + ENABLE_HARDENED_RUNTIME = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "$(SRCROOT)/SDWebImageAVIFCoder_Example macOS/Info.plist"; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.SDWebImageAVIFCoder-CITestRunner"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SDKROOT = macosx; + }; + name = Debug; + }; + 6D37314323E88F6B007F654B /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 115925287E4C4F7663BAC4E1 /* Pods-SDWebImageAVIFCoder_CITestRunner.release.xcconfig */; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CODE_SIGN_ENTITLEMENTS = SDWebImageAVIFCoder_CITestRunner/SDWebImageAVIFCoder_CITestRunner.entitlements; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Manual; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = ""; + ENABLE_HARDENED_RUNTIME = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "$(SRCROOT)/SDWebImageAVIFCoder_Example macOS/Info.plist"; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.SDWebImageAVIFCoder-CITestRunner"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SDKROOT = macosx; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -793,6 +971,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 6D37314423E88F6B007F654B /* Build configuration list for PBXNativeTarget "SDWebImageAVIFCoder_CITestRunner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6D37314223E88F6B007F654B /* Debug */, + 6D37314323E88F6B007F654B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 6003F582195388D10070C39A /* Project object */; diff --git a/Example/SDWebImageAVIFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImageAVIFCoder_CITestRunner.xcscheme b/Example/SDWebImageAVIFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImageAVIFCoder_CITestRunner.xcscheme new file mode 100644 index 0000000..7ca14d2 --- /dev/null +++ b/Example/SDWebImageAVIFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImageAVIFCoder_CITestRunner.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/SDWebImageAVIFCoder_CITestRunner/SDWebImageAVIFCoder_CITestRunner.entitlements b/Example/SDWebImageAVIFCoder_CITestRunner/SDWebImageAVIFCoder_CITestRunner.entitlements new file mode 100644 index 0000000..0c67376 --- /dev/null +++ b/Example/SDWebImageAVIFCoder_CITestRunner/SDWebImageAVIFCoder_CITestRunner.entitlements @@ -0,0 +1,5 @@ + + + + + diff --git a/Example/SDWebImageAVIFCoder_CITestRunner/main.m b/Example/SDWebImageAVIFCoder_CITestRunner/main.m new file mode 100644 index 0000000..ab79a11 --- /dev/null +++ b/Example/SDWebImageAVIFCoder_CITestRunner/main.m @@ -0,0 +1,33 @@ +// +// main.m +// SDWebImageAVIFCoder_CITestRunner +// +// Created by psi on 2020/02/04. +// Copyright © 2020 lizhuoli1126@126.com. All rights reserved. +// + +#import +#import +#import + +int main(int argc, const char * argv[]) { + if(argc != 3) { + fprintf(stderr, "usage: %s \n", argv[0]); + return -1; + } + @autoreleasepool { + NSString* inputPath = [NSString stringWithUTF8String: argv[1]]; + NSString* outputPath = [NSString stringWithUTF8String: argv[2]]; + NSData* data = [[NSData alloc] initWithContentsOfFile: inputPath]; + SDImageAVIFCoder* const coder = [SDImageAVIFCoder sharedCoder]; + UIImage* img = [coder decodedImageWithData: data options:nil]; + + CGImageRef cgRef = [img CGImageForProposedRect:nil context:nil hints:nil]; + NSBitmapImageRep *newRep = [[NSBitmapImageRep alloc] initWithCGImage:cgRef]; + [newRep setSize:[img size]]; // if you want the same resolution + NSDictionary *prop = [[NSDictionary alloc] init]; + NSData* pngData = [newRep representationUsingType:NSBitmapImageFileTypePNG properties: prop]; + [pngData writeToFile:outputPath atomically:YES]; + } + return 0; +} From ca9b6eb2bd87c818d969cb7f55937a9ac6f143ee Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 19:15:24 +0900 Subject: [PATCH 02/13] [WIP] Added CI to check the decoding result --- .github/workflows/check-image-decoding.yml | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/check-image-decoding.yml diff --git a/.github/workflows/check-image-decoding.yml b/.github/workflows/check-image-decoding.yml new file mode 100644 index 0000000..0c86e8f --- /dev/null +++ b/.github/workflows/check-image-decoding.yml @@ -0,0 +1,35 @@ +name: Check the decoded images. + +on: [push] + +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: Build CI Test Runner + shell: bash + run: | + set -ex + cd Example + pod install --repo-update + xcrun xcodebuild \ + -workspace SDWebImageAVIFCoder.xcworkspace \ + -scheme SDWebImageAVIFCoder_CITestRunner \ + -archivePath ./CITestRunner \ + archive + - name: Clone test images + shell: bash + run: | + set -ex + git clone https://github.com/link-u/avif-sample-images.git + - name: Decode all AVIF images + shell: bash + run: | + set -ex + cd avif-sample-images + mkdir recoded + CMD="../Example/CITestRunner.xcarchive/Products/usr/local/bin/SDWebImageAVIFCoder_CITestRunner" + for $file in $(find . -name \*.avif); do + ${CMD} ${file} "./decoded/${file}.png" + done From e63a871af2272142b2ba0ecf4802b90e5128ce33 Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 19:44:20 +0900 Subject: [PATCH 03/13] rename scripts and fix workflow --- .github/workflows/check-image-decoding.yml | 12 ++-- Example/Podfile | 2 +- .../project.pbxproj | 56 +++++++++---------- ... SDWebImageAVIFCoder_Example CLI.xcscheme} | 12 ++-- ...ebImageAVIFCoder_Example CLI.entitlements} | 0 .../main.m | 2 +- 6 files changed, 42 insertions(+), 42 deletions(-) rename Example/SDWebImageAVIFCoder.xcodeproj/xcshareddata/xcschemes/{SDWebImageAVIFCoder_CITestRunner.xcscheme => SDWebImageAVIFCoder_Example CLI.xcscheme} (87%) rename Example/{SDWebImageAVIFCoder_CITestRunner/SDWebImageAVIFCoder_CITestRunner.entitlements => SDWebImageAVIFCoder_Example CLI/SDWebImageAVIFCoder_Example CLI.entitlements} (100%) rename Example/{SDWebImageAVIFCoder_CITestRunner => SDWebImageAVIFCoder_Example CLI}/main.m (97%) diff --git a/.github/workflows/check-image-decoding.yml b/.github/workflows/check-image-decoding.yml index 0c86e8f..3b164eb 100644 --- a/.github/workflows/check-image-decoding.yml +++ b/.github/workflows/check-image-decoding.yml @@ -15,8 +15,8 @@ jobs: pod install --repo-update xcrun xcodebuild \ -workspace SDWebImageAVIFCoder.xcworkspace \ - -scheme SDWebImageAVIFCoder_CITestRunner \ - -archivePath ./CITestRunner \ + -scheme "SDWebImageAVIFCoder_Example CLI" \ + -archivePath ./CLI \ archive - name: Clone test images shell: bash @@ -28,8 +28,8 @@ jobs: run: | set -ex cd avif-sample-images - mkdir recoded - CMD="../Example/CITestRunner.xcarchive/Products/usr/local/bin/SDWebImageAVIFCoder_CITestRunner" - for $file in $(find . -name \*.avif); do - ${CMD} ${file} "./decoded/${file}.png" + mkdir decoded + CMD="../Example/CLI.xcarchive/Products/usr/local/bin/SDWebImageAVIFCoder_Example CLI" + for file in $(find . -name \*.avif); do + "${CMD}" ${file} "./decoded/${file}.png" done diff --git a/Example/Podfile b/Example/Podfile index 1e9498d..2e6fb21 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -18,7 +18,7 @@ target 'SDWebImageAVIFCoder_Example macOS' do pod 'libavif', :subspecs => ['librav1e', 'libdav1d'] end -target 'SDWebImageAVIFCoder_CITestRunner' do +target 'SDWebImageAVIFCoder_Example CLI' do platform :osx, '10.10' pod 'SDWebImageAVIFCoder', :path => '../' pod 'libavif', :subspecs => ['librav1e', 'libdav1d'] diff --git a/Example/SDWebImageAVIFCoder.xcodeproj/project.pbxproj b/Example/SDWebImageAVIFCoder.xcodeproj/project.pbxproj index bccc569..4c56850 100644 --- a/Example/SDWebImageAVIFCoder.xcodeproj/project.pbxproj +++ b/Example/SDWebImageAVIFCoder.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 32D32641226344EC001B208C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 32D32640226344EC001B208C /* Assets.xcassets */; }; 32D32644226344EC001B208C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32D32642226344EC001B208C /* Main.storyboard */; }; 32D32647226344EC001B208C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D32646226344EC001B208C /* main.m */; }; + 560DF9D6CE4279F70E079FDE /* libPods-SDWebImageAVIFCoder_Example CLI.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D6E4426F3B49328A49F041D /* libPods-SDWebImageAVIFCoder_Example CLI.a */; }; 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; }; 6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; @@ -31,7 +32,6 @@ 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; }; CA030C0A0B57F891DD84371D /* libPods-SDWebImageAVIFCoder_Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2783F1D7B48DB3ED9ADFF864 /* libPods-SDWebImageAVIFCoder_Example.a */; }; EDB2D182F827BB685E80048E /* libPods-SDWebImageAVIFCoder_Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4691BEB7EC16961149D74E32 /* libPods-SDWebImageAVIFCoder_Tests.a */; }; - FBEC96B43FCD1067ED8BFC2C /* libPods-SDWebImageAVIFCoder_CITestRunner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0FE85F829ACFB2B42D56FE26 /* libPods-SDWebImageAVIFCoder_CITestRunner.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -58,9 +58,8 @@ /* Begin PBXFileReference section */ 01396E21D67B93E6F560157A /* Pods-SDWebImageAVIFCoder_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Tests.release.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Tests/Pods-SDWebImageAVIFCoder_Tests.release.xcconfig"; sourceTree = ""; }; - 0FE85F829ACFB2B42D56FE26 /* libPods-SDWebImageAVIFCoder_CITestRunner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SDWebImageAVIFCoder_CITestRunner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 115925287E4C4F7663BAC4E1 /* Pods-SDWebImageAVIFCoder_CITestRunner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_CITestRunner.release.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_CITestRunner/Pods-SDWebImageAVIFCoder_CITestRunner.release.xcconfig"; sourceTree = ""; }; 13CE9906000ABBFFA89F3F10 /* SDWebImageAVIFCoder.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SDWebImageAVIFCoder.podspec; path = ../SDWebImageAVIFCoder.podspec; sourceTree = ""; }; + 1D6E4426F3B49328A49F041D /* libPods-SDWebImageAVIFCoder_Example CLI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SDWebImageAVIFCoder_Example CLI.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 207C633217DCC3D0312C335C /* Pods-SDWebImageAVIFCoder_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Example.release.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Example/Pods-SDWebImageAVIFCoder_Example.release.xcconfig"; sourceTree = ""; }; 2783F1D7B48DB3ED9ADFF864 /* libPods-SDWebImageAVIFCoder_Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SDWebImageAVIFCoder_Example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 3260C60722634CF90046E4C8 /* SDWebImageAVIFCoder_Example macOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "SDWebImageAVIFCoder_Example macOS.entitlements"; sourceTree = ""; }; @@ -95,15 +94,16 @@ 6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = ""; }; 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = ""; }; - 6D37313E23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = SDWebImageAVIFCoder_CITestRunner; sourceTree = BUILT_PRODUCTS_DIR; }; + 646EA09807C18AE2FBD43C9D /* Pods-SDWebImageAVIFCoder_Example CLI.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Example CLI.release.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Example CLI/Pods-SDWebImageAVIFCoder_Example CLI.release.xcconfig"; sourceTree = ""; }; + 6C2B135EF73C44C782F0F9D8 /* Pods-SDWebImageAVIFCoder_Example CLI.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Example CLI.debug.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Example CLI/Pods-SDWebImageAVIFCoder_Example CLI.debug.xcconfig"; sourceTree = ""; }; + 6D37313E23E88F6B007F654B /* SDWebImageAVIFCoder_Example CLI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "SDWebImageAVIFCoder_Example CLI"; sourceTree = BUILT_PRODUCTS_DIR; }; 6D37314023E88F6B007F654B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 6D37314523E89499007F654B /* SDWebImageAVIFCoder_CITestRunner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SDWebImageAVIFCoder_CITestRunner.entitlements; sourceTree = ""; }; + 6D37314523E89499007F654B /* SDWebImageAVIFCoder_Example CLI.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "SDWebImageAVIFCoder_Example CLI.entitlements"; sourceTree = ""; }; 71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 7FE45EC1A1A0874CE3C32260 /* Pods-SDWebImageAVIFCoder_Example macOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Example macOS.debug.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Example macOS/Pods-SDWebImageAVIFCoder_Example macOS.debug.xcconfig"; sourceTree = ""; }; 86EFB0D9CB82C3418B27F7C3 /* Pods-SDWebImageAVIFCoder_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Tests.debug.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Tests/Pods-SDWebImageAVIFCoder_Tests.debug.xcconfig"; sourceTree = ""; }; 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = ""; }; D35147990C9781C1E45F4DE7 /* libPods-SDWebImageAVIFCoder_Example macOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SDWebImageAVIFCoder_Example macOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - EE94D01985EEE3F097BB72FA /* Pods-SDWebImageAVIFCoder_CITestRunner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_CITestRunner.debug.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_CITestRunner/Pods-SDWebImageAVIFCoder_CITestRunner.debug.xcconfig"; sourceTree = ""; }; EFA18806A2B2331D243CEBFE /* Pods-SDWebImageAVIFCoder_Example macOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Example macOS.release.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Example macOS/Pods-SDWebImageAVIFCoder_Example macOS.release.xcconfig"; sourceTree = ""; }; F6B54596AE0C8ECC6DFE1DD6 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; F85182AD5D4FF8570F90A7BC /* Pods-SDWebImageAVIFCoder_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SDWebImageAVIFCoder_Example.debug.xcconfig"; path = "Target Support Files/Pods-SDWebImageAVIFCoder_Example/Pods-SDWebImageAVIFCoder_Example.debug.xcconfig"; sourceTree = ""; }; @@ -144,7 +144,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - FBEC96B43FCD1067ED8BFC2C /* libPods-SDWebImageAVIFCoder_CITestRunner.a in Frameworks */, + 560DF9D6CE4279F70E079FDE /* libPods-SDWebImageAVIFCoder_Example CLI.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -175,7 +175,7 @@ 6003F593195388D20070C39A /* Example for SDWebImageAVIFCoder */, 6003F5B5195388D20070C39A /* Tests */, 32D32639226344EC001B208C /* SDWebImageAVIFCoder_Example macOS */, - 6D37313F23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */, + 6D37313F23E88F6B007F654B /* SDWebImageAVIFCoder_Example CLI */, 6003F58C195388D20070C39A /* Frameworks */, 6003F58B195388D20070C39A /* Products */, E40A1283864141E18825AD7D /* Pods */, @@ -188,7 +188,7 @@ 6003F58A195388D20070C39A /* SDWebImageAVIFCoder_Example.app */, 6003F5AE195388D20070C39A /* SDWebImageAVIFCoder_Tests.xctest */, 32D32638226344EC001B208C /* SDWebImageAVIFCoder_Example macOS.app */, - 6D37313E23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */, + 6D37313E23E88F6B007F654B /* SDWebImageAVIFCoder_Example CLI */, ); name = Products; sourceTree = ""; @@ -203,7 +203,7 @@ 2783F1D7B48DB3ED9ADFF864 /* libPods-SDWebImageAVIFCoder_Example.a */, D35147990C9781C1E45F4DE7 /* libPods-SDWebImageAVIFCoder_Example macOS.a */, 4691BEB7EC16961149D74E32 /* libPods-SDWebImageAVIFCoder_Tests.a */, - 0FE85F829ACFB2B42D56FE26 /* libPods-SDWebImageAVIFCoder_CITestRunner.a */, + 1D6E4426F3B49328A49F041D /* libPods-SDWebImageAVIFCoder_Example CLI.a */, ); name = Frameworks; sourceTree = ""; @@ -264,13 +264,13 @@ name = "Podspec Metadata"; sourceTree = ""; }; - 6D37313F23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */ = { + 6D37313F23E88F6B007F654B /* SDWebImageAVIFCoder_Example CLI */ = { isa = PBXGroup; children = ( - 6D37314523E89499007F654B /* SDWebImageAVIFCoder_CITestRunner.entitlements */, + 6D37314523E89499007F654B /* SDWebImageAVIFCoder_Example CLI.entitlements */, 6D37314023E88F6B007F654B /* main.m */, ); - path = SDWebImageAVIFCoder_CITestRunner; + path = "SDWebImageAVIFCoder_Example CLI"; sourceTree = ""; }; E40A1283864141E18825AD7D /* Pods */ = { @@ -282,8 +282,8 @@ 01396E21D67B93E6F560157A /* Pods-SDWebImageAVIFCoder_Tests.release.xcconfig */, 7FE45EC1A1A0874CE3C32260 /* Pods-SDWebImageAVIFCoder_Example macOS.debug.xcconfig */, EFA18806A2B2331D243CEBFE /* Pods-SDWebImageAVIFCoder_Example macOS.release.xcconfig */, - EE94D01985EEE3F097BB72FA /* Pods-SDWebImageAVIFCoder_CITestRunner.debug.xcconfig */, - 115925287E4C4F7663BAC4E1 /* Pods-SDWebImageAVIFCoder_CITestRunner.release.xcconfig */, + 6C2B135EF73C44C782F0F9D8 /* Pods-SDWebImageAVIFCoder_Example CLI.debug.xcconfig */, + 646EA09807C18AE2FBD43C9D /* Pods-SDWebImageAVIFCoder_Example CLI.release.xcconfig */, ); path = Pods; sourceTree = ""; @@ -346,9 +346,9 @@ productReference = 6003F5AE195388D20070C39A /* SDWebImageAVIFCoder_Tests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; - 6D37313D23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */ = { + 6D37313D23E88F6B007F654B /* SDWebImageAVIFCoder_Example CLI */ = { isa = PBXNativeTarget; - buildConfigurationList = 6D37314423E88F6B007F654B /* Build configuration list for PBXNativeTarget "SDWebImageAVIFCoder_CITestRunner" */; + buildConfigurationList = 6D37314423E88F6B007F654B /* Build configuration list for PBXNativeTarget "SDWebImageAVIFCoder_Example CLI" */; buildPhases = ( E590E76A0606D9D1813727F4 /* [CP] Check Pods Manifest.lock */, 6D37313A23E88F6B007F654B /* Sources */, @@ -359,9 +359,9 @@ ); dependencies = ( ); - name = SDWebImageAVIFCoder_CITestRunner; + name = "SDWebImageAVIFCoder_Example CLI"; productName = SDWebImageAVIFCoder_CITestRunner; - productReference = 6D37313E23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */; + productReference = 6D37313E23E88F6B007F654B /* SDWebImageAVIFCoder_Example CLI */; productType = "com.apple.product-type.tool"; }; /* End PBXNativeTarget section */ @@ -409,7 +409,7 @@ 6003F589195388D20070C39A /* SDWebImageAVIFCoder_Example */, 6003F5AD195388D20070C39A /* SDWebImageAVIFCoder_Tests */, 32D32637226344EC001B208C /* SDWebImageAVIFCoder_Example macOS */, - 6D37313D23E88F6B007F654B /* SDWebImageAVIFCoder_CITestRunner */, + 6D37313D23E88F6B007F654B /* SDWebImageAVIFCoder_Example CLI */, ); }; /* End PBXProject section */ @@ -527,7 +527,7 @@ outputFileListPaths = ( ); outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-SDWebImageAVIFCoder_CITestRunner-checkManifestLockResult.txt", + "$(DERIVED_FILE_DIR)/Pods-SDWebImageAVIFCoder_Example CLI-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -851,7 +851,7 @@ }; 6D37314223E88F6B007F654B /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = EE94D01985EEE3F097BB72FA /* Pods-SDWebImageAVIFCoder_CITestRunner.debug.xcconfig */; + baseConfigurationReference = 6C2B135EF73C44C782F0F9D8 /* Pods-SDWebImageAVIFCoder_Example CLI.debug.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -870,7 +870,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; - CODE_SIGN_ENTITLEMENTS = SDWebImageAVIFCoder_CITestRunner/SDWebImageAVIFCoder_CITestRunner.entitlements; + CODE_SIGN_ENTITLEMENTS = "SDWebImageAVIFCoder_Example CLI/SDWebImageAVIFCoder_Example CLI.entitlements"; CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; DEBUG_INFORMATION_FORMAT = dwarf; @@ -883,7 +883,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.SDWebImageAVIFCoder-CITestRunner"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.SDWebImageAVIFCoder-Example-CLI"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; @@ -892,7 +892,7 @@ }; 6D37314323E88F6B007F654B /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 115925287E4C4F7663BAC4E1 /* Pods-SDWebImageAVIFCoder_CITestRunner.release.xcconfig */; + baseConfigurationReference = 646EA09807C18AE2FBD43C9D /* Pods-SDWebImageAVIFCoder_Example CLI.release.xcconfig */; buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -911,7 +911,7 @@ CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; - CODE_SIGN_ENTITLEMENTS = SDWebImageAVIFCoder_CITestRunner/SDWebImageAVIFCoder_CITestRunner.entitlements; + CODE_SIGN_ENTITLEMENTS = "SDWebImageAVIFCoder_Example CLI/SDWebImageAVIFCoder_Example CLI.entitlements"; CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; COPY_PHASE_STRIP = NO; @@ -925,7 +925,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.SDWebImageAVIFCoder-CITestRunner"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.SDWebImageAVIFCoder-Example-CLI"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; @@ -971,7 +971,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 6D37314423E88F6B007F654B /* Build configuration list for PBXNativeTarget "SDWebImageAVIFCoder_CITestRunner" */ = { + 6D37314423E88F6B007F654B /* Build configuration list for PBXNativeTarget "SDWebImageAVIFCoder_Example CLI" */ = { isa = XCConfigurationList; buildConfigurations = ( 6D37314223E88F6B007F654B /* Debug */, diff --git a/Example/SDWebImageAVIFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImageAVIFCoder_CITestRunner.xcscheme b/Example/SDWebImageAVIFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImageAVIFCoder_Example CLI.xcscheme similarity index 87% rename from Example/SDWebImageAVIFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImageAVIFCoder_CITestRunner.xcscheme rename to Example/SDWebImageAVIFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImageAVIFCoder_Example CLI.xcscheme index 7ca14d2..e748503 100644 --- a/Example/SDWebImageAVIFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImageAVIFCoder_CITestRunner.xcscheme +++ b/Example/SDWebImageAVIFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImageAVIFCoder_Example CLI.xcscheme @@ -15,8 +15,8 @@ @@ -45,8 +45,8 @@ @@ -62,8 +62,8 @@ diff --git a/Example/SDWebImageAVIFCoder_CITestRunner/SDWebImageAVIFCoder_CITestRunner.entitlements b/Example/SDWebImageAVIFCoder_Example CLI/SDWebImageAVIFCoder_Example CLI.entitlements similarity index 100% rename from Example/SDWebImageAVIFCoder_CITestRunner/SDWebImageAVIFCoder_CITestRunner.entitlements rename to Example/SDWebImageAVIFCoder_Example CLI/SDWebImageAVIFCoder_Example CLI.entitlements diff --git a/Example/SDWebImageAVIFCoder_CITestRunner/main.m b/Example/SDWebImageAVIFCoder_Example CLI/main.m similarity index 97% rename from Example/SDWebImageAVIFCoder_CITestRunner/main.m rename to Example/SDWebImageAVIFCoder_Example CLI/main.m index ab79a11..717c697 100644 --- a/Example/SDWebImageAVIFCoder_CITestRunner/main.m +++ b/Example/SDWebImageAVIFCoder_Example CLI/main.m @@ -1,6 +1,6 @@ // // main.m -// SDWebImageAVIFCoder_CITestRunner +// SDWebImageAVIFCoder_Example CLI // // Created by psi on 2020/02/04. // Copyright © 2020 lizhuoli1126@126.com. All rights reserved. From d73e1243eb3f7933ca450224e715edaec130171c Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 19:55:09 +0900 Subject: [PATCH 04/13] add image comparison logic --- .github/workflows/check-image-decoding.yml | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-image-decoding.yml b/.github/workflows/check-image-decoding.yml index 3b164eb..54036cd 100644 --- a/.github/workflows/check-image-decoding.yml +++ b/.github/workflows/check-image-decoding.yml @@ -31,5 +31,28 @@ jobs: mkdir decoded CMD="../Example/CLI.xcarchive/Products/usr/local/bin/SDWebImageAVIFCoder_Example CLI" for file in $(find . -name \*.avif); do - "${CMD}" ${file} "./decoded/${file}.png" + file=$(basename ${file}) + "${CMD}" "${file}" "./decoded/${file}.png" + done + - name: Install imagemagick to compare images. + shell: bash + run: brew install imagemagick + - name: Compare images + shell: bash + run: | + set -ex + cd avif-sample-images + for file in $(find . -name \*.avif); do + file=$(basename ${file}) + if (cat ${file} | grep "\(monochrome\|crop\|rotate\|mirror\)"); then + # FIXME(ledyba-z): Check them. + echo "Ignore: ${file}" + continue + else + score=$(compare -metric PSNR "${file}" "decoded/${file}.png") + echo " * ${file}: ${score}" + if test $(echo "${score} >= 30.0" | bc -l) -eq 0; then + exit -1 + fi + fi done From 2762e9c1fe8ab790aac4421cfd5c4f78f2b615f1 Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 19:57:02 +0900 Subject: [PATCH 05/13] Rename task name. --- .github/workflows/check-image-decoding.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-image-decoding.yml b/.github/workflows/check-image-decoding.yml index 54036cd..6b94d23 100644 --- a/.github/workflows/check-image-decoding.yml +++ b/.github/workflows/check-image-decoding.yml @@ -7,7 +7,7 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v2 - - name: Build CI Test Runner + - name: Build CLI tool shell: bash run: | set -ex From 86819bdf819107cb17e0a451c2b5c60a0ba65b60 Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 20:02:32 +0900 Subject: [PATCH 06/13] Use original image to compare --- .github/workflows/check-image-decoding.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-image-decoding.yml b/.github/workflows/check-image-decoding.yml index 6b94d23..ffb0603 100644 --- a/.github/workflows/check-image-decoding.yml +++ b/.github/workflows/check-image-decoding.yml @@ -49,7 +49,8 @@ jobs: echo "Ignore: ${file}" continue else - score=$(compare -metric PSNR "${file}" "decoded/${file}.png") + orig=$(cat Makefile | grep "^${file}" | sed "s/^${file}: \(.*\)$/\1/") + score=$(compare -metric PSNR "${orig}" "decoded/${file}.png") echo " * ${file}: ${score}" if test $(echo "${score} >= 30.0" | bc -l) -eq 0; then exit -1 From 6236f7d992b66efe6f30b1a4af893f7a7ffb5bf3 Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 20:08:07 +0900 Subject: [PATCH 07/13] Fix compare command --- .github/workflows/check-image-decoding.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-image-decoding.yml b/.github/workflows/check-image-decoding.yml index ffb0603..a9b51d2 100644 --- a/.github/workflows/check-image-decoding.yml +++ b/.github/workflows/check-image-decoding.yml @@ -50,7 +50,7 @@ jobs: continue else orig=$(cat Makefile | grep "^${file}" | sed "s/^${file}: \(.*\)$/\1/") - score=$(compare -metric PSNR "${orig}" "decoded/${file}.png") + score=$(compare -metric PSNR "${orig}" "decoded/${file}.png" NULL: 2>&1) echo " * ${file}: ${score}" if test $(echo "${score} >= 30.0" | bc -l) -eq 0; then exit -1 From 976aade4b9c0582af07eff1e291d7f3acec18e38 Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 20:25:33 +0900 Subject: [PATCH 08/13] Fixed wrong condition --- .github/workflows/check-image-decoding.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-image-decoding.yml b/.github/workflows/check-image-decoding.yml index a9b51d2..86ea273 100644 --- a/.github/workflows/check-image-decoding.yml +++ b/.github/workflows/check-image-decoding.yml @@ -44,7 +44,7 @@ jobs: cd avif-sample-images for file in $(find . -name \*.avif); do file=$(basename ${file}) - if (cat ${file} | grep "\(monochrome\|crop\|rotate\|mirror\)"); then + if (echo ${file} | grep "\(monochrome\|crop\|rotate\|mirror\)"); then # FIXME(ledyba-z): Check them. echo "Ignore: ${file}" continue From 3a2f57081c4d16cc6f36d72123c40f64dd695c8b Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 20:34:55 +0900 Subject: [PATCH 09/13] Added || true to ignore compare error. --- .github/workflows/check-image-decoding.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-image-decoding.yml b/.github/workflows/check-image-decoding.yml index 86ea273..894395c 100644 --- a/.github/workflows/check-image-decoding.yml +++ b/.github/workflows/check-image-decoding.yml @@ -50,7 +50,7 @@ jobs: continue else orig=$(cat Makefile | grep "^${file}" | sed "s/^${file}: \(.*\)$/\1/") - score=$(compare -metric PSNR "${orig}" "decoded/${file}.png" NULL: 2>&1) + score=$(compare -metric PSNR "${orig}" "decoded/${file}.png" NULL: 2>&1 || true) echo " * ${file}: ${score}" if test $(echo "${score} >= 30.0" | bc -l) -eq 0; then exit -1 From 746f83bd9e1f2d60a614c60a6f19f2f31e657574 Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 22:37:21 +0900 Subject: [PATCH 10/13] Make the threashold higher. --- .github/workflows/check-image-decoding.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-image-decoding.yml b/.github/workflows/check-image-decoding.yml index 894395c..c15b342 100644 --- a/.github/workflows/check-image-decoding.yml +++ b/.github/workflows/check-image-decoding.yml @@ -52,7 +52,7 @@ jobs: orig=$(cat Makefile | grep "^${file}" | sed "s/^${file}: \(.*\)$/\1/") score=$(compare -metric PSNR "${orig}" "decoded/${file}.png" NULL: 2>&1 || true) echo " * ${file}: ${score}" - if test $(echo "${score} >= 30.0" | bc -l) -eq 0; then + if test $(echo "${score} >= 35.0" | bc -l) -eq 0; then exit -1 fi fi From 8736d1ff8ddeb996f2700f54b571da1083db7d1e Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 02:03:48 +0900 Subject: [PATCH 11/13] Supports odd dimensions images --- .../Classes/SDImageAVIFCoder.m | 59 ++++++++++++------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m b/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m index 8e385d3..9692883 100644 --- a/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m +++ b/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m @@ -141,8 +141,8 @@ static void ConvertAvifImagePlanar8ToRGB8(avifImage * avif, uint8_t * outPixels) vImage_Buffer origCb = { .data = avif->yuvPlanes[AVIF_CHAN_U], .rowBytes = avif->yuvRowBytes[AVIF_CHAN_U], - .width = avif->width >> state.formatInfo.chromaShiftX, - .height = avif->height >> state.formatInfo.chromaShiftY, + .width = (avif->width+state.formatInfo.chromaShiftX) >> state.formatInfo.chromaShiftX, + .height = (avif->height+state.formatInfo.chromaShiftY) >> state.formatInfo.chromaShiftY, }; if(!origCb.data) { // allocate dummy data to convert monochrome images. @@ -159,8 +159,8 @@ static void ConvertAvifImagePlanar8ToRGB8(avifImage * avif, uint8_t * outPixels) vImage_Buffer origCr = { .data = avif->yuvPlanes[AVIF_CHAN_V], .rowBytes = avif->yuvRowBytes[AVIF_CHAN_V], - .width = avif->width >> state.formatInfo.chromaShiftX, - .height = avif->height >> state.formatInfo.chromaShiftY, + .width = (avif->width+state.formatInfo.chromaShiftX) >> state.formatInfo.chromaShiftX, + .height = (avif->height+state.formatInfo.chromaShiftY) >> state.formatInfo.chromaShiftY, }; if(!origCr.data) { // allocate dummy data to convert monochrome images. dummyCr = calloc(origCr.width, sizeof(uint8_t)); @@ -282,11 +282,13 @@ static void ConvertAvifImagePlanar8ToRGB8(avifImage * avif, uint8_t * outPixels) return; } + ((uint8_t*)origY.data)[origY.rowBytes * (origY.height-1) + origY.width ] = 255; + const vImagePixelCount alignedWidth = (origY.width+1) & (~1); vImage_Buffer tmpY1 = { - .data = calloc(origY.width/2 * origY.height, sizeof(uint8_t)), - .width = origY.width/2, + .data = calloc(alignedWidth/2 * origY.height, sizeof(uint8_t)), + .width = alignedWidth/2, .height = origY.height, - .rowBytes = origY.width/2 * sizeof(uint8_t), + .rowBytes = alignedWidth/2 * sizeof(uint8_t), }; if(!tmpY1.data) { free(argbPixels); @@ -294,11 +296,24 @@ static void ConvertAvifImagePlanar8ToRGB8(avifImage * avif, uint8_t * outPixels) free(dummyCr); return; } + err = vImageConvert_ChunkyToPlanar8((const void*[]){origY.data}, + (const vImage_Buffer*[]){&tmpY1}, + 1 /* channelCount */, 2 /* src srcStrideBytes */, + alignedWidth/2, origY.height, + origY.rowBytes, kvImageNoFlags); + if(err != kvImageNoError) { + NSLog(@"Failed to separate first Y channel: %ld", err); + free(argbPixels); + free(dummyCb); + free(dummyCr); + free(tmpY1.data); + return; + } vImage_Buffer tmpY2 = { - .data = calloc(origY.width/2 * origY.height, sizeof(uint8_t)), - .width = origY.width/2, + .data = calloc(alignedWidth/2 * origY.height, sizeof(uint8_t)), + .width = alignedWidth/2, .height = origY.height, - .rowBytes = origY.width/2 * sizeof(uint8_t), + .rowBytes = alignedWidth/2 * sizeof(uint8_t), }; if(!tmpY2.data) { free(argbPixels); @@ -307,13 +322,15 @@ static void ConvertAvifImagePlanar8ToRGB8(avifImage * avif, uint8_t * outPixels) free(tmpY1.data); return; } - err= vImageConvert_ChunkyToPlanar8((const void*[]){origY.data, origY.data+1}, - (const vImage_Buffer*[]){&tmpY1, &tmpY2}, - 2 /* channelCount */,2 /* src srcStrideBytes */, + tmpY2.width = origY.width/2; + err = vImageConvert_ChunkyToPlanar8((const void*[]){origY.data + 1}, + (const vImage_Buffer*[]){&tmpY2}, + 1 /* channelCount */, 2 /* src srcStrideBytes */, origY.width/2, origY.height, origY.rowBytes, kvImageNoFlags); + tmpY2.width = alignedWidth/2; if(err != kvImageNoError) { - NSLog(@"Failed to separate Y channel: %ld", err); + NSLog(@"Failed to separate second Y channel: %ld", err); free(argbPixels); free(dummyCb); free(dummyCr); @@ -322,10 +339,10 @@ static void ConvertAvifImagePlanar8ToRGB8(avifImage * avif, uint8_t * outPixels) return; } vImage_Buffer tmpBuffer = { - .data = calloc(avif->width * avif->height * 2, sizeof(uint8_t)), - .width = avif->width/2, + .data = calloc(alignedWidth * avif->height * 2, sizeof(uint8_t)), + .width = alignedWidth/2, .height = avif->height, - .rowBytes = avif->width / 2 * 4 * sizeof(uint8_t), + .rowBytes = alignedWidth / 2 * 4 * sizeof(uint8_t), }; if(!tmpBuffer.data) { free(argbPixels); @@ -437,8 +454,8 @@ static void ConvertAvifImagePlanar16ToRGB16U(avifImage * avif, uint8_t * outPixe vImage_Buffer origCb = { .data = avif->yuvPlanes[AVIF_CHAN_U], .rowBytes = avif->yuvRowBytes[AVIF_CHAN_U], - .width = avif->width >> state.formatInfo.chromaShiftX, - .height = avif->height >> state.formatInfo.chromaShiftY, + .width = (avif->width+state.formatInfo.chromaShiftX) >> state.formatInfo.chromaShiftX, + .height = (avif->height+state.formatInfo.chromaShiftY) >> state.formatInfo.chromaShiftY, }; if(!origCb.data) { // allocate dummy data to convert monochrome images. @@ -465,8 +482,8 @@ static void ConvertAvifImagePlanar16ToRGB16U(avifImage * avif, uint8_t * outPixe vImage_Buffer origCr = { .data = avif->yuvPlanes[AVIF_CHAN_V], .rowBytes = avif->yuvRowBytes[AVIF_CHAN_V], - .width = avif->width >> state.formatInfo.chromaShiftX, - .height = avif->height >> state.formatInfo.chromaShiftY, + .width = (avif->width+state.formatInfo.chromaShiftX) >> state.formatInfo.chromaShiftX, + .height = (avif->height+state.formatInfo.chromaShiftY) >> state.formatInfo.chromaShiftY, }; if(!origCr.data) { // allocate dummy data to convert monochrome images. From b949538ea53d0b440b19918942bb38f57ea9684f Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 18:58:44 +0900 Subject: [PATCH 12/13] Fix wrong color matrix --- SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m b/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m index 9692883..a944036 100644 --- a/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m +++ b/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m @@ -21,11 +21,13 @@ static void SetupConversionInfo(avifImage * avif, // Setup Matrix matrix->Yp = 1.0f; - matrix->Cr_R = 2.0f * (1.0f - state->kr); - matrix->Cb_B = 2.0f * (1.0f - state->kb); - matrix->Cb_G = -2.0f * (1.0f - state->kr) * state->kr / state->kg; - matrix->Cr_G = -2.0f * (1.0f - state->kb) * state->kb / state->kg; - + + matrix->Cb_B = 2.0f * (1.0f - state->kb); + matrix->Cb_G = -2.0f * (1.0f - state->kb) * state->kb / state->kg; + + matrix->Cr_R = 2.0f * (1.0f - state->kr); + matrix->Cr_G = -2.0f * (1.0f - state->kr) * state->kr / state->kg; + // Setup Pixel Range switch (avif->depth) { case 8: From a21ca87bcd631607d6a407dd5a7c15abef223bf3 Mon Sep 17 00:00:00 2001 From: psi Date: Tue, 4 Feb 2020 23:46:29 +0900 Subject: [PATCH 13/13] Add FIXME about color managament. --- SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m b/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m index a944036..884fdea 100644 --- a/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m +++ b/SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m @@ -842,6 +842,10 @@ - (nullable CGImageRef)sd_createAVIFImageWithData:(nonnull NSData *)data CF_RETU CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, dest, rowBytes * height, FreeImageData); CGBitmapInfo bitmapInfo = usesU16 ? kCGBitmapByteOrder16Host : kCGBitmapByteOrderDefault; bitmapInfo |= hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNone; + // FIXME: (ledyba-z): Set appropriate color space. + // Currently, there is no way to get MatrixCoefficients, TransferCharacteristics and ColourPrimaries values + // in Sequence Header OBU. + // https://github.com/AOMediaCodec/libavif/blob/7d36984b2994210b/include/avif/avif.h#L149-L236 CGColorSpaceRef colorSpaceRef = [SDImageCoderHelper colorSpaceGetDeviceRGB]; CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault; CGImageRef imageRef = CGImageCreate(width, height, bitsPerComponent, bitsPerPixel, rowBytes, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);