peachsim 0.1.1684 → 0.1.1700
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/bridge-flow-runner.ts +61 -39
- package/cli/commands/agent-wrapper.ts +21 -10
- package/cli/commands/control.ts +27 -7
- package/cli/commands/coverage-swift.ts +72 -5
- package/cli/commands/coverage.ts +1 -1
- package/cli/commands/detect.ts +17 -4
- package/cli/commands/inspect/actions.ts +1 -0
- package/cli/commands/maestro-compare.ts +25 -99
- package/cli/commands/screenshot.ts +12 -0
- package/cli/help-core.ts +3 -4
- package/cli/maestro-compare.ts +172 -4
- package/cli/outbound-endpoints.ts +2 -10
- package/detox/index.ts +15 -0
- package/detox/launch-permissions.ts +169 -0
- package/dist-lib/agent-daemon-client.cjs +2 -2
- package/dist-lib/agent-events.cjs +2 -2
- package/dist-lib/attached-projects.cjs +2 -2
- package/dist-lib/auth/shared-session.cjs +2 -2
- package/dist-lib/backend-origin.cjs +2 -2
- package/dist-lib/beta.cjs +2 -2
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +2 -2
- package/dist-lib/bridge-contract-input.cjs +2 -2
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +2 -2
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +6729 -3591
- package/dist-lib/capture-contract.cjs +2 -2
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +2 -2
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +2 -2
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +2 -2
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +2 -2
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +104 -3
- package/dist-lib/dev-bundle-resolution.cjs +208 -44
- package/dist-lib/expo-swift-bundle.cjs +3475 -2137
- package/dist-lib/expo-swift-metadata.cjs +2 -2
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +2 -2
- package/dist-lib/host/bridge-host.cjs +8970 -3652
- package/dist-lib/host/fetch-proxy-handler.cjs +332 -40
- package/dist-lib/host/fetch-proxy-overrides.cjs +2 -2
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +2 -2
- package/dist-lib/host/websocket-proxy.cjs +2 -2
- package/dist-lib/index.cjs +469 -143
- package/dist-lib/jump-to-source-babel.cjs +2 -2
- package/dist-lib/jump-to-source-native.cjs +2 -2
- package/dist-lib/kotlin-host.cjs +2 -2
- package/dist-lib/menu.cjs +2 -2
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +2 -2
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +2 -2
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +465 -139
- package/dist-lib/native-app-identity-project.cjs +209 -86
- package/dist-lib/native-app-identity-project.mjs +251 -116
- package/dist-lib/native-app-identity.cjs +2 -2
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +2 -2
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +2 -2
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +2 -2
- package/dist-lib/public-brand.cjs +2 -2
- package/dist-lib/public-origins-lib-esm.json +27 -23
- package/dist-lib/public-origins-lib.json +221 -88
- package/dist-lib/react-native-host-modules.cjs +2 -2
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +2 -2
- package/dist-lib/scripts/dev-server-scanner.cjs +206 -31
- package/dist-lib/sdk.cjs +3 -3
- package/dist-lib/sdk.mjs +2 -2
- package/dist-lib/skills.cjs +20997 -16596
- package/dist-lib/swift-compile.cjs +3075 -459
- package/dist-lib/swift-compile.mjs +3028 -415
- package/dist-lib/swift-package.cjs +131 -69
- package/dist-lib/swift-package.mjs +126 -68
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +31 -4
- package/dist-lib/swift.cjs +2 -2
- package/dist-lib/vite-swift.cjs +5049 -1704
- package/dist-lib/vite.cjs +261 -58
- package/dist-lib/worklet-executable.cjs +8 -5
- package/dist-lib/worklet-executable.mjs +7 -4
- package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +15 -1
- package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/scroll-pan-contacts.d.ts +3 -1
- package/dist-types/packages/peach-engine/src/engine/scroll.d.ts +7 -0
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/scroll-mirror.d.ts +17 -0
- package/dist-types/packages/peach-engine/src/render-worker/worker-input-runtime.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +3 -0
- package/dist-types/packages/peach-globals/src/cameraBridgeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +6 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
- package/dist-types/packages/peach-globals/src/nodeContract.d.ts +3 -2
- package/dist-types/packages/peach-globals/src/replayBridgeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/shellHostBridgeContract.d.ts +3 -0
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/dist-types/packages/peach-kit/src/materials/types.d.ts +1 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/scripts/dev-server-scanner.ts +4 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Alpha.h +2282 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/BasicImageTypes.h +55 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Conversion.h +10551 -6
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Convolution.h +4236 -3
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Geometry.h +827 -8
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Histogram.h +1369 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Morphology.h +1243 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Transform.h +1747 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage.h +291 -2
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_CVUtilities.h +1283 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Types.h +811 -91
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Utilities.h +1342 -25
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns.h +2738 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_constants.h +1685 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_graph.h +913 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_structures.h +1917 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/LinearAlgebra.h +23 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/arithmetic.h +209 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/base.h +104 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/linear_systems.h +77 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/matrix.h +554 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/norms.h +58 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/object.h +186 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/splat.h +86 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/vector.h +364 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Quadrature/Integration.h +195 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Quadrature/Quadrature.h +44 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/BLAS/BLAS.h +2330 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/BLAS/Types.h +123 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/Solve.h +8339 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/SolveImplementation.h +520 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/SolveImplementationTyped.h +1893 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/Sparse.h +10 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/blas_new.h +1098 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/cblas.h +859 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/cblas_new.h +1134 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/clapack.h +10555 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h +695 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack.h +38526 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack_types.h +60 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack_version.h +20 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/thread_api.h +50 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vBasicOps.h +1218 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vBigNum.h +1458 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vDSP.h +10377 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vDSP_translate.h +167 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vForce.h +1243 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vecLib.h +114 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vecLibTypes.h +146 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vectorOps.h +1106 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vfp.h +294 -0
- package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Headers/Accelerate.h +25 -1
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFArray.h +673 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFAvailability.h +232 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h +827 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCalendar.h +121 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCharacterSet.h +387 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFData.h +79 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDate.h +122 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDictionary.h +674 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFError.h +182 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFLocale.h +213 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFNotificationCenter.h +82 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFNumber.h +129 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFSet.h +491 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h +883 -2
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFTimeZone.h +98 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +11 -220
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +2 -6
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLAvailability.h +22 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBackgroundActivitySession.h +145 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBeaconIdentityCondition.h +113 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBeaconIdentityConstraint.h +34 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBeaconRegion.h +225 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBody.h +26 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLCircularGeographicCondition.h +59 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLCircularRegion.h +64 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLCondition.h +48 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLError.h +52 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLErrorDomain.h +24 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLGeocoder.h +55 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLHeading.h +117 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocation.h +9 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager+CLVisitExtensions.h +45 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +877 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManagerDelegate.h +225 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationPushServiceError.h +33 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationPushServiceExtension.h +28 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationUpdater.h +250 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLMonitor.h +140 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLMonitorConfiguration.h +77 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLMonitoringEvent.h +184 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLMonitoringRecord.h +57 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLPlacemark.h +98 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +123 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLServiceSession.h +211 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLVisit.h +66 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CoreLocation.h +46 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Modules/module.modulemap +7 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +98 -3
- package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceBase.h +52 -0
- package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceObjC.h +240 -0
- package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceRef.h +474 -0
- package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceTypes.h +66 -0
- package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Modules/module.modulemap +10 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4AccelerationStructure.h +9 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4Archive.h +16 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4ArgumentTable.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4BinaryFunction.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4BinaryFunctionDescriptor.h +14 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4BufferRange.h +79 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommandAllocator.h +15 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommandBuffer.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommandEncoder.h +16 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommandQueue.h +19 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CommitFeedback.h +15 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4Compiler.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4CompilerTask.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4ComputeCommandEncoder.h +19 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4ComputePipeline.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4Counters.h +19 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4FunctionDescriptor.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4LibraryDescriptor.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4LibraryFunctionDescriptor.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4LinkingDescriptor.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4MachineLearningCommandEncoder.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4MachineLearningPipeline.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4MeshRenderPipeline.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4PipelineDataSetSerializer.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4PipelineState.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4RenderCommandEncoder.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4RenderPass.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4RenderPipeline.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4SpecializedFunctionDescriptor.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4StitchedFunctionDescriptor.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTL4TileRenderPipeline.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLAccelerationStructure.h +1212 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLAccelerationStructureCommandEncoder.h +322 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLAccelerationStructureTypes.h +224 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLAllocation.h +22 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLArgument.h +279 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLArgumentEncoder.h +199 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLBinaryArchive.h +142 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLBlitCommandEncoder.h +266 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLBlitPass.h +82 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLBuffer.h +94 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCaptureManager.h +113 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCaptureScope.h +43 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCommandBuffer.h +449 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCommandEncoder.h +148 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCommandQueue.h +102 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLComputeCommandEncoder.h +350 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLComputePass.h +90 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLComputePipeline.h +274 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLCounters.h +225 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDataType.h +232 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDefines.h +39 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDepthStencil.h +93 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDevice.h +1122 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDeviceCertification.h +29 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDrawable.h +36 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLDynamicLibrary.h +81 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLEvent.h +79 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFence.h +22 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionConstantValues.h +30 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionDescriptor.h +95 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionHandle.h +29 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionLog.h +37 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLFunctionStitching.h +131 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLGPUAddress.h +19 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLHeap.h +284 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIOCommandBuffer.h +10 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIOCommandQueue.h +11 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIOCompressor.h +10 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIndirectCommandBuffer.h +157 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIndirectCommandEncoder.h +110 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLIntersectionFunctionTable.h +186 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLLibrary.h +549 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLLinkedFunctions.h +57 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLLogState.h +65 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLParallelRenderCommandEncoder.h +77 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLPipeline.h +57 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLPixelFormat.h +342 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRasterizationRate.h +323 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRenderCommandEncoder.h +1068 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRenderPass.h +411 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRenderPipeline.h +788 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResidencySet.h +141 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResource.h +307 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResourceStateCommandEncoder.h +125 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResourceStatePass.h +85 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLResourceViewPool.h +22 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLSampler.h +252 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLStageInputOutputDescriptor.h +158 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLTensor.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLTexture.h +460 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLTextureViewPool.h +18 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLTypes.h +125 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLVertexDescriptor.h +153 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLVisibleFunctionTable.h +45 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/Metal.h +94 -0
- package/sdk/ios/System/Library/Frameworks/Metal.framework/Modules/module.modulemap +6 -0
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h +1 -0
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecBase.h +906 -3
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecCertificate.h +613 -0
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecItem.h +1284 -29
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecPolicy.h +441 -0
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecTrust.h +845 -0
- package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/Security.h +4 -0
- package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UTDefines.h +35 -0
- package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UTTagClass.h +33 -0
- package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UTType.h +504 -0
- package/sdk/ios/System/Library/Frameworks/_LocationEssentials.framework/Headers/CLEssentialsAvailability.h +14 -0
- package/sdk/ios/System/Library/Frameworks/_LocationEssentials.framework/Headers/CLLocationEssentials.h +444 -0
- package/sdk/ios/System/Library/Frameworks/_LocationEssentials.framework/Headers/LocationEssentials.h +14 -0
- package/sdk/ios/System/Library/Frameworks/_LocationEssentials.framework/Modules/module.modulemap +14 -0
- package/sdk/ios/usr/include/AvailabilityMacros.h +3985 -0
- package/sdk/ios/usr/include/complex.h +167 -0
- package/sdk/ios/usr/include/copyfile.h +143 -0
- package/sdk/ios/usr/include/dispatch/dispatch.h +5 -0
- package/sdk/ios/usr/include/mach/mach_types.h +1 -0
- package/sdk/ios/usr/include/malloc/_malloc.h +143 -0
- package/sdk/ios/usr/include/malloc/_malloc_type.h +153 -0
- package/sdk/ios/usr/include/malloc/_platform.h +80 -0
- package/sdk/ios/usr/include/malloc/_ptrcheck.h +43 -0
- package/sdk/ios/usr/include/malloc/malloc.h +768 -0
- package/sdk/ios/usr/include/math.h +835 -2
- package/sdk/ios/usr/include/os/availability.h +168 -6
- package/sdk/ios/usr/include/os/base.h +351 -0
- package/sdk/ios/usr/include/os/clock.h +18 -0
- package/sdk/ios/usr/include/os/lock.h +232 -10
- package/sdk/ios/usr/include/os/log.h +521 -38
- package/sdk/ios/usr/include/os/object.h +320 -3
- package/sdk/ios/usr/include/os/trace.h +492 -0
- package/sdk/ios/usr/include/os/trace_base.h +167 -0
- package/sdk/ios/usr/include/os/workgroup.h +37 -0
- package/sdk/ios/usr/include/os/workgroup_base.h +91 -0
- package/sdk/ios/usr/include/os/workgroup_interval.h +156 -0
- package/sdk/ios/usr/include/os/workgroup_object.h +359 -0
- package/sdk/ios/usr/include/os/workgroup_parallel.h +76 -0
- package/sdk/ios/usr/include/sys/cdefs.h +38 -1
- package/sdk/ios/wasm/include/unistd.h +3 -0
- package/skills/contrast/SKILL.md +3 -0
- package/src/codex-client.ts +11 -6
- package/src/dev-bundle-resolution.ts +124 -48
- package/src/expo-native-workspace.ts +176 -0
- package/src/expo-swift-host.ts +161 -26
- package/src/expo-swift-ready.ts +14 -28
- package/src/expoSwiftContract.ts +4 -1
- package/src/generated/swift-c-predefines.json +2044 -0
- package/src/host/bridge-host.ts +5 -0
- package/src/installed-package-versions.ts +14 -1
- package/src/metro-project-root.ts +44 -33
- package/src/native-app-identity-project.ts +1 -0
- package/src/nitro-adapter.lock.json +916 -10
- package/src/nitro-adapter.ts +33 -24
- package/src/nitro-bundle.ts +108 -21
- package/src/nitro-compile.ts +36 -5
- package/src/nitro-source.ts +13 -3
- package/src/nitroAdapterContract.ts +100 -20
- package/src/nitroContract.ts +18 -2
- package/src/node-http-fetch.ts +116 -0
- package/src/packageVersionsContract.ts +46 -0
- package/src/serverDiscoveryContract.ts +1 -0
- package/src/settingsContract.ts +0 -30
- package/src/swift-binary-modules.ts +20 -5
- package/src/swift-compile.ts +598 -81
- package/src/swift-coverage/package.ts +3 -1
- package/src/swift-coverage/xcode-assets.ts +66 -5
- package/src/swift-coverage/xcode-packages.ts +11 -6
- package/src/swift-host.ts +347 -60
- package/src/swift-objc-compile.ts +52 -10
- package/src/swift-objc-metadata.ts +2 -2
- package/src/swift-objc-platform.ts +2 -2
- package/src/swift-objc-standin.ts +53 -13
- package/src/swift-package-manifest.ts +151 -28
- package/src/swift-package.ts +158 -75
- package/src/swift-packages.ts +141 -44
- package/src/swift-source-file.ts +10 -15
- package/src/swift-source-pods.ts +126 -41
- package/src/swift-standin-digest.ts +77 -0
- package/src/swift-standin-emit.ts +40 -4
- package/src/swift-standins.ts +154 -31
- package/src/swift-submit.ts +5 -0
- package/src/swift-toolchain.ts +38 -0
- package/src/swiftContract.ts +168 -75
- package/src/target-matcher.ts +15 -2
- package/src/vite-plugin.ts +0 -10
- package/src/worklet-executable.ts +7 -3
- package/src/xcode-json-project.ts +14 -2
- package/src/xcode-project.ts +215 -100
- package/src/settings-flags.ts +0 -107
|
@@ -1,8 +1,29 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @header vImage_Utilities.h
|
|
3
|
+
* vImage
|
|
4
|
+
*
|
|
5
|
+
* Created by Ian Ollmann on 6/7/12.
|
|
6
|
+
*
|
|
7
|
+
* See vImage/vImage.h for more on how to view the headerdoc documentation for functions declared herein.
|
|
8
|
+
*
|
|
9
|
+
* @copyright Copyright (c) 2012-2016 by Apple Inc. All rights reserved.
|
|
10
|
+
*
|
|
11
|
+
* @discussion These interfaces provide methods to help exchange data between CoreGraphics and vImage
|
|
12
|
+
* and provides conversion routines to convert nearly any image format to nearly any
|
|
13
|
+
* other image format. They are intended to streamline vImage adoption, and make it possible
|
|
14
|
+
* for your application's imaging pipeline to gracefully handle a wide diversity of image formats.
|
|
15
|
+
* When conversions are necessary, they are vectorized and multithreaded to minimize cost in
|
|
16
|
+
* time and energy.
|
|
17
|
+
*
|
|
18
|
+
* @ignorefuncmacro VIMAGE_NON_NULL
|
|
19
|
+
* @ignorefuncmacro VIMAGE_CHOICE_ENUM
|
|
20
|
+
*/
|
|
21
|
+
|
|
1
22
|
#ifndef vImage_Utilities_h
|
|
2
23
|
#define vImage_Utilities_h
|
|
3
24
|
|
|
4
25
|
#include <vImage/vImage_Types.h>
|
|
5
|
-
#include <CoreGraphics/CoreGraphics.h>
|
|
26
|
+
#include <CoreGraphics/CoreGraphics.h> /* #define vImage_Utilities_h 1 before including Accelerate headers to turn this header off */
|
|
6
27
|
|
|
7
28
|
#ifdef __cplusplus
|
|
8
29
|
extern "C" {
|
|
@@ -11,9 +32,120 @@ extern "C" {
|
|
|
11
32
|
#ifndef VIMAGE_PF
|
|
12
33
|
#define VIMAGE_PF __attribute__ ((visibility ("default")))
|
|
13
34
|
#endif
|
|
14
|
-
|
|
35
|
+
|
|
36
|
+
/*!
|
|
37
|
+
* @const kvImageDecodeArray_16Q12Format
|
|
38
|
+
* @abstract Predefined decode array constant to use with 16Q12 formatted data
|
|
39
|
+
* @discussion 16Q12 data is a signed 16-bit fixed point integer. The format is implicitly divided by 2**12
|
|
40
|
+
* to give a range of [-8,8) (SHRT_MIN/4096,SHRT_MAX/4096). The type is present to allow
|
|
41
|
+
* 8-bit content to be converted into other colorspaces and operated on without undue
|
|
42
|
+
* loss of precision or loss of color gamut due to clamping. This constant is "magic" in the
|
|
43
|
+
* sense that it is identified by address. Copying the values here will cause a CG format to
|
|
44
|
+
* be instead interpreted as a _unsigned_ 16 bit format.
|
|
45
|
+
*
|
|
46
|
+
* 16Q12 pixels do not follow CG image format conventions in two respects. The format is signed.
|
|
47
|
+
* The alpha channel is subject to the decode array transform too, meaning that 0 is transparent
|
|
48
|
+
* and 4096 opaque. Consequently, ALL buffers that use this format must be tagged with the
|
|
49
|
+
* kvImageDecodeArray_16Q12Format decode array.
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
15
52
|
extern VIMAGE_PF const CGFloat * kvImageDecodeArray_16Q12Format;
|
|
16
53
|
|
|
54
|
+
/*!
|
|
55
|
+
* @struct vImage_CGImageFormat
|
|
56
|
+
* @abstract A pixel format
|
|
57
|
+
* @discussion A vImage_CGImageFormat describes the ordering of the color channels, how many there are,
|
|
58
|
+
* the size and type of the data in the color channels and whether the data is premultiplied by alpha or not.
|
|
59
|
+
* This format mirrors the image format descriptors used by CoreGraphics to create things like CGImageRef and
|
|
60
|
+
* CGBitmapContextRef.
|
|
61
|
+
*
|
|
62
|
+
* This vImage_CGImageFormat:
|
|
63
|
+
*
|
|
64
|
+
* <pre>@textblock
|
|
65
|
+
* vImage_CGImageFormat format = {
|
|
66
|
+
* .bitsPerComponent = 8,
|
|
67
|
+
* .bitsPerPixel = 32,
|
|
68
|
+
* .colorSpace = CGColorSpaceCreateDeviceRGB(), // don't forget to release this!
|
|
69
|
+
* .bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little,
|
|
70
|
+
* .version = 0, // must be 0
|
|
71
|
+
* .decode = NULL,
|
|
72
|
+
* .renderingIntent = kCGRenderingIntentDefault
|
|
73
|
+
* };
|
|
74
|
+
* @/textblock</pre>
|
|
75
|
+
*
|
|
76
|
+
* codes for a little endian ARGB8888 pixel, or what is called in the rest of vImage, BGRA8888. Note: for 16-
|
|
77
|
+
* and 32-bits per component formats (int16_t, uint16_t, half-float, float) most vImage image filters assume
|
|
78
|
+
* the data is in host-endian format. (The APIs in this header do not.) Host-endian is little endian for Intel
|
|
79
|
+
* and ARM, big endian for PowerPC. If the data is not in host-endian format, then you may use
|
|
80
|
+
* vImagePermuteChannels_ARGB8888 or vImageByteSwap_Planar16U to swap the image data byte ordering.
|
|
81
|
+
*
|
|
82
|
+
* Some examples:
|
|
83
|
+
* <pre>@textblock
|
|
84
|
+
* ARGB8888 -> {8, 32, NULL, alpha first, 0, NULL, kCGRenderingIntentDefault} alpha first = { kCGImageAlphaFirst, kCGImageAlphaPremultipliedFirst, kCGImageAlphaNoneSkipFirst }
|
|
85
|
+
* RGBA8888 -> {8, 32, NULL, alpha last, 0, NULL, kCGRenderingIntentDefault} alpha last = { kCGImageAlphaLast, kCGImageAlphaPremultipliedLast, kCGImageAlphaNoneSkipLast }
|
|
86
|
+
* BGRA8888 -> {8, 32, NULL, alpha first | kCGBitmapByteOrder32Little, 0, NULL, kCGRenderingIntentDefault}
|
|
87
|
+
* RGB888 -> {8, 24, NULL, kCGImageAlphaNone | kCGBitmapByteOrderDefault, 0, NULL, kCGRenderingIntentDefault}
|
|
88
|
+
* RGB565 -> {5, 16, NULL, kCGImageAlphaNone | kCGBitmapByteOrder16Little, 0, NULL, kCGRenderingIntentDefault}
|
|
89
|
+
* ARGB1555 -> {5, 16, NULL, alpha first | kCGBitmapByteOrder16Little, 0, NULL, kCGRenderingIntentDefault}
|
|
90
|
+
* RGBA16F -> {16, 64, NULL, alpha last | kCGBitmapFloatComponents | kCGBitmapByteOrder16Little, 0, NULL, kCGRenderingIntentDefault }
|
|
91
|
+
* CMYK8888 -> {8, 32, CGColorSpaceCreateDeviceCMYK(), kCGImageAlphaNone, 0, NULL, kCGRenderingIntentDefault }
|
|
92
|
+
* ARGBFFFF premultiplied -> {32, 128, NULL, kCGImageAlphaPremultipliedFirst | kCGBitmapFloatComponents | kCGBitmapByteOrder32Little, 0, NULL, kCGRenderingIntentDefault }
|
|
93
|
+
* ARGBFFFF not-premultiplied -> {32, 128, NULL, kCGImageAlphaFirst | kCGBitmapFloatComponents | kCGBitmapByteOrder32Little, 0, NULL, kCGRenderingIntentDefault }
|
|
94
|
+
* ARGBFFFF, alpha = 1 -> {32, 128, NULL, kCGImageAlphaNoneSkipFirst | kCGBitmapFloatComponents | kCGBitmapByteOrder32Little, 0, NULL, kCGRenderingIntentDefault }
|
|
95
|
+
* @/textblock</pre>
|
|
96
|
+
*
|
|
97
|
+
* Note that some of these formats, particularly RGB565 and 16F formats are supported by vImage but
|
|
98
|
+
* not necessarily CoreGraphics. They will be converted to a higher precision format as necessary by
|
|
99
|
+
* vImage in vImageCreateCGImageFromBuffer().
|
|
100
|
+
*
|
|
101
|
+
* By C rules, uninitialized struct parameters are set to zero. The last three parameters are usually zero, so can usually be omitted.
|
|
102
|
+
*
|
|
103
|
+
* <pre>@textblock
|
|
104
|
+
* vImage_CGImageFormat srgb888 = (vImage_CGImageFormat){
|
|
105
|
+
* .bitsPerComponent = 8,
|
|
106
|
+
* .bitsPerPixel = 24,
|
|
107
|
+
* .colorSpace = NULL,
|
|
108
|
+
* .bitmapInfo = kCGImageAlphaNone | kCGBitmapByteOrderDefault };
|
|
109
|
+
* @/textblock</pre>
|
|
110
|
+
*
|
|
111
|
+
* To understand how these various parameters relate to one another, we can look at the process of converting from
|
|
112
|
+
* one vImage_CGImageFormat format to another:
|
|
113
|
+
*
|
|
114
|
+
* 1) transform endianness of src format given by bitmapInfo to host endian (except 8 bitPerComponent content)
|
|
115
|
+
* 2) remove decode array transformation, and up convert to a higher range format as necessary to preserve precision / range
|
|
116
|
+
* 3) convert src colorspace to reference XYZ colorspace (may cause upconvert to preserve range / precision)
|
|
117
|
+
* 4) convert XYZ to destination colorspace + rendering intent
|
|
118
|
+
* 5) convert to destination precision (given by bitsPerComponent)
|
|
119
|
+
* 6) deal with any alpha changes (given by bitmapInfo) or flattening that needs to occur
|
|
120
|
+
* 7) Apply any channel reordering requested, if it didn't happen at an earlier step. (As indicated by src and dest bitmapInfo)
|
|
121
|
+
* 8) Apply destination decode array
|
|
122
|
+
* 9) Apply endianness transform given by dest bitmapInfo
|
|
123
|
+
*
|
|
124
|
+
* Clearly, for most common transformations not all steps need to occur and multiple steps can be collapsed into a compound operation.
|
|
125
|
+
*
|
|
126
|
+
* @field bitsPerComponent The number of bits needed to represent one channel of data in one pixel. For ARGB8888, this would be 8. Expected values: {1, 2, 4, 5, 8, 10, 12, 16, 32}
|
|
127
|
+
* @field bitsPerPixel The number of bits needed to represent one pixel. For ARGB8888, this would be 32.
|
|
128
|
+
* It is possible that bitsPerPixel > bitsPerComponent * number of components, but in practice this is rare.
|
|
129
|
+
* The number of color components is given by the colorspace and the number of alpha components (0 or 1) is given by
|
|
130
|
+
* by the bitmapInfo.
|
|
131
|
+
* @field colorSpace A description of how the pixel data in the image is positioned relative to a reference XYZ color space.
|
|
132
|
+
* See CoreGraphics/CGColorSpace.h. Pass NULL as a shorthand for sRGB. The vImage_CGImageFormat is not
|
|
133
|
+
* capable of managing the memory held by the colorSpace. If you created the colorspace, you must
|
|
134
|
+
* be sure to release it before all references to it disappear from scope.
|
|
135
|
+
* @field bitmapInfo The CGBitmapInfo describing the color channels. See CoreGraphics/CGImage.h.
|
|
136
|
+
* ARGB8888 is kCGImageAlphaFirst | kCGBitmapByteOrderDefault
|
|
137
|
+
* BGRA8888 is kCGImageAlphaFirst | kCGBitmapByteOrder32Little
|
|
138
|
+
* @field version The struct is versioned for future expansion. Pass 0 here.
|
|
139
|
+
* @field decode Prior to transformations caused by the colorspace, color channels are subject to a linear transformation.
|
|
140
|
+
* This allows for a different range than the typical [0,1.0]. NULL indicates default behavior of [0,1.0]
|
|
141
|
+
* range, and is what you should use if you don't understand this parameter. See description of CGImageCreate()
|
|
142
|
+
* for a discussion of decode arrays. See also Decode Arrays section of Chapter 4.8 of the PDF specification.
|
|
143
|
+
* The vImage_CGImageFormat is not capable of managing the memory held by the decode array. If you created a
|
|
144
|
+
* decode array on the heap, you must be sure to release it before all references to it disappear from scope.
|
|
145
|
+
*
|
|
146
|
+
* @field renderingIntent See CGColorSpace.h. kCGRenderingIntentDefault is typical here. By convention, rendering intent changes that
|
|
147
|
+
* are not accompanied by a colorspace change are ignored.
|
|
148
|
+
*/
|
|
17
149
|
typedef struct vImage_CGImageFormat
|
|
18
150
|
{
|
|
19
151
|
uint32_t bitsPerComponent;
|
|
@@ -25,6 +157,87 @@ typedef struct vImage_CGImageFormat
|
|
|
25
157
|
CGColorRenderingIntent renderingIntent;
|
|
26
158
|
}vImage_CGImageFormat;
|
|
27
159
|
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
/*!
|
|
163
|
+
* @functiongroup vImage_Buffer utilities
|
|
164
|
+
* @discussion Convenience methods for working with vImage_Buffers.
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
/*!
|
|
168
|
+
* @function vImageBuffer_Init
|
|
169
|
+
* @abstract Convenience function to allocate a vImage_Buffer of desired size
|
|
170
|
+
* @discussion This function is a convenience method to help initialize a vImage_Buffer struct with a buffer sized
|
|
171
|
+
* and aligned for best performance. It will initialize the height, width and rowBytes fields, and allocate
|
|
172
|
+
* the pixel storage for you. You are responsible for releasing the memory pointed to by buf->data back to
|
|
173
|
+
* the system when you are done with it using free(). If no such allocation is desired, pass
|
|
174
|
+
* kvImageNoAllocate in the flags to cause buf->data to be set to NULL and the preferred alignment
|
|
175
|
+
* to be returned from the left hand side of the function.
|
|
176
|
+
*
|
|
177
|
+
* Here is an example of typical usage:
|
|
178
|
+
*
|
|
179
|
+
* <pre>@textblock
|
|
180
|
+
* vImage_Buffer buf;
|
|
181
|
+
* vImage_Error err = vImageBuffer_Init( &buf, height, width, 8 * sizeof(pixel), kvImageNoFlags);
|
|
182
|
+
* ...
|
|
183
|
+
* @/textblock</pre>
|
|
184
|
+
*
|
|
185
|
+
* And typical usage using your own allocator (posix_memalign in this case):
|
|
186
|
+
*
|
|
187
|
+
* <pre>@textblock
|
|
188
|
+
* vImage_Buffer buf;
|
|
189
|
+
* ssize_t alignment = vImageBuffer_Init( &buf, height, width, 8 * sizeof(pixel), kvImageNoAllocate);
|
|
190
|
+
* if( alignment >= 0 ) // <0 is an error
|
|
191
|
+
* error = posix_memalign( &buf.data, alignment, buf.height * buf.rowBytes ); // An allocator
|
|
192
|
+
* @/textblock</pre>
|
|
193
|
+
*
|
|
194
|
+
* On return, buf is initialized to contain the provided height and width and best rowBytes for the image.
|
|
195
|
+
* buf->data will also be allocated by default. If kvImageNoAllocate is passed then allocation is skipped,
|
|
196
|
+
* buf->data is set to NULL, and the preferred alignment is returned out the left hand side of the
|
|
197
|
+
* function.
|
|
198
|
+
*
|
|
199
|
+
* @param buf A valid empty vImage_Buffer struct. On return, all fields will be initialized.
|
|
200
|
+
* Please see behavior of kvImageNoAllocate in the flags parameter below.
|
|
201
|
+
*
|
|
202
|
+
* @param height The desired height of the image
|
|
203
|
+
* @param width The desired width of the image
|
|
204
|
+
*
|
|
205
|
+
* @param pixelBits The number of bits in a pixel of image data. If the image is in a planar format
|
|
206
|
+
* then this is the number of bits per color component. If pixelBits is not divisible
|
|
207
|
+
* by 8, then vImage will pad the scanline out to a multiple of a byte so that
|
|
208
|
+
* two scanlines can not share the same byte and all scanlines start at the start of
|
|
209
|
+
* a byte.
|
|
210
|
+
*
|
|
211
|
+
* @param flags Must be from the following list:
|
|
212
|
+
*
|
|
213
|
+
* <pre>@textblock
|
|
214
|
+
* kvImageNoAllocate -- on return buf->data is initialized to NULL. A preferred
|
|
215
|
+
* alignment suitable for use with posix_memalign is returned out the left hand
|
|
216
|
+
* side of the function and buf->rowBytes will be set to the preferred rowBytes.
|
|
217
|
+
* If the left hand side return is negative, it is an error code, not a size.
|
|
218
|
+
*
|
|
219
|
+
* If the kvImageNoAllocate flag is not passed, then on return buf->data will point
|
|
220
|
+
* to a newly allocated buffer with preferred alignment and rowBytes. An appropriate
|
|
221
|
+
* error code will be returned from the left hand side.
|
|
222
|
+
*
|
|
223
|
+
* kvImagePrintDiagnosticsToConsole -- directs the function to print diagnostic information
|
|
224
|
+
* to the console in the event of failure.
|
|
225
|
+
* @/textblock</pre>
|
|
226
|
+
*
|
|
227
|
+
* @return One of the following error codes will be returned out the left hand side.
|
|
228
|
+
*
|
|
229
|
+
* <pre>@textblock
|
|
230
|
+
* >0 kvImageNoAllocate was passed. The value returned indicates the
|
|
231
|
+
* preferred alignment (in bytes) for buf->data. buf->data is NULL.
|
|
232
|
+
*
|
|
233
|
+
* kvImageNoError Success
|
|
234
|
+
*
|
|
235
|
+
* kvImageMemoryAllocationError you requested that buf->data be allocated but the allocation failed
|
|
236
|
+
*
|
|
237
|
+
* kvImageUnknownFlagsBit flags was not from the list above
|
|
238
|
+
* @/textblock</pre>
|
|
239
|
+
*/
|
|
240
|
+
|
|
28
241
|
VIMAGE_PF vImage_Error vImageBuffer_Init( vImage_Buffer * buf,
|
|
29
242
|
vImagePixelCount height,
|
|
30
243
|
vImagePixelCount width,
|
|
@@ -33,17 +246,180 @@ VIMAGE_PF vImage_Error vImageBuffer_Init( vImage_Buffer * buf,
|
|
|
33
246
|
VIMAGE_NON_NULL(1)
|
|
34
247
|
API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
|
|
35
248
|
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
/*!
|
|
252
|
+
* @function vImageBuffer_GetSize
|
|
253
|
+
* @abstract Returns size of a vImage_Buffer as a CGSize.
|
|
254
|
+
* @discussion The CGSize / NSSize is rounded down to the nearest representable
|
|
255
|
+
* CGFloat that is less than or equal to the actual size of the image. In practice
|
|
256
|
+
* the conversion will always be exact, except for really, really big images. In
|
|
257
|
+
* that case, some part of the bottom or right edge might be truncated.
|
|
258
|
+
*
|
|
259
|
+
* <pre>@textblock
|
|
260
|
+
* Rationale: If you attempt your own home-made conversion to CGSize / NSSize by
|
|
261
|
+
* ordinary C rules and the value rounds, it will round up half the time.
|
|
262
|
+
* This could lead to a crash later because the height or width
|
|
263
|
+
* will be reported to be larger than it really is and an ensuing image
|
|
264
|
+
* operation will attempt to touch scanlines that don't exist.
|
|
265
|
+
* @/textblock</pre>
|
|
266
|
+
*
|
|
267
|
+
* @param buf A pointer to a valid vImage_Buffer
|
|
268
|
+
*
|
|
269
|
+
* @return The largest CGSize that will fit in the buffer. In typical usage, this
|
|
270
|
+
* is equal to the size of the buffer.
|
|
271
|
+
*/
|
|
36
272
|
VIMAGE_PF CGSize vImageBuffer_GetSize( const vImage_Buffer *buf )
|
|
37
273
|
VIMAGE_NON_NULL(1)
|
|
38
274
|
API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
|
|
39
275
|
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
/*!
|
|
281
|
+
* @functiongroup vImage_CGImageFormat functions
|
|
282
|
+
* @discussion A vImage_CGImageFormat describes a pixel format compatible with CoreGraphics.
|
|
283
|
+
* Most access to the vImage_CGImageFormat struct is done directly through memberwise
|
|
284
|
+
* access, but a few tasks are complicated enough to deserve their own library function.
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
/*!
|
|
288
|
+
* @function vImageCGImageFormat_GetComponentCount
|
|
289
|
+
* @abstract Calculate the number of channels (color + alpha) for a given image format
|
|
290
|
+
* @discussion The number of channels may not be safely calculated as bitsPerPixel / bitsPerComponent.
|
|
291
|
+
* Use this routine instead.
|
|
292
|
+
* @param format A pointer to a valid vImage_CGImageFormat. If format->colorspace is NULL,
|
|
293
|
+
* the format is assumed to belong to the sRGB colorspace.
|
|
294
|
+
*
|
|
295
|
+
* @return Returns the number of color + alpha channels in the image.
|
|
296
|
+
*/
|
|
40
297
|
VIMAGE_PF uint32_t vImageCGImageFormat_GetComponentCount( const vImage_CGImageFormat *format )
|
|
41
298
|
VIMAGE_NON_NULL(1)
|
|
42
299
|
API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
|
|
43
300
|
|
|
301
|
+
/*!
|
|
302
|
+
* @function vImageCGImageFormat_IsEqual
|
|
303
|
+
* @abstract Test to see if two vImage_CGImageFormats are equivalent
|
|
304
|
+
* @discussion Returns nonzero if two vImage_CGImageFormats are the same
|
|
305
|
+
* If either operand is NULL, the result is false.
|
|
306
|
+
* If vImage_CGImageFormat.colorSpace is NULL, sRGB is used.
|
|
307
|
+
*
|
|
308
|
+
* @param f1 A pointer to the first vImage_CGImageFormat
|
|
309
|
+
* @param f2 A pointer to the second vImage_CGImageFormat
|
|
310
|
+
*
|
|
311
|
+
* @return nonzero if two vImage_CGImageFormats are the same
|
|
312
|
+
*/
|
|
44
313
|
VIMAGE_PF Boolean vImageCGImageFormat_IsEqual( const vImage_CGImageFormat *f1, const vImage_CGImageFormat *f2 )
|
|
45
314
|
API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
|
|
46
315
|
|
|
316
|
+
|
|
317
|
+
/*!
|
|
318
|
+
* @functiongroup vImage_Buffer CGImageRef interconversion
|
|
319
|
+
* @discussion High level routines to convert from vImage_Buffer to CGImageRef and back.
|
|
320
|
+
*/
|
|
321
|
+
|
|
322
|
+
/*!
|
|
323
|
+
* @function vImageBuffer_InitWithCGImage
|
|
324
|
+
* @abstract Initialize a vImage_Buffer struct with the contents of a CGImageRef
|
|
325
|
+
* @discussion This function will initialize a vImage_Buffer struct with an image from a CGImageRef.
|
|
326
|
+
* By default, a new region of memory to hold the image data will be allocated by this function. You may
|
|
327
|
+
* optionally allocate the memory region yourself by passing in the kvImageNoAllocate flag.
|
|
328
|
+
*
|
|
329
|
+
* You may release the CGImageRef and format->colorspace upon successful return of this function.
|
|
330
|
+
*
|
|
331
|
+
* You are responsible for returning the memory referenced by buf->data to the system using free() when you are done with it.
|
|
332
|
+
* The CGImage may have other metadata associated with it, such as camera orientiation, which may require further
|
|
333
|
+
* processing downstream. vImage just does 1:1 pixel conversions from the raw image source.
|
|
334
|
+
*
|
|
335
|
+
*
|
|
336
|
+
* To create a CGImageRef from a image file on disk:
|
|
337
|
+
*
|
|
338
|
+
* <pre>@textblock
|
|
339
|
+
* CFURLRef path = ...; // path to image
|
|
340
|
+
* CGImageSourceRef imageSource = CGImageSourceCreateWithURL( path, optionsDictionary ); // optionsDictionary may be NULL
|
|
341
|
+
* CGImageRef imageRef = CGImageSourceCreateImageAtIndex( imageSource, imageIndex, optionsDictionary );
|
|
342
|
+
* @/textblock</pre>
|
|
343
|
+
*
|
|
344
|
+
* Similarly, with a chunk of compressed image data in memory:
|
|
345
|
+
*
|
|
346
|
+
* <pre>@textblock
|
|
347
|
+
* CFDataRef data = ...;
|
|
348
|
+
* CGImageSourceRef imageSource = CGImageSourceCreateWithData( path, optionsDictionary );
|
|
349
|
+
* CGImageRef imageRef = CGImageSourceCreateImageAtIndex( imageSource, imageIndex, optionsDictionary );
|
|
350
|
+
* @/textblock</pre>
|
|
351
|
+
*
|
|
352
|
+
* You can do similar things through AppKit / UIKit with [NSImage initWithContentsOfFile:],
|
|
353
|
+
* [NSImage initWithContentsOfURL:], or [NSImage initWithData:], and use [NSImage CGImageForProposedRect:context:hints:]
|
|
354
|
+
* to get out a CGImageRef.
|
|
355
|
+
*
|
|
356
|
+
* @param buf A pointer to a valid vImage_Buffer struct. The fields of the structure pointed to by buf will
|
|
357
|
+
* be updated to point to a vImage_Buffer representation of the CGImage. By default, a newly
|
|
358
|
+
* allocated piece of memory will be used to hold the image. You are responsible
|
|
359
|
+
* for releasing the memory pointed to by buf->data back to the system using free().
|
|
360
|
+
*
|
|
361
|
+
* If you want to allocate the buf->data and initialize rowBytes yourself, then you may pass
|
|
362
|
+
* kvImageNoAllocate in the flags parameter. This will cause the buf->data and rowBytes values
|
|
363
|
+
* passed into the function to be used directly without modification. You may find vImageBuffer_Init,
|
|
364
|
+
* vImageCGImageFormat_GetPixelBits, CGImageGetWidth and CGImageGetHeight helpful in sizing your buffer.
|
|
365
|
+
*
|
|
366
|
+
* @param format A pointer to a valid vImage_CGImageFormat specifying the desired image format associated with the
|
|
367
|
+
* output buf. If format->colorspace is NULL, sRGB will be used.
|
|
368
|
+
*
|
|
369
|
+
* @param backgroundColor If the CGImageRef encodes an alpha (or mask) and the output format does not have alpha then the
|
|
370
|
+
* result will be flattened against a background color. See vImageConverter_CreateWithCGImageFormat
|
|
371
|
+
* and functions like vImageFlatten_ARGB8888ToRGB888 for more on flattening. The background color here is
|
|
372
|
+
* a series of values of range [0,1] interpreted according to the colorspace passed in format. Example: If
|
|
373
|
+
* the format encodes for a AGBR 8-bit image (kCGImageAlphaLast, kCGBitmapByteOrder32Little), then this would be
|
|
374
|
+
* {red, green, blue}, the canonical ordering for a RGB colorspace, as an array of three CGFloats.
|
|
375
|
+
* If NULL is passed, an array full of zeros is used. The backgroundColor must have at least as many
|
|
376
|
+
* CGFloats in it as the colorspace has color channels. See CGColorSpaceGetNumberOfComponents.
|
|
377
|
+
*
|
|
378
|
+
* @param image A valid CGImageRef to be used as source data.
|
|
379
|
+
*
|
|
380
|
+
* @param flags You may set the following flags:
|
|
381
|
+
*
|
|
382
|
+
* <pre>@textblock
|
|
383
|
+
* kvImageNoAllocate the buf->data and buf->rowBytes values passed in are used without modification.
|
|
384
|
+
* This allows you to allocate your own buffer to hold the result. See buf description
|
|
385
|
+
* above.
|
|
386
|
+
*
|
|
387
|
+
* kvImagePrintDiagnosticsToConsole In the event of a problem, print out some helpful debug messages.
|
|
388
|
+
*
|
|
389
|
+
* kvImageDoNoTile It is possible that vImage will have to do an image format conversion from the
|
|
390
|
+
* image native format to the desired format. This will turn off multithreading for
|
|
391
|
+
* that step and any other vImage work that is multithreaded. Since any such conversions
|
|
392
|
+
* are likely happening outside your tiling engine, use of this flag here is
|
|
393
|
+
* probably counterproductive. In rare cases, it might be valuable as a method to
|
|
394
|
+
* leave unoccupied some cores for other tasks, if you have other multithreaded time
|
|
395
|
+
* sensitive tasks running. Likewise, if you are converting multiple images concurrently,
|
|
396
|
+
* it might be helpful to avoid oversubscribing the system.
|
|
397
|
+
* @/textblock </pre>
|
|
398
|
+
*
|
|
399
|
+
*
|
|
400
|
+
* @return If the call succeeds, kvImageNoError is returned and the memory region pointed to by buf will be initialized to
|
|
401
|
+
* describe a valid repesentation of the CGImageRef.
|
|
402
|
+
*
|
|
403
|
+
* If the call fails, then one of the following error codes will be returned and buf->data will be set to NULL.
|
|
404
|
+
*
|
|
405
|
+
* <pre>@textblock
|
|
406
|
+
* kvImageUnknownFlagsBit flags must be kvImageNoFlags or kvImageNoAllocate
|
|
407
|
+
* kvImageMemoryAllocationError Not enough memory to allocate buf->data
|
|
408
|
+
* kvImageInvalidParameter format->bitmapInfo has unknown bits set
|
|
409
|
+
* kvImageInvalidParameter format->version is not 0 or 1
|
|
410
|
+
* kvImageInvalidParameter format->decode is not NULL
|
|
411
|
+
* kvImageInvalidParameter format->bitsPerComponent is not in {0,1,2,4,5,8,16,32}
|
|
412
|
+
* kvImageInvalidImageFormat format->renderingIntent is not a known value
|
|
413
|
+
* kvImageInvalidImageFormat The format called for conversion to an input-only colorspace. Some color profiles
|
|
414
|
+
* (e.g. those arising from a scanner) are described as input only, because the device can
|
|
415
|
+
* not produce image output.
|
|
416
|
+
* kvImageNullPointerArgument format may not be NULL
|
|
417
|
+
* kvImageNullPointerArgument image may not be NULL
|
|
418
|
+
* kvImageInternalError Something unexpected went wrong. Please file a bug.
|
|
419
|
+
* @/textblock </pre>
|
|
420
|
+
*
|
|
421
|
+
*/
|
|
422
|
+
|
|
47
423
|
VIMAGE_PF vImage_Error vImageBuffer_InitWithCGImage( vImage_Buffer * buf,
|
|
48
424
|
vImage_CGImageFormat * format,
|
|
49
425
|
const CGFloat * backgroundColor,
|
|
@@ -52,6 +428,109 @@ VIMAGE_PF vImage_Error vImageBuffer_InitWithCGImage( vImage_Buffer * bu
|
|
|
52
428
|
VIMAGE_NON_NULL(1,2,4)
|
|
53
429
|
API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
|
|
54
430
|
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
/*!
|
|
434
|
+
* @function vImageCreateCGImageFromBuffer
|
|
435
|
+
* @abstract Create a CGImageRef from a vImage_Buffer.
|
|
436
|
+
* @discussion This function creates a CGImageRef using the image data in a vImage_Buffer. The CGImageRef has a retain count of 1.
|
|
437
|
+
* By default, a copy of the image data is made. This allows the function to convert to a CG-friendly format as necessary
|
|
438
|
+
* and allows you to continue to use the vImage_Buffer without causing problems for the CGImageRef.
|
|
439
|
+
*
|
|
440
|
+
* <pre>@textblock
|
|
441
|
+
* No copy mode
|
|
442
|
+
* ------------
|
|
443
|
+
* When the kvImageNoAllocate flag is passed, then "no-copy" operation is said to occur. Ownership of the memory region
|
|
444
|
+
* pointed to by buf->data is transferred to the CGImageRef and it becomes private to and owned by that object and will
|
|
445
|
+
* be used without modification. The memory region pointed to by buf->data will be destroyed when the CGImageRef is
|
|
446
|
+
* destroyed. Caution: CGImageRefs are defined to be immutable once created. Behavior is undefined if you create
|
|
447
|
+
* a CGImageRef then modify the pixels in its backing store.
|
|
448
|
+
*
|
|
449
|
+
* No-copy mode can be a little fussy about formats. When a format is rejected, kvImageInvalidImageFormat will be returned.
|
|
450
|
+
* Formats that are likely to succeed are 8-bit unsigned, 16-bit unsigned and 32-bit floating-point. The image should be
|
|
451
|
+
* kCGImageAlphaNone, kCGImageAlphaLast, kCGImageAlphaPremultipliedLast or kCGImageAlphaNoneSkipLast, and decode = NULL.
|
|
452
|
+
* The image should be in host endian mode. This is kCGBitmapByteOrderDefault for 8-bit per component images, and or larger
|
|
453
|
+
* types, the endianness is given by the endianness of the host system and the size is given by the size of the pixel
|
|
454
|
+
* (bitsPerComponent < 8) or channel (bitsPerComponent > 8). For example RGB565 data should be kCGBitmapByteOrder16Little
|
|
455
|
+
* and 32-bit floating point data should be kCGBitmapByteOrder32Little on little endian processors.
|
|
456
|
+
*
|
|
457
|
+
* It is recommended that if no-copy mode fails, that you try again without the kvImageNoAllocate flag. The call probably
|
|
458
|
+
* will succeed.
|
|
459
|
+
* @/textblock </pre>
|
|
460
|
+
*
|
|
461
|
+
* CGImage Debugging Note:
|
|
462
|
+
* The format parameter describes the image data you pass in, but there is no requirement that this is the
|
|
463
|
+
* format that is actually used to represent the image data held by the CGImage. You should be able to get
|
|
464
|
+
* back the data in any format you like with vImageBuffer_InitWithCGImage. However, understand that if you
|
|
465
|
+
* request the data through another API like CGDataProviderCopyData(), it will be formatted as described by
|
|
466
|
+
* that API -- for CGDataProviderCopyData(), that would be as described by: CGImageGetBitmapInfo, CGImageGetDecode,
|
|
467
|
+
* CGImageGetRenderingIntent, CGImageGetColorSpace, CGImageGetBytesPerRow, CGImageGetBitsPerPixel,
|
|
468
|
+
* CGImageGetBitsPerComponent, etc. Furthermore, the format that those APIs report is also not necessarily
|
|
469
|
+
* the format of the data held by the CGImageRef. Common image data consumers like CoreAnimation and
|
|
470
|
+
* CoreGraphics have their format preferences and vImage caters to them in order to deliver good performance.
|
|
471
|
+
*
|
|
472
|
+
* CGImageRefs can also be made from vImage_Buffers using CGImageCreate() and CGDataProviderCreateWithData().
|
|
473
|
+
*
|
|
474
|
+
* @param buf The vImage_Buffer from which to make the CGImageRef
|
|
475
|
+
*
|
|
476
|
+
* @param format The image format of the vImage_Buffer. format may not be NULL. format->colorspace may be NULL,
|
|
477
|
+
* in which case sRGB will be used. The colorspace is retained as needed by the new CGImage.
|
|
478
|
+
*
|
|
479
|
+
* @param callback In no-copy mode, this callback is called to destroy the buf->data when the CGImageRef no longer needs it.
|
|
480
|
+
* If NULL is passed for the callback, then free() will be used to destroy buf->data. userData will be
|
|
481
|
+
* passed to the callback function as the userData parameter and buf->data passed as the buf_data parameter.
|
|
482
|
+
*
|
|
483
|
+
* This parameter has no effect if kvImageNoAllocate is not in flags.
|
|
484
|
+
*
|
|
485
|
+
* The callback may be called at any time from any thread. It is possible for it to be called before
|
|
486
|
+
* vImageCreateCGImageFromBuffer returns.
|
|
487
|
+
*
|
|
488
|
+
* The callback will not be called if the returned CGImageRef is NULL.
|
|
489
|
+
*
|
|
490
|
+
* @param userData The value to pass to the callbacks userData parameter. If callback is NULL or kvImageNoAllocate
|
|
491
|
+
* is passed in flags, this value is ignored.
|
|
492
|
+
*
|
|
493
|
+
* @param flags The following flags are allowed:
|
|
494
|
+
* <pre>@textblock
|
|
495
|
+
* kvImageNoAllocate Causes vImageCreateCGImageFromBuffer to run in no-copy mode.
|
|
496
|
+
* Ownership of the memory pointed to by buf->data is transferred
|
|
497
|
+
* to the CGImageRef. You'll need to set up a callback and userData
|
|
498
|
+
* to manage releasing the memory back to the system when the CGImage
|
|
499
|
+
* is done with it.
|
|
500
|
+
*
|
|
501
|
+
* kvImagePrintDiagnosticsToConsole In the event of a problem, print out some helpful debug messages.
|
|
502
|
+
*
|
|
503
|
+
* kvImageHighQualityResampling Sometimes the system will ask for the image to be resamled to
|
|
504
|
+
* a smaller size. If that happens vImageAffineWarp_<fmt>" will be
|
|
505
|
+
* called. In that case, the value of this bit will be used to
|
|
506
|
+
* determine whether Lanczos3 or Lanczos5 resampling is used.
|
|
507
|
+
*
|
|
508
|
+
* kvImageDoNotTile Disables multithreading in any conversions that need to be done.
|
|
509
|
+
* Since it seems likely any such conversions will not be running in
|
|
510
|
+
* the context of your tiling engine (if you wrote one) in this case,
|
|
511
|
+
* this flag is probably counterproductive in this context. Conversions
|
|
512
|
+
* can happen later, after this call returns, when the image is drawn.
|
|
513
|
+
* @/textblock </pre>
|
|
514
|
+
* @param error if not NULL, points to a more informative error code to describe what went wrong on exit. May be NULL.
|
|
515
|
+
* Testing the result against NULL is sufficient to detect success or failure. kvImagePrintDiagnosticsToConsole
|
|
516
|
+
* is another way to get error information.
|
|
517
|
+
*
|
|
518
|
+
* @return On success, the returned CGImageRef will be non-NULL. If error is not NULL, kvImageNoError will be written there.
|
|
519
|
+
* On failure, NULL will be returned, and if error is not NULL, a more informative error code will be written there.
|
|
520
|
+
*
|
|
521
|
+
* <pre>@textblock
|
|
522
|
+
* Error Values:
|
|
523
|
+
* kvImageUnknownFlagsBit flags was not from the list described in the flags parameter above
|
|
524
|
+
* kvImageMemoryAllocationError Not enough memory to allocate the new CGImageRef
|
|
525
|
+
* kvImageInvalidParameter format->bitmapInfo has unknown bits set
|
|
526
|
+
* kvImageInvalidParameter format->bitsPerComponent is not in {5,8,16,32}
|
|
527
|
+
* kvImageInvalidImageFormat format->renderingIntent is not a known value
|
|
528
|
+
* kvImageNullPointerArgument format may not be NULL
|
|
529
|
+
* kvImageNullPointerArgument buf may not be NULL
|
|
530
|
+
* @/textblock </pre>
|
|
531
|
+
*
|
|
532
|
+
*/
|
|
533
|
+
|
|
55
534
|
VIMAGE_PF CGImageRef vImageCreateCGImageFromBuffer( const vImage_Buffer *buf,
|
|
56
535
|
const vImage_CGImageFormat *format,
|
|
57
536
|
void (*callback)(void *userData, void *buf_data),
|
|
@@ -61,10 +540,163 @@ VIMAGE_PF CGImageRef vImageCreateCGImageFromBuffer( const vImage_Buffer *buf,
|
|
|
61
540
|
VIMAGE_NON_NULL(1,2)
|
|
62
541
|
API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
|
|
63
542
|
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
/*!
|
|
546
|
+
* @functiongroup vImageConverterRef methods
|
|
547
|
+
* @discussion A vImageConverterRef describes a particular pixel format to pixel format conversion. These functions
|
|
548
|
+
* create, retain, release and get information about a vImageConverterRef. vImageConvert_AnyToAny() uses
|
|
549
|
+
* a vImageConverterRef to do a image format conversion.
|
|
550
|
+
*/
|
|
551
|
+
|
|
552
|
+
/*!
|
|
553
|
+
* @function vImageConverter_Retain
|
|
554
|
+
* @abstract Retain a vImageConverterRef
|
|
555
|
+
* @discussion You should retain a vImageConverterRef when you receive it from elsewhere (that is, you did not
|
|
556
|
+
* create or copy it) and you want it to persist. If you retain a vImageConverterRef you are responsible
|
|
557
|
+
* for releasing it (see Memory Management Programming Guide for Core Foundation).
|
|
558
|
+
*
|
|
559
|
+
* Like all of vImage, this interface is thread safe and may be called reentrantly.
|
|
560
|
+
*
|
|
561
|
+
* @param converter The vImageConverter to retain. If NULL, then nothing happens.
|
|
562
|
+
*/
|
|
64
563
|
VIMAGE_PF void vImageConverter_Retain( vImageConverterRef converter ) API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
|
|
65
564
|
|
|
565
|
+
/*!
|
|
566
|
+
* @function vImageConverter_Release
|
|
567
|
+
* @abstract Release a vImageConverterRef
|
|
568
|
+
* @discussion If the retain count of a vImageConverterRef becomes zero, the memory allocated to the
|
|
569
|
+
* object is deallocated and the object is destroyed. If you create or explicitly
|
|
570
|
+
* retain (see the vImageConverter_Retain function) a vImageConverterRef, you are responsible for
|
|
571
|
+
* releasing it when you no longer need it (see Memory Management Programming Guide for Core Foundation).
|
|
572
|
+
*
|
|
573
|
+
* Like all of vImage, this interface is thread safe and may be called reentrantly.
|
|
574
|
+
*
|
|
575
|
+
* @param converter The vImageConverter to release. If NULL, then nothing happens.
|
|
576
|
+
*/
|
|
66
577
|
VIMAGE_PF void vImageConverter_Release( vImageConverterRef converter ) API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
|
|
67
578
|
|
|
579
|
+
|
|
580
|
+
/*!
|
|
581
|
+
* @function vImageConverter_CreateWithCGImageFormat
|
|
582
|
+
* @abstract Create a vImageConverterRef to convert from one vImage_CGImageFormat to another
|
|
583
|
+
* @discussion vImageConverter_CreateWithCGImageFormat creates a vImageConverter to convert between
|
|
584
|
+
* image formats describable with a vImage_CGImageFormat. The vImageConverter is intended
|
|
585
|
+
* to be used (and reused, possibly reentrantly) with vImageConvert_AnyToAny() to convert
|
|
586
|
+
* images from one format to another.
|
|
587
|
+
*
|
|
588
|
+
* <pre>@textblock
|
|
589
|
+
* Image Format Notes:
|
|
590
|
+
* CG Integer images map the range [0,1.0] (black to full color intensity) to the range [0, TYPE_MAX]. A 8-bit unsigned image
|
|
591
|
+
* has a range [0,255] and a 16-bit signed image has a range [0,32767]. Floating point images map [0,1.0] to [0,1.0]. Some formats,
|
|
592
|
+
* like floating-point and signed integers are capable of representing values outside of that range. Conversions involving these
|
|
593
|
+
* formats will occasionally produce results outside of [0,1]. If the conversion causes a value to go out of the representable range
|
|
594
|
+
* for the underlying type, it will be clamped to the nearest representable value. This can happen in normal operation during color
|
|
595
|
+
* correction. You can clamp floating-point results back into [0,1] using vImageClip_PlanarF, if you like.
|
|
596
|
+
*
|
|
597
|
+
* Usually, colors must be direct mapped. Indexed color is supported format->bitsPerComponent and format->.bitsPerPixel are 1,2,4
|
|
598
|
+
* or 8, and equal (i.e. grayscale) only. Indexed color is not supported for the destination image. Images with indexed color must use
|
|
599
|
+
* (kCGImageAlphaNone | kCGBitmapByteOrderDefault) as the bitmapInfo. It is usually faster with indexed color spaces to use
|
|
600
|
+
* vImageConvert_AnyToAny to convert the color table rather than the image itself when possible, because the table is usually much
|
|
601
|
+
* smaller than the image. vImageConvert_AnyToAny can not do that automatically for you behind the scenes because it does not return
|
|
602
|
+
* a modified colorspace.
|
|
603
|
+
*
|
|
604
|
+
* Device Colorspaces:
|
|
605
|
+
* Because vImage has no concept of a rendering context or destination graphics device, vImage maps device RGB, device grayscale
|
|
606
|
+
* and device CMYK to a virtual device which is not your display. The virtual device uses kColorSyncGenericGrayGamma22Profile,
|
|
607
|
+
* kColorSyncSRGBProfile and kColorSyncGenericCMYKProfile respectively. If you want the image to be converted to the right colorspace
|
|
608
|
+
* for your display device, you will need to pass in the CGColorSpaceRef for that device obtained from an API like CGDisplayCopyColorSpace().
|
|
609
|
+
*
|
|
610
|
+
* Black Point Compensation:
|
|
611
|
+
* By default, BPC is off for this function. If you want black point compensation or other advanced ColorSync effects, construct your
|
|
612
|
+
* own ColorSyncTransformRef and pass the associated "code fragment" to vImageConverter_CreateWithColorSyncCodeFragment.
|
|
613
|
+
* See Apple Sample Code "Converting an Image with Black Point Compensation" https://developer.apple.com/library/mac/samplecode/convertImage/Introduction/Intro.html
|
|
614
|
+
* @/textblock </pre>
|
|
615
|
+
*
|
|
616
|
+
* See also vImageConverter_CreateForCGToCVImageFormat and vImageConverter_CreateForCVToCGImageFormat for converters
|
|
617
|
+
* that can operate on CoreVideo formats.
|
|
618
|
+
*
|
|
619
|
+
* @param srcFormat A pointer to a populated vImage_CGImageFormat struct describing the image format
|
|
620
|
+
* of the source image. If the CGColorSpaceRef is NULL, sRGB will be used
|
|
621
|
+
* as the default value. The CGColorSpaceRef will be retained by this function. It
|
|
622
|
+
* will be released when the vImageConverter is destroyed.
|
|
623
|
+
*
|
|
624
|
+
* @param destFormat A pointer to a populated vImage_CGImageFormat struct describing the image format
|
|
625
|
+
* of the destination image. If the CGColorSpaceRef is NULL, sRGB will be
|
|
626
|
+
* used as the default value. The CGColorSpaceRef will be retained by this function.
|
|
627
|
+
* It will be released when the vImageConverter is destroyed.
|
|
628
|
+
*
|
|
629
|
+
* @param backgroundColor Points to an array of floats to be used as a background color if one is needed. The
|
|
630
|
+
* backgroundColor range is assumed to be [0,1]. The channel ordering and number of color
|
|
631
|
+
* channels must match the natural order of the destination colorSpace (e.g. RGB or CMYK).
|
|
632
|
+
* The backgroundColor may be NULL if no background color is needed.
|
|
633
|
+
*
|
|
634
|
+
* A background color is used when the image is converted from an alpha-containing format
|
|
635
|
+
* to an alpha-none format, in which case the alpha is removed by compositing against the
|
|
636
|
+
* opaque background color pointed to by this parameter. If the image is instead converted
|
|
637
|
+
* from one alpha containing format to another, then the image will be premultiplied or
|
|
638
|
+
* unpremultiplied as necessary and no background color is necessary. (For unpremultiplication,
|
|
639
|
+
* the result color value for pixels with alpha 0 is 0.) Likewise, when converting between
|
|
640
|
+
* alpha-none formats, a background color is not used. In the case of kCGImageAlphaNone ->
|
|
641
|
+
* kCGImageAlphaNoneSkipFirst/Last, the vacant alpha channel is filled in with 1.0. If NULL
|
|
642
|
+
* is passed here, then 0 will be used for the color channels.
|
|
643
|
+
*
|
|
644
|
+
* The vImageConverter will contain a copy of the data passed in this field.
|
|
645
|
+
*
|
|
646
|
+
* @param flags Any of the following flags are allowed:
|
|
647
|
+
*
|
|
648
|
+
* <pre>@textblock
|
|
649
|
+
* kvImagePrintDiagnosticsToConsole In the event of a problem, print out some helpful debug
|
|
650
|
+
* messages.
|
|
651
|
+
*
|
|
652
|
+
* kvImageDoNotTile A converter created with this flag will operate as if
|
|
653
|
+
* kvImageDoNotTile was passed to vImageConvert_AnyToAny
|
|
654
|
+
* whether it was or not.
|
|
655
|
+
* @/textblock </pre>
|
|
656
|
+
*
|
|
657
|
+
* @param error May be NULL. If not NULL, then a vImage_Error is returned at the address pointed to by error.
|
|
658
|
+
* The vImage_Error will be less than 0 if an error condition occurred. Checking the vImageConverter
|
|
659
|
+
* returned to make sure it is non-NULL is sufficient to verify success or failure of the function.
|
|
660
|
+
*
|
|
661
|
+
* The following error values can occur:
|
|
662
|
+
* <pre>@textblock
|
|
663
|
+
* kvImageNoError Success.
|
|
664
|
+
*
|
|
665
|
+
* kvImageNullPointerArgument srcFormat and/or destFormat is NULL.
|
|
666
|
+
*
|
|
667
|
+
* kvImageUnknownFlagsBit Currently only kvImagePrintDiagnosticsToConsole and kvImageDoNotTile are
|
|
668
|
+
* allowed. All other bits in the flags field must be 0.
|
|
669
|
+
*
|
|
670
|
+
* kvImageInvalidParameter backgroundColor is NULL and the conversion needed a backgroundColor
|
|
671
|
+
*
|
|
672
|
+
* kvImageInvalidImageFormat bitsPerComponent must be in {1,2,4,5,8,12,16,32}.
|
|
673
|
+
* kvImageInvalidImageFormat The base colorspace must be grayscale for destination images using indexed color.
|
|
674
|
+
* kvImageInvalidImageFormat The colorspace may be indexed color for images only if it is {1,2,4,8} bitsPerComponent
|
|
675
|
+
* and kCGImageAlphaNone.
|
|
676
|
+
* kvImageInvalidImageFormat vImage_CGImageFormat.bitmapInfo & kCGBitmapAlphaInfoMask does not encode a valid alpha
|
|
677
|
+
* kvImageInvalidImageFormat floating point formats must be 16 or 32 bits per component. 16-bit floats are
|
|
678
|
+
* IEEE-754-2008 binary16 interchange format (a.k.a. OpenEXR half float). 32-bit floats
|
|
679
|
+
* are the standard IEEE-754-2008 binary32 interchange format. (a.k.a float in C/C++/ObjC)
|
|
680
|
+
* kvImageInvalidImageFormat format->renderingIntent is not a known value
|
|
681
|
+
* kvImageInvalidImageFormat The conversion called for conversion to an input-only colorspace. Some color profiles
|
|
682
|
+
* (e.g. those arising from a scanner) are described as input only, because the device can
|
|
683
|
+
* not produce image output.
|
|
684
|
+
*
|
|
685
|
+
* kvImageInternalError The converter was unable to find a path from the source format to the destination format.
|
|
686
|
+
* This should not happen and indicates incorrect operation of the function. Please file a bug.
|
|
687
|
+
* The kvImagePrintDiagnosticsToConsole flag will provide additional diagnostic info.
|
|
688
|
+
* @/textblock </pre>
|
|
689
|
+
*
|
|
690
|
+
* In cases where the error code is not sufficient to quickly determine the problem, the kvImagePrintDiagnosticsToConsole flag
|
|
691
|
+
* should provide additional diagnostic info.
|
|
692
|
+
*
|
|
693
|
+
* @return A vImageConverter object with reference count of 1 is created. If the call fails due to an error, then NULL
|
|
694
|
+
* will be returned. Use vImageConverter_Release to release your reference to it and allow the resources used
|
|
695
|
+
* by the converter to be returned to the system.
|
|
696
|
+
*
|
|
697
|
+
* If error is not NULL, an error code will be written to that address on return.
|
|
698
|
+
*/
|
|
699
|
+
|
|
68
700
|
VIMAGE_PF vImageConverterRef vImageConverter_CreateWithCGImageFormat( const vImage_CGImageFormat *srcFormat,
|
|
69
701
|
const vImage_CGImageFormat *destFormat,
|
|
70
702
|
const CGFloat *backgroundColor,
|
|
@@ -73,6 +705,117 @@ VIMAGE_PF vImageConverterRef vImageConverter_CreateWithCGImageFormat( const vIma
|
|
|
73
705
|
VIMAGE_NON_NULL(1,2)
|
|
74
706
|
API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
|
|
75
707
|
|
|
708
|
+
|
|
709
|
+
/*!
|
|
710
|
+
* @function vImageConverter_CreateWithColorSyncCodeFragment
|
|
711
|
+
* @abstract Create a vImageConverterRef substituting in a custom ColorSync transform for the one vImage usually generates for the color conversion steps.
|
|
712
|
+
* @discussion vImageConverter_CreateWithColorSyncCodeFragment is like vImageConverter_CreateWithCGImageFormat, except that
|
|
713
|
+
* instead of creating its own colorspace transform for any colorspace conversions, it uses the one you pass in.
|
|
714
|
+
* This gives you greater control over the fine details of colorspace conversion, for exacting color fidelity.
|
|
715
|
+
* The colorspaces for source and destination images must refer to colorspaces that have the same number of channels
|
|
716
|
+
* as the codeFragment is designed to accept / produce.
|
|
717
|
+
*
|
|
718
|
+
* See Apple Sample Code "Converting an Image with Black Point Compensation" https://developer.apple.com/library/mac/samplecode/convertImage/Introduction/Intro.html
|
|
719
|
+
* for an example of usage.
|
|
720
|
+
*
|
|
721
|
+
* @param codeFragment A code fragment created with ColorSyncTransformCopyProperty( kColorSyncTransformFullConversionData,
|
|
722
|
+
* kColorSyncTransformParametricConversionData or kColorSyncTransformSimplifiedConversionData)
|
|
723
|
+
* May be NULL. If NULL, no colorspace conversion / correction is done. In this case,
|
|
724
|
+
* behavior is undefined if the colorspaces do not have the same channel order or have a
|
|
725
|
+
* different number of channels or the colorspaces are not from the same family.
|
|
726
|
+
* kColorSyncTransformFullConversionData is required for black point compensation.
|
|
727
|
+
* CAUTION: vImageConverter_CreateWithColorSyncCodeFragment does not verify that the
|
|
728
|
+
* codeFragment is actually appropriate for the srcFormat and destFormat provided. Nor
|
|
729
|
+
* does it attempt to append additional color space transformation steps to make the
|
|
730
|
+
* codeFragment appropriate to the images provided. If the colorspace of the srcFormat
|
|
731
|
+
* and destFormat do not correspond to the ColorSyncProfileRefs used to create the
|
|
732
|
+
* ColorSync transform in at least colorspace model, then the behavior is undefined.
|
|
733
|
+
* See CGColorSpaceModel CoreGraphics/CGColorSpace.h
|
|
734
|
+
*
|
|
735
|
+
* @param srcFormat A pointer to a populated vImage_CGImageFormat struct describing the image format
|
|
736
|
+
* of the source image. If the CGColorSpaceRef is NULL, sRGB will be used
|
|
737
|
+
* as the default value. The CGColorSpaceRef will be retained by this function. It
|
|
738
|
+
* will be released when the vImageConverter is destroyed.
|
|
739
|
+
*
|
|
740
|
+
* @param destFormat A pointer to a populated vImage_CGImageFormat struct describing the image format
|
|
741
|
+
* of the destination image. If the CGColorSpaceRef is NULL, sRGB will be
|
|
742
|
+
* used as the default value. The CGColorSpaceRef will be retained by this function.
|
|
743
|
+
* It will be released when the vImageConverter is destroyed.
|
|
744
|
+
*
|
|
745
|
+
* @param backgroundColor Points to an array of floats to be used as a background color if one is needed. The
|
|
746
|
+
* backgroundColor range is assumed to be [0,1]. The channel ordering and number of color
|
|
747
|
+
* channels must match the natural order of the destination colorSpace (e.g. RGB or CMYK).
|
|
748
|
+
* The backgroundColor may be NULL if no background color is needed.
|
|
749
|
+
*
|
|
750
|
+
* A background color is used when the image is converted from an alpha-containing format
|
|
751
|
+
* to an alpha-none format, in which case the alpha is removed by compositing against the
|
|
752
|
+
* opaque background color pointed to by this parameter. If the image is instead converted
|
|
753
|
+
* from one alpha containing format to another, then the image will be premultiplied or
|
|
754
|
+
* unpremultiplied as necessary and no background color is necessary. (For unpremultiplication,
|
|
755
|
+
* the result color value for pixels with alpha 0 is 0.) Likewise, when converting between
|
|
756
|
+
* alpha-none formats, a background color is not use. In the case of kCGImageAlphaNone ->
|
|
757
|
+
* kCGImageAlphaNoneSkipFirst/Last, the vacant alpha channel is filled in with 1.0. If NULL
|
|
758
|
+
* is passed here, then 0 will be used for the color channels.
|
|
759
|
+
*
|
|
760
|
+
* The vImageConverter will contain a copy of the data passed in this field.
|
|
761
|
+
*
|
|
762
|
+
* @param flags Any of the following flags are allowed:
|
|
763
|
+
*
|
|
764
|
+
* <pre>@textblock
|
|
765
|
+
* kvImagePrintDiagnosticsToConsole In the event of a problem, print out some helpful debug
|
|
766
|
+
* messages.
|
|
767
|
+
*
|
|
768
|
+
* kvImageDoNotTile A converter created with this flag will operate as if
|
|
769
|
+
* kvImageDoNotTile was passed to vImageConvert_AnyToAny
|
|
770
|
+
* whether it was or not.
|
|
771
|
+
* @/textblock </pre>
|
|
772
|
+
*
|
|
773
|
+
* @param error May be NULL. If not NULL, then a vImage_Error is returned at the address pointed to by error.
|
|
774
|
+
* The vImage_Error will be less than 0 if an error condition occurred. Checking the vImageConverter
|
|
775
|
+
* returned to make sure it is non-NULL is sufficient to verify success or failure of the function.
|
|
776
|
+
*
|
|
777
|
+
* The following error values can occur:
|
|
778
|
+
* <pre>@textblock
|
|
779
|
+
* kvImageNoError Success.
|
|
780
|
+
*
|
|
781
|
+
* kvImageNullPointerArgument srcFormat and/or destFormat is NULL.
|
|
782
|
+
*
|
|
783
|
+
* kvImageUnknownFlagsBit Currently only kvImagePrintDiagnosticsToConsole and kvImageDoNotTile are
|
|
784
|
+
* allowed. All other bits in the flags field must be 0.
|
|
785
|
+
*
|
|
786
|
+
* kvImageInvalidParameter backgroundColor is NULL and the conversion needed a backgroundColor
|
|
787
|
+
*
|
|
788
|
+
* kvImageInvalidImageFormat bitsPerComponent must be in {1,2,4,5,8,12,16,32}.
|
|
789
|
+
* kvImageInvalidImageFormat The base colorspace must be grayscale for destination images using indexed color.
|
|
790
|
+
* kvImageInvalidImageFormat The colorspace may be indexed color for images only if it is {1,2,4,8} bitsPerComponent
|
|
791
|
+
* and kCGImageAlphaNone.
|
|
792
|
+
* kvImageInvalidImageFormat vImage_CGImageFormat.bitmapInfo & kCGBitmapAlphaInfoMask does not encode a valid alpha
|
|
793
|
+
* kvImageInvalidImageFormat floating point formats must be 16 or 32 bits per component. 16-bit floats are
|
|
794
|
+
* IEEE-754-2008 binary16 interchange format (a.k.a. OpenEXR half float). 32-bit floats
|
|
795
|
+
* are the standard IEEE-754-2008 binary32 interchange format. (a.k.a float in C/C++/ObjC)
|
|
796
|
+
* kvImageInvalidImageFormat format->renderingIntent is not a known value
|
|
797
|
+
* kvImageInvalidImageFormat The conversion called for conversion to an input-only colorspace. Some color profiles
|
|
798
|
+
* (e.g. those arising from a scanner) are described as input only, because the device can
|
|
799
|
+
* not produce image output.
|
|
800
|
+
*
|
|
801
|
+
* kvImageInvalidImageFormat codeFragment was found to be otherwise invalid / unusable
|
|
802
|
+
*
|
|
803
|
+
* kvImageInternalError The converter was unable to find a path from the source format to the destination format.
|
|
804
|
+
* This should not happen and indicates incorrect operation of the function. Please file a bug.
|
|
805
|
+
* The kvImagePrintDiagnosticsToConsole flag will provide additional diagnostic info.
|
|
806
|
+
* @/textblock </pre>
|
|
807
|
+
*
|
|
808
|
+
* In cases where the error code is not sufficient to quickly determine the problem, the kvImagePrintDiagnosticsToConsole flag
|
|
809
|
+
* should provide additional diagnostic info.
|
|
810
|
+
*
|
|
811
|
+
* @return A vImageConverter object with reference count of 1 is created. If the call fails due to an error, then NULL
|
|
812
|
+
* will be returned. Use vImageConverter_Release to release your reference to it and allow the resources used
|
|
813
|
+
* by the converter to be returned to the system.
|
|
814
|
+
*
|
|
815
|
+
* If error is not NULL, an error code will be written to that address on return.
|
|
816
|
+
*
|
|
817
|
+
*/
|
|
818
|
+
|
|
76
819
|
VIMAGE_PF vImageConverterRef vImageConverter_CreateWithColorSyncCodeFragment( CFTypeRef codeFragment,
|
|
77
820
|
const vImage_CGImageFormat *srcFormat,
|
|
78
821
|
const vImage_CGImageFormat *destFormat,
|
|
@@ -82,10 +825,165 @@ VIMAGE_PF vImageConverterRef vImageConverter_CreateWithColorSyncCodeFragment( CF
|
|
|
82
825
|
VIMAGE_NON_NULL(1,2)
|
|
83
826
|
API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
|
|
84
827
|
|
|
828
|
+
|
|
829
|
+
/*!
|
|
830
|
+
* @function vImageConverter_CreateWithCGColorConversionInfo
|
|
831
|
+
* @abstract Create a vImageConverterRef substituting in CGColorConversionInfo for the one vImage usually generates for the color conversion steps.
|
|
832
|
+
* @discussion vImageConverter_CreateWithCGColorConversionInfo is like vImageConverter_CreateWithCGImageFormat, except that
|
|
833
|
+
* instead of creating its own colorspace transform for any colorspace conversions, it uses the one you pass in through CGColorConversionInfo.
|
|
834
|
+
* This gives you greater control over the fine details of colorspace conversion, for exacting color fidelity.
|
|
835
|
+
* The colorspaces for source and destination images must refer to colorspaces that have the same number of channels
|
|
836
|
+
* as the codeFragment is designed to accept / produce.
|
|
837
|
+
*
|
|
838
|
+
* See Apple Sample Code "Converting an Image with Black Point Compensation" https://developer.apple.com/library/mac/samplecode/convertImage/Introduction/Intro.html
|
|
839
|
+
* for an example of usage.
|
|
840
|
+
*
|
|
841
|
+
* @param colorConversionInfoRef CGColorConversionInfo described in CGColorConversionInfo.h
|
|
842
|
+
*
|
|
843
|
+
* @param srcFormat A pointer to a populated vImage_CGImageFormat struct describing the image format
|
|
844
|
+
* of the source image. CGColorSpaceRef will be ignored since vImage will get color space conversion
|
|
845
|
+
* information through CGColorConversionInfo.
|
|
846
|
+
*
|
|
847
|
+
* @param destFormat A pointer to a populated vImage_CGImageFormat struct describing the image format
|
|
848
|
+
* of the destination image. CGColorSpaceRef will be ignored since vImage will get color space conversion
|
|
849
|
+
* information through CGColorConversionInfo.
|
|
850
|
+
*
|
|
851
|
+
* @param backgroundColor Points to an array of floats to be used as a background color if one is needed. The
|
|
852
|
+
* backgroundColor range is assumed to be [0,1]. The channel ordering and number of color
|
|
853
|
+
* channels must match the natural order of the destination colorSpace (e.g. RGB or CMYK).
|
|
854
|
+
* The backgroundColor may be NULL if no background color is needed.
|
|
855
|
+
*
|
|
856
|
+
* A background color is used when the image is converted from an alpha-containing format
|
|
857
|
+
* to an alpha-none format, in which case the alpha is removed by compositing against the
|
|
858
|
+
* opaque background color pointed to by this parameter. If the image is instead converted
|
|
859
|
+
* from one alpha containing format to another, then the image will be premultiplied or
|
|
860
|
+
* unpremultiplied as necessary and no background color is necessary. (For unpremultiplication,
|
|
861
|
+
* the result color value for pixels with alpha 0 is 0.) Likewise, when converting between
|
|
862
|
+
* alpha-none formats, a background color is not use. In the case of kCGImageAlphaNone ->
|
|
863
|
+
* kCGImageAlphaNoneSkipFirst/Last, the vacant alpha channel is filled in with 1.0. If NULL
|
|
864
|
+
* is passed here, then 0 will be used for the color channels.
|
|
865
|
+
*
|
|
866
|
+
* The vImageConverter will contain a copy of the data passed in this field.
|
|
867
|
+
*
|
|
868
|
+
* @param flags Any of the following flags are allowed:
|
|
869
|
+
*
|
|
870
|
+
* <pre>@textblock
|
|
871
|
+
* kvImagePrintDiagnosticsToConsole In the event of a problem, print out some helpful debug
|
|
872
|
+
* messages.
|
|
873
|
+
*
|
|
874
|
+
* kvImageDoNotTile A converter created with this flag will operate as if
|
|
875
|
+
* kvImageDoNotTile was passed to vImageConvert_AnyToAny
|
|
876
|
+
* whether it was or not.
|
|
877
|
+
* @/textblock </pre>
|
|
878
|
+
*
|
|
879
|
+
* @param error May be NULL. If not NULL, then a vImage_Error is returned at the address pointed to by error.
|
|
880
|
+
* The vImage_Error will be less than 0 if an error condition occurred. Checking the vImageConverter
|
|
881
|
+
* returned to make sure it is non-NULL is sufficient to verify success or failure of the function.
|
|
882
|
+
*
|
|
883
|
+
* Some possible error values that can occur are :
|
|
884
|
+
* <pre>@textblock
|
|
885
|
+
* kvImageNoError Success.
|
|
886
|
+
*
|
|
887
|
+
* kvImageNullPointerArgument srcFormat and/or destFormat is NULL.
|
|
888
|
+
*
|
|
889
|
+
* kvImageUnknownFlagsBit Currently only kvImagePrintDiagnosticsToConsole and kvImageDoNotTile are
|
|
890
|
+
* allowed. All other bits in the flags field must be 0.
|
|
891
|
+
*
|
|
892
|
+
* kvImageInvalidParameter backgroundColor is NULL and the conversion needed a backgroundColor
|
|
893
|
+
*
|
|
894
|
+
* kvImageInvalidImageFormat The base colorspace must be grayscale for destination images using indexed color.
|
|
895
|
+
* kvImageInvalidImageFormat The colorspace may be indexed color for images only if it is {1,2,4,8} bitsPerComponent
|
|
896
|
+
* and kCGImageAlphaNone.
|
|
897
|
+
* kvImageInvalidImageFormat vImage_CGImageFormat.bitmapInfo & kCGBitmapAlphaInfoMask does not encode a valid alpha
|
|
898
|
+
* kvImageInvalidImageFormat floating point formats must be 16 or 32 bits per component. 16-bit floats are
|
|
899
|
+
* IEEE-754-2008 binary16 interchange format (a.k.a. OpenEXR half float). 32-bit floats
|
|
900
|
+
* are the standard IEEE-754-2008 binary32 interchange format. (a.k.a float in C/C++/ObjC)
|
|
901
|
+
* kvImageInvalidImageFormat format->renderingIntent is not a known value
|
|
902
|
+
* kvImageInvalidImageFormat The conversion called for conversion to an input-only colorspace. Some color profiles
|
|
903
|
+
* (e.g. those arising from a scanner) are described as input only, because the device can
|
|
904
|
+
* not produce image output.
|
|
905
|
+
*
|
|
906
|
+
* kvImageInvalidImageFormat CGColorConversionInfo was found to be otherwise invalid / unusable
|
|
907
|
+
*
|
|
908
|
+
* kvImageInternalError The converter was unable to find a path from the source format to the destination format.
|
|
909
|
+
* This should not happen and indicates incorrect operation of the function. Please file a bug.
|
|
910
|
+
* The kvImagePrintDiagnosticsToConsole flag will provide additional diagnostic info.
|
|
911
|
+
* @/textblock </pre>
|
|
912
|
+
*
|
|
913
|
+
* In cases where the error code is not sufficient to quickly determine the problem, the kvImagePrintDiagnosticsToConsole flag
|
|
914
|
+
* should provide additional diagnostic info.
|
|
915
|
+
*
|
|
916
|
+
* @return A vImageConverter object with reference count of 1 is created. If the call fails due to an error, then NULL
|
|
917
|
+
* will be returned. Use vImageConverter_Release to release your reference to it and allow the resources used
|
|
918
|
+
* by the converter to be returned to the system.
|
|
919
|
+
*
|
|
920
|
+
* If error is not NULL, an error code will be written to that address on return.
|
|
921
|
+
*
|
|
922
|
+
*/
|
|
923
|
+
|
|
85
924
|
VIMAGE_PF vImageConverterRef vImageConverter_CreateWithCGColorConversionInfo(CGColorConversionInfoRef colorConversionInfoRef, const vImage_CGImageFormat *sFormat, const vImage_CGImageFormat *dFormat, const CGFloat *bg, vImage_Flags flags, vImage_Error *error)
|
|
86
925
|
VIMAGE_NON_NULL(1,2,3)
|
|
87
926
|
API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0));
|
|
88
927
|
|
|
928
|
+
/*!
|
|
929
|
+
* @function vImageConverter_MustOperateOutOfPlace
|
|
930
|
+
* @abstract Determine whether a converter is capable of operating in place.
|
|
931
|
+
* @discussion Some conversions will work if the src and destination image buffer
|
|
932
|
+
* scanlines start at the same address. Others will not. In such cases,
|
|
933
|
+
* you need to allocate additional storage to hold the destination buffer.
|
|
934
|
+
* This function returns kvImageOutOfPlaceOperationRequired if the conversion
|
|
935
|
+
* requires out of place operation.
|
|
936
|
+
*
|
|
937
|
+
* <pre>@textblock
|
|
938
|
+
* In-place operation is considered to mean srcs[i].data = dests[i].data
|
|
939
|
+
* and srcs[i].rowBytes = dests[i].rowBytes. Other styles of partial buffer
|
|
940
|
+
* overlap produce undefined behavior.
|
|
941
|
+
* @/textblock </pre>
|
|
942
|
+
*
|
|
943
|
+
* The list of source and destination buffers is optional. Results are as follows:
|
|
944
|
+
*
|
|
945
|
+
* <pre>@textblock
|
|
946
|
+
* srcs = dests = NULL kvImageNoError if any conversion with this converter is guaranteed to work in place,
|
|
947
|
+
* provided that srcs[i].data = dests[i].data and srcs[i].rowBytes = dests[i].rowBytes.
|
|
948
|
+
* If there exists at least one combination of height and width for which in place operation
|
|
949
|
+
* is not possible with this converter, then kvImageOutOfPlaceOperationRequired will be returned.
|
|
950
|
+
*
|
|
951
|
+
* srcs != NULL, dests = NULL kvImageNullPointerArgument
|
|
952
|
+
* srcs = NULL, dests != NULL kvImageNullPointerArgument
|
|
953
|
+
*
|
|
954
|
+
* srcs != NULL, dests != NULL kvImageNoError if the conversion will successfully operate in place for this particular
|
|
955
|
+
* combination of heights, widths and rowBytes. In this case, vImage does not check to see if the
|
|
956
|
+
* buffers overlap. It presumes that srcs[i].data = dests[i].data. This is intended to allow
|
|
957
|
+
* you to defer allocation until later. If in place operation will not work, then
|
|
958
|
+
* kvImageOutOfPlaceOperationRequired is returned.
|
|
959
|
+
* @/textblock </pre>
|
|
960
|
+
*
|
|
961
|
+
* In no case during this function call does vImage examine the contents of the memory pointed to by srcs[i].data or dests[i].data.
|
|
962
|
+
*
|
|
963
|
+
* @param converter The converter to check
|
|
964
|
+
*
|
|
965
|
+
* @param srcs The list of source buffers you plan to use with vImageConvert_AnyToAny. May be NULL.
|
|
966
|
+
* @param dests The list of destination buffers you plan to use with vImageConvert_AnyToAny. May be NULL.
|
|
967
|
+
*
|
|
968
|
+
* @param flags The flags you plan to pass to vImageConvert_AnyToAny.
|
|
969
|
+
*
|
|
970
|
+
* <pre>@textblock
|
|
971
|
+
* Note: in the case of kvImagePrintDiagnosticsToConsole, the flag means print
|
|
972
|
+
* error information to the console for errors caught by vImageConverter_MustOperateOutOfPlace,
|
|
973
|
+
* not vImageConvert_AnyToAny. At times, vImageConverter_MustOperateOutOfPlace may fail because
|
|
974
|
+
* it detects an error condition that would cause vImageConvert_AnyToAny to fail.
|
|
975
|
+
* @/textblock </pre>
|
|
976
|
+
*
|
|
977
|
+
* @return Error Codes:
|
|
978
|
+
* <pre>@textblock
|
|
979
|
+
* kvImageNoError In-place operation will work
|
|
980
|
+
* kvImageNullPointerArgument The converter may not be NULL
|
|
981
|
+
* kvImageNullPointerArgument srcs and dests must either both be NULL or neither must be NULL.
|
|
982
|
+
* kvImageInvalidParameter The converter is invalid
|
|
983
|
+
* kvImageUnknownFlagsBit An unknown / unsupported flag was used
|
|
984
|
+
* kvImageOutOfPlaceOperationRequired vImageConvert_AnyToAny requires separate buffers be used for this operation
|
|
985
|
+
* @/textblock </pre>
|
|
986
|
+
*/
|
|
89
987
|
VIMAGE_PF vImage_Error vImageConverter_MustOperateOutOfPlace( const vImageConverterRef converter,
|
|
90
988
|
const vImage_Buffer *srcs,
|
|
91
989
|
const vImage_Buffer *dests,
|
|
@@ -93,14 +991,109 @@ VIMAGE_PF vImage_Error vImageConverter_MustOperateOutOfPlace( const vImageConver
|
|
|
93
991
|
VIMAGE_NON_NULL(1)
|
|
94
992
|
API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
|
|
95
993
|
|
|
994
|
+
/*!
|
|
995
|
+
* @function vImageConverter_GetNumberOfSourceBuffers
|
|
996
|
+
* @abstract Get the number of source buffers consumed by the converter.
|
|
997
|
+
* @discussion All formats discribed by a vImage_CGImageFormat just consume one vImage_Buffer
|
|
998
|
+
* and produce one vImage_Buffer. There are no multi-plane vImage_CGImageFormats.
|
|
999
|
+
* However, some video formats (see vImage/vImage_CVUtilities) have planar
|
|
1000
|
+
* data formats with data in more than one plane. For such conversions, it may be
|
|
1001
|
+
* necessary to know how many input buffers are consumed by a converter.
|
|
1002
|
+
*
|
|
1003
|
+
* For older operating systems, where these functions are not available,
|
|
1004
|
+
* the number of source and destination buffers is always 1.
|
|
1005
|
+
*
|
|
1006
|
+
* @param converter The conversion for which you wish to know the number of source buffers
|
|
1007
|
+
*
|
|
1008
|
+
* @return On success, the number of source buffers is returned. On failure, 0 is returned.
|
|
1009
|
+
*/
|
|
96
1010
|
VIMAGE_PF unsigned long vImageConverter_GetNumberOfSourceBuffers( const vImageConverterRef converter ) VIMAGE_NON_NULL(1) API_AVAILABLE(macos(10.10), ios(8.0), watchos(1.0), tvos(8.0));
|
|
97
1011
|
|
|
1012
|
+
/*!
|
|
1013
|
+
* @function vImageConverter_GetNumberOfDestinationBuffers
|
|
1014
|
+
* @abstract Get the number of destination buffers written to by the converter.
|
|
1015
|
+
* @discussion All formats discribed by a vImage_CGImageFormat just consume one vImage_Buffer
|
|
1016
|
+
* and produce one vImage_Buffer. There are no multi-plane vImage_CGImageFormats.
|
|
1017
|
+
* However, some video formats (see vImage/vImage_CVUtilities) have planar
|
|
1018
|
+
* data formats with data in more than one plane. For such conversions, it may be
|
|
1019
|
+
* necessary to know how many out buffers are overwritten by a converter.
|
|
1020
|
+
*
|
|
1021
|
+
* For older operating systems, where these functions are not available,
|
|
1022
|
+
* the number of source and destination buffers is always 1.
|
|
1023
|
+
*
|
|
1024
|
+
* @param converter The conversion for which you wish to know the number of result buffers
|
|
1025
|
+
*
|
|
1026
|
+
* @return On success, the number of result buffers is returned. On failure, 0 is returned.
|
|
1027
|
+
*/
|
|
98
1028
|
VIMAGE_PF unsigned long vImageConverter_GetNumberOfDestinationBuffers( const vImageConverterRef converter ) VIMAGE_NON_NULL(1) API_AVAILABLE(macos(10.10), ios(8.0), watchos(1.0), tvos(8.0));
|
|
99
1029
|
|
|
1030
|
+
/*!
|
|
1031
|
+
* @enum vImageBufferTypeCode
|
|
1032
|
+
*
|
|
1033
|
+
* @abstract Type codes for what is in a vImage_Buffer, such as red or luminance or chunky
|
|
1034
|
+
*
|
|
1035
|
+
* @discussion In rare circumstances, it may be necessary to introspect a vImageConverterRef that consumes
|
|
1036
|
+
* or produces multiple image planes to find out which color channels go into which planes.
|
|
1037
|
+
* See vImageConverter_GetSourceBufferOrder and vImageConverter_GetDestinationBufferOrder.
|
|
1038
|
+
* (This is typically only necessary with video content, because no CG formatted buffers have
|
|
1039
|
+
* multiple planes.) The vImageBufferTypeCode encodes what kind of data goes into each channel.
|
|
1040
|
+
*
|
|
1041
|
+
* @constant kvImageBufferTypeCode_Alpha The buffer contains the alpha channel / coverage component
|
|
1042
|
+
*
|
|
1043
|
+
* @constant kvImageBufferTypeCode_Indexed The buffer contains data in an indexed colorspace. This is a
|
|
1044
|
+
* planar buffer that is used to index a lookup table of color values. The color
|
|
1045
|
+
* values in the table may belong to more than one color component. Typically the
|
|
1046
|
+
* colorspace will have a color model of kCGColorSpaceModelIndexed and you will need
|
|
1047
|
+
* use CGColorSpaceGetBaseColorSpace to find out what to what color model the lookup
|
|
1048
|
+
* table maps.
|
|
1049
|
+
*
|
|
1050
|
+
* @constant kvImageBufferTypeCode_CVPixelBuffer_YCbCr The buffer contains luminance, and both chroma channels
|
|
1051
|
+
* interleaved according to the vImageConstCVImageFormatRef image type.
|
|
1052
|
+
*
|
|
1053
|
+
* @constant kvImageBufferTypeCode_Luminance The buffer contains only luminance data.
|
|
1054
|
+
*
|
|
1055
|
+
* @constant kvImageBufferTypeCode_Chroma The buffer contains both chrominance channels, interleaved.
|
|
1056
|
+
*
|
|
1057
|
+
* @constant kvImageBufferTypeCode_Cb The buffer contains the blue chrominance channel
|
|
1058
|
+
*
|
|
1059
|
+
* @constant kvImageBufferTypeCode_Cr The buffer contains the red chrominance channel
|
|
1060
|
+
*
|
|
1061
|
+
* @constant kvImageBufferTypeCode_CGFormat The buffer contains data describable as a vImage_CGImageFormat as
|
|
1062
|
+
* a single (likely chunky) buffer
|
|
1063
|
+
*
|
|
1064
|
+
* @constant kvImageBufferTypeCode_Chunky The buffer contains chunky data not describable as a vImage_CGImageFormat.
|
|
1065
|
+
*
|
|
1066
|
+
* @constant kvImageBufferTypeCode_RGB_Red If the image has a RGB color model, the buffer contains the red channel.
|
|
1067
|
+
*
|
|
1068
|
+
* @constant kvImageBufferTypeCode_RGB_Green If the image has a RGB color model, the buffer contains the green channel.
|
|
1069
|
+
*
|
|
1070
|
+
* @constant kvImageBufferTypeCode_RGB_Blue If the image has a RGB color model, the buffer contains the blue channel.
|
|
1071
|
+
*
|
|
1072
|
+
* @constant kvImageBufferTypeCode_CMYK_Cyan If the image has a CMYK color model, the buffer contains the cyan channel.
|
|
1073
|
+
*
|
|
1074
|
+
* @constant kvImageBufferTypeCode_CMYK_Magenta If the image has a CMYK color model, the buffer contains the magenta channel.
|
|
1075
|
+
*
|
|
1076
|
+
* @constant kvImageBufferTypeCode_CMYK_Yellow If the image has a CMYK color model, the buffer contains the yellow channel.
|
|
1077
|
+
*
|
|
1078
|
+
* @constant kvImageBufferTypeCode_CMYK_Black If the image has a CMYK color model, the buffer contains the black channel.
|
|
1079
|
+
*
|
|
1080
|
+
* @constant kvImageBufferTypeCode_XYZ_X If the image has a XYZ color model, the buffer contains the X channel.
|
|
1081
|
+
*
|
|
1082
|
+
* @constant kvImageBufferTypeCode_XYZ_Y If the image has a XYZ color model, the buffer contains the Y channel.
|
|
1083
|
+
*
|
|
1084
|
+
* @constant kvImageBufferTypeCode_XYZ_Z If the image has a XYZ color model, the buffer contains the Z channel.
|
|
1085
|
+
*
|
|
1086
|
+
* @constant kvImageBufferTypeCode_LAB_L If the image has a LAB color model, the buffer contains the L* channel.
|
|
1087
|
+
*
|
|
1088
|
+
* @constant kvImageBufferTypeCode_LAB_A If the image has a LAB color model, the buffer contains the a* channel.
|
|
1089
|
+
*
|
|
1090
|
+
* @constant kvImageBufferTypeCode_LAB_B If the image has a LAB color model, the buffer contains the b* channel.
|
|
1091
|
+
*/
|
|
100
1092
|
typedef VIMAGE_CHOICE_ENUM(vImageBufferTypeCode, uint32_t)
|
|
101
1093
|
{
|
|
102
1094
|
kvImageBufferTypeCode_EndOfList VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = 0,
|
|
103
|
-
|
|
1095
|
+
|
|
1096
|
+
/* planar formats -- each buffer contains a single color channel, arising from an image described by a colorspace */
|
|
104
1097
|
kvImageBufferTypeCode_ColorSpaceChannel1 VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ),
|
|
105
1098
|
kvImageBufferTypeCode_ColorSpaceChannel2 VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ),
|
|
106
1099
|
kvImageBufferTypeCode_ColorSpaceChannel3 VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ),
|
|
@@ -117,58 +1110,382 @@ typedef VIMAGE_CHOICE_ENUM(vImageBufferTypeCode, uint32_t)
|
|
|
117
1110
|
kvImageBufferTypeCode_ColorSpaceChannel14 VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ),
|
|
118
1111
|
kvImageBufferTypeCode_ColorSpaceChannel15 VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ),
|
|
119
1112
|
kvImageBufferTypeCode_ColorSpaceChannel16 VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ),
|
|
120
|
-
|
|
1113
|
+
|
|
1114
|
+
/* Coverage component */
|
|
121
1115
|
kvImageBufferTypeCode_Alpha VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ),
|
|
122
|
-
|
|
1116
|
+
|
|
1117
|
+
/* indexed color spaces */
|
|
123
1118
|
kvImageBufferTypeCode_Indexed VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ),
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
1119
|
+
|
|
1120
|
+
/* YUV formats. */
|
|
1121
|
+
kvImageBufferTypeCode_CVPixelBuffer_YCbCr VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ), /* A YCbCr packed buffer formatted according to types in CVPixelBuffer.h. May be accompanied by an alpha channel */
|
|
1122
|
+
kvImageBufferTypeCode_Luminance VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ), /* A Luminance (Y) plane */
|
|
1123
|
+
kvImageBufferTypeCode_Chroma VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ), /* A two-channel chroma (CbCr) plane */
|
|
1124
|
+
kvImageBufferTypeCode_Cb VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ), /* A blue chroma (Cb) plane */
|
|
1125
|
+
kvImageBufferTypeCode_Cr VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ), /* A red chroma (Cr) plane */
|
|
1126
|
+
|
|
1127
|
+
/* A interleaved (chunky) format with one or more channels, encodable as a vImage_CGImageFormat */
|
|
1128
|
+
kvImageBufferTypeCode_CGFormat VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ), /* always a singleton -- appearing as { kvImageBufferTypeCode_CGFormat, 0} */
|
|
1129
|
+
/* prior to OS X.10 and iOS 8.0, all vImageConvert_AnyToAny buffers have this type.*/
|
|
1130
|
+
|
|
1131
|
+
kvImageBufferTypeCode_Chunky VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ), /* always a singleton -- appearing as { kvImageBufferTypeCode_Chunky, 0} */
|
|
1132
|
+
/* buffer format is not encodable as vImage_CGImageFormat. Not YpCbCr. */
|
|
1133
|
+
|
|
1134
|
+
/* must appear after last unique code */
|
|
135
1135
|
kvImageBufferTypeCode_UniqueFormatCount VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ),
|
|
136
|
-
|
|
1136
|
+
|
|
1137
|
+
/* Convenience codes for better code readability */
|
|
137
1138
|
kvImageBufferTypeCode_Monochrome VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel1,
|
|
138
|
-
|
|
1139
|
+
|
|
1140
|
+
|
|
139
1141
|
kvImageBufferTypeCode_RGB_Red VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel1,
|
|
140
1142
|
kvImageBufferTypeCode_RGB_Green VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel2,
|
|
141
1143
|
kvImageBufferTypeCode_RGB_Blue VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel3,
|
|
142
|
-
|
|
1144
|
+
|
|
143
1145
|
kvImageBufferTypeCode_CMYK_Cyan VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel1,
|
|
144
1146
|
kvImageBufferTypeCode_CMYK_Magenta VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel2,
|
|
145
1147
|
kvImageBufferTypeCode_CMYK_Yellow VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel3,
|
|
146
1148
|
kvImageBufferTypeCode_CMYK_Black VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel4,
|
|
147
|
-
|
|
1149
|
+
|
|
148
1150
|
kvImageBufferTypeCode_XYZ_X VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel1,
|
|
149
1151
|
kvImageBufferTypeCode_XYZ_Y VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel2,
|
|
150
1152
|
kvImageBufferTypeCode_XYZ_Z VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel3,
|
|
151
|
-
|
|
1153
|
+
|
|
152
1154
|
kvImageBufferTypeCode_LAB_L VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel1,
|
|
153
1155
|
kvImageBufferTypeCode_LAB_A VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel2,
|
|
154
1156
|
kvImageBufferTypeCode_LAB_B VIMAGE_ENUM_AVAILABLE_STARTING( __MAC_10_9, __IPHONE_7_0 ) = kvImageBufferTypeCode_ColorSpaceChannel3,
|
|
155
1157
|
};
|
|
156
1158
|
|
|
1159
|
+
/*!
|
|
1160
|
+
* @function vImageConverter_GetSourceBufferOrder
|
|
1161
|
+
*
|
|
1162
|
+
* @abstract Get a list of vImage_Buffer channel names specifying the order of planes
|
|
1163
|
+
*
|
|
1164
|
+
* @discussion These functions describe the identity of each buffer passed in the srcs parameters of vImageConvert_AnyToAny,
|
|
1165
|
+
* to allow you to order the buffers correctly. It is provided for informational purposes, to help wire up image
|
|
1166
|
+
* processing pipelines to vImage that are not supported through more direct means, CGImages, CVPixelBuffers, the alternative
|
|
1167
|
+
* handling of which is described at the end of this comment.
|
|
1168
|
+
*
|
|
1169
|
+
* Prior to OS X.10 and iOS 8.0, only CG Image formats are handled by vImageConvert_AnyToAny. Had these functions existed
|
|
1170
|
+
* then, the result would always be {kvImageBufferTypeCode_CGFormat, kvImageBufferTypeCode_EndOfList}
|
|
1171
|
+
*
|
|
1172
|
+
* <pre>@textblock
|
|
1173
|
+
* Simplified Common Cases
|
|
1174
|
+
* -----------------------
|
|
1175
|
+
* CGImageRefs:
|
|
1176
|
+
* CoreGraphics formats always come as a single buffer, with one or more channels. No buffer ordering is
|
|
1177
|
+
* requred. The buffer order is always kvImageBufferTypeCode_CGFormat. Prior to OS X.10 and iOS 8.0, only
|
|
1178
|
+
* converters to CG image formats are available, so where these functions are not available, the answer would
|
|
1179
|
+
* have always been { kvImageBufferTypeCode_CGFormat, 0}. As a point of trivia, the ordering of the channels
|
|
1180
|
+
* within a buffer is by convention as follows:
|
|
1181
|
+
*
|
|
1182
|
+
* number of channels = number of channels in colorspace + (alpha != kCGImageAlphaNone)
|
|
1183
|
+
* alpha is either first or last, given by the alpha component of the CGBitmapInfo
|
|
1184
|
+
* The ordering of the non-alpha channels is given by the colorspace, e.g. {R,G,B} for a RGB image.
|
|
1185
|
+
* For 8-bit images, the ordering of the channels may be reversed according to
|
|
1186
|
+
* kCGBitmapByteOrderLittleEndian32 or kCGBitmapByteOrderLittleEndian16, but
|
|
1187
|
+
* the pixel size must match the endian swap chunk size. This gives you access to formats
|
|
1188
|
+
* like BGRA8888. If the endian is default or big endian, then no swap occurs.
|
|
1189
|
+
*
|
|
1190
|
+
* CVPixelBufferRefs:
|
|
1191
|
+
* Though these APIs will work for this purpose, it is expected to be simpler to use vImageBuffer_InitForCopyToCVPixelBuffer
|
|
1192
|
+
* or vImageBuffer_InitForCopyFromCVPixelBuffer to set up a vImage_Buffer array for srcs and dests. Pass kvImageDoNotAllocate
|
|
1193
|
+
* to have it automatically alias a locked CVPixelBuffer. The conversion will then copy the data right into or out of the
|
|
1194
|
+
* CVPixelBuffer without further copying or modification. (It may still need to be copied out to the GPU, for example, however.)
|
|
1195
|
+
*
|
|
1196
|
+
* @/textblock</pre>
|
|
1197
|
+
*
|
|
1198
|
+
* @param converter The conversion for which you wish to know the ordering of source or result buffers.
|
|
1199
|
+
* converter must be a valid vImageConverterRef.
|
|
1200
|
+
*
|
|
1201
|
+
*
|
|
1202
|
+
* @return The function returns a kvImageBufferTypeCode_EndOfList terminated array of buffer type codes. The type codes
|
|
1203
|
+
* indicate the order that the vImage_Buffers are passed in to vImageConvert_AnyToAny. The array is valid for the
|
|
1204
|
+
* lifetime of the vImageConverterRef. It belongs to the vImageConverterRef and should not be freed by you.
|
|
1205
|
+
*/
|
|
157
1206
|
VIMAGE_PF const vImageBufferTypeCode * vImageConverter_GetSourceBufferOrder( vImageConverterRef converter ) VIMAGE_NON_NULL(1) API_AVAILABLE(macos(10.10), ios(8.0), watchos(1.0), tvos(8.0));
|
|
158
1207
|
|
|
1208
|
+
/*!
|
|
1209
|
+
* @function vImageConverter_GetDestinationBufferOrder
|
|
1210
|
+
*
|
|
1211
|
+
* @abstract Get a list of vImage_Buffer channel names specifying the order of planes
|
|
1212
|
+
*
|
|
1213
|
+
* @discussion These functions describe the identity of each buffer passed in the dests parameters of vImageConvert_AnyToAny,
|
|
1214
|
+
* to allow you to order the buffers correctly. It is provided for informational purposes, to help wire up image
|
|
1215
|
+
* processing pipelines to vImage that are not supported through more direct means, CGImages, CVPixelBuffers, the alternative
|
|
1216
|
+
* handling of which is described at the end of this comment.
|
|
1217
|
+
*
|
|
1218
|
+
* Prior to OS X.10 and iOS 8.0, only CG Image formats are handled by vImageConvert_AnyToAny. Had these functions existed
|
|
1219
|
+
* then, the result would always be {kvImageBufferTypeCode_CGFormat, kvImageBufferTypeCode_EndOfList}
|
|
1220
|
+
*
|
|
1221
|
+
* <pre>@textblock
|
|
1222
|
+
* Simplified Common Cases
|
|
1223
|
+
* -----------------------
|
|
1224
|
+
* CGImageRefs:
|
|
1225
|
+
* CoreGraphics formats always come as a single buffer, with one or more channels. No buffer ordering is
|
|
1226
|
+
* requred. The buffer order is always kvImageBufferTypeCode_CGFormat. Prior to OS X.10 and iOS 8.0, only
|
|
1227
|
+
* converters to CG image formats are available, so where these functions are not available, the answer would
|
|
1228
|
+
* have always been { kvImageBufferTypeCode_CGFormat, 0}. As a point of trivia, the ordering of the channels
|
|
1229
|
+
* within a buffer is by convention as follows:
|
|
1230
|
+
*
|
|
1231
|
+
* number of channels = number of channels in colorspace + (alpha != kCGImageAlphaNone)
|
|
1232
|
+
* alpha is either first or last, given by the alpha component of the CGBitmapInfo
|
|
1233
|
+
* The ordering of the non-alpha channels is given by the colorspace, e.g. {R,G,B} for a RGB image.
|
|
1234
|
+
* For 8-bit images, the ordering of the channels may be reversed according to
|
|
1235
|
+
* kCGBitmapByteOrderLittleEndian32 or kCGBitmapByteOrderLittleEndian16, but
|
|
1236
|
+
* the pixel size must match the endian swap chunk size. This gives you access to formats
|
|
1237
|
+
* like BGRA8888. If the endian is default or big endian, then no swap occurs.
|
|
1238
|
+
*
|
|
1239
|
+
* CVPixelBufferRefs:
|
|
1240
|
+
* Though these APIs will work for this purpose, it is expected to be simpler to use vImageBuffer_InitForCopyToCVPixelBuffer
|
|
1241
|
+
* or vImageBuffer_InitForCopyFromCVPixelBuffer to set up a vImage_Buffer array for srcs and dests. Pass kvImageDoNotAllocate
|
|
1242
|
+
* to have it automatically alias a locked CVPixelBuffer. The conversion will then copy the data right into or out of the
|
|
1243
|
+
* CVPixelBuffer without further copying or modification. (It may still need to be copied out to the GPU, for example, however.)
|
|
1244
|
+
*
|
|
1245
|
+
* @/textblock</pre>
|
|
1246
|
+
*
|
|
1247
|
+
* @param converter The conversion for which you wish to know the ordering of source or result buffers.
|
|
1248
|
+
* converter must be a valid vImageConverterRef.
|
|
1249
|
+
*
|
|
1250
|
+
*
|
|
1251
|
+
* @return The function returns a kvImageBufferTypeCode_EndOfList terminated array of buffer type codes. The type codes
|
|
1252
|
+
* indicate the order that the vImage_Buffers are passed in to vImageConvert_AnyToAny. The array is valid for the
|
|
1253
|
+
* lifetime of the vImageConverterRef. It belongs to the vImageConverterRef and should not be freed by you.
|
|
1254
|
+
*/
|
|
159
1255
|
VIMAGE_PF const vImageBufferTypeCode * vImageConverter_GetDestinationBufferOrder( vImageConverterRef converter ) VIMAGE_NON_NULL(1) API_AVAILABLE(macos(10.10), ios(8.0), watchos(1.0), tvos(8.0));
|
|
160
1256
|
|
|
1257
|
+
|
|
1258
|
+
/*!
|
|
1259
|
+
* @function vImageConvert_AnyToAny
|
|
1260
|
+
*
|
|
1261
|
+
* @abstract Use a vImageConverterRef to convert the pixels in a vImage_Buffer to another format
|
|
1262
|
+
*
|
|
1263
|
+
* @discussion With an appropriately configured vImageConverter, convert the image channels found in srcs
|
|
1264
|
+
* to the image channels found in dests. Whenever possible, conversion passes are vectorized and multithreaded
|
|
1265
|
+
* to reduce the time and energy cost of the function.
|
|
1266
|
+
*
|
|
1267
|
+
* Please use vImageConverter_MustOperateOutOfPlace() to determine whether a particular conversion can operate in place.
|
|
1268
|
+
* For an in-place conversion to work, it is required that srcs[i].data = dests[i].data and srcs[i].rowBytes = dests[i].rowBytes.
|
|
1269
|
+
*
|
|
1270
|
+
* All scanlines must start at an at least byte aligned address. (Some formats have 1, 2, 4 or 12 bits per channel/pixel and
|
|
1271
|
+
* conceivably might not start at a byte aligned address.) A single byte may not span multiple rows of data.
|
|
1272
|
+
*
|
|
1273
|
+
* Some formats, particarly YUV 422 and 420 and those that have pixel size not evenly divisble by 8 bits, operate in chunks
|
|
1274
|
+
* containing multiple pixels. For example, a Y'CbCr 422 chunk may have {Y0, Cb, Y1, Cr} in the chunk. The chunk contains two
|
|
1275
|
+
* pixels, each with an independent Y (luminance) component, but shared chrominance. Even though the chunk width is two,
|
|
1276
|
+
* it is still possible for an image to have a width that is not divisible by two. This means that some part of the chunk on
|
|
1277
|
+
* the rightmost edge of the scanline must refer to a non-existant pixel. When reading incomplete chunks, vImage will only
|
|
1278
|
+
* touch the unused parts of the chunk when it knows it to be safe to do so. When writing incomplete chunks, vImage will
|
|
1279
|
+
* copy the rightmost valid pixel color into the unused part of the chunk. Thus, on reading the entire chunk doesn't have to
|
|
1280
|
+
* be there, but on writing, it does. Conventions on this are varied among chunk using imaging pipelines and this conservative
|
|
1281
|
+
* approach should interoperate with most. However, some care must be exercised when writing to chunk based formats (not to be
|
|
1282
|
+
* confused with chunky formats which merely have several channels interleaved) to make sure that the buffer is large enough
|
|
1283
|
+
* to tolerate the write policy. If you are tiling chunk based data, care must be taken not to run tile boundaries
|
|
1284
|
+
* through the middle of a chunk. Chunks are assumed to be indivisible.
|
|
1285
|
+
*
|
|
1286
|
+
* @param converter A valid vImageConverterRef indicating what conversion to do. The same vImageConverterRef
|
|
1287
|
+
* may be used concurrently from multiple threads. vImageConverterRefs may be created with
|
|
1288
|
+
* vImageConverter_CreateWithCGImageFormat, vImageConverter_CreateWithColorSyncCodeFragment,
|
|
1289
|
+
* vImageConverter_CreateForCGToCVImageFormat or vImageConverter_CreateForCVToCGImageFormat.
|
|
1290
|
+
* May not be NULL.
|
|
1291
|
+
*
|
|
1292
|
+
* @param srcs a pointer to an array of vImage_Buffer structs that describe the color planes that make
|
|
1293
|
+
* up the input image. Please see the description of the function that created the
|
|
1294
|
+
* vImageConverter for the ordering and number of input buffers. The ordering can also be
|
|
1295
|
+
* determined manually using vImageConverter_GetSourceBufferOrder.
|
|
1296
|
+
*
|
|
1297
|
+
* @param dests a pointer to an array of vImage_Buffer structs that describe the color planes that make
|
|
1298
|
+
* up the result image. Please see the description of the function that created the
|
|
1299
|
+
* vImageConverter for the ordering and number of output buffers. The ordering can also be
|
|
1300
|
+
* determined manually using vImageConverter_GetSourceBufferOrder. The destination buffer may
|
|
1301
|
+
* only alias the srcs buffers only if vImageConverter_MustOperateOutOfPlace() returns 0, and
|
|
1302
|
+
* only if the respective scanlines of the aliasing buffers start at the same address.
|
|
1303
|
+
*
|
|
1304
|
+
* @param tempBuffer May be NULL. If not NULL, the memory pointed to by tempBuffer will be used as scratch space
|
|
1305
|
+
* by the function. The size of the tempBuffer can be determined by passing kvImageGetTempBufferSize
|
|
1306
|
+
* to the in the flags parameter. See below. If NULL is passed here and a tempBuffer is needed '
|
|
1307
|
+
* (temp buffer size > 0) then the function will allocate one on the heap and free it before
|
|
1308
|
+
* returning. This may run more slowly, both because of the allocation cost and the cost of VM
|
|
1309
|
+
* faults to zero fill pages as they are used. NULL is the right option when the function is
|
|
1310
|
+
* used infrequently or convenience is valued.
|
|
1311
|
+
*
|
|
1312
|
+
* @param flags The following flags are allowed. Other flags will trigger an error.
|
|
1313
|
+
*
|
|
1314
|
+
* <pre>@textblock
|
|
1315
|
+
* kvImagePrintDiagnosticsToConsole In the event of a problem, print out some helpful debug messages.
|
|
1316
|
+
*
|
|
1317
|
+
* kvImageGetTempBufferSize No image conversion work is done. The value returned out the
|
|
1318
|
+
* left hand side of the function is the an error code if it is
|
|
1319
|
+
* less than zero. Otherwise, it is the size of the tempBuffer
|
|
1320
|
+
* to be passed into the function. The size may be 0.
|
|
1321
|
+
*
|
|
1322
|
+
* kvImageDoNotTile Disables internal multithreading. You may wish to pass this
|
|
1323
|
+
* flag if you are doing your own threading and think it will
|
|
1324
|
+
* conflict with vImage's attempts to do the same.
|
|
1325
|
+
*
|
|
1326
|
+
* kvImageNoFlags Default behavior.
|
|
1327
|
+
* @/textblock </pre>
|
|
1328
|
+
*
|
|
1329
|
+
* @return The following error codes may be returned:
|
|
1330
|
+
* <pre>@textblock
|
|
1331
|
+
* kvImageNoError Success!
|
|
1332
|
+
*
|
|
1333
|
+
* 0 kvImageGetTempBufferSize was passed in flags, and no temp buffer is needed.
|
|
1334
|
+
*
|
|
1335
|
+
* >0 kvImageGetTempBufferSize was passed in flags. The value indicates the size
|
|
1336
|
+
* of the temp buffer needed.
|
|
1337
|
+
*
|
|
1338
|
+
* kvImageMemoryAllocationError NULL was passed in tempBuffer and vImage failed to allocate its own
|
|
1339
|
+
* temp buffer
|
|
1340
|
+
* kvImageBufferSizeMismatch The source buffer(s) must be at least as large as the destination buffer(s)
|
|
1341
|
+
* (src.height >= dest.height && src.width >= dest.width)
|
|
1342
|
+
* kvImageUnknownFlagsBit A flag was passed to the vImageConverter creation function which is
|
|
1343
|
+
* unrecognized or not appropriate to this function
|
|
1344
|
+
* kvImageNullPointerArgument converter is NULL
|
|
1345
|
+
* kvImageInvalidParameter One of the buffers pointed to by srcs or dests has a NULL vImage_Buffer.data pointer
|
|
1346
|
+
* kvImageUnknownFlagsBit An unknown or unsupported flags bit was set.
|
|
1347
|
+
* kvImageInvalidImageFormat if a byte ordering is specified (e.g. kCGBitmapByteOrder16Little), the buffer.rowBytes
|
|
1348
|
+
* must be multiple of 2 (kCGBitmapByteOrder16Little, kCGBitmapByteOrder16Big) or
|
|
1349
|
+
* 4 (kCGBitmapByteOrder32Little, kCGBitmapByteOrder32Big)
|
|
1350
|
+
* @/textblock </pre>
|
|
1351
|
+
*
|
|
1352
|
+
*/
|
|
161
1353
|
VIMAGE_PF vImage_Error vImageConvert_AnyToAny( const vImageConverterRef converter,
|
|
162
|
-
const vImage_Buffer * srcs,
|
|
163
|
-
const vImage_Buffer * dests,
|
|
164
|
-
void *tempBuffer,
|
|
1354
|
+
const vImage_Buffer * srcs, /* an array of vImage_Buffer structs describing source data planes */
|
|
1355
|
+
const vImage_Buffer * dests, /* an array of vImage_Buffer structs describing destination data planes */
|
|
1356
|
+
void *tempBuffer, /* may be NULL */
|
|
165
1357
|
vImage_Flags flags
|
|
166
1358
|
)
|
|
167
1359
|
VIMAGE_NON_NULL(1,2,3)
|
|
168
1360
|
API_AVAILABLE(macos(10.9), ios(7.0), watchos(1.0), tvos(7.0));
|
|
169
1361
|
|
|
1362
|
+
/*
|
|
1363
|
+
* General vImage alignment requirements:
|
|
1364
|
+
* ======================================
|
|
1365
|
+
* All scanlines must be at least byte aligned
|
|
1366
|
+
* A single byte of image data may not span multiple rows of the image. For example, if the image is 1 bit per pixel monochrome, then
|
|
1367
|
+
* 8 pixels fit in a byte. If the width of such an image is not divisible by 8, then the potential exists that the first part of a byte might
|
|
1368
|
+
* lie in one image row and the rest of the byte in the next. It would even be possible that one byte could span up to 8 scanlines if the
|
|
1369
|
+
* image width is 1 pixel! These cases are not allowed. Implicit in the design of using a rowBytes instead of a rowBits describe the image
|
|
1370
|
+
* is that each row must be exactly an integral number of bytes. When the width of the image is such that it would not naturally be so, the
|
|
1371
|
+
* caller must pad out the remaining bits on the image row so that the next row starts on a byte boundary. This is done by setting the rowBytes
|
|
1372
|
+
* to be at least (width * bitsPerPixel + 7) / 8 bytes. When planar images are used then this becomes rowBytes = (width * bitsPerComponent + 7) / 8.
|
|
1373
|
+
*
|
|
1374
|
+
* In many cases, images that do not pad rows out to an integral number of bytes can still be processed by vImage by setting
|
|
1375
|
+
* width = height * width and height = 1. However, operating on images with a single row may defeat internal multithreading, so performance
|
|
1376
|
+
* may suffer. (Please use kvImageDoNotTile to defeat internal multithreading if that is your goal. That is its purpose.) Cleverer schemes that
|
|
1377
|
+
* redivide the image into a larger number of byte aligned rows may be devised.
|
|
1378
|
+
*
|
|
1379
|
+
* Some image formats must have 2- or 4-byte aligned scanlines and may need to be host endian
|
|
1380
|
+
* Images with components that are 16-bits in size (e.g. 16U and half float images) or pixels which are 16-bits in size and which do not
|
|
1381
|
+
* have channel boundaries at byte boundaries (e.g. RGB565 and ARGB1555, but not GrayscaleAlpha88) must have vImage_Buffer.data 2-byte aligned and
|
|
1382
|
+
* vImage_Buffer.rowBytes a multiple of 2. Likewise, 32-bits per component (e.g. float or a putative ARGB-2-10-10-10 format) must be 4 byte aligned
|
|
1383
|
+
* and rowBytes a multiple of 4. Failure to conform to 2- and 4-byte alignment restrictions may result in undefined behavior -- at minimum poor
|
|
1384
|
+
* performance and on some systems it can cause a program fault.
|
|
1385
|
+
*
|
|
1386
|
+
* Except where otherwise explicitly allowed by the vImageConverter_Create function (e.g. vImage_CGImageFormat.bitmapInfo might be kCGBitmapByteOrder16Big
|
|
1387
|
+
* even on little endian systems) these cases must also conform to the native endianness of the host system. For example, floating-point data on an Intel
|
|
1388
|
+
* system is normally expected to be little-endian unless the converter provides a means to say that it is not. Please see the vImageConverter_Create
|
|
1389
|
+
* function that you plan to use for additional restrictions that may apply.
|
|
1390
|
+
*
|
|
1391
|
+
* Performance tips:
|
|
1392
|
+
* =================
|
|
1393
|
+
*
|
|
1394
|
+
* Alignment
|
|
1395
|
+
* ---------
|
|
1396
|
+
* Performance will typically improve with even greater alignment up to cacheline aligned image rows. vImageBuffer_Init() can be used to get vImage's
|
|
1397
|
+
* estimation of what sort of row padding is generally likely to work best on the current machine for a given image and pixel size.
|
|
1398
|
+
*
|
|
1399
|
+
* Memory reuse
|
|
1400
|
+
* ------------
|
|
1401
|
+
* It can also be quite helpful to reuse vImage_Buffers and operate in-place so as to avoid spending time in zero-fill faults zeroing the contents
|
|
1402
|
+
* of newly allocated buffers. (These will show up in Instruments traces as time spent in kernel VM activity.) However, caching unused buffers for
|
|
1403
|
+
* extended periods of time can contribute to degradation of overall system performance in low memory situations so recycling of buffers is usually
|
|
1404
|
+
* best done when good temporal locality is expected. LibCache may be helpful for avoiding such problems when it is not known with certainty that the
|
|
1405
|
+
* buffer will be reused immediately.
|
|
1406
|
+
*
|
|
1407
|
+
* Tiling and multithreading
|
|
1408
|
+
* -------------------------
|
|
1409
|
+
* Most vImage functions, including vImageConvert_AnyToAny, will automatically split up work across multiple processors (when available) if there is
|
|
1410
|
+
* enough image data to warrant it. It can take some time to wake up other processors or redirect their attention from their current task to a new one,
|
|
1411
|
+
* so multithreading is not attempted if it seems likely the current processor can complete the work before the attention of the other cores can be
|
|
1412
|
+
* redirected to work on the problem. With some exceptions, the work is typically divided at boundaries between image rows. (To be clear, tiles can be
|
|
1413
|
+
* taller than just one row.) So, for some functions, if you break up the work to one scanline at a time, it will never multithread. Exactly which functions
|
|
1414
|
+
* do that is subject to change. If you want to stop multithreading, please use kvImageDoNotTile.
|
|
1415
|
+
*
|
|
1416
|
+
* The size of the tile chosen by the function varies by function. Some do little computation and so need the lowest possible load/store latencies to
|
|
1417
|
+
* run at top speed. Others do more work per byte are consequently not so dependent on low memory access latencies, so may work equally well with tiles
|
|
1418
|
+
* closer to the size of the L2 or L3 caches and so may use larger tiles. Some computationally intense functions may not care if the data is in cache
|
|
1419
|
+
* at all. Each vImage function will tile its workload as it sees fit without regard to what other vImage functions may have done or plan to do.
|
|
1420
|
+
*
|
|
1421
|
+
* While this scheme generally works well, you can often do much better with a little work especially in cases where multiple vImage functions are called
|
|
1422
|
+
* back to back for a few reasons:
|
|
1423
|
+
*
|
|
1424
|
+
* First of all, if the image is larger than the caches, then as new pixels are produced, they will cause earlier result pixels from the same image
|
|
1425
|
+
* to be flushed to more remote levels of the cache or ultimately out to DRAM (or even disk in low memory situations!) to make room for the new results. When
|
|
1426
|
+
* it is time to call the next vImage function on the result, you may find that even though you just worked on it, part of the image is not in the cache and
|
|
1427
|
+
* so you have to pay some time to load it back in again when it as needed. This can happen over and over again with each new vImage filter. A similar
|
|
1428
|
+
* story may occur for smaller images as data is flushed from level 1 to level 2 to level 3 of the cache to make room for new data. It would be faster if
|
|
1429
|
+
* you could somehow move on to the next vImage filter while a region of the image is still in the cache before it is evicted to make room for the rest
|
|
1430
|
+
* of the image. We will get to the how a little later.
|
|
1431
|
+
*
|
|
1432
|
+
* Second, since processor cores are usually assigned by vImage to work on parts of the image on a first-come first-served basis to keep per-call latency
|
|
1433
|
+
* down, it is probably common that different cores will work on different parts of the image in each successive vImage call, even in cases where the tiling
|
|
1434
|
+
* strategies between two back to back vImage calls are otherwise similar. That is, in the first vImage function call, the top left corner might be done by
|
|
1435
|
+
* processor 1 and in the next vImage function call by processor 3. The next time you call the same code, it might be processor 2 and processor 5 that do
|
|
1436
|
+
* the work on that region. Unfortunately, in many current processor architectures, the faster cache levels (level 1 and 2) are often not shared with most
|
|
1437
|
+
* of the other cores and it can take more time for the other cores to get data from them. It would be faster if you could somehow convince the same core to
|
|
1438
|
+
* operate on the same region of the image each time, because only then do we have some guarantee that the faster cache levels are doing us any good between
|
|
1439
|
+
* back to back calls.
|
|
1440
|
+
*
|
|
1441
|
+
* Third, just as it may take some time to get all the processors redirected to work on a particular task, you may also lose some time because
|
|
1442
|
+
* they don't all finish at the same time. Some processors end up waiting for others to finish before the vImage call can return. Here one expects this
|
|
1443
|
+
* time lost to be a tiny fraction of the overall time for large images, but for medium sized ones it may weigh against overall performance. (Smaller images
|
|
1444
|
+
* may not even bother to multithread in such cases.) When you advance to the next back-to-back vImage call, some of the cores might have gone to sleep or
|
|
1445
|
+
* moved on to unrelated work waiting for other cores to finish, and now you have to wait for them to get back on task again. You could reduce overall latency
|
|
1446
|
+
* if you could somehow convince the next filter to start on regions that are done without having to wait for all of the regions of the image to be done,
|
|
1447
|
+
* so that the cores stay busy and don't get distracted.
|
|
1448
|
+
*
|
|
1449
|
+
* Fourth, doing back-to-back-to-back vImage calls probably means having a bunch of intermediate vImage_Buffers hanging around that take up memory.
|
|
1450
|
+
* In cases where the intermediate computation has to be done in some higher precision, like floating-point, some of these can be quite big. It would be
|
|
1451
|
+
* very helpful to somehow make those go away, or at least go on a diet.
|
|
1452
|
+
*
|
|
1453
|
+
* So, how is this collection of problems fixed? Well, first of all, you don't /have/ to fix anything. Even with all of that, it should still work pretty
|
|
1454
|
+
* well. If pretty well is not good enough, then the solution is to manage the threading yourself. Lets say you want to apply 4 vImage filters (A, B, C and
|
|
1455
|
+
* D) to an image in a back-to-back fashion. First you break up the result image into a bunch of smaller chunks, called tiles. These should be small enough
|
|
1456
|
+
* to fit conformably in the cache but not so small that we devote too much time doing setup tasks like parameter checking or initializing variables repeatedly.
|
|
1457
|
+
* (You can figure out the right size later when it all works. Guess for now.) Starting from the result tiles, work backward. For each tile in the output of D,
|
|
1458
|
+
* figure out which pixels from C are needed as input. This defines the set of tiles produced by C. In cases where the function needs to look at nearby pixels
|
|
1459
|
+
* to calculate a result pixel (e.g. Convolution or various Morphology filters) then it is possible that the C-produced tiles may overlap a bit. The process is
|
|
1460
|
+
* then repeated moving backward through B and A until we arrive at the starting image. We can now trace each result tile through a bunch of discrete image
|
|
1461
|
+
* fragments back up to a region in the original image. Since we know that we have all the input pixels we need to calculate a result tile at each stage, we
|
|
1462
|
+
* can apply filters A,B,C and D in series to a tile without needing to worry about what is happening in the other tiles. Thus, each tile can be operated on
|
|
1463
|
+
* by a different thread, and multithreading becomes trivial.
|
|
1464
|
+
*
|
|
1465
|
+
* Consider the implications. Since each tile of data is operated on by a single thread and threads usually do not gratuitously hop around from core to core
|
|
1466
|
+
* (very much) the result from filter A on that tile should usually be in the right L1 or L2 cache when we call filter B to consume the result from A for that region,
|
|
1467
|
+
* provided that we call filter B on that tile from that thread right away and don't run off and do other things. The same goes for filters C and D. So, you
|
|
1468
|
+
* are now probably getting better-than-good-enough temporal cache locality. Observe also that it is generally not required that the intermediate (A,B or
|
|
1469
|
+
* C product) tiles be stored in memory that is contiguous with other tiles from the same intermediate image. They can be their own little chunks of memory
|
|
1470
|
+
* stored somewhere else. Maybe you even put them on the stack -- which probably will avoid most zero fill faults and is quick to allocate. In fact, if the
|
|
1471
|
+
* output tiles are of the same size, then as the thread finishes one tile, you can just reuse those small intermediate buffers that hold the intermediate
|
|
1472
|
+
* tiles for the next tile. The intermediate image then never exists as a whole at any given time and so you never have to allocate storage for most of it.
|
|
1473
|
+
* This gives you better-than-good-enough memory usage. Floating-point is starting to look a lot better! Next, because each tile is not waiting on its fellows,
|
|
1474
|
+
* you can begin working on filter B as soon as the thread is done with filter A. There is no more waiting for filter A to be done on the entire image before
|
|
1475
|
+
* B can be started. Threads go idle less. There is probably still bit of time lost to waiting for cores to spin up and some for the last thread to finish on
|
|
1476
|
+
* exit, but it is amortized over four filters instead of each filter.
|
|
1477
|
+
*
|
|
1478
|
+
* Recall that in standard opertaion, vImage will still be trying to multithread behind your back for all these little tiles. This will cause the threads to
|
|
1479
|
+
* oversubscribe the number of cores. Work that was supposed to be done by one thread is now split up to many. Threads may hop around from core to core much
|
|
1480
|
+
* more looking for a place to run, defeating cache locality. You may spend a lot of time waiting for cores to redirect to the next job with lots of little
|
|
1481
|
+
* jobs. The Instruments system trace looks like a tangled knot of threads playing musical chairs for a limited number of cores. To stop this, pass the
|
|
1482
|
+
* kvImageDoNotTile flag to make sure vImage is running only on the thread you assign to it.
|
|
1483
|
+
*/
|
|
1484
|
+
|
|
1485
|
+
|
|
170
1486
|
#ifdef __cplusplus
|
|
171
1487
|
}
|
|
172
1488
|
#endif
|
|
173
1489
|
|
|
174
|
-
#endif
|
|
1490
|
+
#endif /* vImage_Utilities_h */
|
|
1491
|
+
|