forge
Explore
Log in

Don't you dare go Hollow

S6: Decoder::loop_filter holds the post-pass once; the key and inter paths had identical copies (same extents and call)

Browse files at this commit

da21edb9901cae3e45ccab5ab92be107ad5f089cAhmet Kaan GümüşParent: cbfe14c
crates/ec-vp9/src/decode.rsmodified+28 -40
@@ -567,25 +567,7 @@ impl Decoder {
567 // Loop filter post-pass: same extents as the keyframe path, but the567 // Loop filter post-pass: same extents as the keyframe path, but the
568 // per-cell level comes from the block's own reference and mode class568 // per-cell level comes from the block's own reference and mode class
569 // (`get_filter_level`, vp9_loopfilter.c:249).569 // (`get_filter_level`, vp9_loopfilter.c:249).
570- if hdr.loop_filter.level > 0 {570+ self.loop_filter(&grids, hdr);
571- let p = self.planes.as_mut().expect("frame scratch");
572- let (vw, vh) = (mi_cols * 8, mi_rows * 8);
573- grids.filter_frame(
574- &mut p.y,
575- p.ys,
576- &mut p.u,
577- &mut p.v,
578- p.uvs,
579- vw,
580- vh,
581- vw >> ss_x,
582- vh >> ss_y,
583- ss_x,
584- ss_y,
585- hdr.loop_filter.sharpness,
586- hdr.bit_depth,
587- );
588- }
589 571
590 let pic = self.take_picture(hdr);572 let pic = self.take_picture(hdr);
591 // Reference refresh (spec 8.10 / `swap_frame_buffers`): bit i of573 // Reference refresh (spec 8.10 / `swap_frame_buffers`): bit i of
@@ -611,6 +593,32 @@ impl Decoder {
611 }593 }
612 }594 }
613 595
596+ /// Loop-filter post-pass over the MI-aligned visible planes (level 0
597+ /// disables it); the extents are not the padded buffer size.
598+ fn loop_filter(&mut self, grids: &LfGrids, hdr: &FrameHeader) {
599+ if hdr.loop_filter.level == 0 {
600+ return;
601+ }
602+ 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);
604+ 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+ );
620+ }
621+
614 /// Crop the frame scratch to a [`Picture`].622 /// Crop the frame scratch to a [`Picture`].
615 fn take_picture(&self, hdr: &FrameHeader) -> Picture {623 fn take_picture(&self, hdr: &FrameHeader) -> Picture {
616 crop_picture(624 crop_picture(
@@ -942,8 +950,6 @@ impl Decoder {
942 tx_mode: u8,950 tx_mode: u8,
943 tail: &[u8],951 tail: &[u8],
944 ) -> Result<Picture> {952 ) -> Result<Picture> {
945- let ss_x = hdr.subsampling_x as usize;
946- let ss_y = hdr.subsampling_y as usize;
947 let mi_cols = hdr.mi_cols() as usize;953 let mi_cols = hdr.mi_cols() as usize;
948 let mi_rows = hdr.mi_rows() as usize;954 let mi_rows = hdr.mi_rows() as usize;
949 let tile_cols = 1usize << hdr.tile_info.cols_log2;955 let tile_cols = 1usize << hdr.tile_info.cols_log2;
@@ -978,25 +984,7 @@ impl Decoder {
978 // Loop filter post-pass (level 0 disables it for the frame).984 // Loop filter post-pass (level 0 disables it for the frame).
979 // The extents are the MI-aligned VISIBLE plane (libvpx's masks clear985 // The extents are the MI-aligned VISIBLE plane (libvpx's masks clear
980 // everything past `mi_cols`/`mi_rows`), not the padded buffer size.986 // everything past `mi_cols`/`mi_rows`), not the padded buffer size.
981- if hdr.loop_filter.level > 0 {987+ self.loop_filter(&grids, hdr);
982- let p = self.planes.as_mut().expect("frame scratch");
983- let (vw, vh) = (mi_cols * 8, mi_rows * 8);
984- grids.filter_frame(
985- &mut p.y,
986- p.ys,
987- &mut p.u,
988- &mut p.v,
989- p.uvs,
990- vw,
991- vh,
992- vw >> ss_x,
993- vh >> ss_y,
994- ss_x,
995- ss_y,
996- hdr.loop_filter.sharpness,
997- hdr.bit_depth,
998- );
999- }
1000 988
1001 // `vp9_swap_current_and_last_seg_map` runs only when segmentation is989 // `vp9_swap_current_and_last_seg_map` runs only when segmentation is
1002 // enabled: this frame's map becomes the next frame's prediction map.990 // enabled: this frame's map becomes the next frame's prediction map.