[MPlayer-cvslog] r33448 - trunk/gui/mplayer/gui_common.c

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun May 22 20:02:45 CEST 2011


On Sun, May 22, 2011 at 01:51:24PM +0200, Ingo Brückl wrote:
> Reimar Döffinger wrote on Sun, 22 May 2011 12:56:08 +0200:
> 
> >> - asf->movielength=(fileh->play_duration-10000*fileh->preroll)/10000000.0;
> >> +      if (fileh->play_duration>10000*fileh->preroll) asf->movielength=(fileh->play_duration-10000*fileh->preroll)/10000000.0;
> >> +      else asf->movielength=0;
> 
> > Isn't it equivalent and more obvious to do
> > asf->movielength=FFMAX((fileh->play_duration-10000*fileh->preroll)/100000
> > 00.0, 0.0);
> > for example?
> 
> All the fileh variables are unsigned.
> 
> > Or in a separate line.
> 
> I don't get what you might mean by that.
> 
> > Just think it would be better to avoid duplicating the
> > 10000*fileh->preroll stuff.
> 
> Yes, I agree.
> 
> Maybe this attempt is better?
> 
> Ingo

> Index: libmpdemux/asfheader.c
> ===================================================================
> --- libmpdemux/asfheader.c	(revision 33464)
> +++ libmpdemux/asfheader.c	(working copy)
> @@ -530,6 +530,7 @@
>    // find file header
>    pos = find_asf_guid(hdr, asf_file_header_guid, 0, hdr_len);
>    if (pos >= 0) {
> +      uint64_t preroll_duration;
>        ASF_file_header_t *fileh = (ASF_file_header_t *)&hdr[pos];
>        pos += sizeof(ASF_file_header_t);
>        if (pos > hdr_len) goto len_err_out;
> @@ -543,7 +544,9 @@
>        asf->packetsize=fileh->max_packet_size;
>        asf->packet=malloc(asf->packetsize); // !!!
>        asf->packetrate=fileh->max_bitrate/8.0/(double)asf->packetsize;
> -      asf->movielength=(fileh->play_duration-10000*fileh->preroll)/10000000.0;
> +      preroll_duration=10000*fileh->preroll;
> +      if (fileh->play_duration>preroll_duration) asf->movielength=(fileh->play_duration-preroll_duration)/10000000.0;
> +      else asf->movielength=0;

I missed that the variables are all unsigned, why not
int64_t duration = fileh->play_duration;
duration = FFMAX(duration - 10000*fileh->preroll, 0);
asf->movielength=duration/10000000.0;


More information about the MPlayer-cvslog mailing list