@@ -944,19 +944,14 @@ const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p,
const uint8_t *end,
uint32_t *av_restrict start_code)
{
- int i;
+ *start_code = ~0;
av_assert0(p <= end);
- if (p >= end)
+ // minimum length for a start code
+ if (p + 4 > end)
return end;
- *start_code = ~0;
- for (i = 0; i < 3; i++) {
- uint32_t tmp = *start_code << 8;
- *start_code = tmp + *(p++);
- if (tmp == 0x100 || p == end)
- return p;
- }
+ p += 3; // offset for negative indices in while loop
/* with memory address increasing left to right, we are looking for (in hexadecimal):
* 00 00 01 XX