codecs/audio/Aac: probe parses only, two frames for AAC-LC streams
This commit is contained in:
1 parent
a081e7d437
commit
9a4cacc40b
4 files changed
+2406
-695
No files matched your search
+1855
-155
File diff suppressed because it is too large.
Load diff
+541
-540
File diff suppressed because it is too large.
Load diff
@@ -153,6 +153,7 @@ export type State = {
|
|||||||
map: { number }?,
|
map: { number }?,
|
||||||
-- SBR output (codecs/audio/Aac/Sbr): sbrRate = the output rate when on, psOut = a mono stream output as stereo
|
-- SBR output (codecs/audio/Aac/Sbr): sbrRate = the output rate when on, psOut = a mono stream output as stereo
|
||||||
sbrOn: boolean,
|
sbrOn: boolean,
|
||||||
|
probe: boolean, -- parse only (SBR / PS detection): no output
|
||||||
sbrRate: number,
|
sbrRate: number,
|
||||||
psOut: boolean,
|
psOut: boolean,
|
||||||
sbrElems: { any },
|
sbrElems: { any },
|
||||||
@@ -927,6 +928,9 @@ function Decode.frame(st: State, buf: buffer, off: number, len: number): (number
|
|||||||
if n == 0 then
|
if n == 0 then
|
||||||
return 0, nil
|
return 0, nil
|
||||||
end
|
end
|
||||||
|
if st.probe then
|
||||||
|
return n, nil
|
||||||
|
end
|
||||||
if st.sbrOn then
|
if st.sbrOn then
|
||||||
return sbrOutput(st, order, nElem), nil
|
return sbrOutput(st, order, nElem), nil
|
||||||
end
|
end
|
||||||
@@ -955,6 +959,7 @@ function Decode.state(sfIndex: number): State
|
|||||||
sbr = false,
|
sbr = false,
|
||||||
map = nil,
|
map = nil,
|
||||||
sbrOn = false,
|
sbrOn = false,
|
||||||
|
probe = false,
|
||||||
sbrRate = 0,
|
sbrRate = 0,
|
||||||
psOut = false,
|
psOut = false,
|
||||||
sbrElems = {},
|
sbrElems = {},
|
||||||
|
|||||||
@@ -309,6 +309,7 @@ local function probe(self: Decoder, buf: buffer, offset: number?, length: number
|
|||||||
scratch.channels = cfg.channels
|
scratch.channels = cfg.channels
|
||||||
scratch.map = self.state.map
|
scratch.map = self.state.map
|
||||||
scratch.sbrOn = true
|
scratch.sbrOn = true
|
||||||
|
scratch.probe = true
|
||||||
scratch.sbrRate = cfg.sampleRate * 2
|
scratch.sbrRate = cfg.sampleRate * 2
|
||||||
scratch.psOut = cfg.channels == 1
|
scratch.psOut = cfg.channels == 1
|
||||||
local chans = Decode.frame(scratch, buf, o, n)
|
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
|
if d:probe(buf, offs[i], sizes[i]) then
|
||||||
changed = true
|
changed = true
|
||||||
end
|
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
|
end
|
||||||
return changed
|
return changed
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user