edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
lane/proresfast report
Host: server b (AMD EPYC-Rome, 4 vCPU, shared; a few runs on host a were too loaded to use).
Bench: cargo test -p ec-prores --release --test perf -- --nocapture (1080p 422 HQ, noisy testsrc2, best of 10 passes of 24 frames).
Decode speed (1 thread / 4 threads, fps)
| 1 thread | 4 threads | |
|---|---|---|
| before (main) | 44.5 | 133.9 |
| after | 63.0 - 65.6 (target 60 met) | 95 - 170 (host load varies; 169.9 best, 134 and up when quiet) |
4-thread figures are noisy because other jobs share the server; the 1-thread figure was stable (+-2 fps). Output is bit-identical: all ec-prores tests, hash pins and ffmpeg parity tests pass.
What changed (ec-prores decode):
- Profiling by cycle counters: AC entropy decode was about 65% of a frame, IDCT about 12%, DC 5%.
- AC decode: 64-bit register bit buffer with branch-free refill (no per-coefficient load in the dependency chain), lookup tables hold code length, value and next-context offset (no clamps), three coefficients per refill.
- Two slices are decoded interleaved (
decode_slices,AcState) to overlap the latency-bound chains. - DC: 8-bit lookup tables per codebook.
- IDCT: explicit SSE2
std::archimplementation (x86_64 baseline, so no runtime detection is needed) with thewidecode kept as the portable fallback on other targets; the DC-only shortcut is detected inside the IDCT, so the per-coefficient non-zero mask is gone. The unit tests compare against the scalar reference (200k blocks, 10 and 12 bit). - Frame assembly: planes are written as little-endian bytes straight from the IDCT; a single-group progressive frame moves those buffers into the output (no row copy pass).
#![forbid(unsafe_code)]became#![deny(unsafe_code)]; the onlyallow(unsafe_code)is the SSE2 module in idct.rs.- AVX2 was not added: after the changes the IDCT is a small share and the entropy chain dominates.
Encoder
- Interlaced (field) coding for every profile: a frame with
interlaceTopFieldFirst/BottomFieldFirst is written as two field pictures (interlaced scan, frame_type 1/2, per-field picture headers, one frame-wide quantiser search). - 4444 and 4444 XQ alpha:
EncoderConfig::alpha_bits(8 or 16) andProResEncoder::encode_with_alpha(frame, Some(&AlphaPlane))(RDD 36 run-length alpha, 8-byte slice header, alpha bytes counted in the rate search).encode()writes opaque alpha. - Encode speed was not touched (1080p HQ, 4 threads: 48.7 fps on host b).
Checks (tests added in crates/ec-prores/tests/encode.rs, ffmpeg 8.1.3)
interlaced_every_profile_ffmpeg_and_ours_agree: all 6 profiles, TFF and BFF, 331x75: ffprobe frame fields show interlaced_frame=1 and the right top_field_first; ffmpeg and ec-prores decode byte-identically; PSNR vs source > 34 dB; output independent of thread count. (Stream-levelfield_orderstays "progressive" because the mov muxer writes nofielatom; the order is in the ProRes frame header and in the decoded frames.)interlaced_fields_are_coded_separately: field-different content, 74.0 dB with field coding against 69.0 dB progressive.alpha_4444_round_trips_and_ffmpeg_agrees: 4444 and XQ, alpha 8 and 16 bit, progressive and BFF: ffprobe pix_fmt yuva444p12le, our decoder returns the alpha exactly (16-bit) or the replicated 8-bit value, ffmpeg and ec-prores agree byte for byte on Y/U/V/A, PSNR > 34 dB; no alpha plane gives fully opaque alpha.alpha_config_is_validated.- Gate:
cargo clippy --workspace --all-targets -- -D warningsclean;EC_REQUIRE_FIXTURES=1 cargo test -p ec-prores --releaseall pass. - All media is synthetic (generated in the tests, ffmpeg testsrc2/mandelbrot).