All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Kieran Bingham <kbingham@kernel.org>
Cc: linux-renesas-soc@vger.kernel.org,
	Tomi Valkeinen <tomi.valkeinen@ti.com>,
	Kieran Bingham <kieran.bingham@ideasonboard.com>
Subject: Re: [PATCH 4/4] kms++util: Add frame compare functionality
Date: Mon, 18 Dec 2017 13:47:10 +0200	[thread overview]
Message-ID: <29111142.qPZD2G3ZDZ@avalon> (raw)
In-Reply-To: <29f0046ac6a6e4f9337aa66c912d99fa4a30d592.1513206331.git-series.kieran.bingham@ideasonboard.com>

Hi Kieran,

Thank you for the patch.

On Thursday, 14 December 2017 01:10:12 EET Kieran Bingham wrote:
> From: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> Provide a means to compare two identically sized framebuffers.
> 
> This basic implementation expects the two buffers to have the same
> formats and sizes, and will return zero for identical frames, or a
> positive float representing and average difference otherwise.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  kms++util/inc/kms++util/kms++util.h |  1 +-
>  kms++util/src/verification.cpp      | 31 ++++++++++++++++++++++++++++++-
>  py/pykms/pykmsutil.cpp              |  2 ++-
>  3 files changed, 34 insertions(+)
> 
> diff --git a/kms++util/inc/kms++util/kms++util.h
> b/kms++util/inc/kms++util/kms++util.h index 431de0bb159a..753cee189451
> 100644
> --- a/kms++util/inc/kms++util/kms++util.h
> +++ b/kms++util/inc/kms++util/kms++util.h
> @@ -29,6 +29,7 @@ void draw_color_bar(IFramebuffer& buf, int old_xpos, int
> xpos, int width); void draw_test_pattern(IFramebuffer &fb, YUVType yuvt =
> YUVType::BT601_Lim);
> 
>  void save_raw_frame(IFramebuffer& fb, const char *filename);
> +float compare_framebuffers(IFramebuffer& a, IFramebuffer& b);
>  }
> 
>  #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
> diff --git a/kms++util/src/verification.cpp b/kms++util/src/verification.cpp
> index 3210bb144d2b..a46d6f924095 100644
> --- a/kms++util/src/verification.cpp
> +++ b/kms++util/src/verification.cpp
> @@ -18,4 +18,35 @@ void save_raw_frame(IFramebuffer& fb, const char
> *filename) os->write((char*)fb.map(i), fb.size(i));
>  }
> 
> +float compare_framebuffers(IFramebuffer& a, IFramebuffer& b)
> +{
> +	unsigned int i;
> +	unsigned int pixels = a.width() * a.height();
> +	uint8_t *pa = a.map(0);
> +	uint8_t *pb = b.map(0);
> +
> +	float diff = 0;
> +
> +	if (a.format() != b.format())
> +		throw std::invalid_argument("Pixel formats differ...");
> +
> +	if ((a.width() != b.width() ||
> +	    (a.height() != b.height())))
> +		throw std::invalid_argument("Frame sizes differ...");
> +
> +	// Formats are identical, so num_planes are already identical
> +	for (i = 0; i < a.num_planes(); i++) {
> +		if ((a.offset(i) != b.offset(i)) ||
> +		    (a.stride(i) != b.stride(i)))
> +			throw std::invalid_argument("Planes differ...");
> +	}

Is this required ? Why can't we compare two image of identical size stored in 
frame buffers with different strides ?

> +	// Simple byte comparisons to start.
> +	// This expects a frame to be identical, including non-visible data.

Do we need to compare the non-visible data ?

> +	for (i = 0; i < a.size(0) && i < b.size(0); i++)
> +		diff += abs(pa[i] - pb[i]);
> +
> +	return diff / pixels;
> +}
> +
>  }
> diff --git a/py/pykms/pykmsutil.cpp b/py/pykms/pykmsutil.cpp
> index 2d741751ba75..b86690a3d306 100644
> --- a/py/pykms/pykmsutil.cpp
> +++ b/py/pykms/pykmsutil.cpp
> @@ -64,4 +64,6 @@ void init_pykmstest(py::module &m)
>  	m.def("save_raw_frame", [](Framebuffer& fb, const char * filename) {
>  		save_raw_frame(fb, filename);
>  	});
> +	m.def("compare_framebuffers", [](Framebuffer& a, Framebuffer& b) {
> +		return compare_framebuffers(a, b); } );
>  }

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2017-12-18 11:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 23:10 [PATCH 0/4] kms++util: Provide validation helpers Kieran Bingham
2017-12-13 23:10 ` [PATCH 1/4] videodevice: Fix minor spacing Kieran Bingham
2017-12-18 11:23   ` Laurent Pinchart
2017-12-13 23:10 ` [PATCH 2/4] py: pyvid: Provide stream_off binding Kieran Bingham
2017-12-18 11:29   ` Laurent Pinchart
2017-12-13 23:10 ` [PATCH 3/4] kms++util: Add verification module Kieran Bingham
2017-12-15 13:43   ` Tomi Valkeinen
2017-12-16 16:13     ` Kieran Bingham
2017-12-18 11:36       ` Laurent Pinchart
2017-12-18 11:46         ` Tomi Valkeinen
2017-12-18 11:50           ` Laurent Pinchart
2017-12-18 12:04             ` Tomi Valkeinen
2017-12-18 15:41               ` Laurent Pinchart
2017-12-18 15:48                 ` Tomi Valkeinen
2017-12-18 12:06             ` Geert Uytterhoeven
2017-12-18 11:49       ` Tomi Valkeinen
2017-12-13 23:10 ` [PATCH 4/4] kms++util: Add frame compare functionality Kieran Bingham
2017-12-14  8:52   ` Geert Uytterhoeven
2017-12-14 10:28     ` Kieran Bingham
2017-12-15 14:09   ` Tomi Valkeinen
2017-12-16 16:41     ` Kieran Bingham
2017-12-18 11:47   ` Laurent Pinchart [this message]
2017-12-13 23:17 ` [PATCH 0/4] kms++util: Provide validation helpers Kieran Bingham
2017-12-15 14:10 ` Tomi Valkeinen
2017-12-16 16:46   ` Kieran Bingham

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=29111142.qPZD2G3ZDZ@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=kbingham@kernel.org \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=tomi.valkeinen@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.