Skip to content

Commit

Permalink
struct Rav1dFrameData::mvs: Avoid re-allocating f.mvs if the leng…
Browse files Browse the repository at this point in the history
…th doesn't change.
  • Loading branch information
kkysen committed Oct 31, 2024
1 parent 7f8c74a commit 04ea1ab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5220,10 +5220,11 @@ pub fn rav1d_submit_frame(c: &Rav1dContext, state: &mut Rav1dState) -> Rav1dResu

// ref_mvs
if frame_hdr.frame_type.is_inter_or_switch() || frame_hdr.allow_intrabc {
// TODO fallible allocation
f.mvs = Some(DisjointMutArcSlice::new_zeroed_slice(
f.sb128h as usize * 16 * (f.b4_stride >> 1) as usize,
));
let n_mvs = f.sb128h as usize * 16 * (f.b4_stride as usize >> 1);
if f.mvs.as_ref().map_or(true, |mvs| mvs.inner.len() != n_mvs) {
// TODO fallible allocation
f.mvs = Some(DisjointMutArcSlice::new_zeroed_slice(n_mvs));
}
if !frame_hdr.allow_intrabc {
for i in 0..7 {
f.refpoc[i] = f.refp[i].p.frame_hdr.as_ref().unwrap().frame_offset as c_uint;
Expand Down

0 comments on commit 04ea1ab

Please sign in to comment.