[FFmpeg-devel] [PATCH] Make libavcodec/apiexample.c compile

Robert Swain robert.swain
Mon Mar 23 20:10:41 CET 2009


On 23/3/09 05:43, Michael Niedermayer wrote:
> On Mon, Mar 23, 2009 at 12:35:29AM +0000, Robert Swain wrote:
>> On 20/3/09 15:56, Michael Niedermayer wrote:
>>> On Fri, Mar 20, 2009 at 03:33:33PM +0000, Robert Swain wrote:
>>>> Is anything more than the attached needed to bring
>>>> libavcodec/apiexample.c
>>> setting out_size
>> So the attached should do it? I thought it would be a good idea to set it
>> close to where it is allocated in case it is changed in future.
> [...]
>> @@ -138,6 +138,7 @@
>>       }
>>
>>       outbuf = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
>> +    out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
>>
>>       f = fopen(filename, "rb");
>>       if (!f) {
>> @@ -159,7 +160,7 @@
>>
>>           inbuf_ptr = inbuf;
>>           while (size>  0) {
>> -            len = avcodec_decode_audio(c, (short *)outbuf,&out_size,
>> +            len = avcodec_decode_audio2(c, (short *)outbuf,&out_size,
>>                                          inbuf_ptr, size);
>>               if (len<  0) {
>>                   fprintf(stderr, "Error while decoding\n");
>
> i just wanted to say ok, then i saw the while()
> is te out_size value correct if this is executed more than once?

Hmm, indeed. I think out_size needs to be reset before each call to 
avcodec_decode_audio2(). See attached.

Regards,
Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20090323-0943-fix_apiexample.diff
Type: text/x-diff
Size: 608 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090323/8d291898/attachment.diff>



More information about the ffmpeg-devel mailing list