16 #include "stream/stream.h"
22 /* sub_cc (closed captions)*/
25 /* biCompression constant */
29 #include "demux_rtp.h"
32 static mp_mpeg_header_t picture
;
34 static int telecine
=0;
35 static float telecine_cnt
=-2.5;
45 static video_codec_t
find_video_codec(sh_video_t
*sh_video
)
47 demux_stream_t
*d_video
=sh_video
->ds
;
48 int fmt
= d_video
->demuxer
->file_format
;
51 (fmt
== DEMUXER_TYPE_PVA
) ||
52 (fmt
== DEMUXER_TYPE_MPEG_ES
) ||
53 (fmt
== DEMUXER_TYPE_MPEG_GXF
) ||
54 (fmt
== DEMUXER_TYPE_MPEG_PES
) ||
56 (fmt
== DEMUXER_TYPE_MPEG_PS
|| fmt
== DEMUXER_TYPE_MPEG_TS
) &&
57 ((! sh_video
->format
) || (sh_video
->format
==0x10000001) || (sh_video
->format
==0x10000002))
59 (fmt
== DEMUXER_TYPE_MPEG_TY
)
61 || ((fmt
== DEMUXER_TYPE_RTP
) && demux_is_mpeg_rtp_stream(d_video
->demuxer
))
65 else if((fmt
== DEMUXER_TYPE_MPEG4_ES
) ||
66 ((fmt
== DEMUXER_TYPE_MPEG_TS
) && (sh_video
->format
==0x10000004)) ||
67 ((fmt
== DEMUXER_TYPE_MPEG_PS
) && (sh_video
->format
==0x10000004))
70 else if((fmt
== DEMUXER_TYPE_H264_ES
) ||
71 ((fmt
== DEMUXER_TYPE_MPEG_TS
) && (sh_video
->format
==0x10000005)) ||
72 ((fmt
== DEMUXER_TYPE_MPEG_PS
) && (sh_video
->format
==0x10000005))
75 else if((fmt
== DEMUXER_TYPE_MPEG_PS
|| fmt
== DEMUXER_TYPE_MPEG_TS
) &&
76 (sh_video
->format
==mmioFOURCC('W', 'V', 'C', '1')))
78 else if (fmt
== DEMUXER_TYPE_ASF
&& sh_video
->bih
&& sh_video
->bih
->biCompression
== mmioFOURCC('D', 'V', 'R', ' '))
84 int video_read_properties(sh_video_t
*sh_video
){
85 demux_stream_t
*d_video
=sh_video
->ds
;
86 video_codec_t video_codec
= find_video_codec(sh_video
);
87 // Determine image properties:
90 if((d_video
->demuxer
->file_format
== DEMUXER_TYPE_ASF
) || (d_video
->demuxer
->file_format
== DEMUXER_TYPE_AVI
)) {
92 // in case no strf chunk has been seen in avi, we have no bitmap header
93 if(!sh_video
->bih
) return 0;
94 sh_video
->format
=sh_video
->bih
->biCompression
;
95 sh_video
->disp_w
=sh_video
->bih
->biWidth
;
96 sh_video
->disp_h
=abs(sh_video
->bih
->biHeight
);
101 int pos
= 0, vop_cnt
=0, units
[3];
102 videobuf_len
=0; videobuf_code_len
=0;
103 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for Video Object Start code... ");
105 int i
=sync_video_packet(d_video
);
106 if(i
<=0x11F) break; // found it!
107 if(!i
|| !skip_video_packet(d_video
)){
108 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
112 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
114 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ MP_INPUT_BUFFER_PADDING_SIZE
);
115 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, MP_INPUT_BUFFER_PADDING_SIZE
);
117 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
121 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for Video Object Layer Start code... ");
123 int i
=sync_video_packet(d_video
);
124 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"M4V: 0x%X\n",i
);
125 if(i
>=0x120 && i
<=0x12F) break; // found it!
126 if(!i
|| !read_video_packet(d_video
)){
127 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
131 pos
= videobuf_len
+4;
132 if(!read_video_packet(d_video
)){
133 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Can't read Video Object Layer Header\n");
136 mp4_header_process_vol(&picture
, &(videobuffer
[pos
]));
137 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK! FPS SEEMS TO BE %.3f\nSearching for Video Object Plane Start code... ", sh_video
->fps
);
140 int i
=sync_video_packet(d_video
);
141 if(i
==0x1B6) break; // found it!
142 if(!i
|| !read_video_packet(d_video
)){
143 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
147 pos
= videobuf_len
+4;
148 if(!read_video_packet(d_video
)){
149 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Can't read Video Object Plane Header\n");
152 mp4_header_process_vop(&picture
, &(videobuffer
[pos
]));
153 units
[vop_cnt
] = picture
.timeinc_unit
;
155 //mp_msg(MSGT_DECVIDEO,MSGL_V, "TYPE: %d, unit: %d\n", picture.picture_type, picture.timeinc_unit);
157 int i
, mn
, md
, mx
, diff
;
171 if((units
[i
] > mn
) && (units
[i
] < mx
))
174 mp_msg(MSGT_DECVIDEO
,MSGL_V
, "MIN: %d, mid: %d, max: %d\n", mn
, md
, mx
);
175 if(mx
- md
> md
- mn
)
180 picture
.fps
= ((float)picture
.timeinc_resolution
) / diff
;
181 mp_msg(MSGT_DECVIDEO
,MSGL_V
, "FPS seems to be: %f, resolution: %d, delta_units: %d\n", picture
.fps
, picture
.timeinc_resolution
, diff
);
185 sh_video
->fps
=picture
.fps
;
186 sh_video
->frametime
=1.0/picture
.fps
;
187 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
, "FPS seems to be: %f\n", picture
.fps
);
189 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
190 sh_video
->format
=0x10000004;
195 videobuf_len
=0; videobuf_code_len
=0;
196 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for sequence parameter set... ");
198 int i
=sync_video_packet(d_video
);
199 if((i
&~0x60) == 0x107 && i
!= 0x107) break; // found it!
200 if(!i
|| !skip_video_packet(d_video
)){
201 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
205 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
207 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ MP_INPUT_BUFFER_PADDING_SIZE
);
208 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, MP_INPUT_BUFFER_PADDING_SIZE
);
210 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
214 pos
= videobuf_len
+4;
215 if(!read_video_packet(d_video
)){
216 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Can't read sequence parameter set\n");
219 h264_parse_sps(&picture
, &(videobuffer
[pos
]), videobuf_len
- pos
);
220 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for picture parameter set... ");
222 int i
=sync_video_packet(d_video
);
223 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"H264: 0x%X\n",i
);
224 if((i
&~0x60) == 0x108 && i
!= 0x108) break; // found it!
225 if(!i
|| !read_video_packet(d_video
)){
226 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
230 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\nSearching for Slice... ");
232 int i
=sync_video_packet(d_video
);
233 if((i
&~0x60) == 0x101 || (i
&~0x60) == 0x102 || (i
&~0x60) == 0x105) break; // found it!
234 if(!i
|| !read_video_packet(d_video
)){
235 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
239 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
240 sh_video
->format
=0x10000005;
242 sh_video
->fps
=picture
.fps
;
243 sh_video
->frametime
=1.0/picture
.fps
;
244 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
, "FPS seems to be: %f\n", picture
.fps
);
249 if (d_video
->demuxer
->file_format
== DEMUXER_TYPE_ASF
) { // DVR-MS
250 if(!sh_video
->bih
) return 0;
251 sh_video
->format
=sh_video
->bih
->biCompression
;
254 // Find sequence_header first:
255 videobuf_len
=0; videobuf_code_len
=0;
256 telecine
=0; telecine_cnt
=-2.5;
257 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for sequence header... ");
259 int i
=sync_video_packet(d_video
);
260 if(i
==0x1B3) break; // found it!
261 if(!i
|| !skip_video_packet(d_video
)){
262 if( mp_msg_test(MSGT_DECVIDEO
,MSGL_V
) ) mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
263 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_MpegNoSequHdr
);
267 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
268 // ========= Read & process sequence header & extension ============
270 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ MP_INPUT_BUFFER_PADDING_SIZE
);
271 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, MP_INPUT_BUFFER_PADDING_SIZE
);
273 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
278 if(!read_video_packet(d_video
)){
279 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_CannotReadMpegSequHdr
);
282 if(mp_header_process_sequence_header (&picture
, &videobuffer
[4])) {
283 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_BadMpegSequHdr
);
284 goto mpeg_header_parser
;
286 if(sync_video_packet(d_video
)==0x1B5){ // next packet is seq. ext.
287 int pos
=videobuf_len
;
288 if(!read_video_packet(d_video
)){
289 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_CannotReadMpegSequHdrEx
);
292 if(mp_header_process_extension (&picture
, &videobuffer
[pos
+4])) {
293 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_BadMpegSequHdrEx
);
299 sh_video
->format
=picture
.mpeg1
?0x10000001:0x10000002; // mpeg video
300 sh_video
->fps
=picture
.fps
;
302 sh_video
->frametime
=0;
304 sh_video
->frametime
=1.0/picture
.fps
;
306 sh_video
->disp_w
=picture
.display_picture_width
;
307 sh_video
->disp_h
=picture
.display_picture_height
;
309 if(picture
.bitrate
!=0x3FFFF) // unspecified/VBR ?
310 sh_video
->i_bps
=picture
.bitrate
* 400 / 8;
312 mp_dbg(MSGT_DECVIDEO
,MSGL_DBG2
,"mpeg bitrate: %d (%X)\n",picture
.bitrate
,picture
.bitrate
);
313 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"VIDEO: %s %dx%d (aspect %d) %5.3f fps %5.1f kbps (%4.1f kbyte/s)\n",
314 picture
.mpeg1
?"MPEG1":"MPEG2",
315 sh_video
->disp_w
,sh_video
->disp_h
,
316 picture
.aspect_ratio_information
,
318 sh_video
->i_bps
* 8 / 1000.0,
319 sh_video
->i_bps
/ 1000.0 );
323 // Find sequence_header:
326 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"Searching for VC1 sequence header... ");
328 int i
=sync_video_packet(d_video
);
329 if(i
==0x10F) break; // found it!
330 if(!i
|| !skip_video_packet(d_video
)){
331 if( mp_msg_test(MSGT_DECVIDEO
,MSGL_V
) ) mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
332 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
, "Couldn't find VC-1 sequence header\n");
336 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"found\n");
338 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ MP_INPUT_BUFFER_PADDING_SIZE
);
339 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, MP_INPUT_BUFFER_PADDING_SIZE
);
341 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
345 if(!read_video_packet(d_video
)){
346 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
, "Couldn't read VC-1 sequence header!\n");
351 int i
=sync_video_packet(d_video
);
352 if(i
==0x10E) break; // found it!
353 if(!i
|| !skip_video_packet(d_video
)){
354 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Couldn't find VC-1 entry point sync-code:(\n");
358 if(!read_video_packet(d_video
)){
359 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Couldn't read VC-1 entry point sync-code:(\n");
363 if(mp_vc1_decode_sequence_header(&picture
, &videobuffer
[4], videobuf_len
-4)) {
364 sh_video
->bih
= (BITMAPINFOHEADER
*) calloc(1, sizeof(BITMAPINFOHEADER
) + videobuf_len
);
365 if(sh_video
->bih
== NULL
) {
366 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Couldn't alloc %d bytes for VC-1 extradata!\n", sizeof(BITMAPINFOHEADER
) + videobuf_len
);
369 sh_video
->bih
->biSize
= sizeof(BITMAPINFOHEADER
) + videobuf_len
;
370 memcpy(sh_video
->bih
+ 1, videobuffer
, videobuf_len
);
371 sh_video
->bih
->biCompression
= sh_video
->format
;
372 sh_video
->bih
->biWidth
= sh_video
->disp_w
= picture
.display_picture_width
;
373 sh_video
->bih
->biHeight
= sh_video
->disp_h
= picture
.display_picture_height
;
374 if(picture
.fps
> 0) {
375 sh_video
->frametime
=1.0/picture
.fps
;
376 sh_video
->fps
= picture
.fps
;
378 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"VIDEO: VC-1 %dx%d, %5.3f fps, header len: %d\n",
379 sh_video
->disp_w
, sh_video
->disp_h
, sh_video
->fps
, videobuf_len
);
383 } // switch(file_format)
388 void ty_processuserdata( unsigned char* buf
, int len
);
390 static void process_userdata(unsigned char* buf
,int len
){
392 /* if the user data starts with "CC", assume it is a CC info packet */
393 if(len
>2 && buf
[0]=='C' && buf
[1]=='C'){
394 // mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"video.c: process_userdata() detected Closed Captions!\n");
395 subcc_process_data(buf
+2,len
-2);
397 if( len
> 2 && buf
[ 0 ] == 'T' && buf
[ 1 ] == 'Y' )
399 ty_processuserdata( buf
+ 2, len
- 2 );
402 if(verbose
<2) return;
403 fprintf(stderr
, "user_data: len=%3d %02X %02X %02X %02X '",
404 len
, buf
[0], buf
[1], buf
[2], buf
[3]);
406 // if(buf[i]>=32 && buf[i]<127) fputc(buf[i], stderr);
407 if(buf
[i
]&0x60) fputc(buf
[i
]&0x7F, stderr
);
408 fprintf(stderr
, "'\n");
411 int video_read_frame(sh_video_t
* sh_video
,float* frame_time_ptr
,unsigned char** start
,int force_fps
){
412 demux_stream_t
*d_video
=sh_video
->ds
;
413 demuxer_t
*demuxer
=d_video
->demuxer
;
415 float pts1
=d_video
->pts
;
417 int picture_coding_type
=0;
419 video_codec_t video_codec
= find_video_codec(sh_video
);
423 if(video_codec
== VIDEO_MPEG12
){
427 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
){
428 int i
=sync_video_packet(d_video
);
429 //void* buffer=&videobuffer[videobuf_len+4];
430 int start
=videobuf_len
+4;
432 if(i
<0x101 || i
>=0x1B0){ // not slice code -> end of frame
433 if(!i
) return -1; // EOF
441 if(i
>=0x101 && i
<0x1B0) in_frame
=1; // picture startcode
442 else if(!i
) return -1; // EOF
444 if(!read_video_packet(d_video
)) return -1; // EOF
447 case 0x1B3: mp_header_process_sequence_header (&picture
, &videobuffer
[start
]);break;
448 case 0x1B5: mp_header_process_extension (&picture
, &videobuffer
[start
]);break;
449 case 0x1B2: process_userdata (&videobuffer
[start
], videobuf_len
-start
);break;
450 case 0x100: picture_coding_type
=(videobuffer
[start
+1] >> 3) & 7;break;
454 *start
=videobuffer
; in_size
=videobuf_len
;
457 if(sh_video
->fps
!=picture
.fps
) if(!force_fps
&& !telecine
){
458 mp_msg(MSGT_CPLAYER
,MSGL_WARN
,"Warning! FPS changed %5.3f -> %5.3f (%f) [%d] \n",sh_video
->fps
,picture
.fps
,sh_video
->fps
-picture
.fps
,picture
.frame_rate_code
);
459 sh_video
->fps
=picture
.fps
;
460 sh_video
->frametime
=1.0/picture
.fps
;
463 // fix mpeg2 frametime:
464 frame_time
=(picture
.display_time
)*0.01f
;
465 picture
.display_time
=100;
468 telecine_cnt
*=0.9; // drift out error
469 telecine_cnt
+=frame_time
-5.0/4.0;
470 mp_msg(MSGT_DECVIDEO
,MSGL_DBG2
,"\r telecine = %3.1f %5.3f \n",frame_time
,telecine_cnt
);
474 if(telecine_cnt
<-1.5 || telecine_cnt
>1.5){
475 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,MSGTR_LeaveTelecineMode
);
479 if(telecine_cnt
>-0.5 && telecine_cnt
<0.5 && !force_fps
){
480 sh_video
->fps
=sh_video
->fps
*4/5;
481 sh_video
->frametime
=sh_video
->frametime
*5/4;
482 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,MSGTR_EnterTelecineMode
);
485 } else if(video_codec
== VIDEO_MPEG4
){
486 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
){
487 int i
=sync_video_packet(d_video
);
489 if(!read_video_packet(d_video
)) return -1; // EOF
492 *start
=videobuffer
; in_size
=videobuf_len
;
494 } else if(video_codec
== VIDEO_H264
){
496 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
){
497 int i
=sync_video_packet(d_video
);
498 int pos
= videobuf_len
+4;
500 if(!read_video_packet(d_video
)) return -1; // EOF
501 if((i
&~0x60) == 0x107 && i
!= 0x107) {
502 h264_parse_sps(&picture
, &(videobuffer
[pos
]), videobuf_len
- pos
);
503 if(picture
.fps
> 0) {
504 sh_video
->fps
=picture
.fps
;
505 sh_video
->frametime
=1.0/picture
.fps
;
507 i
=sync_video_packet(d_video
);
509 if(!read_video_packet(d_video
)) return -1; // EOF
512 // here starts the access unit end detection code
513 // see the mail on MPlayer-dev-eng for details:
514 // Date: Sat, 17 Sep 2005 11:24:06 +0200
515 // Subject: Re: [MPlayer-dev-eng] [RFC] h264 ES parser problems
516 // Message-ID: <20050917092406.GA7699@rz.uni-karlsruhe.de>
517 if((i
&~0x60) == 0x101 || (i
&~0x60) == 0x102 || (i
&~0x60) == 0x105)
518 // found VCL NAL with slice header i.e. start of current primary coded
519 // picture, so start scanning for the end now
522 i
= sync_video_packet(d_video
) & ~0x60; // code of next packet
523 if(i
== 0x106 || i
== 0x109) break; // SEI or access unit delim.
524 if(i
== 0x101 || i
== 0x102 || i
== 0x105) {
525 // assuming arbitrary slice ordering is not allowed, the
526 // first_mb_in_slice (golomb encoded) value should be 0 then
527 // for the first VCL NAL in a picture
528 if (demux_peekc(d_video
) & 0x80)
533 *start
=videobuffer
; in_size
=videobuf_len
;
535 } else if(video_codec
== VIDEO_VC1
) {
536 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
) {
537 int i
=sync_video_packet(d_video
);
539 if(!read_video_packet(d_video
)) return -1; // EOF
543 in_size
=videobuf_len
;
546 // frame-based file formats: (AVI,ASF,MOV)
547 in_size
=ds_get_packet(d_video
,start
);
548 if(in_size
<0) return -1; // EOF
552 //------------------------ frame decoded. --------------------
554 // Increase video timers:
555 sh_video
->num_frames
+=frame_time
;
556 ++sh_video
->num_frames_decoded
;
558 frame_time
*=sh_video
->frametime
;
560 // override frame_time for variable/unknown FPS formats:
561 if(!force_fps
) switch(demuxer
->file_format
){
562 case DEMUXER_TYPE_GIF
:
563 case DEMUXER_TYPE_MATROSKA
:
564 case DEMUXER_TYPE_MNG
:
565 if(d_video
->pts
>0 && pts1
>0 && d_video
->pts
>pts1
)
566 frame_time
=d_video
->pts
-pts1
;
568 case DEMUXER_TYPE_TV
:
569 case DEMUXER_TYPE_MOV
:
570 case DEMUXER_TYPE_FILM
:
571 case DEMUXER_TYPE_VIVO
:
572 case DEMUXER_TYPE_OGG
:
573 case DEMUXER_TYPE_ASF
: {
574 double next_pts
= ds_get_next_pts(d_video
);
575 double d
= (next_pts
!= MP_NOPTS_VALUE
) ? next_pts
- d_video
->pts
: d_video
->pts
-pts1
;
578 if((int)sh_video
->fps
==1000)
579 mp_msg(MSGT_CPLAYER
,MSGL_V
,"\navg. framerate: %d fps \n",(int)(1.0f
/d
));
580 sh_video
->frametime
=d
; // 1ms
581 sh_video
->fps
=1.0f
/d
;
585 mp_msg(MSGT_CPLAYER
,MSGL_WARN
,"\nInvalid frame duration value (%5.3f/%5.3f => %5.3f). Defaulting to %5.3f sec.\n",d_video
->pts
,next_pts
,d
,frame_time
);
586 // frame_time = 1/25.0;
590 case DEMUXER_TYPE_LAVF
:
591 case DEMUXER_TYPE_LAVF_PREFERRED
:
592 if((int)sh_video
->fps
==1000 || (int)sh_video
->fps
<=1){
593 double next_pts
= ds_get_next_pts(d_video
);
594 double d
= (next_pts
!= MP_NOPTS_VALUE
) ? next_pts
- d_video
->pts
: d_video
->pts
-pts1
;
600 case DEMUXER_TYPE_REAL
:
602 double next_pts
= ds_get_next_pts(d_video
);
603 double d
= (next_pts
!= MP_NOPTS_VALUE
) ? next_pts
- d_video
->pts
: d_video
->pts
- pts1
;
605 frame_time
= (d
>= 0 && pts1
> 0) ? d
: 0.001;
610 if(video_codec
== VIDEO_MPEG12
){
611 sh_video
->pts
+=frame_time
;
612 if(picture_coding_type
==1)
614 if(picture_coding_type
<=2 && sh_video
->i_pts
){
615 sh_video
->pts
=sh_video
->i_pts
;
619 if(picture_coding_type
<=2) sh_video
->i_pts
=pts
;
620 else sh_video
->pts
=pts
;
624 sh_video
->pts
=d_video
->pts
;
626 if(frame_time_ptr
) *frame_time_ptr
=frame_time
;