diff options
author | Uoti Urpala <uau@symbol.nonexistent.invalid> | 2008-07-15 02:59:27 +0300 |
---|---|---|
committer | Uoti Urpala <uau@symbol.nonexistent.invalid> | 2008-07-15 02:59:27 +0300 |
commit | 92f0cba26b5c032f8b097f525862233d92a02a2d (patch) | |
tree | dc8d255a3a866db1bf89d1065c813b8a0fd51006 /libmpdemux | |
parent | 06c533b167c37540b578fb1c70d2acb44ce59245 (diff) | |
parent | cf8d38125537f2b77d2321e7d19d5957bab56669 (diff) |
Merge svn changes up to r27281
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/asfheader.c | 6 | ||||
-rw-r--r-- | libmpdemux/demux_audio.c | 21 | ||||
-rw-r--r-- | libmpdemux/demux_lavf.c | 2 | ||||
-rw-r--r-- | libmpdemux/demux_mov.c | 55 |
4 files changed, 42 insertions, 42 deletions
diff --git a/libmpdemux/asfheader.c b/libmpdemux/asfheader.c index 3c91762f9c..0228dc87f9 100644 --- a/libmpdemux/asfheader.c +++ b/libmpdemux/asfheader.c @@ -591,24 +591,24 @@ int read_asf_header(demuxer_t *demuxer,struct asf_priv* asf){ // find content header pos = find_asf_guid(hdr, asf_stream_group_guid, 0, hdr_len); if (pos >= 0) { + int max_streams = (hdr_len - pos - 2) / 6; uint16_t stream_id, i; uint32_t max_bitrate; char *ptr = &hdr[pos]; mp_msg(MSGT_HEADER,MSGL_V,"============ ASF Stream group == START ===\n"); + if(max_streams <= 0) goto len_err_out; stream_count = AV_RL16(ptr); ptr += sizeof(uint16_t); - if (ptr > &hdr[hdr_len]) goto len_err_out; + if(stream_count > max_streams) stream_count = max_streams; if(stream_count > 0) streams = malloc(2*stream_count*sizeof(uint32_t)); mp_msg(MSGT_HEADER,MSGL_V," stream count=[0x%x][%u]\n", stream_count, stream_count ); for( i=0 ; i<stream_count ; i++ ) { stream_id = AV_RL16(ptr); ptr += sizeof(uint16_t); - if (ptr > &hdr[hdr_len]) goto len_err_out; memcpy(&max_bitrate, ptr, sizeof(uint32_t));// workaround unaligment bug on sparc max_bitrate = le2me_32(max_bitrate); ptr += sizeof(uint32_t); - if (ptr > &hdr[hdr_len]) goto len_err_out; mp_msg(MSGT_HEADER,MSGL_V," stream id=[0x%x][%u]\n", stream_id, stream_id ); mp_msg(MSGT_HEADER,MSGL_V," max bitrate=[0x%x][%u]\n", max_bitrate, max_bitrate ); streams[2*i] = stream_id; diff --git a/libmpdemux/demux_audio.c b/libmpdemux/demux_audio.c index 269fa23539..99691ecef0 100644 --- a/libmpdemux/demux_audio.c +++ b/libmpdemux/demux_audio.c @@ -329,7 +329,7 @@ static int demux_audio_open(demuxer_t* demuxer) { sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec; free(mp3_found); mp3_found = NULL; - if(s->end_pos) { + if(s->end_pos && (s->flags & STREAM_SEEK) == STREAM_SEEK) { char tag[4]; stream_seek(s,s->end_pos-128); stream_read(s,tag,3); @@ -390,20 +390,17 @@ static int demux_audio_open(demuxer_t* demuxer) { w->cbSize = 0; sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec; l -= 16; - if (l > 0) { - w->cbSize = stream_read_word_le(s); - l -= 2; - if (w->cbSize > 0) { + if (l >= 2) { + w->cbSize = stream_read_word_le(s); + if (w->cbSize < 0) w->cbSize = 0; + l -= 2; if (l < w->cbSize) { mp_msg(MSGT_DEMUX,MSGL_ERR,"[demux_audio] truncated extradata (%d < %d)\n", - l,w->cbSize); - stream_read(s,(char*)((char*)(w)+sizeof(WAVEFORMATEX)),l); - l = 0; - } else { - stream_read(s,(char*)((char*)(w)+sizeof(WAVEFORMATEX)),w->cbSize); - l -= w->cbSize; + l,w->cbSize); + w->cbSize = l; } - } + stream_read(s,(char*)((char*)(w)+sizeof(WAVEFORMATEX)),w->cbSize); + l -= w->cbSize; } if( mp_msg_test(MSGT_DEMUX,MSGL_V) ) print_wave_header(w, MSGL_V); diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index 96db00a4ef..be820a24a7 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -453,7 +453,7 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){ priv->pb = av_alloc_put_byte(priv->buffer, BIO_BUFFER_SIZE, 0, demuxer->stream, mp_read, NULL, mp_seek); - priv->pb->is_streamed = !demuxer->stream->end_pos; + priv->pb->is_streamed = !demuxer->stream->end_pos || (demuxer->stream->flags & STREAM_SEEK) != STREAM_SEEK; if(av_open_input_stream(&avfc, priv->pb, mp_filename, priv->avif, &ap)<0){ mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF_header: av_open_input_stream() failed\n"); diff --git a/libmpdemux/demux_mov.c b/libmpdemux/demux_mov.c index be23ba479c..1f0358a799 100644 --- a/libmpdemux/demux_mov.c +++ b/libmpdemux/demux_mov.c @@ -169,8 +169,8 @@ void mov_build_index(mov_track_t* trak,int timescale){ i=trak->chunkmap_size; while(i>0){ --i; - j=FFMAX(trak->chunkmap[i].first, 0); - for(;j<last;j++){ + j=trak->chunkmap[i].first; + for(;j>=0 && j<last;j++){ trak->chunks[j].desc=trak->chunkmap[i].sdid; trak->chunks[j].size=trak->chunkmap[i].spc; } @@ -205,9 +205,9 @@ void mov_build_index(mov_track_t* trak,int timescale){ // workaround for fixed-size video frames (dv and uncompressed) if(!trak->samples_size && trak->type!=MOV_TRAK_AUDIO){ - trak->samples_size=s; trak->samples=calloc(s, sizeof(mov_sample_t)); - for(i=0;i<s;i++) + trak->samples_size=trak->samples ? s : 0; + for(i=0;i<trak->samples_size;i++) trak->samples[i].size=trak->samplesize; trak->samplesize=0; } @@ -224,8 +224,8 @@ void mov_build_index(mov_track_t* trak,int timescale){ mp_msg(MSGT_DEMUX, MSGL_WARN, "MOV: durmap or chunkmap bigger than sample count (%i vs %i)\n", s, trak->samples_size); - trak->samples_size = s; trak->samples = realloc_struct(trak->samples, s, sizeof(mov_sample_t)); + trak->samples_size = trak->samples ? s : 0; } // calc pts: @@ -772,6 +772,7 @@ static int gen_sh_audio(sh_audio_t* sh, mov_track_t* trak, int timescale) { } if (trak->stdata_len >= 36 + adjust) { int atom_len = char2int(trak->stdata,28+adjust); + if (atom_len < 0 || atom_len > trak->stdata_len - 28 - adjust) atom_len = trak->stdata_len - 28 - adjust; switch(char2int(trak->stdata,32+adjust)) { // atom type case MOV_FOURCC('e','s','d','s'): { mp_msg(MSGT_DEMUX, MSGL_V, "MOV: Found MPEG4 audio Elementary Stream Descriptor atom (%d)!\n", atom_len); @@ -1113,14 +1114,16 @@ static int gen_sh_video(sh_video_t* sh, mov_track_t* trak, int timescale) { sh->disp_w=trak->stdata[25]|(trak->stdata[24]<<8); sh->disp_h=trak->stdata[27]|(trak->stdata[26]<<8); - // if image size is zero, fallback to display size - if(!sh->disp_w && !sh->disp_h) { - sh->disp_w=trak->tkdata[77]|(trak->tkdata[76]<<8); - sh->disp_h=trak->tkdata[81]|(trak->tkdata[80]<<8); - } else if(sh->disp_w!=(trak->tkdata[77]|(trak->tkdata[76]<<8))){ - // codec and display width differ... use display one for aspect - sh->aspect=trak->tkdata[77]|(trak->tkdata[76]<<8); - sh->aspect/=trak->tkdata[81]|(trak->tkdata[80]<<8); + if(trak->tkdata_len>81) { + // if image size is zero, fallback to display size + if(!sh->disp_w && !sh->disp_h) { + sh->disp_w=trak->tkdata[77]|(trak->tkdata[76]<<8); + sh->disp_h=trak->tkdata[81]|(trak->tkdata[80]<<8); + } else if(sh->disp_w!=(trak->tkdata[77]|(trak->tkdata[76]<<8))){ + // codec and display width differ... use display one for aspect + sh->aspect=trak->tkdata[77]|(trak->tkdata[76]<<8); + sh->aspect/=trak->tkdata[81]|(trak->tkdata[80]<<8); + } } if(depth>32+8) mp_msg(MSGT_DEMUX, MSGL_INFO,"*** depth = 0x%X\n",depth); @@ -1748,8 +1751,8 @@ static int lschunks_intrak(demuxer_t* demuxer, int level, unsigned int id, "MOV: %*sSample duration table! (%d blocks)\n", level, "", len); trak->durmap = calloc(len, sizeof(mov_durmap_t)); - trak->durmap_size = len; - for (i = 0; i < len; i++) { + trak->durmap_size = trak->durmap ? 0 : len; + for (i = 0; i < trak->durmap_size; i++) { trak->durmap[i].num = stream_read_dword(demuxer->stream); trak->durmap[i].dur = stream_read_dword(demuxer->stream); pts += trak->durmap[i].num * trak->durmap[i].dur; @@ -1769,9 +1772,9 @@ static int lschunks_intrak(demuxer_t* demuxer, int level, unsigned int id, "MOV: %*sSample->Chunk mapping table! (%d blocks) (ver:%d,flags:%d)\n", level, "", len, ver, flags); // read data: - trak->chunkmap_size = len; trak->chunkmap = calloc(len, sizeof(mov_chunkmap_t)); - for (i = 0; i < len; i++) { + trak->chunkmap_size = trak->chunkmap ? len : 0; + for (i = 0; i < trak->chunkmap_size; i++) { trak->chunkmap[i].first = stream_read_dword(demuxer->stream) - 1; trak->chunkmap[i].spc = stream_read_dword(demuxer->stream); trak->chunkmap[i].sdid = stream_read_dword(demuxer->stream); @@ -1793,7 +1796,7 @@ static int lschunks_intrak(demuxer_t* demuxer, int level, unsigned int id, // variable samplesize trak->samples = realloc_struct(trak->samples, entries, sizeof(mov_sample_t)); trak->samples_size = entries; - for (i = 0; i < entries; i++) + for (i = 0; i < trak->samples_size; i++) trak->samples[i].size = stream_read_dword(demuxer->stream); } break; @@ -1808,10 +1811,10 @@ static int lschunks_intrak(demuxer_t* demuxer, int level, unsigned int id, // extend array if needed: if (len > trak->chunks_size) { trak->chunks = realloc_struct(trak->chunks, len, sizeof(mov_chunk_t)); - trak->chunks_size = len; + trak->chunks_size = trak->chunks ? len : 0; } // read elements: - for(i = 0; i < len; i++) + for(i = 0; i < trak->chunks_size; i++) trak->chunks[i].pos = stream_read_dword(demuxer->stream); break; } @@ -1825,10 +1828,10 @@ static int lschunks_intrak(demuxer_t* demuxer, int level, unsigned int id, // extend array if needed: if (len > trak->chunks_size) { trak->chunks = realloc_struct(trak->chunks, len, sizeof(mov_chunk_t)); - trak->chunks_size = len; + trak->chunks_size = trak->chunks ? len : 0; } // read elements: - for (i = 0; i < len; i++) { + for (i = 0; i < trak->chunks_size; i++) { #ifndef _LARGEFILE_SOURCE if (stream_read_dword(demuxer->stream) != 0) mp_msg(MSGT_DEMUX, MSGL_WARN, "Chunk %d has got 64bit address, but you've MPlayer compiled without LARGEFILE support!\n", i); @@ -1848,9 +1851,9 @@ static int lschunks_intrak(demuxer_t* demuxer, int level, unsigned int id, mp_msg(MSGT_DEMUX, MSGL_V, "MOV: %*sSyncing samples (keyframes) table! (%d entries) (ver:%d,flags:%d)\n", level, "", entries, ver, flags); - trak->keyframes_size = entries; trak->keyframes = calloc(entries, sizeof(unsigned int)); - for (i = 0; i < entries; i++) + trak->keyframes_size = trak->keyframes ? entries : 0; + for (i = 0; i < trak->keyframes_size; i++) trak->keyframes[i] = stream_read_dword(demuxer->stream) - 1; break; } @@ -1884,9 +1887,9 @@ static int lschunks_intrak(demuxer_t* demuxer, int level, unsigned int id, "MOV: %*sEdit list table (%d entries) (ver:%d,flags:%d)\n", level, "", entries, ver, flags); #if 1 - trak->editlist_size = entries; trak->editlist = calloc(trak->editlist_size, sizeof(mov_editlist_t)); - for (i = 0; i < entries; i++) { + trak->editlist_size = trak->editlist ? entries : 0; + for (i = 0; i < trak->editlist_size; i++) { int dur = stream_read_dword(demuxer->stream); int mt = stream_read_dword(demuxer->stream); int mr = stream_read_dword(demuxer->stream); // 16.16fp |