mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 15:33:56 +08:00
refactor(media): share the Opus vendor UTF-8 decoder (#17340)
This commit is contained in:
@@ -14,7 +14,7 @@ import type {
|
||||
VulkanPipelineCacheMetadata,
|
||||
} from "../../domain/formatMetadata/mediaAssetMetadata.js";
|
||||
import { BinaryReader } from "../../domain/binaryContainer.js";
|
||||
import { decodeStrictUtf8 } from "../../domain/strictUtf8.js";
|
||||
import { decodeUtf8PreservingBomOrNull } from "../../domain/strictUtf8.js";
|
||||
import type { MediaAssetReaderLimits } from "../../domain/artifactReaderLimits.js";
|
||||
import { artifactReaderLimitFailure } from "../../resources/index.js";
|
||||
import { byteToHex } from "../../kernel/byteToHex.js";
|
||||
@@ -384,17 +384,15 @@ export const oggOpusLayout = async (
|
||||
limitations.push(
|
||||
`The OpusTags vendor string declares ${String(vendorLength)} bytes, but only ${String(tagsPrefix.length - 12)} were examined; the vendor was not read.`,
|
||||
);
|
||||
else
|
||||
try {
|
||||
vendor = decodeStrictUtf8(
|
||||
tagsPrefix.subarray(12, 12 + vendorLength),
|
||||
"preserve",
|
||||
);
|
||||
} catch {
|
||||
else {
|
||||
vendor = decodeUtf8PreservingBomOrNull(
|
||||
tagsPrefix.subarray(12, 12 + vendorLength),
|
||||
);
|
||||
if (vendor === null)
|
||||
limitations.push(
|
||||
"The OpusTags vendor string is not valid UTF-8, which RFC 7845 requires; the vendor fact was omitted.",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user