Skip to content

Commit

Permalink
struct Rav1dFrameData::mvs: Only allocate when the length changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkysen committed Oct 31, 2024
1 parent c7d127e commit 3854d5e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5219,12 +5219,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(
(0..f.sb128h as usize * 16 * (f.b4_stride >> 1) as usize)
.map(|_| Default::default())
.collect(),
);
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((0..n_mvs).map(|_| Default::default()).collect());
}
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 3854d5e

Please sign in to comment.