diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-08-08 12:50:57 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-08-08 12:52:20 +0200 |
commit | cf7f798984a9d93a2297ecbf203b85a660317e31 (patch) | |
tree | 6be5b7a71fe092dd42a4b22206daad9a95eeabcf | |
parent | 244a58fff0adabcce3f9ea80d848a562ff377843 (diff) | |
parent | d7dbc687e312a91ef2ccf797d57b95c61d0e8a2f (diff) | |
download | ffmpeg-cf7f798984a9d93a2297ecbf203b85a660317e31.tar.gz |
Merge commit 'd7dbc687e312a91ef2ccf797d57b95c61d0e8a2f' into release/1.1
* commit 'd7dbc687e312a91ef2ccf797d57b95c61d0e8a2f':
Check mp3 header before calling avpriv_mpegaudio_decode_header().
Conflicts:
libavformat/mp3enc.c
See: See: 2dd0da787ce5008d4d1b8f461fbd1288c32e2c38
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/libmp3lame.c | 8 | ||||
-rw-r--r-- | libavformat/mp3enc.c | 22 |
2 files changed, 18 insertions, 12 deletions
diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index eea9d031b1..24ad797222 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -191,6 +191,7 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, MPADecodeHeader hdr; int len, ret, ch; int lame_result; + uint32_t h; if (frame) { switch (avctx->sample_fmt) { @@ -246,7 +247,12 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, determine the frame size. */ if (s->buffer_index < 4) return 0; - if (avpriv_mpegaudio_decode_header(&hdr, AV_RB32(s->buffer))) { + h = AV_RB32(s->buffer); + if (ff_mpa_check_header(h) < 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid mp3 header at start of buffer\n"); + return AVERROR_BUG; + } + if (avpriv_mpegaudio_decode_header(&hdr, h)) { av_log(avctx, AV_LOG_ERROR, "free format output not supported\n"); return -1; } diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index eba70a1ab8..245b507796 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -265,19 +265,19 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt) if (pkt->data && pkt->size >= 4) { MPADecodeHeader mpah; int av_unused base; - uint32_t head = AV_RB32(pkt->data); - - if (ff_mpa_check_header(head) < 0) { + uint32_t h; + + h = AV_RB32(pkt->data); + if (ff_mpa_check_header(h) == 0) { + avpriv_mpegaudio_decode_header(&mpah, h); + if (!mp3->initial_bitrate) + mp3->initial_bitrate = mpah.bit_rate; + if ((mpah.bit_rate == 0) || (mp3->initial_bitrate != mpah.bit_rate)) + mp3->has_variable_bitrate = 1; + } else { av_log(s, AV_LOG_WARNING, "Audio packet of size %d (starting with %08X...) " - "is invalid, writing it anyway.\n", pkt->size, head); - return ff_raw_write_packet(s, pkt); + "is invalid, writing it anyway.\n", pkt->size, h); } - avpriv_mpegaudio_decode_header(&mpah, head); - - if (!mp3->initial_bitrate) - mp3->initial_bitrate = mpah.bit_rate; - if ((mpah.bit_rate == 0) || (mp3->initial_bitrate != mpah.bit_rate)) - mp3->has_variable_bitrate = 1; #ifdef FILTER_VBR_HEADERS /* filter out XING and INFO headers. */ |