[Libav-user] Converting audio sample buffer format

Brad O'Hearne brado at bighillsoftware.com
Tue Feb 26 23:27:44 CET 2013


On Feb 26, 2013, at 3:04 PM, Nicolas George <nicolas.george at normalesup.org> wrote:

>> On Feb 26, 2013, at 1:01 PM, René J.V. Bertin <rjvbertin-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:
>>> 							  What I don't dare
>>> to guess is why the void* type isn't used - is there a practical reason
>>> or only a 'programming principle' behind that?
> 
> You can not do pointer arithmetic with void pointers. Therefore, for some
> simple task (for example, copying n samples from position m to position p),
> having the pointer already with a suitable type avoids an additional cast.
> 
> 
> L'octidi 8 ventôse, an CCXXI, Brad O'Hearne a écrit :
>> Perhaps I've been staring at this too long and am losing my mind, but
>> there is a difference between uint8_t and int8_t:
> 
> This difference is irrelevant for pointer arithmetic, it is only relevant
> when dereferencing the pointer. You are not supposed to dereference these
> pointers directly, you are supposed to cast them to the actual type of the
> samples before.

Nicolas - thanks for the reply. This makes sense (more or less) to me for a planar format -- if I'm understanding you correctly, such a structure would look something like:

uint8_t **data
data[0]-> channel 1 buffer
data[1]-> channel 2 buffer

If this is right, then what does an interleaved format look like, is it like this:

uint8_t **data
data[0]-> buffer containing interleaved channel 1 and channel 2 data

Is that correct? 

Thanks,

Brad



More information about the Libav-user mailing list