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 | frame_height: usize, | 19725 | frame_height: usize, |
| 19726 | width: usize, | 19726 | width: usize, |
| 19727 | height: usize, | 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 | thread_local! { | 19735 | thread_local! { |
| @@ -19772,6 +19777,7 @@ fn capture_filter_replay( | |||
| 19772 | frame_height, | 19777 | frame_height, |
| 19773 | width, | 19778 | width, |
| 19774 | height, | 19779 | height, |
| 19780 | + deblocked: None, | ||
| 19775 | }); | 19781 | }); |
| 19776 | }); | 19782 | }); |
| 19777 | } | 19783 | } |
| @@ -19785,23 +19791,31 @@ pub(crate) fn replay_filters( | |||
| 19785 | cdef: &CdefParams, | 19791 | cdef: &CdefParams, |
| 19786 | fctx: &FrameCtx, | 19792 | fctx: &FrameCtx, |
| 19787 | ) -> Option<Picture> { | 19793 | ) -> Option<Picture> { |
| 19788 | - REPLAY.with_borrow(|slot| { | 19794 | + REPLAY.with_borrow_mut(|slot| { |
| 19789 | - let r = slot.as_ref()?; | 19795 | + let r = slot.as_mut()?; |
| 19790 | let copy = |p: &PlaneBuf<'_>| PlaneBuf { | 19796 | let copy = |p: &PlaneBuf<'_>| PlaneBuf { |
| 19791 | data: std::borrow::Cow::Owned(p.data.to_vec()), | 19797 | data: std::borrow::Cow::Owned(p.data.to_vec()), |
| 19792 | ..*p | 19798 | ..*p |
| 19793 | }; | 19799 | }; |
| 19794 | - let (mut y, mut u, mut v) = (copy(&r.y), copy(&r.u), copy(&r.v)); | 19800 | + let hit = matches!(&r.deblocked, Some((lf, ..)) if lf == loop_filter); |
| 19795 | - apply_deblock( | 19801 | + let (mut y, mut u, mut v) = if hit { |
| 19796 | - &mut y, | 19802 | + let (_, dy, du, dv) = r.deblocked.as_ref().expect("just matched"); |
| 19797 | - &mut u, | 19803 | + (copy(dy), copy(du), copy(dv)) |
| 19798 | - &mut v, | 19804 | + } else { |
| 19799 | - loop_filter, | 19805 | + let (mut y, mut u, mut v) = (copy(&r.y), copy(&r.u), copy(&r.v)); |
| 19800 | - &r.neighbours, | 19806 | + apply_deblock( |
| 19801 | - r.frame_width, | 19807 | + &mut y, |
| 19802 | - r.frame_height, | 19808 | + &mut u, |
| 19803 | - fctx, | 19809 | + &mut v, |
| 19804 | - ); | 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 | apply_cdef(&mut y, &mut u, &mut v, cdef, &r.neighbours, (r.frame_width, r.frame_height), fctx); | 19819 | apply_cdef(&mut y, &mut u, &mut v, cdef, &r.neighbours, (r.frame_width, r.frame_height), fctx); |
| 19806 | // The capture only happens on the shape the decoder's own tail | 19820 | // The capture only happens on the shape the decoder's own tail |
| 19807 | // returns whole (no superres, no loop restoration, no crop), so this | 19821 | // returns whole (no superres, no loop restoration, no crop), so this |