ws-audio: MP3 layer III encoder (Encode3: shine-style CBR, MPEG-1/2/2.5, mono/stereo/joint MS, global-gain rate loop, region/table choice, count1 A/B) + MP2 layer II encoder (Encode2: standard alloc tables, greedy noise allocation, grouping), shared polyphase Analysis, EncTables (PDMP3 public-domain window + Huffman trees -> codeword tables); mp3 init encode() with ID3v2.4; fixtures decode with ffmpeg + lame (no errors, SNR floors); bench lines
This commit is contained in:
1 parent
4dbd236962
commit
e817053a40
14 files changed
+1859
-12
No files matched your search
@@ -144,3 +144,19 @@ do
|
||||
print(string.format("%-8s %-30s %8.0fx real time", runtime, "", 10 / dt))
|
||||
end
|
||||
end
|
||||
-- mp3 / mp2 encode (ws-audio): 10 s of 44.1 kHz stereo tones
|
||||
do
|
||||
local M3 = require("@formats/audio/mp3")
|
||||
local n = 441000
|
||||
local a = Types.Audio.new(44100, 2, n)
|
||||
for i = 0, n - 1 do
|
||||
buffer.writef32(a.samples, i * 8, math.sin(i * 0.031) * 0.4 + math.sin(i * 0.21) * 0.1)
|
||||
buffer.writef32(a.samples, i * 8 + 4, math.sin(i * 0.017) * 0.3)
|
||||
end
|
||||
for _, cfg in { { layer = 3, bitrate = 128 }, { layer = 2, bitrate = 192 } } do
|
||||
local dt = bench(string.format("mp%d encode %d kbps (10 s st)", cfg.layer, cfg.bitrate), 2, n * 8, function()
|
||||
M3.encode(a, cfg)
|
||||
end)
|
||||
print(string.format("%-8s %-30s %8.1fx real time", runtime, "", 10 / dt))
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user