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