Write unknown size if the size given is too large for EBML (greater than 2^56-1)

Originally committed as revision 10309 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
David Conrad 2007-09-05 00:23:06 +00:00
parent 815eb6a2fe
commit ffb880c278

View File

@ -46,11 +46,12 @@ static void put_ebml_id(ByteIOContext *pb, unsigned int id)
static void put_ebml_size(ByteIOContext *pb, uint64_t size, int minbytes) static void put_ebml_size(ByteIOContext *pb, uint64_t size, int minbytes)
{ {
int bytes = minbytes; int bytes = minbytes;
while (size >> (bytes*7 + 7)) bytes++;
// sizes larger than this are currently undefined in EBML // sizes larger than this are currently undefined in EBML
// XXX: error condition? // so write "unknown" size
if (size > (1ULL<<56)-1) return; size = FFMIN(size, (1ULL<<56)-1);
while (size >> (bytes*7 + 7)) bytes++;
put_byte(pb, (0x80 >> bytes) | (size >> bytes*8)); put_byte(pb, (0x80 >> bytes) | (size >> bytes*8));
for (bytes -= 1; bytes >= 0; bytes--) for (bytes -= 1; bytes >= 0; bytes--)