comparison libmpdemux/demuxer.c @ 18917:d9a75b26da6c

Add a new video pts tracking mode, enabled by option -correct-pts. This mode has the following differences: - Video timing is correct for streams with B frames, at least with some demuxers. - Video filters can modify frame timestamps and insert new frames, and removing frames is handled better than before. - Some things are known to break, it's not usable as the default yet. Things should work as before when the -correct-pts option is not used.
author uau
date Thu, 06 Jul 2006 06:58:17 +0000
parents 0b53e6d1b27f
children 75327b24e06f
comparison
equal deleted inserted replaced
18916:a95ed361d16b 18917:d9a75b26da6c
353 ds->buffer_pos=0; 353 ds->buffer_pos=0;
354 ds->buffer_size=p->len; 354 ds->buffer_size=p->len;
355 ds->pos=p->pos; 355 ds->pos=p->pos;
356 ds->dpos+=p->len; // !!! 356 ds->dpos+=p->len; // !!!
357 ++ds->pack_no; 357 ++ds->pack_no;
358 if(p->pts){ 358 if (p->pts != (correct_pts ? MP_NOPTS_VALUE : 0)) {
359 ds->pts=p->pts; 359 ds->pts=p->pts;
360 ds->pts_bytes=0; 360 ds->pts_bytes=0;
361 } 361 }
362 ds->pts_bytes+=p->len; // !!! 362 ds->pts_bytes+=p->len; // !!!
363 ds->flags=p->flags; 363 ds->flags=p->flags;
509 if (!ds_fill_buffer(ds)) { 509 if (!ds_fill_buffer(ds)) {
510 // EOF 510 // EOF
511 *start = NULL; 511 *start = NULL;
512 return -1; 512 return -1;
513 } 513 }
514 // Should use MP_NOPTS_VALUE for "unknown pts" in the packets too 514 }
515 if (ds->current->pts) 515 // Should use MP_NOPTS_VALUE for "unknown pts" in the packets too
516 *pts = ds->current->pts; 516 // Return pts unless this read starts from the middle of a packet
517 } 517 if (!ds->buffer_pos && (correct_pts || ds->current->pts))
518 *pts = ds->current->pts;
518 len=ds->buffer_size-ds->buffer_pos; 519 len=ds->buffer_size-ds->buffer_pos;
519 *start = &ds->buffer[ds->buffer_pos]; 520 *start = &ds->buffer[ds->buffer_pos];
520 ds->buffer_pos+=len; 521 ds->buffer_pos+=len;
521 return len; 522 return len;
522 } 523 }
621 622
622 return -1; 623 return -1;
623 } 624 }
624 625
625 int extension_parsing=1; // 0=off 1=mixed (used only for unstable formats) 626 int extension_parsing=1; // 0=off 1=mixed (used only for unstable formats)
627
628 int correct_pts=0;
626 629
627 /* 630 /*
628 NOTE : Several demuxers may be opened at the same time so 631 NOTE : Several demuxers may be opened at the same time so
629 demuxers should NEVER rely on an external var to enable them 632 demuxers should NEVER rely on an external var to enable them
630 self. If a demuxer can't do any autodection it should only use 633 self. If a demuxer can't do any autodection it should only use