Mercurial > mplayer.hg
annotate dec_audio.c @ 5092:3cc4aaa3724b
10l
author | arpi |
---|---|
date | Fri, 15 Mar 2002 16:36:45 +0000 |
parents | e080a8d5019f |
children | 378d60504938 |
rev | line source |
---|---|
3866 | 1 |
2 #define USE_G72X | |
3886 | 3 //#define USE_LIBAC3 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
4 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
5 #include <stdio.h> |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
6 #include <stdlib.h> |
1430 | 7 #include <unistd.h> |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
8 |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
9 #include "config.h" |
1567 | 10 #include "mp_msg.h" |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
11 #include "help_mp.h" |
1567 | 12 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
13 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
|
14 |
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 "codec-cfg.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
19 #include "stheader.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
20 |
2563 | 21 #include "dec_audio.h" |
22 | |
4486 | 23 #include "roqav.h" |
24 | |
2563 | 25 //========================================================================== |
26 | |
27 #include "libao2/afmt.h" | |
28 | |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
1973
diff
changeset
|
29 #include "dll_init.h" |
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
1973
diff
changeset
|
30 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
31 #include "mp3lib/mp3.h" |
3886 | 32 |
33 #ifdef USE_LIBAC3 | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
34 #include "libac3/ac3.h" |
3886 | 35 #endif |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
36 |
3413 | 37 #include "liba52/a52.h" |
3907 | 38 #include "liba52/mm_accel.h" |
3413 | 39 static sample_t * a52_samples; |
40 static a52_state_t a52_state; | |
3907 | 41 static uint32_t a52_accel=0; |
3911 | 42 static uint32_t a52_flags=0; |
3413 | 43 |
3866 | 44 #ifdef USE_G72X |
3426 | 45 #include "g72x/g72x.h" |
46 static G72x_DATA g72x_data; | |
3866 | 47 #endif |
3413 | 48 |
883 | 49 #include "alaw.h" |
50 | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
51 #include "xa/xa_gsm.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
52 |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
53 #include "ac3-iec958.h" |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
54 |
3756 | 55 #include "adpcm.h" |
2420 | 56 |
3145 | 57 #include "cpudetect.h" |
58 | |
3182
95bbd21e8e1f
moved num_audio_channels out of LIBMAD ifdef, where it didn't belong!
steve
parents:
3181
diff
changeset
|
59 /* used for ac3surround decoder - set using -channels option */ |
95bbd21e8e1f
moved num_audio_channels out of LIBMAD ifdef, where it didn't belong!
steve
parents:
3181
diff
changeset
|
60 int audio_output_channels = 2; |
95bbd21e8e1f
moved num_audio_channels out of LIBMAD ifdef, where it didn't belong!
steve
parents:
3181
diff
changeset
|
61 |
2563 | 62 #ifdef USE_FAKE_MONO |
63 int fakemono=0; | |
64 #endif | |
65 | |
1291 | 66 #ifdef USE_DIRECTSHOW |
3947
2eb8c8aacca7
using dshow headers from dshow/ instead of c++ version
arpi
parents:
3933
diff
changeset
|
67 #include "loader/dshow/DS_AudioDecoder.h" |
2eb8c8aacca7
using dshow headers from dshow/ instead of c++ version
arpi
parents:
3933
diff
changeset
|
68 static DS_AudioDecoder* ds_adec=NULL; |
1291 | 69 #endif |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
70 |
1828 | 71 #ifdef HAVE_OGGVORBIS |
72 /* XXX is math.h really needed? - atmos */ | |
73 #include <math.h> | |
74 #include <vorbis/codec.h> | |
2341 | 75 |
76 typedef struct ov_struct_st { | |
77 ogg_sync_state oy; /* sync and verify incoming physical bitstream */ | |
78 ogg_stream_state os; /* take physical pages, weld into a logical | |
79 stream of packets */ | |
80 ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ | |
81 ogg_packet op; /* one raw packet of data for decode */ | |
3145 | 82 |
2341 | 83 vorbis_info vi; /* struct that stores all the static vorbis bitstream |
84 settings */ | |
85 vorbis_comment vc; /* struct that stores all the bitstream user comments */ | |
86 vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ | |
87 vorbis_block vb; /* local working space for packet->PCM decode */ | |
88 } ov_struct_t; | |
1828 | 89 #endif |
90 | |
1927 | 91 #ifdef USE_LIBAVCODEC |
2496 | 92 #ifdef USE_LIBAVCODEC_SO |
93 #include <libffmpeg/avcodec.h> | |
94 #else | |
1927 | 95 #include "libavcodec/avcodec.h" |
2496 | 96 #endif |
1927 | 97 static AVCodec *lavc_codec=NULL; |
98 static AVCodecContext lavc_context; | |
99 extern int avcodec_inited; | |
100 #endif | |
101 | |
2415 | 102 |
103 | |
104 #ifdef USE_LIBMAD | |
105 #include <mad.h> | |
4208
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
106 |
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
107 #define MAD_SINGLE_BUFFER_SIZE 8192 |
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
108 #define MAD_TOTAL_BUFFER_SIZE ((MAD_SINGLE_BUFFER_SIZE)*3) |
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
109 |
2415 | 110 static struct mad_stream mad_stream; |
111 static struct mad_frame mad_frame; | |
112 static struct mad_synth mad_synth; | |
4208
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
113 static char* mad_in_buffer = 0; /* base pointer of buffer */ |
2415 | 114 |
115 // ensure buffer is filled with some data | |
116 static void mad_prepare_buffer(sh_audio_t* sh_audio, struct mad_stream* ms, int length) | |
117 { | |
118 if(sh_audio->a_in_buffer_len < length) { | |
119 int len = demux_read_data(sh_audio->ds, sh_audio->a_in_buffer+sh_audio->a_in_buffer_len, length-sh_audio->a_in_buffer_len); | |
120 sh_audio->a_in_buffer_len += len; | |
3874 | 121 // printf("mad_prepare_buffer: read %d bytes\n", len); |
2415 | 122 } |
123 } | |
124 | |
125 static void mad_postprocess_buffer(sh_audio_t* sh_audio, struct mad_stream* ms) | |
126 { | |
4208
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
127 /* rotate buffer while possible, in order to reduce the overhead of endless memcpy */ |
2415 | 128 int delta = (unsigned char*)ms->next_frame - (unsigned char *)sh_audio->a_in_buffer; |
4208
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
129 if((unsigned long)(sh_audio->a_in_buffer) - (unsigned long)mad_in_buffer < |
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
130 (MAD_TOTAL_BUFFER_SIZE - MAD_SINGLE_BUFFER_SIZE - delta)) { |
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
131 sh_audio->a_in_buffer += delta; |
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
132 sh_audio->a_in_buffer_len -= delta; |
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
133 } else { |
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
134 sh_audio->a_in_buffer = mad_in_buffer; |
2415 | 135 sh_audio->a_in_buffer_len -= delta; |
136 memcpy(sh_audio->a_in_buffer, ms->next_frame, sh_audio->a_in_buffer_len); | |
137 } | |
138 } | |
139 | |
140 static inline | |
141 signed short mad_scale(mad_fixed_t sample) | |
142 { | |
143 /* round */ | |
144 sample += (1L << (MAD_F_FRACBITS - 16)); | |
145 | |
146 /* clip */ | |
147 if (sample >= MAD_F_ONE) | |
148 sample = MAD_F_ONE - 1; | |
149 else if (sample < -MAD_F_ONE) | |
150 sample = -MAD_F_ONE; | |
151 | |
152 /* quantize */ | |
153 return sample >> (MAD_F_FRACBITS + 1 - 16); | |
3871 | 154 |
155 } | |
156 | |
157 static void mad_sync(sh_audio_t* sh_audio, struct mad_stream* ms) | |
158 { | |
159 int len; | |
3874 | 160 #if 1 |
3871 | 161 int skipped = 0; |
162 | |
163 // printf("buffer len: %d\n", sh_audio->a_in_buffer_len); | |
164 while(sh_audio->a_in_buffer_len - skipped) | |
165 { | |
166 len = mp_decode_mp3_header(sh_audio->a_in_buffer+skipped); | |
167 if (len != -1) | |
168 { | |
169 // printf("Frame len=%d\n", len); | |
170 break; | |
171 } | |
172 else | |
173 skipped++; | |
174 } | |
175 if (skipped) | |
176 { | |
177 printf("Audio synced, skipped bytes: %d\n", skipped); | |
3874 | 178 // ms->skiplen += skipped; |
179 // printf("skiplen: %d (skipped: %d)\n", ms->skiplen, skipped); | |
180 | |
181 // if (sh_audio->a_in_buffer_len - skipped < MAD_BUFFER_GUARD) | |
182 // printf("Mad reports: too small buffer\n"); | |
183 | |
184 // mad_stream_buffer(ms, sh_audio->a_in_buffer+skipped, sh_audio->a_in_buffer_len-skipped); | |
185 // mad_prepare_buffer(sh_audio, ms, sh_audio->a_in_buffer_len-skipped); | |
186 | |
187 /* move frame to the beginning of the buffer and fill up to a_in_buffer_size */ | |
188 sh_audio->a_in_buffer_len -= skipped; | |
189 memcpy(sh_audio->a_in_buffer, sh_audio->a_in_buffer+skipped, sh_audio->a_in_buffer_len); | |
190 mad_prepare_buffer(sh_audio, ms, sh_audio->a_in_buffer_size); | |
191 mad_stream_buffer(ms, sh_audio->a_in_buffer, sh_audio->a_in_buffer_len); | |
192 // printf("bufflen: %d\n", sh_audio->a_in_buffer_len); | |
193 | |
194 // len = mp_decode_mp3_header(sh_audio->a_in_buffer); | |
195 // printf("len: %d\n", len); | |
196 ms->md_len = len; | |
3871 | 197 } |
3874 | 198 #else |
3871 | 199 len = mad_stream_sync(&ms); |
200 if (len == -1) | |
201 { | |
202 printf("Mad sync failed\n"); | |
203 } | |
204 #endif | |
2415 | 205 } |
3874 | 206 |
207 static void mad_print_error(struct mad_stream *mad_stream) | |
208 { | |
209 printf("error (0x%x): ", mad_stream->error); | |
210 switch(mad_stream->error) | |
211 { | |
212 case MAD_ERROR_BUFLEN: printf("buffer too small"); break; | |
213 case MAD_ERROR_BUFPTR: printf("invalid buffer pointer"); break; | |
214 case MAD_ERROR_NOMEM: printf("not enought memory"); break; | |
215 case MAD_ERROR_LOSTSYNC: printf("lost sync"); break; | |
216 case MAD_ERROR_BADLAYER: printf("bad layer"); break; | |
217 case MAD_ERROR_BADBITRATE: printf("bad bitrate"); break; | |
218 case MAD_ERROR_BADSAMPLERATE: printf("bad samplerate"); break; | |
219 case MAD_ERROR_BADEMPHASIS: printf("bad emphasis"); break; | |
220 case MAD_ERROR_BADCRC: printf("bad crc"); break; | |
221 case MAD_ERROR_BADBITALLOC: printf("forbidden bit alloc val"); break; | |
222 case MAD_ERROR_BADSCALEFACTOR: printf("bad scalefactor index"); break; | |
223 case MAD_ERROR_BADFRAMELEN: printf("bad frame length"); break; | |
224 case MAD_ERROR_BADBIGVALUES: printf("bad bigvalues count"); break; | |
225 case MAD_ERROR_BADBLOCKTYPE: printf("reserved blocktype"); break; | |
226 case MAD_ERROR_BADSCFSI: printf("bad scalefactor selinfo"); break; | |
227 case MAD_ERROR_BADDATAPTR: printf("bad maindatabegin ptr"); break; | |
228 case MAD_ERROR_BADPART3LEN: printf("bad audio data len"); break; | |
229 case MAD_ERROR_BADHUFFTABLE: printf("bad huffman table sel"); break; | |
230 case MAD_ERROR_BADHUFFDATA: printf("huffman data overrun"); break; | |
231 case MAD_ERROR_BADSTEREO: printf("incomp. blocktype for JS"); break; | |
232 default: | |
233 printf("unknown error"); | |
234 } | |
235 printf("\n"); | |
236 } | |
2415 | 237 #endif |
238 | |
239 | |
3413 | 240 static int a52_fillbuff(sh_audio_t *sh_audio){ |
241 int length=0; | |
242 int flags=0; | |
243 int sample_rate=0; | |
244 int bit_rate=0; | |
3834 | 245 |
246 sh_audio->a_in_buffer_len=0; | |
247 // sync frame: | |
3413 | 248 while(1){ |
249 while(sh_audio->a_in_buffer_len<7){ | |
250 int c=demux_getc(sh_audio->ds); | |
251 if(c<0) return -1; // EOF | |
252 sh_audio->a_in_buffer[sh_audio->a_in_buffer_len++]=c; | |
253 } | |
254 length = a52_syncinfo (sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate); | |
3834 | 255 if(length>=7 && length<=3840) break; // we're done. |
256 // bad file => resync | |
257 memcpy(sh_audio->a_in_buffer,sh_audio->a_in_buffer+1,6); | |
258 --sh_audio->a_in_buffer_len; | |
259 } | |
3413 | 260 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"a52: len=%d flags=0x%X %d Hz %d bit/s\n",length,flags,sample_rate,bit_rate); |
261 sh_audio->samplerate=sample_rate; | |
262 sh_audio->i_bps=bit_rate/8; | |
263 demux_read_data(sh_audio->ds,sh_audio->a_in_buffer+7,length-7); | |
3891 | 264 |
265 if(crc16_block(sh_audio->a_in_buffer+2,length-2)!=0) | |
266 mp_msg(MSGT_DECAUDIO,MSGL_STATUS,"a52: CRC check failed! \n"); | |
267 | |
3413 | 268 return length; |
269 } | |
2415 | 270 |
3887 | 271 // returns: number of available channels |
272 static int a52_printinfo(sh_audio_t *sh_audio){ | |
273 int flags, sample_rate, bit_rate; | |
274 char* mode="unknown"; | |
275 int channels=0; | |
276 a52_syncinfo (sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate); | |
277 switch(flags&A52_CHANNEL_MASK){ | |
278 case A52_CHANNEL: mode="channel"; channels=2; break; | |
279 case A52_MONO: mode="mono"; channels=1; break; | |
280 case A52_STEREO: mode="stereo"; channels=2; break; | |
281 case A52_3F: mode="3f";channels=3;break; | |
282 case A52_2F1R: mode="2f+1r";channels=3;break; | |
283 case A52_3F1R: mode="3f+1r";channels=4;break; | |
284 case A52_2F2R: mode="2f+2r";channels=4;break; | |
285 case A52_3F2R: mode="3f+2r";channels=5;break; | |
286 case A52_CHANNEL1: mode="channel1"; channels=2; break; | |
287 case A52_CHANNEL2: mode="channel2"; channels=2; break; | |
288 case A52_DOLBY: mode="dolby"; channels=2; break; | |
289 } | |
290 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"AC3: %d.%d (%s%s) %d Hz %3.1f kbit/s\n", | |
291 channels, (flags&A52_LFE)?1:0, | |
292 mode, (flags&A52_LFE)?"+lfe":"", | |
293 sample_rate, bit_rate*0.001f); | |
294 return (flags&A52_LFE) ? (channels+1) : channels; | |
295 } | |
296 | |
1927 | 297 int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen); |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
298 |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
299 |
1289 | 300 static sh_audio_t* dec_audio_sh=NULL; |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
301 |
3886 | 302 #ifdef USE_LIBAC3 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
303 // AC3 decoder buffer callback: |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
304 static void ac3_fill_buffer(uint8_t **start,uint8_t **end){ |
1289 | 305 int len=ds_get_packet(dec_audio_sh->ds,start); |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
306 //printf("<ac3:%d>\n",len); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
307 if(len<0) |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
308 *start = *end = NULL; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
309 else |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
310 *end = *start + len; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
311 } |
3886 | 312 #endif |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
313 |
1289 | 314 // MP3 decoder buffer callback: |
315 int mplayer_audio_read(char *buf,int size){ | |
316 int len; | |
317 len=demux_read_data(dec_audio_sh->ds,buf,size); | |
318 return len; | |
319 } | |
320 | |
296 | 321 int init_audio(sh_audio_t *sh_audio){ |
303 | 322 int driver=sh_audio->codec->driver; |
296 | 323 |
324 sh_audio->samplesize=2; | |
4423
ed500b952d2d
possible AC3 fix, by Marcus Blomenkamp <Marcus.Blomenkamp@epost.de>
arpi
parents:
4208
diff
changeset
|
325 #ifdef WORDS_BIGENDIAN |
1320
18374d49befa
On big-endian architectures, all audio decoders default to big-endian 16-bit
jkeil
parents:
1313
diff
changeset
|
326 sh_audio->sample_format=AFMT_S16_BE; |
18374d49befa
On big-endian architectures, all audio decoders default to big-endian 16-bit
jkeil
parents:
1313
diff
changeset
|
327 #else |
758 | 328 sh_audio->sample_format=AFMT_S16_LE; |
1320
18374d49befa
On big-endian architectures, all audio decoders default to big-endian 16-bit
jkeil
parents:
1313
diff
changeset
|
329 #endif |
303 | 330 sh_audio->samplerate=0; |
401 | 331 //sh_audio->pcm_bswap=0; |
1529 | 332 sh_audio->o_bps=0; |
303 | 333 |
758 | 334 sh_audio->a_buffer_size=0; |
303 | 335 sh_audio->a_buffer=NULL; |
296 | 336 |
746 | 337 sh_audio->a_in_buffer_len=0; |
338 | |
758 | 339 // setup required min. in/out buffer size: |
340 sh_audio->audio_out_minsize=8192;// default size, maybe not enough for Win32/ACM | |
341 | |
342 switch(driver){ | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
343 case AFM_ACM: |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1485
diff
changeset
|
344 #ifndef USE_WIN32DLL |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
345 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_NoACMSupport); |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
346 driver=0; |
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
347 #else |
296 | 348 // Win32 ACM audio codec: |
349 if(init_acm_audio_codec(sh_audio)){ | |
746 | 350 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; |
296 | 351 sh_audio->channels=sh_audio->o_wf.nChannels; |
352 sh_audio->samplerate=sh_audio->o_wf.nSamplesPerSec; | |
758 | 353 // if(sh_audio->audio_out_minsize>16384) sh_audio->audio_out_minsize=16384; |
354 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize; | |
355 // if(sh_audio->a_buffer_size<sh_audio->audio_out_minsize+MAX_OUTBURST) | |
356 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; | |
296 | 357 } else { |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
358 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_ACMiniterror); |
303 | 359 driver=0; |
296 | 360 } |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
361 #endif |
758 | 362 break; |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
363 case AFM_DSHOW: |
296 | 364 #ifndef USE_DIRECTSHOW |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
365 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_NoDShowAudio); |
303 | 366 driver=0; |
296 | 367 #else |
368 // Win32 DShow audio codec: | |
340 | 369 // printf("DShow_audio: channs=%d rate=%d\n",sh_audio->channels,sh_audio->samplerate); |
3442 | 370 if(!(ds_adec=DS_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf))){ |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
371 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_audio->codec->dll); |
303 | 372 driver=0; |
373 } else { | |
746 | 374 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
|
375 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
|
376 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
|
377 sh_audio->audio_in_minsize=2*sh_audio->wf->nBlockAlign; |
296 | 378 if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192; |
379 sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize; | |
380 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); | |
381 sh_audio->a_in_buffer_len=0; | |
758 | 382 sh_audio->audio_out_minsize=16384; |
296 | 383 } |
384 #endif | |
758 | 385 break; |
1828 | 386 case AFM_VORBIS: |
387 #ifndef HAVE_OGGVORBIS | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
388 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_NoOggVorbis); |
1828 | 389 driver=0; |
390 #else | |
391 /* OggVorbis audio via libvorbis, compatible with files created by nandub and zorannt codec */ | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
392 sh_audio->audio_out_minsize=1024*4; // 1024 samples/frame |
1828 | 393 #endif |
394 break; | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
395 case AFM_PCM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
396 case AFM_DVDPCM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
397 case AFM_ALAW: |
758 | 398 // PCM, aLaw |
399 sh_audio->audio_out_minsize=2048; | |
400 break; | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
401 case AFM_AC3: |
3413 | 402 case AFM_A52: |
758 | 403 // Dolby AC3 audio: |
3181
c8edb0691f09
Extended oss output driver and libac3 to support 4 and 6 channel output mixes. added -channels command line option
steve
parents:
3145
diff
changeset
|
404 // however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame |
c8edb0691f09
Extended oss output driver and libac3 to support 4 and 6 channel output mixes. added -channels command line option
steve
parents:
3145
diff
changeset
|
405 sh_audio->audio_out_minsize=audio_output_channels*2*256*6; |
758 | 406 break; |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
407 case AFM_HWAC3: |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
408 // Dolby AC3 audio: |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
409 sh_audio->audio_out_minsize=4*256*6; |
4423
ed500b952d2d
possible AC3 fix, by Marcus Blomenkamp <Marcus.Blomenkamp@epost.de>
arpi
parents:
4208
diff
changeset
|
410 // sh_audio->sample_format = AFMT_AC3; |
ed500b952d2d
possible AC3 fix, by Marcus Blomenkamp <Marcus.Blomenkamp@epost.de>
arpi
parents:
4208
diff
changeset
|
411 // sh_audio->sample_format = AFMT_S16_LE; |
ed500b952d2d
possible AC3 fix, by Marcus Blomenkamp <Marcus.Blomenkamp@epost.de>
arpi
parents:
4208
diff
changeset
|
412 sh_audio->channels=2; |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
413 break; |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
414 case AFM_GSM: |
758 | 415 // MS-GSM audio codec: |
416 sh_audio->audio_out_minsize=4*320; | |
417 break; | |
3787 | 418 case AFM_IMAADPCM: |
3756 | 419 sh_audio->audio_out_minsize=4096; |
420 sh_audio->ds->ss_div=IMA_ADPCM_SAMPLES_PER_BLOCK; | |
5049
e080a8d5019f
fixed long-standing issue with stereo IMA4 decoder
melanson
parents:
4854
diff
changeset
|
421 sh_audio->ds->ss_mul=IMA_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels; |
2420 | 422 break; |
3787 | 423 case AFM_MSADPCM: |
3875
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
424 sh_audio->audio_out_minsize=sh_audio->wf->nBlockAlign * 8; |
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
425 sh_audio->ds->ss_div = MS_ADPCM_SAMPLES_PER_BLOCK; |
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
426 sh_audio->ds->ss_mul = sh_audio->wf->nBlockAlign; |
3787 | 427 break; |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
428 case AFM_DK4ADPCM: |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
429 sh_audio->audio_out_minsize=DK4_ADPCM_SAMPLES_PER_BLOCK * 4; |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
430 sh_audio->ds->ss_div=DK4_ADPCM_SAMPLES_PER_BLOCK; |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
431 sh_audio->ds->ss_mul=sh_audio->wf->nBlockAlign; |
3933
60db4273246d
added initial support for format 0x61 ADPCM (sounds good, but still pops)
melanson
parents:
3911
diff
changeset
|
432 break; |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
433 case AFM_DK3ADPCM: |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
434 sh_audio->audio_out_minsize=DK3_ADPCM_SAMPLES_PER_BLOCK * 4; |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
435 sh_audio->ds->ss_div=DK3_ADPCM_SAMPLES_PER_BLOCK; |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
436 sh_audio->ds->ss_mul=DK3_ADPCM_BLOCK_SIZE; |
3826
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
437 break; |
4486 | 438 case AFM_ROQAUDIO: |
439 // minsize was stored in wf->nBlockAlign by the RoQ demuxer | |
440 sh_audio->audio_out_minsize=sh_audio->wf->nBlockAlign; | |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
441 sh_audio->ds->ss_div=DK3_ADPCM_SAMPLES_PER_BLOCK; |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
442 sh_audio->ds->ss_mul=DK3_ADPCM_BLOCK_SIZE; |
4486 | 443 sh_audio->context = roq_decode_audio_init(); |
444 break; | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
445 case AFM_MPEG: |
758 | 446 // MPEG Audio: |
447 sh_audio->audio_out_minsize=4608; | |
448 break; | |
3866 | 449 #ifdef USE_G72X |
3426 | 450 case AFM_G72X: |
451 // g72x_reader_init(&g72x_data,G723_16_BITS_PER_SAMPLE); | |
452 g72x_reader_init(&g72x_data,G723_24_BITS_PER_SAMPLE); | |
453 // g72x_reader_init(&g72x_data,G721_32_BITS_PER_SAMPLE); | |
454 // g72x_reader_init(&g72x_data,G721_40_BITS_PER_SAMPLE); | |
455 sh_audio->audio_out_minsize=g72x_data.samplesperblock*4; | |
456 break; | |
3866 | 457 #endif |
1927 | 458 case AFM_FFMPEG: |
459 #ifndef USE_LIBAVCODEC | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
460 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_NoLAVCsupport); |
1927 | 461 return 0; |
462 #else | |
463 // FFmpeg Audio: | |
464 sh_audio->audio_out_minsize=AVCODEC_MAX_AUDIO_FRAME_SIZE; | |
465 break; | |
466 #endif | |
2415 | 467 |
468 #ifdef USE_LIBMAD | |
469 case AFM_MAD: | |
470 printf(__FILE__ ":%d:mad: setting minimum outputsize\n", __LINE__); | |
471 sh_audio->audio_out_minsize=4608; | |
4208
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
472 if(sh_audio->audio_in_minsize<MAD_SINGLE_BUFFER_SIZE) sh_audio->audio_in_minsize=MAD_SINGLE_BUFFER_SIZE; |
2415 | 473 sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize; |
4208
c92c23a42e91
libmad memcpy optimization by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
arpi
parents:
4151
diff
changeset
|
474 mad_in_buffer = sh_audio->a_in_buffer = malloc(MAD_TOTAL_BUFFER_SIZE); |
2415 | 475 sh_audio->a_in_buffer_len=0; |
476 break; | |
477 #endif | |
296 | 478 } |
479 | |
303 | 480 if(!driver) return 0; |
296 | 481 |
482 // allocate audio out buffer: | |
758 | 483 sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; // worst case calc. |
484 | |
1567 | 485 mp_msg(MSGT_DECAUDIO,MSGL_V,"dec_audio: Allocating %d + %d = %d bytes for output buffer\n", |
758 | 486 sh_audio->audio_out_minsize,MAX_OUTBURST,sh_audio->a_buffer_size); |
487 | |
296 | 488 sh_audio->a_buffer=malloc(sh_audio->a_buffer_size); |
758 | 489 if(!sh_audio->a_buffer){ |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
490 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_CantAllocAudioBuf); |
758 | 491 return 0; |
492 } | |
296 | 493 memset(sh_audio->a_buffer,0,sh_audio->a_buffer_size); |
494 sh_audio->a_buffer_len=0; | |
495 | |
303 | 496 switch(driver){ |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1485
diff
changeset
|
497 #ifdef USE_WIN32DLL |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
498 case AFM_ACM: { |
758 | 499 int ret=acm_decode_audio(sh_audio,sh_audio->a_buffer,4096,sh_audio->a_buffer_size); |
296 | 500 if(ret<0){ |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
501 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"ACM decoding error: %d\n",ret); |
303 | 502 driver=0; |
296 | 503 } |
640 | 504 sh_audio->a_buffer_len=ret; |
303 | 505 break; |
296 | 506 } |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
507 #endif |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
508 case AFM_PCM: { |
296 | 509 // 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
|
510 WAVEFORMATEX *h=sh_audio->wf; |
746 | 511 sh_audio->i_bps=h->nAvgBytesPerSec; |
296 | 512 sh_audio->channels=h->nChannels; |
513 sh_audio->samplerate=h->nSamplesPerSec; | |
514 sh_audio->samplesize=(h->wBitsPerSample+7)/8; | |
758 | 515 switch(sh_audio->format){ // hardware formats: |
516 case 0x6: sh_audio->sample_format=AFMT_A_LAW;break; | |
517 case 0x7: sh_audio->sample_format=AFMT_MU_LAW;break; | |
518 case 0x11: sh_audio->sample_format=AFMT_IMA_ADPCM;break; | |
519 case 0x50: sh_audio->sample_format=AFMT_MPEG;break; | |
2547 | 520 case 0x736F7774: sh_audio->sample_format=AFMT_S16_LE;sh_audio->codec->driver=AFM_DVDPCM;break; |
758 | 521 // case 0x2000: sh_audio->sample_format=AFMT_AC3; |
522 default: sh_audio->sample_format=(sh_audio->samplesize==2)?AFMT_S16_LE:AFMT_U8; | |
523 } | |
401 | 524 break; |
525 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
526 case AFM_DVDPCM: { |
401 | 527 // DVD PCM Audio: |
528 sh_audio->channels=2; | |
529 sh_audio->samplerate=48000; | |
746 | 530 sh_audio->i_bps=2*2*48000; |
296 | 531 // sh_audio->pcm_bswap=1; |
303 | 532 break; |
533 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
534 case AFM_AC3: { |
3886 | 535 #ifndef USE_LIBAC3 |
536 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"WARNING: libac3 support is disabled. (hint: upgrade codecs.conf)\n"); | |
537 driver=0; | |
538 #else | |
296 | 539 // Dolby AC3 audio: |
1289 | 540 dec_audio_sh=sh_audio; // save sh_audio for the callback: |
296 | 541 ac3_config.fill_buffer_callback = ac3_fill_buffer; |
3181
c8edb0691f09
Extended oss output driver and libac3 to support 4 and 6 channel output mixes. added -channels command line option
steve
parents:
3145
diff
changeset
|
542 ac3_config.num_output_ch = audio_output_channels; |
296 | 543 ac3_config.flags = 0; |
3145 | 544 if(gCpuCaps.hasMMX){ |
296 | 545 ac3_config.flags |= AC3_MMX_ENABLE; |
3145 | 546 } |
547 if(gCpuCaps.has3DNow){ | |
296 | 548 ac3_config.flags |= AC3_3DNOW_ENABLE; |
3145 | 549 } |
296 | 550 ac3_init(); |
551 sh_audio->ac3_frame = ac3_decode_frame(); | |
552 if(sh_audio->ac3_frame){ | |
746 | 553 ac3_frame_t* fr=(ac3_frame_t*)sh_audio->ac3_frame; |
554 sh_audio->samplerate=fr->sampling_rate; | |
3181
c8edb0691f09
Extended oss output driver and libac3 to support 4 and 6 channel output mixes. added -channels command line option
steve
parents:
3145
diff
changeset
|
555 sh_audio->channels=ac3_config.num_output_ch; |
746 | 556 // 1 frame: 6*256 samples 1 sec: sh_audio->samplerate samples |
557 //sh_audio->i_bps=fr->frame_size*fr->sampling_rate/(6*256); | |
558 sh_audio->i_bps=fr->bit_rate*(1000/8); | |
303 | 559 } else { |
560 driver=0; // bad frame -> disable audio | |
561 } | |
3886 | 562 #endif |
303 | 563 break; |
564 } | |
3413 | 565 case AFM_A52: { |
3911 | 566 sample_t level=1, bias=384; |
567 int flags=0; | |
3413 | 568 // Dolby AC3 audio: |
3907 | 569 if(gCpuCaps.hasSSE) a52_accel|=MM_ACCEL_X86_SSE; |
570 if(gCpuCaps.hasMMX) a52_accel|=MM_ACCEL_X86_MMX; | |
571 if(gCpuCaps.hasMMX2) a52_accel|=MM_ACCEL_X86_MMXEXT; | |
572 if(gCpuCaps.has3DNow) a52_accel|=MM_ACCEL_X86_3DNOW; | |
4497 | 573 if(gCpuCaps.has3DNowExt) a52_accel|=MM_ACCEL_X86_3DNOWEXT; |
3907 | 574 a52_samples=a52_init (a52_accel); |
3413 | 575 if (a52_samples == NULL) { |
576 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n"); | |
577 driver=0;break; | |
578 } | |
579 sh_audio->a_in_buffer_size=3840; | |
580 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); | |
581 sh_audio->a_in_buffer_len=0; | |
582 if(a52_fillbuff(sh_audio)<0){ | |
583 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n"); | |
584 driver=0;break; | |
585 } | |
3887 | 586 // 'a52 cannot upmix' hotfix: |
3968 | 587 a52_printinfo(sh_audio); |
588 // if(audio_output_channels<sh_audio->channels) | |
589 // sh_audio->channels=audio_output_channels; | |
3911 | 590 // channels setup: |
3968 | 591 sh_audio->channels=audio_output_channels; |
592 while(sh_audio->channels>0){ | |
3911 | 593 switch(sh_audio->channels){ |
594 case 1: a52_flags=A52_MONO; break; | |
595 // case 2: a52_flags=A52_STEREO; break; | |
596 case 2: a52_flags=A52_DOLBY; break; | |
597 // case 3: a52_flags=A52_3F; break; | |
598 case 3: a52_flags=A52_2F1R; break; | |
599 case 4: a52_flags=A52_2F2R; break; // 2+2 | |
600 case 5: a52_flags=A52_3F2R; break; | |
601 case 6: a52_flags=A52_3F2R|A52_LFE; break; // 5.1 | |
602 } | |
603 // test: | |
604 flags=a52_flags|A52_ADJUST_LEVEL; | |
605 mp_msg(MSGT_DECAUDIO,MSGL_V,"A52 flags before a52_frame: 0x%X\n",flags); | |
606 if (a52_frame (&a52_state, sh_audio->a_in_buffer, &flags, &level, bias)){ | |
607 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"a52: error decoding frame -> nosound\n"); | |
608 driver=0;break; | |
609 } | |
610 mp_msg(MSGT_DECAUDIO,MSGL_V,"A52 flags after a52_frame: 0x%X\n",flags); | |
611 // frame decoded, let's init resampler: | |
3968 | 612 if(a52_resample_init(a52_accel,flags,sh_audio->channels)) break; |
613 --sh_audio->channels; // try to decrease no. of channels | |
614 } | |
615 if(sh_audio->channels<=0){ | |
3911 | 616 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"a52: no resampler. try different channel setup!\n"); |
617 driver=0;break; | |
618 } | |
3413 | 619 break; |
620 } | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
621 case AFM_HWAC3: { |
3829 | 622 // Dolby AC3 passthrough: |
3907 | 623 a52_samples=a52_init (a52_accel); |
3829 | 624 if (a52_samples == NULL) { |
625 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n"); | |
626 driver=0;break; | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
627 } |
3829 | 628 sh_audio->a_in_buffer_size=3840; |
629 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); | |
630 sh_audio->a_in_buffer_len=0; | |
631 if(a52_fillbuff(sh_audio)<0) { | |
632 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n"); | |
633 driver=0;break; | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
634 } |
3829 | 635 |
636 //sh_audio->samplerate=ai.samplerate; // SET by a52_fillbuff() | |
637 //sh_audio->samplesize=ai.framesize; | |
638 //sh_audio->i_bps=ai.bitrate*(1000/8); // SET by a52_fillbuff() | |
639 //sh_audio->ac3_frame=malloc(6144); | |
640 //sh_audio->o_bps=sh_audio->i_bps; // XXX FIXME!!! XXX | |
641 | |
642 // o_bps is calculated from samplesize*channels*samplerate | |
643 // a single ac3 frame is always translated to 6144 byte packet. (zero padding) | |
4423
ed500b952d2d
possible AC3 fix, by Marcus Blomenkamp <Marcus.Blomenkamp@epost.de>
arpi
parents:
4208
diff
changeset
|
644 sh_audio->channels=2; |
ed500b952d2d
possible AC3 fix, by Marcus Blomenkamp <Marcus.Blomenkamp@epost.de>
arpi
parents:
4208
diff
changeset
|
645 sh_audio->samplesize=2; // 2*2*(6*256) = 6144 (very TRICKY!) |
3829 | 646 |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
647 break; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
648 } |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
649 case AFM_ALAW: { |
296 | 650 // 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
|
651 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
|
652 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
746 | 653 sh_audio->i_bps=sh_audio->channels*sh_audio->samplerate; |
303 | 654 break; |
655 } | |
3866 | 656 #ifdef USE_G72X |
3426 | 657 case AFM_G72X: { |
658 // GSM 723 audio codec: | |
659 sh_audio->channels=sh_audio->wf->nChannels; | |
660 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
661 sh_audio->i_bps=(sh_audio->samplerate/g72x_data.samplesperblock)*g72x_data.blocksize; | |
662 break; | |
663 } | |
3866 | 664 #endif |
1927 | 665 #ifdef USE_LIBAVCODEC |
666 case AFM_FFMPEG: { | |
667 int x; | |
668 mp_msg(MSGT_DECAUDIO,MSGL_V,"FFmpeg's libavcodec audio codec\n"); | |
669 if(!avcodec_inited){ | |
670 avcodec_init(); | |
671 avcodec_register_all(); | |
672 avcodec_inited=1; | |
673 } | |
674 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_audio->codec->dll); | |
675 if(!lavc_codec){ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
676 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh_audio->codec->dll); |
1927 | 677 return 0; |
678 } | |
679 memset(&lavc_context, 0, sizeof(lavc_context)); | |
680 /* open it */ | |
681 if (avcodec_open(&lavc_context, lavc_codec) < 0) { | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
682 mp_msg(MSGT_DECAUDIO,MSGL_ERR, MSGTR_CantOpenCodec); |
1927 | 683 return 0; |
684 } | |
685 mp_msg(MSGT_DECAUDIO,MSGL_V,"INFO: libavcodec init OK!\n"); | |
686 | |
687 // Decode at least 1 byte: (to get header filled) | |
688 x=decode_audio(sh_audio,sh_audio->a_buffer,1,sh_audio->a_buffer_size); | |
689 if(x>0) sh_audio->a_buffer_len=x; | |
690 | |
691 #if 1 | |
692 sh_audio->channels=lavc_context.channels; | |
693 sh_audio->samplerate=lavc_context.sample_rate; | |
694 sh_audio->i_bps=lavc_context.bit_rate/8; | |
695 #else | |
696 sh_audio->channels=sh_audio->wf->nChannels; | |
697 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
698 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; | |
699 #endif | |
700 break; | |
701 } | |
702 #endif | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
703 case AFM_GSM: { |
296 | 704 // MS-GSM audio codec: |
705 GSM_Init(); | |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
706 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
|
707 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
746 | 708 // decodes 65 byte -> 320 short |
709 // 1 sec: sh_audio->channels*sh_audio->samplerate samples | |
710 // 1 frame: 320 samples | |
711 sh_audio->i_bps=65*(sh_audio->channels*sh_audio->samplerate)/320; // 1:10 | |
303 | 712 break; |
296 | 713 } |
3787 | 714 case AFM_IMAADPCM: |
2420 | 715 // IMA-ADPCM 4:1 audio codec: |
716 sh_audio->channels=sh_audio->wf->nChannels; | |
717 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
718 // decodes 34 byte -> 64 short | |
3756 | 719 sh_audio->i_bps=IMA_ADPCM_BLOCK_SIZE*(sh_audio->channels*sh_audio->samplerate)/IMA_ADPCM_SAMPLES_PER_BLOCK; // 1:4 |
2420 | 720 break; |
3787 | 721 case AFM_MSADPCM: |
722 sh_audio->channels=sh_audio->wf->nChannels; | |
723 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
3875
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
724 sh_audio->i_bps = sh_audio->wf->nBlockAlign * |
3826
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
725 (sh_audio->channels*sh_audio->samplerate) / MS_ADPCM_SAMPLES_PER_BLOCK; |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
726 break; |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
727 case AFM_DK4ADPCM: |
3933
60db4273246d
added initial support for format 0x61 ADPCM (sounds good, but still pops)
melanson
parents:
3911
diff
changeset
|
728 sh_audio->channels=sh_audio->wf->nChannels; |
60db4273246d
added initial support for format 0x61 ADPCM (sounds good, but still pops)
melanson
parents:
3911
diff
changeset
|
729 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
730 sh_audio->i_bps = sh_audio->wf->nBlockAlign * |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
731 (sh_audio->channels*sh_audio->samplerate) / DK4_ADPCM_SAMPLES_PER_BLOCK; |
3933
60db4273246d
added initial support for format 0x61 ADPCM (sounds good, but still pops)
melanson
parents:
3911
diff
changeset
|
732 break; |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
733 case AFM_DK3ADPCM: |
3826
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
734 sh_audio->channels=sh_audio->wf->nChannels; |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
735 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
736 sh_audio->i_bps=DK3_ADPCM_BLOCK_SIZE* |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
737 (sh_audio->channels*sh_audio->samplerate) / DK3_ADPCM_SAMPLES_PER_BLOCK; |
3787 | 738 break; |
4486 | 739 case AFM_ROQAUDIO: |
740 sh_audio->channels=sh_audio->wf->nChannels; | |
741 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
742 sh_audio->i_bps = (sh_audio->channels * 22050) / 2; | |
743 break; | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
744 case AFM_MPEG: { |
296 | 745 // MPEG Audio: |
1289 | 746 dec_audio_sh=sh_audio; // save sh_audio for the callback: |
732
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
747 #ifdef USE_FAKE_MONO |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
748 MP3_Init(fakemono); |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
749 #else |
296 | 750 MP3_Init(); |
732
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
751 #endif |
296 | 752 MP3_samplerate=MP3_channels=0; |
753 sh_audio->a_buffer_len=MP3_DecodeFrame(sh_audio->a_buffer,-1); | |
754 sh_audio->channels=2; // hack | |
755 sh_audio->samplerate=MP3_samplerate; | |
746 | 756 sh_audio->i_bps=MP3_bitrate*(1000/8); |
4151 | 757 MP3_PrintHeader(); |
303 | 758 break; |
759 } | |
1828 | 760 #ifdef HAVE_OGGVORBIS |
761 case AFM_VORBIS: { | |
762 // OggVorbis Audio: | |
763 #if 0 /* just here for reference - atmos */ | |
764 ogg_sync_state oy; /* sync and verify incoming physical bitstream */ | |
765 ogg_stream_state os; /* take physical pages, weld into a logical | |
766 stream of packets */ | |
767 ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ | |
768 ogg_packet op; /* one raw packet of data for decode */ | |
769 | |
770 vorbis_info vi; /* struct that stores all the static vorbis bitstream | |
771 settings */ | |
772 vorbis_comment vc; /* struct that stores all the bitstream user comments */ | |
773 vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ | |
774 vorbis_block vb; /* local working space for packet->PCM decode */ | |
775 #else | |
776 /* nix, nada, rien, nothing, nem, nüx */ | |
777 #endif | |
778 | |
779 uint32_t hdrsizes[3];/* stores vorbis header sizes from AVI audio header, | |
780 maybe use ogg_uint32_t */ | |
781 //int i; | |
782 int ret; | |
783 char *buffer; | |
784 ogg_packet hdr; | |
785 //ov_struct_t *s=&sh_audio->ov; | |
786 sh_audio->ov=malloc(sizeof(ov_struct_t)); | |
787 //s=&sh_audio->ov; | |
788 | |
789 vorbis_info_init(&sh_audio->ov->vi); | |
790 vorbis_comment_init(&sh_audio->ov->vc); | |
791 | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
792 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"OggVorbis: cbsize: %i\n", sh_audio->wf->cbSize); |
1828 | 793 memcpy(hdrsizes, ((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX), 3*sizeof(uint32_t)); |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
794 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"OggVorbis: Read header sizes: initial: %i comment: %i codebook: %i\n", hdrsizes[0], hdrsizes[1], hdrsizes[2]); |
1828 | 795 /*for(i=12; i <= 40; i+=2) { // header bruteforce :) |
796 memcpy(hdrsizes, ((unsigned char*)sh_audio->wf)+i, 3*sizeof(uint32_t)); | |
797 printf("OggVorbis: Read header sizes (%i): %ld %ld %ld\n", i, hdrsizes[0], hdrsizes[1], hdrsizes[2]); | |
798 }*/ | |
799 | |
800 /* read headers */ // FIXME disable sound on errors here, we absolutely need this headers! - atmos | |
801 hdr.packet=NULL; | |
802 hdr.b_o_s = 1; /* beginning of stream for first packet */ | |
803 hdr.bytes = hdrsizes[0]; | |
804 hdr.packet = realloc(hdr.packet,hdr.bytes); | |
805 memcpy(hdr.packet,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t),hdr.bytes); | |
806 if(vorbis_synthesis_headerin(&sh_audio->ov->vi,&sh_audio->ov->vc,&hdr)<0) | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
807 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: initial (identification) header broken!\n"); |
1828 | 808 hdr.b_o_s = 0; |
809 hdr.bytes = hdrsizes[1]; | |
810 hdr.packet = realloc(hdr.packet,hdr.bytes); | |
811 memcpy(hdr.packet,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t)+hdrsizes[0],hdr.bytes); | |
812 if(vorbis_synthesis_headerin(&sh_audio->ov->vi,&sh_audio->ov->vc,&hdr)<0) | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
813 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: comment header broken!\n"); |
1828 | 814 hdr.bytes = hdrsizes[2]; |
815 hdr.packet = realloc(hdr.packet,hdr.bytes); | |
816 memcpy(hdr.packet,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t)+hdrsizes[0]+hdrsizes[1],hdr.bytes); | |
817 if(vorbis_synthesis_headerin(&sh_audio->ov->vi,&sh_audio->ov->vc,&hdr)<0) | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
818 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: codebook header broken!\n"); |
1828 | 819 hdr.bytes=0; |
820 hdr.packet = realloc(hdr.packet,hdr.bytes); /* free */ | |
821 /* done with the headers */ | |
822 | |
823 | |
824 /* Throw the comments plus a few lines about the bitstream we're | |
825 decoding */ | |
826 { | |
827 char **ptr=sh_audio->ov->vc.user_comments; | |
828 while(*ptr){ | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
829 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbisComment: %s\n",*ptr); |
1828 | 830 ++ptr; |
831 } | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
832 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Bitstream is %d channel, %ldHz, %ldkbit/s %cBR\n",sh_audio->ov->vi.channels,sh_audio->ov->vi.rate,sh_audio->ov->vi.bitrate_nominal/1000, (sh_audio->ov->vi.bitrate_lower!=sh_audio->ov->vi.bitrate_nominal)||(sh_audio->ov->vi.bitrate_upper!=sh_audio->ov->vi.bitrate_nominal)?'V':'C'); |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
833 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Encoded by: %s\n",sh_audio->ov->vc.vendor); |
1828 | 834 } |
835 sh_audio->channels=sh_audio->ov->vi.channels; | |
836 sh_audio->samplerate=sh_audio->ov->vi.rate; | |
837 sh_audio->i_bps=sh_audio->ov->vi.bitrate_nominal/8; | |
838 | |
839 // printf("[\n"); | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
840 // sh_audio->a_buffer_len=sh_audio->audio_out_minsize;///ov->vi.channels; |
1828 | 841 // printf("]\n"); |
842 | |
843 /* OK, got and parsed all three headers. Initialize the Vorbis | |
844 packet->PCM decoder. */ | |
845 vorbis_synthesis_init(&sh_audio->ov->vd,&sh_audio->ov->vi); /* central decode state */ | |
846 vorbis_block_init(&sh_audio->ov->vd,&sh_audio->ov->vb); /* local state for most of the decode | |
847 so multiple block decodes can | |
848 proceed in parallel. We could init | |
849 multiple vorbis_block structures | |
850 for vd here */ | |
851 //printf("OggVorbis: synthesis and block init done.\n"); | |
852 ogg_sync_init(&sh_audio->ov->oy); /* Now we can read pages */ | |
853 | |
854 while((ret = ogg_sync_pageout(&sh_audio->ov->oy,&sh_audio->ov->og))!=1) { | |
855 if(ret == -1) | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
856 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: Pageout: not properly synced, had to skip some bytes.\n"); |
1828 | 857 else |
858 if(ret == 0) { | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
859 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Pageout: need more data to verify page, reading more data.\n"); |
1828 | 860 /* submit a a_buffer_len block to libvorbis' Ogg layer */ |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
861 buffer=ogg_sync_buffer(&sh_audio->ov->oy,256); |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
862 ogg_sync_wrote(&sh_audio->ov->oy,demux_read_data(sh_audio->ds,buffer,256)); |
1828 | 863 } |
864 } | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
865 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Pageout: successfull.\n"); |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
866 ogg_stream_pagein(&sh_audio->ov->os,&sh_audio->ov->og); /* we can ignore any errors here |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
867 as they'll also become apparent |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
868 at packetout */ |
1828 | 869 |
870 /* Get the serial number and set up the rest of decode. */ | |
871 /* serialno first; use it to set up a logical stream */ | |
872 ogg_stream_init(&sh_audio->ov->os,ogg_page_serialno(&sh_audio->ov->og)); | |
873 | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
874 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Init OK!\n"); |
1828 | 875 |
876 break; | |
877 } | |
878 #endif | |
2415 | 879 |
880 #ifdef USE_LIBMAD | |
881 case AFM_MAD: | |
882 { | |
3871 | 883 printf("%s %s %s (%s)\n", mad_version, mad_copyright, mad_author, mad_build); |
884 | |
2415 | 885 printf(__FILE__ ":%d:mad: initialising\n", __LINE__); |
886 mad_frame_init(&mad_frame); | |
887 mad_stream_init(&mad_stream); | |
888 | |
889 printf(__FILE__ ":%d:mad: preparing buffer\n", __LINE__); | |
890 mad_prepare_buffer(sh_audio, &mad_stream, sh_audio->a_in_buffer_size); | |
891 mad_stream_buffer(&mad_stream, (unsigned char*)(sh_audio->a_in_buffer), sh_audio->a_in_buffer_len); | |
3871 | 892 // mad_stream_sync(&mad_stream); |
893 mad_sync(sh_audio, &mad_stream); | |
2415 | 894 mad_synth_init(&mad_synth); |
895 | |
896 if(mad_frame_decode(&mad_frame, &mad_stream) == 0) | |
897 { | |
898 printf(__FILE__ ":%d:mad: post processing buffer\n", __LINE__); | |
899 mad_postprocess_buffer(sh_audio, &mad_stream); | |
900 } | |
901 else | |
902 { | |
903 printf(__FILE__ ":%d:mad: frame decoding failed\n", __LINE__); | |
3874 | 904 mad_print_error(&mad_stream); |
2415 | 905 } |
906 | |
2434
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
907 switch (mad_frame.header.mode) |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
908 { |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
909 case MAD_MODE_SINGLE_CHANNEL: |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
910 sh_audio->channels=1; |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
911 break; |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
912 case MAD_MODE_DUAL_CHANNEL: |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
913 case MAD_MODE_JOINT_STEREO: |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
914 case MAD_MODE_STEREO: |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
915 sh_audio->channels=2; |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
916 break; |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
917 default: |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
918 mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "mad: unknown number of channels\n"); |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
919 } |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
920 mp_msg(MSGT_DECAUDIO, MSGL_HINT, "mad: channels: %d (mad channel mode: %d)\n", |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
921 sh_audio->channels, mad_frame.header.mode); |
2432 | 922 /* var. name changed in 0.13.0 (beta) (libmad/CHANGES) -- alex */ |
923 #if (MAD_VERSION_MAJOR >= 0) && (MAD_VERSION_MINOR >= 13) | |
924 sh_audio->samplerate=mad_frame.header.samplerate; | |
925 #else | |
2415 | 926 sh_audio->samplerate=mad_frame.header.sfreq; |
2432 | 927 #endif |
2415 | 928 sh_audio->i_bps=mad_frame.header.bitrate; |
929 printf(__FILE__ ":%d:mad: continuing\n", __LINE__); | |
930 break; | |
931 } | |
932 #endif | |
296 | 933 } |
934 | |
935 if(!sh_audio->channels || !sh_audio->samplerate){ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
936 mp_msg(MSGT_DECAUDIO,MSGL_WARN,MSGTR_UnknownAudio); |
303 | 937 driver=0; |
296 | 938 } |
939 | |
303 | 940 if(!driver){ |
941 if(sh_audio->a_buffer) free(sh_audio->a_buffer); | |
1313
d797ecb9778f
sh_audio->a_buffer is freed twice (here and in mplayer.c), can result to
jkeil
parents:
1309
diff
changeset
|
942 sh_audio->a_buffer=NULL; |
303 | 943 return 0; |
944 } | |
296 | 945 |
1529 | 946 if(!sh_audio->o_bps) |
303 | 947 sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize; |
948 return driver; | |
296 | 949 } |
291 | 950 |
746 | 951 // Audio decoding: |
291 | 952 |
746 | 953 // Decode a single frame (mp3,acm etc) or 'minlen' bytes (pcm/alaw etc) |
954 // buffer length is 'maxlen' bytes, it shouldn't be exceeded... | |
955 | |
956 int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){ | |
291 | 957 int len=-1; |
303 | 958 switch(sh_audio->codec->driver){ |
1927 | 959 #ifdef USE_LIBAVCODEC |
960 case AFM_FFMPEG: { | |
961 unsigned char *start=NULL; | |
962 int y; | |
963 while(len<minlen){ | |
964 int len2=0; | |
965 int x=ds_get_packet(sh_audio->ds,&start); | |
966 if(x<=0) break; // error | |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
1973
diff
changeset
|
967 y=avcodec_decode_audio(&lavc_context,(INT16*)buf,&len2,start,x); |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
968 if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; } |
1927 | 969 if(y<x) sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!) |
970 if(len2>0){ | |
971 //len=len2;break; | |
972 if(len<0) len=len2; else len+=len2; | |
973 buf+=len2; | |
974 } | |
975 mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"Decoded %d -> %d \n",y,len2); | |
976 } | |
977 } | |
978 break; | |
979 #endif | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
980 case AFM_MPEG: // MPEG layer 2 or 3 |
291 | 981 len=MP3_DecodeFrame(buf,-1); |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1456
diff
changeset
|
982 // len=MP3_DecodeFrame(buf,3); |
291 | 983 break; |
1830 | 984 #ifdef HAVE_OGGVORBIS |
1828 | 985 case AFM_VORBIS: { // OggVorbis |
986 /* note: good minlen would be 4k or 8k IMHO - atmos */ | |
987 int ret; | |
988 char *buffer; | |
989 int bytes; | |
990 int samples; | |
991 float **pcm; | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
992 //ogg_int16_t convbuffer[4096]; |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
993 // int convsize; |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
994 int readlen=1024; |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
995 len=0; |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
996 // convsize=minlen/sh_audio->ov->vi.channels; |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
997 |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
998 while(len < minlen) { /* double loop allows for break in inner loop */ |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
999 while(len < minlen) { /* without aborting the outer loop - atmos */ |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1000 ret=ogg_stream_packetout(&sh_audio->ov->os,&sh_audio->ov->op); |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1001 if(ret==0) { |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1002 int xxx=0; |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1003 //printf("OggVorbis: Packetout: need more data, paging!\n"); |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1004 while((ret = ogg_sync_pageout(&sh_audio->ov->oy,&sh_audio->ov->og))!=1) { |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1005 if(ret == -1) |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1006 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Pageout: not properly synced, had to skip some bytes.\n"); |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1007 else |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1008 if(ret == 0) { |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1009 //printf("OggVorbis: Pageout: need more data to verify page, reading more data.\n"); |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1010 /* submit a readlen k block to libvorbis' Ogg layer */ |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1011 buffer=ogg_sync_buffer(&sh_audio->ov->oy,readlen); |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1012 bytes=demux_read_data(sh_audio->ds,buffer,readlen); |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1013 xxx+=bytes; |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1014 ogg_sync_wrote(&sh_audio->ov->oy,bytes); |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1015 if(bytes==0) |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1016 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: 0Bytes written, possible End of Stream\n"); |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1017 } |
1828 | 1018 } |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1019 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"\n[sync: %d ]\n",xxx); |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1020 //printf("OggVorbis: Pageout: successfull, pagin in.\n"); |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1021 if(ogg_stream_pagein(&sh_audio->ov->os,&sh_audio->ov->og)<0) |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1022 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Pagein failed!\n"); |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1023 break; |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1024 } else if(ret<0) { |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1025 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Packetout: missing or corrupt data, skipping packet!\n"); |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1026 break; |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1027 } else { |
1828 | 1028 |
1029 /* we have a packet. Decode it */ | |
1030 | |
1031 if(vorbis_synthesis(&sh_audio->ov->vb,&sh_audio->ov->op)==0) /* test for success! */ | |
1032 vorbis_synthesis_blockin(&sh_audio->ov->vd,&sh_audio->ov->vb); | |
1033 | |
1034 /* **pcm is a multichannel float vector. In stereo, for | |
1035 example, pcm[0] is left, and pcm[1] is right. samples is | |
1036 the size of each channel. Convert the float values | |
1037 (-1.<=range<=1.) to whatever PCM format and write it out */ | |
1038 | |
1039 while((samples=vorbis_synthesis_pcmout(&sh_audio->ov->vd,&pcm))>0){ | |
1040 int i,j; | |
1041 int clipflag=0; | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1042 int convsize=(maxlen-len)/(2*sh_audio->ov->vi.channels); // max size! |
1828 | 1043 int bout=(samples<convsize?samples:convsize); |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1044 |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1045 if(bout<=0) break; |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1046 |
1828 | 1047 /* convert floats to 16 bit signed ints (host order) and |
1048 interleave */ | |
1049 for(i=0;i<sh_audio->ov->vi.channels;i++){ | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1050 ogg_int16_t *convbuffer=(ogg_int16_t *)(&buf[len]); |
1828 | 1051 ogg_int16_t *ptr=convbuffer+i; |
1052 float *mono=pcm[i]; | |
1053 for(j=0;j<bout;j++){ | |
1054 #if 1 | |
1055 int val=mono[j]*32767.f; | |
1056 #else /* optional dither */ | |
1057 int val=mono[j]*32767.f+drand48()-0.5f; | |
1058 #endif | |
1059 /* might as well guard against clipping */ | |
1060 if(val>32767){ | |
1061 val=32767; | |
1062 clipflag=1; | |
1063 } | |
1064 if(val<-32768){ | |
1065 val=-32768; | |
1066 clipflag=1; | |
1067 } | |
1068 *ptr=val; | |
1069 ptr+=sh_audio->ov->vi.channels; | |
1070 } | |
1071 } | |
1072 | |
1073 if(clipflag) | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1074 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"Clipping in frame %ld\n",(long)(sh_audio->ov->vd.sequence)); |
1828 | 1075 |
1076 //fwrite(convbuffer,2*sh_audio->ov->vi.channels,bout,stderr); //dump pcm to file for debugging | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1077 //memcpy(buf+len,convbuffer,2*sh_audio->ov->vi.channels*bout); |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1078 len+=2*sh_audio->ov->vi.channels*bout; |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1079 |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1080 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"\n[decoded: %d / %d ]\n",bout,samples); |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1081 |
1828 | 1082 vorbis_synthesis_read(&sh_audio->ov->vd,bout); /* tell libvorbis how |
1083 many samples we | |
1084 actually consumed */ | |
1085 } | |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1086 } // from else, packetout ok |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1087 } // while len |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
1088 } // outer while len |
1828 | 1089 if(ogg_page_eos(&sh_audio->ov->og)) |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1090 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: End of Stream reached!\n"); // FIXME clearup decoder, notify mplayer - atmos |
1828 | 1091 |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
1092 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"\n[len: %d ]\n",len); |
1828 | 1093 |
1094 break; | |
1831 | 1095 } |
1830 | 1096 #endif |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1097 case AFM_PCM: // AVI PCM |
1058 | 1098 len=demux_read_data(sh_audio->ds,buf,minlen); |
401 | 1099 break; |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1100 case AFM_DVDPCM: // DVD PCM |
401 | 1101 { int j; |
746 | 1102 len=demux_read_data(sh_audio->ds,buf,minlen); |
291 | 1103 //if(i&1){ printf("Warning! pcm_audio_size&1 !=0 (%d)\n",i);i&=~1; } |
746 | 1104 // swap endian: |
291 | 1105 for(j=0;j<len;j+=2){ |
1106 char x=buf[j]; | |
1107 buf[j]=buf[j+1]; | |
1108 buf[j+1]=x; | |
1109 } | |
1110 break; | |
1111 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1112 case AFM_ALAW: // aLaw decoder |
746 | 1113 { int l=demux_read_data(sh_audio->ds,buf,minlen/2); |
291 | 1114 unsigned short *d=(unsigned short *) buf; |
1115 unsigned char *s=buf; | |
1116 len=2*l; | |
758 | 1117 if(sh_audio->format==6){ |
1118 // aLaw | |
883 | 1119 while(l>0){ --l; d[l]=alaw2short[s[l]]; } |
758 | 1120 } else { |
1121 // uLaw | |
883 | 1122 while(l>0){ --l; d[l]=ulaw2short[s[l]]; } |
291 | 1123 } |
1124 break; | |
1125 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1126 case AFM_GSM: // MS-GSM decoder |
2420 | 1127 { unsigned char ibuf[65]; // 65 bytes / frame |
1128 if(demux_read_data(sh_audio->ds,ibuf,65)!=65) break; // EOF | |
1129 XA_MSGSM_Decoder(ibuf,(unsigned short *) buf); // decodes 65 byte -> 320 short | |
746 | 1130 // XA_GSM_Decoder(buf,(unsigned short *) &sh_audio->a_buffer[sh_audio->a_buffer_len]); // decodes 33 byte -> 160 short |
1131 len=2*320; | |
291 | 1132 break; |
1133 } | |
3866 | 1134 #ifdef USE_G72X |
3426 | 1135 case AFM_G72X: // GSM 723 decoder |
1136 { if(demux_read_data(sh_audio->ds,g72x_data.block, g72x_data.blocksize)!=g72x_data.blocksize) break; // EOF | |
1137 g72x_decode_block(&g72x_data); | |
1138 len=2*g72x_data.samplesperblock; | |
1139 memcpy(buf,g72x_data.samples,len); | |
1140 break; | |
1141 } | |
3866 | 1142 #endif |
3787 | 1143 case AFM_IMAADPCM: |
3756 | 1144 { unsigned char ibuf[IMA_ADPCM_BLOCK_SIZE * 2]; // bytes / stereo frame |
1145 if (demux_read_data(sh_audio->ds, ibuf, | |
3787 | 1146 IMA_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) != |
3756 | 1147 IMA_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) |
1148 break; // EOF | |
1149 len=2*ima_adpcm_decode_block((unsigned short*)buf,ibuf, sh_audio->wf->nChannels); | |
3787 | 1150 break; |
1151 } | |
1152 case AFM_MSADPCM: | |
3875
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
1153 { static unsigned char *ibuf = NULL; |
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
1154 if (!ibuf) |
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
1155 ibuf = (unsigned char *)malloc |
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
1156 (sh_audio->wf->nBlockAlign * sh_audio->wf->nChannels); |
3787 | 1157 if (demux_read_data(sh_audio->ds, ibuf, |
3875
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
1158 sh_audio->wf->nBlockAlign) != |
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
1159 sh_audio->wf->nBlockAlign) |
3787 | 1160 break; // EOF |
3875
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
1161 len= 2 * ms_adpcm_decode_block( |
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
1162 (unsigned short*)buf,ibuf, sh_audio->wf->nChannels, |
e3caff2daa98
fixed stereo MS ADPCM decoder and reinstated opensource decoder as the
melanson
parents:
3874
diff
changeset
|
1163 sh_audio->wf->nBlockAlign); |
2420 | 1164 break; |
1165 } | |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1166 case AFM_DK4ADPCM: |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1167 { static unsigned char *ibuf = NULL; |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1168 if (!ibuf) |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1169 ibuf = (unsigned char *)malloc(sh_audio->wf->nBlockAlign); |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1170 if (demux_read_data(sh_audio->ds, ibuf, sh_audio->wf->nBlockAlign) != |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1171 sh_audio->wf->nBlockAlign) |
3933
60db4273246d
added initial support for format 0x61 ADPCM (sounds good, but still pops)
melanson
parents:
3911
diff
changeset
|
1172 break; // EOF |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1173 len=2*dk4_adpcm_decode_block((unsigned short*)buf,ibuf, |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1174 sh_audio->wf->nChannels, sh_audio->wf->nBlockAlign); |
3933
60db4273246d
added initial support for format 0x61 ADPCM (sounds good, but still pops)
melanson
parents:
3911
diff
changeset
|
1175 break; |
60db4273246d
added initial support for format 0x61 ADPCM (sounds good, but still pops)
melanson
parents:
3911
diff
changeset
|
1176 } |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1177 case AFM_DK3ADPCM: |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1178 { unsigned char ibuf[DK3_ADPCM_BLOCK_SIZE * 2]; // bytes / stereo frame |
3826
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
1179 if (demux_read_data(sh_audio->ds, ibuf, |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1180 DK3_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) != |
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1181 DK3_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) |
3826
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
1182 break; // EOF |
4854
4a6dde59834c
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
melanson
parents:
4497
diff
changeset
|
1183 len = 2 * dk3_adpcm_decode_block( |
4001 | 1184 (unsigned short*)buf,ibuf); |
3826
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
1185 break; |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
1186 } |
4486 | 1187 case AFM_ROQAUDIO: |
1188 { | |
1189 static unsigned char *ibuf = NULL; | |
1190 unsigned char header_data[6]; | |
1191 int read_len; | |
1192 | |
1193 if (!ibuf) | |
1194 ibuf = (unsigned char *)malloc(sh_audio->audio_out_minsize / 2); | |
1195 | |
1196 // figure out how much data to read | |
1197 if (demux_read_data(sh_audio->ds, header_data, 6) != 6) | |
1198 break; // EOF | |
1199 read_len = (header_data[5] << 24) | (header_data[4] << 16) | | |
1200 (header_data[3] << 8) | header_data[2]; | |
1201 read_len += 2; // 16-bit arguments | |
1202 if (demux_read_data(sh_audio->ds, ibuf, read_len) != read_len) | |
1203 break; | |
1204 len = 2 * roq_decode_audio((unsigned short *)buf, ibuf, | |
1205 read_len, sh_audio->channels, sh_audio->context); | |
1206 break; | |
1207 } | |
3886 | 1208 #ifdef USE_LIBAC3 |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1209 case AFM_AC3: // AC3 decoder |
291 | 1210 //printf("{1:%d}",avi_header.idx_pos);fflush(stdout); |
1211 if(!sh_audio->ac3_frame) sh_audio->ac3_frame=ac3_decode_frame(); | |
1212 //printf("{2:%d}",avi_header.idx_pos);fflush(stdout); | |
1213 if(sh_audio->ac3_frame){ | |
296 | 1214 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
|
1215 memcpy(buf,((ac3_frame_t*)sh_audio->ac3_frame)->audio_data,len); |
291 | 1216 sh_audio->ac3_frame=NULL; |
1217 } | |
1218 //printf("{3:%d}",avi_header.idx_pos);fflush(stdout); | |
1219 break; | |
3886 | 1220 #endif |
3413 | 1221 case AFM_A52: { // AC3 decoder |
3911 | 1222 sample_t level=1, bias=384; |
1223 int flags=a52_flags|A52_ADJUST_LEVEL; | |
3413 | 1224 int i; |
1225 if(!sh_audio->a_in_buffer_len) | |
1226 if(a52_fillbuff(sh_audio)<0) break; // EOF | |
1227 sh_audio->a_in_buffer_len=0; | |
1228 if (a52_frame (&a52_state, sh_audio->a_in_buffer, &flags, &level, bias)){ | |
1229 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"a52: error decoding frame\n"); | |
1230 break; | |
1231 } | |
1232 // a52_dynrng (&state, NULL, NULL); // disable dynamic range compensation | |
1233 | |
1234 // frame decoded, let's resample: | |
3911 | 1235 //a52_resample_init(a52_accel,flags,sh_audio->channels); |
3413 | 1236 len=0; |
1237 for (i = 0; i < 6; i++) { | |
1238 if (a52_block (&a52_state, a52_samples)){ | |
1239 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"a52: error at resampling\n"); | |
1240 break; | |
1241 } | |
1242 len+=2*a52_resample(a52_samples,&buf[len]); | |
1243 } | |
3417 | 1244 // printf("len = %d \n",len); // 6144 on all vobs I tried so far... (5.1 and 2.0) ::atmos |
3413 | 1245 break; |
1246 } | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
1247 case AFM_HWAC3: // AC3 through SPDIF |
3829 | 1248 if(!sh_audio->a_in_buffer_len) |
1249 if((len=a52_fillbuff(sh_audio))<0) break; //EOF | |
1250 sh_audio->a_in_buffer_len=0; | |
1251 len = ac3_iec958_build_burst(len, 0x01, 1, sh_audio->a_in_buffer, buf); | |
1252 // len = 6144 = 4*(6*256) | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
1253 break; |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1485
diff
changeset
|
1254 #ifdef USE_WIN32DLL |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1255 case AFM_ACM: |
758 | 1256 // len=sh_audio->audio_out_minsize; // optimal decoded fragment size |
1257 // if(len<minlen) len=minlen; else | |
1258 // if(len>maxlen) len=maxlen; | |
1259 // len=acm_decode_audio(sh_audio,buf,len); | |
1260 len=acm_decode_audio(sh_audio,buf,minlen,maxlen); | |
291 | 1261 break; |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
1262 #endif |
746 | 1263 |
291 | 1264 #ifdef USE_DIRECTSHOW |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1265 case AFM_DSHOW: // DirectShow |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1266 { int size_in=0; |
291 | 1267 int size_out=0; |
3442 | 1268 int srcsize=DS_AudioDecoder_GetSrcSize(ds_adec, maxlen); |
1567 | 1269 mp_msg(MSGT_DECAUDIO,MSGL_DBG3,"DShow says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen); |
291 | 1270 if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!! |
1271 if(sh_audio->a_in_buffer_len<srcsize){ | |
1272 sh_audio->a_in_buffer_len+= | |
1273 demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len], | |
1274 srcsize-sh_audio->a_in_buffer_len); | |
1275 } | |
3442 | 1276 DS_AudioDecoder_Convert(ds_adec, sh_audio->a_in_buffer,sh_audio->a_in_buffer_len, |
291 | 1277 buf,maxlen, &size_in,&size_out); |
1567 | 1278 mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"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 | 1279 if(size_in>=sh_audio->a_in_buffer_len){ |
1280 sh_audio->a_in_buffer_len=0; | |
1281 } else { | |
1282 sh_audio->a_in_buffer_len-=size_in; | |
1283 memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len); | |
1284 } | |
1285 len=size_out; | |
1286 break; | |
1287 } | |
1288 #endif | |
2415 | 1289 |
1290 #ifdef USE_LIBMAD | |
1291 case AFM_MAD: | |
1292 { | |
1293 mad_prepare_buffer(sh_audio, &mad_stream, sh_audio->a_in_buffer_size); | |
1294 mad_stream_buffer(&mad_stream, sh_audio->a_in_buffer, sh_audio->a_in_buffer_len); | |
3871 | 1295 // mad_stream_sync(&mad_stream); |
1296 mad_sync(sh_audio, &mad_stream); | |
2415 | 1297 if(mad_frame_decode(&mad_frame, &mad_stream) == 0) |
1298 { | |
1299 mad_synth_frame(&mad_synth, &mad_frame); | |
1300 mad_postprocess_buffer(sh_audio, &mad_stream); | |
1301 | |
1302 /* and fill buffer */ | |
1303 | |
1304 { | |
1305 int i; | |
1306 int end_size = mad_synth.pcm.length; | |
1307 signed short* samples = (signed short*)buf; | |
1308 if(end_size > maxlen/4) | |
1309 end_size=maxlen/4; | |
1310 | |
1311 for(i=0; i<mad_synth.pcm.length; ++i) { | |
1312 *samples++ = mad_scale(mad_synth.pcm.samples[0][i]); | |
1313 *samples++ = mad_scale(mad_synth.pcm.samples[0][i]); | |
1314 // *buf++ = mad_scale(mad_synth.pcm.sampAles[1][i]); | |
1315 } | |
1316 len = end_size*4; | |
1317 } | |
1318 } | |
1319 else | |
1320 { | |
3871 | 1321 printf(__FILE__ ":%d:mad: frame decoding failed (error: %d)\n", __LINE__, |
1322 mad_stream.error); | |
3874 | 1323 mad_print_error(&mad_stream); |
2415 | 1324 } |
1325 | |
1326 break; | |
1327 } | |
1328 #endif | |
291 | 1329 } |
1330 return len; | |
1331 } | |
1332 | |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1333 void resync_audio_stream(sh_audio_t *sh_audio){ |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1334 switch(sh_audio->codec->driver){ |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1335 case AFM_MPEG: |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1336 MP3_DecodeFrame(NULL,-2); // resync |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1337 MP3_DecodeFrame(NULL,-2); // resync |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1338 MP3_DecodeFrame(NULL,-2); // resync |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1339 break; |
1849
5f246fcc2971
Resetting stream and sync for seek, no correct test files yet for proper testing but should be ok.
atmos4
parents:
1837
diff
changeset
|
1340 #ifdef HAVE_OGGVORBIS |
5f246fcc2971
Resetting stream and sync for seek, no correct test files yet for proper testing but should be ok.
atmos4
parents:
1837
diff
changeset
|
1341 case AFM_VORBIS: |
5f246fcc2971
Resetting stream and sync for seek, no correct test files yet for proper testing but should be ok.
atmos4
parents:
1837
diff
changeset
|
1342 //printf("OggVorbis: resetting stream.\n"); |
5f246fcc2971
Resetting stream and sync for seek, no correct test files yet for proper testing but should be ok.
atmos4
parents:
1837
diff
changeset
|
1343 ogg_sync_reset(&sh_audio->ov->oy); |
5f246fcc2971
Resetting stream and sync for seek, no correct test files yet for proper testing but should be ok.
atmos4
parents:
1837
diff
changeset
|
1344 ogg_stream_reset(&sh_audio->ov->os); |
5f246fcc2971
Resetting stream and sync for seek, no correct test files yet for proper testing but should be ok.
atmos4
parents:
1837
diff
changeset
|
1345 break; |
5f246fcc2971
Resetting stream and sync for seek, no correct test files yet for proper testing but should be ok.
atmos4
parents:
1837
diff
changeset
|
1346 #endif |
3886 | 1347 #ifdef USE_LIBAC3 |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1348 case AFM_AC3: |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1349 ac3_bitstream_reset(); // reset AC3 bitstream buffer |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1350 // if(verbose){ printf("Resyncing AC3 audio...");fflush(stdout);} |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1351 sh_audio->ac3_frame=ac3_decode_frame(); // resync |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1352 // if(verbose) printf(" OK!\n"); |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1353 break; |
3886 | 1354 #endif |
3413 | 1355 case AFM_A52: |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1356 case AFM_ACM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1357 case AFM_DSHOW: |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
1358 case AFM_HWAC3: |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1359 sh_audio->a_in_buffer_len=0; // reset ACM/DShow audio buffer |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1360 break; |
2415 | 1361 |
1362 #ifdef USE_LIBMAD | |
1363 case AFM_MAD: | |
1364 mad_prepare_buffer(sh_audio, &mad_stream, sh_audio->a_in_buffer_size); | |
1365 mad_stream_buffer(&mad_stream, sh_audio->a_in_buffer, sh_audio->a_in_buffer_len); | |
3871 | 1366 // mad_stream_sync(&mad_stream); |
1367 mad_sync(sh_audio, &mad_stream); | |
2415 | 1368 mad_postprocess_buffer(sh_audio, &mad_stream); |
1369 break; | |
2418 | 1370 #endif |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1371 } |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1372 } |
291 | 1373 |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1374 void skip_audio_frame(sh_audio_t *sh_audio){ |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1375 switch(sh_audio->codec->driver){ |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1376 case AFM_MPEG: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame |
3886 | 1377 #ifdef USE_LIBAC3 |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1378 case AFM_AC3: sh_audio->ac3_frame=ac3_decode_frame();break; // skip AC3 frame |
3886 | 1379 #endif |
3829 | 1380 case AFM_HWAC3: |
3413 | 1381 case AFM_A52: a52_fillbuff(sh_audio);break; // skip AC3 frame |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1382 case AFM_ACM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1383 case AFM_DSHOW: { |
1408 | 1384 int skip=sh_audio->wf->nBlockAlign; |
1385 if(skip<16){ | |
1386 skip=(sh_audio->wf->nAvgBytesPerSec/16)&(~7); | |
1387 if(skip<16) skip=16; | |
1388 } | |
1389 demux_read_data(sh_audio->ds,NULL,skip); | |
1390 break; | |
1391 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1392 case AFM_PCM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1393 case AFM_DVDPCM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1394 case AFM_ALAW: { |
1408 | 1395 int skip=sh_audio->i_bps/16; |
1396 skip=skip&(~3); | |
1397 demux_read_data(sh_audio->ds,NULL,skip); | |
1398 break; | |
1399 } | |
2415 | 1400 #ifdef USE_LIBMAD |
1401 case AFM_MAD: | |
1402 { | |
1403 mad_prepare_buffer(sh_audio, &mad_stream, sh_audio->a_in_buffer_size); | |
1404 mad_stream_buffer(&mad_stream, sh_audio->a_in_buffer, sh_audio->a_in_buffer_len); | |
1405 mad_stream_skip(&mad_stream, 2); | |
3871 | 1406 // mad_stream_sync(&mad_stream); |
1407 mad_sync(sh_audio, &mad_stream); | |
2415 | 1408 mad_postprocess_buffer(sh_audio, &mad_stream); |
1409 break; | |
1410 } | |
1411 #endif | |
1412 | |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1413 default: ds_fill_buffer(sh_audio->ds); // skip PCM frame |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1414 } |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1415 } |