video/smk: Smacker (SMK2 / SMK4) with its video codec and audio
containers into containers/Demux (palette updates ride on each video packet as packet.palette); the Smacker video codec (header Huffman trees with the escape cache, MONO / FULL (+ SMK4 doubled modes) / SKIP / FILL blocks) lives in codecs/video/Legacy/Smacker and registers as 'smackvid'; Smacker's packed DPCM-Huffman audio (8 / 16-bit, mono / stereo) and raw PCM tracks decode in video/smk/Audio, the Decoder built by the format over codecs/audio/Stream (Smk.openAudio; open() installs it as the openAudio hook). Fixtures encoded by tools/fixtures/smk.py: video and audio bit-exact with ffmpeg.
This commit is contained in:
1 parent
a1d2e7218c
commit
bf639260e4
8 files changed
+1522
-3
No files matched your search
@@ -3,7 +3,8 @@
|
||||
-- The 1990s inter-frame codecs as codecs/video/Video registry decoders (rgba8 pictures, one per packet): Autodesk
|
||||
-- FLI / FLC ("flic", the frames of video/fli), Cinepak ("cinepak",
|
||||
-- 'cvid'), Microsoft Video 1 ("msvideo1": CRAM / MSVC / WHAM, 8-bit palettised and 16-bit), QuickTime Animation
|
||||
-- ("qtrle", 'rle ': depths 1 / 2 / 4 / 8 / 16 / 24 / 32 and grey) and QuickTime Graphics ("smc", 'smc ').
|
||||
-- ("qtrle", 'rle ': depths 1 / 2 / 4 / 8 / 16 / 24 / 32 and grey), QuickTime Graphics ("smc", 'smc ') and Smacker
|
||||
-- video ("smackvid", the frames of video/smk: track.config = the header's tree sizes and trees, codecTag SMK2 / SMK4).
|
||||
-- New in formats-luau, written from the format descriptions (see each submodule); decoding is bit-exact with ffmpeg's
|
||||
-- decoders (tests/codecs/legacy.luau). Every decoder keeps the previous picture (a packet paints over it) and returns
|
||||
-- a fresh copy.
|
||||
@@ -13,7 +14,7 @@
|
||||
-- packet on. Depths come from track.bitsPerPixel (AVI biBitCount, the QuickTime depth).
|
||||
--
|
||||
-- local dec, err = Legacy.newDecoder("cinepak", track, { maxPixels = 2^22 }) -- a Types.VideoCodecDecoder
|
||||
-- Legacy.CODECS --> { "flic", "cinepak", "msvideo1", "qtrle", "smc" }
|
||||
-- Legacy.CODECS --> { "flic", "cinepak", "msvideo1", "qtrle", "smc", "smackvid" }
|
||||
--
|
||||
-- Never throws: bad tracks return nil, Err; bad packets return Err from decode().
|
||||
local Err = require("@formats/core/Err")
|
||||
@@ -24,6 +25,7 @@ local Cinepak = require("@formats/codecs/video/Legacy/Cinepak")
|
||||
local Msvideo1 = require("@formats/codecs/video/Legacy/Msvideo1")
|
||||
local QtRle = require("@formats/codecs/video/Legacy/QtRle")
|
||||
local Smc = require("@formats/codecs/video/Legacy/Smc")
|
||||
local Smacker = require("@formats/codecs/video/Legacy/Smacker")
|
||||
|
||||
local Legacy = {}
|
||||
|
||||
@@ -33,7 +35,8 @@ Legacy.Cinepak = Cinepak
|
||||
Legacy.Msvideo1 = Msvideo1
|
||||
Legacy.QtRle = QtRle
|
||||
Legacy.Smc = Smc
|
||||
Legacy.CODECS = { "flic", "cinepak", "msvideo1", "qtrle", "smc" }
|
||||
Legacy.Smacker = Smacker
|
||||
Legacy.CODECS = { "flic", "cinepak", "msvideo1", "qtrle", "smc", "smackvid" }
|
||||
|
||||
export type Options = {
|
||||
maxPixels: number?, -- refuse bigger pictures (LIMIT; default 2^26)
|
||||
@@ -124,6 +127,30 @@ local CODECS: { [string]: Codec } = {
|
||||
return Picture.image(st.pic), nil
|
||||
end,
|
||||
},
|
||||
smackvid = {
|
||||
make = function(t)
|
||||
local cfg = t.config
|
||||
if type(cfg) ~= "buffer" then
|
||||
return nil, "no Smacker trees"
|
||||
end
|
||||
local trees, msg = Smacker.trees(cfg)
|
||||
if not trees then
|
||||
return nil, msg
|
||||
end
|
||||
return { pic = Picture.new(t.width :: number, t.height :: number, true, 4, 4, t.palette), trees = trees, v4 = t.codecTag == "SMK4" }, nil
|
||||
end,
|
||||
step = function(st, data, packet)
|
||||
packetPalette(st.pic, packet)
|
||||
if buffer.len(data) == 0 then
|
||||
return nil, fail("empty frame")
|
||||
end
|
||||
local ok, msg = Smacker.decode(st.pic, data, st.trees, st.v4)
|
||||
if not ok then
|
||||
return nil, fail(msg)
|
||||
end
|
||||
return Picture.image(st.pic), nil
|
||||
end,
|
||||
},
|
||||
flic = {
|
||||
make = function(t)
|
||||
return Flic.state(t.width :: number, t.height :: number, t.bitsPerPixel or 8)
|
||||
|
||||
Reference in new issue
Block a user