The filter replay deblocks once per level pair
Browse files at this commit95de47fc4b4ef45aea807025014d3bb28c48fa2fParent: 2b23fd6- perf
- the filter replay deblocks once per level pair
1 changed file +27 -13
- crates/ec-av1/src/decode.rs +27 -13
crates/ec-av1/src/decode.rsmodified+27 -13
| @@ -19725,6 +19725,11 @@ pub(crate) struct FilterReplay { | ||
| 19725 | 19725 | frame_height: usize, |
| 19726 | 19726 | width: usize, |
| 19727 | 19727 | height: usize, |
| 19728 | + /// The last deblocked planes and the levels that produced them. | |
| 19729 | + /// Deblocking depends on nothing else the search moves, and the search | |
| 19730 | + /// fixes the levels before it walks the CDEF strengths, so every | |
| 19731 | + /// candidate after the first of a level pair replays CDEF alone. | |
| 19732 | + deblocked: Option<(LoopFilterParams, PlaneBuf<'static>, PlaneBuf<'static>, PlaneBuf<'static>)>, | |
| 19728 | 19733 | } |
| 19729 | 19734 | |
| 19730 | 19735 | thread_local! { |
| @@ -19772,6 +19777,7 @@ fn capture_filter_replay( | ||
| 19772 | 19777 | frame_height, |
| 19773 | 19778 | width, |
| 19774 | 19779 | height, |
| 19780 | + deblocked: None, | |
| 19775 | 19781 | }); |
| 19776 | 19782 | }); |
| 19777 | 19783 | } |
| @@ -19785,23 +19791,31 @@ pub(crate) fn replay_filters( | ||
| 19785 | 19791 | cdef: &CdefParams, |
| 19786 | 19792 | fctx: &FrameCtx, |
| 19787 | 19793 | ) -> Option<Picture> { |
| 19788 | - REPLAY.with_borrow(|slot| { | |
| 19789 | - let r = slot.as_ref()?; | |
| 19794 | + REPLAY.with_borrow_mut(|slot| { | |
| 19795 | + let r = slot.as_mut()?; | |
| 19790 | 19796 | let copy = |p: &PlaneBuf<'_>| PlaneBuf { |
| 19791 | 19797 | data: std::borrow::Cow::Owned(p.data.to_vec()), |
| 19792 | 19798 | ..*p |
| 19793 | 19799 | }; |
| 19794 | - let (mut y, mut u, mut v) = (copy(&r.y), copy(&r.u), copy(&r.v)); | |
| 19795 | - apply_deblock( | |
| 19796 | - &mut y, | |
| 19797 | - &mut u, | |
| 19798 | - &mut v, | |
| 19799 | - loop_filter, | |
| 19800 | - &r.neighbours, | |
| 19801 | - r.frame_width, | |
| 19802 | - r.frame_height, | |
| 19803 | - fctx, | |
| 19804 | - ); | |
| 19800 | + let hit = matches!(&r.deblocked, Some((lf, ..)) if lf == loop_filter); | |
| 19801 | + let (mut y, mut u, mut v) = if hit { | |
| 19802 | + let (_, dy, du, dv) = r.deblocked.as_ref().expect("just matched"); | |
| 19803 | + (copy(dy), copy(du), copy(dv)) | |
| 19804 | + } else { | |
| 19805 | + let (mut y, mut u, mut v) = (copy(&r.y), copy(&r.u), copy(&r.v)); | |
| 19806 | + apply_deblock( | |
| 19807 | + &mut y, | |
| 19808 | + &mut u, | |
| 19809 | + &mut v, | |
| 19810 | + loop_filter, | |
| 19811 | + &r.neighbours, | |
| 19812 | + r.frame_width, | |
| 19813 | + r.frame_height, | |
| 19814 | + fctx, | |
| 19815 | + ); | |
| 19816 | + r.deblocked = Some((*loop_filter, copy(&y), copy(&u), copy(&v))); | |
| 19817 | + (y, u, v) | |
| 19818 | + }; | |
| 19805 | 19819 | apply_cdef(&mut y, &mut u, &mut v, cdef, &r.neighbours, (r.frame_width, r.frame_height), fctx); |
| 19806 | 19820 | // The capture only happens on the shape the decoder's own tail |
| 19807 | 19821 | // returns whole (no superres, no loop restoration, no crop), so this |