const uint8_t *ff_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state){
    int i;
    assert(p<=end);
    if(p>=end)
        return end;
    for(i=0; i<3; i++){
        uint32_t tmp= *state << 8;
        *state= tmp + *(p++);
        if(tmp == 0x100 || p==end)
            return p;
    }
    while(p<end){
        if     (p[-1] > 1      ) p+= 3;
        else if(p[-2]          ) p+= 2;
        else if(p[-3]|(p[-1]-1)) p++;
        else{
            p++;
            break;
        }
    }
    p= FFMIN(p, end)-4;
    *state= AV_RB32(p);
    return p+4;
}
['static int slice_decode_thread(AVCodecContext *c, void *arg){\n    MpegEncContext *s= arg;\n    const uint8_t *buf= s->gb.buffer;\n    int mb_y= s->start_mb_y;\n    s->error_count= 3*(s->end_mb_y - s->start_mb_y)*s->mb_width;\n    for(;;){\n        uint32_t start_code;\n        int ret;\n        ret= mpeg_decode_slice((Mpeg1Context*)s, mb_y, &buf, s->gb.buffer_end - buf);\n        emms_c();\n        if(ret < 0){\n            if(s->resync_mb_x>=0 && s->resync_mb_y>=0)\n                ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);\n        }else{\n            ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_END|DC_END|MV_END);\n        }\n        if(s->mb_y == s->end_mb_y)\n            return 0;\n        start_code= -1;\n        buf = ff_find_start_code(buf, s->gb.buffer_end, &start_code);\n        mb_y= start_code - SLICE_MIN_START_CODE;\n        if(mb_y < 0 || mb_y >= s->end_mb_y)\n            return -1;\n    }\n    return 0;\n}', 'const uint8_t *ff_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state){\n    int i;\n    assert(p<=end);\n    if(p>=end)\n        return end;\n    for(i=0; i<3; i++){\n        uint32_t tmp= *state << 8;\n        *state= tmp + *(p++);\n        if(tmp == 0x100 || p==end)\n            return p;\n    }\n    while(p<end){\n        if     (p[-1] > 1      ) p+= 3;\n        else if(p[-2]          ) p+= 2;\n        else if(p[-3]|(p[-1]-1)) p++;\n        else{\n            p++;\n            break;\n        }\n    }\n    p= FFMIN(p, end)-4;\n    *state= AV_RB32(p);\n    return p+4;\n}']