summaryrefslogtreecommitdiffstats
path: root/tools/guest-diag/xgrab.c
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-11-15 16:00:06 -0500
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-11-15 16:00:06 -0500
commit43bbf490dca972cb96fcf1d69dd0b6859377e452 (patch)
treeac836f0dfcd50b3302d29a88402b1753127f7cf2 /tools/guest-diag/xgrab.c
parentf37f1f6a92939a8c147da1ed5a9032d9e8604ddc (diff)
downloadopen-iov-43bbf490dca972cb96fcf1d69dd0b6859377e452.tar.gz
open-iov-43bbf490dca972cb96fcf1d69dd0b6859377e452.zip
tools/guest-diag: tag BGRA capture records as GZF2 fmt 33
sdl_cap.c wrote the same 32 in the GZF2 record format field for every capture path, so gzf2_video.py's auto mode decoded ARGB8888/X-surface frames (BGRA byte order on little-endian) as RGBA and swapped red and blue. Make the field the documented pixel-order tag: 32 = RGBA8 from the GL swap path (glReadPixels GL_RGBA), 33 = BGRA8 from SDL_RenderReadPixels(ARGB8888) and X window surfaces; xgrab.c tags its ZPixmap BGRA records 33 as well. gzf2_video.py continues to accept both tags (and old all-32 captures via --pix-fmt bgra), checks ffmpeg/ffprobe before indexing, and keeps the final resampled endpoint so a 90-frame 60 fps capture encodes as 90 frames instead of 88.
Diffstat (limited to 'tools/guest-diag/xgrab.c')
-rw-r--r--tools/guest-diag/xgrab.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/guest-diag/xgrab.c b/tools/guest-diag/xgrab.c
index eb605d6..bca23c0 100644
--- a/tools/guest-diag/xgrab.c
+++ b/tools/guest-diag/xgrab.c
@@ -3,8 +3,9 @@
// Pure client-side XGetImage on a software X server (Xvfb): no GL, no driver,
// no present-path hooks. Same record format as sdl_cap.c:
// [0] 8B "GZCAPV01" + zero pad to 4096
-// [4096..] records: 4B "GZF2" | u32 w | u32 h | u32 stride | u32 bpp |
+// [4096..] records: 4B "GZF2" | u32 w | u32 h | u32 stride | u32 fmt |
// u64 ts_ns | u64 seq | stride*h bytes (top-down BGRA)
+// fmt is a pixel-order tag: 33 = BGRA8 (ZPixmap on little-endian X).
// Trailing record seq=0xFFFFFFFFFFFFFFFF on clean stop.
// Usage: xgrab <display> <out> <maxframes|0> <pace_us|0>
#include <X11/Xlib.h>
@@ -83,7 +84,7 @@ int main(int argc, char **argv)
rh[0] = (uint32_t)r_w;
rh[1] = (uint32_t)r_h;
rh[2] = (uint32_t)r_w * 4;
- rh[3] = 32;
+ rh[3] = 33; /* GZF2 pixel-order tag: BGRA8 */
fwrite(m, 1, 4, f);
fwrite(rh, 4, 4, f);
fwrite(&tns, 8, 1, f);