[FFmpeg-devel] [PATCH] au: add duration info

Michael Niedermayer michaelni at gmx.at
Thu Jul 14 11:07:36 CEST 2011


On Wed, Jul 13, 2011 at 11:39:48PM +0200, Stefano Sabatini wrote:
> On date Wednesday 2011-07-13 22:33:21 +0200, Michael Niedermayer encoded:
> > On Wed, Jul 13, 2011 at 12:23:35PM +0200, ami_stuff wrote:
> > [...]
> > > @@ -159,6 +164,10 @@ static int au_read_header(AVFormatContext *s,
> > >      st->codec->codec_id = codec;
> > >      st->codec->channels = channels;
> > >      st->codec->sample_rate = rate;
> > > +
> > > +    if (data_size)
> > > +        st->duration = (data_size<<3) / (st->codec->channels * (uint64_t)av_get_bits_per_sample(st->codec->codec_id));
> >                                      ^^^
> > can overflow
> > otherwise LGTM
> 
> Alternatively:
>     if (data_size)
>         st->duration = data_size / (st->codec->channels * (uint64_t)(av_get_bits_per_sample(st->codec->codec_id)>>3));

id cast data_size to int64 to avoid having to consider
av_get_bits_per_sample(codec_id) < 8


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

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- 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/20110714/573686f3/attachment.asc>


More information about the ffmpeg-devel mailing list