Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/media/video/video_pipeline.zig
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,21 @@ fn loadBootstrap(pipeline: *Pipeline) c_int {
return 0;
};
defer file.close();
const size = file.getEndPos() catch return 0;
if (size == 0 or size > bootstrap_capacity) return 0;
var data: [bootstrap_capacity]u8 = undefined;
file.reader().readNoEof(data[0..@intCast(size)]) catch return 0;
// Size the cache by reading it: getEndPos() goes through File.stat(), which needs
// statx and fails on the 4.9 kernels H700 devices ship. One spare byte detects an
// oversized file.
var data: [bootstrap_capacity + 1]u8 = undefined;
Comment thread
alexander-clawthorne marked this conversation as resolved.
const size = file.readAll(&data) catch |err| {
if (debugEnabled())
std.debug.print("Ignoring unreadable H.264 bootstrap cache: {s}\n", .{@errorName(err)});
return 0;
};
if (size == 0) return 0;
if (size > bootstrap_capacity) {
if (debugEnabled())
std.debug.print("Ignoring oversized H.264 bootstrap cache (over {d} bytes)\n", .{bootstrap_capacity});
return 0;
}
if (c.go_h264_depacketizer_set_bootstrap(pipeline.depacketizer, &data, @intCast(size)) != 0) {
if (debugEnabled()) std.debug.print("Ignoring invalid H.264 bootstrap cache\n", .{});
return 0;
Expand Down