[FFmpeg-devel] [PATCH] Base parser frame_offset on correct packet pos.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Apr 9 23:47:19 CEST 2011


The current code only works if the next buffer starts directly
after the previous one in the file. For formats with some sort
of framing that is not necessarily the case.
Without this change, GENERIC_INDEX with needs_parsing and framing
that causes the stream to be non-consecutive results in a broken
index being generated.
This is probably also a bug in the generic index code, it probably
should ignore the parser output and instead always seek to some
pkt->pos, or at the very least only use it when full parsing is requested.
---
 libavcodec/parser.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index 34659b7..91d4906 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -194,6 +194,9 @@ int av_parser_parse2(AVCodecParserContext *s,
         s->next_frame_offset = s->cur_offset + index;
         s->fetch_timestamp=1;
     }
+    // next frame offsets are based next packet start
+    if (index == buf_size)
+        s->flags &= ~PARSER_FLAG_FETCHED_OFFSET;
     if (index < 0)
         index = 0;
     s->cur_offset += index;
-- 
1.7.4.1



More information about the ffmpeg-devel mailing list