Merge commit '46c477c2a14b04a63ab11d31003b48fab6146a96' into release/2.2
* commit '46c477c2a14b04a63ab11d31003b48fab6146a96': Check mp3 header before calling avpriv_mpegaudio_decode_header(). Conflicts: libavformat/mp3enc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -183,6 +183,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) {
|
||||||
@@ -238,7 +239,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;
|
||||||
}
|
}
|
||||||
|
@@ -262,19 +262,19 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
if (pkt->data && pkt->size >= 4) {
|
if (pkt->data && pkt->size >= 4) {
|
||||||
MPADecodeHeader mpah;
|
MPADecodeHeader mpah;
|
||||||
int av_unused base;
|
int av_unused base;
|
||||||
uint32_t head = AV_RB32(pkt->data);
|
uint32_t h;
|
||||||
|
|
||||||
if (ff_mpa_check_header(head) < 0) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
avpriv_mpegaudio_decode_header(&mpah, head);
|
|
||||||
|
|
||||||
|
h = AV_RB32(pkt->data);
|
||||||
|
if (ff_mpa_check_header(h) == 0) {
|
||||||
|
avpriv_mpegaudio_decode_header(&mpah, h);
|
||||||
if (!mp3->initial_bitrate)
|
if (!mp3->initial_bitrate)
|
||||||
mp3->initial_bitrate = mpah.bit_rate;
|
mp3->initial_bitrate = mpah.bit_rate;
|
||||||
if ((mpah.bit_rate == 0) || (mp3->initial_bitrate != mpah.bit_rate))
|
if ((mpah.bit_rate == 0) || (mp3->initial_bitrate != mpah.bit_rate))
|
||||||
mp3->has_variable_bitrate = 1;
|
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, h);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef FILTER_VBR_HEADERS
|
#ifdef FILTER_VBR_HEADERS
|
||||||
/* filter out XING and INFO headers. */
|
/* filter out XING and INFO headers. */
|
||||||
|
Reference in New Issue
Block a user