Commit cf90a229 authored by Luca Barbato's avatar Luca Barbato Committed by Luca Barbato

Make the input frame Arc

parent b3283b89
......@@ -3,6 +3,7 @@ use rav1e::*;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::sync::Arc;
use std::slice;
use y4m;
......@@ -125,9 +126,12 @@ pub fn process_frame(sequence: &mut Sequence, fi: &mut FrameInvariants,
let y4m_v = y4m_frame.get_v_plane();
eprintln!("{}", fi);
let mut fs = FrameState::new(&fi);
fs.input.planes[0].copy_from_raw_u8(&y4m_y, width * y4m_bytes, y4m_bytes);
fs.input.planes[1].copy_from_raw_u8(&y4m_u, width * y4m_bytes / 2, y4m_bytes);
fs.input.planes[2].copy_from_raw_u8(&y4m_v, width * y4m_bytes / 2, y4m_bytes);
{
let input = Arc::get_mut(&mut fs.input).unwrap();
input.planes[0].copy_from_raw_u8(&y4m_y, width * y4m_bytes, y4m_bytes);
input.planes[1].copy_from_raw_u8(&y4m_u, width * y4m_bytes / 2, y4m_bytes);
input.planes[2].copy_from_raw_u8(&y4m_v, width * y4m_bytes / 2, y4m_bytes);
}
match y4m_bits {
8 | 10 | 12 => {},
......
......@@ -225,9 +225,11 @@ impl Sequence {
}
}
use std::sync::Arc;
#[derive(Debug)]
pub struct FrameState {
pub input: Frame,
pub input: Arc<Frame>,
pub rec: Frame,
pub qc: QuantizationContext,
pub cdfs: CDFContext,
......@@ -236,7 +238,7 @@ pub struct FrameState {
impl FrameState {
pub fn new(fi: &FrameInvariants) -> FrameState {
FrameState {
input: Frame::new(fi.padded_w, fi.padded_h),
input: Arc::new(Frame::new(fi.padded_w, fi.padded_h)),
rec: Frame::new(fi.padded_w, fi.padded_h),
qc: Default::default(),
cdfs: CDFContext::new(0),
......@@ -394,7 +396,7 @@ impl FrameInvariants {
pub fn new_frame_state(&self) -> FrameState {
FrameState {
input: Frame::new(self.padded_w, self.padded_h),
input: Arc::new(Frame::new(self.padded_w, self.padded_h)),
rec: Frame::new(self.padded_w, self.padded_h),
qc: Default::default(),
cdfs: CDFContext::new(0),
......
......@@ -10,6 +10,7 @@ use super::*;
use rand::{ChaChaRng, Rng, SeedableRng};
use std::collections::VecDeque;
use std::mem;
use std::sync::Arc;
fn fill_frame(ra: &mut ChaChaRng, frame: &mut Frame) {
for plane in frame.planes.iter_mut() {
......@@ -217,7 +218,7 @@ use std::mem;
for _ in 0 .. limit {
let mut fs = fi.new_frame_state();
fill_frame(&mut ra, &mut fs.input);
fill_frame(&mut ra, Arc::get_mut(&mut fs.input).unwrap());
fi.frame_type = if fi.number % 30 == 0 { FrameType::KEY } else { FrameType::INTER };
fi.refresh_frame_flags = if fi.frame_type == FrameType::KEY { ALL_REF_FRAMES_MASK } else { 1 };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment