[FFmpeg-devel] [PATCH] avidec: Mark first frame as keyframe in case there are no keyframes.
Michael Niedermayer
michaelni at gmx.at
Mon Jan 30 23:58:23 CET 2012
This fixes seeking in filecopy.avi of Ticket504
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
libavformat/avidec.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 704980c..226da27 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1236,6 +1236,7 @@ static int avi_read_idx1(AVFormatContext *s, int size)
unsigned int index, tag, flags, pos, len, first_packet = 1;
unsigned last_pos= -1;
int64_t idx1_pos, first_packet_pos = 0, data_offset = 0;
+ int anykey = 0;
nb_index_entries = size / 16;
if (nb_index_entries <= 0)
@@ -1283,6 +1284,14 @@ static int avi_read_idx1(AVFormatContext *s, int size)
av_add_index_entry(st, pos, ast->cum_len, len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
ast->cum_len += get_duration(ast, len);
last_pos= pos;
+ anykey |= flags&AVIIF_INDEX;
+ }
+ if (!anykey) {
+ for (index = 0; index < s->nb_streams; index++) {
+ st = s->streams[index];
+ if (st->nb_index_entries)
+ st->index_entries[0].flags |= AVINDEX_KEYFRAME;
+ }
}
return 0;
}
--
1.7.5.4
More information about the ffmpeg-devel
mailing list