Commit Graph
3038 Commits
Author SHA1 Message Date
Dylan M. Taylor b4ada28f19 Fix format registry clippy and add ASE support 2026-11-13 01:37:48 -05:00
alehel 7af2f8e868 craft-media: AVI muxer (AviWriter)
Write AVI files: hdrl with avih and one strl (strh, strf, strn, indx) per
stream, odml/dmlh, an interleaved movi and idx1. Past the RIFF limit
(default 1 GiB) the file continues in OpenDML RIFF AVIX extensions with
ix## standard indexes and an indx super index per stream.

- VideoSpec::for_codec builds the stream from CodecParams; MPEG-4 Part 2
  is tagged FMP4.
- Audio is timed by bytes (PCM-style) or one packet per chunk.
- Bad options and chunks are errors; finish() closes a readable file
  after a failed write.

Tests read the files back through this crate's demuxer by every index,
and through ffmpeg (decode identical to the sources, seeks through the
index, ffprobe fields), in one RIFF and across AVIX extensions. The
MPEG-4 encoder tests play its packets from an AVI file.
2026-11-13 07:34:28 +01:00
alehelandClaude Opus 5.5 fe8c1f697a craft-audio: keep the SBR history when a new program config fails
The SBR decoders now record the layout they were built for and are rebuilt when the
decoder's layout differs, instead of being cleared in set_layout. An access unit whose new
program config fails puts the layout back, and with it the SBR decoders still match.

Refs #1121

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 07:34:10 +01:00
alehelandClaude Opus 5.5 48f5283ec8 craft-audio: cite no section number for l_A
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 07:34:10 +01:00
alehelandClaude Opus 5.5 fa9ca36697 craft-audio: SBR review fixes
- A VARFIX pointer of 1 marks no transient envelope, like 0.
- A start at QMF channel 32 is valid; kx is checked once the crossover is known.
- The noise and harmonic gains take q / (1 + q) first, so two clamped levels no longer
  overflow to infinity and NaN.
- A header that runs past its fill element is refused before it replaces the one in use.
- A new program config layout drops the SBR decoders, whose history was the old order's.
- The ffmpeg oracle requires a high band to compare on every channel but the 5.1 LFE.

Refs #1121

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 07:34:10 +01:00
alehelandClaude Opus 5.5 f68e4369eb craft-audio: decode the HE-AAC SBR high band
aac::Decoder::set_sbr(true) decodes HE-AAC at twice the core rate with the
SBR tool of ISO/IEC 14496-3 §4.6.18: QMF analysis and synthesis, frequency
band tables, patching with LPC inverse filtering, envelope adjustment with
limiter, boost, noise and sinusoids. TrackDecoder uses it in place of the
2x upsampler. Tables are transcribed from ETSI ES 201 980 Annex I.

Matches ffmpeg's decoder on AudioToolbox HE-AAC streams of 1-6 channels:
the same 962-sample delay, ~54 dB SNR, high band level within 0.01 dB.
Parametric stereo is still not decoded.

Refs #1121

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 07:34:10 +01:00
alehel 1df8d98c85 craft-video: MPEG-2 encoder, first step: I and P pictures (#1133)
The start of MPEG-2 encoding in craft_video::mpeg2 (feature
mpeg2-encode): progressive frame pictures, closed I/P GOPs, 4:2:0 Main
Profile and 4:2:2 Profile, constant quantiser or single-pass average
bitrate with adaptive quantisation, half-sample motion search.

The encoder shares the decoder's code tables, IDCT, dequantisation and
motion compensation, so the decoder outputs exactly the encoder's
reconstruction. B pictures, a VBV guarantee, interlaced coding and DVD
or broadcast presets are later steps of #1133.

The mpeg2 feature is split into mpeg2-decode and mpeg2-encode; mpeg2
still turns on both.
2026-11-13 07:34:05 +01:00
Dylan M. Taylor 47bf5650b0 Expose shared InDesign signature 2026-11-13 01:31:26 -05:00
Dylan M. Taylor 96c8487984 Add shared InDesign conversion facade 2026-11-13 01:30:54 -05:00
Dylan M. Taylor bdba99322e Use canonical winprint repository URL 2026-11-13 01:28:04 -05:00
Dylan M. Taylor 6ba1ca33ca Recognize InDesign files in shared registry 2026-11-13 01:27:11 -05:00
Dylan M. Taylor 1f9c271f7d Recognize legacy Word extension in shared registry 2026-11-13 01:26:09 -05:00
Dylan M. Taylor 32529b94e8 Resolve plain text format extensions 2026-11-13 01:24:40 -05:00
Dylan M. Taylor fdfb188855 Use array chunks for raster pixels 2026-11-13 01:24:36 -05:00
Dylan M. Taylor fc9ecb40e7 Extend shared file-format registry 2026-11-13 01:22:58 -05:00
Dylan M. Taylor a47b78256c Expose shared embedded ICC extraction 2026-11-13 01:15:30 -05:00
Dylan M. Taylor 80731087bf Merge remote-tracking branch 'origin/main' into codex/1154-main-refresh 2026-11-13 06:10:02 +00:00
Dylan M. Taylor c6ae974743 Expose shared decoded DNG JPEG XL previews 2026-11-13 01:09:49 -05:00
Dylan M. Taylor 79923702ff Merge remote-tracking branch 'origin/main' into fix/psd-head-view 2026-11-13 06:06:44 +00:00
Dylan M. Taylor 21d7c1267e metafile: draw GDI+ percentage hatch styles 2026-11-13 06:05:42 +00:00
Dylan M. Taylor 913b1aa97f Merge remote-tracking branch 'origin/codex/craft-time-soundcraft' into codex/soundcraft-format 2026-11-13 06:05:40 +00:00
Dylan M. Taylor 07a4cd0fc7 #778: preserve consumer VP8 frame limits 2026-11-13 06:05:39 +00:00
Dylan M. Taylor 10a2d6dd14 Merge remote-tracking branch 'origin/main' into codex/craft-time-soundcraft 2026-11-13 06:05:34 +00:00
Dylan M. Taylor 93d75f44d7 Merge remote-tracking branch 'origin/main' into feat/stencilcraft-format 2026-11-13 06:05:00 +00:00
Dylan M. Taylor d6ed8c20f1 Merge pull request #1161 from dylanmtaylor/codex/workspace-gate-main
ci: route workspace checks through shared gate
2026-11-13 01:04:23 -05:00
Dylan M. Taylor 85145d8dfd Expose shared raster source and tone inspection 2026-11-13 00:58:35 -05:00
Dylan M. Taylor 4b8dde4c12 test(stencilcraft-format): exercise reader scalar root variants 2026-11-13 05:52:28 +00:00
Dylan M. Taylor eb379cf3d2 test(stencilcraft-format): cover scalar JSON roots 2026-11-13 05:51:08 +00:00
Dylan M. Taylor 8bac629c0f Preserve CFA anchor in shared raw metadata 2026-11-13 00:46:33 -05:00
Dylan M. Taylor d8cc88a772 Add image document formats to shared registry 2026-11-13 00:39:59 -05:00
Dylan M. Taylor ba24fe2435 Move bounded EPS rectangle parsing to craft-eps 2026-11-13 00:39:37 -05:00
Dylan M. Taylor c1a1b976d0 Resolve raster subformats centrally 2026-11-13 00:34:48 -05:00
Dylan M. Taylor 8d3c753b5e Recognize G-code filename extensions 2026-11-13 00:34:11 -05:00
Dylan M. Taylor 79c2003ac9 Add shared file format detection 2026-11-13 00:30:56 -05:00
Dylan M. Taylor 7c3a099ad8 Read native format JSON from streams 2026-11-13 05:21:58 +00:00
Dylan M. Taylor 3bdf0eaadd Format shared image codec crate 2026-11-13 00:17:35 -05:00
Dylan M. Taylor 9430f2807e Add shared image codec facade 2026-11-13 00:17:04 -05:00
Dylan M. Taylor 3afade5163 Expose renderer-neutral SVG preflight 2026-11-13 00:13:31 -05:00
Dylan M. Taylor e95c99e7bc Support common raster output formats by path 2026-11-13 00:10:01 -05:00
Dylan M. Taylor dc705aa364 Re-export common RGBA pixel types 2026-11-13 00:09:00 -05:00
Dylan M. Taylor 1dbfad04fd Support extension-based raster encoding 2026-11-13 00:08:05 -05:00
kiwi4boy 79b4fd0144 craft-xlsx: review fixes: CONVERT, shared formula tokens borrowed, cell metadata with its formula
From the first review round:

- 468 (0x1D4) is CONVERT, with 3 arguments. [MS-XLSB]'s Ftab table has no row for it, though
  its grammar lists convert-params among the fixed-argument functions; Excel writes
  =CONVERT(1,"m","ft") in .xlsb as a PtgFunc calling 0x1D4 (observed in Excel). It was the only
  unassigned number from 0x17C to 0x1E4. The module doc says it isn't the specification's row.
- A BrtShrFmla's tokens and extra data are borrowed from the worksheet part instead of copied: a
  record may claim up to 256 MiB, and each shared formula is kept for the rest of the sheet, so
  the copies could cost as much again as the part. BrtArrFmla's are used at once and borrowed too.
- A formula record's cell metadata goes with its formula: when the formula is kept as its value
  (tokens the reader can't decode, an unreadable BrtArrFmla), the cell loses its `cm`, which
  would otherwise mark a dynamic-array formula that isn't there. A value cell keeps its cell
  metadata, as the file has it.

The CONVERT and cell-metadata tests fail without this commit. The Excel-saved workbook still
reads with all 33 formulas as in its .xlsx.
2026-11-13 00:04:32 -05:00
Dylan M. Taylor 5407ea8220 Document required kerf field in native format example 2026-11-13 00:04:29 -05:00
Dylan M. Taylor 4ecdcd78da Export common raster codec facade 2026-11-13 00:03:41 -05:00
Dylan M. Taylor 8c41139369 Add shared raster codec facade and versioned JSON headers 2026-11-13 00:01:32 -05:00
Dylan M. Taylor ca7a73bd2c ci: allow longer Windows workspace gate 2026-11-13 04:50:46 +00:00
kiwi4boy 20050077ad craft-xlsx: the README describes formulas in binary workbooks
They were "token streams that are not decoded". The README now says what the decoder gives
(text in the file's spelling, shared and array kinds and ranges, cell metadata, each shared copy's
own text), what keeps its saved result and why, that the function table and printer are this
crate's own, and the binary_formula_text limit with the decoder's fixed bounds.
2026-11-12 23:36:47 -05:00
kiwi4boy 1f5f1f0f51 craft-xlsx: a shared formula stops decoding copies once one is kept as its value
From gridcraft#3821's review (CodeRabbit, still open there): a shared formula's copies are
checked against the formula text allowance with the first cell's length, which a copy can
exceed. A copy that was decoded and printed, then kept as its value because it didn't fit, or
because it couldn't be decoded, charged nothing, so a file with many cells of one long shared
formula could repeat that work for each of them. The PR's case was GridCraft's 8,192-character
rejection, which isn't here; the allowance and decode failures are the same path.

After one such copy the group keeps every later copy as its value without decoding it, so a
group costs at most one wasted decode. A new test shows a later copy that would have fit kept
as its value; it fails without this commit.
2026-11-12 23:36:18 -05:00
kiwi4boy 734ade8cd9 craft-xlsx: read shared, array and dynamic-array formulas from .xlsb files (port of gridcraft#3821)
A cell whose tokens are only PtgExp (row) + PtgExtraCol (column) belongs to the shared or array
formula starting there; its first cell is followed by BrtShrFmla or BrtArrFmla.

- Shared formulas: each cell's copy is decoded from the shared tokens at its own cell, as
  [MS-XLSB] defines it (PtgRefN/PtgAreaN offsets, wrapping around the grid). Every cell of the
  group gets FormulaKind::Shared, its own text and the group's index (`si`, counted per sheet);
  the first also gets the group's range. Its first cell is the first that uses it, anywhere in
  its range. Copies are charged to the formula text allowance before they are decoded, so a long
  formula shared by a million cells stops costing once the allowance is spent.
- Ctrl+Shift+Enter and dynamic arrays: the first cell gets FormulaKind::Array with its range; a
  dynamic one also has its cell metadata (BrtCellMeta, which now also holds across a BrtValueMeta
  written in between), as `cm` marks it in .xlsx. The other cells of an array keep their cached
  values and have no formula, as in .xlsx.
- A record that can't be read leaves its range as values and never fails the file, with a
  warning; so does a first cell with no formula record after it.

Ported from storytold/gridcraft#3821 (issue gridcraft#3806), with its review fixes (each copy
decoded at its own cell; a shared formula may start inside its range). Changed from the
GridCraft PR:
- In .xlsx a shared formula's other cells have empty text. Here they have their own decoded text
  (and CellFormula's doc says so), because that is exact where shifting the first cell's text is
  not, as the PR's review found.
- Clearing an array's other cells for recalculation, marking dynamic arrays to spill, and the
  check against GridCraft's parser's 8,192-character limit are GridCraft's reading, not the
  file's: the cells keep what the file holds. That test becomes one that a copy may be longer
  than its first cell.
The PR's tests come along in tests/xlsb.rs, with craft-xlsx's model in the expectations.

Checked against Excel: in a workbook Excel saved both as .xlsb and as .xlsx, every formula this
reads (33, shared, array and dynamic ones included) has the .xlsx text, kind and range; the other
5 use tables, an external link or defined names.
2026-11-12 23:34:15 -05:00
kiwi4boy 787b3e44f4 craft-xlsx: read cell formulas from .xlsb files (port of gridcraft#3818)
A BIFF12 decoder for cell formulas (xlsb/formula.rs), separate from craft-xls's BIFF8 one because
nearly every operand differs (32-bit rows, 14-bit columns, UTF-16 strings, its own array-constant
codes, newer functions called through hidden names). It reads references, 3-D references,
constants, array constants, functions by number (xlsb/ftab.rs) and newer functions through
Excel's hidden _xlfn. names. A formula cell's CellFormula holds the text as an .xlsx file holds it
(`_xlfn.CONCAT`, `_xlpm.x`, no implicit `@`), and a BrtCellMeta before a cell gives it
cell_metadata, as `cm` does. Reverse-Polish tokens group by order alone, so the decoded tree
gets the parentheses its text needs from operator precedence; Excel's own text is unchanged. A
chain of string constants joined with & prints as one flat chain.

What a formula refers to must be readable too, so shared, array and data-table forms, user
defined names (XLSB names aren't read yet), table references, external links and PY(index, ...)
(code stored elsewhere in the package) keep only their saved results, with a warning saying why.
So does a formula past Limits::binary_formula_text (128 MiB of text over the workbook). The
workbook's links and names are optional: if they can't be read, the file opens with values only,
as before, and a warning says so.

Ported from storytold/gridcraft#3818 (issue gridcraft#3806), with its two review fixes
(grouping by precedence, the flat & chain). Changed from the GridCraft PR:
- The tree and its A1 printer (xlsb/expr.rs) are a copy of craft-xls's expr.rs, with
  BinOp::precedence added; the decoder's stack and depth guards are copies of craft-xls's. The
  PR used GridCraft's formula crate and shared these with GridCraft's .xls decoder.
- No fmla::from_file, implicit `@`, parse check or Python-cell adoption: those are GridCraft's
  reading of the text, not the file's. A single-cell dynamic-array formula is read (with its
  cell metadata) instead of being kept as its value; the PR left dynamic arrays to the next PR.
- The links are read with the workbook part and kept by Package for its sheets.
Its tests come along in tests/xlsb.rs, with the expected text in the file's spelling.

Checked against Excel: of the formulas in a workbook Excel saved both as .xlsb and as .xlsx,
every one this reads (26) has the text of the .xlsx; the other 12 are the kinds above.
2026-11-12 23:29:29 -05:00