# HG changeset patch # User albeu # Date 1012927810 0 # Node ID 354048e506abbc948a5ad1986ec926e39a10f93e # Parent bc5b78f1df770481726c7c5ed137f9b8853586fb Added auto selection of the best streams and fixed a few compiler warnings diff -r bc5b78f1df77 -r 354048e506ab libmpdemux/asfheader.c --- a/libmpdemux/asfheader.c Tue Feb 05 16:43:18 2002 +0000 +++ b/libmpdemux/asfheader.c Tue Feb 05 16:50:10 2002 +0000 @@ -129,9 +129,13 @@ int read_asf_header(demuxer_t *demuxer){ static unsigned char buffer[1024]; + uint32_t* streams = NULL; int audio_streams=0; int video_streams=0; - + uint16_t stream_count=0; + int best_video = -1; + int best_audio = -1; + #if 1 //printf("ASF file! (subchunks: %d)\n",asfh.cno); while(!stream_eof(demuxer->stream)){ @@ -184,7 +188,7 @@ } case ASF_GUID_PREFIX_video_stream: { sh_video_t* sh_video=new_sh_video(demuxer,streamh.stream_no & 0x7F); - int len=streamh.type_size-(4+4+1+2); + unsigned int len=streamh.type_size-(4+4+1+2); ++video_streams; // sh_video->bih=malloc(chunksize); memset(sh_video->bih,0,chunksize); sh_video->bih=calloc((len 0) + streams = (uint32_t*)malloc(2*stream_count*sizeof(uint32_t)); printf(" stream count=[0x%x][%u]\n", stream_count, stream_count ); for( i=0 ; istream,endpos)) break; } // while EOF +if(streams) { + uint32_t vr = 0, ar = 0,i; + for(i = 0; i < stream_count; i++) { + uint32_t id = streams[2*i]; + uint32_t rate = streams[2*i+1]; + if(demuxer->v_streams[id] && rate > vr) { + vr = rate; + best_video = id; + } else if(demuxer->a_streams[id] && rate > ar) { + ar = rate; + best_audio = id; + } + } + free(streams); +} + mp_msg(MSGT_HEADER,MSGL_V,"ASF: %d audio and %d video streams found\n",audio_streams,video_streams); if(!audio_streams) demuxer->audio->id=-2; // nosound +else if(best_audio > 0 && demuxer->audio->id == -1) demuxer->audio->id=best_audio; if(!video_streams){ if(!audio_streams){ mp_msg(MSGT_HEADER,MSGL_ERR,"ASF: no audio or video headers found - broken file?\n"); return 0; } demuxer->video->id=-2; // audio-only -} +} else if (best_video > 0 && demuxer->video->id == -1) demuxer->video->id = best_video; #if 0 if(verbose){