Revision e05a3ac7 libavcodec/ac3enc.c

View differences:

libavcodec/ac3enc.c
330 330

  
331 331

  
332 332
/**
333
 * LUT to select the bandwidth code based on the bit rate, sample rate, and
334
 * number of full-bandwidth channels.
335
 * bandwidth_tab[fbw_channels-1][sample rate code][bit rate code]
336
 */
337
static const uint8_t ac3_bandwidth_tab[5][3][19] = {
338
//      32  40  48  56  64  80  96 112 128 160 192 224 256 320 384 448 512 576 640
339

  
340
    { {  0,  0,  0, 12, 16, 32, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 },
341
      {  0,  0,  0, 16, 20, 36, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56 },
342
      {  0,  0,  0, 32, 40, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60 } },
343

  
344
    { {  0,  0,  0,  0,  0,  0,  0, 20, 24, 32, 48, 48, 48, 48, 48, 48, 48, 48, 48 },
345
      {  0,  0,  0,  0,  0,  0,  4, 24, 28, 36, 56, 56, 56, 56, 56, 56, 56, 56, 56 },
346
      {  0,  0,  0,  0,  0,  0, 20, 44, 52, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60 } },
347

  
348
    { {  0,  0,  0,  0,  0,  0,  0,  0,  0, 16, 24, 32, 40, 48, 48, 48, 48, 48, 48 },
349
      {  0,  0,  0,  0,  0,  0,  0,  0,  4, 20, 28, 36, 44, 56, 56, 56, 56, 56, 56 },
350
      {  0,  0,  0,  0,  0,  0,  0,  0, 20, 40, 48, 60, 60, 60, 60, 60, 60, 60, 60 } },
351

  
352
    { {  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 12, 24, 32, 48, 48, 48, 48, 48, 48 },
353
      {  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 16, 28, 36, 56, 56, 56, 56, 56, 56 },
354
      {  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 32, 48, 60, 60, 60, 60, 60, 60, 60 } },
355

  
356
    { {  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  8, 20, 32, 40, 48, 48, 48, 48 },
357
      {  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 12, 24, 36, 44, 56, 56, 56, 56 },
358
      {  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 28, 44, 60, 60, 60, 60, 60, 60 } }
359
};
360

  
361

  
362
/**
333 363
 * Adjust the frame size to make the average bit rate match the target bit rate.
334 364
 * This is only needed for 11025, 22050, and 44100 sample rates.
335 365
 */
......
2095 2125
        bw_code        = av_clip((fbw_coeffs - 73) / 3, 0, 60);
2096 2126
    } else {
2097 2127
        /* use default bandwidth setting */
2098
        /* XXX: should compute the bandwidth according to the frame
2099
           size, so that we avoid annoying high frequency artifacts */
2100
        bw_code = 50;
2128
        bw_code = ac3_bandwidth_tab[s->fbw_channels-1][s->bit_alloc.sr_code][s->frame_size_code/2];
2101 2129
    }
2102 2130

  
2103 2131
    /* set number of coefficients for each channel */

Also available in: Unified diff