[MPlayer-dev-eng] [PATCH] AVI bitrate printed incorrectly
Alan Curry
pacman at theworld.com
Mon May 1 06:26:39 CEST 2006
demux_avi.c attempts to calculate the video bitrate based on the total size
of all the video chunks according to the index, or based on size of the file
if there is no index. Unfortunately, it puts that size into a size_t, which
can overflow when there is more than 4G of video. Something similar could
happen if there is more than 4G of audio.
The wrong values end up in sh_video->i_bps and sh_audio->i_bps, but there are
no apparent symptoms other than the -identify output and the "VIDEO:" line
because nothing really cares about sh_video->i_bps and AVIs don't often get
big enough to contain 4G of audio.
This patch replaces some size_t's with off_t's, making the calculations
correct for large AVI files.
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 04:02:05 -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;
+ off_t vsize=0;
+ off_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=%lld (%u) audio size=%lld (%u)\n",(long long)vsize,vsamples,(long long)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;
+ off_t vsize;
+ off_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=%lld (%u) audio size=%lld\n",(long long)vsize,priv->numberofframes,(long long)asize);
sh_video->i_bps=(float)vsize/(sh_video->frametime*priv->numberofframes);
}
More information about the MPlayer-dev-eng
mailing list