1
0
forked from um/web
This commit is contained in:
MengYX 2021-08-25 01:04:46 +08:00
parent 84be57a903
commit 942e43fa16
No known key found for this signature in database
GPG Key ID: E63F9C7303E8F604

View File

@ -128,17 +128,17 @@ export function QmcMaskGetDefault() {
} }
export function QmcMaskDetectMflac(data: Uint8Array) { export function QmcMaskDetectMflac(data: Uint8Array) {
let search_len = Math.min(0x8000, data.length), mask; let search_len = Math.min(0x8000, data.length)
for (let block_idx = 0; block_idx < search_len; block_idx += 128) { for (let block_idx = 0; block_idx < search_len; block_idx += 128) {
try { try {
mask = new QmcMask(data.slice(block_idx, block_idx + 128)); let mask = new QmcMask(data.slice(block_idx, block_idx + 128));
if (BytesHasPrefix(mask.Decrypt(data.slice(0, FLAC_HEADER.length)), FLAC_HEADER)) { if (BytesHasPrefix(mask.Decrypt(data.slice(0, FLAC_HEADER.length)), FLAC_HEADER)) {
break; return mask
} }
} catch (e) { } catch (e) {
} }
} }
return mask; return
} }
export function QmcMaskDetectMgg(data: Uint8Array) { export function QmcMaskDetectMgg(data: Uint8Array) {
@ -166,13 +166,13 @@ export function QmcMaskDetectMgg(data: Uint8Array) {
for (let i = 0; i < 44; i++) for (let i = 0; i < 44; i++)
matrix[i] = calcMaskFromConfidence(matrixConfidence[i]); matrix[i] = calcMaskFromConfidence(matrixConfidence[i]);
} catch (e) { } catch (e) {
return; return
} }
const mask = new QmcMask(matrix); const mask = new QmcMask(matrix);
if (!BytesHasPrefix(mask.Decrypt(data.slice(0, OGG_HEADER.length)), OGG_HEADER)) { if (BytesHasPrefix(mask.Decrypt(data.slice(0, OGG_HEADER.length)), OGG_HEADER)) {
return; return mask
} }
return mask; return
} }