codecs/audio: comments to specs only

This commit is contained in:
4DBug committed 2026-11-01 01:55:39 -05:00
1 parent 0bd7b87d2b
commit 6dcce481bb
69 files changed
+523 -1604

No files matched your search

+4 -12
View File
@@ -1,9 +1,8 @@
--!strict
--!native
--!optimize 2
-- codecs/audio/Opus/Decoder: The Opus decoder proper (libopus src/opus_decoder.c and opus_multistream_decoder.c): per-frame mode switching
-- between SILK, hybrid and CELT, the redundant CELT frames of mode transitions, cross-fades, PLC fallbacks, the
-- multi-frame packet loop and multistream (channel mapping) decoding. Output is 48 kHz float in Luau arrays.
-- codecs/audio/Opus/Decoder: the Opus decoder proper (libopus src/opus_decoder.c and opus_multistream_decoder.c).
-- SILK / hybrid / CELT mode switching, redundant CELT frames of mode transitions, cross-fades, PLC, multistream.
local RD = require("@rosetta/codecs/entropy/RangeCoder/Decoder")
local Packet = require("@rosetta/codecs/audio/Opus/Packet")
local Celt = require("@rosetta/codecs/audio/Opus/Celt")
@@ -153,7 +152,6 @@ local function decodeFrame(st: State, buf: buffer?, off: number, len: number, pc
end
frameSize = audiosize
-- SILK
if mode ~= MODE_CELT then
local tooSmall = frameSize < F10
local sarr, sbase = pcm, pbase
@@ -289,8 +287,7 @@ local function decodeFrame(st: State, buf: buffer?, off: number, len: number, pc
return audiosize
end
-- opus_decode_native: decodes one packet (buf == nil or len == 0: conceal frameSize samples). pcm[pbase + i * ch + c].
-- Returns the samples per channel (or < 0 on error) and the packet's size (self-delimited packets).
-- opus_decode_native (buf nil or len 0: conceal frameSize samples)
function Decoder.decode(st: State, buf: buffer?, off: number, len: number, pcm: { number }, pbase: number, frameSize: number, selfDelimited: boolean?): (number, number)
local ch = st.channels
if buf == nil or len == 0 then
@@ -337,7 +334,6 @@ function Decoder.decode(st: State, buf: buffer?, off: number, len: number, pcm:
return nb, packetOffset
end
-- ---------------------------------------------------------------------------------------------------------------
-- multistream (channel mapping families 0 / 1 / 255)
export type MS = {
@@ -370,7 +366,6 @@ function Decoder.resetMultistream(ms: MS)
end
end
-- copies channel `sc` of src (stride sstride) into every output channel mapped to stream channel index `id`
local function copyOut(ms: MS, id: number, src: { number }, sc: number, sstride: number, pcm: { number }, pbase: number, n: number)
local nch = ms.channels
for c = 0, nch - 1 do
@@ -386,7 +381,7 @@ local function copyOut(ms: MS, id: number, src: { number }, sc: number, sstride:
end
end
-- opus_multistream_decode_native (float). Returns the samples per channel, or < 0 on error.
-- opus_multistream_decode_native
function Decoder.decodeMultistream(ms: MS, buf: buffer?, off: number, len: number, pcm: { number }, pbase: number, frameSize: number): number
local doPlc = buf == nil or len == 0
frameSize = min(frameSize, 5760)
@@ -428,7 +423,6 @@ function Decoder.decodeMultistream(ms: MS, buf: buffer?, off: number, len: numbe
return frameSize
end
-- writes src[base + 1 .. base + count] * gain to out as f32 from byte offset o
function Decoder.writeF32(src: { number }, base: number, count: number, gain: number, out: buffer, o: number)
local writef32 = buffer.writef32
if gain == 1 then
@@ -444,8 +438,6 @@ function Decoder.writeF32(src: { number }, base: number, count: number, gain: nu
end
end
-- Stereo downmix of n frames of srcCh-channel audio (src[base + 1 ..], interleaved): matrix[c * 2 + 1 / + 2] are the
-- left / right weights of channel c. Writes f32 to out from byte offset o.
function Decoder.writeDownmix(src: { number }, base: number, n: number, srcCh: number, matrix: { number }, gain: number, out: buffer, o: number)
local writef32 = buffer.writef32
local p = base