1- //! CVPixelBuffer - Video pixel buffer
1+ //! ` CVPixelBuffer` - Video pixel buffer
22
33use std:: fmt;
44use super :: ffi;
@@ -50,6 +50,10 @@ impl CVPixelBuffer {
5050 /// * `height` - Height of the pixel buffer in pixels
5151 /// * `pixel_format` - Pixel format type (e.g., 0x42475241 for BGRA)
5252 ///
53+ /// # Errors
54+ ///
55+ /// Returns a Core Video error code if the pixel buffer creation fails.
56+ ///
5357 /// # Examples
5458 ///
5559 /// ```
@@ -98,6 +102,10 @@ impl CVPixelBuffer {
98102 /// - Memory remains valid for the lifetime of the pixel buffer
99103 /// - `bytes_per_row` correctly represents the memory layout
100104 ///
105+ /// # Errors
106+ ///
107+ /// Returns a Core Video error code if the pixel buffer creation fails.
108+ ///
101109 /// # Examples
102110 ///
103111 /// ```
@@ -163,6 +171,10 @@ impl CVPixelBuffer {
163171 ///
164172 /// This is useful for pixel buffers that have been created with extended pixels
165173 /// enabled, to ensure proper edge handling for effects and filters.
174+ ///
175+ /// # Errors
176+ ///
177+ /// Returns a Core Video error code if the operation fails.
166178 pub fn fill_extended_pixels ( & self ) -> Result < ( ) , i32 > {
167179 unsafe {
168180 let status = ffi:: cv_pixel_buffer_fill_extended_pixels ( self . 0 ) ;
@@ -182,6 +194,10 @@ impl CVPixelBuffer {
182194 /// - `plane_base_addresses` points to valid memory for each plane
183195 /// - Memory remains valid for the lifetime of the pixel buffer
184196 /// - All plane parameters correctly represent the memory layout
197+ ///
198+ /// # Errors
199+ ///
200+ /// Returns a Core Video error code if the pixel buffer creation fails.
185201 pub unsafe fn create_with_planar_bytes (
186202 width : usize ,
187203 height : usize ,
@@ -218,7 +234,11 @@ impl CVPixelBuffer {
218234 }
219235 }
220236
221- /// Create a pixel buffer from an IOSurface
237+ /// Create a pixel buffer from an `IOSurface`
238+ ///
239+ /// # Errors
240+ ///
241+ /// Returns a Core Video error code if the pixel buffer creation fails.
222242 pub fn create_with_io_surface ( surface : & IOSurface ) -> Result < Self , i32 > {
223243 unsafe {
224244 let mut pixel_buffer_ptr: * mut std:: ffi:: c_void = std:: ptr:: null_mut ( ) ;
@@ -235,7 +255,7 @@ impl CVPixelBuffer {
235255 }
236256 }
237257
238- /// Get the Core Foundation type ID for CVPixelBuffer
258+ /// Get the Core Foundation type ID for ` CVPixelBuffer`
239259 pub fn get_type_id ( ) -> usize {
240260 unsafe { ffi:: cv_pixel_buffer_get_type_id ( ) }
241261 }
@@ -300,7 +320,7 @@ impl CVPixelBuffer {
300320 }
301321 }
302322
303- /// Check if the pixel buffer is backed by an IOSurface
323+ /// Check if the pixel buffer is backed by an ` IOSurface`
304324 pub fn is_backed_by_io_surface ( & self ) -> bool {
305325 self . get_io_surface ( ) . is_some ( )
306326 }
@@ -345,6 +365,11 @@ impl CVPixelBuffer {
345365 unsafe { ffi:: cv_pixel_buffer_get_bytes_per_row ( self . 0 ) }
346366 }
347367
368+ /// Lock the base address for raw access
369+ ///
370+ /// # Errors
371+ ///
372+ /// Returns a Core Video error code if the lock operation fails.
348373 pub fn lock_raw ( & self , flags : u32 ) -> Result < ( ) , i32 > {
349374 unsafe {
350375 let result = ffi:: cv_pixel_buffer_lock_base_address ( self . 0 , flags) ;
@@ -356,6 +381,11 @@ impl CVPixelBuffer {
356381 }
357382 }
358383
384+ /// Unlock the base address after raw access
385+ ///
386+ /// # Errors
387+ ///
388+ /// Returns a Core Video error code if the unlock operation fails.
359389 pub fn unlock_raw ( & self , flags : u32 ) -> Result < ( ) , i32 > {
360390 unsafe {
361391 let result = ffi:: cv_pixel_buffer_unlock_base_address ( self . 0 , flags) ;
@@ -385,14 +415,19 @@ impl CVPixelBuffer {
385415 }
386416 }
387417
418+ /// Lock the base address and return a guard for RAII-style access
419+ ///
420+ /// # Errors
421+ ///
422+ /// Returns a Core Video error code if the lock operation fails.
388423 pub fn lock_base_address ( & self , read_only : bool ) -> Result < CVPixelBufferLockGuard < ' _ > , i32 > {
389424 let flags = u32:: from ( read_only) ;
390425 self . lock_raw ( flags) ?;
391426 Ok ( CVPixelBufferLockGuard { buffer : self , read_only } )
392427 }
393428}
394429
395- /// RAII guard for locked CVPixelBuffer base address
430+ /// RAII guard for locked ` CVPixelBuffer` base address
396431pub struct CVPixelBufferLockGuard < ' a > {
397432 buffer : & ' a CVPixelBuffer ,
398433 read_only : bool ,
@@ -451,7 +486,7 @@ impl fmt::Display for CVPixelBuffer {
451486 }
452487}
453488
454- /// Opaque handle to CVPixelBufferPool
489+ /// Opaque handle to ` CVPixelBufferPool`
455490#[ repr( transparent) ]
456491#[ derive( Debug ) ]
457492pub struct CVPixelBufferPool ( * mut std:: ffi:: c_void ) ;
@@ -500,6 +535,10 @@ impl CVPixelBufferPool {
500535 /// * `height` - Height of pixel buffers in the pool
501536 /// * `pixel_format` - Pixel format type
502537 /// * `max_buffers` - Maximum number of buffers in the pool (0 for unlimited)
538+ ///
539+ /// # Errors
540+ ///
541+ /// Returns a Core Video error code if the pool creation fails.
503542 pub fn create (
504543 width : usize ,
505544 height : usize ,
@@ -525,6 +564,10 @@ impl CVPixelBufferPool {
525564 }
526565
527566 /// Create a pixel buffer from the pool
567+ ///
568+ /// # Errors
569+ ///
570+ /// Returns a Core Video error code if the buffer creation fails.
528571 pub fn create_pixel_buffer ( & self ) -> Result < CVPixelBuffer , i32 > {
529572 unsafe {
530573 let mut pixel_buffer_ptr: * mut std:: ffi:: c_void = std:: ptr:: null_mut ( ) ;
@@ -550,14 +593,18 @@ impl CVPixelBufferPool {
550593 }
551594 }
552595
553- /// Get the Core Foundation type ID for CVPixelBufferPool
596+ /// Get the Core Foundation type ID for ` CVPixelBufferPool`
554597 pub fn get_type_id ( ) -> usize {
555598 unsafe { ffi:: cv_pixel_buffer_pool_get_type_id ( ) }
556599 }
557600
558601 /// Create a pixel buffer from the pool with auxiliary attributes
559602 ///
560603 /// This allows specifying additional attributes for the created buffer
604+ ///
605+ /// # Errors
606+ ///
607+ /// Returns a Core Video error code if the buffer creation fails.
561608 pub fn create_pixel_buffer_with_aux_attributes (
562609 & self ,
563610 aux_attributes : Option < & std:: collections:: HashMap < String , u32 > > ,
@@ -593,7 +640,7 @@ impl CVPixelBufferPool {
593640
594641 /// Get the pool attributes
595642 ///
596- /// Returns the raw pointer to the CFDictionary containing pool attributes
643+ /// Returns the raw pointer to the ` CFDictionary` containing pool attributes
597644 pub fn get_attributes ( & self ) -> Option < * const std:: ffi:: c_void > {
598645 unsafe {
599646 let ptr = ffi:: cv_pixel_buffer_pool_get_attributes ( self . 0 ) ;
@@ -607,7 +654,7 @@ impl CVPixelBufferPool {
607654
608655 /// Get the pixel buffer attributes
609656 ///
610- /// Returns the raw pointer to the CFDictionary containing pixel buffer attributes
657+ /// Returns the raw pointer to the ` CFDictionary` containing pixel buffer attributes
611658 pub fn get_pixel_buffer_attributes ( & self ) -> Option < * const std:: ffi:: c_void > {
612659 unsafe {
613660 let ptr = ffi:: cv_pixel_buffer_pool_get_pixel_buffer_attributes ( self . 0 ) ;
0 commit comments