16 #include "stream/stream.h"
22 /* sub_cc (closed captions)*/
26 #include "libavcodec/avcodec.h"
28 #define FF_INPUT_BUFFER_PADDING_SIZE 8
31 /* biCompression constant */
34 #ifdef STREAMING_LIVE555
35 #include "demux_rtp.h"
38 static mp_mpeg_header_t picture
;
40 static int telecine
=0;
41 static float telecine_cnt
=-2.5;
51 static video_codec_t
find_video_codec(sh_video_t
*sh_video
)
53 demux_stream_t
*d_video
=sh_video
->ds
;
54 int fmt
= d_video
->demuxer
->file_format
;
57 (fmt
== DEMUXER_TYPE_PVA
) ||
58 (fmt
== DEMUXER_TYPE_MPEG_ES
) ||
59 (fmt
== DEMUXER_TYPE_MPEG_GXF
) ||
60 (fmt
== DEMUXER_TYPE_MPEG_PES
) ||
62 (fmt
== DEMUXER_TYPE_MPEG_PS
|| fmt
== DEMUXER_TYPE_MPEG_TS
) &&
63 ((! sh_video
->format
) || (sh_video
->format
==0x10000001) || (sh_video
->format
==0x10000002))
65 (fmt
== DEMUXER_TYPE_MPEG_TY
)
66 #ifdef STREAMING_LIVE555
67 || ((fmt
== DEMUXER_TYPE_RTP
) && demux_is_mpeg_rtp_stream(d_video
->demuxer
))
71 else if((fmt
== DEMUXER_TYPE_MPEG4_ES
) ||
72 ((fmt
== DEMUXER_TYPE_MPEG_TS
) && (sh_video
->format
==0x10000004)) ||
73 ((fmt
== DEMUXER_TYPE_MPEG_PS
) && (sh_video
->format
==0x10000004))
76 else if((fmt
== DEMUXER_TYPE_H264_ES
) ||
77 ((fmt
== DEMUXER_TYPE_MPEG_TS
) && (sh_video
->format
==0x10000005)) ||
78 ((fmt
== DEMUXER_TYPE_MPEG_PS
) && (sh_video
->format
==0x10000005))
81 else if((fmt
== DEMUXER_TYPE_MPEG_PS
|| fmt
== DEMUXER_TYPE_MPEG_TS
) &&
82 (sh_video
->format
==mmioFOURCC('W', 'V', 'C', '1')))
84 else if (fmt
== DEMUXER_TYPE_ASF
&& sh_video
->bih
&& sh_video
->bih
->biCompression
== mmioFOURCC('D', 'V', 'R', ' '))
90 int video_read_properties(sh_video_t
*sh_video
){
91 demux_stream_t
*d_video
=sh_video
->ds
;
92 video_codec_t video_codec
= find_video_codec(sh_video
);
93 // Determine image properties:
96 if((d_video
->demuxer
->file_format
== DEMUXER_TYPE_ASF
) || (d_video
->demuxer
->file_format
== DEMUXER_TYPE_AVI
)) {
98 // in case no strf chunk has been seen in avi, we have no bitmap header
99 if(!sh_video
->bih
) return 0;
100 sh_video
->format
=sh_video
->bih
->biCompression
;
101 sh_video
->disp_w
=sh_video
->bih
->biWidth
;
102 sh_video
->disp_h
=abs(sh_video
->bih
->biHeight
);
107 int pos
= 0, vop_cnt
=0, units
[3];
108 videobuf_len
=0; videobuf_code_len
=0;
109 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for Video Object Start code... ");
111 int i
=sync_video_packet(d_video
);
112 if(i
<=0x11F) break; // found it!
113 if(!i
|| !skip_video_packet(d_video
)){
114 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
118 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
120 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ FF_INPUT_BUFFER_PADDING_SIZE
);
121 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, FF_INPUT_BUFFER_PADDING_SIZE
);
123 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
127 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for Video Object Layer Start code... ");
129 int i
=sync_video_packet(d_video
);
130 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"M4V: 0x%X\n",i
);
131 if(i
>=0x120 && i
<=0x12F) break; // found it!
132 if(!i
|| !read_video_packet(d_video
)){
133 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
137 pos
= videobuf_len
+4;
138 if(!read_video_packet(d_video
)){
139 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Can't read Video Object Layer Header\n");
142 mp4_header_process_vol(&picture
, &(videobuffer
[pos
]));
143 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK! FPS SEEMS TO BE %.3f\nSearching for Video Object Plane Start code... ", sh_video
->fps
);
146 int i
=sync_video_packet(d_video
);
147 if(i
==0x1B6) break; // found it!
148 if(!i
|| !read_video_packet(d_video
)){
149 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
153 pos
= videobuf_len
+4;
154 if(!read_video_packet(d_video
)){
155 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Can't read Video Object Plane Header\n");
158 mp4_header_process_vop(&picture
, &(videobuffer
[pos
]));
159 units
[vop_cnt
] = picture
.timeinc_unit
;
161 //mp_msg(MSGT_DECVIDEO,MSGL_V, "TYPE: %d, unit: %d\n", picture.picture_type, picture.timeinc_unit);
163 int i
, mn
, md
, mx
, diff
;
177 if((units
[i
] > mn
) && (units
[i
] < mx
))
180 mp_msg(MSGT_DECVIDEO
,MSGL_V
, "MIN: %d, mid: %d, max: %d\n", mn
, md
, mx
);
181 if(mx
- md
> md
- mn
)
186 picture
.fps
= ((float)picture
.timeinc_resolution
) / diff
;
187 mp_msg(MSGT_DECVIDEO
,MSGL_V
, "FPS seems to be: %f, resolution: %d, delta_units: %d\n", picture
.fps
, picture
.timeinc_resolution
, diff
);
191 sh_video
->fps
=picture
.fps
;
192 sh_video
->frametime
=1.0/picture
.fps
;
193 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
, "FPS seems to be: %f\n", picture
.fps
);
195 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
196 sh_video
->format
=0x10000004;
201 videobuf_len
=0; videobuf_code_len
=0;
202 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for sequence parameter set... ");
204 int i
=sync_video_packet(d_video
);
205 if((i
&~0x60) == 0x107 && i
!= 0x107) break; // found it!
206 if(!i
|| !skip_video_packet(d_video
)){
207 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
211 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
213 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ FF_INPUT_BUFFER_PADDING_SIZE
);
214 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, FF_INPUT_BUFFER_PADDING_SIZE
);
216 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
220 pos
= videobuf_len
+4;
221 if(!read_video_packet(d_video
)){
222 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Can't read sequence parameter set\n");
225 h264_parse_sps(&picture
, &(videobuffer
[pos
]), videobuf_len
- pos
);
226 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for picture parameter set... ");
228 int i
=sync_video_packet(d_video
);
229 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"H264: 0x%X\n",i
);
230 if((i
&~0x60) == 0x108 && i
!= 0x108) break; // found it!
231 if(!i
|| !read_video_packet(d_video
)){
232 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
236 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\nSearching for Slice... ");
238 int i
=sync_video_packet(d_video
);
239 if((i
&~0x60) == 0x101 || (i
&~0x60) == 0x102 || (i
&~0x60) == 0x105) break; // found it!
240 if(!i
|| !read_video_packet(d_video
)){
241 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
245 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
246 sh_video
->format
=0x10000005;
248 sh_video
->fps
=picture
.fps
;
249 sh_video
->frametime
=1.0/picture
.fps
;
250 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
, "FPS seems to be: %f\n", picture
.fps
);
255 if (d_video
->demuxer
->file_format
== DEMUXER_TYPE_ASF
) { // DVR-MS
256 if(!sh_video
->bih
) return 0;
257 sh_video
->format
=sh_video
->bih
->biCompression
;
260 // Find sequence_header first:
261 videobuf_len
=0; videobuf_code_len
=0;
262 telecine
=0; telecine_cnt
=-2.5;
263 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for sequence header... ");
265 int i
=sync_video_packet(d_video
);
266 if(i
==0x1B3) break; // found it!
267 if(!i
|| !skip_video_packet(d_video
)){
268 if( mp_msg_test(MSGT_DECVIDEO
,MSGL_V
) ) mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
269 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_MpegNoSequHdr
);
273 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
274 // ========= Read & process sequence header & extension ============
276 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ FF_INPUT_BUFFER_PADDING_SIZE
);
277 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, FF_INPUT_BUFFER_PADDING_SIZE
);
279 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
284 if(!read_video_packet(d_video
)){
285 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_CannotReadMpegSequHdr
);
288 if(mp_header_process_sequence_header (&picture
, &videobuffer
[4])) {
289 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_BadMpegSequHdr
);
290 goto mpeg_header_parser
;
292 if(sync_video_packet(d_video
)==0x1B5){ // next packet is seq. ext.
293 int pos
=videobuf_len
;
294 if(!read_video_packet(d_video
)){
295 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_CannotReadMpegSequHdrEx
);
298 if(mp_header_process_extension (&picture
, &videobuffer
[pos
+4])) {
299 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_BadMpegSequHdrEx
);
305 sh_video
->format
=picture
.mpeg1
?0x10000001:0x10000002; // mpeg video
306 sh_video
->fps
=picture
.fps
;
308 sh_video
->frametime
=0;
310 sh_video
->frametime
=1.0/picture
.fps
;
312 sh_video
->disp_w
=picture
.display_picture_width
;
313 sh_video
->disp_h
=picture
.display_picture_height
;
315 if(picture
.bitrate
!=0x3FFFF) // unspecified/VBR ?
316 sh_video
->i_bps
=picture
.bitrate
* 400 / 8;
318 mp_dbg(MSGT_DECVIDEO
,MSGL_DBG2
,"mpeg bitrate: %d (%X)\n",picture
.bitrate
,picture
.bitrate
);
319 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"VIDEO: %s %dx%d (aspect %d) %5.3f fps %5.1f kbps (%4.1f kbyte/s)\n",
320 picture
.mpeg1
?"MPEG1":"MPEG2",
321 sh_video
->disp_w
,sh_video
->disp_h
,
322 picture
.aspect_ratio_information
,
324 sh_video
->i_bps
* 8 / 1000.0,
325 sh_video
->i_bps
/ 1000.0 );
329 // Find sequence_header:
332 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"Searching for VC1 sequence header... ");
334 int i
=sync_video_packet(d_video
);
335 if(i
==0x10F) break; // found it!
336 if(!i
|| !skip_video_packet(d_video
)){
337 if( mp_msg_test(MSGT_DECVIDEO
,MSGL_V
) ) mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
338 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
, "Couldn't find VC-1 sequence header\n");
342 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"found\n");
344 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ FF_INPUT_BUFFER_PADDING_SIZE
);
345 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, FF_INPUT_BUFFER_PADDING_SIZE
);
347 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
351 if(!read_video_packet(d_video
)){
352 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
, "Couldn't read VC-1 sequence header!\n");
357 int i
=sync_video_packet(d_video
);
358 if(i
==0x10E) break; // found it!
359 if(!i
|| !skip_video_packet(d_video
)){
360 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Couldn't find VC-1 entry point sync-code:(\n");
364 if(!read_video_packet(d_video
)){
365 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Couldn't read VC-1 entry point sync-code:(\n");
369 if(mp_vc1_decode_sequence_header(&picture
, &videobuffer
[4], videobuf_len
-4)) {
370 sh_video
->bih
= (BITMAPINFOHEADER
*) calloc(1, sizeof(BITMAPINFOHEADER
) + videobuf_len
);
371 if(sh_video
->bih
== NULL
) {
372 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Couldn't alloc %d bytes for VC-1 extradata!\n", sizeof(BITMAPINFOHEADER
) + videobuf_len
);
375 sh_video
->bih
->biSize
= sizeof(BITMAPINFOHEADER
) + videobuf_len
;
376 memcpy(sh_video
->bih
+ 1, videobuffer
, videobuf_len
);
377 sh_video
->bih
->biCompression
= sh_video
->format
;
378 sh_video
->bih
->biWidth
= sh_video
->disp_w
= picture
.display_picture_width
;
379 sh_video
->bih
->biHeight
= sh_video
->disp_h
= picture
.display_picture_height
;
380 if(picture
.fps
> 0) {
381 sh_video
->frametime
=1.0/picture
.fps
;
382 sh_video
->fps
= picture
.fps
;
384 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"VIDEO: VC-1 %dx%d, %5.3f fps, header len: %d\n",
385 sh_video
->disp_w
, sh_video
->disp_h
, sh_video
->fps
, videobuf_len
);
389 } // switch(file_format)
394 void ty_processuserdata( unsigned char* buf
, int len
);
396 static void process_userdata(unsigned char* buf
,int len
){
398 /* if the user data starts with "CC", assume it is a CC info packet */
399 if(len
>2 && buf
[0]=='C' && buf
[1]=='C'){
400 // mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"video.c: process_userdata() detected Closed Captions!\n");
401 subcc_process_data(buf
+2,len
-2);
403 if( len
> 2 && buf
[ 0 ] == 'T' && buf
[ 1 ] == 'Y' )
405 ty_processuserdata( buf
+ 2, len
- 2 );
408 if(verbose
<2) return;
409 fprintf(stderr
, "user_data: len=%3d %02X %02X %02X %02X '",
410 len
, buf
[0], buf
[1], buf
[2], buf
[3]);
412 // if(buf[i]>=32 && buf[i]<127) fputc(buf[i], stderr);
413 if(buf
[i
]&0x60) fputc(buf
[i
]&0x7F, stderr
);
414 fprintf(stderr
, "'\n");
417 int video_read_frame(sh_video_t
* sh_video
,float* frame_time_ptr
,unsigned char** start
,int force_fps
){
418 demux_stream_t
*d_video
=sh_video
->ds
;
419 demuxer_t
*demuxer
=d_video
->demuxer
;
421 float pts1
=d_video
->pts
;
423 int picture_coding_type
=0;
425 video_codec_t video_codec
= find_video_codec(sh_video
);
429 if(video_codec
== VIDEO_MPEG12
){
433 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
){
434 int i
=sync_video_packet(d_video
);
435 //void* buffer=&videobuffer[videobuf_len+4];
436 int start
=videobuf_len
+4;
438 if(i
<0x101 || i
>=0x1B0){ // not slice code -> end of frame
439 if(!i
) return -1; // EOF
447 if(i
>=0x101 && i
<0x1B0) in_frame
=1; // picture startcode
448 else if(!i
) return -1; // EOF
450 if(!read_video_packet(d_video
)) return -1; // EOF
453 case 0x1B3: mp_header_process_sequence_header (&picture
, &videobuffer
[start
]);break;
454 case 0x1B5: mp_header_process_extension (&picture
, &videobuffer
[start
]);break;
455 case 0x1B2: process_userdata (&videobuffer
[start
], videobuf_len
-start
);break;
456 case 0x100: picture_coding_type
=(videobuffer
[start
+1] >> 3) & 7;break;
460 *start
=videobuffer
; in_size
=videobuf_len
;
463 if(sh_video
->fps
!=picture
.fps
) if(!force_fps
&& !telecine
){
464 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
);
465 sh_video
->fps
=picture
.fps
;
466 sh_video
->frametime
=1.0/picture
.fps
;
469 // fix mpeg2 frametime:
470 frame_time
=(picture
.display_time
)*0.01f
;
471 picture
.display_time
=100;
474 telecine_cnt
*=0.9; // drift out error
475 telecine_cnt
+=frame_time
-5.0/4.0;
476 mp_msg(MSGT_DECVIDEO
,MSGL_DBG2
,"\r telecine = %3.1f %5.3f \n",frame_time
,telecine_cnt
);
480 if(telecine_cnt
<-1.5 || telecine_cnt
>1.5){
481 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,MSGTR_LeaveTelecineMode
);
485 if(telecine_cnt
>-0.5 && telecine_cnt
<0.5 && !force_fps
){
486 sh_video
->fps
=sh_video
->fps
*4/5;
487 sh_video
->frametime
=sh_video
->frametime
*5/4;
488 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,MSGTR_EnterTelecineMode
);
491 } else if(video_codec
== VIDEO_MPEG4
){
492 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
){
493 int i
=sync_video_packet(d_video
);
495 if(!read_video_packet(d_video
)) return -1; // EOF
498 *start
=videobuffer
; in_size
=videobuf_len
;
500 } else if(video_codec
== VIDEO_H264
){
502 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
){
503 int i
=sync_video_packet(d_video
);
504 int pos
= videobuf_len
+4;
506 if(!read_video_packet(d_video
)) return -1; // EOF
507 if((i
&~0x60) == 0x107 && i
!= 0x107) {
508 h264_parse_sps(&picture
, &(videobuffer
[pos
]), videobuf_len
- pos
);
509 if(picture
.fps
> 0) {
510 sh_video
->fps
=picture
.fps
;
511 sh_video
->frametime
=1.0/picture
.fps
;
513 i
=sync_video_packet(d_video
);
515 if(!read_video_packet(d_video
)) return -1; // EOF
518 // here starts the access unit end detection code
519 // see the mail on MPlayer-dev-eng for details:
520 // Date: Sat, 17 Sep 2005 11:24:06 +0200
521 // Subject: Re: [MPlayer-dev-eng] [RFC] h264 ES parser problems
522 // Message-ID: <20050917092406.GA7699@rz.uni-karlsruhe.de>
523 if((i
&~0x60) == 0x101 || (i
&~0x60) == 0x102 || (i
&~0x60) == 0x105)
524 // found VCL NAL with slice header i.e. start of current primary coded
525 // picture, so start scanning for the end now
528 i
= sync_video_packet(d_video
) & ~0x60; // code of next packet
529 if(i
== 0x106 || i
== 0x109) break; // SEI or access unit delim.
530 if(i
== 0x101 || i
== 0x102 || i
== 0x105) {
531 // assuming arbitrary slice ordering is not allowed, the
532 // first_mb_in_slice (golomb encoded) value should be 0 then
533 // for the first VCL NAL in a picture
534 if (demux_peekc(d_video
) & 0x80)
539 *start
=videobuffer
; in_size
=videobuf_len
;
541 } else if(video_codec
== VIDEO_VC1
) {
542 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
) {
543 int i
=sync_video_packet(d_video
);
545 if(!read_video_packet(d_video
)) return -1; // EOF
549 in_size
=videobuf_len
;
552 // frame-based file formats: (AVI,ASF,MOV)
553 in_size
=ds_get_packet(d_video
,start
);
554 if(in_size
<0) return -1; // EOF
558 //------------------------ frame decoded. --------------------
560 // Increase video timers:
561 sh_video
->num_frames
+=frame_time
;
562 ++sh_video
->num_frames_decoded
;
564 frame_time
*=sh_video
->frametime
;
566 // override frame_time for variable/unknown FPS formats:
567 if(!force_fps
) switch(demuxer
->file_format
){
568 case DEMUXER_TYPE_GIF
:
569 case DEMUXER_TYPE_MATROSKA
:
570 if(d_video
->pts
>0 && pts1
>0 && d_video
->pts
>pts1
)
571 frame_time
=d_video
->pts
-pts1
;
573 case DEMUXER_TYPE_TV
:
574 case DEMUXER_TYPE_MOV
:
575 case DEMUXER_TYPE_FILM
:
576 case DEMUXER_TYPE_VIVO
:
577 case DEMUXER_TYPE_OGG
:
578 case DEMUXER_TYPE_ASF
: {
579 double next_pts
= ds_get_next_pts(d_video
);
580 double d
= (next_pts
!= MP_NOPTS_VALUE
) ? next_pts
- d_video
->pts
: d_video
->pts
-pts1
;
583 if((int)sh_video
->fps
==1000)
584 mp_msg(MSGT_CPLAYER
,MSGL_V
,"\navg. framerate: %d fps \n",(int)(1.0f
/d
));
585 sh_video
->frametime
=d
; // 1ms
586 sh_video
->fps
=1.0f
/d
;
590 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
);
591 // frame_time = 1/25.0;
595 case DEMUXER_TYPE_LAVF
:
596 if((int)sh_video
->fps
==1000 || (int)sh_video
->fps
<=1){
597 double next_pts
= ds_get_next_pts(d_video
);
598 double d
= (next_pts
!= MP_NOPTS_VALUE
) ? next_pts
- d_video
->pts
: d_video
->pts
-pts1
;
604 case DEMUXER_TYPE_REAL
:
606 double next_pts
= ds_get_next_pts(d_video
);
607 double d
= (next_pts
!= MP_NOPTS_VALUE
) ? next_pts
- d_video
->pts
: d_video
->pts
- pts1
;
609 frame_time
= (d
>= 0 && pts1
> 0) ? d
: 0.001;
614 if(video_codec
== VIDEO_MPEG12
){
615 sh_video
->pts
+=frame_time
;
616 if(picture_coding_type
==1)
618 if(picture_coding_type
<=2 && sh_video
->i_pts
){
619 sh_video
->pts
=sh_video
->i_pts
;
623 if(picture_coding_type
<=2) sh_video
->i_pts
=pts
;
624 else sh_video
->pts
=pts
;
628 sh_video
->pts
=d_video
->pts
;
630 if(frame_time_ptr
) *frame_time_ptr
=frame_time
;