ws-polish: Flash ADPCM (FLV SoundFormat 1) decodes through codecs/audio/Adpcm.swf
Adpcm.swf / swfFrames: the SWF ADPCM bit stream (2..5-bit codes, 4096-frame blocks), bit-exact with ffmpeg's adpcm_swf (mono and stereo FLV fixtures). containers/AudioWrap decodes adpcm_swf tracks into a float WAV, so FLV audio opens through the api hook.
This commit is contained in:
1 parent
c0412f76cb
commit
c420eab820
7 files changed
+181
-12
No files matched your search
+24
-1
@@ -2,7 +2,8 @@
|
||||
-- (tools/fixtures/adpcm.py: ADX from ffmpeg and PS-ADPCM / DSP from our Python encoders decoded by vgmstream, Apple
|
||||
-- ima4 from ffmpeg, IMA nibble streams decoded by ffmpeg); ADX coefficients; the encoders (IMA nibbles, IMA WAV
|
||||
-- blocks, MS blocks) decoded back with a signal-to-noise floor; the Decoder layouts (seeking matches a straight
|
||||
-- read); a fuzz pass of random bytes through every kernel (ranges valid, contents random) and the layouts.
|
||||
-- read); Flash ADPCM by hand; a fuzz pass of random bytes through every kernel (ranges valid, contents random) and
|
||||
-- the layouts.
|
||||
local T = require("@tests/T")
|
||||
local Adpcm = require("@formats/codecs/audio/Adpcm")
|
||||
local Decoder = require("@formats/codecs/audio/Adpcm/Decoder")
|
||||
@@ -88,6 +89,25 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- Flash ADPCM (bit-exact with ffmpeg's adpcm_swf in tests/video/flv.luau): a hand-made 2-bit packet of 4 bytes:
|
||||
-- code size 0 (2-bit codes), first sample 100, step index 0, then the codes 01 11 00 00
|
||||
do
|
||||
local bits = "00" .. "0000000001100100" .. "000000" .. "01110000"
|
||||
local src = buffer.create(4)
|
||||
for i = 0, 3 do
|
||||
buffer.writeu8(src, i, tonumber(string.sub(bits, i * 8 + 1, i * 8 + 8), 2) :: number)
|
||||
end
|
||||
t:eq(Adpcm.swfFrames(src, 0, 4, 1), 5, "swf: frames in a 4-byte packet")
|
||||
local out = buffer.create(20)
|
||||
t:eq(Adpcm.swf(src, 0, 4, 1, out, 0), 5, "swf: frames decoded")
|
||||
-- 01: +7 + 7/2 = 110 (index 0 + 2: step 9); 11: -(9 + 4) = 97 (index 4: step 11); 00: +5 = 102 (index 3: step
|
||||
-- 10); 00: +5 = 107
|
||||
local want = { 100, 110, 97, 102, 107 }
|
||||
for i, v in want do
|
||||
t:eq(buffer.readf32(out, (i - 1) * 4) * 32768, v, "swf sample " .. i)
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ encoders
|
||||
local function snr(x: buffer, y: buffer, count: number): number
|
||||
local sig, err = 0, 0
|
||||
@@ -235,6 +255,9 @@ t:fuzz("kernels", function(b: buffer)
|
||||
if n >= 17 then
|
||||
Adpcm.modplug(b, 0, math.min((n - 16) * 2, 1000), out, 0)
|
||||
end
|
||||
if n >= 1 then
|
||||
Adpcm.swf(b, 0, math.min(n, 600), 1 + n % 2, buffer.create(Adpcm.swfFrames(b, 0, math.min(n, 600), 1 + n % 2) * 8 + 8), 0)
|
||||
end
|
||||
Adpcm.imaWav(b, 0, n, 2, 1017, buffer.create(1017 * 2 * 4), 0)
|
||||
Adpcm.msBlock(b, 0, n, 2, 1012, buffer.create(1012 * 2 * 4), 0, coefs, 8, buffer.create(40))
|
||||
local dec = Decoder.interleaved({ sampleRate = 8000, channels = 2, tags = {} }, { kind = "adx", buf = b, offset = 0, size = n, interleave = 18, c1 = 7334, c2 = -3283 })
|
||||
|
||||
Reference in new issue
Block a user