Help For Binary I/O On ARM Processor

The project runs on ARM linux, and performs CPU intensive operations on video frames based an internal model. The internal model is specified by several large 2D arrays of floats.

We need a way to quickly swap out the model during runtime, so the idea is to store the 2D arrays as binary files and load them in as needed. I'm free to layout the binary files however I wish.

Here's my current plan:
1. Have the first line of the file be ints that tell the dimensions of the array. Then, I'll allocate a 1D float[] of size (width*height).

2. Read the rest of the binary data (the floats) into a 1D buffer.

Ex: fread(buffer, sizeof(float), width*height, fp)

3. Then, allocate a 2D array, and loop over the buffer, copying row by row from the buffer using memcpy.

Here are my concerns/questions?

1. Overall Approach: Does this seem like a reasonable way to do this? Is there a lightwight library which could do this for me?

2. Endianness: I'm free to create the binary file in a fixed endian. However,
I want the load function to work on either endian platform.
What's the best way to accomplish that?

Anything else I should watch out for? Thanks for your help!



For the 2nd question, I'd just use sqlite, irt takes care of endiannes problem for you and it is lightweight enough.
If you pass the values as text, you avoid this binary compatibilty problem. You have bigger issues than just endianness, you're assuming that your hardware are using the same binary format of double.

You can pass binary floating proint values using a portable format like HDF5.

The Overall Approach is fine. Compute grids basically do this, but the job is specified in self describing proprietory formats.
Topic archived. No new replies allowed.