annotate dec_audio.c @ 378:6e813c134226

variables related to fbdev moved to cfg-mplayer.h
author szabii
date Thu, 12 Apr 2001 20:37:25 +0000
parents 1f7c824033fb
children 835fac6382be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
1
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
2 int init_audio(sh_audio_t *sh_audio){
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
3
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
4 int driver=sh_audio->codec->driver;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
5
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
6 sh_audio->samplesize=2;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
7 sh_audio->samplerate=0;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
8 sh_audio->pcm_bswap=0;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
9
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
10 sh_audio->a_buffer_size=16384; // default size, maybe not enough for Win32/ACM
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
11 sh_audio->a_buffer=NULL;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
12
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
13 if(driver==4){
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
14 // Win32 ACM audio codec:
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
15 if(init_acm_audio_codec(sh_audio)){
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
16 sh_audio->channels=sh_audio->o_wf.nChannels;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
17 sh_audio->samplerate=sh_audio->o_wf.nSamplesPerSec;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
18 if(sh_audio->a_buffer_size<sh_audio->audio_out_minsize+OUTBURST)
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
19 sh_audio->a_buffer_size=sh_audio->audio_out_minsize+OUTBURST;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
20 } else {
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
21 printf("Could not load/initialize Win32/ACM AUDIO codec (missing DLL file?)\n");
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
22 driver=0;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
23 }
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
24 }
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
25
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
26 if(driver==7){
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
27 #ifndef USE_DIRECTSHOW
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
28 printf("Compiled without DirectShow support -> force nosound :(\n");
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
29 driver=0;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
30 #else
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
31 // Win32 DShow audio codec:
340
1f7c824033fb less, and more informal printfs
arpi_esp
parents: 303
diff changeset
32 // printf("DShow_audio: channs=%d rate=%d\n",sh_audio->channels,sh_audio->samplerate);
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
33
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
34 if(DS_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,&sh_audio->wf)){
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
35 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
36 driver=0;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
37 } else {
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
38 sh_audio->channels=sh_audio->wf.nChannels;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
39 sh_audio->samplerate=sh_audio->wf.nSamplesPerSec;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
40 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
41 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
42 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
43 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
44 sh_audio->a_in_buffer_len=0;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
45 }
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
46 #endif
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
47 }
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
48
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
49 if(!driver) return 0;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
50
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
51 // allocate audio out buffer:
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
52 sh_audio->a_buffer=malloc(sh_audio->a_buffer_size);
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
53 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
54 sh_audio->a_buffer_len=0;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
55
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
56 switch(driver){
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
57 case 4: {
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
58 int ret=acm_decode_audio(sh_audio,sh_audio->a_buffer,sh_audio->a_buffer_size);
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
59 if(ret<0){
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
60 printf("ACM decoding error: %d\n",ret);
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
61 driver=0;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
62 }
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
63 break;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
64 }
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
65 case 2: {
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
66 // if(file_format==DEMUXER_TYPE_AVI){ // FIXME!!!!!!!
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
67 // AVI PCM Audio:
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
68 WAVEFORMATEX *h=&sh_audio->wf;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
69 sh_audio->channels=h->nChannels;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
70 sh_audio->samplerate=h->nSamplesPerSec;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
71 sh_audio->samplesize=(h->wBitsPerSample+7)/8;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
72 // } else {
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
73 // // DVD PCM audio:
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
74 // sh_audio->channels=2;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
75 // sh_audio->samplerate=48000;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
76 // sh_audio->pcm_bswap=1;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
77 // }
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
78 break;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
79 }
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
80 case 3: {
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
81 // Dolby AC3 audio:
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
82 ac3_config.fill_buffer_callback = ac3_fill_buffer;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
83 ac3_config.num_output_ch = 2;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
84 ac3_config.flags = 0;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
85 #ifdef HAVE_MMX
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
86 ac3_config.flags |= AC3_MMX_ENABLE;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
87 #endif
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
88 #ifdef HAVE_3DNOW
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
89 ac3_config.flags |= AC3_3DNOW_ENABLE;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
90 #endif
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
91 ac3_init();
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
92 sh_audio->ac3_frame = ac3_decode_frame();
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
93 if(sh_audio->ac3_frame){
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
94 sh_audio->samplerate=sh_audio->ac3_frame->sampling_rate;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
95 sh_audio->channels=2;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
96 } else {
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
97 driver=0; // bad frame -> disable audio
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
98 }
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
99 break;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
100 }
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
101 case 5: {
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
102 // aLaw audio codec:
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
103 Gen_aLaw_2_Signed(); // init table
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
104 sh_audio->channels=sh_audio->wf.nChannels;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
105 sh_audio->samplerate=sh_audio->wf.nSamplesPerSec;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
106 break;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
107 }
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
108 case 6: {
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
109 // MS-GSM audio codec:
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
110 GSM_Init();
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
111 sh_audio->channels=sh_audio->wf.nChannels;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
112 sh_audio->samplerate=sh_audio->wf.nSamplesPerSec;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
113 break;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
114 }
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
115 case 1: {
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
116 // MPEG Audio:
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
117 MP3_Init();
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
118 MP3_samplerate=MP3_channels=0;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
119 // printf("[\n");
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
120 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
121 // printf("]\n");
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
122 sh_audio->channels=2; // hack
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
123 sh_audio->samplerate=MP3_samplerate;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
124 break;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
125 }
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
126 }
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
127
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
128 if(!sh_audio->channels || !sh_audio->samplerate){
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
129 printf("Unknown/missing audio format, using nosound\n");
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
130 driver=0;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
131 }
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
132
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
133 if(!driver){
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
134 if(sh_audio->a_buffer) free(sh_audio->a_buffer);
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
135 sh_audio->o_bps=0;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
136 return 0;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
137 }
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
138
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
139 sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
140 return driver;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
141 }
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
142
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
143 // Audio decoding
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
144
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
145 int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int maxlen){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
146 int len=-1;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
147 switch(sh_audio->codec->driver){
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
148 case 1: // MPEG layer 2 or 3
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
149 len=MP3_DecodeFrame(buf,-1);
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
150 sh_audio->channels=2; // hack
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
151 break;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
152 case 2: // PCM
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
153 { len=demux_read_data(sh_audio->ds,buf,OUTBURST);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
154 if(sh_audio->pcm_bswap){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
155 int j;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
156 //if(i&1){ printf("Warning! pcm_audio_size&1 !=0 (%d)\n",i);i&=~1; }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
157 for(j=0;j<len;j+=2){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
158 char x=buf[j];
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
159 buf[j]=buf[j+1];
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
160 buf[j+1]=x;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
161 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
162 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
163 break;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
164 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
165 case 5: // aLaw decoder
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
166 { int l=demux_read_data(sh_audio->ds,buf,OUTBURST/2);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
167 unsigned short *d=(unsigned short *) buf;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
168 unsigned char *s=buf;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
169 len=2*l;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
170 while(l>0){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
171 --l;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
172 d[l]=xa_alaw_2_sign[s[l]];
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
173 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
174 break;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
175 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
176 case 6: // MS-GSM decoder
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
177 { unsigned char buf[65]; // 65 bytes / frame
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
178 len=0;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
179 while(len<OUTBURST){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
180 if(demux_read_data(d_audio,buf,65)!=65) break; // EOF
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
181 XA_MSGSM_Decoder(buf,(unsigned short *) buf); // decodes 65 byte -> 320 short
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
182 // XA_GSM_Decoder(buf,(unsigned short *) &sh_audio->a_buffer[sh_audio->a_buffer_len]); // decodes 33 byte -> 160 short
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
183 len+=2*320;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
184 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
185 break;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
186 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
187 case 3: // AC3 decoder
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
188 //printf("{1:%d}",avi_header.idx_pos);fflush(stdout);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
189 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
190 //printf("{2:%d}",avi_header.idx_pos);fflush(stdout);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
191 if(sh_audio->ac3_frame){
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
192 len = 256 * 6 *sh_audio->channels*sh_audio->samplesize;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
193 memcpy(buf,sh_audio->ac3_frame->audio_data,len);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
194 sh_audio->ac3_frame=NULL;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
195 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
196 //printf("{3:%d}",avi_header.idx_pos);fflush(stdout);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
197 break;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
198 case 4:
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
199 { len=acm_decode_audio(sh_audio,buf,maxlen);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
200 break;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
201 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
202 #ifdef USE_DIRECTSHOW
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
203 case 7: // DirectShow
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
204 { int ret;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
205 int size_in=0;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
206 int size_out=0;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
207 int srcsize=DS_AudioDecoder_GetSrcSize(maxlen);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
208 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
209 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
210 if(sh_audio->a_in_buffer_len<srcsize){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
211 sh_audio->a_in_buffer_len+=
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
212 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
213 srcsize-sh_audio->a_in_buffer_len);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
214 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
215 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
216 buf,maxlen, &size_in,&size_out);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
217 if(verbose>2)printf("DShow: audio %d -> %d converted (in_buf_len=%d of %d)\n",size_in,size_out,sh_audio->a_in_buffer_len,sh_audio->a_in_buffer_size);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
218 if(size_in>=sh_audio->a_in_buffer_len){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
219 sh_audio->a_in_buffer_len=0;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
220 } else {
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
221 sh_audio->a_in_buffer_len-=size_in;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
222 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
223 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
224 len=size_out;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
225 break;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
226 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
227 #endif
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
228 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
229 return len;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
230 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
231
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
232