Skip to content

Commit

Permalink
Rav1dContext::drop: Unconditionally take f.frame_thread
Browse files Browse the repository at this point in the history
  • Loading branch information
randomPoison committed Feb 22, 2024
1 parent cf2e965 commit 2ca6447
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ pub struct CodedBlockInfo {
pub txtp: [u8; 3], /* plane */
}

#[derive(Default)]
#[repr(C)]
pub struct Rav1dFrameContext_frame_thread {
pub next_tile_row: [c_int; 2], /* 0: reconstruction, 1: entropy */
Expand All @@ -428,6 +427,23 @@ pub struct Rav1dFrameContext_frame_thread {
pub tile_start_off: Vec<u32>,
}

// TODO: Temporary `Default` impl to support using `mem::take` to manually drop
// this field. Remove once the context is fully owned and can be dropped
// normally.
impl Default for Rav1dFrameContext_frame_thread {
fn default() -> Self {
Self {
next_tile_row: Default::default(),
b: Default::default(),
cbi: Default::default(),
pal: Vec::new_in(AlignedAlloc::<64>),
pal_idx: Vec::new_in(AlignedAlloc::<64>),
cf: Vec::new_in(AlignedAlloc::<64>),
tile_start_off: Default::default(),
}
}
}

impl Rav1dFrameContext_frame_thread {
pub fn cf_sz(&self) -> usize {
self.cf.len() / (128 * 128 / 2)
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,11 +902,11 @@ impl Drop for Rav1dContext {
&mut f.tile_thread.lowest_pixel_mem as *mut *mut [[c_int; 2]; 7]
as *mut c_void,
);
let _ = mem::take(&mut f.frame_thread); // TODO: remove when context is owned
}
if self.tc.len() > 1 {
let _ = mem::take(&mut f.task_thread.pending_tasks); // TODO: remove when context is owned
}
let _ = mem::take(&mut f.frame_thread); // TODO: remove when context is owned
mem::take(&mut f.frame_thread_progress.frame); // TODO: remove when context is owned
mem::take(&mut f.frame_thread_progress.copy_lpf); // TODO: remove when context is owned
freep(&mut f.task_thread.tasks as *mut *mut Rav1dTask as *mut c_void);
Expand Down

0 comments on commit 2ca6447

Please sign in to comment.