mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-12 10:00:08 +01:00
avcodec/ac3{dec,enc}: Deduplicate gain levels table
(I don't know why the encoder only uses eight of the nine values.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -61,18 +61,6 @@ static float dynamic_range_tab[256];
|
|||||||
float ff_ac3_heavy_dynamic_range_tab[256];
|
float ff_ac3_heavy_dynamic_range_tab[256];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Adjustments in dB gain */
|
|
||||||
static const float gain_levels[9] = {
|
|
||||||
LEVEL_PLUS_3DB,
|
|
||||||
LEVEL_PLUS_1POINT5DB,
|
|
||||||
LEVEL_ONE,
|
|
||||||
LEVEL_MINUS_1POINT5DB,
|
|
||||||
LEVEL_MINUS_3DB,
|
|
||||||
LEVEL_MINUS_4POINT5DB,
|
|
||||||
LEVEL_MINUS_6DB,
|
|
||||||
LEVEL_ZERO,
|
|
||||||
LEVEL_MINUS_9DB
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Adjustments in dB gain (LFE, +10 to -21 dB) */
|
/** Adjustments in dB gain (LFE, +10 to -21 dB) */
|
||||||
static const float gain_levels_lfe[32] = {
|
static const float gain_levels_lfe[32] = {
|
||||||
@@ -346,8 +334,8 @@ static int parse_frame_header(AC3DecodeContext *s)
|
|||||||
static int set_downmix_coeffs(AC3DecodeContext *s)
|
static int set_downmix_coeffs(AC3DecodeContext *s)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
float cmix = gain_levels[s-> center_mix_level];
|
float cmix = ff_ac3_gain_levels[s-> center_mix_level];
|
||||||
float smix = gain_levels[s->surround_mix_level];
|
float smix = ff_ac3_gain_levels[s->surround_mix_level];
|
||||||
float norm0, norm1;
|
float norm0, norm1;
|
||||||
float downmix_coeffs[2][AC3_MAX_CHANNELS];
|
float downmix_coeffs[2][AC3_MAX_CHANNELS];
|
||||||
|
|
||||||
@@ -360,8 +348,8 @@ static int set_downmix_coeffs(AC3DecodeContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < s->fbw_channels; i++) {
|
for (i = 0; i < s->fbw_channels; i++) {
|
||||||
downmix_coeffs[0][i] = gain_levels[ac3_default_coeffs[s->channel_mode][i][0]];
|
downmix_coeffs[0][i] = ff_ac3_gain_levels[ac3_default_coeffs[s->channel_mode][i][0]];
|
||||||
downmix_coeffs[1][i] = gain_levels[ac3_default_coeffs[s->channel_mode][i][1]];
|
downmix_coeffs[1][i] = ff_ac3_gain_levels[ac3_default_coeffs[s->channel_mode][i][1]];
|
||||||
}
|
}
|
||||||
if (s->channel_mode > 1 && s->channel_mode & 1) {
|
if (s->channel_mode > 1 && s->channel_mode & 1) {
|
||||||
downmix_coeffs[0][1] = downmix_coeffs[1][1] = cmix;
|
downmix_coeffs[0][1] = downmix_coeffs[1][1] = cmix;
|
||||||
@@ -1562,10 +1550,10 @@ dependent_frame:
|
|||||||
s->output_mode = AC3_CHMODE_STEREO;
|
s->output_mode = AC3_CHMODE_STEREO;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->loro_center_mix_level = gain_levels[s-> center_mix_level];
|
s->loro_center_mix_level = ff_ac3_gain_levels[s-> center_mix_level];
|
||||||
s->loro_surround_mix_level = gain_levels[s->surround_mix_level];
|
s->loro_surround_mix_level = ff_ac3_gain_levels[s->surround_mix_level];
|
||||||
s->ltrt_center_mix_level = gain_levels[s-> center_mix_level_ltrt];
|
s->ltrt_center_mix_level = ff_ac3_gain_levels[s-> center_mix_level_ltrt];
|
||||||
s->ltrt_surround_mix_level = gain_levels[s->surround_mix_level_ltrt];
|
s->ltrt_surround_mix_level = ff_ac3_gain_levels[s->surround_mix_level_ltrt];
|
||||||
switch (s->preferred_downmix) {
|
switch (s->preferred_downmix) {
|
||||||
case AC3_DMIXMOD_LTRT:
|
case AC3_DMIXMOD_LTRT:
|
||||||
s->preferred_stereo_downmix = AV_DOWNMIX_TYPE_LTRT;
|
s->preferred_stereo_downmix = AV_DOWNMIX_TYPE_LTRT;
|
||||||
@@ -1804,10 +1792,10 @@ skip:
|
|||||||
downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_UNKNOWN;
|
downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
downmix_info->center_mix_level = gain_levels[s-> center_mix_level];
|
downmix_info->center_mix_level = ff_ac3_gain_levels[s-> center_mix_level];
|
||||||
downmix_info->center_mix_level_ltrt = gain_levels[s-> center_mix_level_ltrt];
|
downmix_info->center_mix_level_ltrt = ff_ac3_gain_levels[s-> center_mix_level_ltrt];
|
||||||
downmix_info->surround_mix_level = gain_levels[s-> surround_mix_level];
|
downmix_info->surround_mix_level = ff_ac3_gain_levels[s-> surround_mix_level];
|
||||||
downmix_info->surround_mix_level_ltrt = gain_levels[s->surround_mix_level_ltrt];
|
downmix_info->surround_mix_level_ltrt = ff_ac3_gain_levels[s->surround_mix_level_ltrt];
|
||||||
if (s->lfe_mix_level_exists)
|
if (s->lfe_mix_level_exists)
|
||||||
downmix_info->lfe_mix_level = gain_levels_lfe[s->lfe_mix_level];
|
downmix_info->lfe_mix_level = gain_levels_lfe[s->lfe_mix_level];
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -71,10 +71,7 @@ static const float surmixlev_options[SURMIXLEV_NUM_OPTIONS] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define EXTMIXLEV_NUM_OPTIONS 8
|
#define EXTMIXLEV_NUM_OPTIONS 8
|
||||||
static const float extmixlev_options[EXTMIXLEV_NUM_OPTIONS] = {
|
#define extmixlev_options ff_ac3_gain_levels
|
||||||
LEVEL_PLUS_3DB, LEVEL_PLUS_1POINT5DB, LEVEL_ONE, LEVEL_MINUS_1POINT5DB,
|
|
||||||
LEVEL_MINUS_3DB, LEVEL_MINUS_4POINT5DB, LEVEL_MINUS_6DB, LEVEL_ZERO
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The first two options apply only to the AC-3 encoders;
|
/* The first two options apply only to the AC-3 encoders;
|
||||||
* the rest is also valid for EAC-3. When modifying it,
|
* the rest is also valid for EAC-3. When modifying it,
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libavutil/channel_layout.h"
|
#include "libavutil/channel_layout.h"
|
||||||
|
#include "libavutil/mathematics.h"
|
||||||
|
|
||||||
#include "ac3tab.h"
|
#include "ac3tab.h"
|
||||||
|
|
||||||
@@ -147,6 +148,19 @@ const uint16_t ff_ac3_fast_gain_tab[8]= {
|
|||||||
0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400,
|
0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Adjustments in dB gain */
|
||||||
|
const float ff_ac3_gain_levels[9] = {
|
||||||
|
LEVEL_PLUS_3DB,
|
||||||
|
LEVEL_PLUS_1POINT5DB,
|
||||||
|
LEVEL_ONE,
|
||||||
|
LEVEL_MINUS_1POINT5DB,
|
||||||
|
LEVEL_MINUS_3DB,
|
||||||
|
LEVEL_MINUS_4POINT5DB,
|
||||||
|
LEVEL_MINUS_6DB,
|
||||||
|
LEVEL_ZERO,
|
||||||
|
LEVEL_MINUS_9DB
|
||||||
|
};
|
||||||
|
|
||||||
const uint64_t ff_eac3_custom_channel_map_locations[16][2] = {
|
const uint64_t ff_eac3_custom_channel_map_locations[16][2] = {
|
||||||
{ 1, AV_CH_FRONT_LEFT },
|
{ 1, AV_CH_FRONT_LEFT },
|
||||||
{ 1, AV_CH_FRONT_CENTER },
|
{ 1, AV_CH_FRONT_CENTER },
|
||||||
|
|||||||
@@ -26,6 +26,9 @@
|
|||||||
|
|
||||||
#include "ac3defs.h"
|
#include "ac3defs.h"
|
||||||
|
|
||||||
|
#include "libavutil/attributes_internal.h"
|
||||||
|
|
||||||
|
FF_VISIBILITY_PUSH_HIDDEN
|
||||||
extern const uint16_t ff_ac3_frame_size_tab[38][3];
|
extern const uint16_t ff_ac3_frame_size_tab[38][3];
|
||||||
extern const uint8_t ff_ac3_channels_tab[8];
|
extern const uint8_t ff_ac3_channels_tab[8];
|
||||||
extern const uint16_t ff_ac3_channel_layout_tab[8];
|
extern const uint16_t ff_ac3_channel_layout_tab[8];
|
||||||
@@ -43,7 +46,9 @@ extern const int16_t ff_ac3_floor_tab[8];
|
|||||||
extern const uint16_t ff_ac3_fast_gain_tab[8];
|
extern const uint16_t ff_ac3_fast_gain_tab[8];
|
||||||
extern const uint8_t ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1];
|
extern const uint8_t ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1];
|
||||||
extern const uint8_t ff_ac3_bin_to_band_tab[253];
|
extern const uint8_t ff_ac3_bin_to_band_tab[253];
|
||||||
|
extern const float ff_ac3_gain_levels[9];
|
||||||
extern const uint64_t ff_eac3_custom_channel_map_locations[16][2];
|
extern const uint64_t ff_eac3_custom_channel_map_locations[16][2];
|
||||||
|
FF_VISIBILITY_POP_HIDDEN
|
||||||
|
|
||||||
#define COMMON_CHANNEL_MAP \
|
#define COMMON_CHANNEL_MAP \
|
||||||
{ { 0, 1, }, { 0, 1, 2, } },\
|
{ { 0, 1, }, { 0, 1, 2, } },\
|
||||||
|
|||||||
Reference in New Issue
Block a user