Commit d05625bd authored by Reimar Döffinger's avatar Reimar Döffinger

avidec: handle 0-size packets that exist only in index.

0-sized packets are used to implement variable fps.
However there seems to be a variation where these are not
even stored in the main file but as 0-size index entries
only.
This fixes the sample in trac issue #957, it now plays both
the same ways as in MPlayer and in a way that looks correct.
Signed-off-by: 's avatarReimar Döffinger <Reimar.Doeffinger@gmx.de>
parent 4c53c66a
...@@ -1236,6 +1236,7 @@ static int avi_read_idx1(AVFormatContext *s, int size) ...@@ -1236,6 +1236,7 @@ static int avi_read_idx1(AVFormatContext *s, int size)
AVIStream *ast; AVIStream *ast;
unsigned int index, tag, flags, pos, len, first_packet = 1; unsigned int index, tag, flags, pos, len, first_packet = 1;
unsigned last_pos= -1; unsigned last_pos= -1;
unsigned last_len= 0;
int64_t idx1_pos, first_packet_pos = 0, data_offset = 0; int64_t idx1_pos, first_packet_pos = 0, data_offset = 0;
nb_index_entries = size / 16; nb_index_entries = size / 16;
...@@ -1278,12 +1279,16 @@ static int avi_read_idx1(AVFormatContext *s, int size) ...@@ -1278,12 +1279,16 @@ static int avi_read_idx1(AVFormatContext *s, int size)
av_dlog(s, "%d cum_len=%"PRId64"\n", len, ast->cum_len); av_dlog(s, "%d cum_len=%"PRId64"\n", len, ast->cum_len);
// even if we have only a single stream, we should
// switch to non-interleaved to get correct timestamps
if(last_pos == pos) if(last_pos == pos)
avi->non_interleaved= 1; avi->non_interleaved= 1;
else if(len || !ast->sample_size) if((last_pos != pos || !last_len) && (len || !ast->sample_size)) {
av_add_index_entry(st, pos, ast->cum_len, len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0); av_add_index_entry(st, pos, ast->cum_len, len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
}
ast->cum_len += get_duration(ast, len); ast->cum_len += get_duration(ast, len);
last_pos= pos; last_pos= pos;
last_len= len;
} }
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment