[FFmpeg-devel] [PATCH] Fix incorrect detection of badly interleaved avi
Michael Niedermayer
michaelni at gmx.at
Fri Jul 5 22:07:50 CEST 2013
On Fri, Jul 05, 2013 at 11:46:22AM +0100, Nigel Touati-Evans wrote:
> On 4 July 2013 19:53, Michael Niedermayer <michaelni at gmx.at> wrote:
>
> > On Thu, Jul 04, 2013 at 04:51:32PM +0100, Nigel Touati-Evans wrote:
> > > 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.
> >
> > commit message should start with "avidec:" or something like that
> >
> >
> > > diff --git a/libavformat/avidec.c b/libavformat/avidec.c
> > > index f5c2345..a09bebd 100644
> > > --- a/libavformat/avidec.c
> > > +++ b/libavformat/avidec.c
> > > @@ -1397,15 +1397,16 @@ static int guess_ni_flag(AVFormatContext *s){
> > >
> > > for (i=0; i<s->nb_streams; i++) {
> > > AVStream *st = s->streams[i];
> > > + AVIStream *ast = st->priv_data;
> > > int n= st->nb_index_entries;
> > > while (idx[i]<n && st->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));
> >
> > the rounding looks wrong
> >
> > (AVRational){FFMAX(1, ast->sample_size), AV_TIME_BASE}
> > is used elsewhere in the file instead of AV_TIME_BASE_Q for this
> > purpose
> >
> > also do you have a file or testcase that needs this ? i wasnt able to
> > find one where this patch made a difference
> >
> > Thanks
> >
> > [...]
> >
> > --
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > If you think the mosad wants you dead since a long time then you are either
> > wrong or dead since a long time.
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> >
> Sorry, didn't know about the commit message format, I will prefix with the
> relevant filename this in the future.
>
> I have done the rounding like that so that it is identical to the
> corresponding test done during demuxing in avi_read_packet:
>
> 1209<http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/avidec.c;h=f5c234552d0e11a66b29613edab20fadf114ece7;hb=HEAD#l1209>
> if(ast->sample_size)
> 1210<http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/avidec.c;h=f5c234552d0e11a66b29613edab20fadf114ece7;hb=HEAD#l1210>
> pkt->dts /= ast->sample_size;
>
> ...
>
> 1262<http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/avidec.c;h=f5c234552d0e11a66b29613edab20fadf114ece7;hb=HEAD#l1262>
> if(!avi->non_interleaved && st->nb_index_entries>1 &&
> avi->index_loaded>1){
> 1263<http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/avidec.c;h=f5c234552d0e11a66b29613edab20fadf114ece7;hb=HEAD#l1263>
> int64_t dts= av_rescale_q(pkt->dts, st->time_base,
> AV_TIME_BASE_Q);
> 1264<http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/avidec.c;h=f5c234552d0e11a66b29613edab20fadf114ece7;hb=HEAD#l1264>
> 1265<http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/avidec.c;h=f5c234552d0e11a66b29613edab20fadf114ece7;hb=HEAD#l1265>
> if(avi->dts_max - dts > 2*AV_TIME_BASE){
> 1266<http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/avidec.c;h=f5c234552d0e11a66b29613edab20fadf114ece7;hb=HEAD#l1266>
> avi->non_interleaved= 1;
> 1267<http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/avidec.c;h=f5c234552d0e11a66b29613edab20fadf114ece7;hb=HEAD#l1267>
> av_log(s, AV_LOG_INFO, "Switching to NI mode, due to
> poor interleaving\n");
>
> Here the division is done first, and then the conversion to AV_TIME_BASE. I
> have no objection to updating the patch to do it as you have suggested and
> combining the two though, if you think that would better.
I think it makes no real difference for this case
so patch applied
thanks
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130705/829e9dbb/attachment.asc>
More information about the ffmpeg-devel
mailing list