[Libav-user] AC3 -> LPCM -> MPEG2 PES

Andrey Utkin andrey.krieger.utkin at gmail.com
Fri Feb 24 17:20:53 CET 2012


2012/2/24 Pavel Sokolov <pavel at sokolov.me>:
> How can I obtain raw data from audio AVFrame?
> It is array of AV_NUM_DATA_POINTERS:
> typedef struct AVFrame {
> ..
> uint8_t *data[AV_NUM_DATA_POINTERS];
> int linesize[AV_NUM_DATA_POINTERS];
> ..
> }
>
> Should I use data all array items, something like this?
> for (int i=0; i<AV_NUM_DATA_POINTERS;i++){
> uint8_t* currdata=frame.data[i];
> int dataSize=frame.linesize[i];
>
> }

Currently, PACKED samples format is used everywhere in libav. So for
audio, all data goes in data[0], containing frame.nb_samples samples.
i think linesize[0] indeed stores number of bytes in data[0].
BBB has explained it to me on #libav this way:
(18:10:13) BBB: which, for stereo, is interleaved
(18:10:18) BBB: so the data packet looks like this:
(18:10:29) BBB: [sample0left][sample0right][sample1left][sample1right][...]
(18:10:33) BBB: right?
(18:10:46) BBB: there's a new audio format (currently unused) called
SAMPLE_FMT_S16LE_PLANAR
(18:10:52) BBB: that will look like this:
(18:11:02) BBB: [sample0left][sample1left][...][sampleNleft]
(18:11:06) BBB: for data[0]
(18:11:09) BBB: and data[1] looks like this:
(18:11:20) BBB: [sample0right][sample1right][...][sampleNright]
(18:11:26) BBB: so then you have multiple pointers

-- 
Andrey Utkin


More information about the Libav-user mailing list