mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-26 09:12:33 +00:00
aacsbr: Make the previous value of bs_num_env local to read_sbr_data().
Originally committed as revision 22409 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
46751a65e3
commit
ecc1f8c3c8
@ -623,69 +623,69 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr,
|
|||||||
// frameLengthFlag ? 15 : 16; 960 sample length frames unsupported; this value is numTimeSlots
|
// frameLengthFlag ? 15 : 16; 960 sample length frames unsupported; this value is numTimeSlots
|
||||||
int abs_bord_trail = 16;
|
int abs_bord_trail = 16;
|
||||||
int num_rel_lead, num_rel_trail;
|
int num_rel_lead, num_rel_trail;
|
||||||
|
unsigned bs_num_env_old = ch_data->bs_num_env;
|
||||||
uint8_t bs_rel_bord[2][3];
|
uint8_t bs_rel_bord[2][3];
|
||||||
|
|
||||||
ch_data->bs_freq_res[0] = ch_data->bs_freq_res[ch_data->bs_num_env[1]];
|
ch_data->bs_freq_res[0] = ch_data->bs_freq_res[ch_data->bs_num_env];
|
||||||
ch_data->bs_num_env[0] = ch_data->bs_num_env[1];
|
|
||||||
ch_data->bs_amp_res = sbr->bs_amp_res_header;
|
ch_data->bs_amp_res = sbr->bs_amp_res_header;
|
||||||
|
|
||||||
switch (ch_data->bs_frame_class = get_bits(gb, 2)) {
|
switch (ch_data->bs_frame_class = get_bits(gb, 2)) {
|
||||||
case FIXFIX:
|
case FIXFIX:
|
||||||
ch_data->bs_num_env[1] = 1 << get_bits(gb, 2);
|
ch_data->bs_num_env = 1 << get_bits(gb, 2);
|
||||||
num_rel_lead = ch_data->bs_num_env[1] - 1;
|
num_rel_lead = ch_data->bs_num_env - 1;
|
||||||
if (ch_data->bs_num_env[1] == 1)
|
if (ch_data->bs_num_env == 1)
|
||||||
ch_data->bs_amp_res = 0;
|
ch_data->bs_amp_res = 0;
|
||||||
|
|
||||||
if (ch_data->bs_num_env[1] > 4) {
|
if (ch_data->bs_num_env > 4) {
|
||||||
av_log(ac->avccontext, AV_LOG_ERROR,
|
av_log(ac->avccontext, AV_LOG_ERROR,
|
||||||
"Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n",
|
"Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n",
|
||||||
ch_data->bs_num_env[1]);
|
ch_data->bs_num_env);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bs_pointer = 0;
|
bs_pointer = 0;
|
||||||
|
|
||||||
ch_data->bs_freq_res[1] = get_bits1(gb);
|
ch_data->bs_freq_res[1] = get_bits1(gb);
|
||||||
for (i = 1; i < ch_data->bs_num_env[1]; i++)
|
for (i = 1; i < ch_data->bs_num_env; i++)
|
||||||
ch_data->bs_freq_res[i + 1] = ch_data->bs_freq_res[1];
|
ch_data->bs_freq_res[i + 1] = ch_data->bs_freq_res[1];
|
||||||
break;
|
break;
|
||||||
case FIXVAR:
|
case FIXVAR:
|
||||||
abs_bord_trail += get_bits(gb, 2);
|
abs_bord_trail += get_bits(gb, 2);
|
||||||
num_rel_trail = get_bits(gb, 2);
|
num_rel_trail = get_bits(gb, 2);
|
||||||
num_rel_lead = 0;
|
num_rel_lead = 0;
|
||||||
ch_data->bs_num_env[1] = num_rel_trail + 1;
|
ch_data->bs_num_env = num_rel_trail + 1;
|
||||||
|
|
||||||
for (i = 0; i < num_rel_trail; i++)
|
for (i = 0; i < num_rel_trail; i++)
|
||||||
bs_rel_bord[1][i] = 2 * get_bits(gb, 2) + 2;
|
bs_rel_bord[1][i] = 2 * get_bits(gb, 2) + 2;
|
||||||
|
|
||||||
bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env[1]]);
|
bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]);
|
||||||
|
|
||||||
for (i = 0; i < ch_data->bs_num_env[1]; i++)
|
for (i = 0; i < ch_data->bs_num_env; i++)
|
||||||
ch_data->bs_freq_res[ch_data->bs_num_env[1] - i] = get_bits1(gb);
|
ch_data->bs_freq_res[ch_data->bs_num_env - i] = get_bits1(gb);
|
||||||
break;
|
break;
|
||||||
case VARFIX:
|
case VARFIX:
|
||||||
abs_bord_lead = get_bits(gb, 2);
|
abs_bord_lead = get_bits(gb, 2);
|
||||||
num_rel_lead = get_bits(gb, 2);
|
num_rel_lead = get_bits(gb, 2);
|
||||||
ch_data->bs_num_env[1] = num_rel_lead + 1;
|
ch_data->bs_num_env = num_rel_lead + 1;
|
||||||
|
|
||||||
for (i = 0; i < num_rel_lead; i++)
|
for (i = 0; i < num_rel_lead; i++)
|
||||||
bs_rel_bord[0][i] = 2 * get_bits(gb, 2) + 2;
|
bs_rel_bord[0][i] = 2 * get_bits(gb, 2) + 2;
|
||||||
|
|
||||||
bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env[1]]);
|
bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]);
|
||||||
|
|
||||||
get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env[1]);
|
get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env);
|
||||||
break;
|
break;
|
||||||
case VARVAR:
|
case VARVAR:
|
||||||
abs_bord_lead = get_bits(gb, 2);
|
abs_bord_lead = get_bits(gb, 2);
|
||||||
abs_bord_trail += get_bits(gb, 2);
|
abs_bord_trail += get_bits(gb, 2);
|
||||||
num_rel_lead = get_bits(gb, 2);
|
num_rel_lead = get_bits(gb, 2);
|
||||||
num_rel_trail = get_bits(gb, 2);
|
num_rel_trail = get_bits(gb, 2);
|
||||||
ch_data->bs_num_env[1] = num_rel_lead + num_rel_trail + 1;
|
ch_data->bs_num_env = num_rel_lead + num_rel_trail + 1;
|
||||||
|
|
||||||
if (ch_data->bs_num_env[1] > 5) {
|
if (ch_data->bs_num_env > 5) {
|
||||||
av_log(ac->avccontext, AV_LOG_ERROR,
|
av_log(ac->avccontext, AV_LOG_ERROR,
|
||||||
"Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n",
|
"Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n",
|
||||||
ch_data->bs_num_env[1]);
|
ch_data->bs_num_env);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,26 +694,26 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr,
|
|||||||
for (i = 0; i < num_rel_trail; i++)
|
for (i = 0; i < num_rel_trail; i++)
|
||||||
bs_rel_bord[1][i] = 2 * get_bits(gb, 2) + 2;
|
bs_rel_bord[1][i] = 2 * get_bits(gb, 2) + 2;
|
||||||
|
|
||||||
bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env[1]]);
|
bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]);
|
||||||
|
|
||||||
get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env[1]);
|
get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bs_pointer > ch_data->bs_num_env[1] + 1) {
|
if (bs_pointer > ch_data->bs_num_env + 1) {
|
||||||
av_log(ac->avccontext, AV_LOG_ERROR,
|
av_log(ac->avccontext, AV_LOG_ERROR,
|
||||||
"Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n",
|
"Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n",
|
||||||
bs_pointer);
|
bs_pointer);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ch_data->t_env_num_env_old = ch_data->t_env[ch_data->bs_num_env[0]];
|
ch_data->t_env_num_env_old = ch_data->t_env[bs_num_env_old];
|
||||||
ch_data->t_env[0] = abs_bord_lead;
|
ch_data->t_env[0] = abs_bord_lead;
|
||||||
ch_data->t_env[ch_data->bs_num_env[1]] = abs_bord_trail;
|
ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail;
|
||||||
|
|
||||||
if (ch_data->bs_frame_class == FIXFIX) {
|
if (ch_data->bs_frame_class == FIXFIX) {
|
||||||
int temp = (abs_bord_trail + (ch_data->bs_num_env[1] >> 1)) /
|
int temp = (abs_bord_trail + (ch_data->bs_num_env >> 1)) /
|
||||||
ch_data->bs_num_env[1];
|
ch_data->bs_num_env;
|
||||||
for (i = 0; i < num_rel_lead; i++)
|
for (i = 0; i < num_rel_lead; i++)
|
||||||
ch_data->t_env[i + 1] = ch_data->t_env[i] + temp;
|
ch_data->t_env[i + 1] = ch_data->t_env[i] + temp;
|
||||||
} else if (ch_data->bs_frame_class > 1) { // VARFIX or VARVAR
|
} else if (ch_data->bs_frame_class > 1) { // VARFIX or VARVAR
|
||||||
@ -722,37 +722,37 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ch_data->bs_frame_class & 1) { // FIXVAR or VARVAR
|
if (ch_data->bs_frame_class & 1) { // FIXVAR or VARVAR
|
||||||
for (i = ch_data->bs_num_env[1] - 1; i > num_rel_lead; i--)
|
for (i = ch_data->bs_num_env - 1; i > num_rel_lead; i--)
|
||||||
ch_data->t_env[i] = ch_data->t_env[i + 1] -
|
ch_data->t_env[i] = ch_data->t_env[i + 1] -
|
||||||
bs_rel_bord[1][ch_data->bs_num_env[1] - 1 - i];
|
bs_rel_bord[1][ch_data->bs_num_env - 1 - i];
|
||||||
}
|
}
|
||||||
|
|
||||||
ch_data->bs_num_noise = (ch_data->bs_num_env[1] > 1) + 1;
|
ch_data->bs_num_noise = (ch_data->bs_num_env > 1) + 1;
|
||||||
|
|
||||||
ch_data->t_q[0] = ch_data->t_env[0];
|
ch_data->t_q[0] = ch_data->t_env[0];
|
||||||
if (ch_data->bs_num_noise > 1) {
|
if (ch_data->bs_num_noise > 1) {
|
||||||
unsigned int idx;
|
unsigned int idx;
|
||||||
if (ch_data->bs_frame_class == FIXFIX) {
|
if (ch_data->bs_frame_class == FIXFIX) {
|
||||||
idx = ch_data->bs_num_env[1] >> 1;
|
idx = ch_data->bs_num_env >> 1;
|
||||||
} else if (ch_data->bs_frame_class & 1) { // FIXVAR or VARVAR
|
} else if (ch_data->bs_frame_class & 1) { // FIXVAR or VARVAR
|
||||||
idx = ch_data->bs_num_env[1] - FFMAX(bs_pointer - 1, 1);
|
idx = ch_data->bs_num_env - FFMAX(bs_pointer - 1, 1);
|
||||||
} else { // VARFIX
|
} else { // VARFIX
|
||||||
if (!bs_pointer)
|
if (!bs_pointer)
|
||||||
idx = 1;
|
idx = 1;
|
||||||
else if (bs_pointer == 1)
|
else if (bs_pointer == 1)
|
||||||
idx = ch_data->bs_num_env[1] - 1;
|
idx = ch_data->bs_num_env - 1;
|
||||||
else // bs_pointer > 1
|
else // bs_pointer > 1
|
||||||
idx = bs_pointer - 1;
|
idx = bs_pointer - 1;
|
||||||
}
|
}
|
||||||
ch_data->t_q[1] = ch_data->t_env[idx];
|
ch_data->t_q[1] = ch_data->t_env[idx];
|
||||||
ch_data->t_q[2] = ch_data->t_env[ch_data->bs_num_env[1]];
|
ch_data->t_q[2] = ch_data->t_env[ch_data->bs_num_env];
|
||||||
} else
|
} else
|
||||||
ch_data->t_q[1] = ch_data->t_env[ch_data->bs_num_env[1]];
|
ch_data->t_q[1] = ch_data->t_env[ch_data->bs_num_env];
|
||||||
|
|
||||||
ch_data->e_a[0] = -(ch_data->e_a[1] != ch_data->bs_num_env[0]); // l_APrev
|
ch_data->e_a[0] = -(ch_data->e_a[1] != bs_num_env_old); // l_APrev
|
||||||
ch_data->e_a[1] = -1;
|
ch_data->e_a[1] = -1;
|
||||||
if ((ch_data->bs_frame_class & 1) && bs_pointer) { // FIXVAR or VARVAR and bs_pointer != 0
|
if ((ch_data->bs_frame_class & 1) && bs_pointer) { // FIXVAR or VARVAR and bs_pointer != 0
|
||||||
ch_data->e_a[1] = ch_data->bs_num_env[1] + 1 - bs_pointer;
|
ch_data->e_a[1] = ch_data->bs_num_env + 1 - bs_pointer;
|
||||||
} else if ((ch_data->bs_frame_class == 2) && (bs_pointer > 1)) // VARFIX and bs_pointer > 1
|
} else if ((ch_data->bs_frame_class == 2) && (bs_pointer > 1)) // VARFIX and bs_pointer > 1
|
||||||
ch_data->e_a[1] = bs_pointer - 1;
|
ch_data->e_a[1] = bs_pointer - 1;
|
||||||
|
|
||||||
@ -761,16 +761,15 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr,
|
|||||||
|
|
||||||
static void copy_sbr_grid(SBRData *dst, const SBRData *src) {
|
static void copy_sbr_grid(SBRData *dst, const SBRData *src) {
|
||||||
//These variables are saved from the previous frame rather than copied
|
//These variables are saved from the previous frame rather than copied
|
||||||
dst->bs_freq_res[0] = dst->bs_freq_res[dst->bs_num_env[1]];
|
dst->bs_freq_res[0] = dst->bs_freq_res[dst->bs_num_env];
|
||||||
dst->bs_num_env[0] = dst->bs_num_env[1];
|
dst->t_env_num_env_old = dst->t_env[dst->bs_num_env];
|
||||||
dst->t_env_num_env_old = dst->t_env[dst->bs_num_env[0]];
|
dst->e_a[0] = -(dst->e_a[1] != dst->bs_num_env);
|
||||||
dst->e_a[0] = -(dst->e_a[1] != dst->bs_num_env[0]);
|
|
||||||
|
|
||||||
//These variables are read from the bitstream and therefore copied
|
//These variables are read from the bitstream and therefore copied
|
||||||
memcpy(dst->bs_freq_res+1, src->bs_freq_res+1, sizeof(dst->bs_freq_res)-sizeof(*dst->bs_freq_res));
|
memcpy(dst->bs_freq_res+1, src->bs_freq_res+1, sizeof(dst->bs_freq_res)-sizeof(*dst->bs_freq_res));
|
||||||
memcpy(dst->bs_num_env+1, src->bs_num_env+1, sizeof(dst->bs_num_env)- sizeof(*dst->bs_num_env));
|
|
||||||
memcpy(dst->t_env, src->t_env, sizeof(dst->t_env));
|
memcpy(dst->t_env, src->t_env, sizeof(dst->t_env));
|
||||||
memcpy(dst->t_q, src->t_q, sizeof(dst->t_q));
|
memcpy(dst->t_q, src->t_q, sizeof(dst->t_q));
|
||||||
|
dst->bs_num_env = src->bs_num_env;
|
||||||
dst->bs_amp_res = src->bs_amp_res;
|
dst->bs_amp_res = src->bs_amp_res;
|
||||||
dst->bs_num_noise = src->bs_num_noise;
|
dst->bs_num_noise = src->bs_num_noise;
|
||||||
dst->bs_frame_class = src->bs_frame_class;
|
dst->bs_frame_class = src->bs_frame_class;
|
||||||
@ -781,7 +780,7 @@ static void copy_sbr_grid(SBRData *dst, const SBRData *src) {
|
|||||||
static void read_sbr_dtdf(SpectralBandReplication *sbr, GetBitContext *gb,
|
static void read_sbr_dtdf(SpectralBandReplication *sbr, GetBitContext *gb,
|
||||||
SBRData *ch_data)
|
SBRData *ch_data)
|
||||||
{
|
{
|
||||||
get_bits1_vector(gb, ch_data->bs_df_env, ch_data->bs_num_env[1]);
|
get_bits1_vector(gb, ch_data->bs_df_env, ch_data->bs_num_env);
|
||||||
get_bits1_vector(gb, ch_data->bs_df_noise, ch_data->bs_num_noise);
|
get_bits1_vector(gb, ch_data->bs_df_noise, ch_data->bs_num_noise);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,9 +835,9 @@ static void read_sbr_envelope(SpectralBandReplication *sbr, GetBitContext *gb,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ch_data->bs_num_env[1]; i++) {
|
for (i = 0; i < ch_data->bs_num_env; i++) {
|
||||||
if (ch_data->bs_df_env[i]) {
|
if (ch_data->bs_df_env[i]) {
|
||||||
// bs_freq_res[0] == bs_freq_res[bs_num_env[1]] from prev frame
|
// 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]) {
|
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++)
|
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);
|
ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
|
||||||
@ -861,7 +860,7 @@ static void read_sbr_envelope(SpectralBandReplication *sbr, GetBitContext *gb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//assign 0th elements of env_facs from last elements
|
//assign 0th elements of env_facs from last elements
|
||||||
memcpy(ch_data->env_facs[0], ch_data->env_facs[ch_data->bs_num_env[1]],
|
memcpy(ch_data->env_facs[0], ch_data->env_facs[ch_data->bs_num_env],
|
||||||
sizeof(ch_data->env_facs[0]));
|
sizeof(ch_data->env_facs[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1096,7 +1095,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
|
|||||||
if (id_aac == TYPE_CPE && sbr->bs_coupling) {
|
if (id_aac == TYPE_CPE && sbr->bs_coupling) {
|
||||||
float alpha = sbr->data[0].bs_amp_res ? 1.0f : 0.5f;
|
float alpha = sbr->data[0].bs_amp_res ? 1.0f : 0.5f;
|
||||||
float pan_offset = sbr->data[0].bs_amp_res ? 12.0f : 24.0f;
|
float pan_offset = sbr->data[0].bs_amp_res ? 12.0f : 24.0f;
|
||||||
for (e = 1; e <= sbr->data[0].bs_num_env[1]; e++) {
|
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++) {
|
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 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 temp2 = exp2f((pan_offset - sbr->data[1].env_facs[e][k]) * alpha);
|
||||||
@ -1117,7 +1116,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
|
|||||||
} else { // SCE or one non-coupled CPE
|
} else { // SCE or one non-coupled CPE
|
||||||
for (ch = 0; ch < (id_aac == TYPE_CPE) + 1; ch++) {
|
for (ch = 0; ch < (id_aac == TYPE_CPE) + 1; ch++) {
|
||||||
float alpha = sbr->data[ch].bs_amp_res ? 1.0f : 0.5f;
|
float alpha = sbr->data[ch].bs_amp_res ? 1.0f : 0.5f;
|
||||||
for (e = 1; e <= sbr->data[ch].bs_num_env[1]; e++)
|
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++)
|
for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++)
|
||||||
sbr->data[ch].env_facs[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[e][k] + 6.0f);
|
||||||
@ -1456,7 +1455,7 @@ static void sbr_mapping(AACContext *ac, SpectralBandReplication *sbr,
|
|||||||
int e, i, m;
|
int e, i, m;
|
||||||
|
|
||||||
memset(ch_data->s_indexmapped[1], 0, 7*sizeof(ch_data->s_indexmapped[1]));
|
memset(ch_data->s_indexmapped[1], 0, 7*sizeof(ch_data->s_indexmapped[1]));
|
||||||
for (e = 0; e < ch_data->bs_num_env[1]; e++) {
|
for (e = 0; e < ch_data->bs_num_env; e++) {
|
||||||
const unsigned int ilim = sbr->n[ch_data->bs_freq_res[e + 1]];
|
const unsigned int ilim = sbr->n[ch_data->bs_freq_res[e + 1]];
|
||||||
uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow;
|
uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow;
|
||||||
int k;
|
int k;
|
||||||
@ -1494,7 +1493,7 @@ static void sbr_mapping(AACContext *ac, SpectralBandReplication *sbr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(ch_data->s_indexmapped[0], ch_data->s_indexmapped[ch_data->bs_num_env[1]], sizeof(ch_data->s_indexmapped[0]));
|
memcpy(ch_data->s_indexmapped[0], ch_data->s_indexmapped[ch_data->bs_num_env], sizeof(ch_data->s_indexmapped[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Estimation of current envelope (14496-3 sp04 p218)
|
/// Estimation of current envelope (14496-3 sp04 p218)
|
||||||
@ -1504,7 +1503,7 @@ static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2],
|
|||||||
int e, i, m;
|
int e, i, m;
|
||||||
|
|
||||||
if (sbr->bs_interpol_freq) {
|
if (sbr->bs_interpol_freq) {
|
||||||
for (e = 0; e < ch_data->bs_num_env[1]; e++) {
|
for (e = 0; e < ch_data->bs_num_env; e++) {
|
||||||
const float recip_env_size = 0.5f / (ch_data->t_env[e + 1] - ch_data->t_env[e]);
|
const float recip_env_size = 0.5f / (ch_data->t_env[e + 1] - ch_data->t_env[e]);
|
||||||
int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;
|
int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;
|
||||||
int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;
|
int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;
|
||||||
@ -1522,7 +1521,7 @@ static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2],
|
|||||||
} else {
|
} else {
|
||||||
int k, p;
|
int k, p;
|
||||||
|
|
||||||
for (e = 0; e < ch_data->bs_num_env[1]; e++) {
|
for (e = 0; e < ch_data->bs_num_env; e++) {
|
||||||
const int env_size = 2 * (ch_data->t_env[e + 1] - ch_data->t_env[e]);
|
const int env_size = 2 * (ch_data->t_env[e + 1] - ch_data->t_env[e]);
|
||||||
int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;
|
int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;
|
||||||
int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;
|
int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;
|
||||||
@ -1558,7 +1557,7 @@ static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr,
|
|||||||
// max gain limits : -3dB, 0dB, 3dB, inf dB (limiter off)
|
// max gain limits : -3dB, 0dB, 3dB, inf dB (limiter off)
|
||||||
static const float limgain[4] = { 0.70795, 1.0, 1.41254, 10000000000 };
|
static const float limgain[4] = { 0.70795, 1.0, 1.41254, 10000000000 };
|
||||||
|
|
||||||
for (e = 0; e < ch_data->bs_num_env[1]; e++) {
|
for (e = 0; e < ch_data->bs_num_env; e++) {
|
||||||
int delta = !((e == e_a[1]) || (e == e_a[0]));
|
int delta = !((e == e_a[1]) || (e == e_a[0]));
|
||||||
for (k = 0; k < sbr->n_lim; k++) {
|
for (k = 0; k < sbr->n_lim; k++) {
|
||||||
float gain_boost, gain_max;
|
float gain_boost, gain_max;
|
||||||
@ -1641,14 +1640,14 @@ static void sbr_hf_assemble(float Y[2][38][64][2], const float X_high[64][40][2]
|
|||||||
memcpy(q_temp[2*ch_data->t_env[0]], q_temp[2*ch_data->t_env_num_env_old], 4*sizeof(q_temp[0]));
|
memcpy(q_temp[2*ch_data->t_env[0]], q_temp[2*ch_data->t_env_num_env_old], 4*sizeof(q_temp[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (e = 0; e < ch_data->bs_num_env[1]; e++) {
|
for (e = 0; e < ch_data->bs_num_env; e++) {
|
||||||
for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
|
for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
|
||||||
memcpy(g_temp[h_SL + i], sbr->gain[e], m_max * sizeof(sbr->gain[0][0]));
|
memcpy(g_temp[h_SL + i], sbr->gain[e], m_max * sizeof(sbr->gain[0][0]));
|
||||||
memcpy(q_temp[h_SL + i], sbr->q_m[e], m_max * sizeof(sbr->q_m[0][0]));
|
memcpy(q_temp[h_SL + i], sbr->q_m[e], m_max * sizeof(sbr->q_m[0][0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (e = 0; e < ch_data->bs_num_env[1]; e++) {
|
for (e = 0; e < ch_data->bs_num_env; e++) {
|
||||||
for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
|
for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
|
||||||
int phi_sign = (1 - 2*(kx & 1));
|
int phi_sign = (1 - 2*(kx & 1));
|
||||||
|
|
||||||
@ -1737,7 +1736,7 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int ch,
|
|||||||
sbr_chirp(sbr, &sbr->data[ch]);
|
sbr_chirp(sbr, &sbr->data[ch]);
|
||||||
sbr_hf_gen(ac, sbr, sbr->X_high, sbr->X_low, sbr->alpha0, sbr->alpha1,
|
sbr_hf_gen(ac, sbr, sbr->X_high, sbr->X_low, sbr->alpha0, sbr->alpha1,
|
||||||
sbr->data[ch].bw_array, sbr->data[ch].t_env,
|
sbr->data[ch].bw_array, sbr->data[ch].t_env,
|
||||||
sbr->data[ch].bs_num_env[1]);
|
sbr->data[ch].bs_num_env);
|
||||||
|
|
||||||
// hf_adj
|
// hf_adj
|
||||||
sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a);
|
sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a);
|
||||||
|
@ -62,7 +62,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
unsigned bs_frame_class;
|
unsigned bs_frame_class;
|
||||||
unsigned bs_add_harmonic_flag;
|
unsigned bs_add_harmonic_flag;
|
||||||
unsigned bs_num_env[2];
|
unsigned bs_num_env;
|
||||||
uint8_t bs_freq_res[7];
|
uint8_t bs_freq_res[7];
|
||||||
unsigned bs_num_noise;
|
unsigned bs_num_noise;
|
||||||
uint8_t bs_df_env[5];
|
uint8_t bs_df_env[5];
|
||||||
|
Loading…
Reference in New Issue
Block a user