Revision a74008a4

View differences:

libavcodec/avcodec.h
37 37
#define AV_STRINGIFY(s)         AV_TOSTRING(s)
38 38
#define AV_TOSTRING(s) #s
39 39

  
40
#define LIBAVCODEC_VERSION_INT  ((51<<16)+(40<<8)+2)
41
#define LIBAVCODEC_VERSION      51.40.2
40
#define LIBAVCODEC_VERSION_INT  ((51<<16)+(40<<8)+3)
41
#define LIBAVCODEC_VERSION      51.40.3
42 42
#define LIBAVCODEC_BUILD        LIBAVCODEC_VERSION_INT
43 43

  
44 44
#define LIBAVCODEC_IDENT        "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
......
2940 2940

  
2941 2941
    int flags;
2942 2942
#define PARSER_FLAG_COMPLETE_FRAMES           0x0001
2943

  
2944
    int64_t offset;      ///< byte offset from starting packet start
2945
    int64_t last_offset;
2943 2946
} AVCodecParserContext;
2944 2947

  
2945 2948
typedef struct AVCodecParser {
libavcodec/parser.c
124 124
            s->fetch_timestamp=0;
125 125
            s->last_pts = pts;
126 126
            s->last_dts = dts;
127
            s->last_offset = 0;
127 128
            s->cur_frame_pts[k] =
128 129
            s->cur_frame_dts[k] = AV_NOPTS_VALUE;
129 130
        }
......
138 139
        s->frame_offset = s->last_frame_offset;
139 140
        s->pts = s->last_pts;
140 141
        s->dts = s->last_dts;
142
        s->offset = s->last_offset;
141 143

  
142 144
        /* offset of the next frame */
143 145
        s->last_frame_offset = s->cur_offset + index;
......
156 158

  
157 159
        s->last_pts = s->cur_frame_pts[k];
158 160
        s->last_dts = s->cur_frame_dts[k];
161
        s->last_offset = s->last_frame_offset - s->cur_frame_offset[k];
159 162

  
160 163
        /* some parsers tell us the packet size even before seeing the first byte of the next packet,
161 164
           so the next pts/dts is in the next chunk */
libavformat/avformat.h
25 25
extern "C" {
26 26
#endif
27 27

  
28
#define LIBAVFORMAT_VERSION_INT ((51<<16)+(12<<8)+0)
29
#define LIBAVFORMAT_VERSION     51.12.0
28
#define LIBAVFORMAT_VERSION_INT ((51<<16)+(12<<8)+1)
29
#define LIBAVFORMAT_VERSION     51.12.1
30 30
#define LIBAVFORMAT_BUILD       LIBAVFORMAT_VERSION_INT
31 31

  
32 32
#define LIBAVFORMAT_IDENT       "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
......
309 309
    char language[4]; /** ISO 639 3-letter language code (empty string if undefined) */
310 310

  
311 311
    /* av_read_frame() support */
312
    int need_parsing;                  ///< 1->full parsing needed, 2->only parse headers dont repack
312
#define AVSTREAM_PARSE_TIMESTAMPS 3    /**< full parsing and interpolation of timestamps for frames not starting on packet boundary */
313
    int need_parsing;                  ///< 1->full parsing needed, 2->only parse headers dont repack, 3->full parsing and interpolate timestamps
313 314
    struct AVCodecParserContext *parser;
314 315

  
315 316
    int64_t cur_dts;
libavformat/avidec.c
452 452
                    if (size%2) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
453 453
                        url_fskip(pb, 1);
454 454
                    /* Force parsing as several audio frames can be in
455
                     * one packet. */
456
                    st->need_parsing = 1;
455
                     * one packet and timestamps refer to packet start*/
456
                    st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
457 457
                    /* ADTS header is in extradata, AAC without header must be stored as exact frames, parser not needed and it will fail */
458 458
                    if (st->codec->codec_id == CODEC_ID_AAC && st->codec->extradata_size)
459 459
                        st->need_parsing = 0;
libavformat/utils.c
584 584
                               AVCodecParserContext *pc, AVPacket *pkt)
585 585
{
586 586
    int num, den, presentation_delayed, delay, i;
587
    int64_t offset;
587 588
    /* handle wrapping */
588 589
    if(st->cur_dts != AV_NOPTS_VALUE){
589 590
        if(pkt->pts != AV_NOPTS_VALUE)
......
599 600
        }
600 601
    }
601 602

  
603
    /* correct timestamps with byte offset if demuxers only have timestamps on packet boundaries */
604
    if(pc && st->need_parsing == AVSTREAM_PARSE_TIMESTAMPS && pkt->size){
605
        /* this will estimate bitrate based on this frame's duration and size */
606
        offset = av_rescale(pc->offset, pkt->duration, pkt->size);
607
        if(pkt->pts != AV_NOPTS_VALUE)
608
            pkt->pts += offset;
609
        if(pkt->dts != AV_NOPTS_VALUE)
610
            pkt->dts += offset;
611
    }
612

  
602 613
    if(is_intra_only(st->codec))
603 614
        pkt->flags |= PKT_FLAG_KEY;
604 615

  

Also available in: Unified diff