32 #define MAX_SYNC_SIZE 100000
36 int pes2= (p[3] & 0xC0) == 0x80
37 && (p[4] & 0xC0) != 0x40
38 &&((p[4] & 0xC0) == 0x00 || (p[4]&0xC0)>>2 == (p[6]&0xF0));
40 for(p+=3; p<end && *p == 0xFF; p++);
41 if((*p&0xC0) == 0x40) p+=2;
42 if((*p&0xF0) == 0x20){
43 pes1= p[0]&p[2]&p[4]&1;
44 }
else if((*p&0xF0) == 0x30){
45 pes1= p[0]&p[2]&p[4]&p[5]&p[7]&p[9]&1;
53 return (buf[1] & 0xC0) == 0x40 || (buf[1] & 0xF0) == 0x20;
59 int sys=0, pspack=0, priv1=0, vid=0, audio=0, invalid=0;
64 code = (code<<8) + p->
buf[i];
65 if ((code & 0xffffff00) == 0x100) {
72 else if((code & 0xf0) ==
VIDEO_ID && pes) vid++;
75 else if((code & 0xe0) ==
AUDIO_ID && pes) {audio++; i+=
len;}
78 else if((code & 0xf0) ==
VIDEO_ID && !pes) invalid++;
79 else if((code & 0xe0) ==
AUDIO_ID && !pes) invalid++;
84 if(vid+audio > invalid)
87 if(sys>invalid && sys*9 <= pspack*10)
89 if(pspack > invalid && (priv1+vid+audio)*10 >= pspack*9)
91 if((!!vid ^ !!audio) && (audio > 4 || vid > 1) && !sys && !pspack && p->
buf_size>2048 && vid + audio > invalid)
109 const char *sofdec =
"Sofdec";
120 }
while (v == sofdec[i] && i++ < 6);
132 buf[0] = c<0 ?
avio_r8(pb) : c;
141 unsigned int state, v;
144 state = *header_state;
151 if (state == 0x000001) {
152 state = ((state << 8) | v) & 0xffffff;
156 state = ((state << 8) | v) & 0xffffff;
160 *header_state =
state;
173 int psm_length, ps_info_length, es_map_length;
185 while (es_map_length >= 4){
186 unsigned char type =
avio_r8(pb);
187 unsigned char es_id =
avio_r8(pb);
193 es_map_length -= 4 + es_info_length;
196 return 2 + psm_length;
203 int64_t *ppos,
int *pstart_code,
204 int64_t *ppts, int64_t *pdts)
208 int pes_ext, ext2_len, id_ext, skip;
242 m->
sofdec = !memcmp(buf,
"ofdec", 5);
258 if (!((startcode >= 0x1c0 && startcode <= 0x1df) ||
259 (startcode >= 0x1e0 && startcode <= 0x1ef) ||
260 (startcode == 0x1bd) || (startcode == 0x1fd)))
278 if ((c & 0xc0) == 0x40) {
284 if ((c & 0xe0) == 0x20) {
291 }
else if ((c & 0xc0) == 0x80) {
296 if (header_len > len)
307 if (flags & 0x3f && header_len == 0){
315 skip = (pes_ext >> 4) & 0xb;
317 if (pes_ext & 0x40 || skip > header_len){
324 if (pes_ext & 0x01) {
327 if ((ext2_len & 0x7f) > 0) {
329 if ((id_ext & 0x80) == 0)
330 startcode = ((startcode & 0xff) << 8) | id_ext;
345 if (startcode >= 0x80 && startcode <= 0xcf) {
351 if (startcode >= 0xb0 && startcode <= 0xbf) {
371 *pstart_code = startcode;
382 int len, startcode, i, es_type, ret;
385 int64_t pts, dts, dummy_pos;
393 if(startcode == 0x1bd) {
394 dvdaudio_substream_type =
avio_r8(s->
pb);
402 if (st->
id == startcode)
433 }
else if (startcode >= 0x1e0 && startcode <= 0x1ef) {
434 static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 };
435 unsigned char buf[8];
438 if(!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1))
443 }
else if (startcode >= 0x1c0 && startcode <= 0x1df) {
446 }
else if (startcode >= 0x80 && startcode <= 0x87) {
449 }
else if ( ( startcode >= 0x88 && startcode <= 0x8f)
450 ||( startcode >= 0x98 && startcode <= 0x9f)) {
454 }
else if (startcode >= 0xa0 && startcode <= 0xaf) {
458 }
else if (startcode >= 0xb0 && startcode <= 0xbf) {
461 }
else if (startcode >= 0xc0 && startcode <= 0xcf) {
465 }
else if (startcode >= 0x20 && startcode <= 0x3f) {
468 }
else if (startcode >= 0xfd55 && startcode <= 0xfd5f) {
471 }
else if (startcode == 0x1bd) {
474 switch(dvdaudio_substream_type & 0xe0) {
477 case 0x80:
if((dvdaudio_substream_type & 0xf8) == 0x88)
502 if ((startcode >= 0xa0 && startcode <= 0xaf) ||
503 (startcode == 0x1bd && ((dvdaudio_substream_type & 0xe0) == 0xa0))) {
514 freq = (b1 >> 4) & 3;
529 pkt->
pos = dummy_pos;
531 av_dlog(s,
"%d: pts=%0.3f dts=%0.3f size=%d\n",
535 return (ret < 0) ? ret : 0;
539 int64_t *ppos, int64_t pos_limit)
542 int64_t pos, pts, dts;
551 av_dlog(s,
"none (ret=%d)\n", len);
554 if (startcode == s->
streams[stream_index]->
id &&
560 av_dlog(s,
"pos=0x%"PRIx64
" dts=0x%"PRIx64
" %0.3f\n",
561 pos, dts, dts / 90000.0);