Algorithm to make interleaved buffer to non-interleaved

Algorithm to make interleaved buffer to non-interleaved

Post by Barz » Sat, 03 Apr 2010 17:43:37


Hi,

I have an interleaved audio buffer: short* Buffer.
And I have to to this conversion

[A][B][C][A][B][C][A][B][C] -> [A][A][A][B][B][B][C][C][C]

Is there some pattern or specific algorithm?
Thanks,
Daniele.
 
 
 

Algorithm to make interleaved buffer to non-interleaved

Post by Sam » Sat, 03 Apr 2010 18:55:32

This is a MIME GnuPG-signed message. If you see this text, it means that
your E-mail or Usenet software does not support MIME signed messages.
The Internet standard for MIME PGP messages, RFC 2015, was published in 1996.
To open this message correctly you will need to install E-mail or Usenet
software that supports modern Internet standards.

Barzo writes:


Yes, but this has nothing to do with C++, the programming language. The
algorithm would be the same whether it's implemented in C++, or Java, or
Python, or Perl, or any other capable language that's ever existed. Your
question seems to be not how to implement this specifically C++, but what it
actually is. Well, if "I" is your input array of size N, where N is
divisible by 3, and the I array is indexed from 0, then your output array
consists of elements

I[0], I[3], I[6], I[N-3]

followed by

I[1], I[4], I[7], I[N-2]

and finally followed by

I[2], I[5], I[8] I[N-1]



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEABECAAYFAku1vxMACgkQx9p3GYHlUOLAWQCcCpKBRSyycooJQJzMWaA7sU6J
DDgAn2ZZszqmLGPZhaHK/XOQ47Mvr9tH
=gjmQ
-----END PGP SIGNATURE-----

 
 
 

Algorithm to make interleaved buffer to non-interleaved

Post by Jeff Flin » Sat, 03 Apr 2010 20:44:30


Image data is similarly interleaved. The boost GIL library has the
facilities to view and traverse numerous ways including planar view as
you describe above. See:

http://www.yqcomputer.com/

Jeff
 
 
 

Algorithm to make interleaved buffer to non-interleaved

Post by Jonathan L » Sat, 03 Apr 2010 23:13:20


You want to look for matrix transposition algorithms.

If you have different input and output arrays, the simplest
thing to do is to just copy all the As then all the Bs, etc. More
or less what Sam pointed out. This can cause some cache thrash,
though. There are cache oblivious algorithms to handle that.

If you have to do it in place, Google for "in situ matrix
transposition".

--Jonathan