Mercurial > mplayer.hg
comparison mplayer.c @ 432:5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
author | arpi_esp |
---|---|
date | Sun, 15 Apr 2001 14:33:49 +0000 |
parents | c106cb97db06 |
children | 50955d1a56c1 |
comparison
equal
deleted
inserted
replaced
431:c106cb97db06 | 432:5251b0c57e39 |
---|---|
695 printf("AVI: No Audio stream found... ->nosound\n"); | 695 printf("AVI: No Audio stream found... ->nosound\n"); |
696 has_audio=0; | 696 has_audio=0; |
697 sh_audio=NULL; | 697 sh_audio=NULL; |
698 } else { | 698 } else { |
699 sh_audio=d_audio->sh;sh_audio->ds=d_audio; | 699 sh_audio=d_audio->sh;sh_audio->ds=d_audio; |
700 sh_audio->format=sh_audio->wf.wFormatTag; | 700 sh_audio->format=sh_audio->wf->wFormatTag; |
701 } | 701 } |
702 } | 702 } |
703 // calc. FPS: | 703 // calc. FPS: |
704 sh_video->fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale; | 704 sh_video->fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale; |
705 sh_video->frametime=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; | 705 sh_video->frametime=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; |
707 avi_header.bitrate=avi_header.movi_end-avi_header.movi_start-avi_header.idx_size*8; | 707 avi_header.bitrate=avi_header.movi_end-avi_header.movi_start-avi_header.idx_size*8; |
708 if(sh_audio) avi_header.bitrate-=sh_audio->audio.dwLength; | 708 if(sh_audio) avi_header.bitrate-=sh_audio->audio.dwLength; |
709 if(verbose) printf("AVI video length=%d\n",avi_header.bitrate); | 709 if(verbose) printf("AVI video length=%d\n",avi_header.bitrate); |
710 avi_header.bitrate=((float)avi_header.bitrate/(float)sh_video->video.dwLength)*sh_video->fps; | 710 avi_header.bitrate=((float)avi_header.bitrate/(float)sh_video->video.dwLength)*sh_video->fps; |
711 printf("VIDEO: [%.4s] %dx%d %dbpp %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", | 711 printf("VIDEO: [%.4s] %dx%d %dbpp %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", |
712 &sh_video->bih.biCompression, | 712 &sh_video->bih->biCompression, |
713 sh_video->bih.biWidth, | 713 sh_video->bih->biWidth, |
714 sh_video->bih.biHeight, | 714 sh_video->bih->biHeight, |
715 sh_video->bih.biBitCount, | 715 sh_video->bih->biBitCount, |
716 sh_video->fps, | 716 sh_video->fps, |
717 avi_header.bitrate*0.008f, | 717 avi_header.bitrate*0.008f, |
718 avi_header.bitrate/1024.0f ); | 718 avi_header.bitrate/1024.0f ); |
719 break; | 719 break; |
720 } | 720 } |
736 printf("ASF: No Audio stream found... ->nosound\n"); | 736 printf("ASF: No Audio stream found... ->nosound\n"); |
737 has_audio=0; | 737 has_audio=0; |
738 sh_audio=NULL; | 738 sh_audio=NULL; |
739 } else { | 739 } else { |
740 sh_audio=d_audio->sh;sh_audio->ds=d_audio; | 740 sh_audio=d_audio->sh;sh_audio->ds=d_audio; |
741 sh_audio->format=sh_audio->wf.wFormatTag; | 741 sh_audio->format=sh_audio->wf->wFormatTag; |
742 } | 742 } |
743 } | 743 } |
744 sh_video->fps=1000.0f; sh_video->frametime=0.001f; // 1ms | 744 sh_video->fps=1000.0f; sh_video->frametime=0.001f; // 1ms |
745 printf("VIDEO: [%.4s] %dx%d %dbpp\n", | 745 printf("VIDEO: [%.4s] %dx%d %dbpp\n", |
746 &sh_video->bih.biCompression, | 746 &sh_video->bih->biCompression, |
747 sh_video->bih.biWidth, | 747 sh_video->bih->biWidth, |
748 sh_video->bih.biHeight, | 748 sh_video->bih->biHeight, |
749 sh_video->bih.biBitCount); | 749 sh_video->bih->biBitCount); |
750 break; | 750 break; |
751 } | 751 } |
752 case DEMUXER_TYPE_MPEG_ES: { | 752 case DEMUXER_TYPE_MPEG_ES: { |
753 d_audio->type=0; | 753 d_audio->type=0; |
754 has_audio=0;sh_audio=NULL; // ES streams has no audio channel | 754 has_audio=0;sh_audio=NULL; // ES streams has no audio channel |
776 // Determine image properties: | 776 // Determine image properties: |
777 switch(file_format){ | 777 switch(file_format){ |
778 case DEMUXER_TYPE_AVI: | 778 case DEMUXER_TYPE_AVI: |
779 case DEMUXER_TYPE_ASF: { | 779 case DEMUXER_TYPE_ASF: { |
780 // display info: | 780 // display info: |
781 sh_video->format=sh_video->bih.biCompression; | 781 sh_video->format=sh_video->bih->biCompression; |
782 sh_video->disp_w=sh_video->bih.biWidth; | 782 sh_video->disp_w=sh_video->bih->biWidth; |
783 sh_video->disp_h=abs(sh_video->bih.biHeight); | 783 sh_video->disp_h=abs(sh_video->bih->biHeight); |
784 break; | 784 break; |
785 } | 785 } |
786 case DEMUXER_TYPE_MPEG_ES: | 786 case DEMUXER_TYPE_MPEG_ES: |
787 case DEMUXER_TYPE_MPEG_PS: { | 787 case DEMUXER_TYPE_MPEG_PS: { |
788 // Find sequence_header first: | 788 // Find sequence_header first: |
866 } | 866 } |
867 | 867 |
868 //================== Init VIDEO (codec & libvo) ========================== | 868 //================== Init VIDEO (codec & libvo) ========================== |
869 | 869 |
870 // Go through the codec.conf and find the best codec... | 870 // Go through the codec.conf and find the best codec... |
871 sh_video->codec=find_codec(sh_video->format,(unsigned int*) &sh_video->bih.biCompression,NULL,0); | 871 sh_video->codec=find_codec(sh_video->format,(unsigned int*) &sh_video->bih->biCompression,NULL,0); |
872 if(!sh_video->codec){ | 872 if(!sh_video->codec){ |
873 printf("Can't find codec for video format 0x%X !\n",sh_video->format); | 873 printf("Can't find codec for video format 0x%X !\n",sh_video->format); |
874 exit(1); | 874 exit(1); |
875 } | 875 } |
876 //has_video=sh_video->codec->driver; | 876 //has_video=sh_video->codec->driver; |
897 #ifndef USE_DIRECTSHOW | 897 #ifndef USE_DIRECTSHOW |
898 printf("MPlayer was compiled WITHOUT directshow support!\n"); | 898 printf("MPlayer was compiled WITHOUT directshow support!\n"); |
899 exit(1); | 899 exit(1); |
900 #else | 900 #else |
901 sh_video->our_out_buffer=NULL; | 901 sh_video->our_out_buffer=NULL; |
902 if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, &sh_video->bih, 0, &sh_video->our_out_buffer)){ | 902 if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, &sh_video->our_out_buffer)){ |
903 printf("ERROR: Couldn't open required DirectShow codec: %s\n",sh_video->codec->dll); | 903 printf("ERROR: Couldn't open required DirectShow codec: %s\n",sh_video->codec->dll); |
904 printf("Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n"); | 904 printf("Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n"); |
905 printf("package from: ftp://thot.banki.hu/esp-team/linux/MPlayer/w32codec.zip !\n"); | 905 printf("package from: ftp://thot.banki.hu/esp-team/linux/MPlayer/w32codec.zip !\n"); |
906 printf("Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n"); | 906 printf("Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n"); |
907 exit(1); | 907 exit(1); |
924 } | 924 } |
925 case 3: { // OpenDivX | 925 case 3: { // OpenDivX |
926 if(verbose) printf("OpenDivX video codec\n"); | 926 if(verbose) printf("OpenDivX video codec\n"); |
927 { DEC_PARAM dec_param; | 927 { DEC_PARAM dec_param; |
928 DEC_SET dec_set; | 928 DEC_SET dec_set; |
929 dec_param.x_dim = sh_video->bih.biWidth; | 929 dec_param.x_dim = sh_video->bih->biWidth; |
930 dec_param.y_dim = sh_video->bih.biHeight; | 930 dec_param.y_dim = sh_video->bih->biHeight; |
931 dec_param.color_depth = 32; | 931 dec_param.color_depth = 32; |
932 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); | 932 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); |
933 dec_set.postproc_level = divx_quality; | 933 dec_set.postproc_level = divx_quality; |
934 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | 934 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); |
935 } | 935 } |
1347 unsigned int t2; | 1347 unsigned int t2; |
1348 int in_size=ds_get_packet(d_video,&start); | 1348 int in_size=ds_get_packet(d_video,&start); |
1349 if(in_size<0){ eof=1;break;} | 1349 if(in_size<0){ eof=1;break;} |
1350 if(in_size>max_framesize) max_framesize=in_size; | 1350 if(in_size>max_framesize) max_framesize=in_size; |
1351 | 1351 |
1352 sh_video->bih.biSizeImage = in_size; | 1352 if(in_size){ |
1353 sh_video->bih->biSizeImage = in_size; | |
1353 // ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME|(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL), | 1354 // ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME|(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL), |
1354 ret = ICDecompress(sh_video->hic, ICDECOMPRESS_NOTKEYFRAME, | 1355 ret = ICDecompress(sh_video->hic, ICDECOMPRESS_NOTKEYFRAME, |
1355 &sh_video->bih, start, | 1356 sh_video->bih, start, |
1356 &sh_video->o_bih, sh_video->our_out_buffer); | 1357 &sh_video->o_bih, sh_video->our_out_buffer); |
1357 if(ret){ printf("Error decompressing frame, err=%d\n",ret);break; } | 1358 if(ret){ printf("Error decompressing frame, err=%d\n",ret);break; } |
1358 | 1359 } |
1359 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; | 1360 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; |
1360 video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer); | 1361 video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer); |
1361 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; | 1362 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; |
1362 | 1363 |
1363 break; | 1364 break; |
1446 #if 1 | 1447 #if 1 |
1447 /*================ A-V TIMESTAMP CORRECTION: =========================*/ | 1448 /*================ A-V TIMESTAMP CORRECTION: =========================*/ |
1448 if(has_audio){ | 1449 if(has_audio){ |
1449 if(pts_from_bps && (file_format==DEMUXER_TYPE_AVI)){ | 1450 if(pts_from_bps && (file_format==DEMUXER_TYPE_AVI)){ |
1450 // a_pts=(float)ds_tell(d_audio)/sh_audio->wf.nAvgBytesPerSec-(buffer_delay+audio_delay); | 1451 // a_pts=(float)ds_tell(d_audio)/sh_audio->wf.nAvgBytesPerSec-(buffer_delay+audio_delay); |
1451 a_pts=(float)ds_tell(d_audio)/sh_audio->wf.nAvgBytesPerSec-(buffer_delay); | 1452 a_pts=(float)ds_tell(d_audio)/sh_audio->wf->nAvgBytesPerSec-(buffer_delay); |
1452 delay_corrected=1; // hack | 1453 delay_corrected=1; // hack |
1453 } else | 1454 } else |
1454 if(d_audio->pts){ | 1455 if(d_audio->pts){ |
1455 // printf("\n=== APTS a_pts=%5.3f v_pts=%5.3f === \n",d_audio->pts,d_video->pts); | 1456 // printf("\n=== APTS a_pts=%5.3f v_pts=%5.3f === \n",d_audio->pts,d_video->pts); |
1456 #if 1 | 1457 #if 1 |
1661 int apos=0; | 1662 int apos=0; |
1662 int last=0; | 1663 int last=0; |
1663 int len=0; | 1664 int len=0; |
1664 | 1665 |
1665 // calc new audio position in audio stream: (using avg.bps value) | 1666 // calc new audio position in audio stream: (using avg.bps value) |
1666 curr_audio_pos=(avi_video_pts) * sh_audio->wf.nAvgBytesPerSec; | 1667 curr_audio_pos=(avi_video_pts) * sh_audio->wf->nAvgBytesPerSec; |
1667 if(curr_audio_pos<0)curr_audio_pos=0; | 1668 if(curr_audio_pos<0)curr_audio_pos=0; |
1668 #if 1 | 1669 #if 1 |
1669 curr_audio_pos&=~15; // requires for PCM formats!!! | 1670 curr_audio_pos&=~15; // requires for PCM formats!!! |
1670 #else | 1671 #else |
1671 curr_audio_pos/=sh_audio->wf.nBlockAlign; | 1672 curr_audio_pos/=sh_audio->wf->nBlockAlign; |
1672 curr_audio_pos*=sh_audio->wf.nBlockAlign; | 1673 curr_audio_pos*=sh_audio->wf->nBlockAlign; |
1673 avi_header.audio_seekable=1; | 1674 avi_header.audio_seekable=1; |
1674 #endif | 1675 #endif |
1675 | 1676 |
1676 // find audio chunk pos: | 1677 // find audio chunk pos: |
1677 for(i=0;i<video_chunk_pos;i++){ | 1678 for(i=0;i<video_chunk_pos;i++){ |
1703 avi_header.idx_pos=audio_chunk_pos; | 1704 avi_header.idx_pos=audio_chunk_pos; |
1704 | 1705 |
1705 if(!(sh_audio->codec->flags&CODECS_FLAG_SEEKABLE)){ | 1706 if(!(sh_audio->codec->flags&CODECS_FLAG_SEEKABLE)){ |
1706 #if 0 | 1707 #if 0 |
1707 // curr_audio_pos=apos; // selected audio codec can't seek in chunk | 1708 // curr_audio_pos=apos; // selected audio codec can't seek in chunk |
1708 skip_audio_secs=(float)skip_audio_bytes/(float)sh_audio->wf.nAvgBytesPerSec; | 1709 skip_audio_secs=(float)skip_audio_bytes/(float)sh_audio->wf->nAvgBytesPerSec; |
1709 //printf("Seek_AUDIO: %d bytes --> %5.3f secs\n",skip_audio_bytes,skip_audio_secs); | 1710 //printf("Seek_AUDIO: %d bytes --> %5.3f secs\n",skip_audio_bytes,skip_audio_secs); |
1710 skip_audio_bytes=0; | 1711 skip_audio_bytes=0; |
1711 #else | 1712 #else |
1712 int d=skip_audio_bytes % sh_audio->wf.nBlockAlign; | 1713 int d=skip_audio_bytes % sh_audio->wf->nBlockAlign; |
1713 skip_audio_bytes-=d; | 1714 skip_audio_bytes-=d; |
1714 // curr_audio_pos-=d; | 1715 // curr_audio_pos-=d; |
1715 skip_audio_secs=(float)d/(float)sh_audio->wf.nAvgBytesPerSec; | 1716 skip_audio_secs=(float)d/(float)sh_audio->wf->nAvgBytesPerSec; |
1716 //printf("Seek_AUDIO: %d bytes --> %5.3f secs\n",d,skip_audio_secs); | 1717 //printf("Seek_AUDIO: %d bytes --> %5.3f secs\n",d,skip_audio_secs); |
1717 #endif | 1718 #endif |
1718 } | 1719 } |
1719 // now: audio_chunk_pos=pos in index | 1720 // now: audio_chunk_pos=pos in index |
1720 // skip_audio_bytes=bytes to skip from that chunk | 1721 // skip_audio_bytes=bytes to skip from that chunk |