Mercurial > mplayer.hg
annotate dll_init.c @ 737:e8d5e6d4d85f
'--help' bug fixed
author | pontscho |
---|---|
date | Wed, 09 May 2001 14:17:55 +0000 |
parents | eb58bada8bce |
children | cd1f0d4de0b8 |
rev | line source |
---|---|
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
1 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
2 #include <stdio.h> |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
3 #include <stdlib.h> |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
4 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
5 #include "config.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
6 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
7 extern int verbose; // defined in mplayer.c |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
8 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
9 #include "stream.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
10 #include "demuxer.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
11 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
12 #include "loader.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
13 //#include "wine/mmreg.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
14 //#include "wine/vfw.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
15 #include "wine/avifmt.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
16 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
17 #include "codec-cfg.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
18 #include "stheader.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
19 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
20 #include "libvo/img_format.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
21 #include "linux/shmem.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
22 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
23 extern char* win32_codec_name; // must be set before calling DrvOpen() !!! |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
24 |
1 | 25 // ACM audio and VfW video codecs initialization |
26 // based on the avifile library [http://divx.euro.ru] | |
27 | |
296 | 28 int init_acm_audio_codec(sh_audio_t *sh_audio){ |
1 | 29 HRESULT ret; |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
414
diff
changeset
|
30 WAVEFORMATEX *in_fmt=sh_audio->wf; |
1 | 31 unsigned long srcsize=0; |
32 | |
33 if(verbose) printf("======= Win32 (ACM) AUDIO Codec init =======\n"); | |
34 | |
291 | 35 sh_audio->srcstream=NULL; |
1 | 36 |
37 // if(in_fmt->nSamplesPerSec==0){ printf("Bad WAVE header!\n");exit(1); } | |
38 // MSACM_RegisterAllDrivers(); | |
39 | |
291 | 40 sh_audio->o_wf.nChannels=in_fmt->nChannels; |
41 sh_audio->o_wf.nSamplesPerSec=in_fmt->nSamplesPerSec; | |
42 sh_audio->o_wf.nAvgBytesPerSec=2*sh_audio->o_wf.nSamplesPerSec*sh_audio->o_wf.nChannels; | |
43 sh_audio->o_wf.wFormatTag=WAVE_FORMAT_PCM; | |
44 sh_audio->o_wf.nBlockAlign=2*in_fmt->nChannels; | |
45 sh_audio->o_wf.wBitsPerSample=16; | |
46 sh_audio->o_wf.cbSize=0; | |
1 | 47 |
303 | 48 win32_codec_name = sh_audio->codec->dll; |
291 | 49 ret=acmStreamOpen(&sh_audio->srcstream,(HACMDRIVER)NULL, |
50 in_fmt,&sh_audio->o_wf, | |
1 | 51 NULL,0,0,0); |
52 if(ret){ | |
53 if(ret==ACMERR_NOTPOSSIBLE) | |
54 printf("ACM_Decoder: Unappropriate audio format\n"); | |
55 else | |
603 | 56 printf("ACM_Decoder: acmStreamOpen error %d", (int)ret); |
291 | 57 sh_audio->srcstream=NULL; |
1 | 58 return 0; |
59 } | |
60 if(verbose) printf("Audio codec opened OK! ;-)\n"); | |
61 | |
631 | 62 acmStreamSize(sh_audio->srcstream, in_fmt->nBlockAlign, &srcsize, ACM_STREAMSIZEF_SOURCE); |
1 | 63 if(srcsize<OUTBURST) srcsize=OUTBURST; |
291 | 64 sh_audio->audio_out_minsize=srcsize; // audio output min. size |
603 | 65 if(verbose) printf("Audio ACM output buffer min. size: %ld\n",srcsize); |
1 | 66 |
631 | 67 acmStreamSize(sh_audio->srcstream, 2*srcsize, &srcsize, ACM_STREAMSIZEF_DESTINATION); |
291 | 68 sh_audio->audio_in_minsize=srcsize; // audio input min. size |
603 | 69 if(verbose) printf("Audio ACM input buffer min. size: %ld\n",srcsize); |
631 | 70 |
71 if(srcsize<in_fmt->nBlockAlign) srcsize=in_fmt->nBlockAlign; | |
1 | 72 |
631 | 73 sh_audio->a_in_buffer_size=2*sh_audio->audio_in_minsize; |
291 | 74 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); |
75 sh_audio->a_in_buffer_len=0; | |
92 | 76 |
1 | 77 return 1; |
78 } | |
79 | |
291 | 80 int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int len){ |
92 | 81 ACMSTREAMHEADER ash; |
82 HRESULT hr; | |
83 DWORD srcsize=0; | |
291 | 84 acmStreamSize(sh_audio->srcstream,len , &srcsize, ACM_STREAMSIZEF_DESTINATION); |
603 | 85 if(verbose>=3)printf("acm says: srcsize=%ld (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,len); |
291 | 86 // if(srcsize==0) srcsize=((WAVEFORMATEX *)&sh_audio->o_wf_ext)->nBlockAlign; |
87 if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!! | |
88 if(sh_audio->a_in_buffer_len<srcsize){ | |
89 sh_audio->a_in_buffer_len+= | |
90 demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len], | |
91 srcsize-sh_audio->a_in_buffer_len); | |
92 | 92 } |
631 | 93 if(verbose>=3)printf("acm convert %d -> %d bytes\n",sh_audio->a_in_buffer_len,len); |
92 | 94 memset(&ash, 0, sizeof(ash)); |
95 ash.cbStruct=sizeof(ash); | |
96 ash.fdwStatus=0; | |
97 ash.dwUser=0; | |
291 | 98 ash.pbSrc=sh_audio->a_in_buffer; |
99 ash.cbSrcLength=sh_audio->a_in_buffer_len; | |
92 | 100 ash.pbDst=a_buffer; |
101 ash.cbDstLength=len; | |
291 | 102 hr=acmStreamPrepareHeader(sh_audio->srcstream,&ash,0); |
92 | 103 if(hr){ |
603 | 104 printf("ACM_Decoder: acmStreamPrepareHeader error %d\n",(int)hr); |
92 | 105 return -1; |
106 } | |
291 | 107 hr=acmStreamConvert(sh_audio->srcstream,&ash,0); |
92 | 108 if(hr){ |
603 | 109 printf("ACM_Decoder: acmStreamConvert error %d\n",(int)hr); |
631 | 110 |
111 // return -1; | |
92 | 112 } |
631 | 113 if(verbose>=3) printf("acm converted %d -> %d\n",ash.cbSrcLengthUsed,ash.cbDstLengthUsed); |
291 | 114 if(ash.cbSrcLengthUsed>=sh_audio->a_in_buffer_len){ |
115 sh_audio->a_in_buffer_len=0; | |
92 | 116 } else { |
291 | 117 sh_audio->a_in_buffer_len-=ash.cbSrcLengthUsed; |
118 memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[ash.cbSrcLengthUsed],sh_audio->a_in_buffer_len); | |
92 | 119 } |
120 len=ash.cbDstLengthUsed; | |
291 | 121 hr=acmStreamUnprepareHeader(sh_audio->srcstream,&ash,0); |
92 | 122 if(hr){ |
603 | 123 printf("ACM_Decoder: acmStreamUnprepareHeader error %d\n",(int)hr); |
92 | 124 } |
125 return len; | |
126 } | |
127 | |
128 | |
1 | 129 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
489
diff
changeset
|
130 int init_video_codec(sh_video_t *sh_video){ |
1 | 131 HRESULT ret; |
489
2bb59b7c748a
BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents:
469
diff
changeset
|
132 int yuv=0; |
303 | 133 unsigned int outfmt=sh_video->codec->outfmt[sh_video->outfmtidx]; |
1 | 134 |
135 if(verbose) printf("======= Win32 (VFW) VIDEO Codec init =======\n"); | |
136 | |
291 | 137 memset(&sh_video->o_bih, 0, sizeof(BITMAPINFOHEADER)); |
138 sh_video->o_bih.biSize = sizeof(BITMAPINFOHEADER); | |
1 | 139 |
303 | 140 win32_codec_name = sh_video->codec->dll; |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
414
diff
changeset
|
141 sh_video->hic = ICOpen( 0x63646976, sh_video->bih->biCompression, ICMODE_FASTDECOMPRESS); |
291 | 142 // sh_video->hic = ICOpen( 0x63646976, sh_video->bih.biCompression, ICMODE_DECOMPRESS); |
143 if(!sh_video->hic){ | |
1 | 144 printf("ICOpen failed! unknown codec / wrong parameters?\n"); |
145 return 0; | |
146 } | |
147 | |
291 | 148 // sh_video->bih.biBitCount=32; |
1 | 149 |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
414
diff
changeset
|
150 ret = ICDecompressGetFormat(sh_video->hic, sh_video->bih, &sh_video->o_bih); |
1 | 151 if(ret){ |
603 | 152 printf("ICDecompressGetFormat failed: Error %d\n", (int)ret); |
1 | 153 return 0; |
154 } | |
155 if(verbose) printf("ICDecompressGetFormat OK\n"); | |
156 | |
157 // printf("ICM_DECOMPRESS_QUERY=0x%X",ICM_DECOMPRESS_QUERY); | |
158 | |
291 | 159 // sh_video->o_bih.biWidth=sh_video->bih.biWidth; |
160 // sh_video->o_bih.biCompression = 0x32315659; // mmioFOURCC('U','Y','V','Y'); | |
161 // ret=ICDecompressGetFormatSize(sh_video->hic,&sh_video->o_bih); | |
162 // sh_video->o_bih.biCompression = 3; //0x32315659; | |
163 // sh_video->o_bih.biCompression = mmioFOURCC('U','Y','V','Y'); | |
164 // sh_video->o_bih.biCompression = mmioFOURCC('U','Y','V','Y'); | |
165 // sh_video->o_bih.biCompression = mmioFOURCC('Y','U','Y','2'); | |
166 // sh_video->o_bih.biPlanes=3; | |
167 // sh_video->o_bih.biBitCount=16; | |
1 | 168 |
713 | 169 #if 0 |
170 // workaround for pegasus MJPEG: | |
171 if(!sh_video->o_bih.biWidth) sh_video->o_bih.biWidth=sh_video->bih->biWidth; | |
172 if(!sh_video->o_bih.biHeight) sh_video->o_bih.biHeight=sh_video->bih->biHeight; | |
173 if(!sh_video->o_bih.biPlanes) sh_video->o_bih.biPlanes=sh_video->bih->biPlanes; | |
174 #endif | |
408 | 175 |
176 switch (outfmt) { | |
177 | |
178 /* planar format */ | |
179 case IMGFMT_YV12: | |
180 case IMGFMT_I420: | |
181 case IMGFMT_IYUV: | |
182 sh_video->o_bih.biBitCount=12; | |
489
2bb59b7c748a
BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents:
469
diff
changeset
|
183 yuv=1; |
467 | 184 break; |
1 | 185 |
408 | 186 /* packed format */ |
187 case IMGFMT_YUY2: | |
188 case IMGFMT_UYVY: | |
189 case IMGFMT_YVYU: | |
190 sh_video->o_bih.biBitCount=16; | |
489
2bb59b7c748a
BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents:
469
diff
changeset
|
191 yuv=1; |
408 | 192 break; |
303 | 193 |
408 | 194 /* rgb/bgr format */ |
195 case IMGFMT_RGB8: | |
196 case IMGFMT_BGR8: | |
197 sh_video->o_bih.biBitCount=8; | |
198 break; | |
1 | 199 |
408 | 200 case IMGFMT_RGB15: |
201 case IMGFMT_RGB16: | |
202 case IMGFMT_BGR15: | |
203 case IMGFMT_BGR16: | |
204 sh_video->o_bih.biBitCount=16; | |
205 break; | |
206 | |
207 case IMGFMT_RGB24: | |
208 case IMGFMT_BGR24: | |
209 sh_video->o_bih.biBitCount=24; | |
210 break; | |
211 | |
212 case IMGFMT_RGB32: | |
213 case IMGFMT_BGR32: | |
214 sh_video->o_bih.biBitCount=32; | |
215 break; | |
1 | 216 |
408 | 217 default: |
218 printf("unsupported image format: 0x%x\n", outfmt); | |
219 return 0; | |
220 } | |
221 | |
222 sh_video->o_bih.biSizeImage = sh_video->o_bih.biWidth * sh_video->o_bih.biHeight * (sh_video->o_bih.biBitCount/8); | |
713 | 223 |
408 | 224 if(!(sh_video->codec->outflags[sh_video->outfmtidx]&CODECS_FLAG_FLIP)) { |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
414
diff
changeset
|
225 sh_video->o_bih.biHeight=-sh_video->bih->biHeight; // flip image! |
408 | 226 } |
1 | 227 |
489
2bb59b7c748a
BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents:
469
diff
changeset
|
228 if(yuv && !(sh_video->codec->outflags[sh_video->outfmtidx] & CODECS_FLAG_YUVHACK)) |
408 | 229 sh_video->o_bih.biCompression = outfmt; |
1 | 230 |
231 if(verbose) { | |
232 printf("Starting decompression, format:\n"); | |
603 | 233 printf(" biSize %ld\n", sh_video->bih->biSize); |
234 printf(" biWidth %ld\n", sh_video->bih->biWidth); | |
235 printf(" biHeight %ld\n", sh_video->bih->biHeight); | |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
414
diff
changeset
|
236 printf(" biPlanes %d\n", sh_video->bih->biPlanes); |
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
414
diff
changeset
|
237 printf(" biBitCount %d\n", sh_video->bih->biBitCount); |
603 | 238 printf(" biCompression 0x%lx ('%.4s')\n", sh_video->bih->biCompression, (char *)&sh_video->bih->biCompression); |
239 printf(" biSizeImage %ld\n", sh_video->bih->biSizeImage); | |
1 | 240 printf("Dest fmt:\n"); |
603 | 241 printf(" biSize %ld\n", sh_video->o_bih.biSize); |
242 printf(" biWidth %ld\n", sh_video->o_bih.biWidth); | |
243 printf(" biHeight %ld\n", sh_video->o_bih.biHeight); | |
291 | 244 printf(" biPlanes %d\n", sh_video->o_bih.biPlanes); |
245 printf(" biBitCount %d\n", sh_video->o_bih.biBitCount); | |
603 | 246 printf(" biCompression 0x%lx ('%.4s')\n", sh_video->o_bih.biCompression, (char *)&sh_video->o_bih.biCompression); |
247 printf(" biSizeImage %ld\n", sh_video->o_bih.biSizeImage); | |
1 | 248 } |
249 | |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
414
diff
changeset
|
250 ret = ICDecompressQuery(sh_video->hic, sh_video->bih, &sh_video->o_bih); |
1 | 251 if(ret){ |
603 | 252 printf("ICDecompressQuery failed: Error %d\n", (int)ret); |
1 | 253 return 0; |
254 } | |
255 if(verbose) printf("ICDecompressQuery OK\n"); | |
256 | |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
414
diff
changeset
|
257 ret = ICDecompressBegin(sh_video->hic, sh_video->bih, &sh_video->o_bih); |
1 | 258 if(ret){ |
603 | 259 printf("ICDecompressBegin failed: Error %d\n", (int)ret); |
1 | 260 return 0; |
261 } | |
262 | |
263 #if 0 | |
264 | |
291 | 265 //sh_video->hic |
1 | 266 //ICSendMessage(HIC hic,unsigned int msg,long lParam1,long lParam2) |
267 { int i; | |
268 for(i=73;i<256;i++){ | |
269 printf("Calling ICM_USER+%d function...",i);fflush(stdout); | |
291 | 270 ret = ICSendMessage(sh_video->hic,ICM_USER+i,NULL,NULL); |
1 | 271 printf(" ret=%d\n",ret); |
272 } | |
273 } | |
274 #endif | |
275 | |
414 | 276 sh_video->our_out_buffer = shmem_alloc(sh_video->o_bih.biSizeImage); |
291 | 277 if(!sh_video->our_out_buffer){ |
603 | 278 printf("not enough memory for decoded picture buffer (%ld bytes)\n", sh_video->o_bih.biSizeImage); |
1 | 279 return 0; |
280 } | |
281 | |
489
2bb59b7c748a
BGR modes with VfW codecs fixed - biCompression must be 0 for BGR...
arpi_esp
parents:
469
diff
changeset
|
282 if(yuv && sh_video->codec->outflags[sh_video->outfmtidx] & CODECS_FLAG_YUVHACK) |
469 | 283 sh_video->o_bih.biCompression = outfmt; |
1 | 284 |
285 // avi_header.our_in_buffer=malloc(avi_header.video.dwSuggestedBufferSize); // FIXME!!!! | |
286 | |
287 if(verbose) printf("VIDEO CODEC Init OK!!! ;-)\n"); | |
288 return 1; | |
289 } |