annotate dec_audio.c @ 1932:89e373eaf1b9

added ffmp3 #2
author gabucino
date Fri, 21 Sep 2001 22:34:38 +0000
parents 296208b47fd4
children 5216f108cb4f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1728d249c783 missing unistd.h (requires for off_t under freebsd)
arpi
parents: 1410
diff changeset
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
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
7 #include "mp_msg.h"
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
8
1058
cab5ba9ffc6c fixed AFMT_ stuff (inclue afmt.h)
arpi_esp
parents: 1038
diff changeset
9 #include "libao2/afmt.h"
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
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
ef5d1ab14218 using alaw.h instead of alaw.c
arpi_esp
parents: 758
diff changeset
30 #include "alaw.h"
ef5d1ab14218 using alaw.h instead of alaw.c
arpi_esp
parents: 758
diff changeset
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
36ed1692c0b8 video codec stuff moved to dec_video.c
arpi
parents: 1289
diff changeset
36 #ifdef USE_DIRECTSHOW
604
18496fdfd419 warnings killed
szabii
parents: 587
diff changeset
37 #include "loader/DirectShow/DS_AudioDec.h"
1291
36ed1692c0b8 video codec stuff moved to dec_video.c
arpi
parents: 1289
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
40 #ifdef HAVE_OGGVORBIS
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
41 /* XXX is math.h really needed? - atmos */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
42 #include <math.h>
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
43 #include <vorbis/codec.h>
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
44 #endif
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
45
1927
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
46 #ifdef USE_LIBAVCODEC
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
47 #include "libavcodec/avcodec.h"
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
48 static AVCodec *lavc_codec=NULL;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
49 static AVCodecContext lavc_context;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
50 extern int avcodec_inited;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
51 #endif
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
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
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
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
3f490fad9bdf some code clanup (first step to libdemuxer)
arpi
parents: 1058
diff changeset
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
3f490fad9bdf some code clanup (first step to libdemuxer)
arpi
parents: 1058
diff changeset
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
3f490fad9bdf some code clanup (first step to libdemuxer)
arpi
parents: 1058
diff changeset
70 // MP3 decoder buffer callback:
3f490fad9bdf some code clanup (first step to libdemuxer)
arpi
parents: 1058
diff changeset
71 int mplayer_audio_read(char *buf,int size){
3f490fad9bdf some code clanup (first step to libdemuxer)
arpi
parents: 1058
diff changeset
72 int len;
3f490fad9bdf some code clanup (first step to libdemuxer)
arpi
parents: 1058
diff changeset
73 len=demux_read_data(dec_audio_sh->ds,buf,size);
3f490fad9bdf some code clanup (first step to libdemuxer)
arpi
parents: 1058
diff changeset
74 return len;
3f490fad9bdf some code clanup (first step to libdemuxer)
arpi
parents: 1058
diff changeset
75 }
3f490fad9bdf some code clanup (first step to libdemuxer)
arpi
parents: 1058
diff changeset
76
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
77 int init_audio(sh_audio_t *sh_audio){
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
78 int driver=sh_audio->codec->driver;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
79
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
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
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
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
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
86 sh_audio->samplerate=0;
401
835fac6382be DVD PCM audio support
arpi_esp
parents: 340
diff changeset
87 //sh_audio->pcm_bswap=0;
1529
81aa2d701ae0 o_bps changes for hwac3 driver
arpi
parents: 1528
diff changeset
88 sh_audio->o_bps=0;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
89
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
90 sh_audio->a_buffer_size=0;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
91 sh_audio->a_buffer=NULL;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
92
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
93 sh_audio->a_in_buffer_len=0;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
94
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
95 // setup required min. in/out buffer size:
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
96 sh_audio->audio_out_minsize=8192;// default size, maybe not enough for Win32/ACM
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
97
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
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
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
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
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
104 // Win32 ACM audio codec:
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
105 if(init_acm_audio_codec(sh_audio)){
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
106 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
107 sh_audio->channels=sh_audio->o_wf.nChannels;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
108 sh_audio->samplerate=sh_audio->o_wf.nSamplesPerSec;
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
109 // if(sh_audio->audio_out_minsize>16384) sh_audio->audio_out_minsize=16384;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
110 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
111 // if(sh_audio->a_buffer_size<sh_audio->audio_out_minsize+MAX_OUTBURST)
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
112 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
113 } else {
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
114 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Could not load/initialize Win32/ACM AUDIO codec (missing DLL file?)\n");
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
115 driver=0;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
116 }
1309
598e3047ce13 Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents: 1291
diff changeset
117 #endif
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
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
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
120 #ifndef USE_DIRECTSHOW
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
121 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Compiled without DirectShow support -> force nosound :(\n");
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
122 driver=0;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
123 #else
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
124 // Win32 DShow audio codec:
340
1f7c824033fb less, and more informal printfs
arpi_esp
parents: 303
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
127 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not load/initialize Win32/DirectShow AUDIO codec: %s\n",sh_audio->codec->dll);
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
128 driver=0;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
129 } else {
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
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
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
134 if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
135 sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
136 sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size);
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
137 sh_audio->a_in_buffer_len=0;
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
138 sh_audio->audio_out_minsize=16384;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
139 }
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
140 #endif
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
141 break;
1828
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
142 case AFM_VORBIS:
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
143 #ifndef HAVE_OGGVORBIS
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
144 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"OggVorbis audio codec disabled -> force nosound :(\n");
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
145 driver=0;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
146 #else
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
149 #endif
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
154 // PCM, aLaw
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
155 sh_audio->audio_out_minsize=2048;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
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
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
158 // Dolby AC3 audio:
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
159 sh_audio->audio_out_minsize=4*256*6;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
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
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
167 // MS-GSM audio codec:
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
168 sh_audio->audio_out_minsize=4*320;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
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
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
171 // MPEG Audio:
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
172 sh_audio->audio_out_minsize=4608;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
173 break;
1927
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
174 case AFM_FFMPEG:
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
175 #ifndef USE_LIBAVCODEC
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
176 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"MPlayer was compiled WITHOUT libavcodec support!\n");
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
177 return 0;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
178 #else
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
179 // FFmpeg Audio:
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
180 sh_audio->audio_out_minsize=AVCODEC_MAX_AUDIO_FRAME_SIZE;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
181 break;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
182 #endif
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
183 }
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
184
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
185 if(!driver) return 0;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
186
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
187 // allocate audio out buffer:
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
188 sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; // worst case calc.
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
189
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
190 mp_msg(MSGT_DECAUDIO,MSGL_V,"dec_audio: Allocating %d + %d = %d bytes for output buffer\n",
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
191 sh_audio->audio_out_minsize,MAX_OUTBURST,sh_audio->a_buffer_size);
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
192
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
193 sh_audio->a_buffer=malloc(sh_audio->a_buffer_size);
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
194 if(!sh_audio->a_buffer){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
195 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Cannot allocate audio out buffer\n");
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
196 return 0;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
197 }
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
198 memset(sh_audio->a_buffer,0,sh_audio->a_buffer_size);
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
199 sh_audio->a_buffer_len=0;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
200
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
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
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
204 int ret=acm_decode_audio(sh_audio,sh_audio->a_buffer,4096,sh_audio->a_buffer_size);
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
205 if(ret<0){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
206 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"ACM decoding error: %d\n",ret);
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
207 driver=0;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
208 }
640
ef7249823af2 clicks/noise at start fixed
arpi_esp
parents: 604
diff changeset
209 sh_audio->a_buffer_len=ret;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
210 break;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
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
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
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
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
216 sh_audio->i_bps=h->nAvgBytesPerSec;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
217 sh_audio->channels=h->nChannels;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
218 sh_audio->samplerate=h->nSamplesPerSec;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
219 sh_audio->samplesize=(h->wBitsPerSample+7)/8;
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
220 switch(sh_audio->format){ // hardware formats:
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
221 case 0x6: sh_audio->sample_format=AFMT_A_LAW;break;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
222 case 0x7: sh_audio->sample_format=AFMT_MU_LAW;break;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
223 case 0x11: sh_audio->sample_format=AFMT_IMA_ADPCM;break;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
224 case 0x50: sh_audio->sample_format=AFMT_MPEG;break;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
225 // case 0x2000: sh_audio->sample_format=AFMT_AC3;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
226 default: sh_audio->sample_format=(sh_audio->samplesize==2)?AFMT_S16_LE:AFMT_U8;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
227 }
401
835fac6382be DVD PCM audio support
arpi_esp
parents: 340
diff changeset
228 break;
835fac6382be DVD PCM audio support
arpi_esp
parents: 340
diff changeset
229 }
1410
eda16e490ae7 using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents: 1408
diff changeset
230 case AFM_DVDPCM: {
401
835fac6382be DVD PCM audio support
arpi_esp
parents: 340
diff changeset
231 // DVD PCM Audio:
835fac6382be DVD PCM audio support
arpi_esp
parents: 340
diff changeset
232 sh_audio->channels=2;
835fac6382be DVD PCM audio support
arpi_esp
parents: 340
diff changeset
233 sh_audio->samplerate=48000;
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
234 sh_audio->i_bps=2*2*48000;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
235 // sh_audio->pcm_bswap=1;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
236 break;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
237 }
1410
eda16e490ae7 using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents: 1408
diff changeset
238 case AFM_AC3: {
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
239 // Dolby AC3 audio:
1289
3f490fad9bdf some code clanup (first step to libdemuxer)
arpi
parents: 1058
diff changeset
240 dec_audio_sh=sh_audio; // save sh_audio for the callback:
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
241 ac3_config.fill_buffer_callback = ac3_fill_buffer;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
242 ac3_config.num_output_ch = 2;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
243 ac3_config.flags = 0;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
244 #ifdef HAVE_MMX
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
245 ac3_config.flags |= AC3_MMX_ENABLE;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
246 #endif
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
247 #ifdef HAVE_3DNOW
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
248 ac3_config.flags |= AC3_3DNOW_ENABLE;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
249 #endif
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
250 ac3_init();
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
251 sh_audio->ac3_frame = ac3_decode_frame();
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
252 if(sh_audio->ac3_frame){
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
253 ac3_frame_t* fr=(ac3_frame_t*)sh_audio->ac3_frame;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
254 sh_audio->samplerate=fr->sampling_rate;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
255 sh_audio->channels=2;
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
256 // 1 frame: 6*256 samples 1 sec: sh_audio->samplerate samples
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
257 //sh_audio->i_bps=fr->frame_size*fr->sampling_rate/(6*256);
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
258 sh_audio->i_bps=fr->bit_rate*(1000/8);
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
259 } else {
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
260 driver=0; // bad frame -> disable audio
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
261 }
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
262 break;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
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
81aa2d701ae0 o_bps changes for hwac3 driver
arpi
parents: 1528
diff changeset
268 len = ds_get_packet(sh_audio->ds, &buffer); // maybe 1 packet is not enough,
81aa2d701ae0 o_bps changes for hwac3 driver
arpi
parents: 1528
diff changeset
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
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
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
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
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
81aa2d701ae0 o_bps changes for hwac3 driver
arpi
parents: 1528
diff changeset
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
81aa2d701ae0 o_bps changes for hwac3 driver
arpi
parents: 1528
diff changeset
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
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
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
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
292 sh_audio->i_bps=sh_audio->channels*sh_audio->samplerate;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
293 break;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
294 }
1927
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
295 #ifdef USE_LIBAVCODEC
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
296 case AFM_FFMPEG: {
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
297 int x;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
298 mp_msg(MSGT_DECAUDIO,MSGL_V,"FFmpeg's libavcodec audio codec\n");
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
299 if(!avcodec_inited){
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
300 avcodec_init();
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
301 avcodec_register_all();
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
302 avcodec_inited=1;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
303 }
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
304 lavc_codec = (AVCodec *)avcodec_find_decoder_by_name(sh_audio->codec->dll);
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
305 if(!lavc_codec){
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
306 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"Can't find codec '%s' in libavcodec...\n",sh_audio->codec->dll);
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
307 return 0;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
308 }
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
309 memset(&lavc_context, 0, sizeof(lavc_context));
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
310 /* open it */
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
311 if (avcodec_open(&lavc_context, lavc_codec) < 0) {
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
312 mp_msg(MSGT_DECAUDIO,MSGL_ERR, "could not open codec\n");
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
313 return 0;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
314 }
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
315 mp_msg(MSGT_DECAUDIO,MSGL_V,"INFO: libavcodec init OK!\n");
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
316
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
317 // Decode at least 1 byte: (to get header filled)
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
318 x=decode_audio(sh_audio,sh_audio->a_buffer,1,sh_audio->a_buffer_size);
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
319 if(x>0) sh_audio->a_buffer_len=x;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
320
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
321 #if 1
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
322 sh_audio->channels=lavc_context.channels;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
323 sh_audio->samplerate=lavc_context.sample_rate;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
324 sh_audio->i_bps=lavc_context.bit_rate/8;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
325 #else
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
326 sh_audio->channels=sh_audio->wf->nChannels;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
327 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
328 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
329 #endif
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
330 break;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
331 }
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
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
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
334 // MS-GSM audio codec:
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
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
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
338 // decodes 65 byte -> 320 short
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
339 // 1 sec: sh_audio->channels*sh_audio->samplerate samples
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
340 // 1 frame: 320 samples
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
341 sh_audio->i_bps=65*(sh_audio->channels*sh_audio->samplerate)/320; // 1:10
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
342 break;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
343 }
1410
eda16e490ae7 using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents: 1408
diff changeset
344 case AFM_MPEG: {
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
345 // MPEG Audio:
1289
3f490fad9bdf some code clanup (first step to libdemuxer)
arpi
parents: 1058
diff changeset
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
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
350 MP3_Init();
732
e14114170e01 applied 'fakemono' patch by Bryan Chan scorpio@acm.org
arpi_esp
parents: 640
diff changeset
351 #endif
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
352 MP3_samplerate=MP3_channels=0;
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
353 // printf("[\n");
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
354 sh_audio->a_buffer_len=MP3_DecodeFrame(sh_audio->a_buffer,-1);
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
355 // printf("]\n");
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
356 sh_audio->channels=2; // hack
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
357 sh_audio->samplerate=MP3_samplerate;
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
358 sh_audio->i_bps=MP3_bitrate*(1000/8);
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
359 break;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
360 }
1828
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
361 #ifdef HAVE_OGGVORBIS
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
362 case AFM_VORBIS: {
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
363 // OggVorbis Audio:
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
364 #if 0 /* just here for reference - atmos */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
365 ogg_sync_state oy; /* sync and verify incoming physical bitstream */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
366 ogg_stream_state os; /* take physical pages, weld into a logical
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
367 stream of packets */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
368 ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
369 ogg_packet op; /* one raw packet of data for decode */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
370
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
371 vorbis_info vi; /* struct that stores all the static vorbis bitstream
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
372 settings */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
373 vorbis_comment vc; /* struct that stores all the bitstream user comments */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
374 vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
375 vorbis_block vb; /* local working space for packet->PCM decode */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
376 #else
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
377 /* nix, nada, rien, nothing, nem, nüx */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
378 #endif
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
379
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
380 uint32_t hdrsizes[3];/* stores vorbis header sizes from AVI audio header,
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
381 maybe use ogg_uint32_t */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
382 //int i;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
383 int ret;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
384 char *buffer;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
385 ogg_packet hdr;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
386 //ov_struct_t *s=&sh_audio->ov;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
387 sh_audio->ov=malloc(sizeof(ov_struct_t));
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
388 //s=&sh_audio->ov;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
389
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
390 vorbis_info_init(&sh_audio->ov->vi);
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
391 vorbis_comment_init(&sh_audio->ov->vc);
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
396 /*for(i=12; i <= 40; i+=2) { // header bruteforce :)
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
397 memcpy(hdrsizes, ((unsigned char*)sh_audio->wf)+i, 3*sizeof(uint32_t));
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
398 printf("OggVorbis: Read header sizes (%i): %ld %ld %ld\n", i, hdrsizes[0], hdrsizes[1], hdrsizes[2]);
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
399 }*/
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
400
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
401 /* read headers */ // FIXME disable sound on errors here, we absolutely need this headers! - atmos
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
402 hdr.packet=NULL;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
403 hdr.b_o_s = 1; /* beginning of stream for first packet */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
404 hdr.bytes = hdrsizes[0];
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
405 hdr.packet = realloc(hdr.packet,hdr.bytes);
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
406 memcpy(hdr.packet,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t),hdr.bytes);
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
409 hdr.b_o_s = 0;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
410 hdr.bytes = hdrsizes[1];
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
411 hdr.packet = realloc(hdr.packet,hdr.bytes);
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
412 memcpy(hdr.packet,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t)+hdrsizes[0],hdr.bytes);
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
415 hdr.bytes = hdrsizes[2];
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
416 hdr.packet = realloc(hdr.packet,hdr.bytes);
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
417 memcpy(hdr.packet,((unsigned char*)sh_audio->wf)+2*sizeof(WAVEFORMATEX)+3*sizeof(uint32_t)+hdrsizes[0]+hdrsizes[1],hdr.bytes);
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
420 hdr.bytes=0;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
421 hdr.packet = realloc(hdr.packet,hdr.bytes); /* free */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
422 /* done with the headers */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
423
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
424
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
425 /* Throw the comments plus a few lines about the bitstream we're
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
426 decoding */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
427 {
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
428 char **ptr=sh_audio->ov->vc.user_comments;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
431 ++ptr;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
435 }
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
436 sh_audio->channels=sh_audio->ov->vi.channels;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
437 sh_audio->samplerate=sh_audio->ov->vi.rate;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
438 sh_audio->i_bps=sh_audio->ov->vi.bitrate_nominal/8;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
439
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
442 // printf("]\n");
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
443
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
444 /* OK, got and parsed all three headers. Initialize the Vorbis
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
445 packet->PCM decoder. */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
446 vorbis_synthesis_init(&sh_audio->ov->vd,&sh_audio->ov->vi); /* central decode state */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
447 vorbis_block_init(&sh_audio->ov->vd,&sh_audio->ov->vb); /* local state for most of the decode
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
448 so multiple block decodes can
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
449 proceed in parallel. We could init
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
450 multiple vorbis_block structures
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
451 for vd here */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
452 //printf("OggVorbis: synthesis and block init done.\n");
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
453 ogg_sync_init(&sh_audio->ov->oy); /* Now we can read pages */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
454
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
455 while((ret = ogg_sync_pageout(&sh_audio->ov->oy,&sh_audio->ov->og))!=1) {
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
458 else
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
464 }
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
470
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
471 /* Get the serial number and set up the rest of decode. */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
472 /* serialno first; use it to set up a logical stream */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
473 ogg_stream_init(&sh_audio->ov->os,ogg_page_serialno(&sh_audio->ov->og));
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
476
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
477 break;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
478 }
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
479 #endif
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
480 }
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
481
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
482 if(!sh_audio->channels || !sh_audio->samplerate){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
483 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Unknown/missing audio format, using nosound\n");
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
484 driver=0;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
485 }
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
486
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
487 if(!driver){
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
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
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
490 return 0;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
491 }
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
492
1529
81aa2d701ae0 o_bps changes for hwac3 driver
arpi
parents: 1528
diff changeset
493 if(!sh_audio->o_bps)
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
494 sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize;
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
495 return driver;
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
496 }
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
497
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
498 // Audio decoding:
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
499
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
500 // Decode a single frame (mp3,acm etc) or 'minlen' bytes (pcm/alaw etc)
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
501 // buffer length is 'maxlen' bytes, it shouldn't be exceeded...
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
502
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
503 int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
504 int len=-1;
303
828ec81e0d64 codecs.conf support
arpi_esp
parents: 296
diff changeset
505 switch(sh_audio->codec->driver){
1927
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
506 #ifdef USE_LIBAVCODEC
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
507 case AFM_FFMPEG: {
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
508 unsigned char *start=NULL;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
509 int y;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
510 while(len<minlen){
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
511 int len2=0;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
512 int x=ds_get_packet(sh_audio->ds,&start);
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
513 if(x<=0) break; // error
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
514 y=avcodec_decode_audio(&lavc_context,buf,&len2,start,x);
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
515 if(y<0){ printf("lavc_audio: error\n");break; }
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
516 if(y<x) sh_audio->ds->buffer_pos+=y-x; // put back data (HACK!)
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
517 if(len2>0){
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
518 //len=len2;break;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
519 if(len<0) len=len2; else len+=len2;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
520 buf+=len2;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
521 }
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
522 mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"Decoded %d -> %d \n",y,len2);
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
523 }
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
524 }
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
525 break;
296208b47fd4 FFmpeg audio codecs support
arpi
parents: 1849
diff changeset
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
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
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
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
530 break;
1830
46347c4075da OOOPS, miaaing ifdef.
atmos4
parents: 1828
diff changeset
531 #ifdef HAVE_OGGVORBIS
1828
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
532 case AFM_VORBIS: { // OggVorbis
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
533 /* note: good minlen would be 4k or 8k IMHO - atmos */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
534 int ret;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
535 char *buffer;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
536 int bytes;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
537 int samples;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
575
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
576 /* we have a packet. Decode it */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
577
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
578 if(vorbis_synthesis(&sh_audio->ov->vb,&sh_audio->ov->op)==0) /* test for success! */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
579 vorbis_synthesis_blockin(&sh_audio->ov->vd,&sh_audio->ov->vb);
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
580
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
581 /* **pcm is a multichannel float vector. In stereo, for
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
582 example, pcm[0] is left, and pcm[1] is right. samples is
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
583 the size of each channel. Convert the float values
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
584 (-1.<=range<=1.) to whatever PCM format and write it out */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
585
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
586 while((samples=vorbis_synthesis_pcmout(&sh_audio->ov->vd,&pcm))>0){
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
587 int i,j;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
594 /* convert floats to 16 bit signed ints (host order) and
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
595 interleave */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
598 ogg_int16_t *ptr=convbuffer+i;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
599 float *mono=pcm[i];
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
600 for(j=0;j<bout;j++){
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
601 #if 1
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
602 int val=mono[j]*32767.f;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
603 #else /* optional dither */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
604 int val=mono[j]*32767.f+drand48()-0.5f;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
605 #endif
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
606 /* might as well guard against clipping */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
607 if(val>32767){
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
608 val=32767;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
609 clipflag=1;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
610 }
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
611 if(val<-32768){
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
612 val=-32768;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
613 clipflag=1;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
614 }
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
615 *ptr=val;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
616 ptr+=sh_audio->ov->vi.channels;
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
617 }
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
618 }
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
619
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
622
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
629 vorbis_synthesis_read(&sh_audio->ov->vd,bout); /* tell libvorbis how
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
630 many samples we
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
631 actually consumed */
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
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
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
640
60afe3421c04 OggVorbis support, ALPHA state!
atmos4
parents: 1567
diff changeset
641 break;
1831
57afd6a8ae78 Ehh colaCounter++
atmos4
parents: 1830
diff changeset
642 }
1830
46347c4075da OOOPS, miaaing ifdef.
atmos4
parents: 1828
diff changeset
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
cab5ba9ffc6c fixed AFMT_ stuff (inclue afmt.h)
arpi_esp
parents: 1038
diff changeset
645 len=demux_read_data(sh_audio->ds,buf,minlen);
401
835fac6382be DVD PCM audio support
arpi_esp
parents: 340
diff changeset
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
835fac6382be DVD PCM audio support
arpi_esp
parents: 340
diff changeset
648 { int j;
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
649 len=demux_read_data(sh_audio->ds,buf,minlen);
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
650 //if(i&1){ printf("Warning! pcm_audio_size&1 !=0 (%d)\n",i);i&=~1; }
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
651 // swap endian:
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
652 for(j=0;j<len;j+=2){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
653 char x=buf[j];
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
654 buf[j]=buf[j+1];
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
655 buf[j+1]=x;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
656 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
657 break;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
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
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
660 { int l=demux_read_data(sh_audio->ds,buf,minlen/2);
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
661 unsigned short *d=(unsigned short *) buf;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
662 unsigned char *s=buf;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
663 len=2*l;
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
664 if(sh_audio->format==6){
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
665 // aLaw
883
ef5d1ab14218 using alaw.h instead of alaw.c
arpi_esp
parents: 758
diff changeset
666 while(l>0){ --l; d[l]=alaw2short[s[l]]; }
758
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
667 } else {
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
668 // uLaw
883
ef5d1ab14218 using alaw.h instead of alaw.c
arpi_esp
parents: 758
diff changeset
669 while(l>0){ --l; d[l]=ulaw2short[s[l]]; }
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
670 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
671 break;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
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
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
674 { unsigned char buf[65]; // 65 bytes / frame
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
675 if(demux_read_data(sh_audio->ds,buf,65)!=65) break; // EOF
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
676 XA_MSGSM_Decoder(buf,(unsigned short *) buf); // decodes 65 byte -> 320 short
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
677 // XA_GSM_Decoder(buf,(unsigned short *) &sh_audio->a_buffer[sh_audio->a_buffer_len]); // decodes 33 byte -> 160 short
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
678 len=2*320;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
679 break;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
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
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
682 //printf("{1:%d}",avi_header.idx_pos);fflush(stdout);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
683 if(!sh_audio->ac3_frame) sh_audio->ac3_frame=ac3_decode_frame();
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
684 //printf("{2:%d}",avi_header.idx_pos);fflush(stdout);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
685 if(sh_audio->ac3_frame){
296
c3d7a28a0d1a audio init moved to dec_audio.c
arpi_esp
parents: 291
diff changeset
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
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
688 sh_audio->ac3_frame=NULL;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
689 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
690 //printf("{3:%d}",avi_header.idx_pos);fflush(stdout);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
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
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
700 // len=sh_audio->audio_out_minsize; // optimal decoded fragment size
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
701 // if(len<minlen) len=minlen; else
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
702 // if(len>maxlen) len=maxlen;
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
703 // len=acm_decode_audio(sh_audio,buf,len);
5a92a5601666 better audio out buffering & sample_format added
arpi_esp
parents: 754
diff changeset
704 len=acm_decode_audio(sh_audio,buf,minlen,maxlen);
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
705 break;
1309
598e3047ce13 Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents: 1291
diff changeset
706 #endif
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 732
diff changeset
707
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
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
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
711 int size_out=0;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
712 int srcsize=DS_AudioDecoder_GetSrcSize(maxlen);
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
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
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
714 if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!!
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
715 if(sh_audio->a_in_buffer_len<srcsize){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
716 sh_audio->a_in_buffer_len+=
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
717 demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len],
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
718 srcsize-sh_audio->a_in_buffer_len);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
719 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
720 DS_AudioDecoder_Convert(sh_audio->a_in_buffer,sh_audio->a_in_buffer_len,
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
721 buf,maxlen, &size_in,&size_out);
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1529
diff changeset
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
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
723 if(size_in>=sh_audio->a_in_buffer_len){
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
724 sh_audio->a_in_buffer_len=0;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
725 } else {
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
726 sh_audio->a_in_buffer_len-=size_in;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
727 memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len);
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
728 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
729 len=size_out;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
730 break;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
731 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
732 #endif
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
733 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
734 return len;
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
735 }
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
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
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
763
1327
b12e1817bcc2 some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents: 1320
diff changeset
764 }
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents:
diff changeset
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
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
772 int skip=sh_audio->wf->nBlockAlign;
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
773 if(skip<16){
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
774 skip=(sh_audio->wf->nAvgBytesPerSec/16)&(~7);
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
775 if(skip<16) skip=16;
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
776 }
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
777 demux_read_data(sh_audio->ds,NULL,skip);
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
778 break;
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
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
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
783 int skip=sh_audio->i_bps/16;
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
784 skip=skip&(~3);
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
785 demux_read_data(sh_audio->ds,NULL,skip);
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
786 break;
71ad3e1ba014 some cleanup, asf/mpg seek precision improved
arpi
parents: 1327
diff changeset
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 }