tests/audio: comments: specs only

This commit is contained in:
4DBug committed 2026-11-01 01:51:26 -05:00
1 parent 75ddfb4068
commit 0eec255bfb
30 files changed
+66 -244

No files matched your search

+3 -10
View File
@@ -1,7 +1,5 @@
-- audio/mp3 encoder tests (layer III and layer II): every fixture-step encode (sample rates of MPEG-1 / 2 / 2.5,
-- bit rates 24 .. 384 kbps, stereo / joint / mono) decodes in ffmpeg without errors and in LAME, with the expected
-- length and an SNR over a per-bit-rate floor after aligning the decoder delay; our own decoder (the minimp3 port)
-- agrees; streaming from a Decoder gives the same bytes; the ID3v2 tag round-trips; option errors.
-- audio/mp3 encoder tests (layer III and II): fixture-step encodes decode in ffmpeg and LAME, SNR over a per-bit-rate
-- floor after aligning the decoder delay.
-- Fixtures: tools/fixtures/mp3_enc.py.
local T = require("@tests/T")
local Mp3 = require("@rosetta/audio/mp3")
@@ -21,7 +19,6 @@ local function audio(name: string): Types.Audio
return a
end
-- SNR of y (delayed by lag frames) against x over frames [from, to)
local function snr(x: Types.Audio, y: Types.Audio, lag: number, from: number, to: number): number
local ch = x.channels
local sig, er = 0, 0
@@ -85,7 +82,6 @@ for _, e in Enc do
if f > -math.huge then
minByLayer[e.layer] = math.min(minByLayer[e.layer], e.ffSnr)
end
-- our decoder agrees with ffmpeg
local x = audio(e.sig)
local y, err = Mp3.decode(Bytes.reader(buffer.fromstring(e.data)))
t:check(y, e.name .. ": our decoder: " .. tostring(err))
@@ -96,7 +92,6 @@ for _, e in Enc do
end
t:note("%d encodes: ffmpeg + LAME decode them; lowest SNR layer III %.1f dB, layer II %.1f dB", #Enc, minByLayer[3], minByLayer[2])
-- streaming, tags, defaults
do
local a = audio("music_2_44100")
local f1 = Mp3.encode(a, { bitrate = 128 }) :: buffer
@@ -128,8 +123,7 @@ do
t:check(empty and buffer.len(empty) > 0, "empty input: one flush frame")
end
-- other input rates are resampled (codecs/audio/Resample) to the next rate up: 44 kHz -> 44.1 kHz, 46 kHz -> 48 kHz,
-- layer II 8 kHz -> 16 kHz, opts.sampleRate
-- other input rates are resampled to the next rate up (codecs/audio/Resample)
do
local function tone(rate: number, f: number): any
local n = rate
@@ -166,7 +160,6 @@ do
end
end
-- errors
do
local function code(v: any, o: any): string?
local _, e = Mp3.encode(v, o)