From 8a6b37759773aa0f40fb9c9f9eb59e0e67776fbc Mon Sep 17 00:00:00 2001 From: xingluo Date: Mon, 26 Jan 2026 18:33:10 +0800 Subject: [PATCH] revert 011433bb5b54a6c49deccc55a5afa7cf89e82553 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit revert 更新 play.lua --- play.lua | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/play.lua b/play.lua index 67b3551..f7b75fe 100644 --- a/play.lua +++ b/play.lua @@ -133,7 +133,7 @@ local get_task = {} local function readU32(s, pos) if pos + 3 > #s then return nil end local b1, b2, b3, b4 = s:byte(pos, pos + 3) - -- 使用网络字节序(大端序) + -- 使用 bit32.lshift 和 bit32.bor return bit32.bor( bit32.lshift(b1, 24), bit32.lshift(b2, 16), @@ -142,45 +142,27 @@ local function readU32(s, pos) ) end --- 修复后的 FramePack 解析函数 +-- 解析 FramePack 二进制数据 local function unpackFramePack(data) local frames = {} local pos = 1 - -- 读取总帧数 local frameCount = readU32(data, pos) - if not frameCount then - error("Invalid framepack header - no frame count found") - end - print("Parsing " .. frameCount .. " frames") + if not frameCount then error("Invalid framepack header") end pos = pos + 4 for i = 1, frameCount do - -- 读取当前帧的大小 local size = readU32(data, pos) - if not size then - error("Truncated framepack at frame " .. i .. ", position " .. pos) - end - - print("Frame " .. i .. " size: " .. size .. " bytes") + if not size then error("Truncated framepack at frame " .. i) end pos = pos + 4 - - -- 检查是否有足够的数据来读取这个帧 - if pos + size - 1 > #data then - error("Frame " .. i .. " size (" .. size .. ") extends beyond data boundary") - end - - -- 提取帧数据(这应该是完整的PNG图像数据) + if pos + size - 1 > #data then error("Frame " .. i .. " out of bounds") end local frameData = data:sub(pos, pos + size - 1) frames[i] = frameData - pos = pos + size end return frames end - - -- 分批下载(每批 50 帧) local BATCH_SIZE = 20 -- local totalFrames = #videoInfo.frame_urls