From 6f768ab47bc2afdcb20b4a5e39e620f7f58e2256 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Sun, 15 May 2011 15:29:29 +0200 Subject: [PATCH] AVI: support WAVEFORMATEXTENSIBLE for audio This is notably used by files produced by FFmpeg Closes #4742 --- modules/demux/avi/avi.c | 12 ++++++++++-- modules/demux/avi/libavi.c | 7 ++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c index df525ad225..03b0fe2d1f 100644 --- a/modules/demux/avi/avi.c +++ b/modules/demux/avi/avi.c @@ -401,8 +401,16 @@ static int Open( vlc_object_t * p_this ) { case( AVIFOURCC_auds ): tk->i_cat = AUDIO_ES; - tk->i_codec = AVI_FourccGetCodec( AUDIO_ES, - p_auds->p_wf->wFormatTag ); + if( p_auds->p_wf->wFormatTag == WAVE_FORMAT_EXTENSIBLE && + p_auds->p_wf->cbSize >= sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) ) + { + WAVEFORMATEXTENSIBLE *p_wfe = (WAVEFORMATEXTENSIBLE *)p_auds->p_wf; + tk->i_codec = AVI_FourccGetCodec( AUDIO_ES, + p_wfe->SubFormat.Data1 ); + } + else + tk->i_codec = AVI_FourccGetCodec( AUDIO_ES, + p_auds->p_wf->wFormatTag ); tk->i_blocksize = p_auds->p_wf->nBlockAlign; if( tk->i_blocksize == 0 ) diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c index 0031a167b8..32cae3294a 100644 --- a/modules/demux/avi/libavi.c +++ b/modules/demux/avi/libavi.c @@ -342,10 +342,12 @@ static int AVI_ChunkRead_strf( stream_t *s, avi_chunk_t *p_chk ) AVI_READ4BYTES( p_chk->strf.auds.p_wf->nAvgBytesPerSec ); AVI_READ2BYTES( p_chk->strf.auds.p_wf->nBlockAlign ); AVI_READ2BYTES( p_chk->strf.auds.p_wf->wBitsPerSample ); + if( p_chk->strf.auds.p_wf->wFormatTag != WAVE_FORMAT_PCM && p_chk->common.i_chunk_size > sizeof( WAVEFORMATEX ) ) { AVI_READ2BYTES( p_chk->strf.auds.p_wf->cbSize ); + /* prevent segfault */ if( p_chk->strf.auds.p_wf->cbSize > p_chk->common.i_chunk_size - sizeof( WAVEFORMATEX ) ) @@ -353,11 +355,10 @@ static int AVI_ChunkRead_strf( stream_t *s, avi_chunk_t *p_chk ) p_chk->strf.auds.p_wf->cbSize = p_chk->common.i_chunk_size - sizeof( WAVEFORMATEX ); } + if( p_chk->strf.auds.p_wf->wFormatTag == WAVE_FORMAT_EXTENSIBLE ) { - /* Found an extensible header atm almost nothing uses that. */ - msg_Warn( (vlc_object_t*)s, "WAVE_FORMAT_EXTENSIBLE or " - "vorbis audio dectected: not supported" ); + msg_Dbg( s, "Extended header found" ); } } else -- 2.11.4.GIT