[FFmpeg-devel] [patch 3/3] Make timing calculations less dependant on start_time being defined.

Michael Niedermayer michaelni
Sat Aug 18 03:26:21 CEST 2007


Hi

On Thu, Aug 16, 2007 at 04:27:11PM +1000, neilb at suse.de wrote:
> If a stream has no start time defined, we should leave it undefined,
> and not let that interfere with correct setting of the duration.
> 
> So:
> - Change av_update_stream_timings to track overall duration as well
>   as start and end times, and use that duration if start and end
>   are not both defined.
> - fill_all_stream_timings should not set start_time to 0 if it is
>   undefined.
> - av_has_timines should consider just one valid 'duration' as enough
>   to set the duration of the whole thus avoiding the need to estimate
>   the duration based on bitrate.
> ---
>  libavformat/utils.c |   28 +++++++++++++++++-----------
>  1 file changed, 17 insertions(+), 11 deletions(-)
> 
> --- ffmpeg.orig/libavformat/utils.c
> +++ ffmpeg/libavformat/utils.c
> @@ -1359,9 +1359,9 @@ int av_seek_frame(AVFormatContext *s, in
>  /*******************************************************/
>  
>  /**
> - * Returns TRUE if the stream has accurate timings in any stream.
> + * Returns TRUE if the stream has accurate duration in any stream.
>   *
> - * @return TRUE if the stream has accurate timings for at least one component.
> + * @return TRUE if the stream has accurate duration for at least one component.
>   */
>  static int av_has_timings(AVFormatContext *ic)
>  {
> @@ -1370,8 +1370,7 @@ static int av_has_timings(AVFormatContex
>  
>      for(i = 0;i < ic->nb_streams; i++) {
>          st = ic->streams[i];
> -        if (st->start_time != AV_NOPTS_VALUE &&
> -            st->duration != AV_NOPTS_VALUE)
> +        if (st->duration != AV_NOPTS_VALUE)
>              return 1;
>      }
>      return 0;

the functions name no longer matches what it does ...
has_duration() would make more sense


[...]
>                      end_time = end_time1;
>              }
>          }
> +	if (st->duration != AV_NOPTS_VALUE) {
> +		duration1 = av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q);
> +		if (duration1 > duration)
> +			duration = duration1;
> +	}

tabs are forbidden in ffmpeg svn


[...]

> @@ -1460,11 +1469,8 @@ static void av_estimate_timings_from_bit
>              for(i = 0; i < ic->nb_streams; i++) {
>                  st = ic->streams[i];
>                  duration= av_rescale(8*filesize, st->time_base.den, ic->bit_rate*(int64_t)st->time_base.num);
> -                if (st->start_time == AV_NOPTS_VALUE ||
> -                    st->duration == AV_NOPTS_VALUE) {
> -                    st->start_time = 0;
> +                if (st->duration == AV_NOPTS_VALUE)
>                      st->duration = duration;
> -                }
>              }
>          }

applied this hunk


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

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- 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/20070818/a9d6ae49/attachment.pgp>



More information about the ffmpeg-devel mailing list