Revision 27ca0a79 libavformat/utils.c

View differences:

libavformat/utils.c
834 834
            pkt->dts += offset;
835 835
    }
836 836

  
837
    if (pc && pc->dts_sync_point >= 0) {
838
        // we have synchronization info from the parser
839
        int64_t den = st->codec->time_base.den * (int64_t) st->time_base.num;
840
        if (den > 0) {
841
            int64_t num = st->codec->time_base.num * (int64_t) st->time_base.den;
842
            if (pkt->dts != AV_NOPTS_VALUE) {
843
                // got DTS from the stream, update reference timestamp
844
                st->reference_dts = pkt->dts - pc->dts_ref_dts_delta * num / den;
845
                pkt->pts = pkt->dts + pc->pts_dts_delta * num / den;
846
            } else if (st->reference_dts != AV_NOPTS_VALUE) {
847
                // compute DTS based on reference timestamp
848
                pkt->dts = st->reference_dts + pc->dts_ref_dts_delta * num / den;
849
                pkt->pts = pkt->dts + pc->pts_dts_delta * num / den;
850
            }
851
            if (pc->dts_sync_point > 0)
852
                st->reference_dts = pkt->dts; // new reference
853
        }
854
    }
855

  
837 856
    /* This may be redundant, but it should not hurt. */
838 857
    if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts > pkt->dts)
839 858
        presentation_delayed = 1;
......
1157 1176
        }
1158 1177
        st->last_IP_pts = AV_NOPTS_VALUE;
1159 1178
        st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */
1179
        st->reference_dts = AV_NOPTS_VALUE;
1160 1180
        /* fail safe */
1161 1181
        st->cur_ptr = NULL;
1162 1182
        st->cur_len = 0;
......
2332 2352
    st->last_IP_pts = AV_NOPTS_VALUE;
2333 2353
    for(i=0; i<MAX_REORDER_DELAY+1; i++)
2334 2354
        st->pts_buffer[i]= AV_NOPTS_VALUE;
2355
    st->reference_dts = AV_NOPTS_VALUE;
2335 2356

  
2336 2357
    st->sample_aspect_ratio = (AVRational){0,1};
2337 2358

  

Also available in: Unified diff