[Ffmpeg-devel] [PATCH] remove ac3 tables from parser.c

Justin Ruggles justinruggles
Fri Mar 9 01:59:51 CET 2007


Michael Niedermayer wrote:
> Hi
> 
> On Thu, Mar 08, 2007 at 06:21:09PM -0500, Justin Ruggles wrote:
> 
>>This removes duplication in the AC-3 tables between encoder and parser.
>>
>>For now, there is not a place for common AC-3 code, so with this patch,
>>parser.c includes ac3tab.h.  Once there is an ac3.c, parser.c will be
>>changed to include ac3.h instead.
> 
> 
> this effectively duplicates the table in the object files as every file
> which includes ac3tab.h would have a duplicated table ...

Only temporarily.  Once ac3.c is created, it will be the only file
including ac3tab.h.  Right now, only ac3enc.c includes it.  Also, after
sending the patch, I noticed that ac3enc.c can make use of the frame
size table as well.  Another reason to put the frame size table in
ac3tab.h is that it can eventually be generated at runtime in
ac3_common_init.

New patch attached including the change to ac3enc.c.

> [...]
> 
> 
>> static const uint8_t eac3_blocks[4] = {
>>     1, 2, 3, 6
>> };
>>@@ -672,7 +621,7 @@
>>         fscod = get_bits(&bits, 2);
>>         frmsizecod = get_bits(&bits, 6);
>> 
>>-        if(fscod == 3)
>>+        if(fscod == 3 || frmsizecod > 37)
>>             return 0;
> 
> 
> unrelated change?

It is related.  The bitrate table in parser.c has a length of 64 and is
indexed by frmsizecod, but the one in ac3tab.h is only 19 and is indexed
by (frmsizecod >> 1).  Adding the check avoids reading past the end of
the array when frmsizecod is too high.  Plus, values over 37 are
invalid, so this is better behavior anyway.

-Justin




More information about the ffmpeg-devel mailing list