avformat/matroskadec: Improve frame size parsing error messages

When parsing the sizes of the frames in a lace fails, sometimes no
error message was raised (e.g. when using xiph or fixed-size lacing).
Only EBML lacing generated error messages (which were wrongly declared
as AV_LOG_INFO), but even here not all errors resulted in an error
message. So add a generic error message to catch them all.

Moreover, if parsing one of the EBML numbers fails, ebml_read_num already
emits its own error messages, so that all that is needed is a generic error
message to indicate that this happened during parsing the sizes of the
frames in a block; in other words, the error messages specific to
parsing EBML lace numbers can be and have been removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2019-12-03 18:09:09 +01:00 committed by James Almer
parent f74eaa17bb
commit dbe3be6744

View File

@ -3048,11 +3048,10 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
uint64_t num; uint64_t num;
uint64_t total; uint64_t total;
n = matroska_ebmlnum_uint(matroska, data, size, &num); n = matroska_ebmlnum_uint(matroska, data, size, &num);
if (n < 0 || num > INT_MAX) { if (n < 0)
av_log(matroska->ctx, AV_LOG_INFO, return n;
"EBML block data error\n"); if (num > INT_MAX)
return n < 0 ? n : AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
}
data += n; data += n;
size -= n; size -= n;
total = lace_size[0] = num; total = lace_size[0] = num;
@ -3060,11 +3059,10 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
int64_t snum; int64_t snum;
int r; int r;
r = matroska_ebmlnum_sint(matroska, data, size, &snum); r = matroska_ebmlnum_sint(matroska, data, size, &snum);
if (r < 0 || lace_size[n - 1] + snum > (uint64_t)INT_MAX) { if (r < 0)
av_log(matroska->ctx, AV_LOG_INFO, return r;
"EBML block data error\n"); if (lace_size[n - 1] + snum > (uint64_t)INT_MAX)
return r < 0 ? r : AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
}
data += r; data += r;
size -= r; size -= r;
lace_size[n] = lace_size[n - 1] + snum; lace_size[n] = lace_size[n - 1] + snum;
@ -3575,8 +3573,10 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf
res = matroska_parse_laces(matroska, &data, size, (flags & 0x06) >> 1, res = matroska_parse_laces(matroska, &data, size, (flags & 0x06) >> 1,
lace_size, &laces); lace_size, &laces);
if (res < 0) if (res < 0) {
av_log(matroska->ctx, AV_LOG_ERROR, "Error parsing frame sizes.\n");
return res; return res;
}
if (track->audio.samplerate == 8000) { if (track->audio.samplerate == 8000) {
// If this is needed for more codecs, then add them here // If this is needed for more codecs, then add them here