X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fparser.c;h=0b007e9ee4bce8fa63f4092328fd443c2220d0e2;hb=86decad65240ea9e1bea177f1091f80d08b62402;hp=9a9424f0cbd972016dd85b9287ded3c9027134e5;hpb=2cc304215d53b1e4140508f10c407c29754687e9;p=ffmpeg diff --git a/libavcodec/parser.c b/libavcodec/parser.c index 9a9424f0cbd..0b007e9ee4b 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -85,14 +85,17 @@ void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){ int i; s->dts= s->pts= AV_NOPTS_VALUE; + s->pos= -1; s->offset= 0; for(i = 0; i < AV_PARSER_PTS_NB; i++) { if ( s->cur_offset + off >= s->cur_frame_offset[i] - &&(s-> frame_offset < s->cur_frame_offset[i] || !s->frame_offset) + && (s->frame_offset < s->cur_frame_offset[i] || + (!s->frame_offset && !s->next_frame_offset)) // first field/frame //check is disabled becausue mpeg-ts doesnt send complete PES packets && /*s->next_frame_offset + off <*/ s->cur_frame_end[i]){ s->dts= s->cur_frame_dts[i]; s->pts= s->cur_frame_pts[i]; + s->pos= s->cur_frame_pos[i]; s->offset = s->next_frame_offset - s->cur_frame_offset[i]; if(remove) s->cur_frame_offset[i]= INT64_MAX; @@ -125,12 +128,24 @@ void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){ * decode_frame(data, size); * } * @endcode + * + * @deprecated Use av_parser_parse2() instead. */ int av_parser_parse(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int64_t pts, int64_t dts) +{ + return av_parser_parse2(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts, AV_NOPTS_VALUE); +} + +int av_parser_parse2(AVCodecParserContext *s, + AVCodecContext *avctx, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, + int64_t pts, int64_t dts, + int64_t pos) { int index, i; uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE]; @@ -139,22 +154,23 @@ int av_parser_parse(AVCodecParserContext *s, /* padding is always necessary even if EOF, so we add it here */ memset(dummy_buf, 0, sizeof(dummy_buf)); buf = dummy_buf; - } else { + } else if (s->cur_offset + buf_size != + s->cur_frame_end[s->cur_frame_start_index]) { /* skip remainder packets */ /* add a new packet descriptor */ - if(pts != AV_NOPTS_VALUE || dts != AV_NOPTS_VALUE){ i = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1); s->cur_frame_start_index = i; s->cur_frame_offset[i] = s->cur_offset; s->cur_frame_end[i] = s->cur_offset + buf_size; s->cur_frame_pts[i] = pts; s->cur_frame_dts[i] = dts; - } + s->cur_frame_pos[i] = pos; } if (s->fetch_timestamp){ s->fetch_timestamp=0; s->last_pts = s->pts; s->last_dts = s->dts; + s->last_pos = s->pos; ff_fetch_timestamp(s, 0, 0); }