ws-audio2: codecs/audio/Adpcm (IMA / ima4 / IMA WAV / MS / ADX / PS-ADPCM / DSP decode, IMA + MS encode, Decoder layouts) and audio/adpcm (raw streams)
- codecs/audio/Adpcm: decoder kernels bit-exact with ffmpeg (IMA, ima4, MS) and vgmstream (ADX, PS-ADPCM, DSP); IMA nibble / IMA WAV / MS block encoders. Adpcm/Decoder: streaming Decoders over the shared layouts (channel interleaved frames, nibble streams, self-contained blocks) with exact seeking through state snapshots. - audio/wav: its IMA / MS block decoders moved to codecs/audio/Adpcm (wav tests unchanged and green). - codecs/audio/Stream (shared, small and backward compatible): pcm() may return a buffer of f32 (copied with buffer.copy) instead of a table. - audio/adpcm: headerless ima / ima_wav / ms / ima_qt / psx streams by options; encode ima / ima_wav / ms. - licenses: vgmstream (ISC).
This commit is contained in:
1 parent
de4f14a343
commit
363b14932f
14 files changed
+1931
-166
No files matched your search
@@ -21,6 +21,7 @@ local Types = require("@formats/Types")
|
||||
local Pcm = require("@formats/codecs/audio/Pcm")
|
||||
local Riff = require("@formats/containers/Riff")
|
||||
local Codecs = require("@formats/audio/wav/Codecs")
|
||||
local Adpcm = require("@formats/codecs/audio/Adpcm")
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ contract
|
||||
local Wav = {
|
||||
@@ -28,7 +29,7 @@ local Wav = {
|
||||
category = "audio",
|
||||
extensions = { "wav", "wave", "rf64", "bw64" },
|
||||
mime = { "audio/wav", "audio/x-wav", "audio/wave", "audio/vnd.wave" },
|
||||
deps = { "core/Err", "core/Bytes", "Types", "containers/Riff", "codecs/audio/Pcm" },
|
||||
deps = { "core/Err", "core/Bytes", "Types", "containers/Riff", "codecs/audio/Pcm", "codecs/audio/Adpcm" },
|
||||
caps = { decode = true, encode = true, streaming = true, depths = { 8, 16, 24, 32 }, float = true, rf64 = true },
|
||||
}
|
||||
|
||||
@@ -488,8 +489,7 @@ function Wav.open(r: Bytes.Reader, _opts: OpenOptions?): (Decoder?, Err.Err?)
|
||||
spb = computed
|
||||
end
|
||||
-- coefficients from the fmt extension, else the 7 standard pairs
|
||||
local c1 = { 256, 512, 0, 192, 240, 460, 392 }
|
||||
local c2 = { 0, -256, 0, 64, 0, -208, -232 }
|
||||
local c1, c2 = Adpcm.MS_COEF1, Adpcm.MS_COEF2
|
||||
local ncoef = 7
|
||||
if fmt.avail >= 22 then
|
||||
local k = u16(fmt.body + 20)
|
||||
@@ -592,9 +592,9 @@ function Decoder.read(self: Decoder, maxFrames: number, out: buffer?): (buffer,
|
||||
local avail = math.min(ba, self.dataOffset + self.dataSize - off)
|
||||
local got
|
||||
if kind == "ima_adpcm" then
|
||||
got = Codecs.imaBlock(self._buf, off, avail, ch, spb, cache)
|
||||
got = Adpcm.imaWav(self._buf, off, avail, ch, spb, cache, 0)
|
||||
else
|
||||
got = Codecs.msBlock(self._buf, off, avail, ch, spb, cache, self._coefs :: buffer, self._ncoef,
|
||||
got = Adpcm.msBlock(self._buf, off, avail, ch, spb, cache, 0, self._coefs :: buffer, self._ncoef,
|
||||
self._state :: buffer)
|
||||
end
|
||||
self._cacheBlock = block
|
||||
|
||||
Reference in new issue
Block a user