forge
Explore
Log in

Don't you dare go Hollow

A compound inter block predicts on the worker too

Browse files at this commit

52da7db6934595d19a13415541fbb235197c809dAhmet Kaan GümüşParent: 4a7d65a
  • perf
    • a compound inter block predicts on the worker too
Show full message
perf(av1): a compound inter block predicts on the worker too

lane-wave4: the compound arm's whole prediction -- both references, the
wedge/diffwtd/distance blend, all three planes -- becomes the same deferred
closure the single-reference arm got. A compound block reads neither
motion_mode nor interintra, so its build has nothing that must stay on the
parsing thread.
crates/ec-av1/src/decode.rsmodified+49 -25
@@ -24037,6 +24037,18 @@ fn decode_inter_block(
2403724037 MIXED_SCALE_COMPOUND_HITS.with(|c| c.set(c.get() + 1));
2403824038 }
2403924039
24040+ // lane-wave4 (the compound arm's half): this block's whole
24041+ // prediction -- both references, the wedge/diffwtd/distance
24042+ // blend, every plane -- as a closure, run here at one
24043+ // reconstruction thread and on the wavefront worker otherwise
24044+ // (see the single-reference arm below). A compound block reads
24045+ // neither `motion_mode` nor `interintra`, so nothing but the
24046+ // blend itself lives in here.
24047+ let build = move |_y: &mut PlaneBuf<'static>,
24048+ _u: &mut PlaneBuf<'static>,
24049+ _v: &mut PlaneBuf<'static>,
24050+ fctx: &crate::decode::FrameCtx|
24051+ -> [Vec<u16>; 3] {
2404024052 let mut inter0_y = vec![0i32; side * side];
2404124053 mc::predict_compound_intermediate_kern(
2404224054 &py0.data,
@@ -24263,6 +24275,26 @@ fn decode_inter_block(
2426324275
2426424276 // lane-inter4 r2: a rectangular strip's transform tree starts from
2426524277 // its own rect `max_txsize_rect_lookup` entry, not a square one.
24278+ [pred_y, pred_u, pred_v]
24279+ };
24280+ let (pred_y, pred_u, pred_v): (Vec<u16>, Vec<u16>, Vec<u16>);
24281+ let (sy, su, sv) = if recon_deferred(fctx) {
24282+ push_pred(fctx, build);
24283+ (
24284+ Pred::Cur { plane: 0, stride: side, off: 0 },
24285+ Pred::Cur { plane: 1, stride: chroma_side, off: 0 },
24286+ Pred::Cur { plane: 2, stride: chroma_side, off: 0 },
24287+ )
24288+ } else {
24289+ let [by, bu, bv] = build(y, u, v, fctx);
24290+ (pred_y, pred_u, pred_v) = (by, bu, bv);
24291+ (
24292+ Pred::Inline(&pred_y, side),
24293+ Pred::Inline(&pred_u, chroma_side),
24294+ Pred::Inline(&pred_v, chroma_side),
24295+ )
24296+ };
24297+
2426624298 let rect_tu = (write_w, write_h) != (side, side);
2426724299 vartx_leaves = if rect_tu {
2426824300 read_block_tx_size_rect(
@@ -24294,7 +24326,7 @@ fn decode_inter_block(
2429424326 side,
2429524327 write_w,
2429624328 write_h,
24297- Pred::dense(&pred_y),
24329+ sy,
2429824330 &vec![0i32; side * side], fctx,
2429924331 );
2430024332 push_mc_rect(1,
@@ -24303,7 +24335,7 @@ fn decode_inter_block(
2430324335 chroma_side,
2430424336 write_chroma_w,
2430524337 write_chroma_h,
24306- Pred::dense(&pred_u),
24338+ su,
2430724339 &vec![0i32; chroma_side * chroma_side], fctx,
2430824340 );
2430924341 push_mc_rect(2,
@@ -24312,7 +24344,7 @@ fn decode_inter_block(
2431224344 chroma_side,
2431324345 write_chroma_w,
2431424346 write_chroma_h,
24315- Pred::dense(&pred_v),
24347+ sv,
2431624348 &vec![0i32; chroma_side * chroma_side], fctx,
2431724349 );
2431824350 luma_grid = vec![0i32; side * side];
@@ -24346,11 +24378,7 @@ fn decode_inter_block(
2434624378 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
2434724379 let (tu_grid, tu_tx_type) = if tw == th {
2434824380 let tx_px = tw;
24349- let mut tu_pred = Vec::with_capacity(tx_px * tx_px);
24350- for rr in 0..tx_px {
24351- let start = (row * MI + rr) * side + col * MI;
24352- tu_pred.extend_from_slice(&pred_y[start..start + tx_px]);
24353- }
24381+ let tu_pred = sy.offset(row * MI * side + col * MI);
2435424382 let scan = default_scan(tx_px.min(32));
2435524383 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
2435624384 read_inter_plane(
@@ -24366,7 +24394,7 @@ fn decode_inter_block(
2436624394 tu_py,
2436724395 tx_px,
2436824396 base_q_idx,
24369- Pred::dense(&tu_pred),
24397+ tu_pred,
2437024398 None,
2437124399 Some(tu_skip_ctx), fctx,
2437224400 )?
@@ -24394,7 +24422,7 @@ fn decode_inter_block(
2439424422 y,
2439524423 tu_px,
2439624424 tu_py,
24397- Pred::dense(&pred_y[start..]),
24425+ sy.offset(start),
2439824426 None,
2439924427 Some(tu_skip_ctx), fctx,
2440024428 )?
@@ -24428,16 +24456,12 @@ fn decode_inter_block(
2442824456 let cu_scan = default_scan(cu_tx);
2442924457 for plane_idx in 1..3 {
2443024458 let (src, buf) = if plane_idx == 1 {
24431- (&pred_u, &mut *u)
24459+ (su, &mut *u)
2443224460 } else {
24433- (&pred_v, &mut *v)
24461+ (sv, &mut *v)
2443424462 };
24435- let mut cu_pred = Vec::with_capacity(cu_tx * cu_tx);
24436- for rr in 0..cu_tx {
24437- let start =
24438- (cr * cu_tx + rr) * chroma_side + cc * cu_tx;
24439- cu_pred.extend_from_slice(&src[start..start + cu_tx]);
24440- }
24463+ let cu_pred =
24464+ src.offset(cr * cu_tx * chroma_side + cc * cu_tx);
2444124465 let cu_grid = read_inter_plane(
2444224466 dec,
2444324467 cdfs,
@@ -24451,7 +24475,7 @@ fn decode_inter_block(
2445124475 cu_y,
2445224476 cu_tx,
2445324477 base_q_idx,
24454- Pred::dense(&cu_pred),
24478+ cu_pred,
2445524479 Some(first_tx_type),
2445624480 Some(3), fctx,
2445724481 )?
@@ -24498,7 +24522,7 @@ fn decode_inter_block(
2449824522 y,
2449924523 px,
2450024524 py,
24501- Pred::dense(&pred_y),
24525+ sy,
2450224526 None,
2450324527 None, fctx,
2450424528 )?;
@@ -24518,7 +24542,7 @@ fn decode_inter_block(
2451824542 py,
2451924543 side,
2452024544 base_q_idx,
24521- Pred::dense(&pred_y),
24545+ sy,
2452224546 None,
2452324547 None, fctx,
2452424548 )?;
@@ -24548,7 +24572,7 @@ fn decode_inter_block(
2454824572 u,
2454924573 cpx,
2455024574 cpy,
24551- Pred::dense(&pred_u),
24575+ su,
2455224576 Some(luma_tx_type),
2455324577 None, fctx,
2455424578 )?
@@ -24570,7 +24594,7 @@ fn decode_inter_block(
2457024594 v,
2457124595 cpx,
2457224596 cpy,
24573- Pred::dense(&pred_v),
24597+ sv,
2457424598 Some(luma_tx_type),
2457524599 None, fctx,
2457624600 )?
@@ -24593,7 +24617,7 @@ fn decode_inter_block(
2459324617 cpy,
2459424618 chroma_side,
2459524619 base_q_idx,
24596- Pred::dense(&pred_u),
24620+ su,
2459724621 Some(luma_tx_type),
2459824622 None, fctx,
2459924623 )?
@@ -24611,7 +24635,7 @@ fn decode_inter_block(
2461124635 cpy,
2461224636 chroma_side,
2461324637 base_q_idx,
24614- Pred::dense(&pred_v),
24638+ sv,
2461524639 Some(luma_tx_type),
2461624640 None, fctx,
2461724641 )?