Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions crates/coreav-h264-encoder/src/deblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(crate) struct Record {
pub(crate) nonzero: u16,
}

fn strength(p: Record, q: Record, pi: usize, qi: usize, external: bool) -> Result<u8> {
fn strength(p: &Record, q: &Record, pi: usize, qi: usize, external: bool) -> Result<u8> {
if p.motion.intra || q.motion.intra {
return Ok(if external { 4 } else { 3 });
}
Expand Down Expand Up @@ -102,9 +102,9 @@ pub(crate) fn picture(
for vertical in [true, false] {
for offset in (0..n).step_by(4) {
let p = match (offset, vertical) {
(0, true) => left,
(0, false) => top,
_ => Some(q),
(0, true) => left.as_ref(),
(0, false) => top.as_ref(),
_ => Some(&q),
};
let Some(p) = p else {
continue;
Expand All @@ -122,7 +122,7 @@ pub(crate) fn picture(
(if edge == 0 { 3 } else { edge - 1 }) * 4 + segment,
)
};
*bs = strength(p, q, pi, qi, offset == 0)?;
*bs = strength(p, &q, pi, qi, offset == 0)?;
}
if params.bs == [0; 4] {
continue;
Expand Down Expand Up @@ -237,26 +237,26 @@ mod tests {
nonzero: 0,
};
let mut q = p;
assert_eq!(strength(p, q, 3, 0, true).unwrap(), 0);
assert_eq!(strength(&p, &q, 3, 0, true).unwrap(), 0);
for delta in [-4, 4] {
q.motion.vectors[0].x = delta;
assert_eq!(strength(p, q, 3, 0, true).unwrap(), 1);
assert_eq!(strength(&p, &q, 3, 0, true).unwrap(), 1);
q.motion.vectors[0].x = 0;
q.motion.vectors[0].y = delta;
assert_eq!(strength(p, q, 3, 0, true).unwrap(), 1);
assert_eq!(strength(&p, &q, 3, 0, true).unwrap(), 1);
q.motion.vectors[0].y = 0;
}
q.motion.vectors[0].x = 3;
q.motion.vectors[0].y = -3;
assert_eq!(strength(p, q, 3, 0, true).unwrap(), 0);
assert_eq!(strength(&p, &q, 3, 0, true).unwrap(), 0);
p.nonzero = 1 << 3;
assert_eq!(strength(p, q, 3, 0, true).unwrap(), 2);
assert_eq!(strength(&p, &q, 3, 0, true).unwrap(), 2);
p.nonzero = 0;
q.nonzero = 1;
assert_eq!(strength(p, q, 3, 0, true).unwrap(), 2);
assert_eq!(strength(&p, &q, 3, 0, true).unwrap(), 2);
p.motion.intra = true;
assert_eq!(strength(p, q, 3, 0, true).unwrap(), 4);
assert_eq!(strength(p, q, 3, 0, false).unwrap(), 3);
assert_eq!(strength(&p, &q, 3, 0, true).unwrap(), 4);
assert_eq!(strength(&p, &q, 3, 0, false).unwrap(), 3);
assert_eq!(TC0_1[33], 2);
assert_eq!(TC0_2[33], 2);
assert_eq!(TC0_3[33], 3);
Expand Down
7 changes: 7 additions & 0 deletions docs/design/h264-deblock-records.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Borrow deblocking records

The encoder keeps its current deblocking order, boundary strengths, thresholds and scalar pixel filter. This change borrows macroblock records while deriving each edge instead of copying their motion-vector arrays into edge and segment temporaries. Record lookup and the public encoder API stay unchanged.

This is an output-preserving optimization. Verification compares complete streams and reconstructions with the baseline, in dispatched and scalar builds at one, two, three and eight workers. Existing deblocking conformance and encoder fixtures remain required. Instruction ceilings and alternating one-worker and four-worker timing run on native x86-64 hosts before acceptance.

Pixel SIMD and overlap with row decisions are outside this change. They have separate safety and dependency requirements and are not needed to remove record copies.
Loading