Revision 27ca0a79

View differences:

libavcodec/avcodec.h
30 30
#include "libavutil/avutil.h"
31 31

  
32 32
#define LIBAVCODEC_VERSION_MAJOR 52
33
#define LIBAVCODEC_VERSION_MINOR 18
33
#define LIBAVCODEC_VERSION_MINOR 19
34 34
#define LIBAVCODEC_VERSION_MICRO  0
35 35

  
36 36
#define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
3147 3147
     * subtitles are correctly displayed after seeking.
3148 3148
     */
3149 3149
    int64_t convergence_duration;
3150

  
3151
    // Timestamp generation support:
3152
    /**
3153
     * Synchronization point for start of timestamp generation.
3154
     *
3155
     * Set to >0 for sync point, 0 for no sync point and <0 for undefined
3156
     * (default).
3157
     *
3158
     * For example, this corresponds to presence of H.264 buffering period
3159
     * SEI message.
3160
     */
3161
    int dts_sync_point;
3162

  
3163
    /**
3164
     * Offset of the current timestamp against last timestamp sync point in
3165
     * units of AVCodecContext.time_base.
3166
     *
3167
     * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
3168
     * contain a valid timestamp offset.
3169
     *
3170
     * Note that the timestamp of sync point has usually a nonzero
3171
     * dts_ref_dts_delta, which refers to the previous sync point. Offset of
3172
     * the next frame after timestamp sync point will be usually 1.
3173
     *
3174
     * For example, this corresponds to H.264 cpb_removal_delay.
3175
     */
3176
    int dts_ref_dts_delta;
3177

  
3178
    /**
3179
     * Presentation delay of current frame in units of AVCodecContext.time_base.
3180
     *
3181
     * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
3182
     * contain valid non-negative timestamp delta (presentation time of a frame
3183
     * must not lie in the past).
3184
     *
3185
     * This delay represents the difference between decoding and presentation
3186
     * time of the frame.
3187
     *
3188
     * For example, this corresponds to H.264 dpb_output_delay.
3189
     */
3190
    int pts_dts_delta;
3150 3191
} AVCodecParserContext;
3151 3192

  
3152 3193
typedef struct AVCodecParser {
libavcodec/parser.c
75 75
    s->pict_type = FF_I_TYPE;
76 76
    s->key_frame = -1;
77 77
    s->convergence_duration = AV_NOPTS_VALUE;
78
    s->dts_sync_point       = INT_MIN;
79
    s->dts_ref_dts_delta    = INT_MIN;
80
    s->pts_dts_delta        = INT_MIN;
78 81
    return s;
79 82
}
80 83

  
libavformat/avformat.h
22 22
#define AVFORMAT_AVFORMAT_H
23 23

  
24 24
#define LIBAVFORMAT_VERSION_MAJOR 52
25
#define LIBAVFORMAT_VERSION_MINOR 29
26
#define LIBAVFORMAT_VERSION_MICRO  2
25
#define LIBAVFORMAT_VERSION_MINOR 30
26
#define LIBAVFORMAT_VERSION_MICRO  0
27 27

  
28 28
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
29 29
                                               LIBAVFORMAT_VERSION_MINOR, \
......
494 494
    const uint8_t *cur_ptr;
495 495
    int cur_len;
496 496
    AVPacket cur_pkt;
497

  
498
    // Timestamp generation support:
499
    /**
500
     * Timestamp corresponding to the last dts sync point.
501
     *
502
     * Initialized when AVCodecParserContext.dts_sync_point >= 0 and
503
     * a DTS is received from the underlying container. Otherwise set to
504
     * AV_NOPTS_VALUE by default.
505
     */
506
    int64_t reference_dts;
497 507
} AVStream;
498 508

  
499 509
#define AV_PROGRAM_RUNNING 1
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