forge
Explore
Log in

Don't you dare go Hollow

S6: filter_frame takes &mut Planes and the frame extent (5 args, was 13); loop_filter passes the scratch it already holds; the planes carry ss_x/ss_y/bd equal to the header values

Browse files at this commit

f5f883a7b1e47aee7c1407347939facab47ade79Ahmet Kaan GümüşParent: 58d72d3
crates/ec-vp9/src/decode.rsmodified+11 -26
@@ -71,22 +71,22 @@ pub struct Picture {
7171 pub subsampling_y: u8,
7272 }
7373
74-struct Planes {
75- y: Vec<Sample>,
76- u: Vec<Sample>,
77- v: Vec<Sample>,
78- ys: usize,
79- uvs: usize,
74+pub(crate) struct Planes {
75+ pub(crate) y: Vec<Sample>,
76+ pub(crate) u: Vec<Sample>,
77+ pub(crate) v: Vec<Sample>,
78+ pub(crate) ys: usize,
79+ pub(crate) uvs: usize,
8080 aw: usize,
8181 ah: usize,
8282 /// Bits per sample this frame was decoded at.
83- bd: u8,
83+ pub(crate) bd: u8,
8484 /// Chroma horizontal subsampling (`subsampling_x`): 0 for 4:4:4, 1 for
8585 /// 4:2:0/4:2:2.
86- ss_x: usize,
86+ pub(crate) ss_x: usize,
8787 /// Chroma vertical subsampling (`subsampling_y`): 0 for 4:4:4/4:2:2, 1
8888 /// for 4:2:0/4:4:0.
89- ss_y: usize,
89+ pub(crate) ss_y: usize,
9090 }
9191
9292 /// VP9 level 6.2 caps a picture at 8192x4352 luma samples. Larger frame headers are refused
@@ -116,7 +116,7 @@ impl Planes {
116116 /// edge decode at FULL size), so the fill only backs the never-written
117117 /// padding past the MI extent. Chroma planes are `aw >> ss_x` by
118118 /// `ah >> ss_y`; since `aw`/`ah` are 64-multiples the shift is exact.
119- fn new(aw: usize, ah: usize, bd: u8, ss_x: usize, ss_y: usize) -> Planes {
119+ pub(crate) fn new(aw: usize, ah: usize, bd: u8, ss_x: usize, ss_y: usize) -> Planes {
120120 let fill = 1u16 << (bd - 1);
121121 let (cw, ch) = (aw >> ss_x, ah >> ss_y);
122122 Planes {
@@ -600,23 +600,8 @@ impl Decoder {
600600 return;
601601 }
602602 let p = self.planes.as_mut().expect("frame scratch");
603- let (ss_x, ss_y) = (hdr.subsampling_x as usize, hdr.subsampling_y as usize);
604603 let (vw, vh) = (hdr.mi_cols() as usize * 8, hdr.mi_rows() as usize * 8);
605- grids.filter_frame(
606- &mut p.y,
607- p.ys,
608- &mut p.u,
609- &mut p.v,
610- p.uvs,
611- vw,
612- vh,
613- vw >> ss_x,
614- vh >> ss_y,
615- ss_x,
616- ss_y,
617- hdr.loop_filter.sharpness,
618- hdr.bit_depth,
619- );
604+ grids.filter_frame(p, vw, vh, hdr.loop_filter.sharpness);
620605 }
621606
622607 /// Crop the frame scratch to a [`Picture`].
crates/ec-vp9/src/loopfilter.rsmodified+11 -22
@@ -75,6 +75,7 @@ const LUMA_ABOVE_TXF: [u64; 4] = [u64::MAX, u64::MAX, 0x00ff00ff00ff00ff, 0x0000
7575 const LUMA_LEFT_BORDER: u64 = 0x1111111111111111;
7676 const LUMA_ABOVE_BORDER: u64 = 0x000000ff000000ff;
7777
78+use crate::decode::Planes;
7879 use crate::Sample;
7980
8081 /// `signed_char_clamp_high` (`vpx_dsp/loopfilter.c:23`): clamp to
@@ -1192,23 +1193,10 @@ impl LfGrids {
11921193 /// `vp9_loop_filter_frame` (vp9_loopfilter.c:1430): luma always takes the
11931194 /// ss00 path; chroma takes ss00 for 4:4:4, ss11 for 4:2:0, and the
11941195 /// non420 slow path otherwise (4:2:2 / 4:4:0).
1195- #[allow(clippy::too_many_arguments)]
1196- pub(crate) fn filter_frame(
1197- &self,
1198- y: &mut [Sample],
1199- stride: usize,
1200- u: &mut [Sample],
1201- v: &mut [Sample],
1202- uv_stride: usize,
1203- y_w: usize,
1204- y_h: usize,
1205- uv_w: usize,
1206- uv_h: usize,
1207- ss_x: usize,
1208- ss_y: usize,
1209- sharpness: u8,
1210- bd: u8,
1211- ) {
1196+ pub(crate) fn filter_frame(&self, p: &mut Planes, vw: usize, vh: usize, sharpness: u8) {
1197+ let (ss_x, ss_y, bd) = (p.ss_x, p.ss_y, p.bd);
1198+ let (uv_w, uv_h) = (vw >> ss_x, vh >> ss_y);
1199+ let (stride, uv_stride) = (p.ys, p.uvs);
12121200 // The three planes are filtered from the same read-only grids and touch
12131201 // disjoint buffers, so they run concurrently: luma on one thread, both
12141202 // chroma planes on another. Each plane's edge order is unchanged, so the
@@ -1226,8 +1214,8 @@ impl LfGrids {
12261214 }
12271215 };
12281216 std::thread::scope(|scope| {
1229- scope.spawn(|| chroma(u, v));
1230- self.filter_ss00_plane(y, stride, y_w, y_h, sharpness, bd);
1217+ scope.spawn(|| chroma(&mut p.u, &mut p.v));
1218+ self.filter_ss00_plane(&mut p.y, stride, vw, vh, sharpness, bd);
12311219 });
12321220 }
12331221 }
@@ -1253,9 +1241,10 @@ mod tests {
12531241 }
12541242
12551243 fn run(g: &LfGrids, y: &mut [Sample]) {
1256- let mut u = vec![128u16; 32 * 32];
1257- let mut v = vec![128u16; 32 * 32];
1258- g.filter_frame(y, 64, &mut u, &mut v, 32, 64, 64, 32, 32, 1, 1, 0, 8);
1244+ let mut p = Planes::new(64, 64, 8, 1, 1);
1245+ p.y.copy_from_slice(y);
1246+ g.filter_frame(&mut p, 64, 64, 0);
1247+ y.copy_from_slice(&p.y);
12591248 }
12601249
12611250 /// The luma internal-4x4 horizontal edge fires on the frame's LAST MI row.