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 commitda21edb9901cae3e45ccab5ab92be107ad5f089cParent: cbfe14c1 changed file +28 -40
- crates/ec-vp9/src/decode.rs +28 -40
crates/ec-vp9/src/decode.rsmodified+28 -40
| @@ -567,25 +567,7 @@ impl Decoder { | ||
| 567 | 567 | // Loop filter post-pass: same extents as the keyframe path, but the |
| 568 | 568 | // per-cell level comes from the block's own reference and mode class |
| 569 | 569 | // (`get_filter_level`, vp9_loopfilter.c:249). |
| 570 | - if hdr.loop_filter.level > 0 { | |
| 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 | - } | |
| 570 | + self.loop_filter(&grids, hdr); | |
| 589 | 571 | |
| 590 | 572 | let pic = self.take_picture(hdr); |
| 591 | 573 | // 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 | 622 | /// Crop the frame scratch to a [`Picture`]. |
| 615 | 623 | fn take_picture(&self, hdr: &FrameHeader) -> Picture { |
| 616 | 624 | crop_picture( |
| @@ -942,8 +950,6 @@ impl Decoder { | ||
| 942 | 950 | tx_mode: u8, |
| 943 | 951 | tail: &[u8], |
| 944 | 952 | ) -> Result<Picture> { |
| 945 | - let ss_x = hdr.subsampling_x as usize; | |
| 946 | - let ss_y = hdr.subsampling_y as usize; | |
| 947 | 953 | let mi_cols = hdr.mi_cols() as usize; |
| 948 | 954 | let mi_rows = hdr.mi_rows() as usize; |
| 949 | 955 | let tile_cols = 1usize << hdr.tile_info.cols_log2; |
| @@ -978,25 +984,7 @@ impl Decoder { | ||
| 978 | 984 | // Loop filter post-pass (level 0 disables it for the frame). |
| 979 | 985 | // The extents are the MI-aligned VISIBLE plane (libvpx's masks clear |
| 980 | 986 | // everything past `mi_cols`/`mi_rows`), not the padded buffer size. |
| 981 | - if hdr.loop_filter.level > 0 { | |
| 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 | - } | |
| 987 | + self.loop_filter(&grids, hdr); | |
| 1000 | 988 | |
| 1001 | 989 | // `vp9_swap_current_and_last_seg_map` runs only when segmentation is |
| 1002 | 990 | // enabled: this frame's map becomes the next frame's prediction map. |