@audio/decode-aac 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/decode-aac.js +17 -8
- package/package.json +4 -4
package/decode-aac.js
CHANGED
|
@@ -121,17 +121,23 @@ class AACDecoder {
|
|
|
121
121
|
|
|
122
122
|
_tryM4AInit() {
|
|
123
123
|
let buf = this._catAccum()
|
|
124
|
-
|
|
124
|
+
// tables are collected per trak — a second non-audio track (e.g. a QuickTime
|
|
125
|
+
// chapter/text track, github #48) must not clobber the audio track's tables
|
|
126
|
+
let traks = [], t = null
|
|
125
127
|
|
|
126
128
|
parseBoxes(buf, 0, buf.length, (type, data) => {
|
|
127
|
-
if (type === '
|
|
128
|
-
else if (
|
|
129
|
-
else if (type === '
|
|
130
|
-
else if (type === '
|
|
131
|
-
else if (type === '
|
|
132
|
-
else if (type === '
|
|
129
|
+
if (type === 'trak') traks.push(t = {})
|
|
130
|
+
else if (!t) return
|
|
131
|
+
else if (type === 'esds') t.asc = parseEsds(data)
|
|
132
|
+
else if (type === 'alac') t.alacCookie = data // ALAC magic cookie: version/flags(4) + ALACSpecificConfig(24)
|
|
133
|
+
else if (type === 'stsz') t.stsz = parseStsz(data)
|
|
134
|
+
else if (type === 'stco') t.stco = parseStco(data)
|
|
135
|
+
else if (type === 'co64') t.stco = parseCo64(data)
|
|
136
|
+
else if (type === 'stsc') t.stsc = parseStsc(data)
|
|
133
137
|
})
|
|
134
138
|
|
|
139
|
+
// the audio track: first trak with an audio config + sample tables
|
|
140
|
+
let { asc, alacCookie, stsz, stco, stsc } = traks.find(t => (t.asc || t.alacCookie) && t.stsz && t.stco?.length) ?? {}
|
|
135
141
|
if ((!asc && !alacCookie) || !stsz || !stco?.length) return EMPTY // moov/tables not ready
|
|
136
142
|
|
|
137
143
|
if (alacCookie) {
|
|
@@ -341,7 +347,10 @@ function parseBoxes(buf, start, end, cb) {
|
|
|
341
347
|
|
|
342
348
|
let bodyOff = off + 8
|
|
343
349
|
if (type === 'stsd') parseSampleDesc(buf, bodyOff, size - 8, cb)
|
|
344
|
-
else if (CONTAINERS.has(type))
|
|
350
|
+
else if (CONTAINERS.has(type)) {
|
|
351
|
+
if (type === 'trak') cb(type, null) // track boundary — tables that follow belong to this trak
|
|
352
|
+
parseBoxes(buf, bodyOff + (type === 'meta' ? 4 : 0), off + size, cb)
|
|
353
|
+
}
|
|
345
354
|
else cb(type, buf.subarray(bodyOff, off + size))
|
|
346
355
|
|
|
347
356
|
off += size
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audio/decode-aac",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Decode AAC/M4A (FAAD2 WASM) and ALAC/Apple Lossless (pure JS) to PCM samples",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "decode-aac.js",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
],
|
|
48
48
|
"license": "GPL-2.0",
|
|
49
49
|
"author": "audiojs",
|
|
50
|
-
"homepage": "https://github.com/audiojs/decode-aac#readme",
|
|
51
|
-
"bugs": "https://github.com/audiojs/decode
|
|
50
|
+
"homepage": "https://github.com/audiojs/decode/tree/master/packages/decode-aac#readme",
|
|
51
|
+
"bugs": "https://github.com/audiojs/decode/issues",
|
|
52
52
|
"repository": {
|
|
53
53
|
"type": "git",
|
|
54
|
-
"url": "git+https://github.com/audiojs/decode
|
|
54
|
+
"url": "git+https://github.com/audiojs/decode.git",
|
|
55
55
|
"directory": "packages/decode-aac"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|