Revision 15bc38e5 libavformat/utils.c

View differences:

libavformat/utils.c
1726 1726
    AVStream *st;
1727 1727
    AVPacket pkt1, *pkt;
1728 1728
    AVPacketList *pktl=NULL, **ppktl;
1729
    int64_t last_dts[MAX_STREAMS];
1730
    int64_t best_duration[MAX_STREAMS];
1729 1731

  
1732
    for(i=0;i<MAX_STREAMS;i++){
1733
        last_dts[i]= AV_NOPTS_VALUE;
1734
        best_duration[i]= INT64_MAX;
1735
    }
1736
    
1730 1737
    count = 0;
1731 1738
    read_size = 0;
1732 1739
    ppktl = &ic->packet_buffer;
......
1792 1799
        if (pkt->duration != 0)
1793 1800
            st->codec_info_nb_frames++;
1794 1801

  
1802
        if(st->codec.codec_type == CODEC_TYPE_VIDEO){
1803
            int64_t last= last_dts[pkt->stream_index];
1804
            
1805
            if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && last < pkt->dts && 
1806
               best_duration[pkt->stream_index] > pkt->dts - last){
1807
                best_duration[pkt->stream_index] = pkt->dts - last;
1808
            }
1809
            last_dts[pkt->stream_index]= pkt->dts;
1810
        }
1795 1811
        /* if still no information, we try to open the codec and to
1796 1812
           decompress the frame. We try to avoid that in most cases as
1797 1813
           it takes longer and uses more memory. For MPEG4, we need to
......
1823 1839
        if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
1824 1840
            if(st->codec.codec_id == CODEC_ID_RAWVIDEO && !st->codec.codec_tag && !st->codec.bits_per_sample)
1825 1841
                st->codec.codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec.pix_fmt);
1842

  
1843
            if(best_duration[i] < INT64_MAX && st->codec.frame_rate_base*1000 <= st->codec.frame_rate){
1844
                st->r_frame_rate= st->codec.frame_rate;
1845
                st->r_frame_rate_base= av_rescale(best_duration[i], st->codec.frame_rate, AV_TIME_BASE);
1846
                av_reduce(&st->r_frame_rate, &st->r_frame_rate_base, st->r_frame_rate, st->r_frame_rate_base, 1<<15);
1847
            }
1848

  
1826 1849
            /* set real frame rate info */
1827 1850
            /* compute the real frame rate for telecine */
1828 1851
            if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO ||

Also available in: Unified diff