codecs/audio/Aac: probe parses only, two frames for AAC-LC streams

This commit is contained in:
4DBug committed 2026-11-02 00:38:29 -06:00
1 parent a081e7d437
commit 9a4cacc40b
4 files changed
+2406 -695

No files matched your search

+5
View File
@@ -153,6 +153,7 @@ export type State = {
map: { number }?,
-- SBR output (codecs/audio/Aac/Sbr): sbrRate = the output rate when on, psOut = a mono stream output as stereo
sbrOn: boolean,
probe: boolean, -- parse only (SBR / PS detection): no output
sbrRate: number,
psOut: boolean,
sbrElems: { any },
@@ -927,6 +928,9 @@ function Decode.frame(st: State, buf: buffer, off: number, len: number): (number
if n == 0 then
return 0, nil
end
if st.probe then
return n, nil
end
if st.sbrOn then
return sbrOutput(st, order, nElem), nil
end
@@ -955,6 +959,7 @@ function Decode.state(sfIndex: number): State
sbr = false,
map = nil,
sbrOn = false,
probe = false,
sbrRate = 0,
psOut = false,
sbrElems = {},
+5
View File
@@ -309,6 +309,7 @@ local function probe(self: Decoder, buf: buffer, offset: number?, length: number
scratch.channels = cfg.channels
scratch.map = self.state.map
scratch.sbrOn = true
scratch.probe = true
scratch.sbrRate = cfg.sampleRate * 2
scratch.psOut = cfg.channels == 1
local chans = Decode.frame(scratch, buf, o, n)
@@ -335,6 +336,10 @@ function Aac.probeFrames(d: Decoder, buf: buffer, offs: { number }, sizes: { num
if d:probe(buf, offs[i], sizes[i]) then
changed = true
end
-- SBR data is in every frame of an HE-AAC stream; a PS header may come later
if i >= 2 and not d.sbrOutput or d.ps or (d.sbrOutput and d.config.channels ~= 1) then
break
end
end
return changed
end