mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
ac3enc: add channel coupling support
Channel coupling is an optional AC-3 feature that increases quality by combining high frequency information from multiple channels into a single channel. The per-channel high frequency information is sent with less accuracy in both the frequency and time domains. This allows more bits to be used for lower frequencies while preserving enough information to reconstruct the high frequencies.
This commit is contained in:
parent
a7a187a1be
commit
7f3a7b5c40
@ -365,4 +365,47 @@ is highly recommended that it be left as enabled except for testing purposes.
|
||||
|
||||
@end table
|
||||
|
||||
@subheading Floating-Point-Only AC-3 Encoding Options
|
||||
|
||||
These options are only valid for the floating-point encoder and do not exist
|
||||
for the fixed-point encoder due to the corresponding features not being
|
||||
implemented in fixed-point.
|
||||
|
||||
@table @option
|
||||
|
||||
@item -channel_coupling @var{boolean}
|
||||
Enables/Disables use of channel coupling, which is an optional AC-3 feature
|
||||
that increases quality by combining high frequency information from multiple
|
||||
channels into a single channel. The per-channel high frequency information is
|
||||
sent with less accuracy in both the frequency and time domains. This allows
|
||||
more bits to be used for lower frequencies while preserving enough information
|
||||
to reconstruct the high frequencies. This option is enabled by default for the
|
||||
floating-point encoder and should generally be left as enabled except for
|
||||
testing purposes or to increase encoding speed.
|
||||
@table @option
|
||||
@item -1
|
||||
@itemx auto
|
||||
Selected by Encoder (default)
|
||||
@item 0
|
||||
@itemx off
|
||||
Disable Channel Coupling
|
||||
@item 1
|
||||
@itemx on
|
||||
Enable Channel Coupling
|
||||
@end table
|
||||
|
||||
@item -cpl_start_band @var{number}
|
||||
Coupling Start Band. Sets the channel coupling start band, from 1 to 15. If a
|
||||
value higher than the bandwidth is used, it will be reduced to 1 less than the
|
||||
coupling end band. If @var{auto} is used, the start band will be determined by
|
||||
the encoder based on the bit rate, sample rate, and channel layout. This option
|
||||
has no effect if channel coupling is disabled.
|
||||
@table @option
|
||||
@item -1
|
||||
@itemx auto
|
||||
Selected by Encoder (default)
|
||||
@end table
|
||||
|
||||
@end table
|
||||
|
||||
@c man end ENCODERS
|
||||
|
@ -28,7 +28,8 @@
|
||||
#define AVCODEC_AC3_H
|
||||
|
||||
#define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */
|
||||
#define AC3_MAX_CHANNELS 6 /* including LFE channel */
|
||||
#define AC3_MAX_CHANNELS 7 /**< maximum number of channels, including coupling channel */
|
||||
#define CPL_CH 0 /**< coupling channel index */
|
||||
|
||||
#define AC3_MAX_COEFS 256
|
||||
#define AC3_BLOCK_SIZE 256
|
||||
|
@ -58,11 +58,6 @@
|
||||
#include "fft.h"
|
||||
#include "fmtconvert.h"
|
||||
|
||||
/* override ac3.h to include coupling channel */
|
||||
#undef AC3_MAX_CHANNELS
|
||||
#define AC3_MAX_CHANNELS 7
|
||||
#define CPL_CH 0
|
||||
|
||||
#define AC3_OUTPUT_LFEON 8
|
||||
|
||||
#define SPX_MAX_BANDS 17
|
||||
|
@ -53,12 +53,6 @@ const uint8_t ff_eac3_hebap_tab[64] = {
|
||||
19, 19, 19, 19,
|
||||
};
|
||||
|
||||
/**
|
||||
* Table E2.16 Default Coupling Banding Structure
|
||||
*/
|
||||
const uint8_t ff_eac3_default_cpl_band_struct[18] =
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1 };
|
||||
|
||||
/**
|
||||
* Table E2.15 Default Spectral Extension Banding Structure
|
||||
*/
|
||||
|
@ -27,7 +27,6 @@
|
||||
extern const uint8_t ff_ac3_ungroup_3_in_5_bits_tab[32][3];
|
||||
|
||||
extern const uint8_t ff_eac3_hebap_tab[64];
|
||||
extern const uint8_t ff_eac3_default_cpl_band_struct[18];
|
||||
extern const uint8_t ff_eac3_default_spx_band_struct[17];
|
||||
|
||||
#endif /* AVCODEC_AC3DEC_DATA_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -101,7 +101,7 @@ static void scale_coefficients(AC3EncodeContext *s)
|
||||
|
||||
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
|
||||
AC3Block *block = &s->blocks[blk];
|
||||
for (ch = 0; ch < s->channels; ch++) {
|
||||
for (ch = 1; ch <= s->channels; ch++) {
|
||||
s->ac3dsp.ac3_rshift_int32(block->mdct_coef[ch], AC3_MAX_COEFS,
|
||||
block->coeff_shift[ch]);
|
||||
}
|
||||
|
@ -93,8 +93,10 @@ static int normalize_samples(AC3EncodeContext *s)
|
||||
*/
|
||||
static void scale_coefficients(AC3EncodeContext *s)
|
||||
{
|
||||
s->ac3dsp.float_to_fixed24(s->fixed_coef_buffer, s->mdct_coef_buffer,
|
||||
AC3_MAX_COEFS * AC3_MAX_BLOCKS * s->channels);
|
||||
int chan_size = AC3_MAX_COEFS * AC3_MAX_BLOCKS;
|
||||
s->ac3dsp.float_to_fixed24(s->fixed_coef_buffer + chan_size,
|
||||
s->mdct_coef_buffer + chan_size,
|
||||
chan_size * s->channels);
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,6 +138,13 @@ const uint16_t ff_ac3_bitrate_tab[19] = {
|
||||
*/
|
||||
const uint8_t ff_ac3_rematrix_band_tab[5] = { 13, 25, 37, 61, 253 };
|
||||
|
||||
/**
|
||||
* Table E2.16 Default Coupling Banding Structure
|
||||
*/
|
||||
const uint8_t ff_eac3_default_cpl_band_struct[18] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1
|
||||
};
|
||||
|
||||
/* AC-3 MDCT window */
|
||||
|
||||
/* MDCT window */
|
||||
|
@ -39,6 +39,7 @@ extern const uint8_t ff_ac3_dec_channel_map[8][2][6];
|
||||
extern const uint16_t ff_ac3_sample_rate_tab[3];
|
||||
extern const uint16_t ff_ac3_bitrate_tab[19];
|
||||
extern const uint8_t ff_ac3_rematrix_band_tab[5];
|
||||
extern const uint8_t ff_eac3_default_cpl_band_struct[18];
|
||||
extern const int16_t ff_ac3_window[AC3_WINDOW_SIZE/2];
|
||||
extern const uint8_t ff_ac3_log_add_tab[260];
|
||||
extern const uint16_t ff_ac3_hearing_threshold_tab[AC3_CRITICAL_BANDS][3];
|
||||
|
Loading…
Reference in New Issue
Block a user