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