Struct adder_codec_rs::framer::driver::FrameSequence
source · pub struct FrameSequence<T> {
pub state: FrameSequenceState,
pub chunk_rows: usize,
/* private fields */
}
Expand description
A sequence of frames, each of which is a 3D array of FrameValue
s
Fields§
§state: FrameSequenceState
The state of the frame sequence
chunk_rows: usize
Number of rows per chunk (per thread)
Implementations§
source§impl<T: Clone + Default + FrameValue<Output = T> + Serialize> FrameSequence<T>
impl<T: Clone + Default + FrameValue<Output = T> + Serialize> FrameSequence<T>
sourcepub fn get_frames_len(&self) -> usize
pub fn get_frames_len(&self) -> usize
Get the number of frames queue’d up to be written
sourcepub fn get_frame_chunks_num(&self) -> usize
pub fn get_frame_chunks_num(&self) -> usize
Get the number of chunks in a frame
sourcepub fn px_at_current(
&self,
y: usize,
x: usize,
c: usize
) -> Result<&Option<T>, FrameSequenceError>
pub fn px_at_current( &self, y: usize, x: usize, c: usize ) -> Result<&Option<T>, FrameSequenceError>
sourcepub fn px_at_frame(
&self,
y: usize,
x: usize,
c: usize,
frame_idx: usize
) -> Result<&Option<T>, FrameSequenceError>
pub fn px_at_frame( &self, y: usize, x: usize, c: usize, frame_idx: usize ) -> Result<&Option<T>, FrameSequenceError>
Get the reference for the pixel at the given coordinates and frame index
Arguments
y
- The y coordinate of the pixelx
- The x coordinate of the pixelc
- The channel of the pixelframe_idx
- The index of the frame to get the pixel from
Returns
Option<&T>
- The reference to the pixel value
Errors
- If the frame at the given index has not been initialized
sourcepub fn is_frame_filled(
&self,
frame_idx: usize
) -> Result<bool, FrameSequenceError>
pub fn is_frame_filled( &self, frame_idx: usize ) -> Result<bool, FrameSequenceError>
Get whether or not the frame at the given index is “filled” (i.e., all pixels have been written to)
Arguments
frame_idx
- The index of the frame to check
Returns
bool
- Whether or not the frame is filled
Errors
- If the frame at the given index has not been initialized
- If the frame index is out of bounds
- If the frame is not aligned with the chunk division
sourcepub fn is_frame_0_filled(&self) -> bool
pub fn is_frame_0_filled(&self) -> bool
Get whether or not the next frame is “filled” (i.e., all pixels have been written to)
sourcepub fn pop_next_frame(&mut self) -> Option<Vec<Array3<Option<T>>>>
pub fn pop_next_frame(&mut self) -> Option<Vec<Array3<Option<T>>>>
Pop the next frame for all chunks
returns: the frame
sourcepub fn pop_next_frame_for_chunk(
&mut self,
chunk_num: usize
) -> Option<Array3<Option<T>>>
pub fn pop_next_frame_for_chunk( &mut self, chunk_num: usize ) -> Option<Array3<Option<T>>>
Pop the next frame from the given chunk
Arguments
chunk_num
: the y-index of the chunk to pop the frame from
returns: the chunk of frame values
sourcepub fn write_frame_bytes(
&mut self,
writer: &mut BufWriter<File>
) -> Result<(), Box<dyn Error>>
pub fn write_frame_bytes( &mut self, writer: &mut BufWriter<File> ) -> Result<(), Box<dyn Error>>
Trait Implementations§
source§impl<T: Clone + Default + FrameValue<Output = T> + Copy + Serialize + Send + Sync + Zero> Framer for FrameSequence<T>
impl<T: Clone + Default + FrameValue<Output = T> + Copy + Serialize + Send + Sync + Zero> Framer for FrameSequence<T>
source§fn ingest_event(&mut self, event: &mut Event) -> bool
fn ingest_event(&mut self, event: &mut Event) -> bool
Examples
let mut frame_sequence: FrameSequence<u8> =
FramerBuilder::new(
PlaneSize::new(10,10,3).unwrap(), 64)
.codec_version(1, TimeMode::DeltaT)
.time_parameters(50000, 1000, 1000, 50.0)
.mode(INSTANTANEOUS)
.source(U8, FramedU8)
.finish();
let mut event: Event = Event {
coord: Coord {
x: 5,
y: 5,
c: Some(1)
},
d: 5,
delta_t: 1000
};
frame_sequence.ingest_event(&mut event);
let elem = frame_sequence.px_at_current(5, 5, 1).unwrap();
assert_eq!(*elem, Some(32));
source§fn new(builder: FramerBuilder) -> Self
fn new(builder: FramerBuilder) -> Self
Create a new
Framer
with the given FramerBuilder
.Auto Trait Implementations§
impl<T> RefUnwindSafe for FrameSequence<T>where T: RefUnwindSafe,
impl<T> Send for FrameSequence<T>where T: Send,
impl<T> Sync for FrameSequence<T>where T: Sync,
impl<T> Unpin for FrameSequence<T>
impl<T> UnwindSafe for FrameSequence<T>where T: RefUnwindSafe,
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.