You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avformat:matroskadec: use a define to mark the EBML length is unknown
Unifying the way the EBML unknown length is signaled, rather than using two incompatible values. UINT64_MAX cannot be read as a valid EBML length with the current code. Co-authored-by: Steve Lhomme <robux4@ycbcr.xyz> Co-authored-by: Dale Curtis <dalecurtis@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
committed by
Michael Niedermayer
parent
96d79ff5b5
commit
a2c7702ccf
@@ -68,6 +68,8 @@
|
|||||||
|
|
||||||
#include "qtpalette.h"
|
#include "qtpalette.h"
|
||||||
|
|
||||||
|
#define EBML_UNKNOWN_LENGTH UINT64_MAX /* EBML unknown length, in uint64_t */
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EBML_NONE,
|
EBML_NONE,
|
||||||
EBML_UINT,
|
EBML_UINT,
|
||||||
@@ -869,7 +871,7 @@ static int ebml_read_length(MatroskaDemuxContext *matroska, AVIOContext *pb,
|
|||||||
{
|
{
|
||||||
int res = ebml_read_num(matroska, pb, 8, number);
|
int res = ebml_read_num(matroska, pb, 8, number);
|
||||||
if (res > 0 && *number + 1 == 1ULL << (7 * res))
|
if (res > 0 && *number + 1 == 1ULL << (7 * res))
|
||||||
*number = 0xffffffffffffffULL;
|
*number = EBML_UNKNOWN_LENGTH;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1049,7 +1051,7 @@ static int ebml_parse_id(MatroskaDemuxContext *matroska, EbmlSyntax *syntax,
|
|||||||
break;
|
break;
|
||||||
if (!syntax[i].id && id == MATROSKA_ID_CLUSTER &&
|
if (!syntax[i].id && id == MATROSKA_ID_CLUSTER &&
|
||||||
matroska->num_levels > 0 &&
|
matroska->num_levels > 0 &&
|
||||||
matroska->levels[matroska->num_levels - 1].length == 0xffffffffffffff)
|
matroska->levels[matroska->num_levels - 1].length == EBML_UNKNOWN_LENGTH)
|
||||||
return 0; // we reached the end of an unknown size cluster
|
return 0; // we reached the end of an unknown size cluster
|
||||||
if (!syntax[i].id && id != EBML_ID_VOID && id != EBML_ID_CRC32) {
|
if (!syntax[i].id && id != EBML_ID_VOID && id != EBML_ID_CRC32) {
|
||||||
av_log(matroska->ctx, AV_LOG_DEBUG, "Unknown entry 0x%"PRIX32"\n", id);
|
av_log(matroska->ctx, AV_LOG_DEBUG, "Unknown entry 0x%"PRIX32"\n", id);
|
||||||
@@ -1201,7 +1203,7 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
|
|||||||
MatroskaLevel *level = &matroska->levels[matroska->num_levels - 1];
|
MatroskaLevel *level = &matroska->levels[matroska->num_levels - 1];
|
||||||
AVIOContext *pb = matroska->ctx->pb;
|
AVIOContext *pb = matroska->ctx->pb;
|
||||||
int64_t pos = avio_tell(pb);
|
int64_t pos = avio_tell(pb);
|
||||||
if (level->length != (uint64_t) -1 &&
|
if (level->length != EBML_UNKNOWN_LENGTH &&
|
||||||
(pos + length) > (level->start + level->length)) {
|
(pos + length) > (level->start + level->length)) {
|
||||||
av_log(matroska->ctx, AV_LOG_ERROR,
|
av_log(matroska->ctx, AV_LOG_ERROR,
|
||||||
"Invalid length 0x%"PRIx64" > 0x%"PRIx64" in parent\n",
|
"Invalid length 0x%"PRIx64" > 0x%"PRIx64" in parent\n",
|
||||||
@@ -1610,7 +1612,7 @@ static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska,
|
|||||||
ret = AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
} else {
|
} else {
|
||||||
level.start = 0;
|
level.start = 0;
|
||||||
level.length = (uint64_t) -1;
|
level.length = EBML_UNKNOWN_LENGTH;
|
||||||
matroska->levels[matroska->num_levels] = level;
|
matroska->levels[matroska->num_levels] = level;
|
||||||
matroska->num_levels++;
|
matroska->num_levels++;
|
||||||
matroska->current_id = 0;
|
matroska->current_id = 0;
|
||||||
@@ -1620,7 +1622,7 @@ static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska,
|
|||||||
/* remove dummy level */
|
/* remove dummy level */
|
||||||
while (matroska->num_levels) {
|
while (matroska->num_levels) {
|
||||||
uint64_t length = matroska->levels[--matroska->num_levels].length;
|
uint64_t length = matroska->levels[--matroska->num_levels].length;
|
||||||
if (length == (uint64_t) -1)
|
if (length == EBML_UNKNOWN_LENGTH)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user