X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Foggparseflac.c;h=57bba68079991fbeb476a3344f6549cf8c482e98;hb=a28468d0daf4be14761c16a3ddd33266b2380123;hp=f9c15f9a6d30a64267ee6fa9c590b7ee0a23ce4c;hpb=db68ef898a3802e51b6f41fd600d0d46d058e3f8;p=ffmpeg diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c index f9c15f9a6d3..57bba680799 100644 --- a/libavformat/oggparseflac.c +++ b/libavformat/oggparseflac.c @@ -34,7 +34,6 @@ flac_header (AVFormatContext * s, int idx) struct ogg_stream *os = ogg->streams + idx; AVStream *st = s->streams[idx]; GetBitContext gb; - FLACStreaminfo si; int mdt; if (os->buf[os->pstart] == 0xff) @@ -46,6 +45,8 @@ flac_header (AVFormatContext * s, int idx) if (mdt == OGG_FLAC_METADATA_TYPE_STREAMINFO) { uint8_t *streaminfo_start = os->buf + os->pstart + 5 + 4 + 4 + 4; + uint32_t samplerate; + skip_bits_long(&gb, 4*8); /* "FLAC" */ if(get_bits(&gb, 8) != 1) /* unsupported major version */ return -1; @@ -56,8 +57,6 @@ flac_header (AVFormatContext * s, int idx) if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE) return -1; - avpriv_flac_parse_streaminfo(st->codec, &si, streaminfo_start); - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = AV_CODEC_ID_FLAC; st->need_parsing = AVSTREAM_PARSE_HEADERS; @@ -67,7 +66,11 @@ flac_header (AVFormatContext * s, int idx) memcpy(st->codec->extradata, streaminfo_start, FLAC_STREAMINFO_SIZE); st->codec->extradata_size = FLAC_STREAMINFO_SIZE; - avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); + samplerate = AV_RB24(st->codec->extradata + 10) >> 4; + if (!samplerate) + return AVERROR_INVALIDDATA; + + avpriv_set_pts_info(st, 64, 1, samplerate); } else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) { ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 4, os->psize - 4); }