Skip to content

Commit

Permalink
Tune cv::PixelBuf api
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Dec 9, 2024
1 parent 0f489fb commit 40a29d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
9 changes: 1 addition & 8 deletions cidre/src/cv/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ define_cf_type!(
Buf(cf::Type)
);

impl Drop for Buf {
fn drop(&mut self) {
unsafe { CVBufferRelease(self) }
}
}

impl Buf {
#[inline]
pub fn attach<'a>(
Expand All @@ -33,7 +27,7 @@ impl Buf {
pub fn set_attach(&mut self, key: &cf::String, val: &cf::Type, attachment_mode: AttachMode) {
unsafe { CVBufferSetAttachment(self, key, val, attachment_mode) }
}

#[inline]
pub fn remove_attach(&mut self, key: &cf::String) {
unsafe { CVBufferRemoveAttachment(self, key) }
Expand Down Expand Up @@ -131,7 +125,6 @@ extern "C-unwind" {
value: &cf::Type,
attachment_mode: AttachMode,
);
pub fn CVBufferRelease(buffer: &mut Buf);
fn CVBufferRemoveAttachment(buffer: &mut Buf, key: &cf::String);
fn CVBufferRemoveAllAttachments(buffer: &mut Buf);
fn CVBufferSetAttachments(
Expand Down
10 changes: 6 additions & 4 deletions cidre/src/cv/pixel_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::io;
pub type PixelBuf = cv::ImageBuf;

pub type ReleaseCallback =
extern "C" fn(releaseRefCon: *mut c_void, baseAddress: *const *const c_void);
extern "C" fn(release_ref_con: *mut c_void, base_address: *const *const c_void);

impl PixelBuf {
#[inline]
Expand Down Expand Up @@ -87,7 +87,8 @@ impl PixelBuf {
unsafe { r.to_result_unchecked(pixel_buffer_out) }
}

pub fn new_with_bytes(
#[doc(alias = "CVPixelBufferCreateWithBytes")]
pub fn with_bytes(
width: usize,
height: usize,
base_address: *mut c_void,
Expand All @@ -99,7 +100,7 @@ impl PixelBuf {
) -> Result<arc::R<PixelBuf>, cv::Return> {
let mut pixel_buf_out = None;

let r = Self::create_with_bytes(
let r = Self::create_with_bytes_in(
width,
height,
pixel_format_type,
Expand Down Expand Up @@ -134,7 +135,8 @@ impl PixelBuf {
}
}

pub fn create_with_bytes(
#[doc(alias = "CVPixelBufferCreateWithBytes")]
pub fn create_with_bytes_in(
width: usize,
height: usize,
pixel_format_type: cv::PixelFormat,
Expand Down

0 comments on commit 40a29d9

Please sign in to comment.