Revision e05a3ac7

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 */
tests/ref/acodec/ac3_fixed
1
408f47ee5a60866fc751f7bc2314cbd6 *./tests/data/acodec/ac3.rm
1
5ddb6d25dd117db29627f9d286153a7a *./tests/data/acodec/ac3.rm
2 2
98751 ./tests/data/acodec/ac3.rm
tests/ref/lavf/rm
1
da74fe749c2eb21bbead7de81d2f3078 *./tests/data/lavf/lavf.rm
1
a1c71456f21d5459d2824d75bbdcc80c *./tests/data/lavf/lavf.rm
2 2
346706 ./tests/data/lavf/lavf.rm
tests/ref/seek/ac3_rm
5 5
ret:-1         st: 0 flags:0  ts: 0.788000
6 6
ret: 0         st: 0 flags:1  ts:-0.317000
7 7
ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    271 size:   556
8
ret:-1         st:-1 flags:0  ts: 2.576668
8
ret: 0         st:-1 flags:0  ts: 2.576668
9
ret: 0         st: 0 flags:1 dts: 2.577000 pts: 2.577000 pos:  42397 size:   558
9 10
ret:-1         st:-1 flags:1  ts: 1.470835
10 11
ret:-1         st: 0 flags:0  ts: 0.365000
11 12
ret: 0         st: 0 flags:1  ts:-0.741000
......
19 20
ret:-1         st:-1 flags:1  ts: 0.624171
20 21
ret: 0         st: 0 flags:0  ts:-0.482000
21 22
ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    271 size:   556
22
ret:-1         st: 0 flags:1  ts: 2.413000
23
ret: 0         st: 0 flags:1  ts: 2.413000
24
ret: 0         st: 0 flags:1 dts: 2.368000 pts: 2.368000 pos:  38981 size:   558
23 25
ret:-1         st:-1 flags:0  ts: 1.306672
24 26
ret:-1         st:-1 flags:1  ts: 0.200839
25 27
ret: 0         st: 0 flags:0  ts:-0.905000
......
28 30
ret:-1         st:-1 flags:0  ts: 0.883340
29 31
ret: 0         st:-1 flags:1  ts:-0.222493
30 32
ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:    271 size:   556
31
ret:-1         st: 0 flags:0  ts: 2.672000
33
ret: 0         st: 0 flags:0  ts: 2.672000
34
ret: 0         st: 0 flags:1 dts: 2.821000 pts: 2.821000 pos:  46383 size:   556
32 35
ret:-1         st: 0 flags:1  ts: 1.566000
33 36
ret:-1         st:-1 flags:0  ts: 0.460008
34 37
ret: 0         st:-1 flags:1  ts:-0.645825

Also available in: Unified diff