From: Sylvain Le Gall <sylvain@le-gall.net>
To: caml-list@inria.fr
Subject: Re: bigarray & int24
Date: Mon, 31 Mar 2008 11:27:16 +0000 (UTC) [thread overview]
Message-ID: <slrnfv1ikk.tll.sylvain@gallu.homelinux.org> (raw)
In-Reply-To: <BB046CA812535C45BD0029AA9D04BA7902C90A60@KL-SRV57.lmsintl.com>
Hello,
On 31-03-2008, Christoph Bauer <Christoph.Bauer@lmsintl.com> wrote:
> Hi,
>
> my program should read unaligned 3 byte integers. (A real world
> example for such a format would be an RGB image). What is
> the best approach?
>
> - extend bigarray for the int24 format and send the patch to INRIA
> - write a C-function, which converts the data to an int32-array
> - read an 1-byte-bigarray and construct an int-bigarray
> - ???
>
> It should be a bigarray solution, because my program reads other
> (supported)
> formats as well.
>
> Speed matters, because there are a lot of data.
>
If speed matters, you could use an alternate approach that can give you
a very efficient way of processing:
* keep an int32/int64 bigarray (use native int format -- the one which is the
more efficient)
* use a number of row that allow you to fit a x 24 bit data in b x
(32/64) bit data (least common multiplicator / 32 or 64)
* create a layer that allow you to process your packed data
This is a way to minimize the number of unaligned access, being fully
compatible with your raw format.
You will still have an issue with conversion to Nativeint when
extracting data.
So i recommend you to write your abstract layer in C (gaining full speed
for extraction of packed-aligned data and conversion) and to return
OCaml int (which is possible since your data are only 24 bits long).
This is not very OCaml friendly -- but allow you to get the best in term
of speed.
Regards,
Sylvain Le Gall
prev parent reply other threads:[~2008-03-31 11:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-31 9:58 Christoph Bauer
2008-03-31 10:30 ` [Caml-list] " Berke Durak
2008-03-31 11:27 ` Sylvain Le Gall [this message]
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=slrnfv1ikk.tll.sylvain@gallu.homelinux.org \
--to=sylvain@le-gall.net \
--cc=caml-list@inria.fr \
/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