Make MP3 next frame location more strict for better recovery (fixes #382), fix Date timezone for ID3 tags

This commit is contained in:
Vanilagy
2026-05-22 11:31:26 +02:00
parent 149a2b4571
commit 85a80972a0
9 changed files with 70 additions and 26 deletions
+7 -2
View File
@@ -6,7 +6,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
export const FRAME_HEADER_SIZE = 4;
export const MP3_FRAME_HEADER_SIZE = 4;
export const SAMPLING_RATES = [44100, 48000, 32000];
export const KILOBIT_RATES = [
// lowSamplingFrequency === 0
@@ -122,7 +122,8 @@ export const readMp3FrameHeader = (word: number, remainingBytes: number | null):
const layer = (secondByte >> 1) & 0x3;
const bitrateIndex = (thirdByte >> 4) & 0xf;
const frequencyIndex = ((thirdByte >> 2) & 0x3) % 3;
const frequencyIndex = ((thirdByte >> 2) & 0x3) % 3; // FFmpeg effectively does % 3 (but in a roundabout way)
const padding = (thirdByte >> 1) & 0x1;
const channel = (fourthByte >> 6) & 0x3;
@@ -212,3 +213,7 @@ export enum XingFlags {
FileSize = 1 << 1,
Toc = 1 << 2,
}
export const getMp3ChannelCount = (channel: number) => {
return channel === 3 ? 1 : 2;
};