Commits
Commits on
01987f4538bf8faf87f4dfb9f380a89d114dcf742026-08-19
fix(ec-aac): bound the HF LPC predictor so it cannot divergeAhmet Kaan Gümüş · 01987f4
fix(ec-aac): bound the HF LPC predictor so it cannot diverge sbr_hf::lpc2 solves a covariance-method normal-equation system, which carries no built-in stability guarantee the way the spec's own Levinson-Durbin reflection coefficients do. Clamp |a1|+|a2| below 1 (a standard sufficient BIBO bound) before the coefficients feed the per-frame y = residual + ca1*y[n-1] + ca2*y[n-2] resynthesis recursion. Measured effect on the real-file sweep: none -- output rms before and after is bit-identical, so the clamp never actually triggers on these two files and the catastrophic energy blowup seen in that sweep (rms up to ~1e6 against ~0.2 for a correct decode) lives somewhere else. Kept anyway as a real, spec-honest gap this module had; see sbr_real_library.rs for where the actual fault is now localized to for the next pass.
test(ec-aac): reach the SBR chain from real HE-AAC files, not just ADTS fixturesAhmet Kaan Gümüş · 5bbfe62
test(ec-aac): reach the SBR chain from real HE-AAC files, not just ADTS fixtures tests/oracle.rs remuxes every source to bare ADTS before decoding, and ADTS carries no AudioSpecificConfig, so with_config_bytes()/set_sbr_rate() never armed and no existing test exercised the SBR path at all. This adds a container-native harness (ec-mp4/ec-matroska as dev-deps, via the shared Demuxer trait) that pulls the real esds/CodecPrivate AudioSpecificConfig and access units out of whichever real HE-AAC files a live library sweep finds, decodes them through with_config_bytes, and compares against the reference decoder by lag-searched correlation, split into below/above-crossover bands for localization. Skips loudly when ffmpeg or no such files are present.
feat(aac): wire SBR HF gen + envelope adjustment into the decode chainAhmet Kaan Gümüş · 5206266
feat(aac): wire SBR HF gen + envelope adjustment into the decode chain sbr_chain.rs ties sbr_payload/_hf/_env/_qmf together per element: a FIL element's sbr_extension_data (explicit ASC signaling only, no implicit ADTS detection yet) drives 32-band analysis of the preceding SCE/CPE's core PCM, HF generation, envelope adjustment, and 64-band resynthesis, replacing that element's plane with double-rate PCM. SbrSupport gains a V1 variant (PS still reports CoreOnly); output_sample_rate now reports the extension rate for a reconstructed stream. sbr_is_reported_not_silently_upsampled is updated (not deleted) to pin the new contract, plus a PS case. Not yet exercised: real-file oracle correlation (next commit), implicit ADTS SBR signaling (deferred, named follow-up per charter), filterbank delay compensation for packet timestamps (open -- see report).
feat(aac): SBR HF generation and envelope adjustment, unwiredAhmet Kaan Gümüş · 49f840b
feat(aac): SBR HF generation and envelope adjustment, unwired
sbr_hf.rs: patch construction (copy-up from below kx into [kx,k2)
aligned to f_high borders), order-2 complex covariance LPC per source
subband, and bandwidth-expanded ("chirped") whitening driven by
bs_invf_mode with fast-attack/slow-release smoothing.
sbr_env.rs: envelope/noise dequantization (including a best-effort
symmetric coupled-CPE balance de-mix, corner-cut noted -- no real-file
fixture exercises it yet), per-(envelope,band) gain toward the
transmitted energy with a noise-floor-relative limiter, noise
injection and add_harmonic sinusoids.
Neither module is wired into the decoder yet (next commit); both carry
their own unit tests and compile clean.chore(aac): allow dead_code on the unwired QMF module, keeping the crate gate greenAhmet Kaan Gümüş · 2ebc6c0Browse files
feat(aac): the SBR QMF filterbank pair, phase convention and prototype closedAhmet Kaan Gümüş · f29cb75
feat(aac): the SBR QMF filterbank pair, phase convention and prototype closed The odd-stacked complex-exponential phase reference needed +bands/2, not -bands/2 (found by a brute-force sweep over the small discrete convention space against the round-trip correlation itself); with that settled, a Kaiser-beta sweep against the same metric closed the residual prototype-shape gap. Round trip now correlates 0.999949 (bar 0.9999) at a measured 898-sample delay, and the impulse test's in-band frequency window is resynced to the synthesis bank's own omega_step.
feat(ec-aac): the SBR payload parser -- bitstream to dequantized envelope/noise intsAhmet Kaan Gümüş · 6a3d21e
feat(ec-aac): the SBR payload parser -- bitstream to dequantized envelope/noise ints sbr_payload.rs parses sbr_header (persisted across frames) and sbr_data for SCE and CPE (coupled and uncoupled), all four grid classes, dt/df envelope and noise coding through the twelve Huffman books, and extension payloads by their own length. Stops at exact integer scalefactors/noise floors -- no QMF, no gain application. Field widths and grid-class bit layout checked against a reference decoder's own byte accounting via scripts/aac-tables/sbrpayload_fixtures.py (same method as sbrtables.py's codebook derivation), which also generates the byte-exact test fixtures embedded in the module's test module.
feat(aac): the SBR frequency-band derivation, ported from the validated rigAhmet Kaan Gümüş · 3a933f6
feat(aac): the SBR frequency-band derivation, ported from the validated rig The master/high/low/noise band tables as the probe rig derived and proved them — 6387/6387 header configurations agree with the reference parser — carried over with 500 embedded cross-check vectors generated by the rig's own function. Not yet consumed by a decode path.
feat(ec-aac): close the eight envelope SBR Huffman codebook valuesAhmet Kaan Gümüş · 86f03f9
feat(ec-aac): close the eight envelope SBR Huffman codebook values The values-stage classifier misread the reference decoder's unconditional "channel element 0.1 is not allocated" complaint (fires on every mono sce probe regardless of range) as a crash signal, hiding in-range codewords as gaps; the discriminator is now whether the parser's byte count matches the full predicted frame length. ENV30_F/ENVB30_F needed their own two-envelope probe config since a lone envelope always forces the 1.5 dB resolution. All twelve SBR codebooks now close with Kraft sum 1 and full values.
feat(ec-aac): derive four SBR noise Huffman codebooks, black boxAhmet Kaan Gümüş · c53ad6b
feat(ec-aac): derive four SBR noise Huffman codebooks, black box
Wires the SBR table-derivation rig's widths/books/values stages into its
CLI and adds the value-assignment stage (bisecting a codeword's raw start
value to the reference decoder's own range-check boundary), then emits
the codebooks that closed with a complete, fully-valued prefix code:
NOISE_T, NOISE_F, NOISEB_T, NOISEB_F. The eight envelope books derive
lengths cleanly but each hit at least one codeword whose value probe
crashes the reference decoder rather than range-checking gracefully
("channel element 0.1 is not allocated"); they are left out of
sbr_tables.rs rather than shipped with a guessed value, per the rig's own
rule against fabricating table entries.shim(image): declare the no-op format features a consumer namesAhmet Kaan Gümüş · 0eae21cBrowse files
chore(aac): SBR codebook derivation, staged sweep/lengths/values over the byte-accounting oracleAhmet Kaan Gümüş · 17d3de1Browse files
test(hw): the reference feed keeps the film's own cadence, and RSS is measured aloneAhmet Kaan Gümüş · 3c2d14b
test(hw): the reference feed keeps the film's own cadence, and RSS is measured alone Three fixes to the live GPU suite: - the reference decode now passes pictures through at their coded cadence instead of conforming to the container's nominal rate, which duplicated or dropped frames on films whose real cadence differs and read as every frame being one off from some point onward - elementary-stream extraction is bounded to the frames under comparison plus a reorder margin, instead of piping a whole feature film through memory - the resident-set leak check re-runs itself in a child process: VmRSS is process-wide, and a sibling test allocating between baseline and end showed up as a 200 MB leak that no code caused
2026-08-14
shim(ruopus): the Opus decoder seat edith consumes, over ec-opusAhmet Kaan Gümüş · 88cf2a7
shim(ruopus): the Opus decoder seat edith consumes, over ec-opus The last audio shim the replica's [patch.crates-io] table was missing. It is one re-export -- `MultistreamDecoder` -- because `ec-opus`'s already has the incumbent's signature and, more to the point, its semantics: `with_rate(rate, streams, coupled, &mapping)` with the same layout rules and the same panic on one the RFC forbids, and output in the *mapping's* channel order rather than the product's. That last one is the only decision here. Both decoders emit Vorbis order for RFC 7845 family 1 (FL, FC, FR, BL, BR, LFE), and edith permutes it into film order at the call site (`audio.rs:vorbis_to_film_order`), so the shim permutes nothing: putting it here would fold every surround track twice. The doc comment says so, since a future reader's first instinct will be to move it. The incumbent's feature names are declared and empty. `spectrograms` was its FFT backend, default-on because CELT synthesis is an N/4 complex FFT per block and the fallback decoded a 5.1 film at 0.95x realtime; the transform behind this crate is not behind a feature at all. They are declared regardless because a [patch.crates-io] consumer that names a feature the patch lacks fails to *resolve*.
perf(h265): 32x32 coding trees by default, for the wavefront rowsAhmet Kaan Gümüş · 7a75a9b
perf(h265): 32x32 coding trees by default, for the wavefront rows The wavefront hands one CTB row to a worker, so the tree size sets the parallelism: 1080 lines are 17 rows at CTB 64 but 34 at 32, and 17 rows dealt round-robin over twelve workers leaves seven of them holding half the work of the other five. Measured at 1080p QP 27: the sizes are identical on one thread (1.80 fps each) and 9.03 vs 7.92 fps on twelve, for 1.0% more bits and 0.02 dB less PSNR. Both numbers are now tests: perf.rs measures the two sizes alternately so a drifting machine load cannot favour whichever ran first, and conformance.rs bounds the bits and the PSNR against 64. The ffmpeg bit-exactness oracle now codes shapes at both tree sizes. The bigger figure that prompted this (3.5 vs 11.8 fps) was an end-to-end export at QP 40 on real content, not this crate's pure-encode harness.
shim(oxideav-core): drop the arms only the vendored H.265 tree neededAhmet Kaan Gümüş · d8c174c
shim(oxideav-core): drop the arms only the vendored H.265 tree needed The replica's software HEVC seat is the family's own intra encoder now, named as a path dependency rather than reached through this shim, so the surface it alone consumed is dead: the registration context and the `register!` macro, the `Encoder` trait with its factory and the two `CodecInfo` builders that carried them, the container-level codec tags, the pixel format and the string-keyed codec options. What the subtitle, AC-3 and Ogg shims speak is untouched: the registry, the `Decoder` trait, `CodecInfo::decoder`, the frames, the packets and the muxer. An item nobody calls is an item nobody can check, which is what this file's own header says it will not carry.
fix(hw): HEVC picture order counts follow prevTid0Pic, not the last pictureAhmet Kaan Gümüş · 5f55768
fix(hw): HEVC picture order counts follow prevTid0Pic, not the last picture A 4K HDR release decoded at 19 dB against the software decoder: right most of the time, wrong wherever it mattered. Two clauses, one cause. 8.3.1 predicts the picture order count MSB from `prevTid0Pic` — the previous picture with TemporalId 0 that is neither a leading picture nor a sub-layer non-reference. Predicting from the previous picture instead works on a stream without temporal sub-layers (every fixture here) and puts the MSB a wrap out on one that has them, which hands the driver the wrong references and the wrong output order. The same NAL types say which pictures may be referenced at all: a "_N" type is a sub-layer non-reference, and storing it as a short-term reference lets the next picture's reference picture set match it by picture order count. Also passes `st_rps_bits` through, so a driver that skips a reference picture set the slice header carried itself knows how long it was, and adds an `EC_HW_DEBUG` trace of the per-picture DPB state — this bug was found with it. Five files from the real library now decode identically to the software decoder, including the one that failed: 2160p HEVC Main10 HDR, 1080p HEVC 10-bit, 1080p AV1 10-bit and two 1440p H.264 screen captures.
shim(rusty_h264): a whole Annex B stream decodes in one callAhmet Kaan Gümüş · e63caff
shim(rusty_h264): a whole Annex B stream decodes in one call `Decoder::decode_stream` is the one piece of the incumbent's surface the shim had missed, and edith's `tests/hw_encode.rs` is what asks for it: it holds a hardware encoder's whole output in a `Vec` and decodes it back in software, with no demuxer to hand over one access unit at a time. The NAL loop `decode` already ran is now `feed`, shared by both: pictures close where a picture boundary says they do, and `decode_stream` collects after a `flush`, so the last picture -- and anything a reordering delay still holds -- comes back with the rest.
chore(aac): SBR probing rig, and what it has established so farAhmet Kaan Gümüş · 838fa63
chore(aac): SBR probing rig, and what it has established so far Not an implementation of SBR: a bench for one. The core AAC-LC writer and the FIL framing are correct and the reference decoder parses the sbr_header this builds -- it answers a deliberately invalid start_freq with a complaint about n_master. sbr_data is not accepted yet; the decoder consumes sixteen bits more than the writer emits, which is where the envelope codebooks would be read. What that decoder reports is the useful part: the exact byte count its parser consumed. That is the same kind of cheap, exact observable the AAC codebooks were derived through, so the ten SBR codebooks have an instrument waiting for them. The measurements that scope the work are in the module docstring rather than in anyone's memory.
test(hw): live GPU tests against ffmpeg, and Annex B fixturesAhmet Kaan Gümüş · 43c8097
test(hw): live GPU tests against ffmpeg, and Annex B fixtures Every test here talks to the real driver — a hardware crate whose tests do not touch the hardware tests nothing — and none is `#[ignore]`d; they skip when there is no VA display or the fixtures are missing. ffmpeg's software decoder is the oracle: each fixture is decoded both ways and compared frame by frame, at the stream's own bit depth (converting a 10-bit reference down to 8 dithers, which would hide a real difference behind a fake 53 dB one). Alongside the four codecs: the `frame_num` gap synthesis, a 719-frame decode-and-read-back loop watching `VmRSS`, the DRM PRIME export, the encoders round-tripping through ffmpeg *and* through this crate's own decoder, and a spot check against his real library rather than the fixtures alone. `scripts/gen-bitstream-fixtures.sh` gains the H.264 and HEVC elementary streams — including B-frame clips, so output reordering is exercised rather than assumed.
feat(hw): hardware encoding for H.264 and HEVC, AV1 behind an opt-inAhmet Kaan Gümüş · 7368f27
feat(hw): hardware encoding for H.264 and HEVC, AV1 behind an opt-in IDR-then-P with a single reference, CQP or CBR, one frame in and one coded frame out. HEVC encoding is in the tree rather than on a branch, which is the whole point of writing this one: the conformance window is a field of the sequence, so 1916x1080 comes out the size it went in. The packed headers are the application's job here. This driver advertises `SEQUENCE | PICTURE | SLICE` and then writes none of them itself, so the crate writes the H.264 parameter sets and slice headers, and reuses `ec-h265-syntax` for the HEVC ones — the same code that parses them. Two driver behaviours are pinned down by comment where they were found by measurement: the parameter sets only reach the stream when a slice header accompanies them, and the HEVC slice header this driver composes omits `slice_loop_filter_across_slices_enabled_flag`, so the PPS has to say the flag is absent or every P picture decodes as `alignment_bit_equal_to_one = 0`. AV1 encoding is refused unless a caller sets `allow_av1`. That guard is not caution for its own sake: a probe at the driver's own minimum encode size took the GPU down with a hard recovery on 2026-08-14, and there is no error to return from a context that no longer exists.
feat(hw): stateless decoding for H.264, HEVC, VP9 and AV1Ahmet Kaan Gümüş · eb589d4
feat(hw): stateless decoding for H.264, HEVC, VP9 and AV1 One decoder per codec behind one `Decoder`. The driver keeps nothing between pictures, so everything the format spreads across frames lives here: the H.264 decoded picture buffer with its picture order counts, reference numbering, list initialisation and modification and marking (clause 8.2); HEVC's reference picture sets and bumping; VP9's and AV1's reference slots with `show_existing_frame`. Frames leave in display order. Three of the four incumbent defects are addressed by construction: - The RT format follows the *stream's* bit depth, so a Main10 stream gets a 10-bit config and a P010 surface instead of losing two bits per sample. - A `frame_num` gap is a normal condition — a seek, a lost packet, an encoder that skipped a picture — and the missing pictures are inferred per 8.2.5.2 rather than ending the hardware session. The inferred frames share the newest reference's surface, which is both a better guess than grey and the only choice this driver accepts. - Surfaces come from a pool and mappings are guards, so a long export neither reallocates nor leaks. The scaling matrices are sent for every H.264 picture whether or not the stream carries any: a driver that never receives them dequantises with a zero matrix and hands back a uniformly grey frame.
feat(hw): the VA-API parameter buffers, surface pool and frame readbackAhmet Kaan Gümüş · 89d28a7
feat(hw): the VA-API parameter buffers, surface pool and frame readback The foundation of the hardware crate: every codec parameter struct libva defines for the paths this family uses, transcribed by hand from the system headers and checked field for field by a `const` assertion against `crates/ec-hw/abi-probe.c`. A transcription slip is a compile error rather than a driver reading garbage. Around them: - `SurfacePool`, which allocates once and recycles: a surface returns to the free list when the reference buffer and the caller are both done with it, so nothing leaks and nothing is reallocated per frame. - `Frame`, with the two ways to reach the pixels — DRM PRIME export for the zero-copy path, and `vaGetImage` readback into I420 (8 or 10 bit) for callers that want the samples. The readback image is created once per stream: one `vaCreateImage`/`vaDestroyImage` pair per frame costs ~20 ms at 1080p on this driver, more than the decode itself. - A typed error for every failure. Nothing here panics: edith loads this path as a dlopen'd plugin whose fall back to software is only as good as that promise.
feat(va): encode capabilities and the image upload pathAhmet Kaan Gümüş · a1a1150
feat(va): encode capabilities and the image upload path `CapEntry` now reports `VAConfigAttribEncPackedHeaders` and `VAConfigAttribRateControl` alongside the RT formats, in the same round trip. The packed-header mask is not decoration: a config created without asking for those headers gets a driver that ignores the ones the application writes, which on radeonsi means a stream with no parameter sets in front of it. `Surface::write_from` wraps `vaPutImage`, the encoder's upload path — fill a standalone image with source pixels and let the driver detile and convert on the way in. `VA_ATTRIB_NOT_SUPPORTED` is reported as zero rather than as every bit set: a decode entrypoint answers that for the encode-only attributes, and "all capabilities" is not what it means.
feat(h265-syntax): the DPB fields a stateless hardware decode needsAhmet Kaan Gümüş · a3e5dd1
feat(h265-syntax): the DPB fields a stateless hardware decode needs A software decoder derives its reference picture set as it goes; a stateless one has to hand the driver finished picture lists, so the parser now keeps what it used to walk past: - `ShortTermRefPicSet` carries `DeltaPocS0`/`S1` and the used-by-current flags, including the inter-set prediction of 7.4.8, and the SPS keeps its sets so a slice that names one by index can resolve it. - `SliceHeader` carries the resolved set, the long-term entries with their `DeltaPocMsbCycleLt` accumulation (7-52), the reference list modification entries and a parsed `pred_weight_table()` whose chroma offsets are derived per 7-56 rather than left as raw deltas. - `SliceHeader::write_without_alignment` writes a header without its closing `byte_alignment()`, which is what a VA-API encoder submits as a packed header, and `write` keeps its old behaviour on top of it. The fuzz suite caught an overflow in the weight derivation on the way in: both terms come straight off the wire, so 7-56 is evaluated in 64 bits and clamped.
fix(probe): the head of a file is exact, and a default track is the flagged oneAhmet Kaan Gümüş · c665d19
fix(probe): the head of a file is exact, and a default track is the flagged one Three gaps the symphonia swap (edith W7) found, all at the start of a file or at the pick of a track: - **An MP3 is gapless.** The LAME tag's encoder delay and padding went unread, so a `.mp3` claimed the silence around its sound as part of it and its samples arrived 25 ms behind the `.flac` of the same tone. `StreamInfo::initial_padding` now states the delay (the tag's, plus Layer III's own 529 samples of synthesis delay) and the duration ends at the last audible sample. Measured against ffmpeg on eight fixtures and three files of a real library: lag 0, correlation 1.0000, where the mp3 was 1105 samples late before. - **A seek to the beginning goes there.** `candidate` started at the nearest *cue*, and a cue naming another track can sit past our own first block: this muxer opens a cluster at every video keyframe and cues the video alone, so a file whose first cluster holds only sound lost that cluster on every seek to zero. Another track's cue now backs off one entry, and a target before everything indexed starts at the first cluster. - **`FlagDefault` picks the track.** `default_stream` answered with the first stream of a kind, so a dual-audio remux that marked its second track default opened in the other language. `StreamInfo::default` carries the flag where a file really wrote it (the element's absent value is 1, which is why "flagged" and "eligible" have to be different questions), and the symphonia shim's `default_track` reads it. The shim gains the surface that carries these: `Track::delay`, the umbrella's feature names (no-ops -- ec-probe serves every format unconditionally -- but a `[patch.crates-io]` consumer naming `features = ["mkv"]` must still resolve). Checks: `ec_probe` `the_head_of_a_file_is_exact` (gapless arithmetic exact against ffmpeg, and no seek lands past a first packet) and `ec_matroska` `the_first_cluster_is_reachable_when_no_cue_names_it` (fails without the cue back-off: the audio restarts at 21 ms instead of 0).
perf(h264): close the decode gap on inter contentAhmet Kaan Gümüş · 4cab1f0
perf(h264): close the decode gap on inter content Instruction counts, single thread, measured with perf over whole streams: 1080p WEB-DL 100 frames 38.23G -> 30.02G (-21.5%), QCIF B streams -47% and -29%. The changes, each measured on its own and kept only where it paid: - chroma interpolation takes a const-width kernel plus a full-sample copy path, so the 2x2 blocks that dominate real motion stop paying for eight lanes and four multiplies they discard; - single-list, default-weight prediction interpolates straight into the picture at the picture's pitch, and declares no scratch at all; - boundary strength is decided once per macroblock for all 24 internal edges (intra gives 3, no coefficients plus one motion vector gives 0) instead of 24 times from the block tables; - the luma half-sample filter splits by partition width, because a 16-lane vector is two SSE2 registers and half of it is thrown away for an 8- or 4-wide partition; - a horizontal chroma edge deblocks as one 8-lane pass; - the rounded average is written as the plain byte idiom the compiler turns into pavgb; - an output frame is grown row by row rather than allocated zeroed; - a direct-mode quadrant whose four 4x4 blocks derive the same motion compensates once as an 8x8 (interpolation is position-invariant, so this is bit-exact). Reverted, measured worse: combining at the picture pitch (+6 to +9%), blanket 8-lane luma taps (+2.2%), window slices for the deblock line filters (+0.8%). Conformance unchanged: 22 conformance tests and 55 unit tests green, JVT full sequences and the real library sweep still bit-exact.
fix(matroska): a Colour element with no Range child states no rangeAhmet Kaan Gümüş · 18d0fc1
fix(matroska): a Colour element with no Range child states no range Same class as ec-mp4 2a3816e, in the crate that commit named as carrying it. `ColorInfo` has to answer `full_range` whether or not the file wrote a `Range` child, so a `Colour` element without one -- which is most of them -- read as a *declaration* of limited range. A host resolving colour in tiers then took that fabricated claim as the container tier and shadowed a bitstream VUI that said full: a full-range picture displayed as limited, which is a visibly washed-out one. `MatroskaDemuxer::color_tags(stream)` hands over what the element really stated -- the Matroska `Range` coding straight into `Tags::from_codes`, where 0 is "nothing said" -- and `VideoParameters::color` is unchanged for every file that carries a `Range`. The unit test holds all three cases.
test(h264): both entropy coders across the encoder sweepAhmet Kaan Gümüş · db36daa
test(h264): both entropy coders across the encoder sweep The encoder defaults to CABAC now, so the reconstruction sweep and the ffmpeg bit-exactness sweep both run each configuration under CAVLC as well: an entropy coder nothing exercises is one that silently rots.
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.
fix(mp4): an nclc colr box states no range, and must not be read as oneAhmet Kaan Gümüş · 98eeb6c
fix(mp4): an nclc colr box states no range, and must not be read as one `ColorInfo` has to answer `full_range` whether or not the file stated one, so the ten-byte QuickTime `nclc` box -- which stops before the range byte -- was coming back as a *declaration* of limited range. A host resolving its colour in tiers then took that fabricated claim as the container tier and shadowed a bitstream VUI that said full range: a full-range picture displayed as limited, which is a visibly washed-out one. `colr` now returns the triplet and the `Tags` that triplet really states, and `Mp4Demuxer::color_tags(stream)` hands the second one over: an `nclx` states its range (1 + the flag), an `nclc` and an `nclx` truncated before that byte state none at all, and a track with no `colr` states nothing. `VideoParameters::color` is unchanged for every file that really carries an `nclx`. Latent rather than seen: no file in the scanned library carries an `nclc`. Fixed as a class anyway -- the same shape sits in ec-matroska, whose `Range` element is likewise absent-means-limited (`demux.rs:1214`). cargo test -p ec-mp4: 17 unit + 10 integration passed.
fix(matroska): the SeekHead really points at the Cues, and four track facts a host needsAhmet Kaan Gümüş · c2c209e
fix(matroska): the SeekHead really points at the Cues, and four track facts a host needs The `SeekHead` stated the `Cues` position twice off the segment: `cues_at` was already relative and the table subtracted the segment body again, so the pointer landed in the middle of a cluster. This crate's own demuxer never noticed -- finding no `Cues` there it falls back to the cluster-header walk and reads the file perfectly -- while symphonia's reader follows the pointer, meets an element that cannot be there and refuses the file outright. Found by driving an exported `.mkv` back through symphonia. The remux test now resolves every `SeekHead` entry and asserts the element it lands on is the one it names. Four accessors a host cannot do without, all off the `Tracks` element that was already parsed: - `track_codec_id` -- the file's own `CodecID` (`A_EAC3`, `S_HDMV/PGS`), which says more than the `CodecId` it maps to and is what a copy and a refusal name. - `track_title` -- `TrackName`, now parsed and now written: `set_track_title` puts it back, so a subtitle track called "Signs" survives a remux. - `track_refusal` / `track_is_plain` -- what a `ContentEncodings` this cannot undo did, asked at the header instead of a cluster later, so one unreadable subtitle track is listed beside the readable ones rather than failing the file. - `unread_tracks` -- the `TrackEntry`s this crate hands no stream for, with their type: "MPEG-2 video nothing here decodes" is an answer, "no video track" is a lie about the same file. And `set_track_delay`, which writes `CodecDelay` for a track whose encoder delay only the caller knows: Opus states its own pre-skip in the `OpusHead` and is unaffected, AAC's is one access unit and nothing in the file says so -- a track written without it plays ~21 ms early against the picture.
feat(shims): rusty_h264 0.9.1 surface over ec-h264Ahmet Kaan Gümüş · f26a1d2
feat(shims): rusty_h264 0.9.1 surface over ec-h264 Decoder::decode over whole access units and the EncoderConfig/Encoder/ YuvFrame/Preset surface edith's export path calls, without the incumbent's process-wide allocator and without its lookahead buffering: try_encode returns the access unit of the picture it was handed, every time.
test(h264): encoder conformance against both decoders and the libraryAhmet Kaan Gümüş · 2fb37fb
test(h264): encoder conformance against both decoders and the library Every stream the encoder writes decodes to the encoder's own reconstruction sample for sample — in this crate's decoder, in ffmpeg and, at 60 dB, on this machine's VA-API decoder. The sweep covers a QP ladder, both presets, one and four threads, sizes that are not macroblock multiples, constant bitrate, and real 1080p+ pictures demuxed by ec-mp4 and decoded by this crate.
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.
feat(h264-syntax): write emulation prevention into an RBSPAhmet Kaan Gümüş · 46b6e85
feat(h264-syntax): write emulation prevention into an RBSP escape_rbsp is the inverse of unescape_rbsp, and the encoder needs it to frame every NAL unit it emits. Same shape as the h265 syntax crate's.
perf(h264): vectorise the motion compensation kernelsAhmet Kaan Gümüş · d69235f
perf(h264): vectorise the motion compensation kernels Motion compensation was 54% of a 1080p decode profile: the 6-tap luma interpolation of 8.4.2.2.1, the chroma bilinear of 8.4.2.2.2 and the prediction average of 8.4.2.3.1, all per sample in 32-bit arithmetic. The unrounded 6-tap result spans -2550..10710 and the chroma bilinear never exceeds 64 * 255, so both fit 16-bit lanes exactly: one vector is one row of a partition (sixteen luma lanes, eight chroma). Only the centre sample j needs 32-bit lanes, because the second pass sums already-filtered values. Every load is fixed length so the compiler emits one widening load rather than a byte loop — the open-ended slice version measured barely faster than scalar. Bit-identical by construction and by the from-spec test, which walks every fractional position and partition size at interior and far outside positions. 1080p library streams: 44.2 to 35.3 Ginstr and 64.2 to 45.5 Ginstr, 18% and 40% less CPU time.
chore: relock the workspaceAhmet Kaan Gümüş · 22fb460
chore: relock the workspace The committed lock predates several workspace members, so every cargo invocation rewrote it; this is that rewrite, with no dependency added by hand and none removed.
feat(opus): multi-rate input, application-driven bandwidth, whole shim surfaceAhmet Kaan Gümüş · 339a2ea
feat(opus): multi-rate input, application-driven bandwidth, whole shim surface Grafts onto the merged CELT encoder, all four bitstream-neutral at 48 kHz fullband (the four regression cells re-encode byte for byte): - encoder: input at 8, 12, 16, 24 or 48 kHz, zero-stuffed to CELT's native rate with the coded bandwidth capped at the input's own Nyquist, so the images the stuffing puts there are never coded; look_ahead() reports the delay in input samples (120 at 48 kHz, scaled). - encoder: Application reaches the encoder instead of being discarded at the shim boundary — it biases the coded bandwidth (Voip one step narrower), which is the only thing a CELT-only encoder can honestly do with it, and the TOC now spans configs 16..31 rather than fullband alone. - celt_enc: `end` is a parameter, so the caller bounds the coded bands. - ogg: the RFC 7845 header builders (opus_head, opus_tags, default_mapping) move into the crate, where the encoder, a muxer and the tests share one definition; the conformance test's hand-rolled OpusHead is now that call, and MultistreamEncoder::surround reads the mapping table from it. - shims/opus-rs: the rest of the incumbent's surface — OpusDecoder, MultistreamEncoder::surround, the Bandwidth enum, the vbr field, look_ahead(), final_range() and encode_i16() — so a caller needs no second crate for the decode half or for surround. Proof: the shim's own tests round-trip every input rate through the decoder with range-state parity per packet, hold the 8 kHz..48 kHz look-ahead, force a wideband TOC and read it back, and encode 5.1; the ec-opus suite (RFC vectors, libopus rate table, opus_demo, Ogg duration, zero-alloc) is unchanged and green.
test(opus): 16 kbps row in the rate table; clippy-clean wide usageAhmet Kaan Gümüş · f935367
test(opus): 16 kbps row in the rate table; clippy-clean wide usage The charter's honest bottom: 16 kbps fullband CELT lands at corr 0.94 mono / 0.52 stereo through libopus — reported and floored as such, not hidden. The PVQ lane-select keeps wide 1.5's blend under a scoped allow (its replacement API does not exist in that release).
feat(opus): CELT encoder — mono/stereo/multistream, all rates, CBR+CVBRAhmet Kaan Gümüş · 52ead44
feat(opus): CELT encoder — mono/stereo/multistream, all rates, CBR+CVBR
Throughput-first CELT-only Opus encoder (RFC 6716 Section 5, coding path
mirrored symbol-for-symbol from the normative Appendix A; analysis replaced
by fast deterministic heuristics: no pitch prefilter, tf_res fixed, spread
fixed NORMAL, single-pass coarse energy):
- range.rs: full RFC 5.1 range encoder (fixed-size frames, shrink, raw-bit
tail), tell()/tell_frac()/range-state exact against the decoder per symbol
- celt_enc.rs: forward MDCT as the exact adjoint of the decoder's inverse,
transient/trim/dynalloc/stereo analyses, encode-side allocation, PVQ
search (wide f32x8 lanes) + V(N,K) enumeration, Laplace coarse energy
- encoder.rs: TOC framing (configs 28..31), CBR and constrained-VBR, plain
and self-delimited (App B) packets
- multistream_enc.rs: RFC 7845 family-1 surround (5.1 helper), per-stream
self-delimited framing, coupled streams weighed 2:1 in the rate split
- shims/opus-rs: the opus-rs 0.1.26 surface edith consumes, mono fixed and
no rate ceiling; root-cause doc for the incumbent's ~165 kbps cliff in
lib.rs
Proof in tests/conformance.rs (same binary): per-packet range-state parity
encoder vs vector-verified decoder at 32..510 kbps x {mono,stereo} x all
frame sizes x CVBR; libopus (ffmpeg) decodes the whole rate table at worst
corr 0.9565 (32k stereo) to 1.0000; 5.1 order-preserved >=0.9978; reference
opus_demo 0.9995 at 256k stereo; Ogg-Opus duration exact; zero-alloc steady
state; speed floors (measured ~150-580x realtime per config).feat(h264): High-profile 8x8 transform, both entropy codersAhmet Kaan Gümüş · 49bb32e
feat(h264): High-profile 8x8 transform, both entropy coders transform_size_8x8_flag (7.3.5) in the intra and inter positions with the neighbour context of 9.3.3.1.1.10, Intra_8x8 prediction with the reference sample filter of 8.3.2.2.1, the 8x8 residual under CAVLC (four interleaved 4x4 blocks) and CABAC (ctxBlockCat 5, ctxIdx 402..435 transcribed from Table 9-24, no coded_block_flag), the 8x8 scaling and inverse transform of 8.5.13 with the 8x8 scaling lists, and the 8.7 rule that an 8x8 macroblock has no transform edge at luma 4 or 12. This is what real content needs: every H.264 file in the library that is not Main profile uses it, so eight of twelve were refused by name before and all twelve now decode 500 frames bit-exactly against ffmpeg. The MP4 whose Annex B extraction ffmpeg itself could only decode three frames of is demuxed by ec-mp4 instead, which restores the oracle. Coverage: 51 quantisers x both coders all-intra, P and B sequences with and without sub-8x8 partitions, and a parameter-set assertion so an encoder silently dropping back to 4x4 cannot make the sweep vacuous.
feat(mp4): the index, random access and late-declared streams a host needsAhmet Kaan Gümüş · d7dca0c
feat(mp4): the index, random access and late-declared streams a host needs The replica's engine reads and writes mp4 through this crate now, and five things it needs were not reachable through the two traits alone: - `Sample` is public, and `samples(stream)` hands the whole resolved table over. That table *is* the index an mp4 carries of itself -- a caller that counts frames, builds a display-order seek table or asks what a track spends reads it here instead of walking the file again. - `read_sample(stream, index)` reads one sample of one stream without moving the packet cursor: random access beside the sequential `next_packet`, for a caller holding an index of its own. - `tracks()` lists every track the container declares, in file order, with its `tkhd` id, its handler, its sample entry fourcc, its language and its edit list's `media_time`. Two things ride on it: a track whose codec this build has no id for is still listed (a picker greys such a row out rather than pretending the file has fewer tracks than it has), and `avc3` can be told from `avc1` by a host that re-injects parameter sets out of the `avcC`. - `duration_secs()` is the `mvhd`'s own length, which is what a file's byte rate is measured over -- not any one track's. - The muxer takes `add_stream` at any point before `finish`, and `set_color` after the stream is declared. Samples are written where they arrive and the sample entries are built at the end, so a track declared after the picture is already in the `mdat` costs nothing -- which is what lets an export mix and encode its sound while it writes the picture, and add its subtitles once the film's length is known. cargo test -p ec-mp4: 10 passed.
fix(h264): colZeroFlag reads the co-located block's own reference indexAhmet Kaan Gümüş · b5f5ec8
fix(h264): colZeroFlag reads the co-located block's own reference index Spatial direct prediction (8.4.1.2.2) zeroes a motion vector when the co-located block sits still on a short-term picture referencing entry 0 of that picture's list. The index that decides it is refIdxCol, of the list clause 8.4.1.2.1 selected; accepting "either index is 0" instead zeroes vectors that must keep their prediction whenever the co-located block is bi-predicted with a non-zero list 0 index. That only happens when the co-located picture is itself a coded B picture, which is the first B of every run under a B pyramid: two real 1080p library files decoded with localized wrong regions in exactly those pictures and nowhere else. The new test reproduces it with b-pyramid and four references, and fails on the previous reading.
test(fixtures): 24-bit ALAC, Matroska-carried audio and cover artAhmet Kaan Gümüş · abd41b6
test(fixtures): 24-bit ALAC, Matroska-carried audio and cover art 24-bit ALAC is the only path where a sample's low bytes ride uncompressed beside the residuals; Matroska-carried aac/flac/opus and a video-plus-sound mkv are what the probe delegates; the two cover-art files are the claim that a still picture is never listed as a video track. The mp4 tests drop attached pictures from their ffprobe oracle for the same reason: this crate does not list one, deliberately, and does not write one either.
feat(shims): symphonia, symphonia-core and symphonia-codec-aac over ec-probeAhmet Kaan Gümüş · 32195c9
feat(shims): symphonia, symphonia-core and symphonia-codec-aac over ec-probe Exactly the surface edith consumes (audio.rs:36-53 and its call sites): the probe and codec registries, the format reader and audio decoder traits, tracks, packets, units and the AAC decoder seat. Written from those call shapes and the crates' published documentation; no symphonia source was read (MPL-2.0 incumbent, MIT OR Apache-2.0 family). Two incumbent defects are gone rather than worked around, and each has a test: a Matroska seek is reliable more than once per reader (edith opens a new reader per attempt because the incumbent's is not), and a multichannel AAC track decodes instead of 'aac: aac too complex'. The shim test drives every call edith makes, in the shape edith makes it, over nine fixtures.
feat(probe): one sniffing reader and one decoder registry for every audio fileAhmet Kaan Gümüş · 51de303
feat(probe): one sniffing reader and one decoder registry for every audio file Content decides the format, never the extension: RIFF, fLaC, OggS, EBML and ftyp by magic, MP3 and ADTS by three chaining frames after any ID3 tag (a lone MPEG audio header turns up inside AAC payload often enough that a single sync is not evidence). WAV, MP3, FLAC and ADTS are demuxed here — one walk, four framings, a frame index built on the first seek so a landing is sample-accurate. Ogg, mp4 and Matroska are delegated to their own crates: there is one EBML parser in this family and it is ec-matroska (cargo tree -p ec-probe shows the edge). Everything is served on the one reader the file was opened with, however many times it is seeked. Reader::seek answers where it actually landed, which is the number a segment start is trimmed against. Reader::unsupported names every audio track with no decoder and why. Cover art is not a video track and never appears as one. Tags: ID3v1/v2 and Vorbis comments; mp4 ilst is not read (edith reads no metadata today) and says so in the module docs. Verified: 26-file fixture matrix (format, codec, channels, packet counts against ffprobe, sample counts against ffmpeg), 100 random seeks per file each landing at or before its target within the container's own granularity, and a 9-file sweep of the real library covering aac, ac3, eac3, opus, mp3 and a TrueHD remux whose unplayable track is listed.
fix(ogg): a seek lands where its packets can say what time it isAhmet Kaan Gümüş · 5a98e1b
fix(ogg): a seek lands where its packets can say what time it is A granule position is where a page ends, and Vorbis and FLAC packets state no duration of their own, so every packet of the page a seek landed on came out with no timestamp at all — a seek that cannot say where it landed. The landing is now the page after the one the bisection found, whose first sample is that page's granule exactly, and the reader never resumes inside the header pages. Measured on a 3-second Vorbis fixture: seeking to 2.6 s reported 0.000 s before and 2.033 s (the page boundary before the target) after.