From 3b969608cb69935ef6b3193260d2c4f6fb73e37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Fri, 25 May 2012 17:45:39 -0400 Subject: [PATCH] wcap: Add a file format magic number and add the pixel format to the header --- src/screenshooter.c | 19 ++++++++++++++++++- src/wcap-decode.c | 9 +++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/screenshooter.c b/src/screenshooter.c index 77d34ea0..d368cfde 100644 --- a/src/screenshooter.c +++ b/src/screenshooter.c @@ -318,12 +318,18 @@ weston_recorder_frame_notify(struct wl_listener *listener, void *data) pixman_region32_fini(&damage); } +#define WCAP_HEADER_MAGIC 0x57434150 +#define WCAP_FORMAT_XRGB8888 0x34325258 +#define WCAP_FORMAT_XBGR8888 0x34324258 +#define WCAP_FORMAT_RGBX8888 0x34325852 +#define WCAP_FORMAT_BGRX8888 0x34325842 + static void weston_recorder_create(struct weston_output *output, const char *filename) { struct weston_recorder *recorder; int stride, size; - struct { uint32_t width, height; } header; + struct { uint32_t magic, format, width, height; } header; recorder = malloc(sizeof *recorder); recorder->output = output; @@ -338,6 +344,17 @@ weston_recorder_create(struct weston_output *output, const char *filename) recorder->fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644); + header.magic = WCAP_HEADER_MAGIC; + + switch (output->compositor->read_format) { + case GL_BGRA_EXT: + header.format = WCAP_FORMAT_XRGB8888; + break; + case GL_RGBA: + header.format = WCAP_FORMAT_XBGR8888; + break; + } + header.width = output->current->width; header.height = output->current->height; recorder->total += write(recorder->fd, &header, sizeof header); diff --git a/src/wcap-decode.c b/src/wcap-decode.c index 9ff7ddb8..8382bfb9 100644 --- a/src/wcap-decode.c +++ b/src/wcap-decode.c @@ -33,7 +33,16 @@ #include +#define WCAP_HEADER_MAGIC 0x57434150 + +#define WCAP_FORMAT_XRGB8888 0x34325258 +#define WCAP_FORMAT_XBGR8888 0x34324258 +#define WCAP_FORMAT_RGBX8888 0x34325852 +#define WCAP_FORMAT_BGRX8888 0x34325842 + struct wcap_header { + uint32_t magic; + uint32_t format; uint32_t width, height; };