objc2_video_toolbox/generated/
VTFrameProcessor_OpticalFlow.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4#[cfg(feature = "objc2")]
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-foundation")]
7use objc2_foundation::*;
8
9use crate::*;
10
11/// Configuration value you set to prioritize quality or performance.
12///
13/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtopticalflowconfigurationqualityprioritization?language=objc)
14// NS_ENUM
15#[cfg(feature = "objc2")]
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct VTOpticalFlowConfigurationQualityPrioritization(pub NSInteger);
19#[cfg(feature = "objc2")]
20impl VTOpticalFlowConfigurationQualityPrioritization {
21    #[doc(alias = "VTOpticalFlowConfigurationQualityPrioritizationNormal")]
22    pub const Normal: Self = Self(1);
23    #[doc(alias = "VTOpticalFlowConfigurationQualityPrioritizationQuality")]
24    pub const Quality: Self = Self(2);
25}
26
27#[cfg(feature = "objc2")]
28unsafe impl Encode for VTOpticalFlowConfigurationQualityPrioritization {
29    const ENCODING: Encoding = NSInteger::ENCODING;
30}
31
32#[cfg(feature = "objc2")]
33unsafe impl RefEncode for VTOpticalFlowConfigurationQualityPrioritization {
34    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37/// Available algorithm revisions.
38///
39/// A new enum case with higher revision number is added when the processing algorithm is updated.
40/// The ``VTOpticalFlowConfiguration/defaultRevision`` property provides the default algorithm revision.
41///
42/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtopticalflowconfigurationrevision?language=objc)
43// NS_ENUM
44#[cfg(feature = "objc2")]
45#[repr(transparent)]
46#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
47pub struct VTOpticalFlowConfigurationRevision(pub NSInteger);
48#[cfg(feature = "objc2")]
49impl VTOpticalFlowConfigurationRevision {
50    #[doc(alias = "VTOpticalFlowConfigurationRevision1")]
51    pub const Revision1: Self = Self(1);
52}
53
54#[cfg(feature = "objc2")]
55unsafe impl Encode for VTOpticalFlowConfigurationRevision {
56    const ENCODING: Encoding = NSInteger::ENCODING;
57}
58
59#[cfg(feature = "objc2")]
60unsafe impl RefEncode for VTOpticalFlowConfigurationRevision {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64/// Indicates the order of input frames.
65///
66/// When submitting ``VTOpticalFlowParameters`` to the processor, you need to provide one of these values based on how
67/// the input frames are related to each other.
68///
69/// Use ``VTOpticalFlowParametersSubmissionModeSequential`` to indicate that the current submission follows presentation
70/// time order without jump or skip, when compared to previous submissions. This value provides better processor
71/// performance than other values.
72///
73/// Use ``VTOpticalFlowParametersSubmissionModeRandom`` to indicate that the current submission has no relation to the
74/// previous submission. Typically, this indicates a jump or a skip in the frame sequence. The processor clears internal
75/// caches when it receives this value in ``VTFrameProcessor/processWithParameters`` function call.
76///
77/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtopticalflowparameterssubmissionmode?language=objc)
78// NS_ENUM
79#[cfg(feature = "objc2")]
80#[repr(transparent)]
81#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
82pub struct VTOpticalFlowParametersSubmissionMode(pub NSInteger);
83#[cfg(feature = "objc2")]
84impl VTOpticalFlowParametersSubmissionMode {
85    #[doc(alias = "VTOpticalFlowParametersSubmissionModeRandom")]
86    pub const Random: Self = Self(1);
87    #[doc(alias = "VTOpticalFlowParametersSubmissionModeSequential")]
88    pub const Sequential: Self = Self(2);
89}
90
91#[cfg(feature = "objc2")]
92unsafe impl Encode for VTOpticalFlowParametersSubmissionMode {
93    const ENCODING: Encoding = NSInteger::ENCODING;
94}
95
96#[cfg(feature = "objc2")]
97unsafe impl RefEncode for VTOpticalFlowParametersSubmissionMode {
98    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
99}
100
101#[cfg(feature = "objc2")]
102extern_class!(
103    /// Configuration that you use to set up an optical flow processor
104    ///
105    /// This configuration enables the optical flow on a `VTFrameProcessor` session.
106    ///
107    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtopticalflowconfiguration?language=objc)
108    #[unsafe(super(NSObject))]
109    #[derive(Debug, PartialEq, Eq, Hash)]
110    #[cfg(feature = "objc2")]
111    pub struct VTOpticalFlowConfiguration;
112);
113
114#[cfg(feature = "objc2")]
115unsafe impl Send for VTOpticalFlowConfiguration {}
116
117#[cfg(feature = "objc2")]
118unsafe impl Sync for VTOpticalFlowConfiguration {}
119
120#[cfg(feature = "objc2")]
121extern_conformance!(
122    unsafe impl NSObjectProtocol for VTOpticalFlowConfiguration {}
123);
124
125#[cfg(all(feature = "VTFrameProcessorConfiguration", feature = "objc2"))]
126extern_conformance!(
127    unsafe impl VTFrameProcessorConfiguration for VTOpticalFlowConfiguration {}
128);
129
130#[cfg(feature = "objc2")]
131impl VTOpticalFlowConfiguration {
132    extern_methods!(
133        /// Creates a new optical flow configuration.
134        ///
135        /// Returns ``nil`` if dimensions are out of range or revision is unsupported.
136        ///
137        /// - Parameters:
138        /// - frameWidth: Width of source frame in pixels; the maximum value is 8192 for macOS, and 4096 for iOS.
139        /// - frameHeight: Height of source frame in pixels; the maximum value is 4320 for macOS, and 2160 for iOS.
140        /// - qualityPrioritization: A level you use to prioritize quality or performance; for more information about supported
141        /// levels, see ``VTOpticalFlowConfigurationQualityPrioritization``.
142        /// - revision: The specific algorithm or configuration revision you use to perform the request.
143        #[unsafe(method(initWithFrameWidth:frameHeight:qualityPrioritization:revision:))]
144        #[unsafe(method_family = init)]
145        pub unsafe fn initWithFrameWidth_frameHeight_qualityPrioritization_revision(
146            this: Allocated<Self>,
147            frame_width: NSInteger,
148            frame_height: NSInteger,
149            quality_prioritization: VTOpticalFlowConfigurationQualityPrioritization,
150            revision: VTOpticalFlowConfigurationRevision,
151        ) -> Option<Retained<Self>>;
152
153        #[unsafe(method(init))]
154        #[unsafe(method_family = init)]
155        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
156
157        #[unsafe(method(new))]
158        #[unsafe(method_family = new)]
159        pub unsafe fn new() -> Retained<Self>;
160
161        /// Width of source frame in pixels.
162        ///
163        /// This property is not atomic.
164        ///
165        /// # Safety
166        ///
167        /// This might not be thread-safe.
168        #[unsafe(method(frameWidth))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn frameWidth(&self) -> NSInteger;
171
172        /// Height of source frame in pixels.
173        ///
174        /// This property is not atomic.
175        ///
176        /// # Safety
177        ///
178        /// This might not be thread-safe.
179        #[unsafe(method(frameHeight))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn frameHeight(&self) -> NSInteger;
182
183        /// A parameter you use to control quality and performance levels.
184        ///
185        /// For more information about supported levels, see ``VTOpticalFlowConfigurationQualityPrioritization``.
186        ///
187        /// This property is not atomic.
188        ///
189        /// # Safety
190        ///
191        /// This might not be thread-safe.
192        #[unsafe(method(qualityPrioritization))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn qualityPrioritization(
195            &self,
196        ) -> VTOpticalFlowConfigurationQualityPrioritization;
197
198        /// The specific algorithm or configuration revision you use to perform the request.
199        ///
200        /// This property is not atomic.
201        ///
202        /// # Safety
203        ///
204        /// This might not be thread-safe.
205        #[unsafe(method(revision))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn revision(&self) -> VTOpticalFlowConfigurationRevision;
208
209        #[cfg(feature = "objc2-foundation")]
210        /// Provides the collection of currently supported algorithms or configuration revisions for the class of configuration.
211        ///
212        /// A property you use to introspect at runtime which revisions are available for each configuration.
213        #[unsafe(method(supportedRevisions))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn supportedRevisions() -> Retained<NSIndexSet>;
216
217        /// Provides the default revision of a specific algorithm or configuration.
218        #[unsafe(method(defaultRevision))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn defaultRevision() -> VTOpticalFlowConfigurationRevision;
221
222        #[cfg(feature = "objc2-foundation")]
223        /// Supported pixel formats for source frames for current configuration.
224        ///
225        /// This property is not atomic.
226        ///
227        /// # Safety
228        ///
229        /// This might not be thread-safe.
230        #[unsafe(method(frameSupportedPixelFormats))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn frameSupportedPixelFormats(&self) -> Retained<NSArray<NSNumber>>;
233
234        #[cfg(feature = "objc2-foundation")]
235        /// Pixel buffer attributes dictionary that describes requirements for pixel buffers which represent source frames and reference frames.
236        ///
237        /// Use ``CVPixelBufferCreateResolvedAttributesDictionary`` to combine this dictionary with your pixel buffer attributes dictionary.
238        ///
239        /// This property is not atomic.
240        ///
241        /// # Safety
242        ///
243        /// This might not be thread-safe.
244        #[unsafe(method(sourcePixelBufferAttributes))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn sourcePixelBufferAttributes(
247            &self,
248        ) -> Retained<NSDictionary<NSString, AnyObject>>;
249
250        #[cfg(feature = "objc2-foundation")]
251        /// Pixel buffer attributes dictionary that describes requirements for pixel buffers which represent destination frames.
252        ///
253        /// Use ``CVPixelBufferCreateResolvedAttributesDictionary`` to combine this dictionary with your pixel buffer attributes dictionary.
254        ///
255        /// This property is not atomic.
256        ///
257        /// # Safety
258        ///
259        /// This might not be thread-safe.
260        #[unsafe(method(destinationPixelBufferAttributes))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn destinationPixelBufferAttributes(
263            &self,
264        ) -> Retained<NSDictionary<NSString, AnyObject>>;
265
266        /// Reports whether the system supports this processor.
267        #[unsafe(method(isSupported))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn isSupported() -> bool;
270
271        #[deprecated]
272        #[unsafe(method(processorSupported))]
273        #[unsafe(method_family = none)]
274        pub unsafe fn processorSupported() -> Boolean;
275    );
276}
277
278#[cfg(feature = "objc2")]
279extern_class!(
280    /// An object that contains both input and output parameters the frame processor needs to generate optical flow between two frames.
281    ///
282    /// Use this object in the `processWithParameters` call of `VTFrameProcessor` class. The output parameter for this class is `destinationOpticalFlow` where the processor returns the output flow (as mutable `VTFrameProcessorOpticalFlow`) back to you once the `processWithParameters` completes.
283    ///
284    /// `VTOpticalFlowParameters` are frame-level parameters.
285    ///
286    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtopticalflowparameters?language=objc)
287    #[unsafe(super(NSObject))]
288    #[derive(Debug, PartialEq, Eq, Hash)]
289    #[cfg(feature = "objc2")]
290    pub struct VTOpticalFlowParameters;
291);
292
293#[cfg(feature = "objc2")]
294extern_conformance!(
295    unsafe impl NSObjectProtocol for VTOpticalFlowParameters {}
296);
297
298#[cfg(all(feature = "VTFrameProcessorParameters", feature = "objc2"))]
299extern_conformance!(
300    unsafe impl VTFrameProcessorParameters for VTOpticalFlowParameters {}
301);
302
303#[cfg(feature = "objc2")]
304impl VTOpticalFlowParameters {
305    extern_methods!(
306        #[cfg(feature = "VTFrameProcessorFrame")]
307        /// Creates a new optical flow parameters object.
308        ///
309        /// Returns `nil` if `sourceFrame` or `nextFrame` is `nil`, or if `sourceFrame` and `nextFrame` have different pixel formats.
310        ///
311        /// - Parameters:
312        /// - sourceFrame: Current source frame; must be non `nil`.
313        /// - nextFrame: Next source frame in presentation time order.
314        /// - submissionMode: Provides a hint to let the processor know whether you are submitting frames in presentation
315        /// sequence. For more information about supported modes see ``VTOpticalFlowParametersSubmissionMode``.
316        /// - destinationOpticalFlow: User allocated `VTFrameProcessorOpticalFlow` that receives the results.
317        #[unsafe(method(initWithSourceFrame:nextFrame:submissionMode:destinationOpticalFlow:))]
318        #[unsafe(method_family = init)]
319        pub unsafe fn initWithSourceFrame_nextFrame_submissionMode_destinationOpticalFlow(
320            this: Allocated<Self>,
321            source_frame: &VTFrameProcessorFrame,
322            next_frame: &VTFrameProcessorFrame,
323            submission_mode: VTOpticalFlowParametersSubmissionMode,
324            destination_optical_flow: &VTFrameProcessorOpticalFlow,
325        ) -> Option<Retained<Self>>;
326
327        #[unsafe(method(init))]
328        #[unsafe(method_family = init)]
329        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
330
331        #[unsafe(method(new))]
332        #[unsafe(method_family = new)]
333        pub unsafe fn new() -> Retained<Self>;
334
335        #[cfg(feature = "VTFrameProcessorFrame")]
336        /// Current source frame, which must be non `nil`.
337        #[unsafe(method(sourceFrame))]
338        #[unsafe(method_family = none)]
339        pub unsafe fn sourceFrame(&self) -> Retained<VTFrameProcessorFrame>;
340
341        #[cfg(feature = "VTFrameProcessorFrame")]
342        /// The next source frame in presentation time order.
343        #[unsafe(method(nextFrame))]
344        #[unsafe(method_family = none)]
345        pub unsafe fn nextFrame(&self) -> Retained<VTFrameProcessorFrame>;
346
347        /// Ordering of the input frames in this submission relative to the previous submission.
348        #[unsafe(method(submissionMode))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn submissionMode(&self) -> VTOpticalFlowParametersSubmissionMode;
351
352        #[cfg(feature = "VTFrameProcessorFrame")]
353        /// Output optical flow calculated by the processor.
354        #[unsafe(method(destinationOpticalFlow))]
355        #[unsafe(method_family = none)]
356        pub unsafe fn destinationOpticalFlow(&self) -> Retained<VTFrameProcessorOpticalFlow>;
357    );
358}