diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2009-11-16 10:41:06 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2009-11-16 10:41:06 +0000 |
commit | 4eac890e07087e0727a14ad8d9671a43b87294cc (patch) | |
tree | 0a99b46513f14696c5b1b2b40b760fdedcca560e | |
parent | b411278fbb00767b8013604157a43e0203f66f4c (diff) |
Try to detect broken files with unaligned chunks.
This patch hopefully makes them playable as long as they have and index without
breaking any other files.
Fixes http://samples.mplayerhq.hu/avi/invalid_unaligned.avi with native demuxer.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29913 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libmpdemux/aviheader.h | 1 | ||||
-rw-r--r-- | libmpdemux/demux_avi.c | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/libmpdemux/aviheader.h b/libmpdemux/aviheader.h index a06ef711ac..4074f6bb03 100644 --- a/libmpdemux/aviheader.h +++ b/libmpdemux/aviheader.h @@ -367,6 +367,7 @@ typedef struct { avisuperindex_chunk *suidx; int suidx_size; int isodml; + int warned_unaligned; } avi_priv_t; #define AVI_PRIV ((avi_priv_t*)(demuxer->priv)) diff --git a/libmpdemux/demux_avi.c b/libmpdemux/demux_avi.c index 21529fb588..0082f2a9fe 100644 --- a/libmpdemux/demux_avi.c +++ b/libmpdemux/demux_avi.c @@ -106,6 +106,12 @@ static int valid_fourcc(unsigned int id){ strchr(valid, fcc[2]) && strchr(valid, fcc[3]); } +static int valid_stream_id(unsigned int id) { + unsigned char* fcc=(unsigned char*)(&id); + return fcc[0] >= '0' && fcc[0] <= '9' && fcc[1] >= '0' && fcc[1] <= '9' && + ((fcc[2] == 'w' && fcc[3] == 'b') || (fcc[2] == 'd' && fcc[3] == 'c')); +} + static int choose_chunk_len(unsigned int len1,unsigned int len2){ // len1 has a bit more priority than len2. len1!=len2 // Note: this is a first-idea-logic, may be wrong. comments welcomed. @@ -218,8 +224,12 @@ do{ idx=&((AVIINDEXENTRY *)priv->idx)[priv->idx_pos++]; if(idx->dwFlags&AVIIF_LIST){ + if (!valid_stream_id(idx->ckid)) // LIST continue; + if (!priv->warned_unaligned) + mp_msg(MSGT_DEMUX, MSGL_WARN, "Looks like unaligned chunk in index, broken AVI file!\n"); + priv->warned_unaligned = 1; } if(!demux_avi_select_stream(demux,idx->ckid)){ mp_dbg(MSGT_DEMUX,MSGL_DBG3,"Skip chunk %.4s (0x%X) \n",(char *)&idx->ckid,(unsigned int)idx->ckid); @@ -317,8 +327,12 @@ do{ idx=&((AVIINDEXENTRY *)priv->idx)[idx_pos]; if(idx->dwFlags&AVIIF_LIST){ + if (!valid_stream_id(idx->ckid)) // LIST continue; + if (!priv->warned_unaligned) + mp_msg(MSGT_DEMUX, MSGL_WARN, "Looks like unaligned chunk in index, broken AVI file!\n"); + priv->warned_unaligned = 1; } if(ds && demux_avi_select_stream(demux,idx->ckid)!=ds){ mp_dbg(MSGT_DEMUX,MSGL_DBG3,"Skip chunk %.4s (0x%X) \n",(char *)&idx->ckid,(unsigned int)idx->ckid); @@ -437,6 +451,7 @@ static demuxer_t* demux_open_avi(demuxer_t* demuxer){ priv->isodml = 0; priv->suidx_size = 0; priv->suidx = NULL; + priv->warned_unaligned = 0; demuxer->priv=(void*)priv; |