ws-cleanup: consistency (lower-case tags, WAVE channel order, loops = play count, Err messages, caps)

- Audio tags keys are lower case everywhere (Types.Tags): FLAC no longer returns TITLE / ARTIST (the raw fields stay
  in meta.source.comments; also for Vorbis and Opus); Vorbis / Opus / FLAC read and write tags through
  codecs/VorbisComment (TRACKNUMBER -> track, DISCNUMBER -> disc, DESCRIPTION -> comment); MP3 albumArtist ->
  albumartist and year -> date (ID3 TYER / TDRC, ID3v1); RIFF INFO / CAF / MP4 freeform names are lower-cased (MP4
  writes iTunSMPB / iTunNORM back in their usual spelling; m4a reads tags.itunsmpb).
- Channel order: Vorbis (and Opus mapping family 1) decode to WAVE order like FLAC / WAV / AAC (both used to return
  the Vorbis order); the Vorbis encoder takes WAVE order and writes Vorbis order. Pcm.WAVE_FROM_VORBIS / Pcm.reorder;
  Vorbis.packetDecoder gives pd.order. Tests reorder oggdec's / opusdec's raw (Vorbis-order) references.
- img.loops is the play count in GIF, APNG and WebP (they already agreed; Types / WebP docs said "loop count");
  tests/api round-trips loops 0 / 1 / 3 through all three.
- Err: messages without the format name (png / midi encoders said "png encode: ..."); codecs/Bzip2 and codecs/Zstd
  check arguments through Bytes.span.
- caps: mp3 encodeLayers = { 2, 3 }, opus encodeChannels = 2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
4DBugandClaude Opus 5.5 committed 2026-10-31 11:01:22 -05:00
1 parent 8158acf3d5
commit fb2dd98db2
27 files changed
+164 -170

No files matched your search

+7 -5
View File
@@ -18,11 +18,12 @@ INPUTS = ["src/Formats/audio/vorbis", "src/Formats/codecs", "src/Formats/contain
WAVE_FROM_VORBIS6 = [0, 2, 1, 4, 5, 3] # vorbis channel k is WAVE channel WAVE_FROM_VORBIS6[k]
def reorder(x):
def to_wave(x):
"""6-channel samples in Vorbis order -> WAVE order"""
out = [0.0] * len(x)
for i in range(0, len(x) - 5, 6):
for k in range(6):
out[i + k] = x[i + WAVE_FROM_VORBIS6[k]]
out[i + WAVE_FROM_VORBIS6[k]] = x[i + k]
return out
@@ -59,11 +60,12 @@ def generate(ctx):
problems = "\n".join(l for l in info.split("\n") if re.search(r"(?i)warning|error", l))
raw = A.tool(ctx, "vorbis-tools", ["oggdec", "-Q", "-R", "-o", "{out}", "{in}"], data, "ogg", "raw")
od = [int.from_bytes(raw[i:i + 2], "little", signed=True) / 32768 for i in range(0, len(raw) - 1, 2)]
osnr, _ = A.snr(samples, od, ch) # (oggdec -R keeps the Vorbis channel order)
if ch == 6: # the input is in WAVE order (FL FR FC LFE RL RR); oggdec -R keeps the Vorbis order (FL FC FR RL RR LFE)
od = to_wave(od)
osnr, _ = A.snr(samples, od, ch)
ffe = A.tool(ctx, "ffmpeg", ["ffmpeg", "-v", "error", "-i", "{in}", "-f", "null", "-"], data, "ogg").decode(errors="replace")
_, fch, ff = A.ffdecode(ctx, data, ext="ogg")
if ch == 6: # ffmpeg reorders to WAVE order (FL FR FC LFE RL RR); Vorbis order is FL FC FR RL RR LFE
ff = reorder(ff)
# (ffmpeg decodes to WAVE order, like our decoder)
fsnr, _ = A.snr(samples, ff, ch) if fch == ch else (-99.0, 0)
e = {"name": name, "sig": sigmod, "quality": q, "rate": rate, "channels": ch, "frames": frames, "ogginfo": problems,
"oggdecFrames": len(od) // ch, "oggdecSnr": osnr, "ffFrames": len(ff) // max(1, fch), "ffSnr": fsnr,