From: Pekka Paalanen <ppaalanen@gmail.com>
To: Maxime Ripard <maxime@cerno.tech>
Cc: igt-dev@lists.freedesktop.org, Petri Latvala <petri.latvala@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t v2 4/8] lib/igt_frame: Add function to dump frames in RGB and raw
Date: Fri, 29 Apr 2022 15:46:45 +0300 [thread overview]
Message-ID: <20220429154645.1680bad2@eldfell> (raw)
In-Reply-To: <20220328145509.2331195-5-maxime@cerno.tech>
[-- Attachment #1: Type: text/plain, Size: 5053 bytes --]
On Mon, 28 Mar 2022 16:55:05 +0200
Maxime Ripard <maxime@cerno.tech> wrote:
> The igt_write_frame_to_png() already allows to dump the content of a
> cairo surface into a PNG image. However, it can be useful to have the
> raw content of the buffer as well, so let's create a function that will
> dump both a PNG image and its raw buffer.
>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Hi,
when exactly is the raw dump useful? Do you need it for checking alpha?
Or for YUV formats? Or for multi-planar formats? Or for greater than 8
bpc or floating point formats?
How do you make use of the raw dump?
PNG can store alpha channel as well, and if that's not convenient
alongsize RGB, you could save another image where alpha has been
converted to gray scale.
PNG can also go up to 16 bpc I think?
PAM file format (netpbm type P7) might also be an option, looks like it
can do up to RGBA 16 bpc, and is trivial to generate.
http://netpbm.sourceforge.net/doc/pam.html
It's not much different from a raw dump, but contains enough metadata
for tools to understand the image.
Thanks,
pq
> ---
> lib/igt_frame.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++
> lib/igt_frame.h | 4 +++
> 2 files changed, 86 insertions(+)
>
> diff --git a/lib/igt_frame.c b/lib/igt_frame.c
> index ba29ac028e1b..f53ba3a381ef 100644
> --- a/lib/igt_frame.c
> +++ b/lib/igt_frame.c
> @@ -112,6 +112,40 @@ static void igt_write_frame_to_png(cairo_surface_t *surface, int summary_fd,
> free(path);
> }
>
> +static void igt_write_frame_to_raw(cairo_surface_t *surface, int summary_fd,
> + const char *qualifier, const char *suffix)
> +{
> + int height, stride, size;
> + char *path;
> + void *ptr;
> + int out_fd = -1;
> +
> + path = igt_get_frame_path(qualifier, suffix, "raw");
> + igt_assert(path);
> +
> + igt_debug("Dumping %s frame to %s...\n", qualifier, path);
> +
> + out_fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
> + igt_assert(out_fd >= 0);
> +
> + ptr = cairo_image_surface_get_data(surface);
> + igt_assert(ptr);
> +
> + stride = cairo_image_surface_get_stride(surface);
> + igt_assert(stride > 0);
> +
> + height = cairo_image_surface_get_height(surface);
> + igt_assert(height > 0);
> +
> + size = stride * height;
> + write(out_fd, ptr, size);
> +
> + close(out_fd);
> +
> + igt_log_frame_path(summary_fd, path);
> + free(path);
> +}
> +
> /**
> * igt_write_compared_frames_to_png:
> * @reference: The reference cairo surface
> @@ -158,6 +192,54 @@ void igt_write_compared_frames_to_png(cairo_surface_t *reference,
> close(fd);
> }
>
> +/**
> + * igt_write_compared_frames:
> + * @reference: The reference cairo surface
> + * @capture: The captured cairo surface
> + * @reference_suffix: The suffix to give to the reference png file
> + * @capture_suffix: The suffix to give to the capture png file
> + *
> + * Dump previously compared frames to png and raw files.
> + */
> +void igt_write_compared_frames(cairo_surface_t *reference,
> + cairo_surface_t *capture,
> + const char *reference_suffix,
> + const char *capture_suffix)
> +{
> + char *id;
> + const char *test_name;
> + const char *subtest_name;
> + char path[PATH_MAX];
> + int fd = -1;
> +
> + if (!igt_frame_dump_is_enabled())
> + return;
> +
> + id = getenv("IGT_FRAME_DUMP_ID");
> +
> + test_name = igt_test_name();
> + subtest_name = igt_subtest_name();
> +
> + if (id)
> + snprintf(path, PATH_MAX, "%s/frame-%s-%s-%s.txt",
> + igt_frame_dump_path, test_name, subtest_name, id);
> + else
> + snprintf(path, PATH_MAX, "%s/frame-%s-%s.txt",
> + igt_frame_dump_path, test_name, subtest_name);
> +
> + fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
> + igt_assert(fd >= 0);
> +
> + igt_debug("Writing dump report to %s...\n", path);
> +
> + igt_write_frame_to_raw(reference, fd, "reference", reference_suffix);
> + igt_write_frame_to_png(reference, fd, "reference", reference_suffix);
> + igt_write_frame_to_raw(capture, fd, "capture", capture_suffix);
> + igt_write_frame_to_png(capture, fd, "capture", capture_suffix);
> +
> + close(fd);
> +}
> +
> /**
> * igt_check_analog_frame_match:
> * @reference: The reference cairo surface
> diff --git a/lib/igt_frame.h b/lib/igt_frame.h
> index f44f57d7ce73..51cbc2bd68b4 100644
> --- a/lib/igt_frame.h
> +++ b/lib/igt_frame.h
> @@ -36,6 +36,10 @@ void igt_write_compared_frames_to_png(cairo_surface_t *reference,
> cairo_surface_t *capture,
> const char *reference_suffix,
> const char *capture_suffix);
> +void igt_write_compared_frames(cairo_surface_t *reference,
> + cairo_surface_t *capture,
> + const char *reference_suffix,
> + const char *capture_suffix);
> bool igt_check_analog_frame_match(cairo_surface_t *reference,
> cairo_surface_t *capture);
> bool igt_check_checkerboard_frame_match(cairo_surface_t *reference,
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2022-04-29 12:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 14:55 [igt-dev] [PATCH i-g-t v2 0/8] Writeback fixes and improvements Maxime Ripard
2022-03-28 14:55 ` [igt-dev] [PATCH i-g-t v2 1/8] lib/igt_frame: Rename summary fd variable Maxime Ripard
2022-03-28 14:55 ` [igt-dev] [PATCH i-g-t v2 2/8] lib/igt_frame: Move frame dump logging to function Maxime Ripard
2022-03-28 14:55 ` [igt-dev] [PATCH i-g-t v2 3/8] lib/igt_frame: Move frame path creation " Maxime Ripard
2022-03-28 14:55 ` [igt-dev] [PATCH i-g-t v2 4/8] lib/igt_frame: Add function to dump frames in RGB and raw Maxime Ripard
2022-04-29 12:46 ` Pekka Paalanen [this message]
2022-05-04 14:56 ` Maxime Ripard
2022-05-05 7:21 ` Pekka Paalanen
2022-03-28 14:55 ` [igt-dev] [PATCH i-g-t v2 5/8] tests/kms_writeback: Use endianness accessor to fill pixels Maxime Ripard
2022-03-28 14:55 ` [igt-dev] [PATCH i-g-t v2 6/8] tests/kms_writeback: Dump the frames if the don't match Maxime Ripard
2022-04-29 12:55 ` Pekka Paalanen
2022-05-04 14:57 ` Maxime Ripard
2022-03-28 14:55 ` [igt-dev] [PATCH i-g-t v2 7/8] lib/igt_fb: Ignore the X component when computing CRC Maxime Ripard
2022-04-29 12:58 ` Pekka Paalanen
2022-03-28 14:55 ` [igt-dev] [PATCH i-g-t v2 8/8] tests/kms_writeback: Use a garbage X value to create fill our test buffer Maxime Ripard
2022-04-29 13:01 ` Pekka Paalanen
2022-03-28 16:07 ` [igt-dev] ✓ Fi.CI.BAT: success for Writeback fixes and improvements (rev2) Patchwork
2022-03-28 19:08 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-03-30 7:30 ` Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220429154645.1680bad2@eldfell \
--to=ppaalanen@gmail.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=maxime@cerno.tech \
--cc=petri.latvala@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox