annotate dec_audio.c @ 1017:7e653295099c

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