Mercurial > mplayer.hg
annotate dec_audio.c @ 1025:b3dde72791ed
Kernel version checking improvements
author | nickols_k |
---|---|
date | Tue, 05 Jun 2001 08:12:00 +0000 |
parents | 72cacd3b8f30 |
children | b36fb1ae4b53 |
rev | line source |
---|---|
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
1 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
2 #include <stdio.h> |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
3 #include <stdlib.h> |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
4 |
1020
72cacd3b8f30
Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents:
883
diff
changeset
|
5 #ifdef __sun |
72cacd3b8f30
Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents:
883
diff
changeset
|
6 #include <sys/audioio.h> |
72cacd3b8f30
Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents:
883
diff
changeset
|
7 #define AFMT_MU_LAW AUDIO_ENCODING_ULAW |
72cacd3b8f30
Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents:
883
diff
changeset
|
8 #define AFMT_A_LAW AUDIO_ENCODING_ALAW |
72cacd3b8f30
Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents:
883
diff
changeset
|
9 #define AFMT_S16_LE AUDIO_ENCODING_LINEAR |
72cacd3b8f30
Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents:
883
diff
changeset
|
10 #define AFMT_IMA_ADPCM AUDIO_ENCODING_DVI |
72cacd3b8f30
Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents:
883
diff
changeset
|
11 #define AFMT_U8 AUDIO_ENCODING_LINEAR8 |
72cacd3b8f30
Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents:
883
diff
changeset
|
12 #else |
758 | 13 #include <sys/soundcard.h> |
1020
72cacd3b8f30
Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents:
883
diff
changeset
|
14 #endif |
758 | 15 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
16 #include "config.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
17 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
18 extern int verbose; // defined in mplayer.c |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
19 |
732
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
20 #ifdef USE_FAKE_MONO |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
21 int fakemono=0; |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
22 #endif |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
23 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
24 #include "stream.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
25 #include "demuxer.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
26 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
27 #include "wine/mmreg.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
28 #include "wine/avifmt.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
29 #include "wine/vfw.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
30 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
31 #include "codec-cfg.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
32 #include "stheader.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
33 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
34 #include "mp3lib/mp3.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
35 #include "libac3/ac3.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
36 |
883 | 37 #include "alaw.h" |
38 | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
39 #include "xa/xa_gsm.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
40 |
604 | 41 #include "loader/DirectShow/DS_AudioDec.h" |
42 | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
43 static sh_audio_t* ac3_audio_sh=NULL; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
44 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
45 // AC3 decoder buffer callback: |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
46 static void ac3_fill_buffer(uint8_t **start,uint8_t **end){ |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
47 int len=ds_get_packet(ac3_audio_sh->ds,start); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
48 //printf("<ac3:%d>\n",len); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
49 if(len<0) |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
50 *start = *end = NULL; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
51 else |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
52 *end = *start + len; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
53 } |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
54 |
296 | 55 |
56 int init_audio(sh_audio_t *sh_audio){ | |
303 | 57 |
58 int driver=sh_audio->codec->driver; | |
296 | 59 |
604 | 60 extern int init_acm_audio_codec(sh_audio_t *sh_audio); |
758 | 61 //extern int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int len); |
62 extern int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int minlen,int maxlen); | |
604 | 63 |
296 | 64 sh_audio->samplesize=2; |
758 | 65 sh_audio->sample_format=AFMT_S16_LE; |
303 | 66 sh_audio->samplerate=0; |
401 | 67 //sh_audio->pcm_bswap=0; |
303 | 68 |
758 | 69 sh_audio->a_buffer_size=0; |
303 | 70 sh_audio->a_buffer=NULL; |
296 | 71 |
746 | 72 sh_audio->a_in_buffer_len=0; |
73 | |
758 | 74 // setup required min. in/out buffer size: |
75 sh_audio->audio_out_minsize=8192;// default size, maybe not enough for Win32/ACM | |
76 | |
77 switch(driver){ | |
78 case 4: | |
296 | 79 // Win32 ACM audio codec: |
80 if(init_acm_audio_codec(sh_audio)){ | |
746 | 81 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; |
296 | 82 sh_audio->channels=sh_audio->o_wf.nChannels; |
83 sh_audio->samplerate=sh_audio->o_wf.nSamplesPerSec; | |
758 | 84 // if(sh_audio->audio_out_minsize>16384) sh_audio->audio_out_minsize=16384; |
85 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize; | |
86 // if(sh_audio->a_buffer_size<sh_audio->audio_out_minsize+MAX_OUTBURST) | |
87 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; | |
296 | 88 } else { |
89 printf("Could not load/initialize Win32/ACM AUDIO codec (missing DLL file?)\n"); | |
303 | 90 driver=0; |
296 | 91 } |
758 | 92 break; |
93 case 7: | |
296 | 94 #ifndef USE_DIRECTSHOW |
95 printf("Compiled without DirectShow support -> force nosound :(\n"); | |
303 | 96 driver=0; |
296 | 97 #else |
98 // Win32 DShow audio codec: | |
340 | 99 // printf("DShow_audio: channs=%d rate=%d\n",sh_audio->channels,sh_audio->samplerate); |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
100 if(DS_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf)){ |
303 | 101 printf("ERROR: Could not load/initialize Win32/DirctShow AUDIO codec: %s\n",sh_audio->codec->dll); |
102 driver=0; | |
103 } else { | |
746 | 104 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
105 sh_audio->channels=sh_audio->wf->nChannels; |
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
106 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
107 sh_audio->audio_in_minsize=2*sh_audio->wf->nBlockAlign; |
296 | 108 if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192; |
109 sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize; | |
110 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); | |
111 sh_audio->a_in_buffer_len=0; | |
758 | 112 sh_audio->audio_out_minsize=16384; |
296 | 113 } |
114 #endif | |
758 | 115 break; |
116 case 2: | |
117 case 8: | |
118 case 5: | |
119 // PCM, aLaw | |
120 sh_audio->audio_out_minsize=2048; | |
121 break; | |
122 case 3: | |
123 // Dolby AC3 audio: | |
124 sh_audio->audio_out_minsize=4*256*6; | |
125 break; | |
126 case 6: | |
127 // MS-GSM audio codec: | |
128 sh_audio->audio_out_minsize=4*320; | |
129 break; | |
130 case 1: | |
131 // MPEG Audio: | |
132 sh_audio->audio_out_minsize=4608; | |
133 break; | |
296 | 134 } |
135 | |
303 | 136 if(!driver) return 0; |
296 | 137 |
138 // allocate audio out buffer: | |
758 | 139 sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; // worst case calc. |
140 | |
141 printf("dec_audio: Allocating %d + %d = %d bytes for output buffer\n", | |
142 sh_audio->audio_out_minsize,MAX_OUTBURST,sh_audio->a_buffer_size); | |
143 | |
296 | 144 sh_audio->a_buffer=malloc(sh_audio->a_buffer_size); |
758 | 145 if(!sh_audio->a_buffer){ |
146 printf("Cannot allocate audio out buffer\n"); | |
147 return 0; | |
148 } | |
296 | 149 memset(sh_audio->a_buffer,0,sh_audio->a_buffer_size); |
150 sh_audio->a_buffer_len=0; | |
151 | |
303 | 152 switch(driver){ |
153 case 4: { | |
758 | 154 int ret=acm_decode_audio(sh_audio,sh_audio->a_buffer,4096,sh_audio->a_buffer_size); |
296 | 155 if(ret<0){ |
303 | 156 printf("ACM decoding error: %d\n",ret); |
157 driver=0; | |
296 | 158 } |
640 | 159 sh_audio->a_buffer_len=ret; |
303 | 160 break; |
296 | 161 } |
303 | 162 case 2: { |
296 | 163 // AVI PCM Audio: |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
164 WAVEFORMATEX *h=sh_audio->wf; |
746 | 165 sh_audio->i_bps=h->nAvgBytesPerSec; |
296 | 166 sh_audio->channels=h->nChannels; |
167 sh_audio->samplerate=h->nSamplesPerSec; | |
168 sh_audio->samplesize=(h->wBitsPerSample+7)/8; | |
758 | 169 switch(sh_audio->format){ // hardware formats: |
170 case 0x6: sh_audio->sample_format=AFMT_A_LAW;break; | |
171 case 0x7: sh_audio->sample_format=AFMT_MU_LAW;break; | |
172 case 0x11: sh_audio->sample_format=AFMT_IMA_ADPCM;break; | |
1020
72cacd3b8f30
Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents:
883
diff
changeset
|
173 #ifndef __sun |
758 | 174 case 0x50: sh_audio->sample_format=AFMT_MPEG;break; |
1020
72cacd3b8f30
Solaris 8 support - patch by Marcus Comstedt <marcus@idonex.se>
arpi_esp
parents:
883
diff
changeset
|
175 #endif |
758 | 176 // case 0x2000: sh_audio->sample_format=AFMT_AC3; |
177 default: sh_audio->sample_format=(sh_audio->samplesize==2)?AFMT_S16_LE:AFMT_U8; | |
178 } | |
401 | 179 break; |
180 } | |
181 case 8: { | |
182 // DVD PCM Audio: | |
183 sh_audio->channels=2; | |
184 sh_audio->samplerate=48000; | |
746 | 185 sh_audio->i_bps=2*2*48000; |
296 | 186 // sh_audio->pcm_bswap=1; |
303 | 187 break; |
188 } | |
189 case 3: { | |
296 | 190 // Dolby AC3 audio: |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
191 ac3_audio_sh=sh_audio; // save sh_audio for the callback: |
296 | 192 ac3_config.fill_buffer_callback = ac3_fill_buffer; |
193 ac3_config.num_output_ch = 2; | |
194 ac3_config.flags = 0; | |
195 #ifdef HAVE_MMX | |
196 ac3_config.flags |= AC3_MMX_ENABLE; | |
197 #endif | |
198 #ifdef HAVE_3DNOW | |
199 ac3_config.flags |= AC3_3DNOW_ENABLE; | |
200 #endif | |
201 ac3_init(); | |
202 sh_audio->ac3_frame = ac3_decode_frame(); | |
203 if(sh_audio->ac3_frame){ | |
746 | 204 ac3_frame_t* fr=(ac3_frame_t*)sh_audio->ac3_frame; |
205 sh_audio->samplerate=fr->sampling_rate; | |
296 | 206 sh_audio->channels=2; |
746 | 207 // 1 frame: 6*256 samples 1 sec: sh_audio->samplerate samples |
208 //sh_audio->i_bps=fr->frame_size*fr->sampling_rate/(6*256); | |
209 sh_audio->i_bps=fr->bit_rate*(1000/8); | |
303 | 210 } else { |
211 driver=0; // bad frame -> disable audio | |
212 } | |
213 break; | |
214 } | |
215 case 5: { | |
296 | 216 // aLaw audio codec: |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
217 sh_audio->channels=sh_audio->wf->nChannels; |
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
218 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
746 | 219 sh_audio->i_bps=sh_audio->channels*sh_audio->samplerate; |
303 | 220 break; |
221 } | |
222 case 6: { | |
296 | 223 // MS-GSM audio codec: |
224 GSM_Init(); | |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
225 sh_audio->channels=sh_audio->wf->nChannels; |
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
226 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
746 | 227 // decodes 65 byte -> 320 short |
228 // 1 sec: sh_audio->channels*sh_audio->samplerate samples | |
229 // 1 frame: 320 samples | |
230 sh_audio->i_bps=65*(sh_audio->channels*sh_audio->samplerate)/320; // 1:10 | |
303 | 231 break; |
296 | 232 } |
303 | 233 case 1: { |
296 | 234 // MPEG Audio: |
732
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
235 #ifdef USE_FAKE_MONO |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
236 MP3_Init(fakemono); |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
237 #else |
296 | 238 MP3_Init(); |
732
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
239 #endif |
296 | 240 MP3_samplerate=MP3_channels=0; |
241 // printf("[\n"); | |
242 sh_audio->a_buffer_len=MP3_DecodeFrame(sh_audio->a_buffer,-1); | |
243 // printf("]\n"); | |
244 sh_audio->channels=2; // hack | |
245 sh_audio->samplerate=MP3_samplerate; | |
746 | 246 sh_audio->i_bps=MP3_bitrate*(1000/8); |
303 | 247 break; |
248 } | |
296 | 249 } |
250 | |
251 if(!sh_audio->channels || !sh_audio->samplerate){ | |
252 printf("Unknown/missing audio format, using nosound\n"); | |
303 | 253 driver=0; |
296 | 254 } |
255 | |
303 | 256 if(!driver){ |
257 if(sh_audio->a_buffer) free(sh_audio->a_buffer); | |
258 sh_audio->o_bps=0; | |
259 return 0; | |
260 } | |
296 | 261 |
303 | 262 sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize; |
263 return driver; | |
296 | 264 } |
291 | 265 |
746 | 266 // Audio decoding: |
291 | 267 |
746 | 268 // Decode a single frame (mp3,acm etc) or 'minlen' bytes (pcm/alaw etc) |
269 // buffer length is 'maxlen' bytes, it shouldn't be exceeded... | |
270 | |
271 int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){ | |
291 | 272 int len=-1; |
303 | 273 switch(sh_audio->codec->driver){ |
291 | 274 case 1: // MPEG layer 2 or 3 |
275 len=MP3_DecodeFrame(buf,-1); | |
296 | 276 sh_audio->channels=2; // hack |
291 | 277 break; |
401 | 278 case 2: // AVI PCM |
746 | 279 { len=demux_read_data(sh_audio->ds,buf,minlen); |
401 | 280 break; |
281 } | |
282 case 8: // DVD PCM | |
283 { int j; | |
746 | 284 len=demux_read_data(sh_audio->ds,buf,minlen); |
291 | 285 //if(i&1){ printf("Warning! pcm_audio_size&1 !=0 (%d)\n",i);i&=~1; } |
746 | 286 // swap endian: |
291 | 287 for(j=0;j<len;j+=2){ |
288 char x=buf[j]; | |
289 buf[j]=buf[j+1]; | |
290 buf[j+1]=x; | |
291 } | |
292 break; | |
293 } | |
294 case 5: // aLaw decoder | |
746 | 295 { int l=demux_read_data(sh_audio->ds,buf,minlen/2); |
291 | 296 unsigned short *d=(unsigned short *) buf; |
297 unsigned char *s=buf; | |
298 len=2*l; | |
758 | 299 if(sh_audio->format==6){ |
300 // aLaw | |
883 | 301 while(l>0){ --l; d[l]=alaw2short[s[l]]; } |
758 | 302 } else { |
303 // uLaw | |
883 | 304 while(l>0){ --l; d[l]=ulaw2short[s[l]]; } |
291 | 305 } |
306 break; | |
307 } | |
308 case 6: // MS-GSM decoder | |
309 { unsigned char buf[65]; // 65 bytes / frame | |
746 | 310 if(demux_read_data(sh_audio->ds,buf,65)!=65) break; // EOF |
311 XA_MSGSM_Decoder(buf,(unsigned short *) buf); // decodes 65 byte -> 320 short | |
312 // XA_GSM_Decoder(buf,(unsigned short *) &sh_audio->a_buffer[sh_audio->a_buffer_len]); // decodes 33 byte -> 160 short | |
313 len=2*320; | |
291 | 314 break; |
315 } | |
316 case 3: // AC3 decoder | |
317 //printf("{1:%d}",avi_header.idx_pos);fflush(stdout); | |
318 if(!sh_audio->ac3_frame) sh_audio->ac3_frame=ac3_decode_frame(); | |
319 //printf("{2:%d}",avi_header.idx_pos);fflush(stdout); | |
320 if(sh_audio->ac3_frame){ | |
296 | 321 len = 256 * 6 *sh_audio->channels*sh_audio->samplesize; |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
322 memcpy(buf,((ac3_frame_t*)sh_audio->ac3_frame)->audio_data,len); |
291 | 323 sh_audio->ac3_frame=NULL; |
324 } | |
325 //printf("{3:%d}",avi_header.idx_pos);fflush(stdout); | |
326 break; | |
327 case 4: | |
758 | 328 // len=sh_audio->audio_out_minsize; // optimal decoded fragment size |
329 // if(len<minlen) len=minlen; else | |
330 // if(len>maxlen) len=maxlen; | |
331 // len=acm_decode_audio(sh_audio,buf,len); | |
332 len=acm_decode_audio(sh_audio,buf,minlen,maxlen); | |
291 | 333 break; |
746 | 334 |
291 | 335 #ifdef USE_DIRECTSHOW |
336 case 7: // DirectShow | |
337 { int ret; | |
338 int size_in=0; | |
339 int size_out=0; | |
340 int srcsize=DS_AudioDecoder_GetSrcSize(maxlen); | |
341 if(verbose>2)printf("DShow says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen); | |
342 if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!! | |
343 if(sh_audio->a_in_buffer_len<srcsize){ | |
344 sh_audio->a_in_buffer_len+= | |
345 demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len], | |
346 srcsize-sh_audio->a_in_buffer_len); | |
347 } | |
348 DS_AudioDecoder_Convert(sh_audio->a_in_buffer,sh_audio->a_in_buffer_len, | |
349 buf,maxlen, &size_in,&size_out); | |
754 | 350 if(verbose) |
351 printf("DShow: audio %d -> %d converted (in_buf_len=%d of %d) %d\n",size_in,size_out,sh_audio->a_in_buffer_len,sh_audio->a_in_buffer_size,ds_tell_pts(sh_audio->ds)); | |
291 | 352 if(size_in>=sh_audio->a_in_buffer_len){ |
353 sh_audio->a_in_buffer_len=0; | |
354 } else { | |
355 sh_audio->a_in_buffer_len-=size_in; | |
356 memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len); | |
357 } | |
358 len=size_out; | |
359 break; | |
360 } | |
361 #endif | |
362 } | |
363 return len; | |
364 } | |
365 | |
366 |