[FFmpeg-devel] [PATCH] Flush final frames in libfaac encoder.

Justin Ruggles justin.ruggles
Sat Jan 29 20:10:04 CET 2011


On 01/29/2011 01:59 PM, M?ns Rullg?rd wrote:

> Justin Ruggles <justin.ruggles at gmail.com> writes:
> 
>> Gives decoded output identical in length to faac commandline encoder.
>> Fixes Issue 670.
>> ---
>>  libavcodec/libfaac.c |    4 +++-
>>  1 files changed, 3 insertions(+), 1 deletions(-)
>>
>>
>> diff --git a/libavcodec/libfaac.c b/libavcodec/libfaac.c
>> index 79ab729..af85587 100644
>> --- a/libavcodec/libfaac.c
>> +++ b/libavcodec/libfaac.c
>> @@ -124,10 +124,11 @@ static int Faac_encode_frame(AVCodecContext *avctx,
>>  {
>>      FaacAudioContext *s = avctx->priv_data;
>>      int bytes_written;
>> +    int num_samples = data ? avctx->frame_size : 0;
>>  
>>      bytes_written = faacEncEncode(s->faac_handle,
>>                                    data,
>> -                                  avctx->frame_size * avctx->channels,
>> +                                  num_samples * avctx->channels,
>>                                    frame,
>>                                    buf_size);
>>  
>> @@ -161,6 +162,7 @@ AVCodec ff_libfaac_encoder = {
>>      Faac_encode_init,
>>      Faac_encode_frame,
>>      Faac_encode_close,
>> +    .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
>>      .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
>>      .long_name = NULL_IF_CONFIG_SMALL("libfaac AAC (Advanced Audio Codec)"),
>>      .profiles = NULL_IF_CONFIG_SMALL(profiles),
> 
> Looks OK.  I trust you tested it.


Yes, I tested it.

[libfaac @ 0x2a6d830] frame 0: 1024 samples, 0 bytes
[libfaac @ 0x2a6d830] frame 1: 1024 samples, 0 bytes
[libfaac @ 0x2a6d830] frame 2: 1024 samples, 0 bytes
[libfaac @ 0x2a6d830] frame 3: 1024 samples, 427 bytes
[libfaac @ 0x2a6d830] frame 4: 1024 samples, 407 bytes
...
[libfaac @ 0x2a6d830] frame 22498: 1024 samples, 398 bytes
[libfaac @ 0x2a6d830] frame 22499: 1015 samples, 380 bytes
[libfaac @ 0x2a6d830] frame 22500: 0 samples, 367 bytes
[libfaac @ 0x2a6d830] frame 22501: 0 samples, 387 bytes
[libfaac @ 0x2a6d830] frame 22502: 0 samples, 397 bytes
[libfaac @ 0x2a6d830] frame 22503: 0 samples, 379 bytes
[libfaac @ 0x2a6d830] frame 22504: 0 samples, 0 bytes

This is also how faac commandline works (write frames until input
samples == 0 and output bytes == 0).  I had to check the source to find
out because I couldn't find documentation anywhere.

Thanks,
Justin



More information about the ffmpeg-devel mailing list