ws-video: MJPEG (codecs/Jpeg, yuv420p full range; encoder remaps limited-range frames) and MPEG-1 (codecs/Mpeg1, display reordering with the packet pts as tag) in the codec registry; VideoFrame times count from the demuxer's startTime (TS starts at 1.4 s); Matroska Vorbis keeps its codec delay; fixtures decode with -fps_mode passthrough

This commit is contained in:
4DBug committed 2026-10-31 09:57:26 -05:00
1 parent dac404aa52
commit 1cd0fdfc24
9 files changed
+136 -11

No files matched your search

+35 -1
View File
@@ -142,10 +142,15 @@ end
-- the range / matrix an Image's meta records (meta.yuv = { range, matrix }); limited BT.601 when absent
local function info(img: Types.Image): (string, string)
local y = img.meta and img.meta.yuv
local m = img.meta
local y = m and m.yuv
if type(y) == "table" then
return y.range or "limited", y.matrix or "bt601"
end
local src = m and m.source
if type(src) == "table" and src.range == "full" then
return "full", "bt601"
end
return "limited", "bt601"
end
Yuv.info = info
@@ -156,6 +161,35 @@ function Yuv.planes(w: number, h: number): (number, number, number, number)
return w * h, w * h + cw * ch, cw, ch
end
-- FULL_Y / FULL_C: limited -> full range sample maps
local FULL_Y = bcreate(256)
local FULL_C = bcreate(256)
for v = 0, 255 do
writeu8(FULL_Y, v, math.clamp(floor((v - 16) * 255 / 219 + 0.5), 0, 255))
writeu8(FULL_C, v, math.clamp(floor((v - 128) * 255 / 224 + 128.5), 0, 255))
end
-- toFullRange(img) -> a yuv420p Image in full range (a limited-range one remapped; a full-range one returned)
function Yuv.toFullRange(img: Types.Image): Types.Image
if img.format ~= "yuv420p" or info(img) == "full" then
return img
end
local w, h = img.width, img.height
local out = Types.Image.new(w, h, "yuv420p")
local src, dst = img.pixels, out.pixels
local ny = w * h
local n = math.min(buffer.len(src), buffer.len(dst))
for i = 0, math.min(ny, n) - 1 do
writeu8(dst, i, readu8(FULL_Y, readu8(src, i)))
end
for i = ny, n - 1 do
writeu8(dst, i, readu8(FULL_C, readu8(src, i)))
end
out.meta.yuv = { range = "full", matrix = select(2, info(img)) }
out.meta.source = img.meta.source
return out
end
-- imageToRgba(img) -> an rgba8 Image (yuv420p converted; rgba8 returned as is; nil for other formats)
function Yuv.imageToRgba(img: Types.Image): Types.Image?
if img.format == "rgba8" then