From e1fcd3a007591193891df1095f5263e9e5e71958 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sat, 12 Apr 2014 18:13:32 +0200 Subject: flac demuxer: improve seeking --- libavcodec/flac_parser.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libavcodec/flac_parser.c') diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index ba1f060fd9..6ff4d9c85f 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -489,6 +489,14 @@ static int get_best_header(FLACParseContext* fpc, const uint8_t **poutbuf, &fpc->wrap_buf, &fpc->wrap_buf_allocated_size); + + if (fpc->pc->flags & PARSER_FLAG_USE_CODEC_TS){ + if (header->fi.is_var_size) + fpc->pc->pts = header->fi.frame_or_sample_num; + else if (header->best_child) + fpc->pc->pts = header->fi.frame_or_sample_num * header->fi.blocksize; + } + fpc->best_header_valid = 0; fpc->last_fi_valid = 1; fpc->last_fi = header->fi; @@ -516,6 +524,11 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, s->duration = fi.blocksize; if (!avctx->sample_rate) avctx->sample_rate = fi.samplerate; + if (fpc->pc->flags & PARSER_FLAG_USE_CODEC_TS){ + fpc->pc->pts = fi.frame_or_sample_num; + if (!fi.is_var_size) + fpc->pc->pts *= fi.blocksize; + } } *poutbuf = buf; *poutbuf_size = buf_size; -- cgit v1.2.3