aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-11-19 13:53:58 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2015-12-12 12:19:07 +0100
commitb78885a3c5bcc531ef3410b2d7592a9b08392505 (patch)
treece12ef1638ef1e4c7e03354140fec6f9aac33e65
parentb4f1636a4d7787eccf022ce2433cd9ce53e407cc (diff)
downloadffmpeg-b78885a3c5bcc531ef3410b2d7592a9b08392505.tar.gz
avcodec/aacsbr: Split the env_facs table
This also removes a #ifdef and special case for the fixed point case Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/aacsbr.c6
-rw-r--r--libavcodec/aacsbr_fixed.c6
-rw-r--r--libavcodec/aacsbr_template.c42
3 files changed, 14 insertions, 40 deletions
diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c
index f7c9b22d7f..d1e3a91e96 100644
--- a/libavcodec/aacsbr.c
+++ b/libavcodec/aacsbr.c
@@ -79,8 +79,8 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
float pan_offset = sbr->data[0].bs_amp_res ? 12.0f : 24.0f;
for (e = 1; e <= sbr->data[0].bs_num_env; e++) {
for (k = 0; k < sbr->n[sbr->data[0].bs_freq_res[e]]; k++) {
- float temp1 = exp2f(sbr->data[0].env_facs[e][k] * alpha + 7.0f);
- float temp2 = exp2f((pan_offset - sbr->data[1].env_facs[e][k]) * alpha);
+ float temp1 = exp2f(sbr->data[0].env_facs_q[e][k] * alpha + 7.0f);
+ float temp2 = exp2f((pan_offset - sbr->data[1].env_facs_q[e][k]) * alpha);
float fac;
if (temp1 > 1E20) {
av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n");
@@ -108,7 +108,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
for (e = 1; e <= sbr->data[ch].bs_num_env; e++)
for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++){
sbr->data[ch].env_facs[e][k] =
- exp2f(alpha * sbr->data[ch].env_facs[e][k] + 6.0f);
+ exp2f(alpha * sbr->data[ch].env_facs_q[e][k] + 6.0f);
if (sbr->data[ch].env_facs[e][k] > 1E20) {
av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n");
sbr->data[ch].env_facs[e][k] = 1;
diff --git a/libavcodec/aacsbr_fixed.c b/libavcodec/aacsbr_fixed.c
index 2473de4ec5..b26314a7eb 100644
--- a/libavcodec/aacsbr_fixed.c
+++ b/libavcodec/aacsbr_fixed.c
@@ -163,7 +163,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
for (k = 0; k < sbr->n[sbr->data[0].bs_freq_res[e]]; k++) {
SoftFloat temp1, temp2, fac;
- temp1.exp = sbr->data[0].env_facs[e][k].mant * alpha + 14;
+ temp1.exp = sbr->data[0].env_facs_q[e][k] * alpha + 14;
if (temp1.exp & 1)
temp1.mant = 759250125;
else
@@ -174,7 +174,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
temp1 = FLOAT_1;
}
- temp2.exp = (pan_offset - sbr->data[1].env_facs[e][k].mant) * alpha;
+ temp2.exp = (pan_offset - sbr->data[1].env_facs_q[e][k]) * alpha;
if (temp2.exp & 1)
temp2.mant = 759250125;
else
@@ -207,7 +207,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++){
SoftFloat temp1;
- temp1.exp = alpha * sbr->data[ch].env_facs[e][k].mant + 12;
+ temp1.exp = alpha * sbr->data[ch].env_facs_q[e][k] + 12;
if (temp1.exp & 1)
temp1.mant = 759250125;
else
diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c
index 72bec5ca4b..dd3c7496ff 100644
--- a/libavcodec/aacsbr_template.c
+++ b/libavcodec/aacsbr_template.c
@@ -833,59 +833,33 @@ static void read_sbr_envelope(SpectralBandReplication *sbr, GetBitContext *gb,
}
}
-#if USE_FIXED
for (i = 0; i < ch_data->bs_num_env; i++) {
if (ch_data->bs_df_env[i]) {
// bs_freq_res[0] == bs_freq_res[bs_num_env] from prev frame
if (ch_data->bs_freq_res[i + 1] == ch_data->bs_freq_res[i]) {
for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++)
- ch_data->env_facs[i + 1][j].mant = ch_data->env_facs[i][j].mant + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
+ ch_data->env_facs_q[i + 1][j] = ch_data->env_facs_q[i][j] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
} else if (ch_data->bs_freq_res[i + 1]) {
for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) {
k = (j + odd) >> 1; // find k such that f_tablelow[k] <= f_tablehigh[j] < f_tablelow[k + 1]
- ch_data->env_facs[i + 1][j].mant = ch_data->env_facs[i][k].mant + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
+ ch_data->env_facs_q[i + 1][j] = ch_data->env_facs_q[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
}
} else {
for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) {
k = j ? 2*j - odd : 0; // find k such that f_tablehigh[k] == f_tablelow[j]
- ch_data->env_facs[i + 1][j].mant = ch_data->env_facs[i][k].mant + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
+ ch_data->env_facs_q[i + 1][j] = ch_data->env_facs_q[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
}
}
} else {
- ch_data->env_facs[i + 1][0].mant = delta * get_bits(gb, bits); // bs_env_start_value_balance
+ ch_data->env_facs_q[i + 1][0] = delta * get_bits(gb, bits); // bs_env_start_value_balance
for (j = 1; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++)
- ch_data->env_facs[i + 1][j].mant = ch_data->env_facs[i + 1][j - 1].mant + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav);
+ ch_data->env_facs_q[i + 1][j] = ch_data->env_facs_q[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav);
}
}
-#else
- for (i = 0; i < ch_data->bs_num_env; i++) {
- if (ch_data->bs_df_env[i]) {
- // bs_freq_res[0] == bs_freq_res[bs_num_env] from prev frame
- if (ch_data->bs_freq_res[i + 1] == ch_data->bs_freq_res[i]) {
- for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++)
- ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
- } else if (ch_data->bs_freq_res[i + 1]) {
- for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) {
- k = (j + odd) >> 1; // find k such that f_tablelow[k] <= f_tablehigh[j] < f_tablelow[k + 1]
- ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
- }
- } else {
- for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) {
- k = j ? 2*j - odd : 0; // find k such that f_tablehigh[k] == f_tablelow[j]
- ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
- }
- }
- } else {
- ch_data->env_facs[i + 1][0] = delta * get_bits(gb, bits); // bs_env_start_value_balance
- for (j = 1; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++)
- ch_data->env_facs[i + 1][j] = ch_data->env_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav);
- }
- }
-#endif /* USE_FIXED */
- //assign 0th elements of env_facs from last elements
- memcpy(ch_data->env_facs[0], ch_data->env_facs[ch_data->bs_num_env],
- sizeof(ch_data->env_facs[0]));
+ //assign 0th elements of env_facs_q from last elements
+ memcpy(ch_data->env_facs_q[0], ch_data->env_facs_q[ch_data->bs_num_env],
+ sizeof(ch_data->env_facs_q[0]));
}
static int read_sbr_noise(AACContext *ac, SpectralBandReplication *sbr, GetBitContext *gb,