summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-11-13 10:17:13 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-14 12:40:33 +0200
commit74377fbfbf0a4dc7d1734403a901e726beaaae1e (patch)
tree4ad29877df748979feef07c004dbf26a2e96d64a
parentc96f83c23576ec04e8ff88fa08f1c16eba68a019 (diff)
downloadmpv-74377fbfbf0a4dc7d1734403a901e726beaaae1e.tar.bz2
mpv-74377fbfbf0a4dc7d1734403a901e726beaaae1e.tar.xz
demux_avi: modify to avoid -aid problem in svn
[ Note: the questionable changes in svn that triggered this problem were never included in git, and so this commit is not strictly necessary here. It's included to reduce the differences between git and svn demux_avi versions. ] Fix possible division by 0 if -aid is used for AVI files. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32622 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libmpdemux/demux_avi.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/libmpdemux/demux_avi.c b/libmpdemux/demux_avi.c
index fea37e5062..1ed9145fd5 100644
--- a/libmpdemux/demux_avi.c
+++ b/libmpdemux/demux_avi.c
@@ -38,6 +38,32 @@ extern const demuxer_desc_t demuxer_desc_avi_nini;
// PTS: 0=interleaved 1=BPS-based
int pts_from_bps=1;
+static void update_audio_block_size(demuxer_t *demux)
+{
+ avi_priv_t *priv = demux->priv;
+ sh_audio_t *sh = demux->audio->sh;
+ if (!sh)
+ return;
+ priv->audio_block_size = sh->audio.dwSampleSize;
+ if (sh->wf) {
+ priv->audio_block_size = sh->wf->nBlockAlign;
+ if (!priv->audio_block_size) {
+ // for PCM audio we can calculate the blocksize:
+ if (sh->format == 1)
+ priv->audio_block_size = sh->wf->nChannels*(sh->wf->wBitsPerSample/8);
+ else
+ priv->audio_block_size = 1; // hope the best...
+ } else {
+ // workaround old mencoder bug:
+ if (sh->audio.dwSampleSize == 1 && sh->audio.dwScale == 1 &&
+ (sh->wf->nBlockAlign == 1152 || sh->wf->nBlockAlign == 576)) {
+ mp_tmsg(MSGT_DEMUX,MSGL_WARN,"AVI: Working around CBR-MP3 nBlockAlign header bug!\n");
+ priv->audio_block_size = 1;
+ }
+ }
+ }
+}
+
// Select ds from ID
static demux_stream_t *demux_avi_select_stream(demuxer_t *demux,
unsigned int id)
@@ -55,29 +81,9 @@ static demux_stream_t *demux_avi_select_stream(demuxer_t *demux,
if(stream_id==demux->audio->id){
if(!demux->audio->sh){
- sh_audio_t* sh;
- avi_priv_t *priv=demux->priv;
- sh=demux->audio->sh=demux->a_streams[stream_id];
+ demux->audio->sh=demux->a_streams[stream_id];
mp_msg(MSGT_DEMUX,MSGL_V,"Auto-selected AVI audio ID = %d\n",demux->audio->id);
- if(sh->wf){
- priv->audio_block_size=sh->wf->nBlockAlign;
- if(!priv->audio_block_size){
- // for PCM audio we can calculate the blocksize:
- if(sh->format==1)
- priv->audio_block_size=sh->wf->nChannels*(sh->wf->wBitsPerSample/8);
- else
- priv->audio_block_size=1; // hope the best...
- } else {
- // workaround old mencoder's bug:
- if(sh->audio.dwSampleSize==1 && sh->audio.dwScale==1 &&
- (sh->wf->nBlockAlign==1152 || sh->wf->nBlockAlign==576)){
- mp_tmsg(MSGT_DEMUX,MSGL_WARN,"AVI: Working around CBR-MP3 nBlockAlign header bug!\n");
- priv->audio_block_size=1;
- }
- }
- } else {
- priv->audio_block_size=sh->audio.dwSampleSize;
- }
+ update_audio_block_size(demux);
}
return demux->audio;
}
@@ -441,6 +447,7 @@ static demuxer_t* demux_open_avi(demuxer_t* demuxer){
//---- AVI header:
read_avi_header(demuxer,(demuxer->stream->flags & MP_STREAM_SEEK_BW)?index_mode:-2);
+ update_audio_block_size(demuxer);
if(demuxer->audio->id>=0 && !demuxer->a_streams[demuxer->audio->id]){
mp_tmsg(MSGT_DEMUX,MSGL_WARN,"AVI: invalid audio stream ID: %d - ignoring (nosound)\n",demuxer->audio->id);