Commits
Commits on
a1a1150ebccc052d3bf976fc505be069d3b1ffea2026-08-14
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.
feat(core): TrueHD and DTS codec ids, and a Matroska track's own numberAhmet Kaan Gümüş · 254c09a
feat(core): TrueHD and DTS codec ids, and a Matroska track's own number A track nothing here decodes is named rather than dropped: a player that lists a TrueHD track as unsupported tells the user something, and one that shows no audio at all does not. The Matroska reader maps A_TRUEHD, A_MLP and the A_DTS family onto them. MatroskaDemuxer::track_number answers what TrackNumber a stream index came from, which is how a caller names one language of a dual-audio remux (edith matches its audio streams by that number).
feat(alac): ALAC decoder, bit-exact against ffmpeg on 16 and 24 bitAhmet Kaan Gümüş · d60d66b
feat(alac): ALAC decoder, bit-exact against ffmpeg on 16 and 24 bit Clean-room from the published ALAC format description: magic cookie in all three shapes a container states it, adaptive-Golomb residuals with the zero-run mode, the sign-adapting LPC predictor, the mid/side un-mix and the shifted low bytes of a 24-bit stream. Decode only. Two things the format description does not spell out were measured against ffmpeg's own encoder output and are commented where they are used: a channel element's predictor plan starts 39 bits into the frame (the mix pair is stated by a mono element too), and the predictor's history window is out[j-k], not out[j-1-k]. Oracle: 8 fixtures (mono/stereo/5.1, 44.1 and 48 kHz, 16 and 24 bit) decode byte-for-byte identical to ffmpeg's decoder.
feat(h264): display-order output reaches the packet entry surfaceAhmet Kaan Gümüş · 5a58bb1
feat(h264): display-order output reaches the packet entry surface A player never touches the NAL-level API, so the reordering has to arrive at H264Decoder: packets in, frames out, timestamps travelling with their pictures rather than with the packets that carried them. packet_entry_surface_reorders_and_carries_timestamps drives exactly that path — one access unit per packet, frames pulled with receive_frame — and proves three things at once: every frame is bit-exact against ffmpeg, the output order is a real permutation of the packet order, and the tag on each emitted frame identifies the packet whose picture it actually is (checked against the same stream decoded in decode order). Also: the crate description now states the scope it reached, the debug tracing added while chasing the inter defects is gone, and clippy and rustfmt are clean.
test(h264): QP and geometry sweeps with motion, real library, SP refusalAhmet Kaan Gümüş · 7c078b5
test(h264): QP and geometry sweeps with motion, real library, SP refusal - every_quantiser_with_motion_matches_ffmpeg: all 51 quantisers over a P/B GOP under both entropy coders. Boundary strengths 1 and 2 only exist between inter macroblocks, so their tC0 columns had no oracle before this and both were wrong; every row of both is now covered. - geometry_with_motion_matches_ffmpeg: 1080p, odd sizes, four slices per picture, loop filter off, a single-macroblock picture and five reference frames with B-pyramid — all over GOPs, both coders. - real_library_streams_match_ffmpeg: the H.264 files actually on this machine, 500 frames each, streamed against ffmpeg one frame at a time so a 1080p sweep costs two frames of memory. Three files bit-exact at 500 frames; eight refused by name, every one of them for the 8x8 transform, which is what stands between this decoder and most real H.264 content. - switching_slices_are_refused_by_name: no encoder here emits SP slices, so the stream is hand built, because an unproven refusal string is indistinguishable from a hidden bug. - The corrupt sweep now includes a B-slice, multi-reference stream and exercises the whole-sequence path, where a mangled slice meets the decoded picture buffer.
fix(mp3): gapless Info tag, and the region split a switched granule must useAhmet Kaan Gümüş · 09040eb
fix(mp3): gapless Info tag, and the region split a switched granule must use The encoder now writes a real Xing/Info header — frame and byte counts plus the encoder delay and padding — so a decoder that honours it hands back exactly the samples that went in. ffmpeg does: a two-second timeline clip encodes and decodes back to 88200 samples per channel at lag zero, where before it came back 1728 samples late with no way to know it, and 72 samples short because the granules held for block-switching lookahead were dropped at the end instead of flushed. Chasing that alignment surfaced two real defects, both invisible until the comparison was made at lag zero over the whole stream: - A granule that switches windows does not transmit its region boundaries; the decoder derives them (three short bands for a short block, eight long bands for a start or stop one). The encoder was choosing its own split and writing the tables for it, so every switched granule parsed as different tables. Bit accounting still landed exactly on part2_3_length, every fixture still decoded, and only the switched granules came back as noise -- 47x the intended energy in the worst one measured. - Short-block spectra are coded band by band and window by window, which is not the order the transform produces them in. The decoder's reorder had no inverse in the encoder. Both now have tests that fail without the fix: one drives an attack that forces the switch and checks the granules around it through our own decoder, one runs the whole window sequence through the transform pair directly. Also: scalefactors for short blocks (they had none, so their noise was flat across the spectrum); a ceiling on scalefactor amplification, since the second partition's length is at most three bits and a band above the split cannot carry more than 7 -- the quantiser used what it wanted and the decoder rebuilt the band with zero; the window-type sequence now carries across frame boundaries, where it used to restart and leave a start window facing a normal one; and a frame of priming silence, so the transform's startup lands before the audio rather than on top of it. Measured on W2's timeline content, ours at lag zero against the incumbent rusty_mp3 0.6.1 at its own lag, RMS error against the source: 128k 1.173e-4 vs 1.143e-4 256k 3.986e-5 vs 3.985e-5 192k 6.027e-5 vs 6.110e-5 320k 2.535e-5 vs 2.567e-5 Correlation is 1.000000 at 256k and above. The encode fixture matrix is unchanged in shape and every entry still beats its bar, now measured at lag zero rather than at the best shift.
test(h264): B pictures, display order, frame_num gaps, zero-alloc on BAhmet Kaan Gümüş · 6e48da7
test(h264): B pictures, display order, frame_num gaps, zero-alloc on B - b_pictures_match_ffmpeg_every_frame: spatial and temporal direct, B-pyramid and weighted prediction, under both entropy coders, every frame bit-exact. The first version of this test measured nothing: x264's adaptive decision produced no B slices at all on the synthetic source, so the test now counts slice types out of the stream and fails if the encoder did not actually emit any. - output_is_display_order_and_the_reorder_is_real: display order matches ffmpeg frame for frame, and the same stream decoded in decode order is a genuine permutation of it — 15 of 20 frames move. - a_frame_num_gap_keeps_decoding: dropping a whole picture leaves the remaining 11 decodable, which is what a seek into a GOP looks like. - The zero-allocation proof now covers a B-slice, multi-reference stream and counts a whole second pass over the stream rather than one picture, so picture-pool recycling is part of the claim. Emitting a picture no longer looks its parameter set up: a stored picture carries its own crop, output size and colour description, which also removes the per-slice parameter-set clone that made the decode loop allocate.
fix(h264): constrained intra prediction stops at predictionAhmet Kaan Gümüş · 18b2689
fix(h264): constrained intra prediction stops at prediction constrained_intra_pred_flag makes an inter neighbour unavailable as an intra *prediction* source (8.3.1.1, 8.3.1.2). It does not change the neighbour availability the residual contexts read: clause 9.2.1 and 9.3.3.1.1.9 exclude an inter neighbour there only when slice data partitioning is in use, which this decoder refuses outright. Feeding the constrained availability into nC and coded_block_flag desynchronised CI_MW_D, whose whole point is constrained intra prediction. JVT full-sequence sweep: 26 of 26 in-scope vectors bit-exact end to end, 9 refused by name (8 interlaced, 1 FMO), nothing unaccounted.
fix(h264): reference index spans its whole 8x8, and numbering precedes markingAhmet Kaan Gümüş · 4b8dc73
fix(h264): reference index spans its whole 8x8, and numbering precedes marking Two more inter-only defects, both found against the JVT reference decoder traces that ship with the vectors: - ref_idx_lX covers a whole macroblock partition. Writing it over only the first sub-macroblock partition left the rest of an 8x8 marked "list unused", so the mvd contexts of 9.3.3.1.1.7 read absMvdComp 0 for a neighbour that had one, and CABAC desynchronised. - clause 8.2.4.1 (FrameNumWrap, PicNum) ran only when a slice built a reference list. An intra slice builds none, and the picture being stored had no FrameNumWrap of its own, so the sliding window of 8.2.5.3 compared stale numbers and evicted the wrong reference. Numbering now runs at the head of `store`, the one point every picture passes through. JVT full-sequence sweep: 18 vectors bit-exact end to end before, 25 now, of the 26 that are in scope.
fix(h264): unavailable neighbours carry reference index -1, not 0Ahmet Kaan Gümüş · 276058c
fix(h264): unavailable neighbours carry reference index -1, not 0 Two derivation defects that only inter coding can reach: - Nb::default() derived Default, so an unavailable neighbouring partition reported refIdxLXN 0 instead of the -1 that clause 8.4.1.3.2 assigns. Every median prediction with a missing neighbour then saw a phantom match on reference picture 0 and took the wrong branch of 8.4.1.3.1. Picture-edge macroblocks came out wrong in most inter frames. - coded_block_flag (9.3.3.1.1.9): an unavailable neighbour counts as set only when the current macroblock is intra. The chroma DC block of an inter macroblock at the left picture edge read the opposite value and desynchronised the arithmetic decoder. JVT full-sequence sweep: 4 vectors bit-exact end to end before, 18 now. Adds the full-sequence conformance test that found them, plus an env-gated macroblock trace (EC_H264_TRACE) and deblocking bypass (EC_H264_NO_DEBLOCK) that split reconstruction defects from filter defects; both resolve their environment once so the decode loop stays allocation free.
test(h265): the bit-target mode and the batch helperAhmet Kaan Gümüş · 4a55700
test(h265): the bit-target mode and the batch helper Both are surface a caller reaches for and neither had a test. The target mode is asserted on the contract it can keep - monotonic in the target and within a factor either side - rather than on a bitrate to the byte, which no single-picture encoder can promise.
test(h265): let ffmpeg check the encoder's own picture hashAhmet Kaan Gümüş · 138d2a4
test(h265): let ffmpeg check the encoder's own picture hash -err_detect crccheck makes the decoder verify the MD5 SEI against what it decoded, plane by plane. It is the one oracle in this suite that does not depend on any other part of this crate being right.
feat(h265-syntax): the fields a VA-API decoder asks for and this encoder does not writeAhmet Kaan Gümüş · 4d59579
feat(h265-syntax): the fields a VA-API decoder asks for and this encoder does not write An audit of every field in VAPictureParameterBufferHEVC and VASliceParameterBufferHEVC against what this crate hands back turned up four the parser walked past: PCM depths and block sizes, explicit tile column and row geometry, colour_plane_id, and the emulation prevention byte count of the slice data. All four are carried now, with round-trip tests, because the consumer is a hardware decode path that cannot re-parse a header the parser already read. What is still deliberately absent, and why: reference lists and the picture buffer (decoder state, not syntax), scaling lists (refused as Unsupported), and pred_weight_table (walked for length, not modelled - no HEVC stream this family produces uses weighted prediction).
test(aac): oracle sweep, real-library tracks, incumbent bar and the table derivationAhmet Kaan Gümüş · 646127f
test(aac): oracle sweep, real-library tracks, incumbent bar and the table derivation Thirteen checks over the decoder and encoder, plus the shim's own three at the call shapes the replica has. Decode: every ADTS and mp4 fixture, mono through 5.1, per-channel correlation at or above 0.999998 against a reference decode; five library tracks including a 7.1 mp4 and a 5.1 mkv at 1.000000; the 5.1 element order proved with one tone per channel; and the one HE-AAC track in the library decoded to its AAC-LC core, matched on band energies against the reference's own core band. 426x realtime on 5.1, release build. Encode: against the incumbent's numbers on the same lossless fixtures at the same bitrates, measured by running it as a black box -- 0.9996 to 1.0000 per channel where it manages 0.9611 to 0.9864. Output decodes with no reference-decoder complaint, and the AudioSpecificConfig this crate writes is byte-identical to the one that muxer puts in an esds. Tables: Kraft sum of exactly 1 and the prescribed entry count for all twelve codebooks, band tables monotone and spanning their window. The derivation itself lands under scripts/ so the clean-room claim is reproducible rather than asserted.
feat(h265): full-depth quadtree search, VA-API check, parse-side fuzzAhmet Kaan Gümüş · b19a281
feat(h265): full-depth quadtree search, VA-API check, parse-side fuzz The search goes down to 8x8 by default because on real pictures that is both better and no slower: measured on a 1080p camera frame at QP 22, -27% bits and +1.5 dB against stopping at 16x16, at the same wall time. The 16x16 floor stays available as a setting. Two defects the earlier tests could not see, both found by pointing the encoder at real footage: - stopping the search early skipped split_cu_flag entirely, while the sequence still allowed a split. Every picture decoded to noise. The flag is written now whatever the search decides. - a fuzzed SPS could name a 45-bit POC field and take ec-core's bit reader past its documented contract. Picture size, POC width and long-term set count are validated where they are parsed. Also: VA-API decode of the encoder's own output is a test (radeonsi, real GPU), progress counters are one per cache line - twelve workers polling eight counters per line spend their time invalidating each other - and waits back off to a sleep instead of spinning on a core someone needs.
feat(image): image shim over ec-imageAhmet Kaan Gümüş · 88de5e3
feat(image): image shim over ec-image Carries the `image` name and version 0.25.10, covering exactly the surface edith's *engine* consumes: ImageReader::open / with_guessed_format / decode / into_dimensions, image::open, DynamicImage with to_rgb8 and its siblings, and the three 8-bit buffer types with dimensions, get_pixel and a Deref to the samples. Anything else upstream exposes is absent, so a new use is a compile error rather than silently different behaviour. The app crate's two call sites (RgbaImage::from_raw, Frame::new) are deliberately not covered: they feed gpui::RenderImage, which is typed against the real `image` crate gpui itself depends on. The swap therefore cannot be a blanket [patch.crates-io] — the engine takes this crate by rename, or the app keeps the real one. That constraint is stated in the crate's own documentation so the replica batch does not rediscover it.
test(image): differential corpus, fuzz sweep and a real-library passAhmet Kaan Gümüş · 82499c0
test(image): differential corpus, fuzz sweep and a real-library pass Three bars, one per format, each the strictest the format allows: - PNG and lossless WebP are pixel-exact against the incumbent `image` crate over every colour type, bit depth and interlace method, with the 16-bit variants compared at 16 bits so neither side's narrowing rounds the comparison away. - JPEG is measured, not asserted away: max sample delta 5 of 255 (1 on grayscale, 3 on 4:4:4), correlation above 0.9999 and 49-66 dB against the incumbent's own decode, all printed per file. T.81 leaves IDCT rounding to the implementation and both readings are legal. - WebP lossy is measured against the *source picture*: 32.1-36.5 dB, within 0.05 dB of the incumbent everywhere, and the alpha plane, being lossless, must match exactly. Ten thousand mutations per format — bit flips, truncations, injections and noise behind each signature, with PNG chunk CRCs repaired so the mutations reach the decoder instead of stopping at the checksum — must produce an Ok or an Err, never a panic. A header claiming four gigapixels is refused before anything is allocated from it. The real-library sweep decodes the PNGs and JPEGs actually on this machine and prints a per-file table: 13 files, PNGs pixel-exact, JPEGs within four counts, 33 Mpx in 568 ms and a 12.6 Mpx phone JPEG in 247 ms in release.
feat(image): WebP decoding, VP8 key frames and VP8LAhmet Kaan Gümüş · 22ac6ab
feat(image): WebP decoding, VP8 key frames and VP8L The RIFF container, both bitstreams, and the separate alpha plane an extended file carries. VP8 (RFC 6386) is a complete key frame decoder: boolean entropy decoder, segmentation, per-partition token decoding with the neighbour contexts, the WHT and DCT inversions bit-exactly as specified, all sixteen intra prediction modes including the six diagonal subblock ones, and both loop filters with their per-macroblock strength derivation. The probability and quantizer tables are generated from the RFC text rather than retyped — two thousand values transcribed by hand is a defect waiting to be found several macroblocks into a picture. VP8L is the lossless bitstream: canonical prefix codes with meta prefix groups, the colour cache, LZ77 over the two-dimensional distance map, and all four transforms applied in the reverse of the order they were read. The colour cache size is read *before* the meta prefix codes; the other order parses plausibly and then fails on the first real file. Alpha arrives either raw or as a headerless lossless stream in the green channel, then unfiltered by the method its chunk declares. Animation is refused by name: a still decoder that quietly returns frame one makes "this plays" and "this decoded" indistinguishable to its caller.
feat(image): baseline and progressive JPEG decodingAhmet Kaan Gümüş · 7eed0e7
feat(image): baseline and progressive JPEG decoding ITU-T T.81 baseline (SOF0), extended sequential (SOF1) and progressive (SOF2), Huffman coded, with restart intervals and both spectral-selection and successive-approximation refinement. Chroma is upsampled with the triangle filter both reference decoders use, in a module JPEG and WebP share: pixel replication is a decibel cheaper against the source and puts a visible staircase on every saturated colour edge. The IDCT is a separable fixed-point inversion carrying thirteen fractional bits, which lands within one count of the incumbent on grayscale, where no colour matrix or upsampler is in the way. EXIF orientation is parsed and exposed, never applied — the same choice the incumbent makes, so a caller swapping between them sees one picture. Arithmetic-coded, lossless and hierarchical JPEGs, and the 4-component CMYK/YCCK family, are refused by name with the reason: decoding ink colours without their ICC profile looks right in a thumbnail and is wrong in print.
feat(image): PNG decoding and the still-image APIAhmet Kaan Gümüş · 7bceff2
feat(image): PNG decoding and the still-image API ec-image decodes stills for the engine's placed-picture path. This first stage is the shared API — format guessing from content, a Pixels buffer in the file's own colour form, parsed-but-unapplied metadata, and pixel limits checked before any buffer is sized from a header — plus the PNG decoder over ec-inflate. Every colour type at every legal bit depth, all five filter types, Adam7 interlace, palette and colour-key transparency, gamma and sRGB exposed, ancillary chunks skipped by length, and every chunk CRC verified: a PNG that fails its own checksum is refused rather than decoded into a picture nobody can tell is wrong. scripts/gen-still-fixtures.sh generates the seeded corpus the later stages measure against; the fixtures themselves stay out of the repository.
feat(aac): AAC-LC decoder, encoder and rusty_aac shimAhmet Kaan Gümüş · 9a848b4
feat(aac): AAC-LC decoder, encoder and rusty_aac shim Decoder covers AAC-LC end to end: AudioSpecificConfig and ADTS framing, all four window sequences and both window shapes, section and scalefactor data, every spectral codebook including the escape one, pulse data, TNS, M/S and intensity stereo, PNS, and SCE/CPE/LFE/DSE/PCE/FIL elements. Output is film order FL, FR, FC, LFE, BL, BR (SL, SR), which is the order the downmix in this family folds, so a 5.1 track needs no caller-side permutation. HE-AAC's SBR is not reconstructed: such a stream decodes to its AAC-LC core and reports the core rate rather than claiming the extension's. Encoder is a full two-loop search: 2048-point FFT masking with spectral flatness for tonality, bark-ish spreading, a relative hearing-threshold floor, transient-driven window switching, per-band mid/side, exact Huffman bit counts for codebook choice, and a bit reservoir against a CBR target. Both ADTS and bare raw_data_block output. The normative tables were derived rather than transcribed: access units with a chosen spectral payload were decoded by a reference decoder and read back through the inverse MDCT, which enumerates each codebook by a binary tree walk. Every one came out with a Kraft sum of exactly 1 and the entry count the standard prescribes. forbid(unsafe_code) in both crates.
feat(h264): inter prediction, decoded picture buffer, display-order outputAhmet Kaan Gümüş · cd996f4
feat(h264): inter prediction, decoded picture buffer, display-order output P and B slices under both entropy coders, with the clause 8.2 decoded picture buffer behind them. - inter.rs: quarter-sample luma interpolation (8.4.2.2.1), eighth-sample chroma (8.4.2.2.2) and the weighted combination of 8.4.2.3. Plane borders are replicated once per picture, which turns the per-sample Clip3 of Equations 8-239/8-240 into a single clamp of the block origin; the unit test checks every fractional position, inside the picture and far outside it, against the spec's clipped definition written out separately. - mv.rs: macroblock and sub-macroblock partitioning (Tables 7-13, 7-14, 7-17, 7-18), neighbouring motion data (8.4.1.3.2) and motion vector prediction (8.4.1.3) including the directional segmentation shortcuts. - dpb.rs: picture order count types 0, 1 and 2, sliding-window and adaptive (MMCO 1..6, long-term references included) marking, reference list initialisation and modification, frame_num gap handling per 8.2.5.2, and the output bumping of C.4.5.3. - decoder.rs: P/B macroblock decode, P_Skip, B_Skip and both direct modes (spatial and temporal), constrained intra prediction, the inter scaling lists, and boundary strength derivation per 8.7.2.1 so deblocking now varies across an edge. - Output is display order by default; OutputOrder::Decode is the escape hatch for a caller that reorders itself. Timestamps travel with the picture, not the packet. The tC0 table rows for bS 1 and 2 were transcribed but unexercised by an intra-only decoder, and both were wrong: whole-row shifts. Re-derived from Table 8-17; inter edges reach them now. CABAC initialisation gains the cabac_init_idc columns of Tables 9-13 to 9-21 (ctxIdx 11..59 and the idc columns of 70..275, 399..401), extracted from the spec text by column alignment.
fix(ac3): switch the spectral extension noise with the dither optionAhmet Kaan Gümüş · 6432e08
fix(ac3): switch the spectral extension noise with the dither option §E3.6.4.2.4's noise() is a zero-mean unit-variance source the standard leaves to the implementation, exactly like §7.3.4's dither: two conformant decoders differ by it and by nothing else. It now follows the same option, so a comparison against another decoder can isolate what the standard does specify, and the default still generates both. On the Dolby Digital Plus track that uses spectral extension this is the whole remaining difference: 0.9988 per-channel correlation with both decoders' noise in, 0.9994 with it out.
fix(ac3): correct the hebap-4 vector quantizer tableAhmet Kaan Gümüş · 9a40807
fix(ac3): correct the hebap-4 vector quantizer table Table E4.4's index column is offset by one against its value rows. The vector an encoder selects with index k is the row the document prints at k + 1, and index 31 selects the all-zero vector, which the table never prints. The other six VQ tables need no such correction. Measured, not guessed: recovering each block's coefficients by running the analysis transform over ffmpeg's PCM makes the comparison per bin rather than per sample. Bucketed that way, only hebap-4 bins diverged -- 0.63% of a channel's energy, and index 31 alone by ten orders of magnitude, with fifteen independent occurrences all recovering exactly zero. Coded bins on that stream now land within 0.01% of ffmpeg's energy.
fix(ac3): rearm the coupling run state when E-AC-3 turns coupling offAhmet Kaan Gümüş · 777214d
fix(ac3): rearm the coupling run state when E-AC-3 turns coupling off Table E1.4's !cplinu branch resets firstcplcos[] and firstcplleak alongside chincpl[], so a frame that switches coupling off and back on again sends its coordinates and leak values unconditionally in the block that revives it. Reading a presence bit there instead desynchronises the rest of the frame: 57 of the 297782 frames of a Dolby Digital Plus track refused with an out-of-range exponent, all of them frames that toggle coupling. That track now decodes to EOF with zero errors.