Remove obsolete CRC calculation and OGG file reading tests

- Deleted test-crc.js which contained a custom CRC calculation implementation.
- Removed test-ogg.js that was responsible for reading and displaying OGG files.
This commit is contained in:
MythEclipse
2026-05-13 14:18:26 +07:00
parent 6e67da2192
commit 0957621950
3 changed files with 0 additions and 123158 deletions

123108
index.js

File diff suppressed because one or more lines are too long

View File

@@ -1,32 +0,0 @@
const { crc } = require('node-crc');
const CRC_TABLE = new Uint32Array(256);
for (let i = 0; i < 256; i++) {
let r = i << 24;
for (let j = 0; j < 8; j++) {
r = (r & 0x80000000) !== 0 ? ((r << 1) ^ 0x04c11db7) : (r << 1);
}
CRC_TABLE[i] = (r >>> 0);
}
function calculateOggCrc(buffer) {
let crc = 0;
for (let i = 0; i < buffer.length; i++) {
crc = ((crc << 8) >>> 0) ^ CRC_TABLE[((crc >>> 24) ^ buffer[i]) & 0xff];
crc >>>= 0;
}
return crc;
}
const testBuffer = Buffer.from("hello world this is a test page", "utf-8");
const expectedBuffer = crc(32, false, 0x04c11db7, 0, 0, 0, 0, 0, testBuffer);
const expected = expectedBuffer.readUInt32BE(0);
const actual = calculateOggCrc(testBuffer);
console.log({
expected: expected.toString(16),
actual: actual.toString(16),
match: expected === actual
});

View File

@@ -1,18 +0,0 @@
const fs = require('fs');
const files = fs.readdirSync('recordings').filter(f => f.endsWith('.ogg')).sort().reverse();
if (files.length === 0) {
console.log("No files to check");
process.exit(0);
}
const file = 'recordings/' + files[0];
console.log("Reading " + file);
const buf = fs.readFileSync(file);
console.log("First 200 bytes:");
console.log(buf.subarray(0, 200).toString('hex').match(/.{1,32}/g).join('\n'));
// check for Opus tags
let str = buf.subarray(0, 200).toString('ascii');
console.log("ASCII:", str.replace(/[^ -~]/g, '.'));