Commits
2026-11-25
2026-11-08
Encoder fixes from round-trip sweep follow-upAhmet Kaan Gümüş · f849ee9
Encoder fixes from round-trip sweep follow-up - ec-opus: 40/60 ms CELT/Hybrid as code-3 packets of 20 ms frames; self-delimited framing for code-3 packets (multistream 40/60 ms); multistream buffer sized for 60 ms - ec-image GIF: pixels turning transparent re-emit the previous frame with disposal 2 over the cleared area - ec-mp3: padding bit at 44.1/22.05/11.025 kHz - ec-aac: refuse bitrate 0 - ec-vorbis: refuse non-finite quality - ec-h264: refuse non-positive frame rate instead of clamping to 1 - ec-av1: with_pyramid doc matches behaviour (mini_gop > gop is clamped)
2026-10-23
Restore edith_codecs after local data loss (2026-10-23)Ahmet Kaan Gümüş · b7434a2
Restore edith_codecs after local data loss (2026-10-23) On 2026-10-23 an automated agent ran `rm -rf $HOME` and deleted the local repository with all of its history. This commit restores the working tree from the newest surviving copy, the host-c server lane mirror. That mirror matches local main as of the testcut Phase 2 reports, including the tool cache, the nextest fast profile and changed-crates.sh. The history before this commit was not recovered.
2026-10-03
h26xpinloud: the h26x test pins fail loudly on an Ok-but-short writeAhmet Kaan Gümüş · 3aa53dd
h26xpinloud: the h26x test pins fail loudly on an Ok-but-short write ec-av1 already owns this class (dumpio::LoudDump: declare the expected byte count, write, then stat the file's own length). These two crates had no shared helper, so four sites called fs::write directly: ec-h264/tests/encode.rs:475 ffmpeg_decode -> ffmpeg -i <stream> ec-h264/tests/encode.rs:1068 x264_encode_qp -> ffmpeg -i <raw> ec-h265/tests/encode.rs:289 ffmpeg_decode -> ffmpeg -i <stream> ec-h265/tests/encode.rs:341 x265_encode_qp -> ffmpeg -i <raw> Each was fs::write(&path, bytes).ok()?. That closes the Err path; the Ok-but-short path stayed open, and it is the one that hands another tool a silently truncated stream, which then reads as a wrong pixel or a shifted PSNR number rather than a write failure. Measured: 1234 bytes written through a path that looks like a stream file but whose filesystem accepts every byte and stores none returns Ok, and the file on disk is 0 bytes. Each site now goes through a per-crate pin_loud: write, then check the on-disk length against the same bytes.len() the writer used, and fail with the path, both counts, and the OS error. The helper returns the failure LINE, not a panic, because these callers bail (or, at one h264 site, turn None into a SKIP) today and that semantics is kept -- the shortfall is printed in full and the existing bail stands. Only write_au panicked before, so only it gets the panicking twin. The helper is local per crate (no cross-crate dep, no new support crate): ec-h265 keeps it in tests/common/mod.rs because its fifth site lives in a different test binary, ec-h264 keeps it in tests/encode.rs where both of its sites are. Two non-vacuity tests per crate: a /dev/null symlink reproduces a genuine Ok-but-short (0 of 1234), with a whole-file control read back byte for byte; and a child under `ulimit -f 1` with SIGXFSZ ignored proves the Err arm reports what actually LANDED (512 of 4096, EFBIG) rather than the count the writer confirmed. Deleting the check turns the first RED. Sweep of both crates: five sites fixed (the four named plus ec-h265's write_au, File::create + write_all, whose path goes to ffmpeg the same way), and one more -- ec-h264's append-mode $EC_H264_RD_TRACE writer, which discarded its write result -- made fatal instead, because append mode has no knowable total and so admits no length check. Everything else in the two crates is ffmpeg's own output, a read-only path, a directory, or an in-memory BitWriter. Success path byte-identical: same bytes, same path, truncate-then-write.
2026-08-25
feat(h264): 8x8 transform on by defaultAhmet Kaan Gümüş · e6fcc5c
feat(h264): 8x8 transform on by default x264 codes the 8x8 transform by default at every preset that reaches High profile, and measured on the library clips the flag is worth +0.716 dB BD-PSNR on a 3840x1608 film clip (18.1% of macroblocks take the 8x8 path) and +0.183 dB on a 2560x1440 screen capture (8.8%). With it on, the encoder's whole-picture comparison against x264 over q22/26/30/34 moves from -0.186 dB to +0.513 dB on the film clip and from -0.482 dB to -0.315 dB on the screen capture. Every default stream now carries profile_idc 100 and the High-profile SPS tail. `production_lambda_tracks_transform_mode` asked the default config for the 4x4 lambda, so it now clears the flag itself first.
2026-08-24
perf(h264): choose chroma_qp_index_offset from the sourceAhmet Kaan Gümüş · eb83b6f
perf(h264): choose chroma_qp_index_offset from the source The offset was a hardcoded 0 in the PPS. Sweeping it showed the optimum is not a constant: a film clip is best at 0 and loses 0.16 dB at -2, while every screen capture and phone clip gains, one of them by 0.23 dB. What separates them is how textured the chroma planes are relative to luma — flat chroma is what wants the extra chroma bits, because its few edges are all the eye has to read there, and film's chroma carries as much detail as its luma, where the same bits buy more. So measure it: mean absolute sample gradient of the chroma planes over that of luma, taken on the first source picture, and code at -2 below half. The offset now reaches the PPS, the encoder's own chroma QP derivation and the deblocking parameters of every slice it writes, so reconstruction still matches a decode exactly. BD-PSNR-YUV against x264 (GOP 10, QP 22/26/30/34, Preset::Balanced) over nine clips, before -> after: -0.504 -> -0.504 (film, keeps 0), -0.406 -> -0.227, -0.495 -> -0.268, -0.601 -> -0.570, -0.639 -> -0.575, -0.931 -> -0.886, -0.510 -> -0.491, -0.352 -> -0.340, -0.376 -> -0.300. The rule reproduces each clip's own swept optimum.
2026-08-21
2026-08-20
feat(h264-enc): Intra_8x8 prediction and the 8x8 transform for inter residuals, chosen on rate-distortion costAhmet Kaan Gümüş · 4e4673b
feat(h264-enc): Intra_8x8 prediction and the 8x8 transform for inter residuals, chosen on rate-distortion cost transform_size_8x8_flag now follows a real decision: Intra_8x8 is coded alongside Intra_4x4 and Intra_16x16 (decoder's filtered reference samples and neighbour-mode rule), P macroblocks try both transform sizes on the same prediction, and the residual writer takes the cat-5 / interleaved path. Encoder::transform_8x8_mbs() counts what was chosen; the reconstruction, ffmpeg and VA-API gates run with 8x8 macroblocks present.
feat(h264-enc): transform_size_8x8_flag emission + cat-5 / interleaved-CAVLC 8x8 residual writers (E3)Ahmet Kaan Gümüş · 655dfcc
feat(h264-enc): transform_size_8x8_flag emission + cat-5 / interleaved-CAVLC 8x8 residual writers (E3) Flag written (always 0 for now) wherever the decoder reads it under transform_8x8_mode_flag; CABAC residual_block_8x8 mirrors the decoder's cat-5 path (no coded_block_flag for 4:2:0); CAVLC sub_block_4x4 interleave helper. Round-trip unit tests through the decoder's own readers; encode integration tests gain transform_8x8=true variants.
feat(h264-enc): High-profile SPS/PPS tail + 8x8 forward transform/quant (E1+E2)Ahmet Kaan Gümüş · 250a6ac
feat(h264-enc): High-profile SPS/PPS tail + 8x8 forward transform/quant (E1+E2) SPS/PPS now write the High-profile 8x8-transform syntax (profile_idc 100, chroma/bit-depth/scaling-matrix fields, transform_8x8_mode_flag) behind a new EncoderConfig::transform_8x8 flag, and quant.rs gains forward_8x8/quant_8x8: an exact algebraic inverse of the decoder's idct8_1d (verified by rational matrix inversion, not a hand-tuned butterfly, since the small-integer transpose leaks ~15% between frequencies — too much for full-range residuals) paired with a plain-division dead-zone quantiser against the existing LevelScale8x8/dequant_8x8. transform_8x8 is NOT yet safe to turn on for a real encode: a conformant decoder unconditionally expects a transform_size_8x8_flag per eligible macroblock once the PPS advertises it (7.3.5), and enc::entropy/enc::mb don't write that bit yet (confirmed by a failing round trip, not left implicit). That emission, and the mode decision that actually picks 8x8 blocks, are later work.
2026-08-14
feat(h264): CABAC encoding, Main profile by defaultAhmet Kaan Gümüş · 466f297
feat(h264): CABAC encoding, Main profile by default The incumbent this encoder replaces writes High-profile CABAC; writing CAVLC against it costs roughly 12% of the bitrate at the same reconstruction, which no amount of mode-decision work makes back. That was the whole screen-capture quality gap. The encoder is the write side of the decoder's own CABAC: context initialisation, the ctxIdx offsets, the ctxIdxInc derivations and the block categories all come from crate::cabac, and the arithmetic encoder of 9.3.4 mirrors the decoder of 9.3.3 step for step. A single wrong context desynchronises the coder inside a macroblock, so the reconstruction test is what holds the two together. Slice data changes shape with the coder -- mb_skip_flag for mb_skip_run, end_of_slice_flag after every macroblock, cabac_alignment_one_bit before the first -- so the macroblock coder now writes syntax elements through one surface (enc::entropy) rather than bits, exactly as the decoder reads them through crate::entropy. Measured at matched bitrate, 1080p Fast: +1.1 dB on a screen capture and +0.25 dB on camera content. CAVLC stays available (EncoderConfig::cabac) and is covered by the same round-trip sweep.
feat(h264): software encoder, I and P pictures, CAVLC, slice-parallelAhmet Kaan Gümüş · 6d22228
feat(h264): software encoder, I and P pictures, CAVLC, slice-parallel The encoder shares the decoder's reconstruction rather than owning one: prediction (pred, inter), dequantisation and the inverse transforms (transform), the deblocking filter and the per-macroblock metadata are the decoder's own code and the decoder's own Picture. What is new here is the forward direction — forward transforms and quantisation (quant), CAVLC writing derived at compile time from the decoder's tables (vlc), parameter sets and slice headers (headers), mode decision and macroblock coding (mb), and rate control (rc). Scope: Baseline-profile syntax (8-bit 4:2:0 progressive, CAVLC, one reference, pic_order_cnt_type 2), intra 16x16 and 4x4 with chroma modes, P_Skip and P_L0_16x16 with a diamond search to quarter sample, and CBR rate control with a per-macroblock-row correction. Coding a picture as one slice per worker gives the parallelism inside the encoder: a slice is independent by definition, so every worker owns its picture buffer and its bitstream, and the bands are stitched and filtered once at the end. B pictures and CABAC are not coded yet; the bframes field is accepted and coded as zero rather than refused.