Commit 708a806c authored by Frank Bossen's avatar Frank Bossen Committed by Thomas Daede

Fix padding of odd-sized frames

Fix padding to begin at output frame boundaries instead of coded
frame boundaries.
Fixes #731
Update test to compare only samples that are within frame boundaries
parent ea6ece6a
......@@ -469,7 +469,7 @@ impl Context {
let data = encode_frame(&mut self.seq, &mut self.fi, &mut fs);
self.packet_data.extend(data);
fs.rec.pad();
fs.rec.pad(self.fi.width, self.fi.height);
// TODO avoid the clone by having rec Arc.
let rec = if self.fi.show_frame { Some(fs.rec.clone()) } else { None };
......
......@@ -63,9 +63,9 @@ impl Frame {
}
}
pub fn pad(&mut self) {
pub fn pad(&mut self, w: usize, h: usize) {
for p in self.planes.iter_mut() {
p.pad();
p.pad(w, h);
}
}
......@@ -2358,9 +2358,9 @@ pub fn encode_frame(sequence: &mut Sequence, fi: &mut FrameInvariants, fs: &mut
}
fs.input_hres.downsample_from(&fs.input.planes[0]);
fs.input_hres.pad();
fs.input_hres.pad(fi.width, fi.height);
fs.input_qres.downsample_from(&fs.input_hres);
fs.input_qres.pad();
fs.input_qres.pad(fi.width, fi.height);
let bit_depth = sequence.bit_depth;
let tile = encode_tile(sequence, fi, fs, bit_depth); // actually tile group
......
......@@ -109,13 +109,13 @@ impl Plane {
}
}
pub fn pad(&mut self) {
pub fn pad(&mut self, w: usize, h: usize) {
assert!(self.cfg.xorigin >= 0 && self.cfg.yorigin >= 0);
let xorigin = self.cfg.xorigin as usize;
let yorigin = self.cfg.yorigin as usize;
let stride = self.cfg.stride;
let width = self.cfg.width;
let height = self.cfg.height;
let width = w >> self.cfg.xdec;
let height = h >> self.cfg.ydec;
if xorigin > 0 {
for y in 0..height {
......
......@@ -189,14 +189,14 @@ fn compare_plane<T: Ord + std::fmt::Debug>(
}
}
fn compare_img(img: *const aom_image_t, frame: &Frame, bit_depth: usize) {
fn compare_img(img: *const aom_image_t, frame: &Frame, bit_depth: usize, width: usize, height: usize) {
use std::slice;
let img = unsafe { *img };
let img_iter = img.planes.iter().zip(img.stride.iter());
for (img_plane, frame_plane) in img_iter.zip(frame.planes.iter()) {
let w = frame_plane.cfg.width;
let h = frame_plane.cfg.height;
let w = width >> frame_plane.cfg.xdec;
let h = height >> frame_plane.cfg.ydec;
let rec_stride = frame_plane.cfg.stride;
if bit_depth > 8 {
......@@ -319,7 +319,7 @@ fn encode_decode(
corrupted_count += corrupted;
let rec = rec_fifo.pop_front().unwrap();
compare_img(img, &rec, bit_depth);
compare_img(img, &rec, bit_depth, w, h);
}
}
}
......
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