From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: kieran.bingham@ideasonboard.com
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>,
linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 3/4] kms++util: Add verification module
Date: Mon, 18 Dec 2017 13:36:20 +0200 [thread overview]
Message-ID: <1593408.WvHWapkjaJ@avalon> (raw)
In-Reply-To: <b8d5db70-0193-49b7-773b-dcebd9c8cb20@ideasonboard.com>
Hi Kieran,
On Saturday, 16 December 2017 18:13:51 EET Kieran Bingham wrote:
> On 15/12/17 13:43, Tomi Valkeinen wrote:
> > On 14/12/17 01:10, Kieran Bingham wrote:
> >> From: Kieran Bingham <kieran.bingham@ideasonboard.com>
> >>
> >> Provide a util module to provide helpers involved in validation and
> >> verification of data frames.
> >>
> >> The first addition is a raw frame binary output with bindings to python
> >> modelled on Tomi's implementation in wbcap.
> >
> > I don't think verification.cpp is a good name for this. A function to save
> > the fb sounds like a generic fb utility.
>
> Yes, I was originally going to put it in one of the existing framebuffer
> classes - but then realised they were abstracted classes, and it had to use
> the base type :)
>
> I was looking at verifying frames, so this was the first name that came to
> my head :D
>
> > In fact, I'd like to have a helper utility function to save as png, as
> > converting a raw image to png is a bit of a hassle. Then again, we'd need
> > a png library for that, and possibly bigger pieces of code to handle all
> > the different pixel formats...
>
> So would I ! I'm glad you bring the topic up :)
>
> Are you happy to bring in external libraries to support such functionality?
>
> I guess we can make it so the configure scripts select the feature if
> libraries are available or such.
>
> Being able to save directly to easily viewable file formats would certainly
> ease things, (while still being able to save raw files for some manual
> verifications)
The problem with PNG (or any other format really) is that you not only need to
encode the image into the target format (PNG or JPG would require external
libraries, simpler formats such as BMP or PNM could be handled internally),
but you also need to convert the image to a particular RGB or YUV format
depending on what the output format requires.
If you want to do so, I would like to reuse code from the v4l2convert library.
The code should be moved to a library that doesn't depend on V4L2, as the
current API encapsulate conversion in other operations. Other tools such as
raw2rgbpnm could then be ported to use that library;
> > So, a function to save the raw bits is fine, but how about "fbutils.cpp"
> > or such?
>
> Yes, that sounds reasonable.
>
> >> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> >> ---
> >> kms++util/inc/kms++util/kms++util.h | 2 ++
> >> kms++util/src/verification.cpp | 21 +++++++++++++++++++++
> >> py/pykms/pykmsutil.cpp | 5 +++++
> >> 3 files changed, 28 insertions(+)
> >> create mode 100644 kms++util/src/verification.cpp
> >>
> >> diff --git a/kms++util/inc/kms++util/kms++util.h
> >> b/kms++util/inc/kms++util/kms++util.h
> >> index 8e45b0df3cde..431de0bb159a 100644
> >> --- a/kms++util/inc/kms++util/kms++util.h
> >> +++ b/kms++util/inc/kms++util/kms++util.h
> >> @@ -27,6 +27,8 @@ void draw_text(IFramebuffer& buf, uint32_t x, uint32_t
> >> y,
> >> const std::string& str
> >> 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);
> >> }
> >> #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
> >> diff --git a/kms++util/src/verification.cpp
> >> b/kms++util/src/verification.cpp new file mode 100644
> >> index 000000000000..3210bb144d2b
> >> --- /dev/null
> >> +++ b/kms++util/src/verification.cpp
> >> @@ -0,0 +1,21 @@
> >> +
> >> +#include <kms++/kms++.h>
> >> +#include <kms++util/kms++util.h>
> >> +
> >> +#include <fstream>
> >> +
> >> +using namespace std;
> >> +
> >> +namespace kms
> >> +{
> >> +
> >> +void save_raw_frame(IFramebuffer& fb, const char *filename)
> >> +{
> >> + unique_ptr<ofstream> os;
> >> + os = unique_ptr<ofstream>(new ofstream(filename, ofstream::binary));
> >> +
> >> + for (unsigned i = 0; i < fb.num_planes(); ++i)
> >> + os->write((char*)fb.map(i), fb.size(i));
> >> +}
> >
> > You don't need any of that unique_ptr stuff here. I needed it as the code
> > needed to handle the case where we don't save, i.e. os = null.
>
> Ah OK - I thought it was providing the hook up to automatically close the
> stream at the end of the function.
>
> I guess an explicit close would be just as clean :)
>
> As the commit message suggests, this was a direct copy paste from your
> implementation after I saw it as a better implementation than my previous
> 'C' version. (I don't spend a lot of time in C++ land)
>
> > And I'm not fond of the function name, "frame" doesn't sound good. Maybe
> > rather save_raw_fb(). Or save_fb_raw(), so in the future we might have
> > also save_fb_png().
>
> Agreed, sounds fine. I'm definitely looking forward to a save_fb_png().
>
> >> +
> >> +}
> >> diff --git a/py/pykms/pykmsutil.cpp b/py/pykms/pykmsutil.cpp
> >> index 518d5eaa88f0..2d741751ba75 100644
> >> --- a/py/pykms/pykmsutil.cpp
> >> +++ b/py/pykms/pykmsutil.cpp
> >> @@ -59,4 +59,9 @@ void init_pykmstest(py::module &m)
> >> } );
> >> m.def("draw_text", [](Framebuffer& fb, uint32_t x, uint32_t y,
> >> const
> >> string& str, RGB color) {
> >> draw_text(fb, x, y, str, color); } );
> >> +
> >> + // Verification and Validation
> >> + m.def("save_raw_frame", [](Framebuffer& fb, const char * filename) {
> >> + save_raw_frame(fb, filename);
> >> + });
> >> }
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2017-12-18 11:36 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 [this message]
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
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=1593408.WvHWapkjaJ@avalon \
--to=laurent.pinchart@ideasonboard.com \
--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.