comparison libmpcodecs/ad_faad.c @ 32654:85f0d7406e07

Remove forked internal libfaad2 copy. The FFmpeg AAC decoder is default now and surpasses libfaad2 in all regards, so there is no longer a reason to keep a forked library copy.
author diego
date Sat, 01 Jan 2011 14:27:41 +0000
parents 34c4e6ff7b17
children a93891202051
comparison
equal deleted inserted replaced
32653:5f92bf78a2c2 32654:85f0d7406e07
21 */ 21 */
22 22
23 #include <stdio.h> 23 #include <stdio.h>
24 #include <stdlib.h> 24 #include <stdlib.h>
25 #include <unistd.h> 25 #include <unistd.h>
26 #include <faad.h>
26 27
27 #include "config.h" 28 #include "config.h"
28 #include "ad_internal.h" 29 #include "ad_internal.h"
29 #include "dec_audio.h" 30 #include "dec_audio.h"
30 #include "libaf/reorder_ch.h" 31 #include "libaf/reorder_ch.h"
37 "faad2", 38 "faad2",
38 "uses libfaad2" 39 "uses libfaad2"
39 }; 40 };
40 41
41 LIBAD_EXTERN(faad) 42 LIBAD_EXTERN(faad)
42
43 #ifndef CONFIG_FAAD_INTERNAL
44 #include <faad.h>
45 #else
46 #include "libfaad2/faad.h"
47 #endif
48 43
49 /* configure maximum supported channels, * 44 /* configure maximum supported channels, *
50 * this is theoretically max. 64 chans */ 45 * this is theoretically max. 64 chans */
51 #define FAAD_MAX_CHANNELS 8 46 #define FAAD_MAX_CHANNELS 8
52 #define FAAD_BUFFLEN (FAAD_MIN_STREAMSIZE*FAAD_MAX_CHANNELS) 47 #define FAAD_BUFFLEN (FAAD_MIN_STREAMSIZE*FAAD_MAX_CHANNELS)
130 if (!sh->a_in_buffer_len) { 125 if (!sh->a_in_buffer_len) {
131 // faad init will crash with 0 buffer length 126 // faad init will crash with 0 buffer length
132 mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Could not get audio data!\n"); 127 mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Could not get audio data!\n");
133 return 0; 128 return 0;
134 } 129 }
135 #if CONFIG_FAAD_INTERNAL
136 /* init the codec, look for LATM */
137 faac_init = faacDecInit(faac_hdec, sh->a_in_buffer,
138 sh->a_in_buffer_len, &faac_samplerate, &faac_channels,1);
139 if (faac_init < 0 && sh->a_in_buffer_len >= 3 && sh->format == mmioFOURCC('M', 'P', '4', 'L')) {
140 // working LATM not found at first try, look further on in stream
141 int i;
142
143 for (i = 0; i < 5; i++) {
144 pos = sh->a_in_buffer_len-3;
145 memmove(sh->a_in_buffer, &(sh->a_in_buffer[pos]), 3);
146 sh->a_in_buffer_len = 3;
147 sh->a_in_buffer_len += demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len],
148 sh->a_in_buffer_size - sh->a_in_buffer_len);
149 faac_init = faacDecInit(faac_hdec, sh->a_in_buffer,
150 sh->a_in_buffer_len, &faac_samplerate, &faac_channels,1);
151 if (faac_init >= 0) break;
152 }
153 }
154 #else
155 /* external faad does not have latm lookup support */ 130 /* external faad does not have latm lookup support */
156 faac_init = faacDecInit(faac_hdec, sh->a_in_buffer, 131 faac_init = faacDecInit(faac_hdec, sh->a_in_buffer,
157 sh->a_in_buffer_len, &faac_samplerate, &faac_channels); 132 sh->a_in_buffer_len, &faac_samplerate, &faac_channels);
158 #endif
159 133
160 if (faac_init < 0) { 134 if (faac_init < 0) {
161 pos = aac_probe(sh->a_in_buffer, sh->a_in_buffer_len); 135 pos = aac_probe(sh->a_in_buffer, sh->a_in_buffer_len);
162 if(pos) { 136 if(pos) {
163 sh->a_in_buffer_len -= pos; 137 sh->a_in_buffer_len -= pos;
167 sh->a_in_buffer_size - sh->a_in_buffer_len); 141 sh->a_in_buffer_size - sh->a_in_buffer_len);
168 pos = 0; 142 pos = 0;
169 } 143 }
170 144
171 /* init the codec */ 145 /* init the codec */
172 #if CONFIG_FAAD_INTERNAL
173 faac_init = faacDecInit(faac_hdec, sh->a_in_buffer,
174 sh->a_in_buffer_len, &faac_samplerate, &faac_channels,0);
175 #else
176 faac_init = faacDecInit(faac_hdec, sh->a_in_buffer, 146 faac_init = faacDecInit(faac_hdec, sh->a_in_buffer,
177 sh->a_in_buffer_len, &faac_samplerate, &faac_channels); 147 sh->a_in_buffer_len, &faac_samplerate, &faac_channels);
178 #endif
179 } 148 }
180 149
181 sh->a_in_buffer_len -= (faac_init > 0)?faac_init:0; // how many bytes init consumed 150 sh->a_in_buffer_len -= (faac_init > 0)?faac_init:0; // how many bytes init consumed
182 // XXX FIXME: shouldn't we memcpy() here in a_in_buffer ?? --A'rpi 151 // XXX FIXME: shouldn't we memcpy() here in a_in_buffer ?? --A'rpi
183 152