Mercurial > mplayer.hg
annotate libmpdemux/demux_mpg.c @ 4147:4bbdda22003d
S->C
author | nick |
---|---|
date | Mon, 14 Jan 2002 09:32:51 +0000 |
parents | 04b2227ab75a |
children | 6394c1e9e770 |
rev | line source |
---|---|
1 | 1 // MPG/VOB file parser for DEMUXER v2.5 by A'rpi/ESP-team |
2 | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
3 #include <stdio.h> |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
4 #include <stdlib.h> |
1430 | 5 #include <unistd.h> |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
6 |
1567 | 7 #include "config.h" |
8 #include "mp_msg.h" | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1735
diff
changeset
|
9 #include "help_mp.h" |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
10 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
11 #include "stream.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
12 #include "demuxer.h" |
1466 | 13 #include "parse_es.h" |
2338 | 14 #include "stheader.h" |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
15 |
2555
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2338
diff
changeset
|
16 #include "dvdauth.h" |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2338
diff
changeset
|
17 |
524
9105fc95636c
A fast'n'ugly hack to correct DVD VOB playback problems
lgb
parents:
501
diff
changeset
|
18 //#define MAX_PS_PACKETSIZE 2048 |
501 | 19 #define MAX_PS_PACKETSIZE (224*1024) |
20 | |
547 | 21 static int mpeg_pts_error=0; |
22 | |
1 | 23 static unsigned int read_mpeg_timestamp(stream_t *s,int c){ |
24 int d,e; | |
25 unsigned int pts; | |
26 d=stream_read_word(s); | |
27 e=stream_read_word(s); | |
547 | 28 if( ((c&1)!=1) || ((d&1)!=1) || ((e&1)!=1) ){ |
29 ++mpeg_pts_error; | |
30 return 0; // invalid pts | |
31 } | |
1 | 32 pts=(((c>>1)&7)<<30)|((d>>1)<<15)|(e>>1); |
1567 | 33 mp_dbg(MSGT_DEMUX,MSGL_DBG3,"{%d}",pts); |
1 | 34 return pts; |
35 } | |
36 | |
37 static int demux_mpg_read_packet(demuxer_t *demux,int id){ | |
38 int d; | |
39 int len; | |
492 | 40 #ifdef HAVE_LIBCSS |
41 int css=0; | |
42 #endif | |
1 | 43 unsigned char c=0; |
44 unsigned int pts=0; | |
45 unsigned int dts=0; | |
46 demux_stream_t *ds=NULL; | |
47 | |
1567 | 48 mp_dbg(MSGT_DEMUX,MSGL_DBG3,"demux_read_packet: %X\n",id); |
1 | 49 |
536 | 50 // if(id==0x1F0){ |
51 // demux->synced=0; // force resync after 0x1F0 | |
52 // return -1; | |
53 //} | |
501 | 54 |
1 | 55 // if(id==0x1BA) packet_start_pos=stream_tell(demux->stream); |
501 | 56 if(id<0x1BC || id>=0x1F0) return -1; |
1 | 57 if(id==0x1BE) return -1; // padding stream |
58 if(id==0x1BF) return -1; // private2 | |
59 | |
60 len=stream_read_word(demux->stream); | |
1567 | 61 mp_dbg(MSGT_DEMUX,MSGL_DBG3,"PACKET len=%d",len); |
536 | 62 // if(len==62480){ demux->synced=0;return -1;} /* :) */ |
501 | 63 if(len==0 || len>MAX_PS_PACKETSIZE){ |
1567 | 64 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"Invalid PS packet len: %d\n",len); |
501 | 65 return -2; // invalid packet !!!!!! |
66 } | |
1 | 67 |
547 | 68 mpeg_pts_error=0; |
69 | |
1 | 70 while(len>0){ // Skip stuFFing bytes |
71 c=stream_read_char(demux->stream);--len; | |
72 if(c!=0xFF)break; | |
73 } | |
74 if((c>>6)==1){ // Read (skip) STD scale & size value | |
75 // printf(" STD_scale=%d",(c>>5)&1); | |
76 d=((c&0x1F)<<8)|stream_read_char(demux->stream); | |
77 len-=2; | |
78 // printf(" STD_size=%d",d); | |
79 c=stream_read_char(demux->stream); | |
80 } | |
81 // Read System-1 stream timestamps: | |
82 if((c>>4)==2){ | |
83 pts=read_mpeg_timestamp(demux->stream,c); | |
84 len-=4; | |
85 } else | |
86 if((c>>4)==3){ | |
87 pts=read_mpeg_timestamp(demux->stream,c); | |
88 c=stream_read_char(demux->stream); | |
89 if((c>>4)!=1) pts=0; //printf("{ERROR4}"); | |
90 dts=read_mpeg_timestamp(demux->stream,c); | |
91 len-=4+1+4; | |
92 } else | |
93 if((c>>6)==2){ | |
94 int pts_flags; | |
95 int hdrlen; | |
96 // System-2 (.VOB) stream: | |
492 | 97 if((c>>4)&3) { |
98 #ifdef HAVE_LIBCSS | |
99 css=1; | |
100 #else | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1735
diff
changeset
|
101 mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_EncryptedVOB); |
492 | 102 #endif |
103 } | |
1 | 104 c=stream_read_char(demux->stream); pts_flags=c>>6; |
105 c=stream_read_char(demux->stream); hdrlen=c; | |
106 len-=2; | |
1567 | 107 mp_dbg(MSGT_DEMUX,MSGL_DBG3," hdrlen=%d (len=%d)",hdrlen,len); |
108 if(hdrlen>len){ mp_msg(MSGT_DEMUX,MSGL_V,"demux_mpg: invalid header length \n"); return -1;} | |
1 | 109 if(pts_flags==2){ |
110 c=stream_read_char(demux->stream); | |
111 pts=read_mpeg_timestamp(demux->stream,c); | |
112 len-=5;hdrlen-=5; | |
113 } else | |
114 if(pts_flags==3){ | |
115 c=stream_read_char(demux->stream); | |
116 pts=read_mpeg_timestamp(demux->stream,c); | |
117 c=stream_read_char(demux->stream); | |
118 dts=read_mpeg_timestamp(demux->stream,c); | |
119 len-=10;hdrlen-=10; | |
120 } | |
121 len-=hdrlen; | |
122 if(hdrlen>0) stream_skip(demux->stream,hdrlen); // skip header bytes | |
123 | |
124 //============== DVD Audio sub-stream ====================== | |
125 if(id==0x1BD){ | |
552 | 126 int aid=stream_read_char(demux->stream);--len; |
1 | 127 if(len<3) return -1; // invalid audio packet |
552 | 128 |
129 // AID: | |
130 // 0x20..0x3F subtitle | |
131 // 0x80..0x9F AC3 audio | |
132 // 0xA0..0xBF PCM audio | |
133 | |
134 if((aid & 0xE0) == 0x20){ | |
135 // subtitle: | |
136 aid&=0x1F; | |
426 | 137 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
138 if(!demux->s_streams[aid]){ |
1567 | 139 mp_msg(MSGT_DEMUX,MSGL_V,"==> Found subtitle: %d\n",aid); |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
140 demux->s_streams[aid]=1; |
552 | 141 } |
142 | |
143 if(demux->sub->id==aid){ | |
144 ds=demux->sub; | |
145 } | |
146 | |
3955 | 147 } else if((aid & 0xC0) == 0x80 || (aid & 0xE0) == 0x00) { |
552 | 148 |
149 // aid=128+(aid&0x7F); | |
150 // aid=0x80..0xBF | |
151 | |
1289 | 152 if(!demux->a_streams[aid]) new_sh_audio(demux,aid); |
552 | 153 if(demux->audio->id==-1) demux->audio->id=aid; |
426 | 154 |
155 if(demux->audio->id==aid){ | |
536 | 156 // int type; |
426 | 157 ds=demux->audio; |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
158 if(!ds->sh) ds->sh=demux->a_streams[aid]; |
1 | 159 // READ Packet: Skip additional audio header data: |
536 | 160 c=stream_read_char(demux->stream);//type=c; |
161 c=stream_read_char(demux->stream);//type|=c<<8; | |
162 c=stream_read_char(demux->stream);//type|=c<<16; | |
163 // printf("[%06X]",type); | |
1 | 164 len-=3; |
1331
b4457de47804
ds->type removed - using id-based audio format detection in mplayer.c
arpi
parents:
1289
diff
changeset
|
165 if((aid&0xE0)==0xA0 && len>=2){ |
1 | 166 // read PCM header |
167 int head; | |
168 head=stream_read_char(demux->stream); head=c<<8; | |
169 c=stream_read_char(demux->stream); head|=c; len-=2; | |
170 while(len>0 && head!=0x180){ | |
171 head=c<<8; | |
172 c=stream_read_char(demux->stream); | |
173 head|=c;--len; | |
174 } | |
1567 | 175 if(!len) mp_msg(MSGT_DEMUX,MSGL_V,"End of packet while searching for PCM header\n"); |
1 | 176 } |
552 | 177 } // if(demux->audio->id==aid) |
178 | |
1567 | 179 } else mp_msg(MSGT_DEMUX,MSGL_V,"Unknown 0x1BD substream: 0x%02X \n",aid); |
552 | 180 |
181 } //if(id==0x1BD) | |
1 | 182 |
183 } else { | |
539 | 184 if(c!=0x0f){ |
1567 | 185 mp_msg(MSGT_DEMUX,MSGL_V," {ERROR5,c=%d} \n",c); |
539 | 186 return -1; // invalid packet !!!!!! |
187 } | |
1 | 188 } |
1567 | 189 if(mpeg_pts_error) mp_msg(MSGT_DEMUX,MSGL_V," {PTS_err:%d} \n",mpeg_pts_error); |
190 mp_dbg(MSGT_DEMUX,MSGL_DBG3," => len=%d\n",len); | |
1 | 191 |
501 | 192 // if(len<=0 || len>MAX_PS_PACKETSIZE) return -1; // Invalid packet size |
193 if(len<=0 || len>MAX_PS_PACKETSIZE){ | |
1567 | 194 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"Invalid PS data len: %d\n",len); |
501 | 195 return -1; // invalid packet !!!!!! |
196 } | |
1 | 197 |
198 if(id>=0x1C0 && id<=0x1DF){ | |
199 // mpeg audio | |
200 int aid=id-0x1C0; | |
1289 | 201 if(!demux->a_streams[aid]) new_sh_audio(demux,aid); |
1 | 202 if(demux->audio->id==-1) demux->audio->id=aid; |
203 if(demux->audio->id==aid){ | |
204 ds=demux->audio; | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
205 if(!ds->sh) ds->sh=demux->a_streams[aid]; |
1 | 206 } |
207 } else | |
208 if(id>=0x1E0 && id<=0x1EF){ | |
209 // mpeg video | |
210 int aid=id-0x1E0; | |
1289 | 211 if(!demux->v_streams[aid]) new_sh_video(demux,aid); |
1 | 212 if(demux->video->id==-1) demux->video->id=aid; |
426 | 213 if(demux->video->id==aid){ |
214 ds=demux->video; | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
215 if(!ds->sh) ds->sh=demux->v_streams[aid]; |
426 | 216 } |
1 | 217 } |
218 | |
219 if(ds){ | |
1567 | 220 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"DEMUX_MPG: Read %d data bytes from packet %04X\n",len,id); |
1 | 221 // printf("packet start = 0x%X \n",stream_tell(demux->stream)-packet_start_pos); |
492 | 222 #ifdef HAVE_LIBCSS |
546 | 223 if (css) { |
3975
04b2227ab75a
Return of the 'Old-style-DVD-support', with dynamic loading (using libdl) so
lgb
parents:
3955
diff
changeset
|
224 if (descrambling) dvd_css_descramble(demux->stream->buffer,key_title); else |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1735
diff
changeset
|
225 mp_msg(MSGT_DEMUX,MSGL_WARN,MSGTR_EncryptedVOBauth); |
546 | 226 } |
492 | 227 #endif |
1735 | 228 ds_read_packet(ds,demux->stream,len,pts/90000.0f,demux->filepos,0); |
554 | 229 // if(ds==demux->sub) parse_dvdsub(ds->last->buffer,ds->last->len); |
1 | 230 return 1; |
231 } | |
1567 | 232 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"DEMUX_MPG: Skipping %d data bytes from packet %04X\n",len,id); |
536 | 233 if(len<=2356) stream_skip(demux->stream,len); |
1 | 234 return 0; |
235 } | |
236 | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
237 int num_elementary_packets100=0; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
554
diff
changeset
|
238 int num_elementary_packets101=0; |
1162 | 239 int num_elementary_packets1B6=0; |
1338
345585097137
mpeg PES steram support (only 1E0 & 1C0 packets, no 1BA/1BB headers)
arpi
parents:
1331
diff
changeset
|
240 int num_elementary_packetsPES=0; |
1 | 241 |
242 int demux_mpg_es_fill_buffer(demuxer_t *demux){ | |
243 // Elementary video stream | |
244 if(demux->stream->eof) return 0; | |
245 demux->filepos=stream_tell(demux->stream); | |
1735 | 246 ds_read_packet(demux->video,demux->stream,STREAM_BUFFER_SIZE,0,demux->filepos,0); |
1 | 247 return 1; |
248 } | |
249 | |
250 int demux_mpg_fill_buffer(demuxer_t *demux){ | |
251 unsigned int head=0; | |
252 int skipped=0; | |
253 int max_packs=128; | |
254 int ret=0; | |
255 | |
256 // System stream | |
257 do{ | |
258 demux->filepos=stream_tell(demux->stream); | |
259 head=stream_read_dword(demux->stream); | |
547 | 260 if((head&0xFFFFFF00)!=0x100){ |
261 // sync... | |
262 demux->filepos-=skipped; | |
263 while(1){ | |
536 | 264 int c=stream_read_char(demux->stream); |
265 if(c<0) break; //EOF | |
266 head<<=8; | |
267 if(head!=0x100){ | |
268 head|=c; | |
269 ++skipped; //++demux->filepos; | |
270 continue; | |
271 } | |
272 head|=c; | |
273 break; | |
547 | 274 } |
275 demux->filepos+=skipped; | |
1 | 276 } |
277 if(stream_eof(demux->stream)) break; | |
278 // sure: head=0x000001XX | |
1567 | 279 mp_dbg(MSGT_DEMUX,MSGL_DBG4,"*** head=0x%X\n",head); |
1 | 280 if(demux->synced==0){ |
3770 | 281 if(head==0x1BA) demux->synced=1; //else |
282 // if(head==0x1BD || (head>=0x1C0 && head<=0x1EF)) demux->synced=3; // PES? | |
1 | 283 } else |
284 if(demux->synced==1){ | |
929 | 285 if(head==0x1BB || head==0x1BD || (head>=0x1C0 && head<=0x1EF)){ |
1 | 286 demux->synced=2; |
1567 | 287 mp_msg(MSGT_DEMUX,MSGL_V,"system stream synced at 0x%X (%d)!\n",demux->filepos,demux->filepos); |
536 | 288 num_elementary_packets100=0; // requires for re-sync! |
289 num_elementary_packets101=0; // requires for re-sync! | |
1 | 290 } else demux->synced=0; |
291 } // else | |
3255
ee28577dad02
combined PS/PES sync to allow .VDR playback from stdin
arpi
parents:
2555
diff
changeset
|
292 if(demux->synced>=2){ |
1 | 293 ret=demux_mpg_read_packet(demux,head); |
294 if(!ret) | |
295 if(--max_packs==0){ | |
296 demux->stream->eof=1; | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1735
diff
changeset
|
297 mp_msg(MSGT_DEMUX,MSGL_ERR,MSGTR_DoesntContainSelectedStream); |
1 | 298 return 0; |
299 } | |
3255
ee28577dad02
combined PS/PES sync to allow .VDR playback from stdin
arpi
parents:
2555
diff
changeset
|
300 if(demux->synced==3) demux->synced=(ret==1)?2:0; // PES detect |
1 | 301 } else { |
302 if(head>=0x100 && head<0x1B0){ | |
1162 | 303 if(head==0x100) ++num_elementary_packets100; else |
304 if(head==0x101) ++num_elementary_packets101; | |
1567 | 305 mp_msg(MSGT_DEMUX,MSGL_DBG3,"Opps... elementary video packet found: %03X\n",head); |
1162 | 306 } else |
1338
345585097137
mpeg PES steram support (only 1E0 & 1C0 packets, no 1BA/1BB headers)
arpi
parents:
1331
diff
changeset
|
307 if(head>=0x1C0 && head<0x1F0){ |
345585097137
mpeg PES steram support (only 1E0 & 1C0 packets, no 1BA/1BB headers)
arpi
parents:
1331
diff
changeset
|
308 ++num_elementary_packetsPES; |
1567 | 309 mp_msg(MSGT_DEMUX,MSGL_DBG3,"Opps... PES packet found: %03X\n",head); |
1338
345585097137
mpeg PES steram support (only 1E0 & 1C0 packets, no 1BA/1BB headers)
arpi
parents:
1331
diff
changeset
|
310 } else |
1162 | 311 if(head==0x1B6) ++num_elementary_packets1B6; |
1 | 312 #if 1 |
1338
345585097137
mpeg PES steram support (only 1E0 & 1C0 packets, no 1BA/1BB headers)
arpi
parents:
1331
diff
changeset
|
313 if( ( (num_elementary_packets100>50 && num_elementary_packets101>50) || |
345585097137
mpeg PES steram support (only 1E0 & 1C0 packets, no 1BA/1BB headers)
arpi
parents:
1331
diff
changeset
|
314 (num_elementary_packetsPES>50) ) && skipped>4000000){ |
1567 | 315 mp_msg(MSGT_DEMUX,MSGL_V,"sync_mpeg_ps: seems to be ES/PES stream...\n"); |
1 | 316 demux->stream->eof=1; |
317 break; | |
318 } | |
319 #endif | |
320 } | |
321 } while(ret!=1); | |
1567 | 322 mp_dbg(MSGT_DEMUX,MSGL_DBG2,"demux: %d bad bytes skipped\n",skipped); |
1 | 323 if(demux->stream->eof){ |
1567 | 324 mp_msg(MSGT_DEMUX,MSGL_V,"MPEG Stream reached EOF\n"); |
1 | 325 return 0; |
326 } | |
327 return 1; | |
328 } | |
329 | |
1497
ad4d402b3d29
seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents:
1466
diff
changeset
|
330 //extern off_t seek_to_byte; |
1466 | 331 |
332 void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,int flags){ | |
333 demux_stream_t *d_audio=demuxer->audio; | |
334 demux_stream_t *d_video=demuxer->video; | |
335 sh_audio_t *sh_audio=d_audio->sh; | |
336 sh_video_t *sh_video=d_video->sh; | |
337 | |
338 //================= seek in MPEG ========================== | |
1628
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
339 off_t newpos=(flags&1)?demuxer->movi_start:demuxer->filepos; |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
340 |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
341 if(flags&2){ |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
342 // float seek 0..1 |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
343 newpos+=(demuxer->movi_end-demuxer->movi_start)*rel_seek_secs; |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
344 } else { |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
345 // time seek (secs) |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
346 if(!sh_video->i_bps) // unspecified or VBR |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
347 newpos+=2324*75*rel_seek_secs; // 174.3 kbyte/sec |
1466 | 348 else |
1628
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
349 newpos+=sh_video->i_bps*rel_seek_secs; |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
350 } |
1466 | 351 |
1628
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
352 if(newpos<demuxer->movi_start) newpos=demuxer->movi_start; |
bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents:
1597
diff
changeset
|
353 |
1466 | 354 #ifdef _LARGEFILE_SOURCE |
355 newpos&=~((long long)STREAM_BUFFER_SIZE-1); /* sector boundary */ | |
356 #else | |
357 newpos&=~(STREAM_BUFFER_SIZE-1); /* sector boundary */ | |
358 #endif | |
359 stream_seek(demuxer->stream,newpos); | |
360 | |
361 // re-sync video: | |
362 videobuf_code_len=0; // reset ES stream buffer | |
363 | |
364 ds_fill_buffer(d_video); | |
365 if(sh_audio){ | |
366 ds_fill_buffer(d_audio); | |
367 resync_audio_stream(sh_audio); | |
368 } | |
369 | |
370 while(1){ | |
371 int i; | |
372 if(sh_audio && !d_audio->eof && d_video->pts && d_audio->pts){ | |
373 float a_pts=d_audio->pts; | |
374 a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; | |
375 if(d_video->pts>a_pts){ | |
376 skip_audio_frame(sh_audio); // sync audio | |
377 continue; | |
378 } | |
379 } | |
380 i=sync_video_packet(d_video); | |
381 if(i==0x1B3 || i==0x1B8) break; // found it! | |
382 if(!i || !skip_video_packet(d_video)) break; // EOF? | |
383 } | |
384 | |
385 | |
386 } | |
387 |