From ef8cc06d6e50d3da7b781e126a3bce7929b53a55 Mon Sep 17 00:00:00 2001 From: Nigel Touati-Evans Date: Thu, 4 Jul 2013 16:51:32 +0100 Subject: [PATCH] avformat/avidec: Fix incorrect detection of badly interleaved avi The method guess_ni_flag needs to divide timestamps in the index by sample_size if it is set in order to compare different streams correctly. Signed-off-by: Michael Niedermayer --- libavcodec/version.h | 2 +- libavformat/avidec.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/version.h b/libavcodec/version.h index f6e2d71c9f..32834460b5 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #define LIBAVCODEC_VERSION_MAJOR 55 #define LIBAVCODEC_VERSION_MINOR 18 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MICRO 102 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavformat/avidec.c b/libavformat/avidec.c index f5c234552d..a09bebd57c 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -1397,15 +1397,16 @@ static int guess_ni_flag(AVFormatContext *s){ for (i=0; inb_streams; i++) { AVStream *st = s->streams[i]; + AVIStream *ast = st->priv_data; int n= st->nb_index_entries; while (idx[i]index_entries[idx[i]].pos < pos) idx[i]++; if (idx[i] < n) { - min_dts = FFMIN(min_dts, av_rescale_q(st->index_entries[idx[i]].timestamp, st->time_base, AV_TIME_BASE_Q)); + min_dts = FFMIN(min_dts, av_rescale_q(st->index_entries[idx[i]].timestamp/FFMAX(ast->sample_size, 1), st->time_base, AV_TIME_BASE_Q)); min_pos = FFMIN(min_pos, st->index_entries[idx[i]].pos); } if (idx[i]) - max_dts = FFMAX(max_dts, av_rescale_q(st->index_entries[idx[i]-1].timestamp, st->time_base, AV_TIME_BASE_Q)); + max_dts = FFMAX(max_dts, av_rescale_q(st->index_entries[idx[i]-1].timestamp/FFMAX(ast->sample_size, 1), st->time_base, AV_TIME_BASE_Q)); } if(max_dts - min_dts > 2*AV_TIME_BASE) { av_free(idx);