diff options
Diffstat (limited to 'libavcodec/vorbis.c')
-rw-r--r-- | libavcodec/vorbis.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c index 2c54320..cca2aa7 100644 --- a/libavcodec/vorbis.c +++ b/libavcodec/vorbis.c @@ -1,18 +1,22 @@ -/* - * This file is part of Libav. +/** + * @file + * Common code for Vorbis I encoder and decoder + * @author Denes Balatoni ( dbalatoni programozo hu ) * - * Libav is free software; you can redistribute it and/or + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -54,22 +58,27 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num) uint32_t exit_at_level[33] = { 404 }; unsigned i, j, p, code; - for (p = 0; (bits[p] == 0) && (p < num); ++p) + for (p = 0; (p < num) && (bits[p] == 0); ++p) ; if (p == num) return 0; codes[p] = 0; if (bits[p] > 32) - return 1; + return AVERROR_INVALIDDATA; for (i = 0; i < bits[p]; ++i) - exit_at_level[i+1] = 1 << i; + exit_at_level[i+1] = 1u << i; ++p; + for (i = p; (i < num) && (bits[i] == 0); ++i) + ; + if (i == num) + return 0; + for (; p < num; ++p) { if (bits[p] > 32) - return 1; + return AVERROR_INVALIDDATA; if (bits[p] == 0) continue; // find corresponding exit(node which the tree can grow further from) @@ -77,19 +86,19 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num) if (exit_at_level[i]) break; if (!i) // overspecified tree - return 1; + return AVERROR_INVALIDDATA; code = exit_at_level[i]; exit_at_level[i] = 0; // construct code (append 0s to end) and introduce new exits for (j = i + 1 ;j <= bits[p]; ++j) - exit_at_level[j] = code + (1 << (j - 1)); + exit_at_level[j] = code + (1u << (j - 1)); codes[p] = code; } //no exits should be left (underspecified tree - ie. unused valid vlcs - not allowed by SPEC) for (p = 1; p < 33; p++) if (exit_at_level[p]) - return 1; + return AVERROR_INVALIDDATA; return 0; } |