Check mp3 header before calling avpriv_mpegaudio_decode_header().
As indicated in the function documentation, the header MUST be checked prior to calling it because no consistency check is done there. CC:libav-stable@libav.org
This commit is contained in:
parent
44127546b0
commit
f2f2e7627f
@ -182,6 +182,7 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
|||||||
MPADecodeHeader hdr;
|
MPADecodeHeader hdr;
|
||||||
int len, ret, ch;
|
int len, ret, ch;
|
||||||
int lame_result;
|
int lame_result;
|
||||||
|
uint32_t h;
|
||||||
|
|
||||||
if (frame) {
|
if (frame) {
|
||||||
switch (avctx->sample_fmt) {
|
switch (avctx->sample_fmt) {
|
||||||
@ -237,7 +238,12 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
|||||||
determine the frame size. */
|
determine the frame size. */
|
||||||
if (s->buffer_index < 4)
|
if (s->buffer_index < 4)
|
||||||
return 0;
|
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");
|
av_log(avctx, AV_LOG_ERROR, "free format output not supported\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -252,13 +252,16 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
|
|
||||||
if (mp3->xing_offset && pkt->size >= 4) {
|
if (mp3->xing_offset && pkt->size >= 4) {
|
||||||
MPADecodeHeader c;
|
MPADecodeHeader c;
|
||||||
|
uint32_t h;
|
||||||
|
|
||||||
avpriv_mpegaudio_decode_header(&c, AV_RB32(pkt->data));
|
h = AV_RB32(pkt->data);
|
||||||
|
if (ff_mpa_check_header(h) == 0) {
|
||||||
if (!mp3->initial_bitrate)
|
avpriv_mpegaudio_decode_header(&c, h);
|
||||||
mp3->initial_bitrate = c.bit_rate;
|
if (!mp3->initial_bitrate)
|
||||||
if ((c.bit_rate == 0) || (mp3->initial_bitrate != c.bit_rate))
|
mp3->initial_bitrate = c.bit_rate;
|
||||||
mp3->has_variable_bitrate = 1;
|
if ((c.bit_rate == 0) || (mp3->initial_bitrate != c.bit_rate))
|
||||||
|
mp3->has_variable_bitrate = 1;
|
||||||
|
}
|
||||||
|
|
||||||
mp3_xing_add_frame(mp3, pkt);
|
mp3_xing_add_frame(mp3, pkt);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user