Commit ed1d1129 authored by Alex Converse's avatar Alex Converse

aacsbr: Fail early on illegal envelope counts.

Originally committed as revision 22381 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 8a9ee4b1
...@@ -628,6 +628,13 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, ...@@ -628,6 +628,13 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr,
if (ch_data->bs_num_env[1] == 1) if (ch_data->bs_num_env[1] == 1)
ch_data->bs_amp_res = 0; ch_data->bs_amp_res = 0;
if (ch_data->bs_num_env[1] > 4) {
av_log(ac->avccontext, AV_LOG_ERROR,
"Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n",
ch_data->bs_num_env[1]);
return -1;
}
ch_data->bs_pointer = 0; ch_data->bs_pointer = 0;
ch_data->bs_freq_res[1] = get_bits1(gb); ch_data->bs_freq_res[1] = get_bits1(gb);
...@@ -666,6 +673,13 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, ...@@ -666,6 +673,13 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr,
ch_data->bs_num_rel[1] = get_bits(gb, 2); ch_data->bs_num_rel[1] = get_bits(gb, 2);
ch_data->bs_num_env[1] = ch_data->bs_num_rel[0] + ch_data->bs_num_rel[1] + 1; ch_data->bs_num_env[1] = ch_data->bs_num_rel[0] + ch_data->bs_num_rel[1] + 1;
if (ch_data->bs_num_env[1] > 5) {
av_log(ac->avccontext, AV_LOG_ERROR,
"Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n",
ch_data->bs_num_env[1]);
return -1;
}
for (i = 0; i < ch_data->bs_num_rel[0]; i++) for (i = 0; i < ch_data->bs_num_rel[0]; i++)
ch_data->bs_rel_bord[0][i] = 2 * get_bits(gb, 2) + 2; ch_data->bs_rel_bord[0][i] = 2 * get_bits(gb, 2) + 2;
for (i = 0; i < ch_data->bs_num_rel[1]; i++) for (i = 0; i < ch_data->bs_num_rel[1]; i++)
...@@ -683,18 +697,6 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr, ...@@ -683,18 +697,6 @@ static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr,
ch_data->bs_pointer); ch_data->bs_pointer);
return -1; return -1;
} }
if (ch_data->bs_frame_class == FIXFIX && ch_data->bs_num_env[1] > 4) {
av_log(ac->avccontext, AV_LOG_ERROR,
"Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n",
ch_data->bs_num_env[1]);
return -1;
}
if (ch_data->bs_frame_class == VARVAR && ch_data->bs_num_env[1] > 5) {
av_log(ac->avccontext, AV_LOG_ERROR,
"Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n",
ch_data->bs_num_env[1]);
return -1;
}
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) + 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment