16 #include "stream/stream.h"
22 /* sub_cc (closed captions)*/
25 #ifdef USE_LIBAVCODEC_SO
26 #include <ffmpeg/avcodec.h>
27 #elif defined(USE_LIBAVCODEC)
28 #include "libavcodec/avcodec.h"
30 #define FF_INPUT_BUFFER_PADDING_SIZE 8
33 /* biCompression constant */
36 #ifdef STREAMING_LIVE555
37 #include "demux_rtp.h"
40 static mp_mpeg_header_t picture
;
42 static int telecine
=0;
43 static float telecine_cnt
=-2.5;
53 static video_codec_t
find_video_codec(sh_video_t
*sh_video
)
55 demux_stream_t
*d_video
=sh_video
->ds
;
56 int fmt
= d_video
->demuxer
->file_format
;
59 (fmt
== DEMUXER_TYPE_PVA
) ||
60 (fmt
== DEMUXER_TYPE_MPEG_ES
) ||
61 (fmt
== DEMUXER_TYPE_MPEG_GXF
) ||
62 (fmt
== DEMUXER_TYPE_MPEG_PES
) ||
64 (fmt
== DEMUXER_TYPE_MPEG_PS
|| fmt
== DEMUXER_TYPE_MPEG_TS
) &&
65 ((! sh_video
->format
) || (sh_video
->format
==0x10000001) || (sh_video
->format
==0x10000002))
67 (fmt
== DEMUXER_TYPE_MPEG_TY
)
68 #ifdef STREAMING_LIVE555
69 || ((fmt
== DEMUXER_TYPE_RTP
) && demux_is_mpeg_rtp_stream(d_video
->demuxer
))
73 else if((fmt
== DEMUXER_TYPE_MPEG4_ES
) ||
74 ((fmt
== DEMUXER_TYPE_MPEG_TS
) && (sh_video
->format
==0x10000004)) ||
75 ((fmt
== DEMUXER_TYPE_MPEG_PS
) && (sh_video
->format
==0x10000004))
78 else if((fmt
== DEMUXER_TYPE_H264_ES
) ||
79 ((fmt
== DEMUXER_TYPE_MPEG_TS
) && (sh_video
->format
==0x10000005)) ||
80 ((fmt
== DEMUXER_TYPE_MPEG_PS
) && (sh_video
->format
==0x10000005))
83 else if((fmt
== DEMUXER_TYPE_MPEG_PS
|| fmt
== DEMUXER_TYPE_MPEG_TS
) &&
84 (sh_video
->format
==mmioFOURCC('W', 'V', 'C', '1')))
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
);
256 // Find sequence_header first:
257 videobuf_len
=0; videobuf_code_len
=0;
258 telecine
=0; telecine_cnt
=-2.5;
259 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Searching for sequence header... ");
261 int i
=sync_video_packet(d_video
);
262 if(i
==0x1B3) break; // found it!
263 if(!i
|| !skip_video_packet(d_video
)){
264 if( mp_msg_test(MSGT_DECVIDEO
,MSGL_V
) ) mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
265 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_MpegNoSequHdr
);
269 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"OK!\n");
270 // ========= Read & process sequence header & extension ============
272 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ FF_INPUT_BUFFER_PADDING_SIZE
);
273 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, FF_INPUT_BUFFER_PADDING_SIZE
);
275 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
280 if(!read_video_packet(d_video
)){
281 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_CannotReadMpegSequHdr
);
284 if(mp_header_process_sequence_header (&picture
, &videobuffer
[4])) {
285 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_BadMpegSequHdr
);
286 goto mpeg_header_parser
;
288 if(sync_video_packet(d_video
)==0x1B5){ // next packet is seq. ext.
289 int pos
=videobuf_len
;
290 if(!read_video_packet(d_video
)){
291 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_CannotReadMpegSequHdrEx
);
294 if(mp_header_process_extension (&picture
, &videobuffer
[pos
+4])) {
295 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_BadMpegSequHdrEx
);
301 sh_video
->format
=picture
.mpeg1
?0x10000001:0x10000002; // mpeg video
302 sh_video
->fps
=picture
.fps
;
304 sh_video
->frametime
=0;
306 sh_video
->frametime
=1.0/picture
.fps
;
308 sh_video
->disp_w
=picture
.display_picture_width
;
309 sh_video
->disp_h
=picture
.display_picture_height
;
311 if(picture
.bitrate
!=0x3FFFF) // unspecified/VBR ?
312 sh_video
->i_bps
=picture
.bitrate
* 400 / 8;
314 mp_dbg(MSGT_DECVIDEO
,MSGL_DBG2
,"mpeg bitrate: %d (%X)\n",picture
.bitrate
,picture
.bitrate
);
315 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"VIDEO: %s %dx%d (aspect %d) %5.3f fps %5.1f kbps (%4.1f kbyte/s)\n",
316 picture
.mpeg1
?"MPEG1":"MPEG2",
317 sh_video
->disp_w
,sh_video
->disp_h
,
318 picture
.aspect_ratio_information
,
320 sh_video
->i_bps
* 8 / 1000.0,
321 sh_video
->i_bps
/ 1000.0 );
325 // Find sequence_header:
328 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"Searching for VC1 sequence header... ");
330 int i
=sync_video_packet(d_video
);
331 if(i
==0x10F) break; // found it!
332 if(!i
|| !skip_video_packet(d_video
)){
333 if( mp_msg_test(MSGT_DECVIDEO
,MSGL_V
) ) mp_msg(MSGT_DECVIDEO
,MSGL_V
,"NONE :(\n");
334 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
, "Couldn't find VC-1 sequence header\n");
338 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"found\n");
340 videobuffer
=(char*)memalign(8,VIDEOBUFFER_SIZE
+ FF_INPUT_BUFFER_PADDING_SIZE
);
341 if (videobuffer
) memset(videobuffer
+VIDEOBUFFER_SIZE
, 0, FF_INPUT_BUFFER_PADDING_SIZE
);
343 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,MSGTR_ShMemAllocFail
);
347 if(!read_video_packet(d_video
)){
348 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
, "Couldn't read VC-1 sequence header!\n");
353 int i
=sync_video_packet(d_video
);
354 if(i
==0x10E) break; // found it!
355 if(!i
|| !skip_video_packet(d_video
)){
356 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Couldn't find VC-1 entry point sync-code:(\n");
360 if(!read_video_packet(d_video
)){
361 mp_msg(MSGT_DECVIDEO
,MSGL_V
,"Couldn't read VC-1 entry point sync-code:(\n");
365 if(mp_vc1_decode_sequence_header(&picture
, &videobuffer
[4], videobuf_len
-4)) {
366 sh_video
->bih
= (BITMAPINFOHEADER
*) calloc(1, sizeof(BITMAPINFOHEADER
) + videobuf_len
);
367 if(sh_video
->bih
== NULL
) {
368 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"Couldn't alloc %d bytes for VC-1 extradata!\n", sizeof(BITMAPINFOHEADER
) + videobuf_len
);
371 sh_video
->bih
->biSize
= sizeof(BITMAPINFOHEADER
) + videobuf_len
;
372 memcpy(sh_video
->bih
+ 1, videobuffer
, videobuf_len
);
373 sh_video
->bih
->biCompression
= sh_video
->format
;
374 sh_video
->bih
->biWidth
= sh_video
->disp_w
= picture
.display_picture_width
;
375 sh_video
->bih
->biHeight
= sh_video
->disp_h
= picture
.display_picture_height
;
376 if(picture
.fps
> 0) {
377 sh_video
->frametime
=1.0/picture
.fps
;
378 sh_video
->fps
= picture
.fps
;
380 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,"VIDEO: VC-1 %dx%d, %5.3f fps, header len: %d\n",
381 sh_video
->disp_w
, sh_video
->disp_h
, sh_video
->fps
, videobuf_len
);
385 } // switch(file_format)
390 void ty_processuserdata( unsigned char* buf
, int len
);
392 static void process_userdata(unsigned char* buf
,int len
){
394 /* if the user data starts with "CC", assume it is a CC info packet */
395 if(len
>2 && buf
[0]=='C' && buf
[1]=='C'){
396 // mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"video.c: process_userdata() detected Closed Captions!\n");
397 subcc_process_data(buf
+2,len
-2);
399 if( len
> 2 && buf
[ 0 ] == 'T' && buf
[ 1 ] == 'Y' )
401 ty_processuserdata( buf
+ 2, len
- 2 );
404 if(verbose
<2) return;
405 fprintf(stderr
, "user_data: len=%3d %02X %02X %02X %02X '",
406 len
, buf
[0], buf
[1], buf
[2], buf
[3]);
408 // if(buf[i]>=32 && buf[i]<127) fputc(buf[i], stderr);
409 if(buf
[i
]&0x60) fputc(buf
[i
]&0x7F, stderr
);
410 fprintf(stderr
, "'\n");
413 int video_read_frame(sh_video_t
* sh_video
,float* frame_time_ptr
,unsigned char** start
,int force_fps
){
414 demux_stream_t
*d_video
=sh_video
->ds
;
415 demuxer_t
*demuxer
=d_video
->demuxer
;
417 float pts1
=d_video
->pts
;
419 int picture_coding_type
=0;
421 video_codec_t video_codec
= find_video_codec(sh_video
);
425 if(video_codec
== VIDEO_MPEG12
){
429 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
){
430 int i
=sync_video_packet(d_video
);
431 //void* buffer=&videobuffer[videobuf_len+4];
432 int start
=videobuf_len
+4;
434 if(i
<0x101 || i
>=0x1B0){ // not slice code -> end of frame
435 if(!i
) return -1; // EOF
443 if(i
>=0x101 && i
<0x1B0) in_frame
=1; // picture startcode
444 else if(!i
) return -1; // EOF
446 if(!read_video_packet(d_video
)) return -1; // EOF
449 case 0x1B3: mp_header_process_sequence_header (&picture
, &videobuffer
[start
]);break;
450 case 0x1B5: mp_header_process_extension (&picture
, &videobuffer
[start
]);break;
451 case 0x1B2: process_userdata (&videobuffer
[start
], videobuf_len
-start
);break;
452 case 0x100: picture_coding_type
=(videobuffer
[start
+1] >> 3) & 7;break;
456 *start
=videobuffer
; in_size
=videobuf_len
;
459 if(sh_video
->fps
!=picture
.fps
) if(!force_fps
&& !telecine
){
460 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
);
461 sh_video
->fps
=picture
.fps
;
462 sh_video
->frametime
=1.0/picture
.fps
;
465 // fix mpeg2 frametime:
466 frame_time
=(picture
.display_time
)*0.01f
;
467 picture
.display_time
=100;
470 telecine_cnt
*=0.9; // drift out error
471 telecine_cnt
+=frame_time
-5.0/4.0;
472 mp_msg(MSGT_DECVIDEO
,MSGL_DBG2
,"\r telecine = %3.1f %5.3f \n",frame_time
,telecine_cnt
);
476 if(telecine_cnt
<-1.5 || telecine_cnt
>1.5){
477 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,MSGTR_LeaveTelecineMode
);
481 if(telecine_cnt
>-0.5 && telecine_cnt
<0.5 && !force_fps
){
482 sh_video
->fps
=sh_video
->fps
*4/5;
483 sh_video
->frametime
=sh_video
->frametime
*5/4;
484 mp_msg(MSGT_DECVIDEO
,MSGL_INFO
,MSGTR_EnterTelecineMode
);
487 } else if(video_codec
== VIDEO_MPEG4
){
488 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
){
489 int i
=sync_video_packet(d_video
);
491 if(!read_video_packet(d_video
)) return -1; // EOF
494 *start
=videobuffer
; in_size
=videobuf_len
;
496 } else if(video_codec
== VIDEO_H264
){
498 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
){
499 int i
=sync_video_packet(d_video
);
500 int pos
= videobuf_len
+4;
502 if(!read_video_packet(d_video
)) return -1; // EOF
503 if((i
&~0x60) == 0x107 && i
!= 0x107) {
504 h264_parse_sps(&picture
, &(videobuffer
[pos
]), videobuf_len
- pos
);
505 if(picture
.fps
> 0) {
506 sh_video
->fps
=picture
.fps
;
507 sh_video
->frametime
=1.0/picture
.fps
;
509 i
=sync_video_packet(d_video
);
511 if(!read_video_packet(d_video
)) return -1; // EOF
514 // here starts the access unit end detection code
515 // see the mail on MPlayer-dev-eng for details:
516 // Date: Sat, 17 Sep 2005 11:24:06 +0200
517 // Subject: Re: [MPlayer-dev-eng] [RFC] h264 ES parser problems
518 // Message-ID: <20050917092406.GA7699@rz.uni-karlsruhe.de>
519 if((i
&~0x60) == 0x101 || (i
&~0x60) == 0x102 || (i
&~0x60) == 0x105)
520 // found VCL NAL with slice header i.e. start of current primary coded
521 // picture, so start scanning for the end now
524 i
= sync_video_packet(d_video
) & ~0x60; // code of next packet
525 if(i
== 0x106 || i
== 0x109) break; // SEI or access unit delim.
526 if(i
== 0x101 || i
== 0x102 || i
== 0x105) {
527 // assuming arbitrary slice ordering is not allowed, the
528 // first_mb_in_slice (golomb encoded) value should be 0 then
529 // for the first VCL NAL in a picture
530 if (demux_peekc(d_video
) & 0x80)
535 *start
=videobuffer
; in_size
=videobuf_len
;
537 } else if(video_codec
== VIDEO_VC1
) {
538 while(videobuf_len
<VIDEOBUFFER_SIZE
-MAX_VIDEO_PACKET_SIZE
) {
539 int i
=sync_video_packet(d_video
);
541 if(!read_video_packet(d_video
)) return -1; // EOF
545 in_size
=videobuf_len
;
548 // frame-based file formats: (AVI,ASF,MOV)
549 in_size
=ds_get_packet(d_video
,start
);
550 if(in_size
<0) return -1; // EOF
554 //------------------------ frame decoded. --------------------
556 // Increase video timers:
557 sh_video
->num_frames
+=frame_time
;
558 ++sh_video
->num_frames_decoded
;
560 frame_time
*=sh_video
->frametime
;
562 // override frame_time for variable/unknown FPS formats:
563 if(!force_fps
) switch(demuxer
->file_format
){
564 case DEMUXER_TYPE_GIF
:
565 case DEMUXER_TYPE_MATROSKA
:
566 if(d_video
->pts
>0 && pts1
>0 && d_video
->pts
>pts1
)
567 frame_time
=d_video
->pts
-pts1
;
569 case DEMUXER_TYPE_TV
:
570 case DEMUXER_TYPE_MOV
:
571 case DEMUXER_TYPE_FILM
:
572 case DEMUXER_TYPE_VIVO
:
573 case DEMUXER_TYPE_OGG
:
574 case DEMUXER_TYPE_ASF
: {
575 double next_pts
= ds_get_next_pts(d_video
);
576 double d
= (next_pts
!= MP_NOPTS_VALUE
) ? next_pts
- d_video
->pts
: d_video
->pts
-pts1
;
579 if((int)sh_video
->fps
==1000)
580 mp_msg(MSGT_CPLAYER
,MSGL_V
,"\navg. framerate: %d fps \n",(int)(1.0f
/d
));
581 sh_video
->frametime
=d
; // 1ms
582 sh_video
->fps
=1.0f
/d
;
586 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
);
587 // frame_time = 1/25.0;
591 case DEMUXER_TYPE_LAVF
:
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
;