codecs/audio: comments to specs only
This commit is contained in:
1 parent
0bd7b87d2b
commit
6dcce481bb
69 files changed
+523
-1604
No files matched your search
@@ -1,19 +1,7 @@
|
||||
--!strict
|
||||
-- codecs/audio/Ape: the Monkey's Audio codec (.ape). A codec (layer 3). Ported from the Monkey's Audio SDK 13.28
|
||||
-- (Matthew T. Ashland, BSD 3-clause since v10, licenses/monkeys-audio-LICENSE.txt): APEHeader.cpp (the descriptor /
|
||||
-- header / seek table, and the pre-3.98 header), APEInfo / APEDecompress.cpp (frame bytes and alignment); the frame
|
||||
-- decoder is codecs/audio/Ape/Decode. Supports file versions 3.95 and later (3.99+ as the current encoder writes; the
|
||||
-- 3.95 - 3.98 range coder model is ported but has no reference fixture), every compression level (fast, normal, high,
|
||||
-- extra high, insane), 8 / 16 / 24 / 32-bit integer and 32-bit float, 1 - 32 channels, special frames (silence,
|
||||
-- pseudo stereo) and the frame CRC. Not supported: versions before 3.95 (UNSUPPORTED), the "interim" 24-bit
|
||||
-- re-decode for files of the 32-bit era before 8.50, big-endian / signed 8-bit source flags (the samples are returned
|
||||
-- as numbers either way).
|
||||
--
|
||||
-- local info, err = Ape.info(buf, base, limit) -- header facts + the frame table
|
||||
-- local dec = Ape.decoder(info)
|
||||
-- local n, err = dec:frame(buf, i) -- frame i (1-based) -> dec.pcm (interleaved; integers, or floats)
|
||||
--
|
||||
-- Never throws: bad data returns nil, Err.
|
||||
-- codecs/audio/Ape: the Monkey's Audio codec (.ape), file versions 3.95 and later.
|
||||
-- Ported from the Monkey's Audio SDK 13.28 (Matthew T. Ashland, BSD 3-clause since v10, licenses/monkeys-audio-LICENSE.txt):
|
||||
-- APEHeader.cpp, APEInfo / APEDecompress.cpp. Not supported: pre-3.95 (UNSUPPORTED), the pre-8.50 "interim" 24-bit re-decode.
|
||||
local Err = require("@rosetta/core/Err")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
local Decode = require("@rosetta/codecs/audio/Ape/Decode")
|
||||
@@ -22,7 +10,7 @@ local Ape = {}
|
||||
|
||||
export type Info = {
|
||||
version: number, -- file version * 1000 (3990)
|
||||
programVersion: number, -- 13280 (0 when not stored)
|
||||
programVersion: number,
|
||||
level: number, -- 1000 (fast) .. 5000 (insane)
|
||||
flags: number,
|
||||
channels: number,
|
||||
@@ -33,16 +21,15 @@ export type Info = {
|
||||
finalFrameBlocks: number,
|
||||
totalFrames: number,
|
||||
totalBlocks: number,
|
||||
frameStart: { number }, -- byte offset of each frame
|
||||
frameStart: { number },
|
||||
firstFrame: number, -- byte offset of frame 1 (the word alignment origin)
|
||||
dataEnd: number, -- the end of the frame data
|
||||
limit: number, -- the end of the file data (frames past it are truncated)
|
||||
dataEnd: number,
|
||||
limit: number,
|
||||
md5: string?,
|
||||
}
|
||||
|
||||
local FLAG_8, FLAG_24, FLAG_PEAK, FLAG_SEEKN, FLAG_WAVHDR, FLAG_FLOAT = 1, 8, 4, 16, 32, 4096
|
||||
|
||||
-- find(buf, base, limit) -> the offset of "MAC " / "MACF" (after an ID3v2 tag) | nil
|
||||
function Ape.find(buf: buffer, base: number, limit: number): number?
|
||||
local at = base
|
||||
if limit - at >= 10 and buffer.readstring(buf, at, 3) == "ID3" then
|
||||
@@ -70,7 +57,6 @@ function Ape.find(buf: buffer, base: number, limit: number): number?
|
||||
return if k then at + k - 1 else nil
|
||||
end
|
||||
|
||||
-- info(buf, base, limit) -> Info | nil, Err
|
||||
function Ape.info(buf: buffer, base: number, limit: number): (Info?, Err.Err?)
|
||||
local at = Ape.find(buf, base, limit)
|
||||
if not at then
|
||||
@@ -184,7 +170,6 @@ function Ape.info(buf: buffer, base: number, limit: number): (Info?, Err.Err?)
|
||||
return info :: Info, nil
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ decoder
|
||||
export type Decoder = {
|
||||
info: Info,
|
||||
pcm: { number },
|
||||
@@ -212,7 +197,6 @@ local function frame(self: Decoder, buf: buffer, i: number): (number?, Err.Err?)
|
||||
return n2, nil
|
||||
end
|
||||
|
||||
-- decoder(info) -> Decoder | nil, Err
|
||||
function Ape.decoder(info: Info): (Decoder?, Err.Err?)
|
||||
local st, msg = Decode.state(info.version, info.level, info.bitsPerSample, info.channels)
|
||||
if not st then
|
||||
|
||||
Reference in new issue
Block a user