diff options
Diffstat (limited to 'libavcodec/flac.c')
-rw-r--r-- | libavcodec/flac.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/libavcodec/flac.c b/libavcodec/flac.c index 3e51fdeb98..5ffbf93190 100644 --- a/libavcodec/flac.c +++ b/libavcodec/flac.c @@ -2,20 +2,20 @@ * FLAC common code * Copyright (c) 2009 Justin Ruggles * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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 */ @@ -201,7 +201,7 @@ void ff_flac_set_channel_layout(AVCodecContext *avctx) avctx->channel_layout = 0; } -void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, +int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, const uint8_t *buffer) { GetBitContext gb; @@ -213,6 +213,7 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, av_log(avctx, AV_LOG_WARNING, "invalid max blocksize: %d\n", s->max_blocksize); s->max_blocksize = 16; + return AVERROR_INVALIDDATA; } skip_bits(&gb, 24); /* skip min frame size */ @@ -222,6 +223,12 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, s->channels = get_bits(&gb, 3) + 1; s->bps = get_bits(&gb, 5) + 1; + if (s->bps < 4) { + av_log(avctx, AV_LOG_ERROR, "invalid bps: %d\n", s->bps); + s->bps = 16; + return AVERROR_INVALIDDATA; + } + avctx->channels = s->channels; avctx->sample_rate = s->samplerate; avctx->bits_per_raw_sample = s->bps; @@ -230,24 +237,10 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) ff_flac_set_channel_layout(avctx); - s->samples = get_bits_long(&gb, 32) << 4; - s->samples |= get_bits(&gb, 4); + s->samples = get_bits64(&gb, 36); skip_bits_long(&gb, 64); /* md5 sum */ skip_bits_long(&gb, 64); /* md5 sum */ -} -#if LIBAVCODEC_VERSION_MAJOR < 57 -void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, - const uint8_t *buffer) -{ - ff_flac_parse_streaminfo(avctx, s, buffer); -} - -int avpriv_flac_is_extradata_valid(AVCodecContext *avctx, - enum FLACExtradataFormat *format, - uint8_t **streaminfo_start) -{ - return ff_flac_is_extradata_valid(avctx, format, streaminfo_start); + return 0; } -#endif |