mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-10 23:04:04 +09:00
interlacing wip3
This commit is contained in:
@@ -436,6 +436,11 @@ const FRAME_SIZE = 560*448*3 // Total frame size = 752,640 bytes
|
||||
const RGB_BUFFER_A = sys.malloc(FRAME_SIZE)
|
||||
const RGB_BUFFER_B = sys.malloc(FRAME_SIZE)
|
||||
|
||||
// Static Yadif deinterlacing buffers (half-height field buffers for interlaced mode)
|
||||
const FIELD_SIZE = 560 * 224 * 3 // Half-height field buffer size
|
||||
const TEMP_FIELD_BUFFER = sys.malloc(FIELD_SIZE)
|
||||
const PREV_FIELD_BUFFER = sys.malloc(FIELD_SIZE)
|
||||
|
||||
// Ping-pong buffer pointers (swap instead of copy)
|
||||
let CURRENT_RGB_ADDR = RGB_BUFFER_A
|
||||
let PREV_RGB_ADDR = RGB_BUFFER_B
|
||||
@@ -444,6 +449,10 @@ let PREV_RGB_ADDR = RGB_BUFFER_B
|
||||
sys.memset(RGB_BUFFER_A, 0, FRAME_PIXELS * 3)
|
||||
sys.memset(RGB_BUFFER_B, 0, FRAME_PIXELS * 3)
|
||||
|
||||
// Initialize Yadif field buffers to black
|
||||
sys.memset(TEMP_FIELD_BUFFER, 0, FIELD_SIZE)
|
||||
sys.memset(PREV_FIELD_BUFFER, 0, FIELD_SIZE)
|
||||
|
||||
// Initialize display framebuffer to black
|
||||
sys.memset(DISPLAY_RG_ADDR, 0, FRAME_PIXELS) // Black in RG plane
|
||||
sys.memset(DISPLAY_BA_ADDR, 15, FRAME_PIXELS) // Black with alpha=15 (opaque) in BA plane
|
||||
@@ -504,7 +513,7 @@ function setBiasLighting() {
|
||||
graphics.setBackground(Math.round(bgr * 255), Math.round(bgg * 255), Math.round(bgb * 255))
|
||||
}
|
||||
|
||||
let blockDataPtr = sys.malloc(560 * 448 * 3)
|
||||
let blockDataPtr = sys.malloc(FRAME_SIZE)
|
||||
|
||||
// Main decoding loop - simplified for performance
|
||||
try {
|
||||
@@ -573,7 +582,7 @@ try {
|
||||
// Hardware-accelerated TEV decoding to RGB buffers (YCoCg-R or XYB based on version)
|
||||
try {
|
||||
let decodeStart = sys.nanoTime()
|
||||
graphics.tevDecode(blockDataPtr, CURRENT_RGB_ADDR, PREV_RGB_ADDR, width, height, [qualityY, qualityCo, qualityCg], frameCount, debugMotionVectors, version, isInterlaced)
|
||||
graphics.tevDecode(blockDataPtr, CURRENT_RGB_ADDR, PREV_RGB_ADDR, width, height, [qualityY, qualityCo, qualityCg], frameCount, debugMotionVectors, version, isInterlaced, TEMP_FIELD_BUFFER, PREV_FIELD_BUFFER)
|
||||
decodeTime = (sys.nanoTime() - decodeStart) / 1000000.0 // Convert to milliseconds
|
||||
|
||||
// Upload RGB buffer to display framebuffer with dithering
|
||||
@@ -661,9 +670,11 @@ catch (e) {
|
||||
}
|
||||
finally {
|
||||
// Cleanup working memory (graphics memory is automatically managed)
|
||||
sys.free(blockDataPtr)
|
||||
if (blockDataPtr > 0) sys.free(blockDataPtr)
|
||||
if (RGB_BUFFER_A > 0) sys.free(RGB_BUFFER_A)
|
||||
if (RGB_BUFFER_B > 0) sys.free(RGB_BUFFER_B)
|
||||
if (TEMP_FIELD_BUFFER > 0) sys.free(TEMP_FIELD_BUFFER)
|
||||
if (PREV_FIELD_BUFFER > 0) sys.free(PREV_FIELD_BUFFER)
|
||||
|
||||
audio.stop(0)
|
||||
audio.purgeQueue(0)
|
||||
|
||||
@@ -35,6 +35,7 @@ const COL_HL_EXT = {
|
||||
"ipf2": 191,
|
||||
"txt": 223,
|
||||
"md": 223,
|
||||
"log": 223
|
||||
}
|
||||
|
||||
const EXEC_FUNS = {
|
||||
@@ -49,7 +50,9 @@ const EXEC_FUNS = {
|
||||
"ipf1": (f) => _G.shell.execute(`decodeipf "${f}" -i`),
|
||||
"ipf2": (f) => _G.shell.execute(`decodeipf "${f}" -i`),
|
||||
"bas": (f) => _G.shell.execute(`basic "${f}"`),
|
||||
"txt": (f) => _G.shell.execute(`less "${f}"`)
|
||||
"txt": (f) => _G.shell.execute(`less "${f}"`),
|
||||
"md": (f) => _G.shell.execute(`less "${f}"`),
|
||||
"log": (f) => _G.shell.execute(`less "${f}"`)
|
||||
}
|
||||
|
||||
let windowMode = 0 // 0 == left, 1 == right
|
||||
|
||||
Reference in New Issue
Block a user