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

Justin Ruggles justinruggles
Sat Mar 10 15:26:37 CET 2007


Michael Niedermayer wrote:
> Hi
> 
> On Fri, Mar 09, 2007 at 11:18:42PM -0500, Justin Ruggles wrote:
> [...]
> 
>>>this looks wrong, it doesnt generate the same table
>>>the followig MIGHT be correct (didnt really check)
>>>
>>>for(i=0; i<38; i++) {
>>>    int br = ff_ac3_bitratetab[i >> 1];
>>>    ff_ac3_frame_sizes[i][0] = (  2*br      );
>>>    ff_ac3_frame_sizes[i][1] = (320*br / 147) + (i & 1);
>>>    ff_ac3_frame_sizes[i][2] = (  3*br      );
>>>}
>>>
>>>[...]
>>
>>You're right.  I did forget about the fact that the odd numbers only
>>differ for 44.1kHz, and that was all I tested with.
>>
>>ff_ac3_frame_sizes[i][j] = (br * 96 / ff_ac3_freqs[j]) + ((i & 1) &&
>>                                                          (j == 1));
>>
>>The above also does the trick, but I like your version better.  New
>>patch attached.
> 
> 
> theres another possible issue which ive missed ...
> ac3_common() is after your patch executed by the AVParser initalization
> which MUST be thread safe as new AVStreams can be added anytime 
> (in mpeg-ps/ts for example) and that also might cause a new AVParser to be
> inited, now the current code looks safe but ac3_common() should get a
> comment that it has to be thread safe because its called by the AVParser 
> init code
> otherwise someone smart might by misstake add code like:
> 
> static int done=0
> if(!done){
>     done=1;
>     for(...)
>         foobartab[i]= abcd;
> }
> 
> except that patch looks ok

Okay.  Would this work?

/**
 * Initializes some tables.
 * note: This function must remain thread safe because it is
 *       called by the AVParser init code.
 */
void ac3_common_init(void)
{




More information about the ffmpeg-devel mailing list