[FFmpeg-devel] [PATCH 1/3] avcodec/aacsbr: Split the env_facs table
Michael Niedermayer
michaelni at gmx.at
Thu Nov 19 14:17:50 CET 2015
From: Michael Niedermayer <michael at niedermayer.cc>
This also removes a #ifdef and special case for the fixed point case
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
libavcodec/aacsbr.c | 6 +++---
libavcodec/aacsbr_fixed.c | 6 +++---
libavcodec/aacsbr_template.c | 42 ++++++++----------------------------------
3 files changed, 14 insertions(+), 40 deletions(-)
diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c
index f7c9b22..d1e3a91 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 6ec39c1..7194b03 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
@@ -210,7 +210,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 7772b68..748877d 100644
--- a/libavcodec/aacsbr_template.c
+++ b/libavcodec/aacsbr_template.c
@@ -831,59 +831,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,
--
1.7.9.5
More information about the ffmpeg-devel
mailing list