[MPlayer-dev-eng] [PATCH] AVI bitrate printed incorrectly

Alan Curry pacman at TheWorld.com
Mon May 1 19:27:47 CEST 2006


Dominik 'Rathann' Mierzejewski writes the following:
>
>On Monday, 01 May 2006 at 06:26, Alan Curry wrote:
>> -    mp_msg(MSGT_DEMUX,MSGL_V,"AVI video size=%u (%u) audio size=%u (%u)\n",vsize,vsamples,asize,asamples);
>> +    mp_msg(MSGT_DEMUX,MSGL_V,"AVI video size=%lld (%u) audio size=%lld (%u)\n",(long long)vsize,vsamples,(long long)asize,asamples);
>
>Don't use %lld. Use the PRId64 macro instead. Also, is long long portable?

PRId64 is correct for int64_t; lld is correct for long long. Either one would
work here. (They're probably the same every system supported by gcc, so you
could get away with using PRId64 and long long, but it's not theoretically
the correct match)

What type to use for the printing of this debug message, since there is no
PRI* macro directly corresponding to off_t, is a cosmetic issue. I picked
off_t for the variables because it seems conceptually right, and long long
for the printf because I think the PRI* macros are ugly.

On the other hand, here's what it looks like with int64_t's instead of off_t.

Index: libmpdemux/demux_avi.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_avi.c,v
retrieving revision 1.74
diff -u -r1.74 demux_avi.c
--- libmpdemux/demux_avi.c	18 Feb 2006 09:26:38 -0000	1.74
+++ libmpdemux/demux_avi.c	1 May 2006 17:25:48 -0000
@@ -565,8 +565,8 @@
   // calculating audio/video bitrate:
   if(priv->idx_size>0){
     // we have index, let's count 'em!
-    size_t vsize=0;
-    size_t asize=0;
+    int64_t vsize=0;
+    int64_t asize=0;
     size_t vsamples=0;
     size_t asamples=0;
     int i;
@@ -582,14 +582,14 @@
 	asamples+=(len+priv->audio_block_size-1)/priv->audio_block_size;
       }
     }
-    mp_msg(MSGT_DEMUX,MSGL_V,"AVI video size=%u (%u) audio size=%u (%u)\n",vsize,vsamples,asize,asamples);
+    mp_msg(MSGT_DEMUX,MSGL_V,"AVI video size=%"PRId64" (%u) audio size=%"PRId64" (%u)\n",vsize,vsamples,asize,asamples);
     priv->numberofframes=vsamples;
     sh_video->i_bps=((float)vsize/(float)vsamples)*(float)sh_video->video.dwRate/(float)sh_video->video.dwScale;
     if(sh_audio) sh_audio->i_bps=((float)asize/(float)asamples)*(float)sh_audio->audio.dwRate/(float)sh_audio->audio.dwScale;
   } else {
     // guessing, results may be inaccurate:
-    size_t vsize;
-    size_t asize=0;
+    int64_t vsize;
+    int64_t asize=0;
 
     if((priv->numberofframes=sh_video->video.dwLength)<=1)
       // bad video header, try to get number of frames from audio
@@ -609,7 +609,7 @@
       }
     }
     vsize=demuxer->movi_end-demuxer->movi_start-asize-8*priv->numberofframes;
-    mp_msg(MSGT_DEMUX,MSGL_V,"AVI video size=%d (%u)  audio size=%d\n",vsize,priv->numberofframes,asize);
+    mp_msg(MSGT_DEMUX,MSGL_V,"AVI video size=%"PRId64" (%u)  audio size=%"PRId64"\n",vsize,priv->numberofframes,asize);
     sh_video->i_bps=(float)vsize/(sh_video->frametime*priv->numberofframes);
   }
 




More information about the MPlayer-dev-eng mailing list