- H264: picture and grid allocations split between yield calls (a 1080p picture's tables are 1.6 M slots) - Vp8: Decode.decodeFrame hook three times per macroblock row and once per loop filter row; Options.yield - Yuv.toRgba / Yuv.scale: optional hook every 16 rows; imageToRgba / imageScale take an out Image and the hook - Video.open passes opts.yield to the conversions, the VP8 and MPEG-1/2 decoders - codecs/video/Video/Disposable: H.264 nal_ref_idc 0 (avcC length-prefixed / Annex B), VP8 frames refreshing no reference; containers/Demux sets packet.disposable for h264 / vp8 tracks; Video.isDisposable(track, packet) - skipDisposable: H.264 keeps skipped pictures in output order (pts pool / POC bookkeeping), VP8 applies the header state then skips; receive() returns false for a skipped picture, VideoFrame.index counts it - Types: Packet.disposable, VideoCodecDecoder.receive may return false - tools/fixtures/videoctl.py: VP8 two temporal layers (IVF + WebM)
38 lines
1.8 KiB
Python
38 lines
1.8 KiB
Python
# Decoder control fixtures (tools/fixtures.py, for tests/video/control.luau): VP8 with two temporal layers (ffmpeg's
|
|
# libvpx, ts_layering_mode 2: every other inter frame refreshes no reference), as IVF and WebM, with and without error
|
|
# resilience; ffmpeg's vp8 decode gives the CRC-32 of every shown yuv420p frame.
|
|
# tests/gen/videoctl_vp8.luau { { name, ivf, webm, width, height, crcs } }
|
|
import importlib.util, os, tempfile
|
|
|
|
_spec = importlib.util.spec_from_file_location("_video_helpers", os.path.join(os.path.dirname(os.path.abspath(__file__)), "_video.py"))
|
|
V = importlib.util.module_from_spec(_spec)
|
|
_spec.loader.exec_module(V)
|
|
|
|
INPUTS = ["tools/fixtures/_video.py"]
|
|
|
|
LAYERS = ["-ts-parameters", "ts_number_layers=2:ts_target_bitrate=150,300:ts_rate_decimator=2,1:ts_periodicity=2:"
|
|
"ts_layer_id=0,1:ts_layering_mode=2"]
|
|
|
|
|
|
def crcs(path):
|
|
out = V.ffmpeg(["-c:v", "vp8", "-i", path, "-fps_mode", "passthrough", "-f", "framehash", "-hash", "crc32", "-"])
|
|
res = []
|
|
for line in out.decode().splitlines():
|
|
if line and not line.startswith("#"):
|
|
res.append(int(line.split(",")[5].strip(), 16))
|
|
return res
|
|
|
|
|
|
def generate(ctx):
|
|
tmp = tempfile.mkdtemp(prefix="videoctl_")
|
|
out = []
|
|
for name, extra in (("layers", []), ("layers_er", ["-error-resilient", "1"])):
|
|
ivf = os.path.join(tmp, name + ".ivf")
|
|
webm = os.path.join(tmp, name + ".webm")
|
|
V.ffmpeg(["-f", "lavfi", "-i", "testsrc2=size=176x144:rate=25", "-frames:v", "20", "-pix_fmt", "yuv420p",
|
|
"-c:v", "libvpx", "-b:v", "300k"] + extra + LAYERS + ["-f", "ivf", ivf])
|
|
V.ffmpeg(["-i", ivf, "-c", "copy", webm])
|
|
out.append({"name": name, "ivf": open(ivf, "rb").read(), "webm": open(webm, "rb").read(), "width": 176,
|
|
"height": 144, "crcs": crcs(ivf)})
|
|
ctx.emit("videoctl_vp8", out)
|