Efficient byte sequence detection
Version 3 

Consider the case of a sequence of 00 00 00 02. This sequence will pass the first 3 if conditions and fail at the 4th one. But what does this tell you ? It tells you that instead of increasing i by 1 it should be increased by 4.  

This idea converted to code could look like this  

for (int i = 0; i &lt; frame.length - 4; i++) {

    if (frame[i] != 0) {
        continue;
    }

    i++;
    if (frame[i] != 0) {
        continue;
    }

    i++;
    if (frame[i] &gt; 1) {
        continue;
    }

    if (frame[i] == 1) {
        // found marker 00 00 01
        // do work here

        continue;
    }

    i++;
    if (frame[i] == 1) {
        // found marker 00 00 00 01
        // do work here
    }
}


which isn't easy to read/understand at first glance, so a big comment about why the increasing of i is done like this would be in order.