50
void* handle; /* dlopen handle */
51
void* faac_handle; /* FAAD library handle */
50
void* handle; /* dlopen handle */
51
void* faac_handle; /* FAAD library handle */
57
56
faacDecHandle FAADAPI (*faacDecOpen)(void);
58
57
faacDecConfigurationPtr FAADAPI (*faacDecGetCurrentConfiguration)(faacDecHandle hDecoder);
59
58
#ifndef FAAD2_VERSION
60
int FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder,
59
int FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder,
61
60
faacDecConfigurationPtr config);
62
int FAADAPI (*faacDecInit)(faacDecHandle hDecoder,
63
unsigned char *buffer,
64
unsigned long *samplerate,
65
unsigned long *channels);
66
int FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer,
61
int FAADAPI (*faacDecInit)(faacDecHandle hDecoder,
62
unsigned char *buffer,
63
unsigned long *samplerate,
64
unsigned long *channels);
65
int FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer,
67
66
unsigned long SizeOfDecoderSpecificInfo,
68
67
unsigned long *samplerate, unsigned long *channels);
69
int FAADAPI (*faacDecDecode)(faacDecHandle hDecoder,
70
unsigned char *buffer,
71
unsigned long *bytesconsumed,
68
int FAADAPI (*faacDecDecode)(faacDecHandle hDecoder,
69
unsigned char *buffer,
70
unsigned long *bytesconsumed,
73
72
unsigned long *samples);
75
unsigned char FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder,
74
unsigned char FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder,
76
75
faacDecConfigurationPtr config);
77
long FAADAPI (*faacDecInit)(faacDecHandle hDecoder,
78
unsigned char *buffer,
79
unsigned long buffer_size,
80
unsigned long *samplerate,
81
unsigned char *channels);
82
char FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer,
76
long FAADAPI (*faacDecInit)(faacDecHandle hDecoder,
77
unsigned char *buffer,
78
unsigned long buffer_size,
79
unsigned long *samplerate,
80
unsigned char *channels);
81
char FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer,
83
82
unsigned long SizeOfDecoderSpecificInfo,
84
83
unsigned long *samplerate, unsigned char *channels);
85
void *FAADAPI (*faacDecDecode)(faacDecHandle hDecoder,
86
faacDecFrameInfo *hInfo,
87
unsigned char *buffer,
88
unsigned long buffer_size);
89
char* FAADAPI (*faacDecGetErrorMessage)(unsigned char errcode);
84
void *FAADAPI (*faacDecDecode)(faacDecHandle hDecoder,
85
faacDecFrameInfo *hInfo,
86
unsigned char *buffer,
87
unsigned long buffer_size);
88
char* FAADAPI (*faacDecGetErrorMessage)(unsigned char errcode);
92
91
void FAADAPI (*faacDecClose)(faacDecHandle hDecoder);
97
96
static const unsigned long faac_srates[] =
114
if (avctx->extradata)
115
r = s->faacDecInit2(s->faac_handle, (uint8_t*) avctx->extradata,
116
avctx->extradata_size,
117
&samplerate, &channels);
118
// else r = s->faacDecInit(s->faac_handle ... );
121
av_log(avctx, AV_LOG_ERROR, "faacDecInit2 failed r:%d sr:%ld ch:%ld s:%d\n",
122
r, samplerate, (long)channels, avctx->extradata_size);
123
avctx->sample_rate = samplerate;
124
avctx->channels = channels;
113
if (avctx->extradata){
114
r = s->faacDecInit2(s->faac_handle, (uint8_t*) avctx->extradata,
115
avctx->extradata_size,
116
&samplerate, &channels);
118
av_log(avctx, AV_LOG_ERROR,
119
"faacDecInit2 failed r:%d sr:%ld ch:%ld s:%d\n",
120
r, samplerate, (long)channels, avctx->extradata_size);
122
avctx->sample_rate = samplerate;
123
avctx->channels = channels;
143
145
if(buf_size == 0)
145
147
#ifndef FAAD2_VERSION
146
out = s->faacDecDecode(s->faac_handle,
148
out = s->faacDecDecode(s->faac_handle,
151
153
samples *= s->sample_size;
153
*data_size = samples;
155
*data_size = samples;
154
156
return (buf_size < (int)bytesconsumed)
155
? buf_size : (int)bytesconsumed;
157
? buf_size : (int)bytesconsumed;
162
unsigned char channels;
163
int r = faacDecInit(s->faac_handle, buf, buf_size, &srate, &channels);
165
av_log(avctx, AV_LOG_ERROR, "faac: codec init failed: %s\n",
166
s->faacDecGetErrorMessage(frame_info.error));
169
avctx->sample_rate = srate;
170
avctx->channels = channels;
158
174
out = s->faacDecDecode(s->faac_handle, &frame_info, (unsigned char*)buf, (unsigned long)buf_size);
160
176
if (frame_info.error > 0) {
161
av_log(avctx, AV_LOG_ERROR, "faac: frame decoding failed: %s\n",
162
s->faacDecGetErrorMessage(frame_info.error));
177
av_log(avctx, AV_LOG_ERROR, "faac: frame decoding failed: %s\n",
178
s->faacDecGetErrorMessage(frame_info.error));
209
225
#endif /* CONFIG_FAADBIN */
211
227
// resolve all needed function calls
212
dfaac(Open, (faacDecHandle FAADAPI (*)(void)));
213
dfaac(GetCurrentConfiguration, (faacDecConfigurationPtr
214
FAADAPI (*)(faacDecHandle)));
228
dfaac(Open, (faacDecHandle FAADAPI (*)(void)));
229
dfaac(GetCurrentConfiguration, (faacDecConfigurationPtr
230
FAADAPI (*)(faacDecHandle)));
215
231
#ifndef FAAD2_VERSION
216
dfaac(SetConfiguration, (int FAADAPI (*)(faacDecHandle,
217
faacDecConfigurationPtr)));
232
dfaac(SetConfiguration, (int FAADAPI (*)(faacDecHandle,
233
faacDecConfigurationPtr)));
219
dfaac(Init, (int FAADAPI (*)(faacDecHandle, unsigned char*,
220
unsigned long*, unsigned long*)));
235
dfaac(Init, (int FAADAPI (*)(faacDecHandle, unsigned char*,
236
unsigned long*, unsigned long*)));
221
237
dfaac(Init2, (int FAADAPI (*)(faacDecHandle, unsigned char*,
222
unsigned long, unsigned long*,
238
unsigned long, unsigned long*,
224
240
dfaac(Close, (void FAADAPI (*)(faacDecHandle hDecoder)));
225
dfaac(Decode, (int FAADAPI (*)(faacDecHandle, unsigned char*,
226
unsigned long*, short*, unsigned long*)));
241
dfaac(Decode, (int FAADAPI (*)(faacDecHandle, unsigned char*,
242
unsigned long*, short*, unsigned long*)));
228
dfaac(SetConfiguration, (unsigned char FAADAPI (*)(faacDecHandle,
229
faacDecConfigurationPtr)));
230
dfaac(Init, (long FAADAPI (*)(faacDecHandle, unsigned char*,
231
unsigned long, unsigned long*, unsigned char*)));
232
dfaac(Init2, (char FAADAPI (*)(faacDecHandle, unsigned char*,
233
unsigned long, unsigned long*,
235
dfaac(Decode, (void *FAADAPI (*)(faacDecHandle, faacDecFrameInfo*,
236
unsigned char*, unsigned long)));
237
dfaac(GetErrorMessage, (char* FAADAPI (*)(unsigned char)));
244
dfaac(SetConfiguration, (unsigned char FAADAPI (*)(faacDecHandle,
245
faacDecConfigurationPtr)));
246
dfaac(Init, (long FAADAPI (*)(faacDecHandle, unsigned char*,
247
unsigned long, unsigned long*, unsigned char*)));
248
dfaac(Init2, (char FAADAPI (*)(faacDecHandle, unsigned char*,
249
unsigned long, unsigned long*,
251
dfaac(Decode, (void *FAADAPI (*)(faacDecHandle, faacDecFrameInfo*,
252
unsigned char*, unsigned long)));
253
dfaac(GetErrorMessage, (char* FAADAPI (*)(unsigned char)));
260
276
faac_cfg = s->faacDecGetCurrentConfiguration(s->faac_handle);
263
switch (avctx->bits_per_sample) {
264
case 8: av_log(avctx, AV_LOG_ERROR, "FAADlib unsupported bps %d\n", avctx->bits_per_sample); break;
268
faac_cfg->outputFormat = FAAD_FMT_16BIT;
274
faac_cfg->outputFormat = FAAD_FMT_24BIT;
280
faac_cfg->outputFormat = FAAD_FMT_32BIT;
279
switch (avctx->bits_per_sample) {
280
case 8: av_log(avctx, AV_LOG_ERROR, "FAADlib unsupported bps %d\n", avctx->bits_per_sample); break;
284
faac_cfg->outputFormat = FAAD_FMT_16BIT;
290
faac_cfg->outputFormat = FAAD_FMT_24BIT;
296
faac_cfg->outputFormat = FAAD_FMT_32BIT;
286
faac_cfg->defSampleRate = (!avctx->sample_rate) ? 44100 : avctx->sample_rate;
287
faac_cfg->defObjectType = LC;
302
faac_cfg->defSampleRate = (!avctx->sample_rate) ? 44100 : avctx->sample_rate;
303
faac_cfg->defObjectType = LC;
290
306
s->faacDecSetConfiguration(s->faac_handle, faac_cfg);