Mercurial > mplayer.hg
annotate dec_audio.c @ 1951:b2b85982fc0e
MTRR autoconfigure
author | nick |
---|---|
date | Tue, 25 Sep 2001 07:20:42 +0000 |
parents | 296208b47fd4 |
children | 5216f108cb4f |
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" |
8 | |
1058 | 9 #include "libao2/afmt.h" |
758 | 10 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
11 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
|
12 |
732
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
13 #ifdef USE_FAKE_MONO |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
14 int fakemono=0; |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
15 #endif |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
16 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
17 #include "stream.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
18 #include "demuxer.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
19 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
20 #include "wine/mmreg.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
21 #include "wine/avifmt.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
22 #include "wine/vfw.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
23 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
24 #include "codec-cfg.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
25 #include "stheader.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
26 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
27 #include "mp3lib/mp3.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
28 #include "libac3/ac3.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
29 |
883 | 30 #include "alaw.h" |
31 | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
32 #include "xa/xa_gsm.h" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
33 |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
34 #include "ac3-iec958.h" |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
35 |
1291 | 36 #ifdef USE_DIRECTSHOW |
604 | 37 #include "loader/DirectShow/DS_AudioDec.h" |
1291 | 38 #endif |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
39 |
1828 | 40 #ifdef HAVE_OGGVORBIS |
41 /* XXX is math.h really needed? - atmos */ | |
42 #include <math.h> | |
43 #include <vorbis/codec.h> | |
44 #endif | |
45 | |
1927 | 46 #ifdef USE_LIBAVCODEC |
47 #include "libavcodec/avcodec.h" | |
48 static AVCodec *lavc_codec=NULL; | |
49 static AVCodecContext lavc_context; | |
50 extern int avcodec_inited; | |
51 #endif | |
52 | |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
53 extern int init_acm_audio_codec(sh_audio_t *sh_audio); |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
54 extern int acm_decode_audio(sh_audio_t *sh_audio, void* a_buffer,int minlen,int maxlen); |
1927 | 55 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
|
56 |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
57 |
1289 | 58 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
|
59 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
60 // AC3 decoder buffer callback: |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
61 static void ac3_fill_buffer(uint8_t **start,uint8_t **end){ |
1289 | 62 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
|
63 //printf("<ac3:%d>\n",len); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
64 if(len<0) |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
65 *start = *end = NULL; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
66 else |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
67 *end = *start + len; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
68 } |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
432
diff
changeset
|
69 |
1289 | 70 // MP3 decoder buffer callback: |
71 int mplayer_audio_read(char *buf,int size){ | |
72 int len; | |
73 len=demux_read_data(dec_audio_sh->ds,buf,size); | |
74 return len; | |
75 } | |
76 | |
296 | 77 int init_audio(sh_audio_t *sh_audio){ |
303 | 78 int driver=sh_audio->codec->driver; |
296 | 79 |
80 sh_audio->samplesize=2; | |
1320
18374d49befa
On big-endian architectures, all audio decoders default to big-endian 16-bit
jkeil
parents:
1313
diff
changeset
|
81 #if WORDS_BIGENDIAN |
18374d49befa
On big-endian architectures, all audio decoders default to big-endian 16-bit
jkeil
parents:
1313
diff
changeset
|
82 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
|
83 #else |
758 | 84 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
|
85 #endif |
303 | 86 sh_audio->samplerate=0; |
401 | 87 //sh_audio->pcm_bswap=0; |
1529 | 88 sh_audio->o_bps=0; |
303 | 89 |
758 | 90 sh_audio->a_buffer_size=0; |
303 | 91 sh_audio->a_buffer=NULL; |
296 | 92 |
746 | 93 sh_audio->a_in_buffer_len=0; |
94 | |
758 | 95 // setup required min. in/out buffer size: |
96 sh_audio->audio_out_minsize=8192;// default size, maybe not enough for Win32/ACM | |
97 | |
98 switch(driver){ | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
99 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
|
100 #ifndef USE_WIN32DLL |
1567 | 101 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Win32/ACM audio codec disabled, or unavailable on non-x86 CPU -> force nosound :(\n"); |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
102 driver=0; |
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
103 #else |
296 | 104 // Win32 ACM audio codec: |
105 if(init_acm_audio_codec(sh_audio)){ | |
746 | 106 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; |
296 | 107 sh_audio->channels=sh_audio->o_wf.nChannels; |
108 sh_audio->samplerate=sh_audio->o_wf.nSamplesPerSec; | |
758 | 109 // if(sh_audio->audio_out_minsize>16384) sh_audio->audio_out_minsize=16384; |
110 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize; | |
111 // if(sh_audio->a_buffer_size<sh_audio->audio_out_minsize+MAX_OUTBURST) | |
112 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; | |
296 | 113 } else { |
1567 | 114 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Could not load/initialize Win32/ACM AUDIO codec (missing DLL file?)\n"); |
303 | 115 driver=0; |
296 | 116 } |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
117 #endif |
758 | 118 break; |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
119 case AFM_DSHOW: |
296 | 120 #ifndef USE_DIRECTSHOW |
1567 | 121 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Compiled without DirectShow support -> force nosound :(\n"); |
303 | 122 driver=0; |
296 | 123 #else |
124 // Win32 DShow audio codec: | |
340 | 125 // printf("DShow_audio: channs=%d rate=%d\n",sh_audio->channels,sh_audio->samplerate); |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
126 if(DS_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf)){ |
1828 | 127 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not load/initialize Win32/DirectShow AUDIO codec: %s\n",sh_audio->codec->dll); |
303 | 128 driver=0; |
129 } else { | |
746 | 130 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
|
131 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
|
132 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
|
133 sh_audio->audio_in_minsize=2*sh_audio->wf->nBlockAlign; |
296 | 134 if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192; |
135 sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize; | |
136 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); | |
137 sh_audio->a_in_buffer_len=0; | |
758 | 138 sh_audio->audio_out_minsize=16384; |
296 | 139 } |
140 #endif | |
758 | 141 break; |
1828 | 142 case AFM_VORBIS: |
143 #ifndef HAVE_OGGVORBIS | |
144 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"OggVorbis audio codec disabled -> force nosound :(\n"); | |
145 driver=0; | |
146 #else | |
147 /* 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
|
148 sh_audio->audio_out_minsize=1024*4; // 1024 samples/frame |
1828 | 149 #endif |
150 break; | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
151 case AFM_PCM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
152 case AFM_DVDPCM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
153 case AFM_ALAW: |
758 | 154 // PCM, aLaw |
155 sh_audio->audio_out_minsize=2048; | |
156 break; | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
157 case AFM_AC3: |
758 | 158 // Dolby AC3 audio: |
159 sh_audio->audio_out_minsize=4*256*6; | |
160 break; | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
161 case AFM_HWAC3: |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
162 // Dolby AC3 audio: |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
163 sh_audio->audio_out_minsize=4*256*6; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
164 sh_audio->sample_format = AFMT_AC3; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
165 break; |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
166 case AFM_GSM: |
758 | 167 // MS-GSM audio codec: |
168 sh_audio->audio_out_minsize=4*320; | |
169 break; | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
170 case AFM_MPEG: |
758 | 171 // MPEG Audio: |
172 sh_audio->audio_out_minsize=4608; | |
173 break; | |
1927 | 174 case AFM_FFMPEG: |
175 #ifndef USE_LIBAVCODEC | |
176 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"MPlayer was compiled WITHOUT libavcodec support!\n"); | |
177 return 0; | |
178 #else | |
179 // FFmpeg Audio: | |
180 sh_audio->audio_out_minsize=AVCODEC_MAX_AUDIO_FRAME_SIZE; | |
181 break; | |
182 #endif | |
296 | 183 } |
184 | |
303 | 185 if(!driver) return 0; |
296 | 186 |
187 // allocate audio out buffer: | |
758 | 188 sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; // worst case calc. |
189 | |
1567 | 190 mp_msg(MSGT_DECAUDIO,MSGL_V,"dec_audio: Allocating %d + %d = %d bytes for output buffer\n", |
758 | 191 sh_audio->audio_out_minsize,MAX_OUTBURST,sh_audio->a_buffer_size); |
192 | |
296 | 193 sh_audio->a_buffer=malloc(sh_audio->a_buffer_size); |
758 | 194 if(!sh_audio->a_buffer){ |
1567 | 195 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Cannot allocate audio out buffer\n"); |
758 | 196 return 0; |
197 } | |
296 | 198 memset(sh_audio->a_buffer,0,sh_audio->a_buffer_size); |
199 sh_audio->a_buffer_len=0; | |
200 | |
303 | 201 switch(driver){ |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1485
diff
changeset
|
202 #ifdef USE_WIN32DLL |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
203 case AFM_ACM: { |
758 | 204 int ret=acm_decode_audio(sh_audio,sh_audio->a_buffer,4096,sh_audio->a_buffer_size); |
296 | 205 if(ret<0){ |
1567 | 206 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"ACM decoding error: %d\n",ret); |
303 | 207 driver=0; |
296 | 208 } |
640 | 209 sh_audio->a_buffer_len=ret; |
303 | 210 break; |
296 | 211 } |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
212 #endif |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
213 case AFM_PCM: { |
296 | 214 // 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
|
215 WAVEFORMATEX *h=sh_audio->wf; |
746 | 216 sh_audio->i_bps=h->nAvgBytesPerSec; |
296 | 217 sh_audio->channels=h->nChannels; |
218 sh_audio->samplerate=h->nSamplesPerSec; | |
219 sh_audio->samplesize=(h->wBitsPerSample+7)/8; | |
758 | 220 switch(sh_audio->format){ // hardware formats: |
221 case 0x6: sh_audio->sample_format=AFMT_A_LAW;break; | |
222 case 0x7: sh_audio->sample_format=AFMT_MU_LAW;break; | |
223 case 0x11: sh_audio->sample_format=AFMT_IMA_ADPCM;break; | |
224 case 0x50: sh_audio->sample_format=AFMT_MPEG;break; | |
225 // case 0x2000: sh_audio->sample_format=AFMT_AC3; | |
226 default: sh_audio->sample_format=(sh_audio->samplesize==2)?AFMT_S16_LE:AFMT_U8; | |
227 } | |
401 | 228 break; |
229 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
230 case AFM_DVDPCM: { |
401 | 231 // DVD PCM Audio: |
232 sh_audio->channels=2; | |
233 sh_audio->samplerate=48000; | |
746 | 234 sh_audio->i_bps=2*2*48000; |
296 | 235 // sh_audio->pcm_bswap=1; |
303 | 236 break; |
237 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
238 case AFM_AC3: { |
296 | 239 // Dolby AC3 audio: |
1289 | 240 dec_audio_sh=sh_audio; // save sh_audio for the callback: |
296 | 241 ac3_config.fill_buffer_callback = ac3_fill_buffer; |
242 ac3_config.num_output_ch = 2; | |
243 ac3_config.flags = 0; | |
244 #ifdef HAVE_MMX | |
245 ac3_config.flags |= AC3_MMX_ENABLE; | |
246 #endif | |
247 #ifdef HAVE_3DNOW | |
248 ac3_config.flags |= AC3_3DNOW_ENABLE; | |
249 #endif | |
250 ac3_init(); | |
251 sh_audio->ac3_frame = ac3_decode_frame(); | |
252 if(sh_audio->ac3_frame){ | |
746 | 253 ac3_frame_t* fr=(ac3_frame_t*)sh_audio->ac3_frame; |
254 sh_audio->samplerate=fr->sampling_rate; | |
296 | 255 sh_audio->channels=2; |
746 | 256 // 1 frame: 6*256 samples 1 sec: sh_audio->samplerate samples |
257 //sh_audio->i_bps=fr->frame_size*fr->sampling_rate/(6*256); | |
258 sh_audio->i_bps=fr->bit_rate*(1000/8); | |
303 | 259 } else { |
260 driver=0; // bad frame -> disable audio | |
261 } | |
262 break; | |
263 } | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
264 case AFM_HWAC3: { |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
265 unsigned char *buffer; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
266 struct hwac3info ai; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
267 int len, skipped; |
1529 | 268 len = ds_get_packet(sh_audio->ds, &buffer); // maybe 1 packet is not enough, |
269 // at least for mpeg, PS packets contain about max. 2000 bytes of data. | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
270 if(ac3_iec958_parse_syncinfo(buffer, len, &ai, &skipped) < 0) { |
1567 | 271 mp_msg(MSGT_DECAUDIO,MSGL_ERR, "AC3 stream not valid.\n"); |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
272 driver = 0; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
273 break; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
274 } |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
275 if(ai.samplerate != 48000) { |
1567 | 276 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Only 48000 Hz streams supported.\n"); |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
277 driver = 0; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
278 break; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
279 } |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
280 sh_audio->samplerate=ai.samplerate; |
1529 | 281 sh_audio->samplesize=ai.framesize; |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
282 sh_audio->channels=1; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
283 sh_audio->i_bps=ai.bitrate*(1000/8); |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
284 sh_audio->ac3_frame=malloc(6144); |
1529 | 285 sh_audio->o_bps=sh_audio->i_bps; // XXX FIXME!!! XXX |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
286 break; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
287 } |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
288 case AFM_ALAW: { |
296 | 289 // 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
|
290 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
|
291 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
746 | 292 sh_audio->i_bps=sh_audio->channels*sh_audio->samplerate; |
303 | 293 break; |
294 } | |
1927 | 295 #ifdef USE_LIBAVCODEC |
296 case AFM_FFMPEG: { | |
297 int x; | |
298 mp_msg(MSGT_DECAUDIO,MSGL_V,"FFmpeg's libavcodec audio codec\n"); | |
299 if(!avcodec_inited){ | |
300 avcodec_init(); | |
301 avcodec_register_all(); | |
302 avcodec_inited=1; | |
303 } | |
304 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_audio->codec->dll); | |
305 if(!lavc_codec){ | |
306 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Can't find codec '%s' in libavcodec...\n",sh_audio->codec->dll); | |
307 return 0; | |
308 } | |
309 memset(&lavc_context, 0, sizeof(lavc_context)); | |
310 /* open it */ | |
311 if (avcodec_open(&lavc_context, lavc_codec) < 0) { | |
312 mp_msg(MSGT_DECAUDIO,MSGL_ERR, "could not open codec\n"); | |
313 return 0; | |
314 } | |
315 mp_msg(MSGT_DECAUDIO,MSGL_V,"INFO: libavcodec init OK!\n"); | |
316 | |
317 // Decode at least 1 byte: (to get header filled) | |
318 x=decode_audio(sh_audio,sh_audio->a_buffer,1,sh_audio->a_buffer_size); | |
319 if(x>0) sh_audio->a_buffer_len=x; | |
320 | |
321 #if 1 | |
322 sh_audio->channels=lavc_context.channels; | |
323 sh_audio->samplerate=lavc_context.sample_rate; | |
324 sh_audio->i_bps=lavc_context.bit_rate/8; | |
325 #else | |
326 sh_audio->channels=sh_audio->wf->nChannels; | |
327 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
328 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; | |
329 #endif | |
330 break; | |
331 } | |
332 #endif | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
333 case AFM_GSM: { |
296 | 334 // MS-GSM audio codec: |
335 GSM_Init(); | |
432
5251b0c57e39
sh_audio->wf and sh_video->bih changed to dynamic (thanx to Jens Hoffmann)
arpi_esp
parents:
401
diff
changeset
|
336 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
|
337 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
746 | 338 // decodes 65 byte -> 320 short |
339 // 1 sec: sh_audio->channels*sh_audio->samplerate samples | |
340 // 1 frame: 320 samples | |
341 sh_audio->i_bps=65*(sh_audio->channels*sh_audio->samplerate)/320; // 1:10 | |
303 | 342 break; |
296 | 343 } |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
344 case AFM_MPEG: { |
296 | 345 // MPEG Audio: |
1289 | 346 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
|
347 #ifdef USE_FAKE_MONO |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
348 MP3_Init(fakemono); |
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
349 #else |
296 | 350 MP3_Init(); |
732
e14114170e01
applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents:
640
diff
changeset
|
351 #endif |
296 | 352 MP3_samplerate=MP3_channels=0; |
353 // printf("[\n"); | |
354 sh_audio->a_buffer_len=MP3_DecodeFrame(sh_audio->a_buffer,-1); | |
355 // printf("]\n"); | |
356 sh_audio->channels=2; // hack | |
357 sh_audio->samplerate=MP3_samplerate; | |
746 | 358 sh_audio->i_bps=MP3_bitrate*(1000/8); |
303 | 359 break; |
360 } | |
1828 | 361 #ifdef HAVE_OGGVORBIS |
362 case AFM_VORBIS: { | |
363 // OggVorbis Audio: | |
364 #if 0 /* just here for reference - atmos */ | |
365 ogg_sync_state oy; /* sync and verify incoming physical bitstream */ | |
366 ogg_stream_state os; /* take physical pages, weld into a logical | |
367 stream of packets */ | |
368 ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ | |
369 ogg_packet op; /* one raw packet of data for decode */ | |
370 | |
371 vorbis_info vi; /* struct that stores all the static vorbis bitstream | |
372 settings */ | |
373 vorbis_comment vc; /* struct that stores all the bitstream user comments */ | |
374 vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ | |
375 vorbis_block vb; /* local working space for packet->PCM decode */ | |
376 #else | |
377 /* nix, nada, rien, nothing, nem, nüx */ | |
378 #endif | |
379 | |
380 uint32_t hdrsizes[3];/* stores vorbis header sizes from AVI audio header, | |
381 maybe use ogg_uint32_t */ | |
382 //int i; | |
383 int ret; | |
384 char *buffer; | |
385 ogg_packet hdr; | |
386 //ov_struct_t *s=&sh_audio->ov; | |
387 sh_audio->ov=malloc(sizeof(ov_struct_t)); | |
388 //s=&sh_audio->ov; | |
389 | |
390 vorbis_info_init(&sh_audio->ov->vi); | |
391 vorbis_comment_init(&sh_audio->ov->vc); | |
392 | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
393 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"OggVorbis: cbsize: %i\n", sh_audio->wf->cbSize); |
1828 | 394 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
|
395 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"OggVorbis: Read header sizes: initial: %i comment: %i codebook: %i\n", hdrsizes[0], hdrsizes[1], hdrsizes[2]); |
1828 | 396 /*for(i=12; i <= 40; i+=2) { // header bruteforce :) |
397 memcpy(hdrsizes, ((unsigned char*)sh_audio->wf)+i, 3*sizeof(uint32_t)); | |
398 printf("OggVorbis: Read header sizes (%i): %ld %ld %ld\n", i, hdrsizes[0], hdrsizes[1], hdrsizes[2]); | |
399 }*/ | |
400 | |
401 /* read headers */ // FIXME disable sound on errors here, we absolutely need this headers! - atmos | |
402 hdr.packet=NULL; | |
403 hdr.b_o_s = 1; /* beginning of stream for first packet */ | |
404 hdr.bytes = hdrsizes[0]; | |
405 hdr.packet = realloc(hdr.packet,hdr.bytes); | |
406 memcpy(hdr.packet,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t),hdr.bytes); | |
407 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
|
408 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: initial (identification) header broken!\n"); |
1828 | 409 hdr.b_o_s = 0; |
410 hdr.bytes = hdrsizes[1]; | |
411 hdr.packet = realloc(hdr.packet,hdr.bytes); | |
412 memcpy(hdr.packet,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t)+hdrsizes[0],hdr.bytes); | |
413 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
|
414 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: comment header broken!\n"); |
1828 | 415 hdr.bytes = hdrsizes[2]; |
416 hdr.packet = realloc(hdr.packet,hdr.bytes); | |
417 memcpy(hdr.packet,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t)+hdrsizes[0]+hdrsizes[1],hdr.bytes); | |
418 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
|
419 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: codebook header broken!\n"); |
1828 | 420 hdr.bytes=0; |
421 hdr.packet = realloc(hdr.packet,hdr.bytes); /* free */ | |
422 /* done with the headers */ | |
423 | |
424 | |
425 /* Throw the comments plus a few lines about the bitstream we're | |
426 decoding */ | |
427 { | |
428 char **ptr=sh_audio->ov->vc.user_comments; | |
429 while(*ptr){ | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
430 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbisComment: %s\n",*ptr); |
1828 | 431 ++ptr; |
432 } | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
433 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
|
434 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Encoded by: %s\n",sh_audio->ov->vc.vendor); |
1828 | 435 } |
436 sh_audio->channels=sh_audio->ov->vi.channels; | |
437 sh_audio->samplerate=sh_audio->ov->vi.rate; | |
438 sh_audio->i_bps=sh_audio->ov->vi.bitrate_nominal/8; | |
439 | |
440 // printf("[\n"); | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
441 // sh_audio->a_buffer_len=sh_audio->audio_out_minsize;///ov->vi.channels; |
1828 | 442 // printf("]\n"); |
443 | |
444 /* OK, got and parsed all three headers. Initialize the Vorbis | |
445 packet->PCM decoder. */ | |
446 vorbis_synthesis_init(&sh_audio->ov->vd,&sh_audio->ov->vi); /* central decode state */ | |
447 vorbis_block_init(&sh_audio->ov->vd,&sh_audio->ov->vb); /* local state for most of the decode | |
448 so multiple block decodes can | |
449 proceed in parallel. We could init | |
450 multiple vorbis_block structures | |
451 for vd here */ | |
452 //printf("OggVorbis: synthesis and block init done.\n"); | |
453 ogg_sync_init(&sh_audio->ov->oy); /* Now we can read pages */ | |
454 | |
455 while((ret = ogg_sync_pageout(&sh_audio->ov->oy,&sh_audio->ov->og))!=1) { | |
456 if(ret == -1) | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
457 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: Pageout: not properly synced, had to skip some bytes.\n"); |
1828 | 458 else |
459 if(ret == 0) { | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
460 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Pageout: need more data to verify page, reading more data.\n"); |
1828 | 461 /* 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
|
462 buffer=ogg_sync_buffer(&sh_audio->ov->oy,256); |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
463 ogg_sync_wrote(&sh_audio->ov->oy,demux_read_data(sh_audio->ds,buffer,256)); |
1828 | 464 } |
465 } | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
466 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
|
467 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
|
468 as they'll also become apparent |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
469 at packetout */ |
1828 | 470 |
471 /* Get the serial number and set up the rest of decode. */ | |
472 /* serialno first; use it to set up a logical stream */ | |
473 ogg_stream_init(&sh_audio->ov->os,ogg_page_serialno(&sh_audio->ov->og)); | |
474 | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
475 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Init OK!\n"); |
1828 | 476 |
477 break; | |
478 } | |
479 #endif | |
296 | 480 } |
481 | |
482 if(!sh_audio->channels || !sh_audio->samplerate){ | |
1567 | 483 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Unknown/missing audio format, using nosound\n"); |
303 | 484 driver=0; |
296 | 485 } |
486 | |
303 | 487 if(!driver){ |
488 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
|
489 sh_audio->a_buffer=NULL; |
303 | 490 return 0; |
491 } | |
296 | 492 |
1529 | 493 if(!sh_audio->o_bps) |
303 | 494 sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize; |
495 return driver; | |
296 | 496 } |
291 | 497 |
746 | 498 // Audio decoding: |
291 | 499 |
746 | 500 // Decode a single frame (mp3,acm etc) or 'minlen' bytes (pcm/alaw etc) |
501 // buffer length is 'maxlen' bytes, it shouldn't be exceeded... | |
502 | |
503 int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){ | |
291 | 504 int len=-1; |
303 | 505 switch(sh_audio->codec->driver){ |
1927 | 506 #ifdef USE_LIBAVCODEC |
507 case AFM_FFMPEG: { | |
508 unsigned char *start=NULL; | |
509 int y; | |
510 while(len<minlen){ | |
511 int len2=0; | |
512 int x=ds_get_packet(sh_audio->ds,&start); | |
513 if(x<=0) break; // error | |
514 y=avcodec_decode_audio(&lavc_context,buf,&len2,start,x); | |
515 if(y<0){ printf("lavc_audio: error\n");break; } | |
516 if(y<x) sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!) | |
517 if(len2>0){ | |
518 //len=len2;break; | |
519 if(len<0) len=len2; else len+=len2; | |
520 buf+=len2; | |
521 } | |
522 mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"Decoded %d -> %d \n",y,len2); | |
523 } | |
524 } | |
525 break; | |
526 #endif | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
527 case AFM_MPEG: // MPEG layer 2 or 3 |
291 | 528 len=MP3_DecodeFrame(buf,-1); |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1456
diff
changeset
|
529 // len=MP3_DecodeFrame(buf,3); |
291 | 530 break; |
1830 | 531 #ifdef HAVE_OGGVORBIS |
1828 | 532 case AFM_VORBIS: { // OggVorbis |
533 /* note: good minlen would be 4k or 8k IMHO - atmos */ | |
534 int ret; | |
535 char *buffer; | |
536 int bytes; | |
537 int samples; | |
538 float **pcm; | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
539 //ogg_int16_t convbuffer[4096]; |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
540 // int convsize; |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
541 int readlen=1024; |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
542 len=0; |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
543 // 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
|
544 |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
545 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
|
546 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
|
547 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
|
548 if(ret==0) { |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
549 int xxx=0; |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
550 //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
|
551 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
|
552 if(ret == -1) |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
553 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
|
554 else |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
555 if(ret == 0) { |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
556 //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
|
557 /* 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
|
558 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
|
559 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
|
560 xxx+=bytes; |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
561 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
|
562 if(bytes==0) |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
563 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
|
564 } |
1828 | 565 } |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
566 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
|
567 //printf("OggVorbis: Pageout: successfull, pagin in.\n"); |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
568 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
|
569 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
|
570 break; |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
571 } else if(ret<0) { |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
572 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
|
573 break; |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
574 } else { |
1828 | 575 |
576 /* we have a packet. Decode it */ | |
577 | |
578 if(vorbis_synthesis(&sh_audio->ov->vb,&sh_audio->ov->op)==0) /* test for success! */ | |
579 vorbis_synthesis_blockin(&sh_audio->ov->vd,&sh_audio->ov->vb); | |
580 | |
581 /* **pcm is a multichannel float vector. In stereo, for | |
582 example, pcm[0] is left, and pcm[1] is right. samples is | |
583 the size of each channel. Convert the float values | |
584 (-1.<=range<=1.) to whatever PCM format and write it out */ | |
585 | |
586 while((samples=vorbis_synthesis_pcmout(&sh_audio->ov->vd,&pcm))>0){ | |
587 int i,j; | |
588 int clipflag=0; | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
589 int convsize=(maxlen-len)/(2*sh_audio->ov->vi.channels); // max size! |
1828 | 590 int bout=(samples<convsize?samples:convsize); |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
591 |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
592 if(bout<=0) break; |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
593 |
1828 | 594 /* convert floats to 16 bit signed ints (host order) and |
595 interleave */ | |
596 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
|
597 ogg_int16_t *convbuffer=(ogg_int16_t *)(&buf[len]); |
1828 | 598 ogg_int16_t *ptr=convbuffer+i; |
599 float *mono=pcm[i]; | |
600 for(j=0;j<bout;j++){ | |
601 #if 1 | |
602 int val=mono[j]*32767.f; | |
603 #else /* optional dither */ | |
604 int val=mono[j]*32767.f+drand48()-0.5f; | |
605 #endif | |
606 /* might as well guard against clipping */ | |
607 if(val>32767){ | |
608 val=32767; | |
609 clipflag=1; | |
610 } | |
611 if(val<-32768){ | |
612 val=-32768; | |
613 clipflag=1; | |
614 } | |
615 *ptr=val; | |
616 ptr+=sh_audio->ov->vi.channels; | |
617 } | |
618 } | |
619 | |
620 if(clipflag) | |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
621 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"Clipping in frame %ld\n",(long)(sh_audio->ov->vd.sequence)); |
1828 | 622 |
623 //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
|
624 //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
|
625 len+=2*sh_audio->ov->vi.channels*bout; |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
626 |
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
627 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
|
628 |
1828 | 629 vorbis_synthesis_read(&sh_audio->ov->vd,bout); /* tell libvorbis how |
630 many samples we | |
631 actually consumed */ | |
632 } | |
1834
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
633 } // from else, packetout ok |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
634 } // while len |
3f8da9408f04
Now oggvorbis decoding properly works, but a/v sync is bad.
atmos4
parents:
1831
diff
changeset
|
635 } // outer while len |
1828 | 636 if(ogg_page_eos(&sh_audio->ov->og)) |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
637 mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: End of Stream reached!\n"); // FIXME clearup decoder, notify mplayer - atmos |
1828 | 638 |
1837
9fd8b5e0b864
ogg/vorbis stuff cleanup, buffering fixes, printf->mp_msg
arpi
parents:
1834
diff
changeset
|
639 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"\n[len: %d ]\n",len); |
1828 | 640 |
641 break; | |
1831 | 642 } |
1830 | 643 #endif |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
644 case AFM_PCM: // AVI PCM |
1058 | 645 len=demux_read_data(sh_audio->ds,buf,minlen); |
401 | 646 break; |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
647 case AFM_DVDPCM: // DVD PCM |
401 | 648 { int j; |
746 | 649 len=demux_read_data(sh_audio->ds,buf,minlen); |
291 | 650 //if(i&1){ printf("Warning! pcm_audio_size&1 !=0 (%d)\n",i);i&=~1; } |
746 | 651 // swap endian: |
291 | 652 for(j=0;j<len;j+=2){ |
653 char x=buf[j]; | |
654 buf[j]=buf[j+1]; | |
655 buf[j+1]=x; | |
656 } | |
657 break; | |
658 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
659 case AFM_ALAW: // aLaw decoder |
746 | 660 { int l=demux_read_data(sh_audio->ds,buf,minlen/2); |
291 | 661 unsigned short *d=(unsigned short *) buf; |
662 unsigned char *s=buf; | |
663 len=2*l; | |
758 | 664 if(sh_audio->format==6){ |
665 // aLaw | |
883 | 666 while(l>0){ --l; d[l]=alaw2short[s[l]]; } |
758 | 667 } else { |
668 // uLaw | |
883 | 669 while(l>0){ --l; d[l]=ulaw2short[s[l]]; } |
291 | 670 } |
671 break; | |
672 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
673 case AFM_GSM: // MS-GSM decoder |
291 | 674 { unsigned char buf[65]; // 65 bytes / frame |
746 | 675 if(demux_read_data(sh_audio->ds,buf,65)!=65) break; // EOF |
676 XA_MSGSM_Decoder(buf,(unsigned short *) buf); // decodes 65 byte -> 320 short | |
677 // XA_GSM_Decoder(buf,(unsigned short *) &sh_audio->a_buffer[sh_audio->a_buffer_len]); // decodes 33 byte -> 160 short | |
678 len=2*320; | |
291 | 679 break; |
680 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
681 case AFM_AC3: // AC3 decoder |
291 | 682 //printf("{1:%d}",avi_header.idx_pos);fflush(stdout); |
683 if(!sh_audio->ac3_frame) sh_audio->ac3_frame=ac3_decode_frame(); | |
684 //printf("{2:%d}",avi_header.idx_pos);fflush(stdout); | |
685 if(sh_audio->ac3_frame){ | |
296 | 686 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
|
687 memcpy(buf,((ac3_frame_t*)sh_audio->ac3_frame)->audio_data,len); |
291 | 688 sh_audio->ac3_frame=NULL; |
689 } | |
690 //printf("{3:%d}",avi_header.idx_pos);fflush(stdout); | |
691 break; | |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
692 case AFM_HWAC3: // AC3 through SPDIF |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
693 if(demux_read_data(sh_audio->ds,sh_audio->ac3_frame, 6144) != 6144) |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
694 break; //EOF |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
695 ac3_iec958_build_burst(1536, 0x1F, 1, buf, sh_audio->ac3_frame); |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
696 len = 6144; |
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
697 break; |
1517
0e9c29538a86
Use USE_WIN32DLL define instead of ARCH_X86 to decide whether or not to compile
jkeil
parents:
1485
diff
changeset
|
698 #ifdef USE_WIN32DLL |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
699 case AFM_ACM: |
758 | 700 // len=sh_audio->audio_out_minsize; // optimal decoded fragment size |
701 // if(len<minlen) len=minlen; else | |
702 // if(len>maxlen) len=maxlen; | |
703 // len=acm_decode_audio(sh_audio,buf,len); | |
704 len=acm_decode_audio(sh_audio,buf,minlen,maxlen); | |
291 | 705 break; |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
1291
diff
changeset
|
706 #endif |
746 | 707 |
291 | 708 #ifdef USE_DIRECTSHOW |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
709 case AFM_DSHOW: // DirectShow |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
710 { int size_in=0; |
291 | 711 int size_out=0; |
712 int srcsize=DS_AudioDecoder_GetSrcSize(maxlen); | |
1567 | 713 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 | 714 if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!! |
715 if(sh_audio->a_in_buffer_len<srcsize){ | |
716 sh_audio->a_in_buffer_len+= | |
717 demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len], | |
718 srcsize-sh_audio->a_in_buffer_len); | |
719 } | |
720 DS_AudioDecoder_Convert(sh_audio->a_in_buffer,sh_audio->a_in_buffer_len, | |
721 buf,maxlen, &size_in,&size_out); | |
1567 | 722 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 | 723 if(size_in>=sh_audio->a_in_buffer_len){ |
724 sh_audio->a_in_buffer_len=0; | |
725 } else { | |
726 sh_audio->a_in_buffer_len-=size_in; | |
727 memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len); | |
728 } | |
729 len=size_out; | |
730 break; | |
731 } | |
732 #endif | |
733 } | |
734 return len; | |
735 } | |
736 | |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
737 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
|
738 switch(sh_audio->codec->driver){ |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
739 case AFM_MPEG: |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
740 MP3_DecodeFrame(NULL,-2); // resync |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
741 MP3_DecodeFrame(NULL,-2); // resync |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
742 MP3_DecodeFrame(NULL,-2); // resync |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
743 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
|
744 #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
|
745 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
|
746 //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
|
747 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
|
748 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
|
749 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
|
750 #endif |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
751 case AFM_AC3: |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
752 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
|
753 // 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
|
754 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
|
755 // if(verbose) printf(" OK!\n"); |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
756 break; |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
757 case AFM_ACM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
758 case AFM_DSHOW: |
1528
a444bd456fcc
ac3/spdif patch by German Gomez Garcia <german@piraos.com>
arpi
parents:
1517
diff
changeset
|
759 case AFM_HWAC3: |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
760 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
|
761 break; |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
762 } |
1408 | 763 |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
764 } |
291 | 765 |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
766 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
|
767 switch(sh_audio->codec->driver){ |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
768 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
|
769 case AFM_AC3: sh_audio->ac3_frame=ac3_decode_frame();break; // skip AC3 frame |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
770 case AFM_ACM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
771 case AFM_DSHOW: { |
1408 | 772 int skip=sh_audio->wf->nBlockAlign; |
773 if(skip<16){ | |
774 skip=(sh_audio->wf->nAvgBytesPerSec/16)&(~7); | |
775 if(skip<16) skip=16; | |
776 } | |
777 demux_read_data(sh_audio->ds,NULL,skip); | |
778 break; | |
779 } | |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
780 case AFM_PCM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
781 case AFM_DVDPCM: |
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1408
diff
changeset
|
782 case AFM_ALAW: { |
1408 | 783 int skip=sh_audio->i_bps/16; |
784 skip=skip&(~3); | |
785 demux_read_data(sh_audio->ds,NULL,skip); | |
786 break; | |
787 } | |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
788 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
|
789 } |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1320
diff
changeset
|
790 } |