[Ffmpeg-devel] Audio decode loops in ffmpeg.c

Thanos Kyritsis djart
Fri Feb 17 09:22:34 CET 2006


Good day,

I'd like some help on understanding the audio decoding part of ffmpeg.c, 
if someone could be willing enough to explain :)

I'm interested on the output_packet() function. This function does the 
following:

....... [snipped code] ......

len = pkt->size;
ptr = pkt->data;
while (len >0) {

....... [snipped code] ......

ret = avcodec_decode_audio(ist->st->codec, samples, &data_size,
                                           ptr, len);

....... [snipped code] ......

ptr += ret;
len -= ret;
if (data_size <= 0) { .... }

etc etc .....

}


I can't understand why:
ptr += ret;
len -= ret;
are needed. 

I have noticed that they cause the whole decoding loop to rerun on the 
same pkt for input streams like AC3, whereas len-=ret makes len = 0 for 
input streams like mp3 or wav, thus making the decoding loop run only 
one time for each pkt.

Could it be because avcodec_decode_audio() is not able to handle a whole 
AC3 pkt, but needs to run twice or more for such a pkt to get decoded 
fully ?


Could someone explain this, please ? Thanks in advance!

-- 
Thanos Kyritsis <djart at linux.gr>

- What's your ONE purpose in life ?
- To explode, of course! ;-)





More information about the ffmpeg-devel mailing list