diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-03-09 00:27:34 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-03-09 00:27:53 +0100 |
commit | d208977cd1c47ddc0281186a6f0521b4b4bd6c1a (patch) | |
tree | 65348fa18e4a9c70791ab3c508f9a918d5d4fb17 | |
parent | 0abd926d64a75c78e89bfc40c5398bcf45b6824b (diff) | |
parent | 7136a0bf88f31bb8d40a3bbd251963706fb14578 (diff) | |
download | ffmpeg-d208977cd1c47ddc0281186a6f0521b4b4bd6c1a.tar.gz |
Merge commit '7136a0bf88f31bb8d40a3bbd251963706fb14578' into release/2.4
* commit '7136a0bf88f31bb8d40a3bbd251963706fb14578':
vorbis: Check the vlc value in setup_classifs
Conflicts:
libavcodec/vorbisdec.c
See: ae038c0914460646503be083e30e3971093239a1
See: 709cae2bcbc0ea2c5d46c932b3d8301cf8f98e6b
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/vorbisdec.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 354ab0e466..984b658253 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1321,7 +1321,7 @@ static av_always_inline int setup_classifs(vorbis_context *vc, int p, j, i; unsigned c_p_c = vc->codebooks[vr->classbook].dimensions; unsigned inverse_class = ff_inverse[vr->classifications]; - unsigned temp, temp2; + int temp, temp2; for (p = 0, j = 0; j < ch_used; ++j) { if (!do_not_decode[j]) { temp = get_vlc2(&vc->gb, vc->codebooks[vr->classbook].vlc.table, @@ -1329,27 +1329,22 @@ static av_always_inline int setup_classifs(vorbis_context *vc, av_dlog(NULL, "Classword: %u\n", temp); - if ((int)temp < 0) - return temp; + av_assert0(temp < 65536); - av_assert0(vr->classifications > 1); //needed for inverse[] + if (temp < 0) { + av_log(vc->avctx, AV_LOG_ERROR, + "Invalid vlc code decoding %d channel.", j); + return AVERROR_INVALIDDATA; + } - if (temp <= 65536) { - for (i = partition_count + c_p_c - 1; i >= partition_count; i--) { - temp2 = (((uint64_t)temp) * inverse_class) >> 32; + av_assert0(vr->classifications > 1); //needed for inverse[] - if (i < ptns_to_read) - vr->classifs[p + i] = temp - temp2 * vr->classifications; - temp = temp2; - } - } else { - for (i = partition_count + c_p_c - 1; i >= partition_count; i--) { - temp2 = temp / vr->classifications; + for (i = partition_count + c_p_c - 1; i >= partition_count; i--) { + temp2 = (((uint64_t)temp) * inverse_class) >> 32; - if (i < ptns_to_read) - vr->classifs[p + i] = temp - temp2 * vr->classifications; - temp = temp2; - } + if (i < ptns_to_read) + vr->classifs[p + i] = temp - temp2 * vr->classifications; + temp = temp2; } } p += ptns_to_read; @@ -1405,8 +1400,8 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, voffset = vr->begin; for (partition_count = 0; partition_count < ptns_to_read;) { // SPEC error if (!pass) { - int ret; - if ((ret = setup_classifs(vc, vr, do_not_decode, ch_used, partition_count, ptns_to_read)) < 0) + int ret = setup_classifs(vc, vr, do_not_decode, ch_used, partition_count, ptns_to_read); + if (ret < 0) return ret; } for (i = 0; (i < c_p_c) && (partition_count < ptns_to_read); ++i) { |