|
|
@ -1770,24 +1770,27 @@ static int mpeg_decode_init(AVCodecContext *avctx) |
|
|
|
state. Return -1 if no start code found */ |
|
|
|
state. Return -1 if no start code found */ |
|
|
|
static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end) |
|
|
|
static int find_start_code(const uint8_t **pbuf_ptr, const uint8_t *buf_end) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const uint8_t *buf_ptr; |
|
|
|
const uint8_t *buf_ptr= *pbuf_ptr; |
|
|
|
unsigned int state=0xFFFFFFFF, v; |
|
|
|
|
|
|
|
int val; |
|
|
|
buf_ptr++; //gurantees that -1 is within the array
|
|
|
|
|
|
|
|
buf_end -= 2; // gurantees that +2 is within the array
|
|
|
|
|
|
|
|
|
|
|
|
buf_ptr = *pbuf_ptr; |
|
|
|
|
|
|
|
while (buf_ptr < buf_end) { |
|
|
|
while (buf_ptr < buf_end) { |
|
|
|
v = *buf_ptr++; |
|
|
|
if(*buf_ptr==0){ |
|
|
|
if (state == 0x000001) { |
|
|
|
while(buf_ptr < buf_end && buf_ptr[1]==0) |
|
|
|
state = ((state << 8) | v) & 0xffffff; |
|
|
|
buf_ptr++; |
|
|
|
val = state; |
|
|
|
|
|
|
|
goto found; |
|
|
|
if(buf_ptr[-1] == 0 && buf_ptr[1] == 1){ |
|
|
|
|
|
|
|
*pbuf_ptr = buf_ptr+3; |
|
|
|
|
|
|
|
return buf_ptr[2] + 0x100; |
|
|
|
} |
|
|
|
} |
|
|
|
state = ((state << 8) | v) & 0xffffff; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
val = -1; |
|
|
|
buf_ptr += 2; |
|
|
|
found: |
|
|
|
} |
|
|
|
*pbuf_ptr = buf_ptr; |
|
|
|
buf_end += 2; //undo the hack above
|
|
|
|
return val; |
|
|
|
|
|
|
|
|
|
|
|
*pbuf_ptr = buf_end; |
|
|
|
|
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int mpeg1_decode_picture(AVCodecContext *avctx,
|
|
|
|
static int mpeg1_decode_picture(AVCodecContext *avctx,
|
|
|
|