code wiki / (root) / nx_vskip.nx

nx_vskip.nx source

↩ module page · 16 lines · 981 B

1// nx_vskip.nx -- sovereign SKIP-BLOCK coding (V-R6). When a block matches its motion prediction closely (residual 2// SAD below threshold) AND the motion vector is the predicted/zero MV, code it as a single 1-bit "skip" flag -- 3// no MV, no residual. A static scene -> almost every block skips -> a near-static frame costs a handful of bits 4// instead of the ~100 B per-block-overhead floor. This is the skip-MB the live codec needs. license_tier: ORIGINAL 5 6// returns 1 if the block should be SKIP-coded (1 bit), else 0 (code MV + residual normally). 7func vs_skip(residual_sad: i64, mv_dx: i64, mv_dy: i64, sad_thresh: i64) -> i64 { 8 if mv_dx != 0 { return 0 } 9 if mv_dy != 0 { return 0 } 10 if residual_sad > sad_thresh { return 0 } 11 return 1 12} 13// bits to code a frame: each skipped block = 1 bit, each coded block = avg_coded_bits. 14func vs_frame_bits(n_blocks: i64, n_skip: i64, avg_coded_bits: i64) -> i64 { 15 return n_skip + (n_blocks - n_skip) * avg_coded_bits 16}