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

Update the decode tests to the current user api

parent f593320a
......@@ -57,24 +57,28 @@ use std::sync::Arc;
}
fn setup_encoder(w: usize, h: usize, speed: usize, quantizer: usize,
bit_depth: usize, chroma_sampling: ChromaSampling) -> (FrameInvariants, Sequence) {
bit_depth: usize, chroma_sampling: ChromaSampling) -> Context {
unsafe {
av1_rtcd();
aom_dsp_rtcd();
}
let config = EncoderConfig {
let enc = EncoderConfig {
quantizer: quantizer,
speed: speed,
..Default::default()
};
let mut fi = FrameInvariants::new(w, h, config);
fi.use_reduced_tx_set = true;
// fi.min_partition_size =
let seq = Sequence::new(w, h, bit_depth, chroma_sampling);
let cfg = Config {
width: w,
height: h,
bit_depth,
chroma_sampling,
timebase: Ratio::new(1, 1000),
enc,
};
(fi, seq)
cfg.new_context()
}
// TODO: support non-multiple-of-16 dimensions
......@@ -208,7 +212,7 @@ use std::sync::Arc;
let mut ra = ChaChaRng::from_seed([0; 32]);
let mut dec = setup_decoder(w, h);
let (mut fi, mut seq) = setup_encoder(w, h, speed, quantizer, bit_depth, ChromaSampling::Cs420);
let mut ctx = setup_encoder(w, h, speed, quantizer, bit_depth, ChromaSampling::Cs420);
println!("Encoding {}x{} speed {} quantizer {}", w, h, speed, quantizer);
......@@ -217,27 +221,20 @@ use std::sync::Arc;
let mut rec_fifo = VecDeque::new();
for _ in 0 .. limit {
let mut fs = fi.new_frame_state();
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 };
let mut input = ctx.new_frame();
fill_frame(&mut ra, Arc::get_mut(&mut input).unwrap());
fi.intra_only = fi.frame_type == FrameType::KEY || fi.frame_type == FrameType::INTRA_ONLY;
fi.use_prev_frame_mvs = !(fi.intra_only || fi.error_resilient);
println!("Encoding frame {}", fi.number);
let packet = encode_frame(&mut seq, &mut fi, &mut fs);
println!("Encoded.");
let _ = ctx.send_frame(input);
let pkt = ctx.receive_packet().unwrap();
println!("Encoded packet {}", pkt.number);
fs.rec.pad();
rec_fifo.push_back(pkt.rec.clone());
rec_fifo.push_back(fs.rec.clone());
update_rec_buffer(&mut fi, fs);
let packet = pkt.data;
let mut corrupted_count = 0;
unsafe {
println!("Decoding frame {}", fi.number);
println!("Decoding frame {}", pkt.number);
let ret = aom_codec_decode(&mut dec.dec, packet.as_ptr(), packet.len(), ptr::null_mut());
println!("Decoded. -> {}", ret);
if ret != 0 {
......@@ -276,7 +273,5 @@ use std::sync::Arc;
}
assert_eq!(corrupted_count, 0);
fi.number += 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