[FFmpeg-devel] [PATCH] LATM Parser & LATM/AAC Decoder

David Conrad lessen42
Wed Apr 22 11:30:42 CEST 2009


On Apr 22, 2009, at 4:58 AM, Paul Kendall wrote:

> On Wednesday 22 April 2009 08:40:49 pm Robert Swain wrote:
>> Paul Kendall wrote:
>>> On Wednesday 22 April 2009 06:08:35 pm David Conrad wrote:
>>>>
>>>> Make an AVBitStreamFilter or AVParser (bitstream filter is probably
>>>> more appropriate) that takes LATM wrapped AAC and extracts a raw  
>>>> AAC
>>>> bitstream, then add a way to get it to automatically use it in  
>>>> the ts
>>>> demuxer. Then the standard mechanisms (-codec for ffmpeg) will  
>>>> allow
>>>> choosing between multiple plain AAC decoders. As an added plus,  
>>>> this
>>>> won't horribly break codec copy.
>>>
>>> Using a bitstream filter is a good idea.
>>>
>>>> From what I understand, you need a parser, which then has a split  
>>>> which
>>>
>>> extracts the extradata (used by an AAC decoder to figure out the  
>>> channels
>>> and sampling frequency etc). Then a bitstream filter (which has  
>>> all the
>>> same code as split!) to remove the LATM and leave the raw AAC from  
>>> the
>>> stream.
>>>
>>> If I'm wrong here, please correct me and I'll consider doing it  
>>> this way
>>> if it's the preferred method.
>>
>> David's description is spot on. An LATM bitstream filter should parse
>> anything necessary from the LATM bitstream and reformat anything such
>> that the AAC (or other, but that can be extended later, I'm just
>> speaking generically) payload is formatted correctly for the decoder.
>>
>> I'm not really sure what you mean about a parser versus a bitstream  
>> filter.
>>
>
> I think I'm a bit confuzzled here too.
>
> So the plan is no parser, use a bitstream filter to extract  
> extradata (for
> channels & sample freq) and the AAC raw data. I know that the ffmpeg  
> libfaad
> decoder can use extradata to configure the faad2 decoder. You can  
> then select
> the decoder using the -codec option to ffmpeg or ffplay.
>
> The last hurdle then is to "somehow" get mpegts so automagically  
> install the
> LATM bitstream filter in the chain.
>
> I think I'm confused because I thought you would need a parser to  
> packetize
> the LATM stream and earlier (a long time ago) Micheal mentioned that a
> split method (in the parser) would be used to extract the extradata  
> for
> configuring the decoder. So, if we had a parser then mpegts would  
> need to
> select the parser, LATM, install the bitstream filter, somehow, then  
> we'd have
> to redirect the raw data to the correct decoder, either ffaac or  
> libfaad.
>
> Phew, what's the right way? Obviously there are some missing pieces,  
> either
> in my understanding or in ffmpeg, either way I am ready & willing to  
> help.

In general, in ffmpeg parsers split a stream into discrete, correct  
frames/packets without changing the actual bitstream, and maybe do  
some stuff with timestamps. So if you compared the concatenated  
bitstream before and after the parser, it should be the same for all  
of ffmpeg's current parsers (I think, I haven't looked at every parser.)

I don't know whether you need a parser for latm (it depends on whether  
mpeg-ts is guaranteed to give you the correct packet boundaries). If  
you do need one, the parser you already have should suffice, though  
ideally CODEC_ID_AAC_LATM would not be needed. Either way, the stream  
should have CODEC_ID_AAC after the bitstream filter.

As for extradata handling, the closest example in ffmpeg I can think  
of is H.264, where the decoder can handle both mp4 style (separate  
extradata) and annex B directly, and the h264_mp4toannexb bitstream  
filter converts between the two.



More information about the ffmpeg-devel mailing list