comparison libmpdemux/video.c @ 24834:a8ef08f502c0

cosmetics: removed tabs/empty lines/trailing spaces and done a partial reformatting where desperately needed
author nicodvb
date Sat, 27 Oct 2007 12:33:56 +0000
parents e0ae2a33857a
children 4e90fdb819b0
comparison
equal deleted inserted replaced
24833:02fa1df91e2f 24834:a8ef08f502c0
41 41
42 static int telecine=0; 42 static int telecine=0;
43 static float telecine_cnt=-2.5; 43 static float telecine_cnt=-2.5;
44 44
45 typedef enum { 45 typedef enum {
46 VIDEO_MPEG12, 46 VIDEO_MPEG12,
47 VIDEO_MPEG4, 47 VIDEO_MPEG4,
48 VIDEO_H264, 48 VIDEO_H264,
49 VIDEO_VC1, 49 VIDEO_VC1,
50 VIDEO_OTHER 50 VIDEO_OTHER
51 } video_codec_t; 51 } video_codec_t;
52 52
53 static video_codec_t find_video_codec(sh_video_t *sh_video) 53 static video_codec_t find_video_codec(sh_video_t *sh_video)
54 { 54 {
55 demux_stream_t *d_video=sh_video->ds; 55 demux_stream_t *d_video=sh_video->ds;
92 video_codec_t video_codec = find_video_codec(sh_video); 92 video_codec_t video_codec = find_video_codec(sh_video);
93 // Determine image properties: 93 // Determine image properties:
94 switch(video_codec){ 94 switch(video_codec){
95 case VIDEO_OTHER: { 95 case VIDEO_OTHER: {
96 if((d_video->demuxer->file_format == DEMUXER_TYPE_ASF) || (d_video->demuxer->file_format == DEMUXER_TYPE_AVI)) { 96 if((d_video->demuxer->file_format == DEMUXER_TYPE_ASF) || (d_video->demuxer->file_format == DEMUXER_TYPE_AVI)) {
97 // display info: 97 // display info:
98 // in case no strf chunk has been seen in avi, we have no bitmap header 98 // in case no strf chunk has been seen in avi, we have no bitmap header
99 if(!sh_video->bih) return 0; 99 if(!sh_video->bih) return 0;
100 100 sh_video->format=sh_video->bih->biCompression;
101 sh_video->format=sh_video->bih->biCompression;
102
103 sh_video->disp_w=sh_video->bih->biWidth; 101 sh_video->disp_w=sh_video->bih->biWidth;
104 sh_video->disp_h=abs(sh_video->bih->biHeight); 102 sh_video->disp_h=abs(sh_video->bih->biHeight);
105
106 } 103 }
107 break; 104 break;
108 } 105 }
109 case VIDEO_MPEG4: { 106 case VIDEO_MPEG4: {
110 int pos = 0, vop_cnt=0, units[3]; 107 int pos = 0, vop_cnt=0, units[3];
113 while(1){ 110 while(1){
114 int i=sync_video_packet(d_video); 111 int i=sync_video_packet(d_video);
115 if(i<=0x11F) break; // found it! 112 if(i<=0x11F) break; // found it!
116 if(!i || !skip_video_packet(d_video)){ 113 if(!i || !skip_video_packet(d_video)){
117 mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n"); 114 mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
118 return 0; 115 return 0;
119 } 116 }
120 } 117 }
121 mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n"); 118 mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
122 if(!videobuffer) { 119 if(!videobuffer) {
123 videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); 120 videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
132 int i=sync_video_packet(d_video); 129 int i=sync_video_packet(d_video);
133 mp_msg(MSGT_DECVIDEO,MSGL_V,"M4V: 0x%X\n",i); 130 mp_msg(MSGT_DECVIDEO,MSGL_V,"M4V: 0x%X\n",i);
134 if(i>=0x120 && i<=0x12F) break; // found it! 131 if(i>=0x120 && i<=0x12F) break; // found it!
135 if(!i || !read_video_packet(d_video)){ 132 if(!i || !read_video_packet(d_video)){
136 mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n"); 133 mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
137 return 0; 134 return 0;
138 } 135 }
139 } 136 }
140 pos = videobuf_len+4; 137 pos = videobuf_len+4;
141 if(!read_video_packet(d_video)){ 138 if(!read_video_packet(d_video)){
142 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Can't read Video Object Layer Header\n"); 139 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Can't read Video Object Layer Header\n");
148 while(1){ 145 while(1){
149 int i=sync_video_packet(d_video); 146 int i=sync_video_packet(d_video);
150 if(i==0x1B6) break; // found it! 147 if(i==0x1B6) break; // found it!
151 if(!i || !read_video_packet(d_video)){ 148 if(!i || !read_video_packet(d_video)){
152 mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n"); 149 mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
153 return 0; 150 return 0;
154 } 151 }
155 } 152 }
156 pos = videobuf_len+4; 153 pos = videobuf_len+4;
157 if(!read_video_packet(d_video)){ 154 if(!read_video_packet(d_video)){
158 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Can't read Video Object Plane Header\n"); 155 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Can't read Video Object Plane Header\n");
206 while(1){ 203 while(1){
207 int i=sync_video_packet(d_video); 204 int i=sync_video_packet(d_video);
208 if((i&~0x60) == 0x107 && i != 0x107) break; // found it! 205 if((i&~0x60) == 0x107 && i != 0x107) break; // found it!
209 if(!i || !skip_video_packet(d_video)){ 206 if(!i || !skip_video_packet(d_video)){
210 mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n"); 207 mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
211 return 0; 208 return 0;
212 } 209 }
213 } 210 }
214 mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n"); 211 mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
215 if(!videobuffer) { 212 if(!videobuffer) {
216 videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); 213 videobuffer=(char*)memalign(8,VIDEOBUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
231 int i=sync_video_packet(d_video); 228 int i=sync_video_packet(d_video);
232 mp_msg(MSGT_DECVIDEO,MSGL_V,"H264: 0x%X\n",i); 229 mp_msg(MSGT_DECVIDEO,MSGL_V,"H264: 0x%X\n",i);
233 if((i&~0x60) == 0x108 && i != 0x108) break; // found it! 230 if((i&~0x60) == 0x108 && i != 0x108) break; // found it!
234 if(!i || !read_video_packet(d_video)){ 231 if(!i || !read_video_packet(d_video)){
235 mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n"); 232 mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
236 return 0; 233 return 0;
237 } 234 }
238 } 235 }
239 mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\nSearching for Slice... ");fflush(stdout); 236 mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\nSearching for Slice... ");fflush(stdout);
240 while(1){ 237 while(1){
241 int i=sync_video_packet(d_video); 238 int i=sync_video_packet(d_video);
242 if((i&~0x60) == 0x101 || (i&~0x60) == 0x102 || (i&~0x60) == 0x105) break; // found it! 239 if((i&~0x60) == 0x101 || (i&~0x60) == 0x102 || (i&~0x60) == 0x105) break; // found it!
243 if(!i || !read_video_packet(d_video)){ 240 if(!i || !read_video_packet(d_video)){
244 mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n"); 241 mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
245 return 0; 242 return 0;
246 } 243 }
247 } 244 }
248 mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n"); 245 mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
249 sh_video->format=0x10000005; 246 sh_video->format=0x10000005;
250 if(picture.fps) { 247 if(picture.fps) {
264 int i=sync_video_packet(d_video); 261 int i=sync_video_packet(d_video);
265 if(i==0x1B3) break; // found it! 262 if(i==0x1B3) break; // found it!
266 if(!i || !skip_video_packet(d_video)){ 263 if(!i || !skip_video_packet(d_video)){
267 if( mp_msg_test(MSGT_DECVIDEO,MSGL_V) ) mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n"); 264 if( mp_msg_test(MSGT_DECVIDEO,MSGL_V) ) mp_msg(MSGT_DECVIDEO,MSGL_V,"NONE :(\n");
268 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MpegNoSequHdr); 265 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MpegNoSequHdr);
269 return 0; 266 return 0;
270 } 267 }
271 } 268 }
272 mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n"); 269 mp_msg(MSGT_DECVIDEO,MSGL_V,"OK!\n");
273 // ========= Read & process sequence header & extension ============ 270 // ========= Read & process sequence header & extension ============
274 if(!videobuffer) { 271 if(!videobuffer) {
277 else { 274 else {
278 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail); 275 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_ShMemAllocFail);
279 return 0; 276 return 0;
280 } 277 }
281 } 278 }
282 279
283 if(!read_video_packet(d_video)){ 280 if(!read_video_packet(d_video)){
284 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CannotReadMpegSequHdr); 281 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_CannotReadMpegSequHdr);
285 return 0; 282 return 0;
286 } 283 }
287 if(mp_header_process_sequence_header (&picture, &videobuffer[4])) { 284 if(mp_header_process_sequence_header (&picture, &videobuffer[4])) {
297 if(mp_header_process_extension (&picture, &videobuffer[pos+4])) { 294 if(mp_header_process_extension (&picture, &videobuffer[pos+4])) {
298 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_BadMpegSequHdrEx); 295 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_BadMpegSequHdrEx);
299 return 0; 296 return 0;
300 } 297 }
301 } 298 }
302 299
303 // display info: 300 // display info:
304 sh_video->format=picture.mpeg1?0x10000001:0x10000002; // mpeg video 301 sh_video->format=picture.mpeg1?0x10000001:0x10000002; // mpeg video
305 sh_video->fps=picture.fps; 302 sh_video->fps=picture.fps;
306 if(!sh_video->fps){ 303 if(!sh_video->fps){
307 sh_video->frametime=0; 304 sh_video->frametime=0;
363 if(!read_video_packet(d_video)){ 360 if(!read_video_packet(d_video)){
364 mp_msg(MSGT_DECVIDEO,MSGL_V,"Couldn't read VC-1 entry point sync-code:(\n"); 361 mp_msg(MSGT_DECVIDEO,MSGL_V,"Couldn't read VC-1 entry point sync-code:(\n");
365 return 0; 362 return 0;
366 } 363 }
367 364
368
369 if(mp_vc1_decode_sequence_header(&picture, &videobuffer[4], videobuf_len-4)) { 365 if(mp_vc1_decode_sequence_header(&picture, &videobuffer[4], videobuf_len-4)) {
370 sh_video->bih = (BITMAPINFOHEADER *) calloc(1, sizeof(BITMAPINFOHEADER) + videobuf_len); 366 sh_video->bih = (BITMAPINFOHEADER *) calloc(1, sizeof(BITMAPINFOHEADER) + videobuf_len);
371 if(sh_video->bih == NULL) { 367 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); 368 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Couldn't alloc %d bytes for VC-1 extradata!\n", sizeof(BITMAPINFOHEADER) + videobuf_len);
373 return 0; 369 return 0;
395 391
396 static void process_userdata(unsigned char* buf,int len){ 392 static void process_userdata(unsigned char* buf,int len){
397 int i; 393 int i;
398 /* if the user data starts with "CC", assume it is a CC info packet */ 394 /* if the user data starts with "CC", assume it is a CC info packet */
399 if(len>2 && buf[0]=='C' && buf[1]=='C'){ 395 if(len>2 && buf[0]=='C' && buf[1]=='C'){
400 // mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"video.c: process_userdata() detected Closed Captions!\n"); 396 // mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"video.c: process_userdata() detected Closed Captions!\n");
401 subcc_process_data(buf+2,len-2); 397 subcc_process_data(buf+2,len-2);
402 } 398 }
403 if( len > 2 && buf[ 0 ] == 'T' && buf[ 1 ] == 'Y' ) 399 if( len > 2 && buf[ 0 ] == 'T' && buf[ 1 ] == 'Y' )
404 { 400 {
405 ty_processuserdata( buf + 2, len - 2 ); 401 ty_processuserdata( buf + 2, len - 2 );
406 return; 402 return;
407 } 403 }
408 if(verbose<2) return; 404 if(verbose<2) return;
409 printf( "user_data: len=%3d %02X %02X %02X %02X '", 405 printf( "user_data: len=%3d %02X %02X %02X %02X '",
410 len, buf[0], buf[1], buf[2], buf[3]); 406 len, buf[0], buf[1], buf[2], buf[3]);
411 for(i=0;i<len;i++) 407 for(i=0;i<len;i++)
412 // if(buf[i]>=32 && buf[i]<127) putchar(buf[i]); 408 // if(buf[i]>=32 && buf[i]<127) putchar(buf[i]);
413 if(buf[i]&0x60) putchar(buf[i]&0x7F); 409 if(buf[i]&0x60) putchar(buf[i]&0x7F);
414 printf("'\n"); 410 printf("'\n");
415 } 411 }
416 412
417 int video_read_frame(sh_video_t* sh_video,float* frame_time_ptr,unsigned char** start,int force_fps){ 413 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; 414 demux_stream_t *d_video=sh_video->ds;
421 float pts1=d_video->pts; 417 float pts1=d_video->pts;
422 float pts=0; 418 float pts=0;
423 int picture_coding_type=0; 419 int picture_coding_type=0;
424 int in_size=0; 420 int in_size=0;
425 video_codec_t video_codec = find_video_codec(sh_video); 421 video_codec_t video_codec = find_video_codec(sh_video);
426 422
427 *start=NULL; 423 *start=NULL;
428 424
429 if(video_codec == VIDEO_MPEG12){ 425 if(video_codec == VIDEO_MPEG12){
430 int in_frame=0; 426 int in_frame=0;
431 //float newfps; 427 //float newfps;
432 //videobuf_len=0; 428 //videobuf_len=0;
433 while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){ 429 while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){
434 int i=sync_video_packet(d_video); 430 int i=sync_video_packet(d_video);
435 //void* buffer=&videobuffer[videobuf_len+4]; 431 //void* buffer=&videobuffer[videobuf_len+4];
436 int start=videobuf_len+4; 432 int start=videobuf_len+4;
437 if(in_frame){ 433 if(in_frame){
438 if(i<0x101 || i>=0x1B0){ // not slice code -> end of frame 434 if(i<0x101 || i>=0x1B0){ // not slice code -> end of frame
439 if(!i) return -1; // EOF 435 if(!i) return -1; // EOF
440 break; 436 break;
441 } 437 }
442 } else { 438 } else {
443 if(i==0x100){ 439 if(i==0x100){
444 pts=d_video->pts; 440 pts=d_video->pts;
445 d_video->pts=0; 441 d_video->pts=0;
446 } 442 }
447 if(i>=0x101 && i<0x1B0) in_frame=1; // picture startcode 443 if(i>=0x101 && i<0x1B0) in_frame=1; // picture startcode
448 else if(!i) return -1; // EOF 444 else if(!i) return -1; // EOF
449 } 445 }
450 if(!read_video_packet(d_video)) return -1; // EOF 446 if(!read_video_packet(d_video)) return -1; // EOF
451 // process headers: 447 // process headers:
452 switch(i){ 448 switch(i){
453 case 0x1B3: mp_header_process_sequence_header (&picture, &videobuffer[start]);break; 449 case 0x1B3: mp_header_process_sequence_header (&picture, &videobuffer[start]);break;
454 case 0x1B5: mp_header_process_extension (&picture, &videobuffer[start]);break; 450 case 0x1B5: mp_header_process_extension (&picture, &videobuffer[start]);break;
455 case 0x1B2: process_userdata (&videobuffer[start], videobuf_len-start);break; 451 case 0x1B2: process_userdata (&videobuffer[start], videobuf_len-start);break;
456 case 0x100: picture_coding_type=(videobuffer[start+1] >> 3) & 7;break; 452 case 0x100: picture_coding_type=(videobuffer[start+1] >> 3) & 7;break;
457 } 453 }
458 } 454 }
459 455
460 *start=videobuffer; in_size=videobuf_len; 456 *start=videobuffer; in_size=videobuf_len;
461 457
462 #if 1 458 #if 1
463 // get mpeg fps: 459 // get mpeg fps:
464 if(sh_video->fps!=picture.fps) if(!force_fps && !telecine){ 460 if(sh_video->fps!=picture.fps) if(!force_fps && !telecine){
465 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 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);
474 videobuf_len=0; 470 videobuf_len=0;
475 471
476 telecine_cnt*=0.9; // drift out error 472 telecine_cnt*=0.9; // drift out error
477 telecine_cnt+=frame_time-5.0/4.0; 473 telecine_cnt+=frame_time-5.0/4.0;
478 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"\r telecine = %3.1f %5.3f \n",frame_time,telecine_cnt); 474 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"\r telecine = %3.1f %5.3f \n",frame_time,telecine_cnt);
479 475
480 if(telecine){ 476 if(telecine){
481 frame_time=1; 477 frame_time=1;
482 if(telecine_cnt<-1.5 || telecine_cnt>1.5){ 478 if(telecine_cnt<-1.5 || telecine_cnt>1.5){
483 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_LeaveTelecineMode); 479 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_LeaveTelecineMode);
484 telecine=0; 480 telecine=0;
485 } 481 }
486 } else 482 } else
487 if(telecine_cnt>-0.5 && telecine_cnt<0.5 && !force_fps){ 483 if(telecine_cnt>-0.5 && telecine_cnt<0.5 && !force_fps){
488 sh_video->fps=sh_video->fps*4/5; 484 sh_video->fps=sh_video->fps*4/5;
489 sh_video->frametime=sh_video->frametime*5/4; 485 sh_video->frametime=sh_video->frametime*5/4;
490 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_EnterTelecineMode); 486 mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_EnterTelecineMode);
491 telecine=1; 487 telecine=1;
492 } 488 }
493
494 } else if(video_codec == VIDEO_MPEG4){ 489 } else if(video_codec == VIDEO_MPEG4){
495 while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){ 490 while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){
496 int i=sync_video_packet(d_video); 491 int i=sync_video_packet(d_video);
497 if(!i) return -1; 492 if(!i) return -1;
498 if(!read_video_packet(d_video)) return -1; // EOF 493 if(!read_video_packet(d_video)) return -1; // EOF
499 if(i==0x1B6) break; 494 if(i==0x1B6) break;
500 } 495 }
501 *start=videobuffer; in_size=videobuf_len; 496 *start=videobuffer; in_size=videobuf_len;
502 videobuf_len=0; 497 videobuf_len=0;
503
504 } else if(video_codec == VIDEO_H264){ 498 } else if(video_codec == VIDEO_H264){
505 int in_picture = 0; 499 int in_picture = 0;
506 while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){ 500 while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){
507 int i=sync_video_packet(d_video); 501 int i=sync_video_packet(d_video);
508 int pos = videobuf_len+4; 502 int pos = videobuf_len+4;
538 if (demux_peekc(d_video) & 0x80) 532 if (demux_peekc(d_video) & 0x80)
539 break; 533 break;
540 } 534 }
541 } 535 }
542 } 536 }
543 *start=videobuffer; in_size=videobuf_len; 537 *start=videobuffer; in_size=videobuf_len;
544 videobuf_len=0; 538 videobuf_len=0;
545
546 } else if(video_codec == VIDEO_VC1) { 539 } else if(video_codec == VIDEO_VC1) {
547 while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE) { 540 while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE) {
548 int i=sync_video_packet(d_video); 541 int i=sync_video_packet(d_video);
549 if(!i) return -1; 542 if(!i) return -1;
550 if(!read_video_packet(d_video)) return -1; // EOF 543 if(!read_video_packet(d_video)) return -1; // EOF
570 563
571 // override frame_time for variable/unknown FPS formats: 564 // override frame_time for variable/unknown FPS formats:
572 if(!force_fps) switch(demuxer->file_format){ 565 if(!force_fps) switch(demuxer->file_format){
573 case DEMUXER_TYPE_GIF: 566 case DEMUXER_TYPE_GIF:
574 case DEMUXER_TYPE_MATROSKA: 567 case DEMUXER_TYPE_MATROSKA:
575 if(d_video->pts>0 && pts1>0 && d_video->pts>pts1) 568 if(d_video->pts>0 && pts1>0 && d_video->pts>pts1)
576 frame_time=d_video->pts-pts1; 569 frame_time=d_video->pts-pts1;
577 break; 570 break;
578 #ifdef USE_TV 571 #ifdef USE_TV
579 case DEMUXER_TYPE_TV: 572 case DEMUXER_TYPE_TV:
580 #endif 573 #endif
581 case DEMUXER_TYPE_MOV: 574 case DEMUXER_TYPE_MOV:
587 double d= (next_pts != MP_NOPTS_VALUE) ? next_pts - d_video->pts : d_video->pts-pts1; 580 double d= (next_pts != MP_NOPTS_VALUE) ? next_pts - d_video->pts : d_video->pts-pts1;
588 if(d>=0){ 581 if(d>=0){
589 if(d>0){ 582 if(d>0){
590 if((int)sh_video->fps==1000) 583 if((int)sh_video->fps==1000)
591 mp_msg(MSGT_CPLAYER,MSGL_V,"\navg. framerate: %d fps \n",(int)(1.0f/d)); 584 mp_msg(MSGT_CPLAYER,MSGL_V,"\navg. framerate: %d fps \n",(int)(1.0f/d));
592 sh_video->frametime=d; // 1ms 585 sh_video->frametime=d; // 1ms
593 sh_video->fps=1.0f/d; 586 sh_video->fps=1.0f/d;
594 } 587 }
595 frame_time = d; 588 frame_time = d;
596 } else { 589 } else {
597 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); 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);
598 // frame_time = 1/25.0; 591 // frame_time = 1/25.0;
599 } 592 }
615 608
616 frame_time = (d >= 0 && pts1 > 0) ? d : 0.001; 609 frame_time = (d >= 0 && pts1 > 0) ? d : 0.001;
617 } 610 }
618 break; 611 break;
619 } 612 }
620 613
621 if(demuxer->file_format==DEMUXER_TYPE_MPEG_PS || 614 if(demuxer->file_format==DEMUXER_TYPE_MPEG_PS ||
622 demuxer->file_format==DEMUXER_TYPE_MPEG_PES || 615 demuxer->file_format==DEMUXER_TYPE_MPEG_PES ||
623 ((demuxer->file_format==DEMUXER_TYPE_MPEG_TS) && ((sh_video->format==0x10000001) || (sh_video->format==0x10000002))) || 616 ((demuxer->file_format==DEMUXER_TYPE_MPEG_TS) && ((sh_video->format==0x10000001) || (sh_video->format==0x10000002))) ||
624 demuxer->file_format==DEMUXER_TYPE_MPEG_ES || 617 demuxer->file_format==DEMUXER_TYPE_MPEG_ES ||
625 demuxer->file_format==DEMUXER_TYPE_MPEG_TY){ 618 demuxer->file_format==DEMUXER_TYPE_MPEG_TY){
626 619
627 620
628 sh_video->pts+=frame_time; 621 sh_video->pts+=frame_time;
629 if(picture_coding_type<=2 && sh_video->i_pts){ 622 if(picture_coding_type<=2 && sh_video->i_pts){
630 sh_video->pts=sh_video->i_pts; 623 sh_video->pts=sh_video->i_pts;
631 sh_video->i_pts=pts; 624 sh_video->i_pts=pts;
632 } else { 625 } else {
633 if(pts){ 626 if(pts){
634 if(picture_coding_type<=2) sh_video->i_pts=pts; 627 if(picture_coding_type<=2) sh_video->i_pts=pts;
635 else { 628 else sh_video->pts=pts;
636 sh_video->pts=pts; 629 }
637 } 630 }
638 }
639 }
640 } else 631 } else
641 sh_video->pts=d_video->pts; 632 sh_video->pts=d_video->pts;
642 633
643 if(frame_time_ptr) *frame_time_ptr=frame_time; 634 if(frame_time_ptr) *frame_time_ptr=frame_time;
644 return in_size; 635 return in_size;
645
646 } 636 }
647 637