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(
24037 MIXED_SCALE_COMPOUND_HITS.with(|c| c.set(c.get() + 1));24037 MIXED_SCALE_COMPOUND_HITS.with(|c| c.set(c.get() + 1));
24038 }24038 }
24039 24039
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] {
24040 let mut inter0_y = vec![0i32; side * side];24052 let mut inter0_y = vec![0i32; side * side];
24041 mc::predict_compound_intermediate_kern(24053 mc::predict_compound_intermediate_kern(
24042 &py0.data,24054 &py0.data,
@@ -24263,6 +24275,26 @@ fn decode_inter_block(
24263 24275
24264 // lane-inter4 r2: a rectangular strip's transform tree starts from24276 // lane-inter4 r2: a rectangular strip's transform tree starts from
24265 // its own rect `max_txsize_rect_lookup` entry, not a square one.24277 // 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+
24266 let rect_tu = (write_w, write_h) != (side, side);24298 let rect_tu = (write_w, write_h) != (side, side);
24267 vartx_leaves = if rect_tu {24299 vartx_leaves = if rect_tu {
24268 read_block_tx_size_rect(24300 read_block_tx_size_rect(
@@ -24294,7 +24326,7 @@ fn decode_inter_block(
24294 side,24326 side,
24295 write_w,24327 write_w,
24296 write_h,24328 write_h,
24297- Pred::dense(&pred_y),24329+ sy,
24298 &vec![0i32; side * side], fctx,24330 &vec![0i32; side * side], fctx,
24299 );24331 );
24300 push_mc_rect(1, 24332 push_mc_rect(1,
@@ -24303,7 +24335,7 @@ fn decode_inter_block(
24303 chroma_side,24335 chroma_side,
24304 write_chroma_w,24336 write_chroma_w,
24305 write_chroma_h,24337 write_chroma_h,
24306- Pred::dense(&pred_u),24338+ su,
24307 &vec![0i32; chroma_side * chroma_side], fctx,24339 &vec![0i32; chroma_side * chroma_side], fctx,
24308 );24340 );
24309 push_mc_rect(2, 24341 push_mc_rect(2,
@@ -24312,7 +24344,7 @@ fn decode_inter_block(
24312 chroma_side,24344 chroma_side,
24313 write_chroma_w,24345 write_chroma_w,
24314 write_chroma_h,24346 write_chroma_h,
24315- Pred::dense(&pred_v),24347+ sv,
24316 &vec![0i32; chroma_side * chroma_side], fctx,24348 &vec![0i32; chroma_side * chroma_side], fctx,
24317 );24349 );
24318 luma_grid = vec![0i32; side * side];24350 luma_grid = vec![0i32; side * side];
@@ -24346,11 +24378,7 @@ fn decode_inter_block(
24346 let (tu_px, tu_py) = (px + col * MI, py + row * MI);24378 let (tu_px, tu_py) = (px + col * MI, py + row * MI);
24347 let (tu_grid, tu_tx_type) = if tw == th {24379 let (tu_grid, tu_tx_type) = if tw == th {
24348 let tx_px = tw;24380 let tx_px = tw;
24349- let mut tu_pred = Vec::with_capacity(tx_px * tx_px);24381+ let tu_pred = sy.offset(row * MI * side + col * MI);
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- }
24354 let scan = default_scan(tx_px.min(32));24382 let scan = default_scan(tx_px.min(32));
24355 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);24383 let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI);
24356 read_inter_plane(24384 read_inter_plane(
@@ -24366,7 +24394,7 @@ fn decode_inter_block(
24366 tu_py,24394 tu_py,
24367 tx_px,24395 tx_px,
24368 base_q_idx,24396 base_q_idx,
24369- Pred::dense(&tu_pred),24397+ tu_pred,
24370 None,24398 None,
24371 Some(tu_skip_ctx), fctx,24399 Some(tu_skip_ctx), fctx,
24372 )?24400 )?
@@ -24394,7 +24422,7 @@ fn decode_inter_block(
24394 y,24422 y,
24395 tu_px,24423 tu_px,
24396 tu_py,24424 tu_py,
24397- Pred::dense(&pred_y[start..]),24425+ sy.offset(start),
24398 None,24426 None,
24399 Some(tu_skip_ctx), fctx,24427 Some(tu_skip_ctx), fctx,
24400 )?24428 )?
@@ -24428,16 +24456,12 @@ fn decode_inter_block(
24428 let cu_scan = default_scan(cu_tx);24456 let cu_scan = default_scan(cu_tx);
24429 for plane_idx in 1..3 {24457 for plane_idx in 1..3 {
24430 let (src, buf) = if plane_idx == 1 {24458 let (src, buf) = if plane_idx == 1 {
24431- (&pred_u, &mut *u)24459+ (su, &mut *u)
24432 } else {24460 } else {
24433- (&pred_v, &mut *v)24461+ (sv, &mut *v)
24434 };24462 };
24435- let mut cu_pred = Vec::with_capacity(cu_tx * cu_tx);24463+ let cu_pred =
24436- for rr in 0..cu_tx {24464+ src.offset(cr * cu_tx * chroma_side + cc * 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- }
24441 let cu_grid = read_inter_plane(24465 let cu_grid = read_inter_plane(
24442 dec,24466 dec,
24443 cdfs,24467 cdfs,
@@ -24451,7 +24475,7 @@ fn decode_inter_block(
24451 cu_y,24475 cu_y,
24452 cu_tx,24476 cu_tx,
24453 base_q_idx,24477 base_q_idx,
24454- Pred::dense(&cu_pred),24478+ cu_pred,
24455 Some(first_tx_type),24479 Some(first_tx_type),
24456 Some(3), fctx,24480 Some(3), fctx,
24457 )?24481 )?
@@ -24498,7 +24522,7 @@ fn decode_inter_block(
24498 y,24522 y,
24499 px,24523 px,
24500 py,24524 py,
24501- Pred::dense(&pred_y),24525+ sy,
24502 None,24526 None,
24503 None, fctx,24527 None, fctx,
24504 )?;24528 )?;
@@ -24518,7 +24542,7 @@ fn decode_inter_block(
24518 py,24542 py,
24519 side,24543 side,
24520 base_q_idx,24544 base_q_idx,
24521- Pred::dense(&pred_y),24545+ sy,
24522 None,24546 None,
24523 None, fctx,24547 None, fctx,
24524 )?;24548 )?;
@@ -24548,7 +24572,7 @@ fn decode_inter_block(
24548 u,24572 u,
24549 cpx,24573 cpx,
24550 cpy,24574 cpy,
24551- Pred::dense(&pred_u),24575+ su,
24552 Some(luma_tx_type),24576 Some(luma_tx_type),
24553 None, fctx,24577 None, fctx,
24554 )?24578 )?
@@ -24570,7 +24594,7 @@ fn decode_inter_block(
24570 v,24594 v,
24571 cpx,24595 cpx,
24572 cpy,24596 cpy,
24573- Pred::dense(&pred_v),24597+ sv,
24574 Some(luma_tx_type),24598 Some(luma_tx_type),
24575 None, fctx,24599 None, fctx,
24576 )?24600 )?
@@ -24593,7 +24617,7 @@ fn decode_inter_block(
24593 cpy,24617 cpy,
24594 chroma_side,24618 chroma_side,
24595 base_q_idx,24619 base_q_idx,
24596- Pred::dense(&pred_u),24620+ su,
24597 Some(luma_tx_type),24621 Some(luma_tx_type),
24598 None, fctx,24622 None, fctx,
24599 )?24623 )?
@@ -24611,7 +24635,7 @@ fn decode_inter_block(
24611 cpy,24635 cpy,
24612 chroma_side,24636 chroma_side,
24613 base_q_idx,24637 base_q_idx,
24614- Pred::dense(&pred_v),24638+ sv,
24615 Some(luma_tx_type),24639 Some(luma_tx_type),
24616 None, fctx,24640 None, fctx,
24617 )?24641 )?