Skip to content

Commit

Permalink
struct Rav1dContext::frame_flags: Make PictureFlags `Atomic<Pictu…
Browse files Browse the repository at this point in the history
…reFlags>`.
  • Loading branch information
kkysen committed Jan 12, 2024
1 parent 21c966c commit e235ade
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ use crate::src::refmvs::refmvs_temporal_block;
use crate::src::refmvs::refmvs_tile;
use crate::src::refmvs::Rav1dRefmvsDSPContext;
use crate::src::thread_data::thread_data;
use atomig::Atomic;
use libc::pthread_cond_t;
use libc::pthread_mutex_t;
use libc::ptrdiff_t;
Expand Down Expand Up @@ -253,7 +254,7 @@ pub struct Rav1dContext {
pub(crate) inloop_filters: Rav1dInloopFilterType,
pub(crate) decode_frame_type: Rav1dDecodeFrameType,
pub(crate) drain: c_int,
pub(crate) frame_flags: PictureFlags,
pub(crate) frame_flags: Atomic<PictureFlags>,
pub(crate) event_flags: Rav1dEventFlags,
pub(crate) cached_error_props: Rav1dDataProps,
pub(crate) cached_error: Rav1dResult,
Expand Down
14 changes: 10 additions & 4 deletions src/obu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2249,7 +2249,8 @@ unsafe fn parse_obus(c: &mut Rav1dContext, r#in: &Rav1dData, global: bool) -> Ra
match &c.seq_hdr {
None => {
c.frame_hdr = None;
c.frame_flags |= PictureFlags::NEW_SEQUENCE;
c.frame_flags
.fetch_or(PictureFlags::NEW_SEQUENCE, Ordering::Relaxed);
}
Some(c_seq_hdr) if !seq_hdr.eq_without_operating_parameter_info(&c_seq_hdr) => {
// See 7.5, `operating_parameter_info` is allowed to change in
Expand All @@ -2265,13 +2266,15 @@ unsafe fn parse_obus(c: &mut Rav1dContext, r#in: &Rav1dData, global: bool) -> Ra
rav1d_ref_dec(&mut c.refs[i as usize].refmvs);
rav1d_cdf_thread_unref(&mut c.cdf[i as usize]);
}
c.frame_flags |= PictureFlags::NEW_SEQUENCE;
c.frame_flags
.fetch_or(PictureFlags::NEW_SEQUENCE, Ordering::Relaxed);
}
Some(c_seq_hdr)
if seq_hdr.operating_parameter_info != c_seq_hdr.operating_parameter_info =>
{
// If operating_parameter_info changed, signal it
c.frame_flags |= PictureFlags::NEW_OP_PARAMS_INFO;
c.frame_flags
.fetch_or(PictureFlags::NEW_OP_PARAMS_INFO, Ordering::Relaxed);
}
_ => {}
}
Expand Down Expand Up @@ -2463,7 +2466,10 @@ unsafe fn parse_obus(c: &mut Rav1dContext, r#in: &Rav1dData, global: bool) -> Ra
}
}
}
RAV1D_OBU_TD => c.frame_flags |= PictureFlags::NEW_TEMPORAL_UNIT,
RAV1D_OBU_TD => {
c.frame_flags
.fetch_or(PictureFlags::NEW_TEMPORAL_UNIT, Ordering::Relaxed);
}
RAV1D_OBU_PADDING => {} // Ignore OBUs we don't care about.
_ => {
// Print a warning, but don't fail for unknown types.
Expand Down
4 changes: 2 additions & 2 deletions src/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use std::ptr;
use std::ptr::addr_of_mut;
use std::slice;
use std::sync::atomic::AtomicU32;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use to_method::To as _;

Expand Down Expand Up @@ -257,8 +258,7 @@ pub(crate) unsafe fn rav1d_thread_picture_alloc(
} else {
PictureFlags::NEW_SEQUENCE | PictureFlags::NEW_OP_PARAMS_INFO
};
p.flags = c.frame_flags;
c.frame_flags &= flags_mask;
p.flags = c.frame_flags.fetch_and(flags_mask, Ordering::Relaxed);
p.visible = frame_hdr.show_frame != 0;
p.showable = frame_hdr.showable_frame != 0;
p.progress = if have_frame_mt {
Expand Down

0 comments on commit e235ade

Please sign in to comment.