ec-vp8 M3: long MV components read bits 9,8,7,6,5,4 (mvlong_width=10) — bit 9 was missing
Browse files at this commitd5796e3313c9d3b8813b77eb268664c2d729d51cParent: 12884f54 changed files +14 -2
- crates/ec-vp8/src/decode.rs +4 -0
- crates/ec-vp8/src/modes.rs +1 -1
- crates/ec-vp8/src/tokens.rs +6 -0
- scripts/vp8ref_model.py +3 -1
crates/ec-vp8/src/decode.rsmodified+4 -0
| @@ -557,6 +557,10 @@ impl Decoder { | ||
| 557 | 557 | header.refresh.sign_bias_altref, |
| 558 | 558 | ]; |
| 559 | 559 | |
| 560 | + // §13.3: non-existent neighbours are empty — the above context | |
| 561 | + // is cleared at every frame start, like the key-frame path. | |
| 562 | + self.token_ctxs.reset_above_row(); | |
| 563 | + | |
| 560 | 564 | // Phase 1: every mode record of the frame, row-major (§16). |
| 561 | 565 | eprintln!("STAGE modes"); |
| 562 | 566 | for row in 1..=self.mb_rows { |
crates/ec-vp8/src/modes.rsmodified+1 -1
| @@ -356,7 +356,7 @@ pub fn read_mv_component(d: &mut BoolDecoder<'_>, probs: &[u8; MVP_COUNT]) -> i1 | ||
| 356 | 356 | for i in 0..3 { |
| 357 | 357 | x += i32::from(d.read_bool(probs[MVP_BITS + i])) << i; |
| 358 | 358 | } |
| 359 | - let mut i = 8; | |
| 359 | + let mut i = 9; | |
| 360 | 360 | loop { |
| 361 | 361 | x += i32::from(d.read_bool(probs[MVP_BITS + i])) << i; |
| 362 | 362 | i -= 1; |
crates/ec-vp8/src/tokens.rsmodified+6 -0
| @@ -268,7 +268,13 @@ pub(crate) fn decode_mb_tokens( | ||
| 268 | 268 | let n0 = usize::from($ptype == 0); |
| 269 | 269 | let (l, a) = ctxs.ctx_pair(mb_col, $idx); |
| 270 | 270 | let ctx = (usize::from(l) + usize::from(a)).min(2); |
| 271 | + if std::env::var_os("EC_VP8_TRACE").is_some() { | |
| 272 | + eprintln!("TB {} ctx={} l={} a={}", $idx, ctx, l, a); | |
| 273 | + } | |
| 271 | 274 | let eob = get_coeffs(bc, &probs[$ptype], ctx, n0, $dc, $ac, $slot); |
| 275 | + if std::env::var_os("EC_VP8_TRACE").is_some() { | |
| 276 | + eprintln!("TBE {} eob={}", $idx, eob); | |
| 277 | + } | |
| 272 | 278 | out.eobs[$idx] = eob as u8; |
| 273 | 279 | let t = u8::from(eob > 0); |
| 274 | 280 | ctxs.set_ctx(mb_col, $idx, t); |
scripts/vp8ref_model.pymodified+3 -1
| @@ -299,7 +299,7 @@ def main(): | ||
| 299 | 299 | x = 0 |
| 300 | 300 | for i in range(3): |
| 301 | 301 | x += d.bool(p[9 + i]) << i |
| 302 | - for i in (8, 7, 6, 5, 4): | |
| 302 | + for i in (9, 8, 7, 6, 5, 4): | |
| 303 | 303 | x += d.bool(p[9 + i]) << i |
| 304 | 304 | if (x & 0xFFF0) == 0 or d.bool(p[9 + 3]): |
| 305 | 305 | x += 8 |
| @@ -610,8 +610,10 @@ def main(): | ||
| 610 | 610 | def one(blkidx, ptype, n0): |
| 611 | 611 | o = [0] * 16 |
| 612 | 612 | ctxv = min(2, left_ctx[LEFT[blkidx]] + above_ctx[c - 1][ABOVE[blkidx]]) |
| 613 | + print(f"TB {blkidx} ctx={ctxv} l={left_ctx[LEFT[blkidx]]} a={above_ctx[c - 1][ABOVE[blkidx]]}") | |
| 613 | 614 | print(f"T {r-1} {c-1} {blkidx} {ptype} {ctxv}") |
| 614 | 615 | eob = get_coeffs(ptype, n0, ctxv, o) |
| 616 | + print(f"TBE {blkidx} eob={eob}") | |
| 615 | 617 | t = 1 if eob > 0 else 0 |
| 616 | 618 | left_ctx[LEFT[blkidx]] = t |
| 617 | 619 | above_ctx[c - 1][ABOVE[blkidx]] = t |