@@ -953,12 +953,27 @@ const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p,
return p;
}
+ /* with memory address increasing left to right, we are looking for (in hexadecimal):
+ * 00 00 01 XX
+ * p points at the address which should have the value of XX
+ */
while (p < end) {
- if (p[-1] > 1 ) p += 3;
- else if (p[-2] ) p += 2;
- else if (p[-3]|(p[-1]-1)) p++;
- else {
+ // UU UU UU
+ if (p[-1] > 1) {
+ p += 3;
+ // start check over with 3 new bytes
+ }
+ else if (p[-1] == 0) {
+ p++;
+ // could be in a start code, so check next byte
+ }
+ else if (/* UU UU 01 */ p[-2] != 0 ||
+ /* UU 00 01 */ p[-3] != 0) {
+ p += 3;
+ }
+ else { /* 00 00 01 */
p++;
+ // p now points at the address following the start code value XX
break;
}
}