Commit 6b2f4c40 authored by conrad's avatar conrad

Use assert for conditions that must be true


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@10366 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent eef7287a
...@@ -104,7 +104,7 @@ static void put_ebml_id(ByteIOContext *pb, unsigned int id) ...@@ -104,7 +104,7 @@ static void put_ebml_id(ByteIOContext *pb, unsigned int id)
*/ */
static void put_ebml_size_unknown(ByteIOContext *pb, int bytes) static void put_ebml_size_unknown(ByteIOContext *pb, int bytes)
{ {
bytes = FFMIN(bytes, 8); assert(bytes <= 8);
put_byte(pb, 0x1ff >> bytes); put_byte(pb, 0x1ff >> bytes);
while (--bytes) while (--bytes)
put_byte(pb, 0xff); put_byte(pb, 0xff);
...@@ -140,14 +140,9 @@ static void put_ebml_size(ByteIOContext *pb, uint64_t size, int bytes) ...@@ -140,14 +140,9 @@ static void put_ebml_size(ByteIOContext *pb, uint64_t size, int bytes)
if (bytes == 0) if (bytes == 0)
// don't care how many bytes are used, so use the min // don't care how many bytes are used, so use the min
bytes = needed_bytes; bytes = needed_bytes;
else if (needed_bytes > bytes) {
// the bytes needed to write the given size would exceed the bytes // the bytes needed to write the given size would exceed the bytes
// that we need to use, so write unknown size. This shouldn't happen. // that we need to use, so write unknown size. This shouldn't happen.
av_log(NULL, AV_LOG_WARNING, "Size of %" PRIu64 " needs %d bytes but only %d bytes reserved\n", assert(bytes >= needed_bytes);
size, needed_bytes, bytes);
put_ebml_size_unknown(pb, bytes);
return;
}
size |= 1ULL << bytes*7; size |= 1ULL << bytes*7;
for (i = bytes - 1; i >= 0; i--) for (i = bytes - 1; i >= 0; i--)
...@@ -195,8 +190,7 @@ static void put_ebml_void(ByteIOContext *pb, uint64_t size) ...@@ -195,8 +190,7 @@ static void put_ebml_void(ByteIOContext *pb, uint64_t size)
{ {
offset_t currentpos = url_ftell(pb); offset_t currentpos = url_ftell(pb);
if (size < 2) assert(size >= 2);
return;
put_ebml_id(pb, EBML_ID_VOID); put_ebml_id(pb, EBML_ID_VOID);
// we need to subtract the length needed to store the size from the // we need to subtract the length needed to store the size from the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment