/packages/univint/src/CVBuffer.pas
Pascal | 331 lines | 26 code | 38 blank | 267 comment | 0 complexity | 591704466f711550a065cb5db716a5b1 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
1{ 2 * CVBuffer.h 3 * CoreVideo 4 * 5 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. 6 * 7 } 8 9{ Pascal Translation: Gale R Paeper, <gpaeper@empirenet.com>, 2008 } 10{ Pascal Translation Update: Gorazd Krosl, <gorazd_1957@yahoo.ca>, 2009 } 11{ Pascal Translation Update: Jonas Maebe <jonas@freepascal.org>, October 2012 } 12 13{ 14 Modified for use with Free Pascal 15 Version 308 16 Please report any bugs to <gpc@microbizz.nl> 17} 18 19{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE} 20{$mode macpas} 21{$packenum 1} 22{$macro on} 23{$inline on} 24{$calling mwpascal} 25 26unit CVBuffer; 27interface 28{$setc UNIVERSAL_INTERFACES_VERSION := $0400} 29{$setc GAP_INTERFACES_VERSION := $0308} 30 31{$ifc not defined USE_CFSTR_CONSTANT_MACROS} 32 {$setc USE_CFSTR_CONSTANT_MACROS := TRUE} 33{$endc} 34 35{$ifc defined CPUPOWERPC and defined CPUI386} 36 {$error Conflicting initial definitions for CPUPOWERPC and CPUI386} 37{$endc} 38{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN} 39 {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN} 40{$endc} 41 42{$ifc not defined __ppc__ and defined CPUPOWERPC32} 43 {$setc __ppc__ := 1} 44{$elsec} 45 {$setc __ppc__ := 0} 46{$endc} 47{$ifc not defined __ppc64__ and defined CPUPOWERPC64} 48 {$setc __ppc64__ := 1} 49{$elsec} 50 {$setc __ppc64__ := 0} 51{$endc} 52{$ifc not defined __i386__ and defined CPUI386} 53 {$setc __i386__ := 1} 54{$elsec} 55 {$setc __i386__ := 0} 56{$endc} 57{$ifc not defined __x86_64__ and defined CPUX86_64} 58 {$setc __x86_64__ := 1} 59{$elsec} 60 {$setc __x86_64__ := 0} 61{$endc} 62{$ifc not defined __arm__ and defined CPUARM} 63 {$setc __arm__ := 1} 64{$elsec} 65 {$setc __arm__ := 0} 66{$endc} 67 68{$ifc defined cpu64} 69 {$setc __LP64__ := 1} 70{$elsec} 71 {$setc __LP64__ := 0} 72{$endc} 73 74 75{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__} 76 {$error Conflicting definitions for __ppc__ and __i386__} 77{$endc} 78 79{$ifc defined __ppc__ and __ppc__} 80 {$setc TARGET_CPU_PPC := TRUE} 81 {$setc TARGET_CPU_PPC64 := FALSE} 82 {$setc TARGET_CPU_X86 := FALSE} 83 {$setc TARGET_CPU_X86_64 := FALSE} 84 {$setc TARGET_CPU_ARM := FALSE} 85 {$setc TARGET_OS_MAC := TRUE} 86 {$setc TARGET_OS_IPHONE := FALSE} 87 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 88 {$setc TARGET_OS_EMBEDDED := FALSE} 89{$elifc defined __ppc64__ and __ppc64__} 90 {$setc TARGET_CPU_PPC := FALSE} 91 {$setc TARGET_CPU_PPC64 := TRUE} 92 {$setc TARGET_CPU_X86 := FALSE} 93 {$setc TARGET_CPU_X86_64 := FALSE} 94 {$setc TARGET_CPU_ARM := FALSE} 95 {$setc TARGET_OS_MAC := TRUE} 96 {$setc TARGET_OS_IPHONE := FALSE} 97 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 98 {$setc TARGET_OS_EMBEDDED := FALSE} 99{$elifc defined __i386__ and __i386__} 100 {$setc TARGET_CPU_PPC := FALSE} 101 {$setc TARGET_CPU_PPC64 := FALSE} 102 {$setc TARGET_CPU_X86 := TRUE} 103 {$setc TARGET_CPU_X86_64 := FALSE} 104 {$setc TARGET_CPU_ARM := FALSE} 105{$ifc defined(iphonesim)} 106 {$setc TARGET_OS_MAC := FALSE} 107 {$setc TARGET_OS_IPHONE := TRUE} 108 {$setc TARGET_IPHONE_SIMULATOR := TRUE} 109{$elsec} 110 {$setc TARGET_OS_MAC := TRUE} 111 {$setc TARGET_OS_IPHONE := FALSE} 112 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 113{$endc} 114 {$setc TARGET_OS_EMBEDDED := FALSE} 115{$elifc defined __x86_64__ and __x86_64__} 116 {$setc TARGET_CPU_PPC := FALSE} 117 {$setc TARGET_CPU_PPC64 := FALSE} 118 {$setc TARGET_CPU_X86 := FALSE} 119 {$setc TARGET_CPU_X86_64 := TRUE} 120 {$setc TARGET_CPU_ARM := FALSE} 121 {$setc TARGET_OS_MAC := TRUE} 122 {$setc TARGET_OS_IPHONE := FALSE} 123 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 124 {$setc TARGET_OS_EMBEDDED := FALSE} 125{$elifc defined __arm__ and __arm__} 126 {$setc TARGET_CPU_PPC := FALSE} 127 {$setc TARGET_CPU_PPC64 := FALSE} 128 {$setc TARGET_CPU_X86 := FALSE} 129 {$setc TARGET_CPU_X86_64 := FALSE} 130 {$setc TARGET_CPU_ARM := TRUE} 131 { will require compiler define when/if other Apple devices with ARM cpus ship } 132 {$setc TARGET_OS_MAC := FALSE} 133 {$setc TARGET_OS_IPHONE := TRUE} 134 {$setc TARGET_IPHONE_SIMULATOR := FALSE} 135 {$setc TARGET_OS_EMBEDDED := TRUE} 136{$elsec} 137 {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.} 138{$endc} 139 140{$ifc defined __LP64__ and __LP64__ } 141 {$setc TARGET_CPU_64 := TRUE} 142{$elsec} 143 {$setc TARGET_CPU_64 := FALSE} 144{$endc} 145 146{$ifc defined FPC_BIG_ENDIAN} 147 {$setc TARGET_RT_BIG_ENDIAN := TRUE} 148 {$setc TARGET_RT_LITTLE_ENDIAN := FALSE} 149{$elifc defined FPC_LITTLE_ENDIAN} 150 {$setc TARGET_RT_BIG_ENDIAN := FALSE} 151 {$setc TARGET_RT_LITTLE_ENDIAN := TRUE} 152{$elsec} 153 {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.} 154{$endc} 155{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE} 156{$setc CALL_NOT_IN_CARBON := FALSE} 157{$setc OLDROUTINENAMES := FALSE} 158{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE} 159{$setc OPAQUE_UPP_TYPES := TRUE} 160{$setc OTCARBONAPPLICATION := TRUE} 161{$setc OTKERNEL := FALSE} 162{$setc PM_USE_SESSION_APIS := TRUE} 163{$setc TARGET_API_MAC_CARBON := TRUE} 164{$setc TARGET_API_MAC_OS8 := FALSE} 165{$setc TARGET_API_MAC_OSX := TRUE} 166{$setc TARGET_CARBON := TRUE} 167{$setc TARGET_CPU_68K := FALSE} 168{$setc TARGET_CPU_MIPS := FALSE} 169{$setc TARGET_CPU_SPARC := FALSE} 170{$setc TARGET_OS_UNIX := FALSE} 171{$setc TARGET_OS_WIN32 := FALSE} 172{$setc TARGET_RT_MAC_68881 := FALSE} 173{$setc TARGET_RT_MAC_CFM := FALSE} 174{$setc TARGET_RT_MAC_MACHO := TRUE} 175{$setc TYPED_FUNCTION_POINTERS := TRUE} 176{$setc TYPE_BOOL := FALSE} 177{$setc TYPE_EXTENDED := FALSE} 178{$setc TYPE_LONGLONG := TRUE} 179uses MacTypes, CFBase, CFDictionary, CVBase, CVReturns; 180{$endc} {not MACOSALLINCLUDE} 181 182 183{$ALIGN POWER} 184 185 186 {! @header CVBuffer.h 187 @copyright 2004 Apple Computer, Inc. All rights reserved. 188 @availability Mac OS X 10.4 or later 189 @discussion CVBufferRef types are abstract and only define ways to attach meta data to buffers (such as timestamps, 190 colorspace information, etc.). CVBufferRefs do not imply any particular kind of data storage. It could 191 be compressed data, image data, etc. 192 193} 194 195 196//#pragma mark CVBufferRef attribute keys 197 198{ The following two keys are useful with the CoreVideo pool and texture cache APIs so that you can specify 199 an initial set of default buffer attachments to automatically be attached to the buffer when it is created. } 200var kCVBufferPropagatedAttachmentsKey: CFStringRef; external name '_kCVBufferPropagatedAttachmentsKey'; (* attribute const *) 201(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 202var kCVBufferNonPropagatedAttachmentsKey: CFStringRef; external name '_kCVBufferNonPropagatedAttachmentsKey'; (* attribute const *) 203(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 204 205//#pragma mark CVBufferRef attachment keys 206 207var kCVBufferMovieTimeKey: CFStringRef; external name '_kCVBufferMovieTimeKey'; (* attribute const *) 208(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) // Generally only available for frames emitted by QuickTime; CFDictionary containing these two keys: 209var kCVBufferTimeValueKey: CFStringRef; external name '_kCVBufferTimeValueKey'; (* attribute const *) 210(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 211var kCVBufferTimeScaleKey: CFStringRef; external name '_kCVBufferTimeScaleKey'; (* attribute const *) 212(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 213 214 215//#pragma mark CVBufferRef 216 217const 218 kCVAttachmentMode_ShouldNotPropagate = 0; 219 kCVAttachmentMode_ShouldPropagate = 1; 220type 221 CVAttachmentMode = UInt32; 222 223{! 224 @typedef CVBufferRef 225 @abstract Base type for all CoreVideo buffers 226 227} 228type 229 CVBufferRef = ^__CVBuffer; { an opaque type } 230 __CVBuffer = record end; 231 232{! 233 @function CVBufferRetain 234 @abstract Retains a CVBuffer object 235 @discussion Like CFRetain CVBufferRetain increments the retain count of a CVBuffer object. In contrast to the CF call it is NULL safe. 236 @param buffer A CVBuffer object that you want to retain. 237 @result A CVBuffer object that is the same as the passed in buffer. 238} 239function CVBufferRetain( buffer: CVBufferRef ): CVBufferRef; external name '_CVBufferRetain'; 240(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 241{! 242 @function CVBufferRelease 243 @abstract Release a CVBuffer object 244 @discussion Like CFRetain CVBufferRetain decrements the retain count of a CVBuffer object. If that count consequently becomes zero the memory allocated to the object is deallocated and the object is destroyed. In contrast to the CF call it is NULL safe. 245 @param buffer A CVBuffer object that you want to release. 246} 247procedure CVBufferRelease( buffer: CVBufferRef ); external name '_CVBufferRelease'; 248(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 249 250//#pragma mark CVBufferAttachment 251 252{! 253 @function CVBufferSetAttachment 254 @abstract Sets or adds a attachment of a CVBuffer object 255 @discussion You can attach any CF object to a CVBuffer object to store additional information. CVBufferGetAttachment stores an attachement identified by a key. If the key doesn't exist, the attachment will be added. If the key does exist, the existing attachment will be replaced. In bouth cases the retain count of the attachment will be incremented. The value can be any CFType but nil has no defined behavior. 256 @param buffer Target CVBuffer object. 257 @param key Key in form of a CFString identifying the desired attachment. 258 @param value Attachment in form af a CF object. 259 @param attachmentMode Specifies which attachment mode is desired for this attachment. A particular attachment key may only exist in 260 a single mode at a time. 261} 262procedure CVBufferSetAttachment( buffer: CVBufferRef; key: CFStringRef; value: CFTypeRef; attachmentMode: CVAttachmentMode ); external name '_CVBufferSetAttachment'; 263(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 264 265 266{! 267 @function CVBufferGetAttachment 268 @abstract Returns a specific attachment of a CVBuffer object 269 @discussion You can attach any CF object to a CVBuffer object to store additional information. CVBufferGetAttachment retrieves an attachement identified by a key. 270 @param buffer Target CVBuffer object. 271 @param key Key in form of a CFString identifying the desired attachment. 272 @param attachmentMode. Returns the mode of the attachment, if desired. May be NULL. 273 @result If found the attachment object 274} 275function CVBufferGetAttachment( buffer: CVBufferRef; key: CFStringRef; var attachmentMode: CVAttachmentMode ): CFTypeRef; external name '_CVBufferGetAttachment'; 276(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 277 278{! 279 @function CVBufferRemoveAttachment 280 @abstract Removes a specific attachment of a CVBuffer object 281 @discussion CVBufferRemoveAttachment removes an attachement identified by a key. If found the attachement is removed and the retain count decremented. 282 @param buffer Target CVBuffer object. 283 @param key Key in form of a CFString identifying the desired attachment. 284} 285procedure CVBufferRemoveAttachment( buffer: CVBufferRef; key: CFStringRef ); external name '_CVBufferRemoveAttachment'; 286(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 287 288{! 289 @function CVBufferRemoveAllAttachments 290 @abstract Removes all attachments of a CVBuffer object 291 @discussion While CVBufferRemoveAttachment removes a specific attachement identified by a key CVBufferRemoveAllAttachments removes all attachments of a buffer and decrements their retain counts. 292 @param buffer Target CVBuffer object. 293} 294procedure CVBufferRemoveAllAttachments( buffer: CVBufferRef ); external name '_CVBufferRemoveAllAttachments'; 295(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 296 297{! 298 @function CVBufferGetAttachments 299 @abstract Returns all attachments of a CVBuffer object 300 @discussion CVBufferGetAttachments is a convenience call that returns all attachments with their corresponding keys in a CFDictionary. 301 @param buffer Target CVBuffer object. 302 @result A CFDictionary with all buffer attachments identified by there keys. If no attachment is present, the dictionary is empty. Returns NULL 303 for invalid attachment mode. 304} 305function CVBufferGetAttachments( buffer: CVBufferRef; attachmentMode: CVAttachmentMode ): CFDictionaryRef; external name '_CVBufferGetAttachments'; 306(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 307 308{! 309 @function CVBufferSetAttachments 310 @abstract Sets a set of attachments for a CVBuffer 311 @discussion CVBufferSetAttachments is a convenience call that in turn calls CVBufferSetAttachment for each key and value in the given dictionary. All key value pairs must be in the root level of the dictionary. 312 @param buffer Target CVBuffer object. 313} 314procedure CVBufferSetAttachments( buffer: CVBufferRef; theAttachments: CFDictionaryRef; attachmentMode: CVAttachmentMode ); external name '_CVBufferSetAttachments'; 315(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 316 317{! 318 @function CVBufferPropagateAttachments 319 @abstract Copy all propagatable attachments from one buffer to another. 320 @discussion CVBufferPropagateAttachments is a convenience call that copies all attachments with a mode of kCVAttachmentMode_ShouldPropagate from one 321 buffer to another. 322 @param sourceBuffer CVBuffer to copy attachments from. 323 @param destinationBuffer CVBuffer to copy attachments to. 324} 325procedure CVBufferPropagateAttachments( sourceBuffer: CVBufferRef; destinationBuffer: CVBufferRef ); external name '_CVBufferPropagateAttachments'; 326(* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) 327 328{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE} 329 330end. 331{$endc} {not MACOSALLINCLUDE}