forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

rdoq_cache_hash.rs70 lines, 3.2 KiBHistoryRawDownload
1//! lane-h265rdoq r3: the sub-block frozen-prefix cursor must not change a
2//! single output byte. Hashes two natural-content encodes (1920x1080 and
3//! 416x240) with FNV-1a; the number itself means nothing, only that it is the
4//! same before and after this round's change to `rdoq()` (checked by hand:
5//! stash `residual.rs`, rerun, compare).
6
7use crate::common::{fnv1a, natural_frame};
8use ec_h265::encoder::{Encoder, EncoderConfig, RateControl};
9
10fn encode_hash(width: u32, height: u32) -> u64 {
11 let mut cfg = EncoderConfig::new(width, height);
12 cfg.rate_control = RateControl::ConstantQp(24);
13 cfg.threads = 1;
14 let encoder = Encoder::new(cfg).expect("encoder");
15 let mut all = Vec::new();
16 for i in 0..3u32 {
17 let frame = natural_frame(width, height, i * 5);
18 all.extend(encoder.encode_idr(&frame).expect("encode").au);
19 }
20 fnv1a(&all)
21}
22
23#[test]
24fn rdoq_cache_hash_1920x1080() {
25 println!("hash 1920x1080 = {:016x}", encode_hash(1920, 1080));
26}
27
28#[test]
29fn rdoq_cache_hash_416x240() {
30 println!("hash 416x240 = {:016x}", encode_hash(416, 240));
31}
32
33/// lane-h265simd: pinned bit-identity gate for the transform's hot path. The
34/// value is the same hash the two tests above print, verified by hand
35/// (`git stash` the transform.rs change, rerun, compare) to be identical
36/// before and after replacing `m32()`'s per-element branch with a
37/// compile-time-mirrored flat table in `forward_1d`/`inverse_1d` — this pins
38/// that equality so a future change to the hot path is caught if it ever
39/// produces a different byte.
40///
41/// lane-h265prune: re-pinned after the RQT split trial gained an all-zero-CBF
42/// early out (mirrors the CU-quadtree's existing `last_cu_empty` skip one
43/// level down at the transform tree): a coding unit whose luma+chroma already
44/// quantised to nothing is committed as one leaf transform unit without
45/// trying the four-child split first, since splitting a zero-SSD block can
46/// only add split_transform_flag and mode-signalling bits. This changes the
47/// bitstream on any content where that trial used to flip a leaf to split
48/// (BD-gated, not bit-identical — see `EncoderConfig::rqt` and this crate's
49/// `bd_psnr_vs_x265`).
50///
51/// lane-h265rdoq: re-pinned after RDOQ's trial costing switched from exact
52/// per-trial CABAC replay to an estimated per-context fracbits table
53/// (`EncoderConfig::rdoq_estimate`, now on by default) — deliberately
54/// bit-different, not exact-mode-preserving; see that field's doc comment
55/// for the BD/speed numbers that justified flipping the default.
56///
57/// lane-h265screen: re-pinned after every committed 4x4 luma block gained a
58/// rate-distortion decision on `transform_skip_flag` (`TransformSkip::Rd`, now
59/// the default) — deliberately bit-different; see that field's doc comment for
60/// the BD numbers per clip.
61///
62/// lane-hevcenctools: re-pinned after the sequence parameter set's
63/// `sps_temporal_mvp_enabled_flag` went on, which the P pictures' slice headers
64/// need. That is one SPS bit; the intra slices are otherwise unchanged, and the
65/// 9203-picture conformance check still matches.
66#[test]
67fn rdoq_cache_hash_is_pinned() {
68 assert_eq!(encode_hash(416, 240), 0xd501713b57091906);
69 assert_eq!(encode_hash(1920, 1080), 0x5eb50f5a747ca1c2);
70}