codecs/audio/Aac: HE-AAC (SBR) and HE-AACv2 (baseline PS) decoding

New shared modules under codecs/audio/Aac: Sbr (bitstream, band tables,
delta decoding), SbrBits, SbrQmf (32-band analysis / 64-band synthesis QMF
through DCT-IV), SbrHf (HF generation and adjustment), Ps (baseline PS),
SbrTables (ISO tables, from syom 0.8.1, MIT). Explicit signalling enables
SBR at construction; implicit SBR / PS is found by Decoder:probe /
Aac.probeFrames. audio/aac and audio/m4a report the output rate and take
opts.sbr = false for the core only; m4a scales iTunSMPB by the media tick.

Outside the folder: containers/AudioWrap writes an AAC-LC ADTS header for
HE-AAC AudioSpecificConfigs (the decoder finds SBR in the stream); the api's
default openAudio hook forwards opts.sbr.
This commit is contained in:
4DBug committed 2026-11-02 00:21:13 -06:00
1 parent 627ddded77
commit 686a1fbf86
14 files changed
+2967 -35

No files matched your search

+7 -3
View File
@@ -304,12 +304,12 @@ end
-- api hooks (a format never requires another format): opts.decodeImage / encodeImage, opts.plugins, opts.decodeModule,
-- opts.openAudio (containers/AudioWrap: PCM -> WAV, Opus / Vorbis -> Ogg, AAC -> ADTS, MP3 / FLAC / AC-3 as they are)
local function openAudio(demuxer: any, track: any): (any, Err.Err?)
local function openAudio(demuxer: any, track: any, sbr: boolean?): (any, Err.Err?)
local buf, fmt, err = AudioWrap.wrap(demuxer, track)
if not buf then
return nil, err
end
local dec, oerr = F.open(buf, { format = fmt, category = "audio" })
local dec, oerr = F.open(buf, { format = fmt, category = "audio", sbr = sbr })
-- Matroska CodecDelay: ffmpeg drops it for MPEG audio / AAC; Opus has its own pre-skip and Vorbis's delay is
-- already the decoder's own (its first packet returns nothing)
-- MP4 edit lists add the play length (the encoder's end padding is cut, as ffmpeg does)
@@ -332,7 +332,11 @@ local function withHooks(o: Options): Options
c.plugins = F.plugins
end
if c.openAudio == nil then
c.openAudio = openAudio
-- opts.sbr reaches the AAC decoder of a video's audio track
local sbr = o.sbr
c.openAudio = function(demuxer: any, track: any): (any, Err.Err?)
return openAudio(demuxer, track, sbr)
end
end
if c.decodeImage == nil then
c.decodeImage = function(b: buffer): (any, Err.Err?)