Ticket #529: ogg_seek2.diff
| File ogg_seek2.diff, 3.1 KB (added by , 20 years ago) |
|---|
-
libavformat/utils.c
1097 1097 * @param timestamp new dts expressed in time_base of param ref_st 1098 1098 * @param ref_st reference stream giving time_base of param timestamp 1099 1099 */ 1100 staticvoid av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp){1100 void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp){ 1101 1101 int i; 1102 1102 1103 1103 for(i = 0; i < s->nb_streams; i++) { -
libavformat/ogg2.c
201 201 return AVERROR_NOMEM; 202 202 203 203 av_set_pts_info(st, 64, 1, 1000000); 204 st->start_time = 0;205 204 206 205 return idx; 207 206 } … … 495 494 496 495 ogg->size = size; 497 496 ogg_restore (s, 0); 497 ogg_save (s); 498 while (ogg_read_page (s, &i)) { 499 if (i == idx && ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0) 500 break; 501 } 502 if (i == idx) { 503 s->streams[idx]->start_time = ogg_gptopts (s, idx, ogg->streams[idx].granule); 504 s->streams[idx]->duration -= s->streams[idx]->start_time; 505 } 506 ogg_restore (s, 0); 498 507 499 508 return 0; 500 509 } … … 572 581 ogg_t *ogg = s->priv_data; 573 582 ByteIOContext *bc = &s->pb; 574 583 uint64_t min = 0, max = ogg->size; 575 uint64_t tmin = 0, tmax =st->duration;584 uint64_t tmin = st->start_time, tmax = st->start_time + st->duration; 576 585 int64_t pts = AV_NOPTS_VALUE; 577 586 578 587 ogg_save (s); 579 588 580 while (min <= max){ 589 if ((uint64_t)target_ts < tmin || target_ts < 0) 590 target_ts = tmin; 591 while (min <= max && tmin < tmax){ 581 592 uint64_t p = min + (max - min) * (target_ts - tmin) / (tmax - tmin); 582 593 int i = -1; 583 594 … … 599 610 break; 600 611 601 612 if (pts > target_ts){ 613 if (max == p && tmax == pts) 614 // probably our tmin is wrong, causing us to always end up too late in the file 615 tmin = (target_ts + tmin) / 2; 602 616 max = p; 603 617 tmax = pts; 604 618 }else{ 619 if (min == p && tmin == pts) 620 // probably our tmax is wrong, causing us to always end up too early in the file 621 tmax = (target_ts + tmax) / 2; 605 622 min = p; 606 623 tmin = pts; 607 624 } … … 615 632 pts = AV_NOPTS_VALUE; 616 633 } 617 634 618 return pts; 635 av_update_cur_dts(s, st, pts); 636 return 0; 619 637 620 638 #if 0 621 639 //later... -
libavformat/avformat.h
472 472 int av_add_index_entry(AVStream *st, 473 473 int64_t pos, int64_t timestamp, int size, int distance, int flags); 474 474 int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags); 475 void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); 475 476 476 477 /* media file output */ 477 478 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
