mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-09 20:51:51 +09:00
TAV: video with TAD audio playback
This commit is contained in:
@@ -1063,6 +1063,8 @@ try {
|
||||
|
||||
}
|
||||
else if (packetType === TAV_PACKET_GOP_UNIFIED) {
|
||||
decoderDbgInfo.frameMode = " "
|
||||
|
||||
// GOP Unified packet (temporal 3D DWT)
|
||||
// DOUBLE-BUFFERING: Decode GOP N+1 while playing GOP N to eliminate hiccups
|
||||
|
||||
@@ -1342,6 +1344,7 @@ try {
|
||||
|
||||
}
|
||||
else if (packetType === TAV_PACKET_AUDIO_TAD) {
|
||||
let sampleLen = seqread.readShort()
|
||||
let payloadLen = seqread.readInt() // compressed size + 6
|
||||
|
||||
if (!tadInitialised) {
|
||||
@@ -1351,8 +1354,7 @@ try {
|
||||
|
||||
seqread.readBytes(payloadLen, SND_MEM_ADDR - 262144)
|
||||
audio.tadDecode()
|
||||
audio.tadUploadDecoded(0)
|
||||
|
||||
audio.tadUploadDecoded(0, sampleLen)
|
||||
}
|
||||
else if (packetType === TAV_PACKET_AUDIO_NATIVE) {
|
||||
// PCM length must not exceed 65536 bytes!
|
||||
|
||||
@@ -31,6 +31,7 @@ const COL_HL_EXT = {
|
||||
"mv1": 213,
|
||||
"mv2": 213,
|
||||
"mv3": 213,
|
||||
"tav": 213,
|
||||
"ipf1": 190,
|
||||
"ipf2": 190,
|
||||
"txt": 223,
|
||||
@@ -46,6 +47,7 @@ const EXEC_FUNS = {
|
||||
"mv1": (f) => _G.shell.execute(`playmv1 "${f}" -i`),
|
||||
"mv2": (f) => _G.shell.execute(`playtev "${f}" -i`),
|
||||
"mv3": (f) => _G.shell.execute(`playtav "${f}" -i`),
|
||||
"tav": (f) => _G.shell.execute(`playtav "${f}" -i`),
|
||||
"pcm": (f) => _G.shell.execute(`playpcm "${f}" -i`),
|
||||
"ipf1": (f) => _G.shell.execute(`decodeipf "${f}" -i`),
|
||||
"ipf2": (f) => _G.shell.execute(`decodeipf "${f}" -i`),
|
||||
|
||||
@@ -1068,6 +1068,7 @@ transmission capability, and region-of-interest coding.
|
||||
|
||||
## TAD Packet Structure
|
||||
uint8 Packet type (0x24)
|
||||
uint16 Sample Count
|
||||
uint32 Compressed Size + 6
|
||||
uint16 Sample Count
|
||||
uint32 Compressed Size
|
||||
|
||||
@@ -107,10 +107,11 @@ class AudioJSR223Delegate(private val vm: VM) {
|
||||
|
||||
fun tadIsBusy() = getFirstSnd()?.mmio_read(44L)?.toInt() == 1
|
||||
|
||||
fun tadUploadDecoded(playhead: Int) {
|
||||
fun tadUploadDecoded(playhead: Int, sampleLength: Int) {
|
||||
if (sampleLength > 32768) throw Error("Sample size too long: expected <= 32768, got $sampleLength")
|
||||
getFirstSnd()?.let { snd ->
|
||||
val ba = ByteArray(65536) // 32768 samples * 2 channels
|
||||
UnsafeHelper.memcpyRaw(null, snd.tadDecodedBin.ptr, ba, UnsafeHelper.getArrayOffset(ba), 65536)
|
||||
val ba = ByteArray(sampleLength * 2) // 32768 samples * 2 channels
|
||||
UnsafeHelper.memcpyRaw(null, snd.tadDecodedBin.ptr, ba, UnsafeHelper.getArrayOffset(ba), sampleLength * 2L)
|
||||
snd.playheads[playhead].pcmQueue.addLast(ba)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6691,7 +6691,7 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
||||
dbgOut["qY"] = qYGlobal
|
||||
dbgOut["qCo"] = qCoGlobal
|
||||
dbgOut["qCg"] = qCgGlobal
|
||||
dbgOut["frameMode"] = "G"
|
||||
dbgOut["frameMode"] = " "
|
||||
|
||||
val gpu = (vm.peripheralTable[1].peripheral as GraphicsAdapter)
|
||||
|
||||
|
||||
@@ -89,8 +89,8 @@ internal class UnsafePtr(pointer: Long, allocSize: Long, private val caller: Any
|
||||
//// You may break the glass and use this tool when some fucking incomprehensible bugs ("vittujen vitun bugit")
|
||||
//// appear (e.g. getting garbage values when it fucking shouldn't)
|
||||
|
||||
if (destroyed) { throw DanglingPointerException("The pointer is already destroyed ($this)") }
|
||||
if (index !in 0 until size) throw AddressOverflowException("Index: $index; alloc size: $size; pointer: ${this}\n${Thread.currentThread().stackTrace.joinToString("\n", limit=10) { " $it" }}")
|
||||
// if (destroyed) { throw DanglingPointerException("The pointer is already destroyed ($this)") }
|
||||
// if (index !in 0 until size) throw AddressOverflowException("Index: $index; alloc size: $size; pointer: ${this}\n${Thread.currentThread().stackTrace.joinToString("\n", limit=10) { " $it" }}")
|
||||
}
|
||||
|
||||
operator fun get(index: Long): Byte {
|
||||
|
||||
@@ -146,7 +146,7 @@ static void get_quantization_weights(int quality, int dwt_levels, float *weights
|
||||
/*15*/{0.2f, 0.2f, 0.8f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.25f, 1.5f, 1.5f}
|
||||
};
|
||||
|
||||
float quality_scale = 4.0f * (1.0f + FCLAMP((4 - quality) * 0.5f, 0.0f, 1000.0f));
|
||||
float quality_scale = 4.0f * (1.0f + FCLAMP((5 - quality) * 0.5f, 0.0f, 1000.0f));
|
||||
|
||||
for (int i = 0; i < dwt_levels; i++) {
|
||||
weights[i] = base_weights[dwt_levels][i] * quality_scale;
|
||||
|
||||
@@ -132,11 +132,11 @@ static int needs_alpha_channel(int channel_layout) {
|
||||
#define DEFAULT_ZSTD_LEVEL 15
|
||||
#define DEFAULT_PCM_ZSTD_LEVEL 3
|
||||
#define TEMPORAL_GOP_SIZE 24
|
||||
#define TEMPORAL_GOP_SIZE_MIN 8 // Minimum GOP size to avoid decoder hiccups
|
||||
#define TEMPORAL_GOP_SIZE_MIN 10 // Minimum GOP size to avoid decoder hiccups
|
||||
#define TEMPORAL_DECOMP_LEVEL 2
|
||||
|
||||
#define SCENE_CHANGE_THRESHOLD_SOFT 0.6
|
||||
#define SCENE_CHANGE_THRESHOLD_HARD 0.8
|
||||
#define SCENE_CHANGE_THRESHOLD_SOFT 0.72
|
||||
#define SCENE_CHANGE_THRESHOLD_HARD 0.90
|
||||
#define MOTION_THRESHOLD 24.0f // Flush if motion exceeds 24 pixels in any direction
|
||||
|
||||
// Audio/subtitle constants (reused from TEV)
|
||||
@@ -8926,6 +8926,7 @@ static int write_tad_packet_samples(tav_encoder_t *enc, FILE *output, int sample
|
||||
|
||||
uint32_t tav_payload_size = (uint32_t)tad_payload_size;
|
||||
uint32_t tav_payload_size_plus_6 = (uint32_t)tad_payload_size + 6;
|
||||
fwrite(&sample_count, sizeof(uint16_t), 1, output);
|
||||
fwrite(&tav_payload_size_plus_6, sizeof(uint32_t), 1, output);
|
||||
fwrite(&sample_count, sizeof(uint16_t), 1, output);
|
||||
fwrite(&tav_payload_size, sizeof(uint32_t), 1, output);
|
||||
|
||||
Reference in New Issue
Block a user