const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end)
{
    const uint8_t *a = p + 4 - ((long)p & 3);
    for( end -= 3; p < a && p < end; p++ ) {
        if( p[0] == 0 && p[1] == 0 && p[2] == 1 )
            return p;
    }
    for( end -= 3; p < end; p += 4 ) {
        uint32_t x = *(const uint32_t*)p;
        if( (x - 0x01010101) & (~x) & 0x80808080 ) {
            if( p[1] == 0 ) {
                if( p[0] == 0 && p[2] == 1 )
                    return p-1;
                if( p[2] == 0 && p[3] == 1 )
                    return p;
            }
            if( p[3] == 0 ) {
                if( p[2] == 0 && p[4] == 1 )
                    return p+1;
                if( p[4] == 0 && p[5] == 1 )
                    return p+2;
            }
        }
    }
    for( end += 3; p < end; p++ ) {
        if( p[0] == 0 && p[1] == 0 && p[2] == 1 )
            return p;
    }
    return end + 3;
}
['const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end)\n{\n    const uint8_t *a = p + 4 - ((long)p & 3);\n    for( end -= 3; p < a && p < end; p++ ) {\n        if( p[0] == 0 && p[1] == 0 && p[2] == 1 )\n            return p;\n    }\n    for( end -= 3; p < end; p += 4 ) {\n        uint32_t x = *(const uint32_t*)p;\n        if( (x - 0x01010101) & (~x) & 0x80808080 ) {\n            if( p[1] == 0 ) {\n                if( p[0] == 0 && p[2] == 1 )\n                    return p-1;\n                if( p[2] == 0 && p[3] == 1 )\n                    return p;\n            }\n            if( p[3] == 0 ) {\n                if( p[2] == 0 && p[4] == 1 )\n                    return p+1;\n                if( p[4] == 0 && p[5] == 1 )\n                    return p+2;\n            }\n        }\n    }\n    for( end += 3; p < end; p++ ) {\n        if( p[0] == 0 && p[1] == 0 && p[2] == 1 )\n            return p;\n    }\n    return end + 3;\n}']