John Swensen wrote:
FYI, here is how I ended up copying a unsigned char buffer into a Matrix
of type uint8. It ended up taking about 50% of the time of doing it
element by element.
static Matrix m1(settings.width, settings.height);
static uint8NDArray m = octave_value(m1).uint8_array_value();
static octave_uint8* tmp = m.fortran_vec();
memcpy( tmp, capturebuffer, settings.height*settings.width );
return octave_value(m.transpose());
Shouldn't that be
static unit8NDArray m (dim_vector(settings.width, settings.height));
static octave_uint8* tmp = m.fortran_vec();
memcpy( tmp, capturebuffer, settings.height*settings.width );
return octave_value(m.transpose());
You might be able to do away with the transpose as well, as the
transpose means that there is a second copy of m in memory at the same
time. However, for it to be efficient, it would have to be some sort of
blocked algorithm so that cache limitations are taken into account..
D.