[FFmpeg-devel] [PATCH] Headerless AAC

Robert Swain robert.swain
Thu Jan 14 11:18:36 CET 2010


On 14/01/10 09:57, Alex Converse wrote:
> On Thu, Jan 14, 2010 at 3:45 AM, Robert Swain<robert.swain at gmail.com>  wrote:
>>
>> On 14/01/10 02:26, Alex Converse wrote:
>>>
>>> This patch allows FFmpeg to decode raw AAC based on just a sample rate and
>>> channel count signaled to the decoder.
>>
>> Cool. :)
>>
>>> diff --git a/libavcodec/aac.c b/libavcodec/aac.c
>>> index b47b58e..df776d4 100644
>>> --- a/libavcodec/aac.c
>>> +++ b/libavcodec/aac.c
>>> @@ -502,8 +502,30 @@ static av_cold int aac_decode_init(AVCodecContext *avccontext)
>>
>> [...]
>>
>>> +        memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
>>> +        if (set_default_channel_config(ac, new_che_pos, chan_config))
>>> +            goto done_out_config;
>>> +        if (output_configure(ac, ac->che_pos, new_che_pos, chan_config, OC_TRIAL_PCE))
>>> +            goto done_out_config;
>>> +        ac->m4ac.chan_config = chan_config;
>>> +        ac->m4ac.sampling_index = sampling_index;
>>>       }
>>> +done_out_config:
>>>
>>>       avccontext->sample_fmt = SAMPLE_FMT_S16;
>>>       avccontext->frame_size = 1024;
>>
>> Hmm, if set_default_channel_config() or output_configure() return an error, shouldn't this function also return with an error?
>>
>
> I tried to make the new support not break anything that already works.
> In particular I'm worried about a case with 7 or 9+ channels where we
> are expecting an in band PCE. (Did I ever mention how much I hate the
> inband PCE?) That's also why I went with the same merit configuration
> as an inband PCE. Thus if anything goes wrong we revert to the old
> behavior of initializing the decoder and try_decode_frame kicks in to
> try to guess a configuration.

Ah, I see. In that case, this is OK. We can always alter the behaviour 
if people report issues.

> If people think we should trust container info more than an inband PCE
> that's fine but be warned some channel counts don't have valid default
> configurations.
>
> If you want I can create a new merit for this that is lower/higher
> than inband PCE.

I suspect use of headerless AAC streams is very rare. As these values 
are from user-input, I'm not sure how much we should trust them. I 
suppose we should absolutely trust them, assume the user knows what 
they're doing, but fail gracefully if it turns out that they don't. In 
which case it could be given a higher merit, right?

Regards,
Rob



More information about the ffmpeg-devel mailing list