codecs/audio/Aac/SbrQmf: fused analysis fold; comment tidy
This commit is contained in:
1 parent
028bee3f59
commit
10f70c3a8a
3 files changed
+9
-16
No files matched your search
+1
-1
@@ -45,7 +45,7 @@ VideoDecoder saved to an image format (`gif`, `apng`, `webp`) becomes an animate
|
|||||||
one category. Extras:
|
one category. Extras:
|
||||||
|
|
||||||
- `F.video.open(src, opts?)`: `opts.maxSide` shrinks the frames (longer side at most n pixels), `opts.yield` is a
|
- `F.video.open(src, opts?)`: `opts.maxSide` shrinks the frames (longer side at most n pixels), `opts.yield` is a
|
||||||
cooperative yield point for slow codecs (H.264; see the video guide), `opts.audio = false` skips the audio track.
|
cooperative yield point for slow codecs (H.264; see the video guide), `opts.audio = false` skips the audio track, `opts.sbr = false` decodes only the AAC-LC core of an HE-AAC track.
|
||||||
It also opens animated images (GIF / APNG / WebP) as videos; `F.video.fromImage(img)`,
|
It also opens animated images (GIF / APNG / WebP) as videos; `F.video.fromImage(img)`,
|
||||||
`F.video.fromFrames(images, delays?)` (an image sequence: `F.save(F.video.fromFrames(list, 1 / 25), "out.avi")`),
|
`F.video.fromFrames(images, delays?)` (an image sequence: `F.save(F.video.fromFrames(list, 1 / 25), "out.avi")`),
|
||||||
`F.video.codecs` (the codec registry `codecs/video/Video`).
|
`F.video.codecs` (the codec registry `codecs/video/Video`).
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ local F_BAL30 = codebook(SbrTables.F_BAL30)
|
|||||||
local T_NOISE30 = codebook(SbrTables.T_NOISE30)
|
local T_NOISE30 = codebook(SbrTables.T_NOISE30)
|
||||||
local T_NOISEBAL30 = codebook(SbrTables.T_NOISEBAL30)
|
local T_NOISEBAL30 = codebook(SbrTables.T_NOISEBAL30)
|
||||||
|
|
||||||
-- ------------------------------------------------------------------------------------------------ band tables
|
|
||||||
local function nint(x: number): number
|
local function nint(x: number): number
|
||||||
return floor(x + 0.5)
|
return floor(x + 0.5)
|
||||||
end
|
end
|
||||||
@@ -141,7 +140,7 @@ local function masterTable(k0: number, k2: number, freqScale: number, alterScale
|
|||||||
return f
|
return f
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 4.6.18.6.3 patch construction: patchNum / patchStart per patch (nil when invalid)
|
-- 4.6.18.6.3 patch construction: e.patchNum / e.patchStart per patch (false when invalid)
|
||||||
local function patches(e: any, k0: number): boolean
|
local function patches(e: any, k0: number): boolean
|
||||||
local master, kx, m = e.fMaster, e.kx, e.M
|
local master, kx, m = e.fMaster, e.kx, e.M
|
||||||
local nMaster = #master - 1
|
local nMaster = #master - 1
|
||||||
@@ -359,11 +358,9 @@ local function deriveTables(e: any, h: any): boolean
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
e.mapH, e.mapL, e.mapQ = mapH, mapL, mapQ
|
e.mapH, e.mapL, e.mapQ = mapH, mapL, mapQ
|
||||||
-- the noise band of each patched target subband, for the chirp factor
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ------------------------------------------------------------------------------------------------ sbr_data
|
|
||||||
local function grid(c: any): boolean
|
local function grid(c: any): boolean
|
||||||
local class = bits(2)
|
local class = bits(2)
|
||||||
local nEnv = 1
|
local nEnv = 1
|
||||||
@@ -756,7 +753,6 @@ function Sbr.parse(e: any, buf: buffer, pos: number, count: number, crc: boolean
|
|||||||
return not SbrBits.over()
|
return not SbrBits.over()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ------------------------------------------------------------------------------------------------ decoding
|
|
||||||
-- 4.6.18.3.5 delta decoding of one channel's envelopes and noise floors
|
-- 4.6.18.3.5 delta decoding of one channel's envelopes and noise floors
|
||||||
local function decodeChannel(e: any, c: any, bal: boolean)
|
local function decodeChannel(e: any, c: any, bal: boolean)
|
||||||
local delta = if bal then 2 else 1
|
local delta = if bal then 2 else 1
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ local dct32, ana32, dct64, syn64 = SbrDct.dct32, SbrDct.ana32, SbrDct.dct64, Sbr
|
|||||||
local IN_SCALE = 32768
|
local IN_SCALE = 32768
|
||||||
|
|
||||||
-- analysis taps per output n: CA[n] = { c[2n + 128j] * IN_SCALE, j = 0 .. 4 }
|
-- analysis taps per output n: CA[n] = { c[2n + 128j] * IN_SCALE, j = 0 .. 4 }
|
||||||
local CA: { { number } } = table.create(64)
|
local CA: { { number } } = {}
|
||||||
for n = 0, 63 do
|
for n = 0, 63 do
|
||||||
local w = table.create(5, 0)
|
local w = table.create(5, 0)
|
||||||
for j = 0, 4 do
|
for j = 0, 4 do
|
||||||
@@ -27,7 +27,7 @@ for n = 0, 63 do
|
|||||||
CA[n + 1] = w
|
CA[n + 1] = w
|
||||||
end
|
end
|
||||||
-- synthesis taps per output k: CS[k] = { c[64i + k], i = 0 .. 9 }
|
-- synthesis taps per output k: CS[k] = { c[64i + k], i = 0 .. 9 }
|
||||||
local CS: { { number } } = table.create(64)
|
local CS: { { number } } = {}
|
||||||
for k = 1, 64 do
|
for k = 1, 64 do
|
||||||
local w = table.create(10, 0)
|
local w = table.create(10, 0)
|
||||||
for i = 0, 9 do
|
for i = 0, 9 do
|
||||||
@@ -36,7 +36,6 @@ for k = 1, 64 do
|
|||||||
CS[k] = w
|
CS[k] = w
|
||||||
end
|
end
|
||||||
|
|
||||||
local U = table.create(64, 0)
|
|
||||||
local A = table.create(32, 0)
|
local A = table.create(32, 0)
|
||||||
local B = table.create(32, 0)
|
local B = table.create(32, 0)
|
||||||
local CR = table.create(64, 0)
|
local CR = table.create(64, 0)
|
||||||
@@ -62,16 +61,14 @@ function SbrQmf.analysis(s: any, inp: { number }, io: number, is: number)
|
|||||||
local xr: { number }, xi: { number } = s.XLr, s.XLi
|
local xr: { number }, xi: { number } = s.XLr, s.XLi
|
||||||
table.move(xr, 1025, 1280, 1)
|
table.move(xr, 1025, 1280, 1)
|
||||||
table.move(xi, 1025, 1280, 1)
|
table.move(xi, 1025, 1280, 1)
|
||||||
local u, a, b, cr = U, A, B, CR
|
local a, b, cr = A, B, CR
|
||||||
for l = 0, 31 do
|
for l = 0, 31 do
|
||||||
local t = 353 + 32 * l
|
local t = 353 + 32 * l
|
||||||
for n = 1, 64 do
|
|
||||||
local q = t - n
|
|
||||||
local w = CA[n]
|
|
||||||
u[n] = x[q] * w[1] + x[q - 64] * w[2] + x[q - 128] * w[3] + x[q - 192] * w[4] + x[q - 256] * w[5]
|
|
||||||
end
|
|
||||||
for m = 1, 32 do
|
for m = 1, 32 do
|
||||||
local u0, u1 = u[m], u[65 - m]
|
local q, w = t - m, CA[m]
|
||||||
|
local u0 = x[q] * w[1] + x[q - 64] * w[2] + x[q - 128] * w[3] + x[q - 192] * w[4] + x[q - 256] * w[5]
|
||||||
|
q, w = t - 65 + m, CA[65 - m]
|
||||||
|
local u1 = x[q] * w[1] + x[q - 64] * w[2] + x[q - 128] * w[3] + x[q - 192] * w[4] + x[q - 256] * w[5]
|
||||||
a[m] = u0 - u1
|
a[m] = u0 - u1
|
||||||
b[m] = u0 + u1
|
b[m] = u0 + u1
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in new issue
Block a user