Revision 411ff322

View differences:

libavformat/utils.c
1771 1771
}
1772 1772

  
1773 1773
#define DURATION_MAX_READ_SIZE 250000
1774
#define DURATION_MAX_RETRY 3
1774 1775

  
1775 1776
/* only usable for MPEG-PS streams */
1776 1777
static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
......
1780 1781
    int read_size, i, ret;
1781 1782
    int64_t end_time, start_time[MAX_STREAMS];
1782 1783
    int64_t filesize, offset, duration;
1784
    int retry=0;
1783 1785

  
1784 1786
    ic->cur_st = NULL;
1785 1787

  
......
1805 1807
    /* estimate the end time (duration) */
1806 1808
    /* XXX: may need to support wrapping */
1807 1809
    filesize = ic->file_size;
1808
    offset = filesize - DURATION_MAX_READ_SIZE;
1810
    end_time = AV_NOPTS_VALUE;
1811
    do{
1812
    offset = filesize - (DURATION_MAX_READ_SIZE<<retry);
1809 1813
    if (offset < 0)
1810 1814
        offset = 0;
1811 1815

  
1812 1816
    url_fseek(ic->pb, offset, SEEK_SET);
1813 1817
    read_size = 0;
1814 1818
    for(;;) {
1815
        if (read_size >= DURATION_MAX_READ_SIZE)
1819
        if (read_size >= DURATION_MAX_READ_SIZE<<(FFMAX(retry-1,0)))
1816 1820
            break;
1817 1821

  
1818 1822
        do{
......
1836 1840
        }
1837 1841
        av_free_packet(pkt);
1838 1842
    }
1843
    }while(   end_time==AV_NOPTS_VALUE
1844
           && filesize > (DURATION_MAX_READ_SIZE<<retry)
1845
           && ++retry <= DURATION_MAX_RETRY);
1839 1846

  
1840 1847
    fill_all_stream_timings(ic);
1841 1848

  

Also available in: Unified diff