* commit '955aec3c7c':
  mpegaudiodecheader: check the header in avpriv_mpegaudio_decode_header

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
This commit is contained in:
Hendrik Leppkes 2016-01-01 16:47:27 +01:00
commit 1e96b151fa
5 changed files with 26 additions and 25 deletions

View file

@ -82,9 +82,6 @@ static int mp3_read_probe(AVProbeData *p)
for(; buf < end; buf= buf2+1) {
buf2 = buf;
if(ff_mpa_check_header(AV_RB32(buf2)))
continue;
for(frames = 0; buf2 < end; frames++) {
int dummy;
header = AV_RB32(buf2);
@ -302,14 +299,16 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
MPADecodeHeader c;
int vbrtag_size = 0;
MP3DecContext *mp3 = s->priv_data;
int ret;
ffio_init_checksum(s->pb, ff_crcA001_update, 0);
v = avio_rb32(s->pb);
if(ff_mpa_check_header(v) < 0)
return -1;
if (avpriv_mpegaudio_decode_header(&c, v) == 0)
ret = avpriv_mpegaudio_decode_header(&c, v);
if (ret < 0)
return ret;
else if (ret == 0)
vbrtag_size = c.frame_size;
if(c.layer != 3)
return -1;

View file

@ -309,12 +309,13 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
if (pkt->data && pkt->size >= 4) {
MPADecodeHeader mpah;
int ret;
int av_unused base;
uint32_t h;
h = AV_RB32(pkt->data);
if (ff_mpa_check_header(h) == 0) {
avpriv_mpegaudio_decode_header(&mpah, h);
ret = avpriv_mpegaudio_decode_header(&mpah, h);
if (ret >= 0) {
if (!mp3->initial_bitrate)
mp3->initial_bitrate = mpah.bit_rate;
if ((mpah.bit_rate == 0) || (mp3->initial_bitrate != mpah.bit_rate))