Mercurial > mplayer.hg
annotate dec_audio.c @ 3837:6659db99f200
warning fix
author | pl |
---|---|
date | Fri, 28 Dec 2001 18:03:03 +0000 |
parents | bc85116eaf5e |
children | 50d7eec1d4b9 |
rev | line source |
---|---|
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
1 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
2 #include <stdio.h> |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
3 #include <stdlib.h> |
1430 | 4 #include <unistd.h> |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
5 |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
6 #include "config.h" |
1567 | 7 #include "mp_msg.h" |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
8 #include "help_mp.h" |
1567 | 9 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
10 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
|
11 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
12 #include "stream.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
13 #include "demuxer.h" |
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 "codec-cfg.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
16 #include "stheader.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
17 |
2563 | 18 #include "dec_audio.h" |
19 | |
20 //========================================================================== | |
21 | |
22 #include "libao2/afmt.h" | |
23 | |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
1973
diff
changeset
|
24 #include "dll_init.h" |
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
1973
diff
changeset
|
25 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
26 #include "mp3lib/mp3.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
27 #include "libac3/ac3.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
28 |
3413 | 29 #include "liba52/a52.h" |
30 static sample_t * a52_samples; | |
31 static a52_state_t a52_state; | |
32 | |
3426 | 33 #include "g72x/g72x.h" |
34 static G72x_DATA g72x_data; | |
3413 | 35 |
883 | 36 #include "alaw.h" |
37 | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
38 #include "xa/xa_gsm.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
39 |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
40 #include "ac3-iec958.h" |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
41 |
3756 | 42 #include "adpcm.h" |
2420 | 43 |
3145 | 44 #include "cpudetect.h" |
45 | |
3182
95bbd21e8e1f
moved num_audio_channels out of LIBMAD ifdef, where it didn't belong!
steve
parents:
3181
diff
changeset
|
46 /* 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
|
47 int audio_output_channels = 2; |
95bbd21e8e1f
moved num_audio_channels out of LIBMAD ifdef, where it didn't belong!
steve
parents:
3181
diff
changeset
|
48 |
2563 | 49 #ifdef USE_FAKE_MONO |
50 int fakemono=0; | |
51 #endif | |
52 | |
1291 | 53 #ifdef USE_DIRECTSHOW |
604 | 54 #include "loader/DirectShow/DS_AudioDec.h" |
3442 | 55 static void* ds_adec=NULL; |
1291 | 56 #endif |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
57 |
1828 | 58 #ifdef HAVE_OGGVORBIS |
59 /* XXX is math.h really needed? - atmos */ | |
60 #include <math.h> | |
61 #include <vorbis/codec.h> | |
2341 | 62 |
63 typedef struct ov_struct_st { | |
64 ogg_sync_state oy; /* sync and verify incoming physical bitstream */ | |
65 ogg_stream_state os; /* take physical pages, weld into a logical | |
66 stream of packets */ | |
67 ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ | |
68 ogg_packet op; /* one raw packet of data for decode */ | |
3145 | 69 |
2341 | 70 vorbis_info vi; /* struct that stores all the static vorbis bitstream |
71 settings */ | |
72 vorbis_comment vc; /* struct that stores all the bitstream user comments */ | |
73 vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ | |
74 vorbis_block vb; /* local working space for packet->PCM decode */ | |
75 } ov_struct_t; | |
1828 | 76 #endif |
77 | |
1927 | 78 #ifdef USE_LIBAVCODEC |
2496 | 79 #ifdef USE_LIBAVCODEC_SO |
80 #include <libffmpeg/avcodec.h> | |
81 #else | |
1927 | 82 #include "libavcodec/avcodec.h" |
2496 | 83 #endif |
1927 | 84 static AVCodec *lavc_codec=NULL; |
85 static AVCodecContext lavc_context; | |
86 extern int avcodec_inited; | |
87 #endif | |
88 | |
2415 | 89 |
90 | |
91 #ifdef USE_LIBMAD | |
92 #include <mad.h> | |
93 static struct mad_stream mad_stream; | |
94 static struct mad_frame mad_frame; | |
95 static struct mad_synth mad_synth; | |
96 | |
97 // ensure buffer is filled with some data | |
98 static void mad_prepare_buffer(sh_audio_t* sh_audio, struct mad_stream* ms, int length) | |
99 { | |
100 if(sh_audio->a_in_buffer_len < length) { | |
101 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); | |
102 sh_audio->a_in_buffer_len += len; | |
103 } | |
104 } | |
105 | |
106 static void mad_postprocess_buffer(sh_audio_t* sh_audio, struct mad_stream* ms) | |
107 { | |
108 int delta = (unsigned char*)ms->next_frame - (unsigned char *)sh_audio->a_in_buffer; | |
109 if(delta != 0) { | |
110 sh_audio->a_in_buffer_len -= delta; | |
111 memcpy(sh_audio->a_in_buffer, ms->next_frame, sh_audio->a_in_buffer_len); | |
112 } | |
113 } | |
114 | |
115 | |
116 static inline | |
117 signed short mad_scale(mad_fixed_t sample) | |
118 { | |
119 /* round */ | |
120 sample += (1L << (MAD_F_FRACBITS - 16)); | |
121 | |
122 /* clip */ | |
123 if (sample >= MAD_F_ONE) | |
124 sample = MAD_F_ONE - 1; | |
125 else if (sample < -MAD_F_ONE) | |
126 sample = -MAD_F_ONE; | |
127 | |
128 /* quantize */ | |
129 return sample >> (MAD_F_FRACBITS + 1 - 16); | |
130 } | |
131 #endif | |
132 | |
133 | |
3413 | 134 static int a52_fillbuff(sh_audio_t *sh_audio){ |
135 int length=0; | |
136 int flags=0; | |
137 int sample_rate=0; | |
138 int bit_rate=0; | |
3834 | 139 |
140 sh_audio->a_in_buffer_len=0; | |
141 // sync frame: | |
3413 | 142 while(1){ |
143 while(sh_audio->a_in_buffer_len<7){ | |
144 int c=demux_getc(sh_audio->ds); | |
145 if(c<0) return -1; // EOF | |
146 sh_audio->a_in_buffer[sh_audio->a_in_buffer_len++]=c; | |
147 } | |
148 length = a52_syncinfo (sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate); | |
3834 | 149 if(length>=7 && length<=3840) break; // we're done. |
150 // bad file => resync | |
151 memcpy(sh_audio->a_in_buffer,sh_audio->a_in_buffer+1,6); | |
152 --sh_audio->a_in_buffer_len; | |
153 } | |
3413 | 154 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"a52: len=%d flags=0x%X %d Hz %d bit/s\n",length,flags,sample_rate,bit_rate); |
155 sh_audio->samplerate=sample_rate; | |
156 sh_audio->i_bps=bit_rate/8; | |
157 demux_read_data(sh_audio->ds,sh_audio->a_in_buffer+7,length-7); | |
158 return length; | |
159 } | |
2415 | 160 |
1927 | 161 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
|
162 |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
163 |
1289 | 164 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
|
165 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
166 // AC3 decoder buffer callback: |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
167 static void ac3_fill_buffer(uint8_t **start,uint8_t **end){ |
1289 | 168 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
|
169 //printf("<ac3:%d>\n",len); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
170 if(len<0) |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
171 *start = *end = NULL; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
172 else |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
173 *end = *start + len; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
174 } |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
175 |
1289 | 176 // MP3 decoder buffer callback: |
177 int mplayer_audio_read(char *buf,int size){ | |
178 int len; | |
179 len=demux_read_data(dec_audio_sh->ds,buf,size); | |
180 return len; | |
181 } | |
182 | |
296 | 183 int init_audio(sh_audio_t *sh_audio){ |
303 | 184 int driver=sh_audio->codec->driver; |
296 | 185 |
186 sh_audio->samplesize=2; | |
1320
18374d49befa
On big-endian architectures, all audio decoders default to big-endian 16-bit
jkeil
parents:
1313
diff
changeset
|
187 #if WORDS_BIGENDIAN |
18374d49befa
On big-endian architectures, all audio decoders default to big-endian 16-bit
jkeil
parents:
1313
diff
changeset
|
188 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
|
189 #else |
758 | 190 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
|
191 #endif |
303 | 192 sh_audio->samplerate=0; |
401 | 193 //sh_audio->pcm_bswap=0; |
1529 | 194 sh_audio->o_bps=0; |
303 | 195 |
758 | 196 sh_audio->a_buffer_size=0; |
303 | 197 sh_audio->a_buffer=NULL; |
296 | 198 |
746 | 199 sh_audio->a_in_buffer_len=0; |
200 | |
758 | 201 // setup required min. in/out buffer size: |
202 sh_audio->audio_out_minsize=8192;// default size, maybe not enough for Win32/ACM | |
203 | |
204 switch(driver){ | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
205 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
|
206 #ifndef USE_WIN32DLL |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
207 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
|
208 driver=0; |
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
209 #else |
296 | 210 // Win32 ACM audio codec: |
211 if(init_acm_audio_codec(sh_audio)){ | |
746 | 212 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; |
296 | 213 sh_audio->channels=sh_audio->o_wf.nChannels; |
214 sh_audio->samplerate=sh_audio->o_wf.nSamplesPerSec; | |
758 | 215 // if(sh_audio->audio_out_minsize>16384) sh_audio->audio_out_minsize=16384; |
216 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize; | |
217 // if(sh_audio->a_buffer_size<sh_audio->audio_out_minsize+MAX_OUTBURST) | |
218 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; | |
296 | 219 } else { |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
220 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_ACMiniterror); |
303 | 221 driver=0; |
296 | 222 } |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
223 #endif |
758 | 224 break; |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
225 case AFM_DSHOW: |
296 | 226 #ifndef USE_DIRECTSHOW |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
227 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_NoDShowAudio); |
303 | 228 driver=0; |
296 | 229 #else |
230 // Win32 DShow audio codec: | |
340 | 231 // printf("DShow_audio: channs=%d rate=%d\n",sh_audio->channels,sh_audio->samplerate); |
3442 | 232 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
|
233 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_audio->codec->dll); |
303 | 234 driver=0; |
235 } else { | |
746 | 236 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
|
237 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
|
238 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
|
239 sh_audio->audio_in_minsize=2*sh_audio->wf->nBlockAlign; |
296 | 240 if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192; |
241 sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize; | |
242 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); | |
243 sh_audio->a_in_buffer_len=0; | |
758 | 244 sh_audio->audio_out_minsize=16384; |
296 | 245 } |
246 #endif | |
758 | 247 break; |
1828 | 248 case AFM_VORBIS: |
249 #ifndef HAVE_OGGVORBIS | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
250 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_NoOggVorbis); |
1828 | 251 driver=0; |
252 #else | |
253 /* 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
|
254 sh_audio->audio_out_minsize=1024*4; // 1024 samples/frame |
1828 | 255 #endif |
256 break; | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
257 case AFM_PCM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
258 case AFM_DVDPCM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
259 case AFM_ALAW: |
758 | 260 // PCM, aLaw |
261 sh_audio->audio_out_minsize=2048; | |
262 break; | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
263 case AFM_AC3: |
3413 | 264 case AFM_A52: |
758 | 265 // 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
|
266 // 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
|
267 sh_audio->audio_out_minsize=audio_output_channels*2*256*6; |
758 | 268 break; |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
269 case AFM_HWAC3: |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
270 // Dolby AC3 audio: |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
271 sh_audio->audio_out_minsize=4*256*6; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
272 sh_audio->sample_format = AFMT_AC3; |
3829 | 273 sh_audio->channels=1; |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
274 break; |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
275 case AFM_GSM: |
758 | 276 // MS-GSM audio codec: |
277 sh_audio->audio_out_minsize=4*320; | |
278 break; | |
3787 | 279 case AFM_IMAADPCM: |
3756 | 280 sh_audio->audio_out_minsize=4096; |
281 sh_audio->ds->ss_div=IMA_ADPCM_SAMPLES_PER_BLOCK; | |
282 sh_audio->ds->ss_mul=IMA_ADPCM_BLOCK_SIZE; | |
2420 | 283 break; |
3787 | 284 case AFM_MSADPCM: |
285 sh_audio->audio_out_minsize=4096; | |
286 sh_audio->ds->ss_div=MS_ADPCM_SAMPLES_PER_BLOCK; | |
287 sh_audio->ds->ss_mul=MS_ADPCM_BLOCK_SIZE; | |
288 break; | |
3826
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
289 case AFM_FOX62ADPCM: |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
290 sh_audio->audio_out_minsize=FOX62_ADPCM_SAMPLES_PER_BLOCK * 4; |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
291 sh_audio->ds->ss_div=FOX62_ADPCM_SAMPLES_PER_BLOCK; |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
292 sh_audio->ds->ss_mul=FOX62_ADPCM_BLOCK_SIZE; |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
293 break; |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
294 case AFM_MPEG: |
758 | 295 // MPEG Audio: |
296 sh_audio->audio_out_minsize=4608; | |
297 break; | |
3426 | 298 case AFM_G72X: |
299 // g72x_reader_init(&g72x_data,G723_16_BITS_PER_SAMPLE); | |
300 g72x_reader_init(&g72x_data,G723_24_BITS_PER_SAMPLE); | |
301 // g72x_reader_init(&g72x_data,G721_32_BITS_PER_SAMPLE); | |
302 // g72x_reader_init(&g72x_data,G721_40_BITS_PER_SAMPLE); | |
303 sh_audio->audio_out_minsize=g72x_data.samplesperblock*4; | |
304 break; | |
1927 | 305 case AFM_FFMPEG: |
306 #ifndef USE_LIBAVCODEC | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
307 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_NoLAVCsupport); |
1927 | 308 return 0; |
309 #else | |
310 // FFmpeg Audio: | |
311 sh_audio->audio_out_minsize=AVCODEC_MAX_AUDIO_FRAME_SIZE; | |
312 break; | |
313 #endif | |
2415 | 314 |
315 #ifdef USE_LIBMAD | |
316 case AFM_MAD: | |
317 printf(__FILE__ ":%d:mad: setting minimum outputsize\n", __LINE__); | |
318 sh_audio->audio_out_minsize=4608; | |
319 if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192; | |
320 sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize; | |
321 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); | |
322 sh_audio->a_in_buffer_len=0; | |
323 break; | |
324 #endif | |
296 | 325 } |
326 | |
303 | 327 if(!driver) return 0; |
296 | 328 |
329 // allocate audio out buffer: | |
758 | 330 sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; // worst case calc. |
331 | |
1567 | 332 mp_msg(MSGT_DECAUDIO,MSGL_V,"dec_audio: Allocating %d + %d = %d bytes for output buffer\n", |
758 | 333 sh_audio->audio_out_minsize,MAX_OUTBURST,sh_audio->a_buffer_size); |
334 | |
296 | 335 sh_audio->a_buffer=malloc(sh_audio->a_buffer_size); |
758 | 336 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
|
337 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_CantAllocAudioBuf); |
758 | 338 return 0; |
339 } | |
296 | 340 memset(sh_audio->a_buffer,0,sh_audio->a_buffer_size); |
341 sh_audio->a_buffer_len=0; | |
342 | |
303 | 343 switch(driver){ |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1485
diff
changeset
|
344 #ifdef USE_WIN32DLL |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
345 case AFM_ACM: { |
758 | 346 int ret=acm_decode_audio(sh_audio,sh_audio->a_buffer,4096,sh_audio->a_buffer_size); |
296 | 347 if(ret<0){ |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
348 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"ACM decoding error: %d\n",ret); |
303 | 349 driver=0; |
296 | 350 } |
640 | 351 sh_audio->a_buffer_len=ret; |
303 | 352 break; |
296 | 353 } |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
354 #endif |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
355 case AFM_PCM: { |
296 | 356 // 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
|
357 WAVEFORMATEX *h=sh_audio->wf; |
746 | 358 sh_audio->i_bps=h->nAvgBytesPerSec; |
296 | 359 sh_audio->channels=h->nChannels; |
360 sh_audio->samplerate=h->nSamplesPerSec; | |
361 sh_audio->samplesize=(h->wBitsPerSample+7)/8; | |
758 | 362 switch(sh_audio->format){ // hardware formats: |
363 case 0x6: sh_audio->sample_format=AFMT_A_LAW;break; | |
364 case 0x7: sh_audio->sample_format=AFMT_MU_LAW;break; | |
365 case 0x11: sh_audio->sample_format=AFMT_IMA_ADPCM;break; | |
366 case 0x50: sh_audio->sample_format=AFMT_MPEG;break; | |
2547 | 367 case 0x736F7774: sh_audio->sample_format=AFMT_S16_LE;sh_audio->codec->driver=AFM_DVDPCM;break; |
758 | 368 // case 0x2000: sh_audio->sample_format=AFMT_AC3; |
369 default: sh_audio->sample_format=(sh_audio->samplesize==2)?AFMT_S16_LE:AFMT_U8; | |
370 } | |
401 | 371 break; |
372 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
373 case AFM_DVDPCM: { |
401 | 374 // DVD PCM Audio: |
375 sh_audio->channels=2; | |
376 sh_audio->samplerate=48000; | |
746 | 377 sh_audio->i_bps=2*2*48000; |
296 | 378 // sh_audio->pcm_bswap=1; |
303 | 379 break; |
380 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
381 case AFM_AC3: { |
296 | 382 // Dolby AC3 audio: |
1289 | 383 dec_audio_sh=sh_audio; // save sh_audio for the callback: |
296 | 384 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
|
385 ac3_config.num_output_ch = audio_output_channels; |
296 | 386 ac3_config.flags = 0; |
3145 | 387 if(gCpuCaps.hasMMX){ |
296 | 388 ac3_config.flags |= AC3_MMX_ENABLE; |
3145 | 389 } |
390 if(gCpuCaps.has3DNow){ | |
296 | 391 ac3_config.flags |= AC3_3DNOW_ENABLE; |
3145 | 392 } |
296 | 393 ac3_init(); |
394 sh_audio->ac3_frame = ac3_decode_frame(); | |
395 if(sh_audio->ac3_frame){ | |
746 | 396 ac3_frame_t* fr=(ac3_frame_t*)sh_audio->ac3_frame; |
397 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
|
398 sh_audio->channels=ac3_config.num_output_ch; |
746 | 399 // 1 frame: 6*256 samples 1 sec: sh_audio->samplerate samples |
400 //sh_audio->i_bps=fr->frame_size*fr->sampling_rate/(6*256); | |
401 sh_audio->i_bps=fr->bit_rate*(1000/8); | |
303 | 402 } else { |
403 driver=0; // bad frame -> disable audio | |
404 } | |
405 break; | |
406 } | |
3413 | 407 case AFM_A52: { |
408 // Dolby AC3 audio: | |
409 int accel=0; // should contain mmx/sse/etc flags | |
410 a52_samples=a52_init (accel); | |
411 if (a52_samples == NULL) { | |
412 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n"); | |
413 driver=0;break; | |
414 } | |
415 sh_audio->a_in_buffer_size=3840; | |
416 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); | |
417 sh_audio->a_in_buffer_len=0; | |
418 if(a52_fillbuff(sh_audio)<0){ | |
419 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n"); | |
420 driver=0;break; | |
421 } | |
422 sh_audio->channels=audio_output_channels; | |
423 break; | |
424 } | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
425 case AFM_HWAC3: { |
3829 | 426 // Dolby AC3 passthrough: |
427 int accel=0; // should contain mmx/sse/etc flags | |
428 a52_samples=a52_init (accel); | |
429 if (a52_samples == NULL) { | |
430 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n"); | |
431 driver=0;break; | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
432 } |
3829 | 433 sh_audio->a_in_buffer_size=3840; |
434 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); | |
435 sh_audio->a_in_buffer_len=0; | |
436 if(a52_fillbuff(sh_audio)<0) { | |
437 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n"); | |
438 driver=0;break; | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
439 } |
3829 | 440 |
441 //sh_audio->samplerate=ai.samplerate; // SET by a52_fillbuff() | |
442 //sh_audio->samplesize=ai.framesize; | |
443 //sh_audio->i_bps=ai.bitrate*(1000/8); // SET by a52_fillbuff() | |
444 //sh_audio->ac3_frame=malloc(6144); | |
445 //sh_audio->o_bps=sh_audio->i_bps; // XXX FIXME!!! XXX | |
446 | |
447 // o_bps is calculated from samplesize*channels*samplerate | |
448 // a single ac3 frame is always translated to 6144 byte packet. (zero padding) | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
449 sh_audio->channels=1; |
3829 | 450 sh_audio->samplesize=4; // 1*4*(6*256) = 6144 (very TRICKY!) |
451 | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
452 break; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
453 } |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
454 case AFM_ALAW: { |
296 | 455 // 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
|
456 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
|
457 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
746 | 458 sh_audio->i_bps=sh_audio->channels*sh_audio->samplerate; |
303 | 459 break; |
460 } | |
3426 | 461 case AFM_G72X: { |
462 // GSM 723 audio codec: | |
463 sh_audio->channels=sh_audio->wf->nChannels; | |
464 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
465 sh_audio->i_bps=(sh_audio->samplerate/g72x_data.samplesperblock)*g72x_data.blocksize; | |
466 break; | |
467 } | |
1927 | 468 #ifdef USE_LIBAVCODEC |
469 case AFM_FFMPEG: { | |
470 int x; | |
471 mp_msg(MSGT_DECAUDIO,MSGL_V,"FFmpeg's libavcodec audio codec\n"); | |
472 if(!avcodec_inited){ | |
473 avcodec_init(); | |
474 avcodec_register_all(); | |
475 avcodec_inited=1; | |
476 } | |
477 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_audio->codec->dll); | |
478 if(!lavc_codec){ | |
1973
5216f108cb4f
all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents:
1927
diff
changeset
|
479 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingLAVCcodec,sh_audio->codec->dll); |
1927 | 480 return 0; |
481 } | |
482 memset(&lavc_context, 0, sizeof(lavc_context)); | |
483 /* open it */ | |
484 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
|
485 mp_msg(MSGT_DECAUDIO,MSGL_ERR, MSGTR_CantOpenCodec); |
1927 | 486 return 0; |
487 } | |
488 mp_msg(MSGT_DECAUDIO,MSGL_V,"INFO: libavcodec init OK!\n"); | |
489 | |
490 // Decode at least 1 byte: (to get header filled) | |
491 x=decode_audio(sh_audio,sh_audio->a_buffer,1,sh_audio->a_buffer_size); | |
492 if(x>0) sh_audio->a_buffer_len=x; | |
493 | |
494 #if 1 | |
495 sh_audio->channels=lavc_context.channels; | |
496 sh_audio->samplerate=lavc_context.sample_rate; | |
497 sh_audio->i_bps=lavc_context.bit_rate/8; | |
498 #else | |
499 sh_audio->channels=sh_audio->wf->nChannels; | |
500 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
501 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; | |
502 #endif | |
503 break; | |
504 } | |
505 #endif | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
506 case AFM_GSM: { |
296 | 507 // MS-GSM audio codec: |
508 GSM_Init(); | |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
509 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
|
510 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
746 | 511 // decodes 65 byte -> 320 short |
512 // 1 sec: sh_audio->channels*sh_audio->samplerate samples | |
513 // 1 frame: 320 samples | |
514 sh_audio->i_bps=65*(sh_audio->channels*sh_audio->samplerate)/320; // 1:10 | |
303 | 515 break; |
296 | 516 } |
3787 | 517 case AFM_IMAADPCM: |
2420 | 518 // IMA-ADPCM 4:1 audio codec: |
519 sh_audio->channels=sh_audio->wf->nChannels; | |
520 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
521 // decodes 34 byte -> 64 short | |
3756 | 522 sh_audio->i_bps=IMA_ADPCM_BLOCK_SIZE*(sh_audio->channels*sh_audio->samplerate)/IMA_ADPCM_SAMPLES_PER_BLOCK; // 1:4 |
2420 | 523 break; |
3787 | 524 case AFM_MSADPCM: |
525 sh_audio->channels=sh_audio->wf->nChannels; | |
526 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
527 sh_audio->i_bps=MS_ADPCM_BLOCK_SIZE* | |
3826
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
528 (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
|
529 break; |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
530 case AFM_FOX62ADPCM: |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
531 sh_audio->channels=sh_audio->wf->nChannels; |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
532 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
533 sh_audio->i_bps=FOX62_ADPCM_BLOCK_SIZE* |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
534 (sh_audio->channels*sh_audio->samplerate) / FOX62_ADPCM_SAMPLES_PER_BLOCK; |
3787 | 535 break; |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
536 case AFM_MPEG: { |
296 | 537 // MPEG Audio: |
1289 | 538 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
|
539 #ifdef USE_FAKE_MONO |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
540 MP3_Init(fakemono); |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
541 #else |
296 | 542 MP3_Init(); |
732
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
543 #endif |
296 | 544 MP3_samplerate=MP3_channels=0; |
545 // printf("[\n"); | |
546 sh_audio->a_buffer_len=MP3_DecodeFrame(sh_audio->a_buffer,-1); | |
547 // printf("]\n"); | |
548 sh_audio->channels=2; // hack | |
549 sh_audio->samplerate=MP3_samplerate; | |
746 | 550 sh_audio->i_bps=MP3_bitrate*(1000/8); |
303 | 551 break; |
552 } | |
1828 | 553 #ifdef HAVE_OGGVORBIS |
554 case AFM_VORBIS: { | |
555 // OggVorbis Audio: | |
556 #if 0 /* just here for reference - atmos */ | |
557 ogg_sync_state oy; /* sync and verify incoming physical bitstream */ | |
558 ogg_stream_state os; /* take physical pages, weld into a logical | |
559 stream of packets */ | |
560 ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ | |
561 ogg_packet op; /* one raw packet of data for decode */ | |
562 | |
563 vorbis_info vi; /* struct that stores all the static vorbis bitstream | |
564 settings */ | |
565 vorbis_comment vc; /* struct that stores all the bitstream user comments */ | |
566 vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ | |
567 vorbis_block vb; /* local working space for packet->PCM decode */ | |
568 #else | |
569 /* nix, nada, rien, nothing, nem, nüx */ | |
570 #endif | |
571 | |
572 uint32_t hdrsizes[3];/* stores vorbis header sizes from AVI audio header, | |
573 maybe use ogg_uint32_t */ | |
574 //int i; | |
575 int ret; | |
576 char *buffer; | |
577 ogg_packet hdr; | |
578 //ov_struct_t *s=&sh_audio->ov; | |
579 sh_audio->ov=malloc(sizeof(ov_struct_t)); | |
580 //s=&sh_audio->ov; | |
581 | |
582 vorbis_info_init(&sh_audio->ov->vi); | |
583 vorbis_comment_init(&sh_audio->ov->vc); | |
584 | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
585 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"OggVorbis: cbsize: %i\n", sh_audio->wf->cbSize); |
1828 | 586 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
|
587 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"OggVorbis: Read header sizes: initial: %i comment: %i codebook: %i\n", hdrsizes[0], hdrsizes[1], hdrsizes[2]); |
1828 | 588 /*for(i=12; i <= 40; i+=2) { // header bruteforce :) |
589 memcpy(hdrsizes, ((unsigned char*)sh_audio->wf)+i, 3*sizeof(uint32_t)); | |
590 printf("OggVorbis: Read header sizes (%i): %ld %ld %ld\n", i, hdrsizes[0], hdrsizes[1], hdrsizes[2]); | |
591 }*/ | |
592 | |
593 /* read headers */ // FIXME disable sound on errors here, we absolutely need this headers! - atmos | |
594 hdr.packet=NULL; | |
595 hdr.b_o_s = 1; /* beginning of stream for first packet */ | |
596 hdr.bytes = hdrsizes[0]; | |
597 hdr.packet = realloc(hdr.packet,hdr.bytes); | |
598 memcpy(hdr.packet,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t),hdr.bytes); | |
599 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
|
600 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: initial (identification) header broken!\n"); |
1828 | 601 hdr.b_o_s = 0; |
602 hdr.bytes = hdrsizes[1]; | |
603 hdr.packet = realloc(hdr.packet,hdr.bytes); | |
604 memcpy(hdr.packet,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t)+hdrsizes[0],hdr.bytes); | |
605 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
|
606 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: comment header broken!\n"); |
1828 | 607 hdr.bytes = hdrsizes[2]; |
608 hdr.packet = realloc(hdr.packet,hdr.bytes); | |
609 memcpy(hdr.packet,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t)+hdrsizes[0]+hdrsizes[1],hdr.bytes); | |
610 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
|
611 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: codebook header broken!\n"); |
1828 | 612 hdr.bytes=0; |
613 hdr.packet = realloc(hdr.packet,hdr.bytes); /* free */ | |
614 /* done with the headers */ | |
615 | |
616 | |
617 /* Throw the comments plus a few lines about the bitstream we're | |
618 decoding */ | |
619 { | |
620 char **ptr=sh_audio->ov->vc.user_comments; | |
621 while(*ptr){ | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
622 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbisComment: %s\n",*ptr); |
1828 | 623 ++ptr; |
624 } | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
625 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
|
626 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Encoded by: %s\n",sh_audio->ov->vc.vendor); |
1828 | 627 } |
628 sh_audio->channels=sh_audio->ov->vi.channels; | |
629 sh_audio->samplerate=sh_audio->ov->vi.rate; | |
630 sh_audio->i_bps=sh_audio->ov->vi.bitrate_nominal/8; | |
631 | |
632 // printf("[\n"); | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
633 // sh_audio->a_buffer_len=sh_audio->audio_out_minsize;///ov->vi.channels; |
1828 | 634 // printf("]\n"); |
635 | |
636 /* OK, got and parsed all three headers. Initialize the Vorbis | |
637 packet->PCM decoder. */ | |
638 vorbis_synthesis_init(&sh_audio->ov->vd,&sh_audio->ov->vi); /* central decode state */ | |
639 vorbis_block_init(&sh_audio->ov->vd,&sh_audio->ov->vb); /* local state for most of the decode | |
640 so multiple block decodes can | |
641 proceed in parallel. We could init | |
642 multiple vorbis_block structures | |
643 for vd here */ | |
644 //printf("OggVorbis: synthesis and block init done.\n"); | |
645 ogg_sync_init(&sh_audio->ov->oy); /* Now we can read pages */ | |
646 | |
647 while((ret = ogg_sync_pageout(&sh_audio->ov->oy,&sh_audio->ov->og))!=1) { | |
648 if(ret == -1) | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
649 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: Pageout: not properly synced, had to skip some bytes.\n"); |
1828 | 650 else |
651 if(ret == 0) { | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
652 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Pageout: need more data to verify page, reading more data.\n"); |
1828 | 653 /* 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
|
654 buffer=ogg_sync_buffer(&sh_audio->ov->oy,256); |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
655 ogg_sync_wrote(&sh_audio->ov->oy,demux_read_data(sh_audio->ds,buffer,256)); |
1828 | 656 } |
657 } | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
658 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
|
659 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
|
660 as they'll also become apparent |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
661 at packetout */ |
1828 | 662 |
663 /* Get the serial number and set up the rest of decode. */ | |
664 /* serialno first; use it to set up a logical stream */ | |
665 ogg_stream_init(&sh_audio->ov->os,ogg_page_serialno(&sh_audio->ov->og)); | |
666 | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
667 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Init OK!\n"); |
1828 | 668 |
669 break; | |
670 } | |
671 #endif | |
2415 | 672 |
673 #ifdef USE_LIBMAD | |
674 case AFM_MAD: | |
675 { | |
676 printf(__FILE__ ":%d:mad: initialising\n", __LINE__); | |
677 mad_frame_init(&mad_frame); | |
678 mad_stream_init(&mad_stream); | |
679 | |
680 printf(__FILE__ ":%d:mad: preparing buffer\n", __LINE__); | |
681 mad_prepare_buffer(sh_audio, &mad_stream, sh_audio->a_in_buffer_size); | |
682 mad_stream_buffer(&mad_stream, (unsigned char*)(sh_audio->a_in_buffer), sh_audio->a_in_buffer_len); | |
683 mad_stream_sync(&mad_stream); | |
684 mad_synth_init(&mad_synth); | |
685 | |
686 if(mad_frame_decode(&mad_frame, &mad_stream) == 0) | |
687 { | |
688 printf(__FILE__ ":%d:mad: post processing buffer\n", __LINE__); | |
689 mad_postprocess_buffer(sh_audio, &mad_stream); | |
690 } | |
691 else | |
692 { | |
693 printf(__FILE__ ":%d:mad: frame decoding failed\n", __LINE__); | |
694 } | |
695 | |
2434
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
696 switch (mad_frame.header.mode) |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
697 { |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
698 case MAD_MODE_SINGLE_CHANNEL: |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
699 sh_audio->channels=1; |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
700 break; |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
701 case MAD_MODE_DUAL_CHANNEL: |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
702 case MAD_MODE_JOINT_STEREO: |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
703 case MAD_MODE_STEREO: |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
704 sh_audio->channels=2; |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
705 break; |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
706 default: |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
707 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
|
708 } |
571538d73e08
audio channels nr is identified from libmad's channel mode
alex
parents:
2432
diff
changeset
|
709 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
|
710 sh_audio->channels, mad_frame.header.mode); |
2432 | 711 /* var. name changed in 0.13.0 (beta) (libmad/CHANGES) -- alex */ |
712 #if (MAD_VERSION_MAJOR >= 0) && (MAD_VERSION_MINOR >= 13) | |
713 sh_audio->samplerate=mad_frame.header.samplerate; | |
714 #else | |
2415 | 715 sh_audio->samplerate=mad_frame.header.sfreq; |
2432 | 716 #endif |
2415 | 717 sh_audio->i_bps=mad_frame.header.bitrate; |
718 printf(__FILE__ ":%d:mad: continuing\n", __LINE__); | |
719 break; | |
720 } | |
721 #endif | |
296 | 722 } |
723 | |
724 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
|
725 mp_msg(MSGT_DECAUDIO,MSGL_WARN,MSGTR_UnknownAudio); |
303 | 726 driver=0; |
296 | 727 } |
728 | |
303 | 729 if(!driver){ |
730 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
|
731 sh_audio->a_buffer=NULL; |
303 | 732 return 0; |
733 } | |
296 | 734 |
1529 | 735 if(!sh_audio->o_bps) |
303 | 736 sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize; |
737 return driver; | |
296 | 738 } |
291 | 739 |
746 | 740 // Audio decoding: |
291 | 741 |
746 | 742 // Decode a single frame (mp3,acm etc) or 'minlen' bytes (pcm/alaw etc) |
743 // buffer length is 'maxlen' bytes, it shouldn't be exceeded... | |
744 | |
745 int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){ | |
291 | 746 int len=-1; |
303 | 747 switch(sh_audio->codec->driver){ |
1927 | 748 #ifdef USE_LIBAVCODEC |
749 case AFM_FFMPEG: { | |
750 unsigned char *start=NULL; | |
751 int y; | |
752 while(len<minlen){ | |
753 int len2=0; | |
754 int x=ds_get_packet(sh_audio->ds,&start); | |
755 if(x<=0) break; // error | |
2049
df41903fd7d7
VfW stuff moved to dll_init, warnings fixed, using dll_init.h
arpi
parents:
1973
diff
changeset
|
756 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
|
757 if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; } |
1927 | 758 if(y<x) sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!) |
759 if(len2>0){ | |
760 //len=len2;break; | |
761 if(len<0) len=len2; else len+=len2; | |
762 buf+=len2; | |
763 } | |
764 mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"Decoded %d -> %d \n",y,len2); | |
765 } | |
766 } | |
767 break; | |
768 #endif | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
769 case AFM_MPEG: // MPEG layer 2 or 3 |
291 | 770 len=MP3_DecodeFrame(buf,-1); |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1456
diff
changeset
|
771 // len=MP3_DecodeFrame(buf,3); |
291 | 772 break; |
1830 | 773 #ifdef HAVE_OGGVORBIS |
1828 | 774 case AFM_VORBIS: { // OggVorbis |
775 /* note: good minlen would be 4k or 8k IMHO - atmos */ | |
776 int ret; | |
777 char *buffer; | |
778 int bytes; | |
779 int samples; | |
780 float **pcm; | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
781 //ogg_int16_t convbuffer[4096]; |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
782 // int convsize; |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
783 int readlen=1024; |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
784 len=0; |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
785 // 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
|
786 |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
787 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
|
788 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
|
789 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
|
790 if(ret==0) { |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
791 int xxx=0; |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
792 //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
|
793 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
|
794 if(ret == -1) |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
795 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
|
796 else |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
797 if(ret == 0) { |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
798 //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
|
799 /* 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
|
800 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
|
801 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
|
802 xxx+=bytes; |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
803 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
|
804 if(bytes==0) |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
805 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
|
806 } |
1828 | 807 } |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
808 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
|
809 //printf("OggVorbis: Pageout: successfull, pagin in.\n"); |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
810 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
|
811 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
|
812 break; |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
813 } else if(ret<0) { |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
814 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
|
815 break; |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
816 } else { |
1828 | 817 |
818 /* we have a packet. Decode it */ | |
819 | |
820 if(vorbis_synthesis(&sh_audio->ov->vb,&sh_audio->ov->op)==0) /* test for success! */ | |
821 vorbis_synthesis_blockin(&sh_audio->ov->vd,&sh_audio->ov->vb); | |
822 | |
823 /* **pcm is a multichannel float vector. In stereo, for | |
824 example, pcm[0] is left, and pcm[1] is right. samples is | |
825 the size of each channel. Convert the float values | |
826 (-1.<=range<=1.) to whatever PCM format and write it out */ | |
827 | |
828 while((samples=vorbis_synthesis_pcmout(&sh_audio->ov->vd,&pcm))>0){ | |
829 int i,j; | |
830 int clipflag=0; | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
831 int convsize=(maxlen-len)/(2*sh_audio->ov->vi.channels); // max size! |
1828 | 832 int bout=(samples<convsize?samples:convsize); |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
833 |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
834 if(bout<=0) break; |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
835 |
1828 | 836 /* convert floats to 16 bit signed ints (host order) and |
837 interleave */ | |
838 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
|
839 ogg_int16_t *convbuffer=(ogg_int16_t *)(&buf[len]); |
1828 | 840 ogg_int16_t *ptr=convbuffer+i; |
841 float *mono=pcm[i]; | |
842 for(j=0;j<bout;j++){ | |
843 #if 1 | |
844 int val=mono[j]*32767.f; | |
845 #else /* optional dither */ | |
846 int val=mono[j]*32767.f+drand48()-0.5f; | |
847 #endif | |
848 /* might as well guard against clipping */ | |
849 if(val>32767){ | |
850 val=32767; | |
851 clipflag=1; | |
852 } | |
853 if(val<-32768){ | |
854 val=-32768; | |
855 clipflag=1; | |
856 } | |
857 *ptr=val; | |
858 ptr+=sh_audio->ov->vi.channels; | |
859 } | |
860 } | |
861 | |
862 if(clipflag) | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
863 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"Clipping in frame %ld\n",(long)(sh_audio->ov->vd.sequence)); |
1828 | 864 |
865 //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
|
866 //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
|
867 len+=2*sh_audio->ov->vi.channels*bout; |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
868 |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
869 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
|
870 |
1828 | 871 vorbis_synthesis_read(&sh_audio->ov->vd,bout); /* tell libvorbis how |
872 many samples we | |
873 actually consumed */ | |
874 } | |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
875 } // from else, packetout ok |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
876 } // while len |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
877 } // outer while len |
1828 | 878 if(ogg_page_eos(&sh_audio->ov->og)) |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
879 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: End of Stream reached!\n"); // FIXME clearup decoder, notify mplayer - atmos |
1828 | 880 |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
881 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"\n[len: %d ]\n",len); |
1828 | 882 |
883 break; | |
1831 | 884 } |
1830 | 885 #endif |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
886 case AFM_PCM: // AVI PCM |
1058 | 887 len=demux_read_data(sh_audio->ds,buf,minlen); |
401 | 888 break; |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
889 case AFM_DVDPCM: // DVD PCM |
401 | 890 { int j; |
746 | 891 len=demux_read_data(sh_audio->ds,buf,minlen); |
291 | 892 //if(i&1){ printf("Warning! pcm_audio_size&1 !=0 (%d)\n",i);i&=~1; } |
746 | 893 // swap endian: |
291 | 894 for(j=0;j<len;j+=2){ |
895 char x=buf[j]; | |
896 buf[j]=buf[j+1]; | |
897 buf[j+1]=x; | |
898 } | |
899 break; | |
900 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
901 case AFM_ALAW: // aLaw decoder |
746 | 902 { int l=demux_read_data(sh_audio->ds,buf,minlen/2); |
291 | 903 unsigned short *d=(unsigned short *) buf; |
904 unsigned char *s=buf; | |
905 len=2*l; | |
758 | 906 if(sh_audio->format==6){ |
907 // aLaw | |
883 | 908 while(l>0){ --l; d[l]=alaw2short[s[l]]; } |
758 | 909 } else { |
910 // uLaw | |
883 | 911 while(l>0){ --l; d[l]=ulaw2short[s[l]]; } |
291 | 912 } |
913 break; | |
914 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
915 case AFM_GSM: // MS-GSM decoder |
2420 | 916 { unsigned char ibuf[65]; // 65 bytes / frame |
917 if(demux_read_data(sh_audio->ds,ibuf,65)!=65) break; // EOF | |
918 XA_MSGSM_Decoder(ibuf,(unsigned short *) buf); // decodes 65 byte -> 320 short | |
746 | 919 // XA_GSM_Decoder(buf,(unsigned short *) &sh_audio->a_buffer[sh_audio->a_buffer_len]); // decodes 33 byte -> 160 short |
920 len=2*320; | |
291 | 921 break; |
922 } | |
3426 | 923 case AFM_G72X: // GSM 723 decoder |
924 { if(demux_read_data(sh_audio->ds,g72x_data.block, g72x_data.blocksize)!=g72x_data.blocksize) break; // EOF | |
925 g72x_decode_block(&g72x_data); | |
926 len=2*g72x_data.samplesperblock; | |
927 memcpy(buf,g72x_data.samples,len); | |
928 break; | |
929 } | |
3787 | 930 case AFM_IMAADPCM: |
3756 | 931 { unsigned char ibuf[IMA_ADPCM_BLOCK_SIZE * 2]; // bytes / stereo frame |
932 if (demux_read_data(sh_audio->ds, ibuf, | |
3787 | 933 IMA_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) != |
3756 | 934 IMA_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) |
935 break; // EOF | |
936 len=2*ima_adpcm_decode_block((unsigned short*)buf,ibuf, sh_audio->wf->nChannels); | |
3787 | 937 break; |
938 } | |
939 case AFM_MSADPCM: | |
940 { unsigned char ibuf[MS_ADPCM_BLOCK_SIZE * 2]; // bytes / stereo frame | |
941 if (demux_read_data(sh_audio->ds, ibuf, | |
942 MS_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) != | |
943 MS_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) | |
944 break; // EOF | |
945 len=2*ms_adpcm_decode_block((unsigned short*)buf,ibuf, sh_audio->wf->nChannels); | |
2420 | 946 break; |
947 } | |
3826
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
948 case AFM_FOX62ADPCM: |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
949 { unsigned char ibuf[FOX62_ADPCM_BLOCK_SIZE * 2]; // bytes / stereo frame |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
950 if (demux_read_data(sh_audio->ds, ibuf, |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
951 FOX62_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) != |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
952 FOX62_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
953 break; // EOF |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
954 len=2*fox62_adpcm_decode_block((unsigned short*)buf,ibuf, sh_audio->wf->nChannels); |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
955 break; |
8a88ed2473aa
added initial, not-yet-functional, support for fox62 audio
melanson
parents:
3787
diff
changeset
|
956 } |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
957 case AFM_AC3: // AC3 decoder |
291 | 958 //printf("{1:%d}",avi_header.idx_pos);fflush(stdout); |
959 if(!sh_audio->ac3_frame) sh_audio->ac3_frame=ac3_decode_frame(); | |
960 //printf("{2:%d}",avi_header.idx_pos);fflush(stdout); | |
961 if(sh_audio->ac3_frame){ | |
296 | 962 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
|
963 memcpy(buf,((ac3_frame_t*)sh_audio->ac3_frame)->audio_data,len); |
291 | 964 sh_audio->ac3_frame=NULL; |
965 } | |
966 //printf("{3:%d}",avi_header.idx_pos);fflush(stdout); | |
967 break; | |
3413 | 968 case AFM_A52: { // AC3 decoder |
969 int flags=0; | |
970 int i; | |
971 sample_t level=1, bias=384; | |
972 if(!sh_audio->a_in_buffer_len) | |
973 if(a52_fillbuff(sh_audio)<0) break; // EOF | |
3834 | 974 |
3413 | 975 switch(sh_audio->channels){ |
976 case 1: flags=A52_MONO; break; | |
977 // case 2: flags=A52_STEREO; break; | |
978 case 2: flags=A52_DOLBY; break; | |
979 // case 3: flags=A52_3F; break; | |
980 case 3: flags=A52_2F1R; break; | |
981 case 4: flags=A52_2F2R; break; // 2+2 | |
982 case 5: flags=A52_3F2R; break; | |
983 case 6: flags=A52_3F2R|A52_LFE; break; // 5.1 | |
984 } | |
985 flags|=A52_ADJUST_LEVEL; | |
986 sh_audio->a_in_buffer_len=0; | |
987 if (a52_frame (&a52_state, sh_audio->a_in_buffer, &flags, &level, bias)){ | |
988 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"a52: error decoding frame\n"); | |
989 break; | |
990 } | |
991 // a52_dynrng (&state, NULL, NULL); // disable dynamic range compensation | |
992 | |
993 // frame decoded, let's resample: | |
994 a52_resample_init(flags,sh_audio->channels); | |
995 len=0; | |
996 for (i = 0; i < 6; i++) { | |
997 if (a52_block (&a52_state, a52_samples)){ | |
998 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"a52: error at resampling\n"); | |
999 break; | |
1000 } | |
1001 len+=2*a52_resample(a52_samples,&buf[len]); | |
1002 } | |
3417 | 1003 // printf("len = %d \n",len); // 6144 on all vobs I tried so far... (5.1 and 2.0) ::atmos |
3413 | 1004 break; |
1005 } | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
1006 case AFM_HWAC3: // AC3 through SPDIF |
3829 | 1007 if(!sh_audio->a_in_buffer_len) |
1008 if((len=a52_fillbuff(sh_audio))<0) break; //EOF | |
1009 sh_audio->a_in_buffer_len=0; | |
1010 len = ac3_iec958_build_burst(len, 0x01, 1, sh_audio->a_in_buffer, buf); | |
1011 // len = 6144 = 4*(6*256) | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
1012 break; |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1485
diff
changeset
|
1013 #ifdef USE_WIN32DLL |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1014 case AFM_ACM: |
758 | 1015 // len=sh_audio->audio_out_minsize; // optimal decoded fragment size |
1016 // if(len<minlen) len=minlen; else | |
1017 // if(len>maxlen) len=maxlen; | |
1018 // len=acm_decode_audio(sh_audio,buf,len); | |
1019 len=acm_decode_audio(sh_audio,buf,minlen,maxlen); | |
291 | 1020 break; |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
1021 #endif |
746 | 1022 |
291 | 1023 #ifdef USE_DIRECTSHOW |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1024 case AFM_DSHOW: // DirectShow |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1025 { int size_in=0; |
291 | 1026 int size_out=0; |
3442 | 1027 int srcsize=DS_AudioDecoder_GetSrcSize(ds_adec, maxlen); |
1567 | 1028 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 | 1029 if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!! |
1030 if(sh_audio->a_in_buffer_len<srcsize){ | |
1031 sh_audio->a_in_buffer_len+= | |
1032 demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len], | |
1033 srcsize-sh_audio->a_in_buffer_len); | |
1034 } | |
3442 | 1035 DS_AudioDecoder_Convert(ds_adec, sh_audio->a_in_buffer,sh_audio->a_in_buffer_len, |
291 | 1036 buf,maxlen, &size_in,&size_out); |
1567 | 1037 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 | 1038 if(size_in>=sh_audio->a_in_buffer_len){ |
1039 sh_audio->a_in_buffer_len=0; | |
1040 } else { | |
1041 sh_audio->a_in_buffer_len-=size_in; | |
1042 memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len); | |
1043 } | |
1044 len=size_out; | |
1045 break; | |
1046 } | |
1047 #endif | |
2415 | 1048 |
1049 #ifdef USE_LIBMAD | |
1050 case AFM_MAD: | |
1051 { | |
1052 mad_prepare_buffer(sh_audio, &mad_stream, sh_audio->a_in_buffer_size); | |
1053 mad_stream_buffer(&mad_stream, sh_audio->a_in_buffer, sh_audio->a_in_buffer_len); | |
1054 if(mad_frame_decode(&mad_frame, &mad_stream) == 0) | |
1055 { | |
1056 mad_synth_frame(&mad_synth, &mad_frame); | |
1057 mad_postprocess_buffer(sh_audio, &mad_stream); | |
1058 | |
1059 /* and fill buffer */ | |
1060 | |
1061 { | |
1062 int i; | |
1063 int end_size = mad_synth.pcm.length; | |
1064 signed short* samples = (signed short*)buf; | |
1065 if(end_size > maxlen/4) | |
1066 end_size=maxlen/4; | |
1067 | |
1068 for(i=0; i<mad_synth.pcm.length; ++i) { | |
1069 *samples++ = mad_scale(mad_synth.pcm.samples[0][i]); | |
1070 *samples++ = mad_scale(mad_synth.pcm.samples[0][i]); | |
1071 // *buf++ = mad_scale(mad_synth.pcm.sampAles[1][i]); | |
1072 } | |
1073 len = end_size*4; | |
1074 } | |
1075 } | |
1076 else | |
1077 { | |
1078 printf(__FILE__ ":%d:mad: frame decoding failed\n", __LINE__); | |
1079 } | |
1080 | |
1081 break; | |
1082 } | |
1083 #endif | |
291 | 1084 } |
1085 return len; | |
1086 } | |
1087 | |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1088 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
|
1089 switch(sh_audio->codec->driver){ |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1090 case AFM_MPEG: |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1091 MP3_DecodeFrame(NULL,-2); // resync |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1092 MP3_DecodeFrame(NULL,-2); // resync |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1093 MP3_DecodeFrame(NULL,-2); // resync |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1094 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
|
1095 #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
|
1096 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
|
1097 //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
|
1098 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
|
1099 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
|
1100 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
|
1101 #endif |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1102 case AFM_AC3: |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1103 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
|
1104 // 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
|
1105 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
|
1106 // if(verbose) printf(" OK!\n"); |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1107 break; |
3413 | 1108 case AFM_A52: |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1109 case AFM_ACM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1110 case AFM_DSHOW: |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
1111 case AFM_HWAC3: |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1112 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
|
1113 break; |
2415 | 1114 |
1115 #ifdef USE_LIBMAD | |
1116 case AFM_MAD: | |
1117 mad_prepare_buffer(sh_audio, &mad_stream, sh_audio->a_in_buffer_size); | |
1118 mad_stream_buffer(&mad_stream, sh_audio->a_in_buffer, sh_audio->a_in_buffer_len); | |
1119 mad_stream_sync(&mad_stream); | |
1120 mad_postprocess_buffer(sh_audio, &mad_stream); | |
1121 break; | |
2418 | 1122 #endif |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1123 } |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1124 } |
291 | 1125 |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1126 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
|
1127 switch(sh_audio->codec->driver){ |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1128 case AFM_MPEG: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1129 case AFM_AC3: sh_audio->ac3_frame=ac3_decode_frame();break; // skip AC3 frame |
3829 | 1130 case AFM_HWAC3: |
3413 | 1131 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
|
1132 case AFM_ACM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1133 case AFM_DSHOW: { |
1408 | 1134 int skip=sh_audio->wf->nBlockAlign; |
1135 if(skip<16){ | |
1136 skip=(sh_audio->wf->nAvgBytesPerSec/16)&(~7); | |
1137 if(skip<16) skip=16; | |
1138 } | |
1139 demux_read_data(sh_audio->ds,NULL,skip); | |
1140 break; | |
1141 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1142 case AFM_PCM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1143 case AFM_DVDPCM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
1144 case AFM_ALAW: { |
1408 | 1145 int skip=sh_audio->i_bps/16; |
1146 skip=skip&(~3); | |
1147 demux_read_data(sh_audio->ds,NULL,skip); | |
1148 break; | |
1149 } | |
2415 | 1150 #ifdef USE_LIBMAD |
1151 case AFM_MAD: | |
1152 { | |
1153 mad_prepare_buffer(sh_audio, &mad_stream, sh_audio->a_in_buffer_size); | |
1154 mad_stream_buffer(&mad_stream, sh_audio->a_in_buffer, sh_audio->a_in_buffer_len); | |
1155 mad_stream_skip(&mad_stream, 2); | |
1156 mad_stream_sync(&mad_stream); | |
1157 mad_postprocess_buffer(sh_audio, &mad_stream); | |
1158 break; | |
1159 } | |
1160 #endif | |
1161 | |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1162 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
|
1163 } |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
1164 } |