[FFmpeg-devel] [PATCH] compute chapters end

Michael Niedermayer michaelni
Sat May 24 17:21:20 CEST 2008


On Sat, May 24, 2008 at 04:13:17PM +0200, Aurelien Jacobs wrote:
> On Sat, 24 May 2008 16:01:21 +0200
> Aurelien Jacobs <aurel at gnuage.org> wrote:
> 
> > Hi,
> > 
> > Attached patch will compute the end of all chapters when end
> > is not specified in the container.
> 
> Oh, and here is a version which won't segfault when no chapters
> are present.
> 
> Aurel

> Index: libavformat/utils.c
> ===================================================================
> --- libavformat/utils.c	(revision 13280)
> +++ libavformat/utils.c	(working copy)
> @@ -1805,6 +1805,20 @@
>      return CODEC_ID_NONE;
>  }
>  
> +static void compute_chapters_end(AVFormatContext *s)
> +{
> +    unsigned int i;
> +
> +    for (i=0; i+1<s->nb_chapters; i++)
> +        if (s->chapters[i]->end == AV_NOPTS_VALUE)
> +            s->chapters[i]->end = s->chapters[i+1]->start;
> +
> +    if (s->nb_chapters && s->chapters[i]->end == AV_NOPTS_VALUE)
> +        s->chapters[i]->end = av_rescale_q(s->start_time + s->duration,
> +                                           AV_TIME_BASE_Q,
> +                                           s->chapters[i]->time_base);
> +}

This needs a few asserts
s->chapters[i]->start <= s->chapters[i+1]->start
s->chapters[i]->time_base == s->chapters[i+1]->time_base
s->start_time != AV_NOPTS_VALUE
s->duration>0

I assume these are guranteed to be true whenever end == AV_NOPTS_VALUE 
currently, the asserts() would ensure that future changes dont lead to
hard to debug issues.

besides these iam fine with the patch

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080524/f67914e7/attachment.pgp>



More information about the ffmpeg-devel mailing list