annotate demux_mpg.c @ 235:6f96d4143806

verbose output changed
author arpi_esp
date Wed, 28 Mar 2001 21:43:21 +0000
parents 3b5f5d1c5041
children 18e5c0f63947
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 // MPG/VOB file parser for DEMUXER v2.5 by A'rpi/ESP-team
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 static unsigned int read_mpeg_timestamp(stream_t *s,int c){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 int d,e;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 unsigned int pts;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 d=stream_read_word(s);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 e=stream_read_word(s);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 if( ((c&1)!=1) || ((d&1)!=1) || ((e&1)!=1) ) return 0; // invalid pts
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 pts=(((c>>1)&7)<<30)|((d>>1)<<15)|(e>>1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 if(verbose>=3) printf("{%d}",pts);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 return pts;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 static char dvdaudio_table[256];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 //static unsigned int packet_start_pos=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 static int demux_mpg_read_packet(demuxer_t *demux,int id){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 int d;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 int len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 unsigned char c=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 unsigned int pts=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 unsigned int dts=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 demux_stream_t *ds=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 if(verbose>=3) printf("demux_read_packet: %X\n",id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 // if(id==0x1BA) packet_start_pos=stream_tell(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 if(id<0x1BC || id>0x1FF) return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 if(id==0x1BE) return -1; // padding stream
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 if(id==0x1BF) return -1; // private2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 len=stream_read_word(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 if(verbose>=3) printf("PACKET len=%d",len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 if(len==0 || len>4096) return -2; // invalid packet !!!!!!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 while(len>0){ // Skip stuFFing bytes
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 c=stream_read_char(demux->stream);--len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 if(c!=0xFF)break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 if((c>>6)==1){ // Read (skip) STD scale & size value
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 // printf(" STD_scale=%d",(c>>5)&1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 d=((c&0x1F)<<8)|stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 len-=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 // printf(" STD_size=%d",d);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 // Read System-1 stream timestamps:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 if((c>>4)==2){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 pts=read_mpeg_timestamp(demux->stream,c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 len-=4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 if((c>>4)==3){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 pts=read_mpeg_timestamp(demux->stream,c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 if((c>>4)!=1) pts=0; //printf("{ERROR4}");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 dts=read_mpeg_timestamp(demux->stream,c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 len-=4+1+4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 if((c>>6)==2){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 int pts_flags;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 int hdrlen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 // System-2 (.VOB) stream:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 if((c>>4)&3) printf("Warning! Encrypted VOB file! (DeCSS not (yet) supported)\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 c=stream_read_char(demux->stream); pts_flags=c>>6;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 c=stream_read_char(demux->stream); hdrlen=c;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 len-=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 if(verbose>=3) printf(" hdrlen=%d (len=%d)",hdrlen,len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 if(hdrlen>len) return -1; // invalid header length
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 if(pts_flags==2){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 pts=read_mpeg_timestamp(demux->stream,c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 len-=5;hdrlen-=5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 if(pts_flags==3){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 pts=read_mpeg_timestamp(demux->stream,c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 dts=read_mpeg_timestamp(demux->stream,c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 len-=10;hdrlen-=10;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 len-=hdrlen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 if(hdrlen>0) stream_skip(demux->stream,hdrlen); // skip header bytes
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 //============== DVD Audio sub-stream ======================
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 if(id==0x1BD){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 int aid=stream_read_char(demux->stream)&0x7F;--len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 ds=demux->audio;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 if(ds->id==-1) ds->id=aid;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 if(!dvdaudio_table[aid]){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 dvdaudio_table[aid]=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 printf("DVD Audio format: %s ID=%d%s\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 ((aid&0x70)==0x20)?"PCM":"AC3",aid,(ds->id==aid)?" CURRENT":"");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 if(len<3) return -1; // invalid audio packet
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 if(ds->id!=aid){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 // drop packet (not selected channel)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 ds=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 // READ Packet: Skip additional audio header data:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 len-=3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 if(ds->type==-1){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 // autodetect type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 ds->type=((aid&0x70)==0x20)?2:3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 if(ds->type==2 && len>=2){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 // read PCM header
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 int head;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 head=stream_read_char(demux->stream); head=c<<8;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 c=stream_read_char(demux->stream); head|=c; len-=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 while(len>0 && head!=0x180){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 head=c<<8;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 c=stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 head|=c;--len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 if(!len) printf("End of packet while searching for PCM header\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 //if(c!=0x0f) printf(" {ERROR5,c=%d} \n",c);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 if(verbose>=3) printf("\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 if(len<=0 || len>4096) return -1; // Invalid packet size
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 if(id>=0x1C0 && id<=0x1DF){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 // mpeg audio
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 int aid=id-0x1C0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 if(demux->audio->id==-1) demux->audio->id=aid;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 if(demux->audio->id==aid){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 ds=demux->audio;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 if(ds->type==-1) ds->type=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 if(id>=0x1E0 && id<=0x1EF){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 // mpeg video
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 int aid=id-0x1E0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 if(demux->video->id==-1) demux->video->id=aid;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 if(demux->video->id==aid) ds=demux->video;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 if(ds){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 if(verbose>=2) printf("DEMUX_MPG: Read %d data bytes from packet %04X\n",len,id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 // printf("packet start = 0x%X \n",stream_tell(demux->stream)-packet_start_pos);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 ds_read_packet(ds,demux->stream,len,pts/90000.0f,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 if(verbose>=2) printf("DEMUX_MPG: Skipping %d data bytes from packet %04X\n",len,id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 stream_skip(demux->stream,len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 static int num_elementary_packets100=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 static int num_elementary_packets101=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 int demux_mpg_es_fill_buffer(demuxer_t *demux){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 //if(demux->type==DEMUXER_TYPE_MPEG_ES)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 // Elementary video stream
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 if(demux->stream->eof) return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 demux->filepos=stream_tell(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 ds_read_packet(demux->video,demux->stream,4096,0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 int demux_mpg_fill_buffer(demuxer_t *demux){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 unsigned int head=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 int skipped=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 int max_packs=128;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 int ret=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 // System stream
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 do{
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 demux->filepos=stream_tell(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 head=stream_read_dword(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 while((head&0xffffff00)!=0x00000100){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 if(stream_eof(demux->stream)) break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 head=(head<<8)|stream_read_char(demux->stream);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 ++skipped; ++demux->filepos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 if(stream_eof(demux->stream)) break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 // sure: head=0x000001XX
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 if(demux->synced==0){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 if(head==0x1BA) demux->synced=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 } else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 if(demux->synced==1){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 if(head==0x1BB || (head>=0x1C0 && head<=0x1EF)){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 demux->synced=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 if(verbose) printf("system stream synced at 0x%X (%d)!\n",demux->filepos,demux->filepos);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 } else demux->synced=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 } // else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 if(demux->synced==2){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 ret=demux_mpg_read_packet(demux,head);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 if(!ret)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 if(--max_packs==0){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 demux->stream->eof=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 printf("demux: file doesn't contain the selected audio or video stream\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 if(head>=0x100 && head<0x1B0){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 if(head==0x100)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 ++num_elementary_packets100;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 if(head==0x101) ++num_elementary_packets101;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 if(verbose>=3) printf("Opps... elementary video packet found: %03X\n",head);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 #if 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 if(num_elementary_packets100>50 && num_elementary_packets101>50
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 && skipped>4000000){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 if(verbose) printf("sync_mpeg_ps: seems to be ES stream...\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 demux->stream->eof=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 } while(ret!=1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 if(verbose>=2) printf("demux: %d bad bytes skipped\n",skipped);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 if(demux->stream->eof){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 if(verbose>=2) printf("MPEG Stream reached EOF\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228