28 #define UNCHECKED_BITSTREAM_READER 1
40 int next_avc= h->
is_avc ? 0 : buf_size;
50 for(i=0; i<buf_size; i++){
55 nalsize = (nalsize << 8) | buf[i++];
56 if(nalsize <= 0 || nalsize > buf_size - i){
60 next_avc= i + nalsize;
65 #if HAVE_FAST_UNALIGNED
70 while(i<next_avc && !((~*(
const uint64_t*)(buf+i) & (*(
const uint64_t*)(buf+i) - 0x0101010101010101ULL)) & 0x8080808080808080ULL))
73 while(i<next_avc && !((~*(
const uint32_t*)(buf+i) & (*(
const uint32_t*)(buf+i) - 0x01010101U)) & 0x80808080U))
77 for(; i<next_avc; i++){
84 if(buf[i]==1) state^= 5;
85 else if(buf[i]) state = 7;
89 if(v==6 || v==7 || v==8 || v==9){
94 }
else if(v==1 || v==2 || v==5){
129 return i-(state&5) - 3*(state>7);
142 const uint8_t *buf,
int buf_size)
145 const uint8_t *buf_end = buf + buf_size;
147 unsigned int slice_type;
150 int q264 = buf_size >=4 && !memcmp(
"Q264", buf, 4);
166 int src_length, dst_length, consumed, nalsize = 0;
172 nalsize = (nalsize << 8) | *buf++;
173 if (nalsize <= 0 || nalsize > buf_end - buf) {
177 src_length = nalsize;
183 src_length = buf_end - buf;
185 switch (state & 0x1f) {
194 if (ptr==
NULL || dst_length < 0)
280 buf += h->
is_avc ? nalsize : consumed;
291 const uint8_t **poutbuf,
int *poutbuf_size,
292 const uint8_t *buf,
int buf_size)
346 *poutbuf_size = buf_size;
351 const uint8_t *buf,
int buf_size)
357 for(i=0; i<=buf_size; i++){
358 if((state&0xFFFFFF1F) == 0x107)
362 if((state&0xFFFFFF00) == 0x100 && (state&0xFFFFFF1F) != 0x107 && (state&0xFFFFFF1F) != 0x108 && (state&0xFFFFFF1F) != 0x109){
364 while(i>4 && buf[i-5]==0) i--;
369 state= (state<<8) | buf[i];
396 .parser_close =
close,