mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
ac3enc: select bandwidth based on bit rate, sample rate, and number of
full-bandwidth channels. This reduces high-frequency artifacts and improves the quality of the lower frequency audio at low bit rates.
This commit is contained in:
parent
e3c007bb43
commit
e05a3ac713
@ -329,6 +329,36 @@ static const int64_t ac3_channel_layouts[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LUT to select the bandwidth code based on the bit rate, sample rate, and
|
||||||
|
* number of full-bandwidth channels.
|
||||||
|
* bandwidth_tab[fbw_channels-1][sample rate code][bit rate code]
|
||||||
|
*/
|
||||||
|
static const uint8_t ac3_bandwidth_tab[5][3][19] = {
|
||||||
|
// 32 40 48 56 64 80 96 112 128 160 192 224 256 320 384 448 512 576 640
|
||||||
|
|
||||||
|
{ { 0, 0, 0, 12, 16, 32, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 },
|
||||||
|
{ 0, 0, 0, 16, 20, 36, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56 },
|
||||||
|
{ 0, 0, 0, 32, 40, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60 } },
|
||||||
|
|
||||||
|
{ { 0, 0, 0, 0, 0, 0, 0, 20, 24, 32, 48, 48, 48, 48, 48, 48, 48, 48, 48 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 4, 24, 28, 36, 56, 56, 56, 56, 56, 56, 56, 56, 56 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 20, 44, 52, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60 } },
|
||||||
|
|
||||||
|
{ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 24, 32, 40, 48, 48, 48, 48, 48, 48 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 4, 20, 28, 36, 44, 56, 56, 56, 56, 56, 56 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 20, 40, 48, 60, 60, 60, 60, 60, 60, 60, 60 } },
|
||||||
|
|
||||||
|
{ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 24, 32, 48, 48, 48, 48, 48, 48 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 28, 36, 56, 56, 56, 56, 56, 56 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 48, 60, 60, 60, 60, 60, 60, 60 } },
|
||||||
|
|
||||||
|
{ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 20, 32, 40, 48, 48, 48, 48 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 24, 36, 44, 56, 56, 56, 56 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 44, 60, 60, 60, 60, 60, 60 } }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adjust the frame size to make the average bit rate match the target bit rate.
|
* Adjust the frame size to make the average bit rate match the target bit rate.
|
||||||
* This is only needed for 11025, 22050, and 44100 sample rates.
|
* This is only needed for 11025, 22050, and 44100 sample rates.
|
||||||
@ -2095,9 +2125,7 @@ static av_cold void set_bandwidth(AC3EncodeContext *s)
|
|||||||
bw_code = av_clip((fbw_coeffs - 73) / 3, 0, 60);
|
bw_code = av_clip((fbw_coeffs - 73) / 3, 0, 60);
|
||||||
} else {
|
} else {
|
||||||
/* use default bandwidth setting */
|
/* use default bandwidth setting */
|
||||||
/* XXX: should compute the bandwidth according to the frame
|
bw_code = ac3_bandwidth_tab[s->fbw_channels-1][s->bit_alloc.sr_code][s->frame_size_code/2];
|
||||||
size, so that we avoid annoying high frequency artifacts */
|
|
||||||
bw_code = 50;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set number of coefficients for each channel */
|
/* set number of coefficients for each channel */
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
408f47ee5a60866fc751f7bc2314cbd6 *./tests/data/acodec/ac3.rm
|
5ddb6d25dd117db29627f9d286153a7a *./tests/data/acodec/ac3.rm
|
||||||
98751 ./tests/data/acodec/ac3.rm
|
98751 ./tests/data/acodec/ac3.rm
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
da74fe749c2eb21bbead7de81d2f3078 *./tests/data/lavf/lavf.rm
|
a1c71456f21d5459d2824d75bbdcc80c *./tests/data/lavf/lavf.rm
|
||||||
346706 ./tests/data/lavf/lavf.rm
|
346706 ./tests/data/lavf/lavf.rm
|
||||||
|
@ -5,7 +5,8 @@ ret:-1 st:-1 flags:1 ts: 1.894167
|
|||||||
ret:-1 st: 0 flags:0 ts: 0.788000
|
ret:-1 st: 0 flags:0 ts: 0.788000
|
||||||
ret: 0 st: 0 flags:1 ts:-0.317000
|
ret: 0 st: 0 flags:1 ts:-0.317000
|
||||||
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
|
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
|
||||||
ret:-1 st:-1 flags:0 ts: 2.576668
|
ret: 0 st:-1 flags:0 ts: 2.576668
|
||||||
|
ret: 0 st: 0 flags:1 dts: 2.577000 pts: 2.577000 pos: 42397 size: 558
|
||||||
ret:-1 st:-1 flags:1 ts: 1.470835
|
ret:-1 st:-1 flags:1 ts: 1.470835
|
||||||
ret:-1 st: 0 flags:0 ts: 0.365000
|
ret:-1 st: 0 flags:0 ts: 0.365000
|
||||||
ret: 0 st: 0 flags:1 ts:-0.741000
|
ret: 0 st: 0 flags:1 ts:-0.741000
|
||||||
@ -19,7 +20,8 @@ ret:-1 st:-1 flags:0 ts: 1.730004
|
|||||||
ret:-1 st:-1 flags:1 ts: 0.624171
|
ret:-1 st:-1 flags:1 ts: 0.624171
|
||||||
ret: 0 st: 0 flags:0 ts:-0.482000
|
ret: 0 st: 0 flags:0 ts:-0.482000
|
||||||
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
|
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
|
||||||
ret:-1 st: 0 flags:1 ts: 2.413000
|
ret: 0 st: 0 flags:1 ts: 2.413000
|
||||||
|
ret: 0 st: 0 flags:1 dts: 2.368000 pts: 2.368000 pos: 38981 size: 558
|
||||||
ret:-1 st:-1 flags:0 ts: 1.306672
|
ret:-1 st:-1 flags:0 ts: 1.306672
|
||||||
ret:-1 st:-1 flags:1 ts: 0.200839
|
ret:-1 st:-1 flags:1 ts: 0.200839
|
||||||
ret: 0 st: 0 flags:0 ts:-0.905000
|
ret: 0 st: 0 flags:0 ts:-0.905000
|
||||||
@ -28,7 +30,8 @@ ret:-1 st: 0 flags:1 ts: 1.989000
|
|||||||
ret:-1 st:-1 flags:0 ts: 0.883340
|
ret:-1 st:-1 flags:0 ts: 0.883340
|
||||||
ret: 0 st:-1 flags:1 ts:-0.222493
|
ret: 0 st:-1 flags:1 ts:-0.222493
|
||||||
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
|
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 271 size: 556
|
||||||
ret:-1 st: 0 flags:0 ts: 2.672000
|
ret: 0 st: 0 flags:0 ts: 2.672000
|
||||||
|
ret: 0 st: 0 flags:1 dts: 2.821000 pts: 2.821000 pos: 46383 size: 556
|
||||||
ret:-1 st: 0 flags:1 ts: 1.566000
|
ret:-1 st: 0 flags:1 ts: 1.566000
|
||||||
ret:-1 st:-1 flags:0 ts: 0.460008
|
ret:-1 st:-1 flags:0 ts: 0.460008
|
||||||
ret: 0 st:-1 flags:1 ts:-0.645825
|
ret: 0 st:-1 flags:1 ts:-0.645825
|
||||||
|
Loading…
Reference in New Issue
Block a user