4 * This file is part of MPlayer.
6 * MPlayer is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * MPlayer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34 #include "stream/stream.h"
36 #include "demux_ty_osd.h"
41 /* sub_cc (closed captions)*/
44 /* biCompression constant */
48 #include "demux_rtp.h"
51 static mp_mpeg_header_t picture
;
53 static int telecine
=0;
54 static float telecine_cnt
=-2.5;
64 static video_codec_t
find_video_codec(sh_video_t
*sh_video
)
66 demux_stream_t
*d_video
=sh_video
->ds
;
67 int fmt
= d_video
->demuxer
->file_format
;
70 (fmt
== DEMUXER_TYPE_PVA
) ||
71 (fmt
== DEMUXER_TYPE_MPEG_ES
) ||
72 (fmt
== DEMUXER_TYPE_MPEG_GXF
) ||
73 (fmt
== DEMUXER_TYPE_MPEG_PES
) ||
75 (fmt
== DEMUXER_TYPE_MPEG_PS
|| fmt
== DEMUXER_TYPE_MPEG_TS
) &&
76 ((! sh_video
->format
) || (sh_video
->format
==0x10000001) || (sh_video
->format
==0x10000002))
78 (fmt
== DEMUXER_TYPE_MPEG_TY
)
80 || ((fmt
== DEMUXER_TYPE_RTP
) && demux_is_mpeg_rtp_stream(d_video
->demuxer
))
84 else if((fmt
== DEMUXER_TYPE_MPEG4_ES
) ||
85 ((fmt
== DEMUXER_TYPE_MPEG_TS
) && (sh_video
->format
==0x10000004)) ||
86 ((fmt
== DEMUXER_TYPE_MPEG_PS
) && (sh_video
->format
==0x10000004))
89 else if((fmt
== DEMUXER_TYPE_H264_ES
) ||
90 ((fmt
== DEMUXER_TYPE_MPEG_TS
) && (sh_video
->format
==0x10000005)) ||
91 ((fmt
== DEMUXER_TYPE_MPEG_PS
) && (sh_video
->format
==0x10000005))
94 else if((fmt
== DEMUXER_TYPE_MPEG_PS
|| fmt
== DEMUXER_TYPE_MPEG_TS
) &&
95 (sh_video
->format
==mmioFOURCC('W', 'V', 'C', '1')))
97 else if (fmt
== DEMUXER_TYPE_ASF
&& sh_video
->bih
&& sh_video
->bih
->biCompression
== mmioFOURCC('D', 'V', 'R', ' '))
103 int video_read_properties(sh_video_t
*sh_video
){
104 demux_stream_t
*d_video
=sh_video
->ds
;
105 video_codec_t video_codec
= find_video_codec(sh_video
);
106 // Determine image properties:
109 if((d_video
->demuxer
->file_format
== DEMUXER_TYPE_ASF
) || (d_video
->demuxer
->file_format
== DEMUXER_TYPE_AVI
)) {
111 // in case no strf chunk has been seen in avi, we have no bitmap header
112 if(!sh_video
->bih
) return 0;
113 sh_video
->format
=sh_video
->bih
->biCompression
;
114 sh_video
->disp_w
=sh_video
->bih
->biWidth
;
115 sh_video
->disp_h
=abs(sh_video
->bih
->biHeight
);
120 int pos
= 0, vop_cnt
=0, units
[3];
121 videobuf_len
=0; videobuf_code_len
=0;
122 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for Video Object Start code... ");
124 int i
=sync_video_packet(d_video
);
125 if(i
<=0x11F) break; // found it!
126 if(!i
|| !skip_video_packet(d_video
)){
127 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
131 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
133 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ MP_INPUT_BUFFER_PADDING_SIZE
);
134 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, MP_INPUT_BUFFER_PADDING_SIZE
);
136 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
140 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for Video Object Layer Start code... ");
142 int i
=sync_video_packet(d_video
);
143 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"M4V: 0x%X\n",i
);
144 if(i
>=0x120 && i
<=0x12F) break; // found it!
145 if(!i
|| !read_video_packet(d_video
)){
146 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
150 pos
= videobuf_len
+4;
151 if(!read_video_packet(d_video
)){
152 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Can't read Video Object Layer Header\n");
155 mp4_header_process_vol(&picture
, &(videobuffer
[pos
]));
156 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK! FPS SEEMS TO BE %.3f\nSearching for Video Object Plane Start code... ", sh_video
->fps
);
159 int i
=sync_video_packet(d_video
);
160 if(i
==0x1B6) break; // found it!
161 if(!i
|| !read_video_packet(d_video
)){
162 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
166 pos
= videobuf_len
+4;
167 if(!read_video_packet(d_video
)){
168 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Can't read Video Object Plane Header\n");
171 mp4_header_process_vop(&picture
, &(videobuffer
[pos
]));
172 sh_video
->disp_w
= picture
.display_picture_width
;
173 sh_video
->disp_h
= picture
.display_picture_height
;
174 units
[vop_cnt
] = picture
.timeinc_unit
;
176 //mp_msg(MSGT_DECVIDEO,MSGL_V, "TYPE: %d, unit: %d\n", picture.picture_type, picture.timeinc_unit);
178 int i
, mn
, md
, mx
, diff
;
192 if((units
[i
] > mn
) && (units
[i
] < mx
))
195 mp_msg(MSGT_DECVIDEO
,MSGL_V
, "MIN: %d, mid: %d, max: %d\n", mn
, md
, mx
);
196 if(mx
- md
> md
- mn
)
201 picture
.fps
= ((float)picture
.timeinc_resolution
) / diff
;
202 mp_msg(MSGT_DECVIDEO
,MSGL_V
, "FPS seems to be: %f, resolution: %d, delta_units: %d\n", picture
.fps
, picture
.timeinc_resolution
, diff
);
206 sh_video
->fps
=picture
.fps
;
207 sh_video
->frametime
=1.0/picture
.fps
;
208 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
, "FPS seems to be: %f\n", picture
.fps
);
210 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
211 sh_video
->format
=0x10000004;
216 videobuf_len
=0; videobuf_code_len
=0;
217 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for sequence parameter set... ");
219 int i
=sync_video_packet(d_video
);
220 if((i
&~0x60) == 0x107 && i
!= 0x107) break; // found it!
221 if(!i
|| !skip_video_packet(d_video
)){
222 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
226 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
228 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ MP_INPUT_BUFFER_PADDING_SIZE
);
229 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, MP_INPUT_BUFFER_PADDING_SIZE
);
231 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
235 pos
= videobuf_len
+4;
236 if(!read_video_packet(d_video
)){
237 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Can't read sequence parameter set\n");
240 h264_parse_sps(&picture
, &(videobuffer
[pos
]), videobuf_len
- pos
);
241 sh_video
->disp_w
=picture
.display_picture_width
;
242 sh_video
->disp_h
=picture
.display_picture_height
;
243 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for picture parameter set... ");
245 int i
=sync_video_packet(d_video
);
246 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"H264: 0x%X\n",i
);
247 if((i
&~0x60) == 0x108 && i
!= 0x108) break; // found it!
248 if(!i
|| !read_video_packet(d_video
)){
249 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
253 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\nSearching for Slice... ");
255 int i
=sync_video_packet(d_video
);
256 if((i
&~0x60) == 0x101 || (i
&~0x60) == 0x102 || (i
&~0x60) == 0x105) break; // found it!
257 if(!i
|| !read_video_packet(d_video
)){
258 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
262 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
263 sh_video
->format
=0x10000005;
265 sh_video
->fps
=picture
.fps
;
266 sh_video
->frametime
=1.0/picture
.fps
;
267 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
, "FPS seems to be: %f\n", picture
.fps
);
272 if (d_video
->demuxer
->file_format
== DEMUXER_TYPE_ASF
) { // DVR-MS
273 if(!sh_video
->bih
) return 0;
274 sh_video
->format
=sh_video
->bih
->biCompression
;
277 // Find sequence_header first:
278 videobuf_len
=0; videobuf_code_len
=0;
279 telecine
=0; telecine_cnt
=-2.5;
280 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for sequence header... ");
282 int i
=sync_video_packet(d_video
);
283 if(i
==0x1B3) break; // found it!
284 if(!i
|| !skip_video_packet(d_video
)){
285 if( mp_msg_test(MSGT_DECVIDEO
,MSGL_V
) ) mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
286 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_MpegNoSequHdr
);
290 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
291 // ========= Read & process sequence header & extension ============
293 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ MP_INPUT_BUFFER_PADDING_SIZE
);
294 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, MP_INPUT_BUFFER_PADDING_SIZE
);
296 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
301 if(!read_video_packet(d_video
)){
302 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_CannotReadMpegSequHdr
);
305 if(mp_header_process_sequence_header (&picture
, &videobuffer
[4])) {
306 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_BadMpegSequHdr
);
307 goto mpeg_header_parser
;
309 if(sync_video_packet(d_video
)==0x1B5){ // next packet is seq. ext.
310 int pos
=videobuf_len
;
311 if(!read_video_packet(d_video
)){
312 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_CannotReadMpegSequHdrEx
);
315 if(mp_header_process_extension (&picture
, &videobuffer
[pos
+4])) {
316 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_BadMpegSequHdrEx
);
322 sh_video
->format
=picture
.mpeg1
?0x10000001:0x10000002; // mpeg video
323 sh_video
->fps
=picture
.fps
* picture
.frame_rate_extension_n
/ picture
.frame_rate_extension_d
;
325 sh_video
->frametime
=0;
327 sh_video
->frametime
=1.0/sh_video
->fps
;
329 sh_video
->disp_w
=picture
.display_picture_width
;
330 sh_video
->disp_h
=picture
.display_picture_height
;
332 if(picture
.bitrate
!=0x3FFFF) // unspecified/VBR ?
333 sh_video
->i_bps
=picture
.bitrate
* 400 / 8;
335 mp_dbg(MSGT_DECVIDEO
,MSGL_DBG2
,"mpeg bitrate: %d (%X)\n",picture
.bitrate
,picture
.bitrate
);
336 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"VIDEO: %s %dx%d (aspect %d) %5.3f fps %5.1f kbps (%4.1f kbyte/s)\n",
337 picture
.mpeg1
?"MPEG1":"MPEG2",
338 sh_video
->disp_w
,sh_video
->disp_h
,
339 picture
.aspect_ratio_information
,
341 sh_video
->i_bps
* 8 / 1000.0,
342 sh_video
->i_bps
/ 1000.0 );
346 // Find sequence_header:
349 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"Searching for VC1 sequence header... ");
351 int i
=sync_video_packet(d_video
);
352 if(i
==0x10F) break; // found it!
353 if(!i
|| !skip_video_packet(d_video
)){
354 if( mp_msg_test(MSGT_DECVIDEO
,MSGL_V
) ) mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
355 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
, "Couldn't find VC-1 sequence header\n");
359 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"found\n");
361 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ MP_INPUT_BUFFER_PADDING_SIZE
);
362 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, MP_INPUT_BUFFER_PADDING_SIZE
);
364 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
368 if(!read_video_packet(d_video
)){
369 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
, "Couldn't read VC-1 sequence header!\n");
374 int i
=sync_video_packet(d_video
);
375 if(i
==0x10E) break; // found it!
376 if(!i
|| !skip_video_packet(d_video
)){
377 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Couldn't find VC-1 entry point sync-code:(\n");
381 if(!read_video_packet(d_video
)){
382 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Couldn't read VC-1 entry point sync-code:(\n");
386 if(mp_vc1_decode_sequence_header(&picture
, &videobuffer
[4], videobuf_len
-4)) {
387 sh_video
->bih
= calloc(1, sizeof(BITMAPINFOHEADER
) + videobuf_len
);
388 if(sh_video
->bih
== NULL
) {
389 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Couldn't alloc %d bytes for VC-1 extradata!\n", sizeof(BITMAPINFOHEADER
) + videobuf_len
);
392 sh_video
->bih
->biSize
= sizeof(BITMAPINFOHEADER
) + videobuf_len
;
393 memcpy(sh_video
->bih
+ 1, videobuffer
, videobuf_len
);
394 sh_video
->bih
->biCompression
= sh_video
->format
;
395 sh_video
->bih
->biWidth
= sh_video
->disp_w
= picture
.display_picture_width
;
396 sh_video
->bih
->biHeight
= sh_video
->disp_h
= picture
.display_picture_height
;
397 if(picture
.fps
> 0) {
398 sh_video
->frametime
=1.0/picture
.fps
;
399 sh_video
->fps
= picture
.fps
;
401 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"VIDEO: VC-1 %dx%d, %5.3f fps, header len: %d\n",
402 sh_video
->disp_w
, sh_video
->disp_h
, sh_video
->fps
, videobuf_len
);
406 } // switch(file_format)
411 static void process_userdata(unsigned char* buf
,int len
){
413 /* if the user data starts with "CC", assume it is a CC info packet */
414 if(len
>2 && buf
[0]=='C' && buf
[1]=='C'){
415 // mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"video.c: process_userdata() detected Closed Captions!\n");
416 subcc_process_data(buf
+2,len
-2);
418 if( len
> 2 && buf
[ 0 ] == 'T' && buf
[ 1 ] == 'Y' )
420 ty_processuserdata( buf
+ 2, len
- 2 );
423 if(verbose
<2) return;
424 fprintf(stderr
, "user_data: len=%3d %02X %02X %02X %02X '",
425 len
, buf
[0], buf
[1], buf
[2], buf
[3]);
427 // if(buf[i]>=32 && buf[i]<127) fputc(buf[i], stderr);
428 if(buf
[i
]&0x60) fputc(buf
[i
]&0x7F, stderr
);
429 fprintf(stderr
, "'\n");
432 int video_read_frame(sh_video_t
* sh_video
,float* frame_time_ptr
,unsigned char** start
,int force_fps
){
433 demux_stream_t
*d_video
=sh_video
->ds
;
434 demuxer_t
*demuxer
=d_video
->demuxer
;
436 float pts1
=d_video
->pts
;
439 int picture_coding_type
=0;
441 video_codec_t video_codec
= find_video_codec(sh_video
);
445 if(video_codec
== VIDEO_MPEG12
){
449 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
){
450 int i
=sync_video_packet(d_video
);
451 //void* buffer=&videobuffer[videobuf_len+4];
452 int start
=videobuf_len
+4;
454 if(i
<0x101 || i
>=0x1B0){ // not slice code -> end of frame
455 if(!i
) return -1; // EOF
463 if(i
>=0x101 && i
<0x1B0) in_frame
=1; // picture startcode
464 else if(!i
) return -1; // EOF
466 if(!read_video_packet(d_video
)) return -1; // EOF
469 case 0x1B3: mp_header_process_sequence_header (&picture
, &videobuffer
[start
]);break;
470 case 0x1B5: mp_header_process_extension (&picture
, &videobuffer
[start
]);break;
471 case 0x1B2: process_userdata (&videobuffer
[start
], videobuf_len
-start
);break;
472 case 0x100: picture_coding_type
=(videobuffer
[start
+1] >> 3) & 7;break;
475 fps
= picture
.fps
* picture
.frame_rate_extension_n
/ picture
.frame_rate_extension_d
;
477 *start
=videobuffer
; in_size
=videobuf_len
;
480 if(sh_video
->fps
!=fps
) if(!force_fps
&& !telecine
){
481 mp_msg(MSGT_CPLAYER
,MSGL_WARN
,"Warning! FPS changed %5.3f -> %5.3f (%f) [%d] \n",sh_video
->fps
,fps
,sh_video
->fps
-fps
,picture
.frame_rate_code
);
483 sh_video
->frametime
=1.0/fps
;
486 // fix mpeg2 frametime:
487 frame_time
=(picture
.display_time
)*0.01f
;
488 picture
.display_time
=100;
491 telecine_cnt
*=0.9; // drift out error
492 telecine_cnt
+=frame_time
-5.0/4.0;
493 mp_msg(MSGT_DECVIDEO
,MSGL_DBG2
,"\r telecine = %3.1f %5.3f \n",frame_time
,telecine_cnt
);
497 if(telecine_cnt
<-1.5 || telecine_cnt
>1.5){
498 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,MSGTR_LeaveTelecineMode
);
502 if(telecine_cnt
>-0.5 && telecine_cnt
<0.5 && !force_fps
){
503 sh_video
->fps
=sh_video
->fps
*4/5;
504 sh_video
->frametime
=sh_video
->frametime
*5/4;
505 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,MSGTR_EnterTelecineMode
);
508 } else if(video_codec
== VIDEO_MPEG4
){
509 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
){
510 int i
=sync_video_packet(d_video
);
512 if(!read_video_packet(d_video
)) return -1; // EOF
515 *start
=videobuffer
; in_size
=videobuf_len
;
517 } else if(video_codec
== VIDEO_H264
){
519 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
){
520 int i
=sync_video_packet(d_video
);
521 int pos
= videobuf_len
+4;
523 if(!read_video_packet(d_video
)) return -1; // EOF
524 if((i
&~0x60) == 0x107 && i
!= 0x107) {
525 h264_parse_sps(&picture
, &(videobuffer
[pos
]), videobuf_len
- pos
);
526 if(picture
.fps
> 0) {
527 sh_video
->fps
=picture
.fps
;
528 sh_video
->frametime
=1.0/picture
.fps
;
530 i
=sync_video_packet(d_video
);
532 if(!read_video_packet(d_video
)) return -1; // EOF
535 // here starts the access unit end detection code
536 // see the mail on MPlayer-dev-eng for details:
537 // Date: Sat, 17 Sep 2005 11:24:06 +0200
538 // Subject: Re: [MPlayer-dev-eng] [RFC] h264 ES parser problems
539 // Message-ID: <20050917092406.GA7699@rz.uni-karlsruhe.de>
540 if((i
&~0x60) == 0x101 || (i
&~0x60) == 0x102 || (i
&~0x60) == 0x105)
541 // found VCL NAL with slice header i.e. start of current primary coded
542 // picture, so start scanning for the end now
545 i
= sync_video_packet(d_video
) & ~0x60; // code of next packet
546 if(i
== 0x106 || i
== 0x109) break; // SEI or access unit delim.
547 if(i
== 0x101 || i
== 0x102 || i
== 0x105) {
548 // assuming arbitrary slice ordering is not allowed, the
549 // first_mb_in_slice (golomb encoded) value should be 0 then
550 // for the first VCL NAL in a picture
551 if (demux_peekc(d_video
) & 0x80)
556 *start
=videobuffer
; in_size
=videobuf_len
;
558 } else if(video_codec
== VIDEO_VC1
) {
559 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
) {
560 int i
=sync_video_packet(d_video
);
562 if(!read_video_packet(d_video
)) return -1; // EOF
566 in_size
=videobuf_len
;
569 // frame-based file formats: (AVI,ASF,MOV)
570 in_size
=ds_get_packet(d_video
,start
);
571 if(in_size
<0) return -1; // EOF
575 //------------------------ frame decoded. --------------------
577 // Increase video timers:
578 sh_video
->num_frames
+=frame_time
;
579 ++sh_video
->num_frames_decoded
;
581 frame_time
*=sh_video
->frametime
;
583 // override frame_time for variable/unknown FPS formats:
584 if(!force_fps
) switch(demuxer
->file_format
){
585 case DEMUXER_TYPE_GIF
:
586 case DEMUXER_TYPE_MATROSKA
:
587 case DEMUXER_TYPE_MNG
:
588 if(d_video
->pts
>0 && pts1
>0 && d_video
->pts
>pts1
)
589 frame_time
=d_video
->pts
-pts1
;
591 case DEMUXER_TYPE_TV
:
592 case DEMUXER_TYPE_MOV
:
593 case DEMUXER_TYPE_FILM
:
594 case DEMUXER_TYPE_VIVO
:
595 case DEMUXER_TYPE_OGG
:
596 case DEMUXER_TYPE_ASF
: {
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
;
601 if((int)sh_video
->fps
==1000)
602 mp_msg(MSGT_CPLAYER
,MSGL_V
,"\navg. framerate: %d fps \n",(int)(1.0f
/d
));
603 sh_video
->frametime
=d
; // 1ms
604 sh_video
->fps
=1.0f
/d
;
608 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
);
609 // frame_time = 1/25.0;
613 case DEMUXER_TYPE_LAVF
:
614 case DEMUXER_TYPE_LAVF_PREFERRED
:
615 if((int)sh_video
->fps
==1000 || (int)sh_video
->fps
<=1){
616 double next_pts
= ds_get_next_pts(d_video
);
617 double d
= (next_pts
!= MP_NOPTS_VALUE
) ? next_pts
- d_video
->pts
: d_video
->pts
-pts1
;
623 case DEMUXER_TYPE_REAL
:
625 double next_pts
= ds_get_next_pts(d_video
);
626 double d
= (next_pts
!= MP_NOPTS_VALUE
) ? next_pts
- d_video
->pts
: d_video
->pts
- pts1
;
628 frame_time
= (d
>= 0 && pts1
> 0) ? d
: 0.001;
633 if(video_codec
== VIDEO_MPEG12
){
634 sh_video
->pts
+=frame_time
;
635 if(picture_coding_type
==1)
637 if(picture_coding_type
<=2 && sh_video
->i_pts
){
638 sh_video
->pts
=sh_video
->i_pts
;
642 if(picture_coding_type
<=2) sh_video
->i_pts
=pts
;
643 else sh_video
->pts
=pts
;
647 sh_video
->pts
=d_video
->pts
;
649 if(frame_time_ptr
) *frame_time_ptr
=frame_time
;