Mercurial > libavcodec.hg
annotate libfaad.c @ 7744:7477cbdacb20 libavcodec
Fix lossless jpeg encoder to comply to spec and store full redundant
residuals, Note this does not change RGB32 as we need to check this
against some decoder that supports it.
| author | michael |
|---|---|
| date | Sat, 30 Aug 2008 20:39:12 +0000 |
| parents | 85ab7655ad4d |
| children | 4525dcd81357 |
| rev | line source |
|---|---|
| 1245 | 1 /* |
| 2 * Faad decoder | |
| 3 * Copyright (c) 2003 Zdenek Kabelac. | |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
4 * Copyright (c) 2004 Thomas Raivio. |
| 1245 | 5 * |
|
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3164
diff
changeset
|
6 * This file is part of FFmpeg. |
|
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3164
diff
changeset
|
7 * |
|
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3164
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
| 1245 | 9 * modify it under the terms of the GNU Lesser General Public |
| 10 * License as published by the Free Software Foundation; either | |
|
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3164
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
| 1245 | 12 * |
|
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3164
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
| 1245 | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 16 * Lesser General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU Lesser General Public | |
|
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3164
diff
changeset
|
19 * License along with FFmpeg; if not, write to the Free Software |
|
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2979
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 1245 | 21 */ |
| 22 | |
| 23 /** | |
| 24 * @file faad.c | |
| 25 * AAC decoder. | |
| 26 * | |
| 27 * still a bit unfinished - but it plays something | |
| 28 */ | |
| 29 | |
| 30 #include "avcodec.h" | |
| 31 #include "faad.h" | |
| 32 | |
|
2061
c28b03fea50f
Building with faad2-cvs fix by ("Steven M. Schultz" <sms at 2bsd dot com>)
michael
parents:
2059
diff
changeset
|
33 #ifndef FAADAPI |
|
c28b03fea50f
Building with faad2-cvs fix by ("Steven M. Schultz" <sms at 2bsd dot com>)
michael
parents:
2059
diff
changeset
|
34 #define FAADAPI |
|
c28b03fea50f
Building with faad2-cvs fix by ("Steven M. Schultz" <sms at 2bsd dot com>)
michael
parents:
2059
diff
changeset
|
35 #endif |
|
c28b03fea50f
Building with faad2-cvs fix by ("Steven M. Schultz" <sms at 2bsd dot com>)
michael
parents:
2059
diff
changeset
|
36 |
| 1245 | 37 /* |
|
4336
b7caa9237018
Rename variables: faad --> libfaad, faac --> libfaac, faadbin --> libfaadbin
diego
parents:
4163
diff
changeset
|
38 * when CONFIG_LIBFAADBIN is defined the libfaad will be opened at runtime |
| 1245 | 39 */ |
|
4336
b7caa9237018
Rename variables: faad --> libfaad, faac --> libfaac, faadbin --> libfaadbin
diego
parents:
4163
diff
changeset
|
40 //#undef CONFIG_LIBFAADBIN |
|
b7caa9237018
Rename variables: faad --> libfaad, faac --> libfaac, faadbin --> libfaadbin
diego
parents:
4163
diff
changeset
|
41 //#define CONFIG_LIBFAADBIN |
| 1245 | 42 |
|
4336
b7caa9237018
Rename variables: faad --> libfaad, faac --> libfaac, faadbin --> libfaadbin
diego
parents:
4163
diff
changeset
|
43 #ifdef CONFIG_LIBFAADBIN |
| 1245 | 44 #include <dlfcn.h> |
| 6174 | 45 static const char* libfaadname = "libfaad.so"; |
| 1245 | 46 #else |
| 47 #define dlopen(a) | |
| 48 #define dlclose(a) | |
| 49 #endif | |
| 50 | |
| 51 typedef struct { | |
| 2979 | 52 void* handle; /* dlopen handle */ |
| 53 void* faac_handle; /* FAAD library handle */ | |
| 1245 | 54 int sample_size; |
| 3097 | 55 int init; |
| 1245 | 56 |
| 57 /* faad calls */ | |
| 58 faacDecHandle FAADAPI (*faacDecOpen)(void); | |
| 59 faacDecConfigurationPtr FAADAPI (*faacDecGetCurrentConfiguration)(faacDecHandle hDecoder); | |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
60 #ifndef FAAD2_VERSION |
| 6175 | 61 int FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder, |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
62 faacDecConfigurationPtr config); |
| 6175 | 63 int FAADAPI (*faacDecInit)(faacDecHandle hDecoder, |
| 64 unsigned char *buffer, | |
| 65 unsigned long *samplerate, | |
| 66 unsigned long *channels); | |
| 67 int FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer, | |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
68 unsigned long SizeOfDecoderSpecificInfo, |
|
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
69 unsigned long *samplerate, unsigned long *channels); |
| 6175 | 70 int FAADAPI (*faacDecDecode)(faacDecHandle hDecoder, |
| 71 unsigned char *buffer, | |
| 72 unsigned long *bytesconsumed, | |
| 73 short *sample_buffer, | |
| 74 unsigned long *samples); | |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
75 #else |
| 6175 | 76 unsigned char FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder, |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
77 faacDecConfigurationPtr config); |
| 6175 | 78 long FAADAPI (*faacDecInit)(faacDecHandle hDecoder, |
| 79 unsigned char *buffer, | |
| 80 unsigned long buffer_size, | |
| 81 unsigned long *samplerate, | |
| 82 unsigned char *channels); | |
| 83 char FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer, | |
| 1245 | 84 unsigned long SizeOfDecoderSpecificInfo, |
| 85 unsigned long *samplerate, unsigned char *channels); | |
| 6175 | 86 void *FAADAPI (*faacDecDecode)(faacDecHandle hDecoder, |
| 87 faacDecFrameInfo *hInfo, | |
| 88 unsigned char *buffer, | |
| 89 unsigned long buffer_size); | |
| 90 char* FAADAPI (*faacDecGetErrorMessage)(unsigned char errcode); | |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
91 #endif |
| 2967 | 92 |
| 1245 | 93 void FAADAPI (*faacDecClose)(faacDecHandle hDecoder); |
| 2967 | 94 |
| 95 | |
| 1245 | 96 } FAACContext; |
| 97 | |
| 98 static const unsigned long faac_srates[] = | |
| 99 { | |
| 100 96000, 88200, 64000, 48000, 44100, 32000, | |
| 101 24000, 22050, 16000, 12000, 11025, 8000 | |
| 102 }; | |
| 103 | |
| 6119 | 104 static void channel_setup(AVCodecContext *avctx) |
| 105 { | |
| 106 #ifdef FAAD2_VERSION | |
| 107 FAACContext *s = avctx->priv_data; | |
| 108 if (avctx->request_channels > 0 && avctx->request_channels == 2 && | |
| 6175 | 109 avctx->request_channels < avctx->channels) { |
| 6119 | 110 faacDecConfigurationPtr faac_cfg; |
| 111 avctx->channels = 2; | |
| 112 faac_cfg = s->faacDecGetCurrentConfiguration(s->faac_handle); | |
| 113 faac_cfg->downMatrix = 1; | |
| 114 s->faacDecSetConfiguration(s->faac_handle, faac_cfg); | |
| 115 } | |
| 116 #endif | |
| 117 } | |
| 118 | |
| 1245 | 119 static int faac_init_mp4(AVCodecContext *avctx) |
| 120 { | |
| 4827 | 121 FAACContext *s = avctx->priv_data; |
| 1245 | 122 unsigned long samplerate; |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
123 #ifndef FAAD2_VERSION |
|
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
124 unsigned long channels; |
|
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
125 #else |
| 1245 | 126 unsigned char channels; |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
127 #endif |
| 1245 | 128 int r = 0; |
| 129 | |
| 3097 | 130 if (avctx->extradata){ |
| 2979 | 131 r = s->faacDecInit2(s->faac_handle, (uint8_t*) avctx->extradata, |
| 132 avctx->extradata_size, | |
| 133 &samplerate, &channels); | |
| 3097 | 134 if (r < 0){ |
| 135 av_log(avctx, AV_LOG_ERROR, | |
| 136 "faacDecInit2 failed r:%d sr:%ld ch:%ld s:%d\n", | |
| 137 r, samplerate, (long)channels, avctx->extradata_size); | |
| 138 } else { | |
| 139 avctx->sample_rate = samplerate; | |
| 140 avctx->channels = channels; | |
| 6119 | 141 channel_setup(avctx); |
| 3097 | 142 s->init = 1; |
| 143 } | |
| 144 } | |
|
2059
ad972ab280bc
sample_rate and channels in aac audio patch by (Luca Abeni <lucabe72 at email dot it>)
michael
parents:
1929
diff
changeset
|
145 |
| 1245 | 146 return r; |
| 147 } | |
| 148 | |
| 149 static int faac_decode_frame(AVCodecContext *avctx, | |
| 150 void *data, int *data_size, | |
| 151 uint8_t *buf, int buf_size) | |
| 152 { | |
| 4827 | 153 FAACContext *s = avctx->priv_data; |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
154 #ifndef FAAD2_VERSION |
|
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
155 unsigned long bytesconsumed; |
|
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
156 short *sample_buffer = NULL; |
|
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
157 unsigned long samples; |
|
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
158 int out; |
|
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
159 #else |
| 1245 | 160 faacDecFrameInfo frame_info; |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
161 void *out; |
|
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
162 #endif |
|
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
163 if(buf_size == 0) |
| 2979 | 164 return 0; |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
165 #ifndef FAAD2_VERSION |
| 2967 | 166 out = s->faacDecDecode(s->faac_handle, |
| 167 (unsigned char*)buf, | |
| 168 &bytesconsumed, | |
| 169 data, | |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
170 &samples); |
|
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
171 samples *= s->sample_size; |
|
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
172 if (data_size) |
| 2979 | 173 *data_size = samples; |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
174 return (buf_size < (int)bytesconsumed) |
| 2979 | 175 ? buf_size : (int)bytesconsumed; |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
176 #else |
| 2967 | 177 |
| 3097 | 178 if(!s->init){ |
| 179 unsigned long srate; | |
| 180 unsigned char channels; | |
| 3155 | 181 int r = s->faacDecInit(s->faac_handle, buf, buf_size, &srate, &channels); |
| 3097 | 182 if(r < 0){ |
|
6790
86ce080ea1e3
Do not use variable frame_info before its value is set.
cehoyos
parents:
6517
diff
changeset
|
183 av_log(avctx, AV_LOG_ERROR, "faac: codec init failed.\n"); |
|
3164
d771383fbcb8
Make faac_decode_frame return -1 on error and not 0 which avoids
mru
parents:
3155
diff
changeset
|
184 return -1; |
| 3097 | 185 } |
| 186 avctx->sample_rate = srate; | |
| 187 avctx->channels = channels; | |
| 6119 | 188 channel_setup(avctx); |
| 3097 | 189 s->init = 1; |
| 190 } | |
| 191 | |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
192 out = s->faacDecDecode(s->faac_handle, &frame_info, (unsigned char*)buf, (unsigned long)buf_size); |
| 1245 | 193 |
| 194 if (frame_info.error > 0) { | |
| 2979 | 195 av_log(avctx, AV_LOG_ERROR, "faac: frame decoding failed: %s\n", |
| 6175 | 196 s->faacDecGetErrorMessage(frame_info.error)); |
|
3164
d771383fbcb8
Make faac_decode_frame return -1 on error and not 0 which avoids
mru
parents:
3155
diff
changeset
|
197 return -1; |
| 1245 | 198 } |
| 7158 | 199 if (!avctx->frame_size) |
| 200 avctx->frame_size = frame_info.samples/avctx->channels; | |
| 1245 | 201 frame_info.samples *= s->sample_size; |
| 202 memcpy(data, out, frame_info.samples); // CHECKME - can we cheat this one | |
| 203 | |
| 204 if (data_size) | |
| 2979 | 205 *data_size = frame_info.samples; |
| 1245 | 206 |
| 207 return (buf_size < (int)frame_info.bytesconsumed) | |
| 2979 | 208 ? buf_size : (int)frame_info.bytesconsumed; |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
209 #endif |
| 1245 | 210 } |
| 211 | |
|
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6177
diff
changeset
|
212 static av_cold int faac_decode_end(AVCodecContext *avctx) |
| 1245 | 213 { |
| 4827 | 214 FAACContext *s = avctx->priv_data; |
| 1245 | 215 |
| 4753 | 216 s->faacDecClose(s->faac_handle); |
| 1245 | 217 |
| 218 dlclose(s->handle); | |
| 219 return 0; | |
| 220 } | |
| 221 | |
|
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6177
diff
changeset
|
222 static av_cold int faac_decode_init(AVCodecContext *avctx) |
| 1245 | 223 { |
| 4827 | 224 FAACContext *s = avctx->priv_data; |
| 1245 | 225 faacDecConfigurationPtr faac_cfg; |
| 226 | |
|
4336
b7caa9237018
Rename variables: faad --> libfaad, faac --> libfaac, faadbin --> libfaadbin
diego
parents:
4163
diff
changeset
|
227 #ifdef CONFIG_LIBFAADBIN |
| 1245 | 228 const char* err = 0; |
| 229 | |
| 230 s->handle = dlopen(libfaadname, RTLD_LAZY); | |
| 231 if (!s->handle) | |
| 232 { | |
| 2979 | 233 av_log(avctx, AV_LOG_ERROR, "FAAD library: %s could not be opened! \n%s\n", |
| 6175 | 234 libfaadname, dlerror()); |
| 1245 | 235 return -1; |
| 236 } | |
| 6177 | 237 |
| 238 #define dfaac(a) do { \ | |
| 239 const char* n = AV_STRINGIFY(faacDec ## a); \ | |
| 240 if (!err && !(s->faacDec ## a = dlsym(s->handle, n))) { \ | |
| 241 err = n; \ | |
| 242 } \ | |
| 243 } while(0) | |
|
4336
b7caa9237018
Rename variables: faad --> libfaad, faac --> libfaac, faadbin --> libfaadbin
diego
parents:
4163
diff
changeset
|
244 #else /* !CONFIG_LIBFAADBIN */ |
| 6177 | 245 #define dfaac(a) s->faacDec ## a = faacDec ## a |
|
4336
b7caa9237018
Rename variables: faad --> libfaad, faac --> libfaac, faadbin --> libfaadbin
diego
parents:
4163
diff
changeset
|
246 #endif /* CONFIG_LIBFAADBIN */ |
| 1245 | 247 |
| 6177 | 248 // resolve all needed function calls |
| 249 dfaac(Open); | |
| 250 dfaac(Close); | |
| 251 dfaac(GetCurrentConfiguration); | |
| 252 dfaac(SetConfiguration); | |
| 253 dfaac(Init); | |
| 254 dfaac(Init2); | |
| 255 dfaac(Decode); | |
| 256 #ifdef FAAD2_VERSION | |
| 257 dfaac(GetErrorMessage); | |
| 258 #endif | |
| 1245 | 259 |
| 6177 | 260 #undef dfaac |
| 1245 | 261 |
|
4336
b7caa9237018
Rename variables: faad --> libfaad, faac --> libfaac, faadbin --> libfaadbin
diego
parents:
4163
diff
changeset
|
262 #ifdef CONFIG_LIBFAADBIN |
| 1245 | 263 if (err) { |
| 264 dlclose(s->handle); | |
| 2979 | 265 av_log(avctx, AV_LOG_ERROR, "FAAD library: cannot resolve %s in %s!\n", |
| 6175 | 266 err, libfaadname); |
| 1245 | 267 return -1; |
| 268 } | |
| 269 #endif | |
| 270 | |
| 271 s->faac_handle = s->faacDecOpen(); | |
| 272 if (!s->faac_handle) { | |
|
1602
fdb8244da1e5
av_log patch(2 of ?) by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1245
diff
changeset
|
273 av_log(avctx, AV_LOG_ERROR, "FAAD library: cannot create handler!\n"); |
| 1245 | 274 faac_decode_end(avctx); |
| 275 return -1; | |
| 276 } | |
| 277 | |
| 278 | |
| 279 faac_cfg = s->faacDecGetCurrentConfiguration(s->faac_handle); | |
| 280 | |
| 281 if (faac_cfg) { | |
| 2979 | 282 switch (avctx->bits_per_sample) { |
| 283 case 8: av_log(avctx, AV_LOG_ERROR, "FAADlib unsupported bps %d\n", avctx->bits_per_sample); break; | |
| 284 default: | |
| 285 case 16: | |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
286 #ifdef FAAD2_VERSION |
| 2979 | 287 faac_cfg->outputFormat = FAAD_FMT_16BIT; |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
288 #endif |
| 2979 | 289 s->sample_size = 2; |
| 290 break; | |
| 291 case 24: | |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
292 #ifdef FAAD2_VERSION |
| 2979 | 293 faac_cfg->outputFormat = FAAD_FMT_24BIT; |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
294 #endif |
| 2979 | 295 s->sample_size = 3; |
| 296 break; | |
| 297 case 32: | |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
298 #ifdef FAAD2_VERSION |
| 2979 | 299 faac_cfg->outputFormat = FAAD_FMT_32BIT; |
|
1929
d4525c3065d0
aac decoding patch by ("Thomas Raivio" <tjraivio at cc dot hut dot fi>)
michael
parents:
1602
diff
changeset
|
300 #endif |
| 2979 | 301 s->sample_size = 4; |
| 302 break; | |
| 303 } | |
| 1245 | 304 |
| 2979 | 305 faac_cfg->defSampleRate = (!avctx->sample_rate) ? 44100 : avctx->sample_rate; |
| 306 faac_cfg->defObjectType = LC; | |
| 1245 | 307 } |
| 308 | |
| 309 s->faacDecSetConfiguration(s->faac_handle, faac_cfg); | |
| 310 | |
| 311 faac_init_mp4(avctx); | |
| 312 | |
| 6119 | 313 if(!s->init && avctx->channels > 0) |
| 314 channel_setup(avctx); | |
| 315 | |
|
7451
85ab7655ad4d
Modify all codecs to report their supported input and output sample format(s).
pross
parents:
7158
diff
changeset
|
316 avctx->sample_fmt = SAMPLE_FMT_S16; |
| 1245 | 317 return 0; |
| 318 } | |
| 319 | |
|
6819
43bede126ef6
missing codec long names by Stefano Sabatini, stefano.sabatini-lala poste it
diego
parents:
6790
diff
changeset
|
320 #define AAC_CODEC(id, name, long_name_) \ |
| 1245 | 321 AVCodec name ## _decoder = { \ |
| 322 #name, \ | |
| 323 CODEC_TYPE_AUDIO, \ | |
| 324 id, \ | |
| 325 sizeof(FAACContext), \ | |
| 326 faac_decode_init, \ | |
| 327 NULL, \ | |
| 328 faac_decode_end, \ | |
| 329 faac_decode_frame, \ | |
|
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6819
diff
changeset
|
330 .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ |
| 1245 | 331 } |
| 332 | |
| 333 // FIXME - raw AAC files - maybe just one entry will be enough | |
|
6819
43bede126ef6
missing codec long names by Stefano Sabatini, stefano.sabatini-lala poste it
diego
parents:
6790
diff
changeset
|
334 AAC_CODEC(CODEC_ID_AAC, libfaad, "libfaad AAC (Advanced Audio Codec)"); |
|
4163
1e8621844040
get rid of CODEC_ID_MPEG4AAC after next version bump, and change it to CODEC_ID_AAC where used
bcoudurier
parents:
3947
diff
changeset
|
335 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0) |
| 1245 | 336 // If it's mp4 file - usually embeded into Qt Mov |
|
6819
43bede126ef6
missing codec long names by Stefano Sabatini, stefano.sabatini-lala poste it
diego
parents:
6790
diff
changeset
|
337 AAC_CODEC(CODEC_ID_MPEG4AAC, mpeg4aac, "libfaad AAC (Advanced Audio Codec)"); |
|
4163
1e8621844040
get rid of CODEC_ID_MPEG4AAC after next version bump, and change it to CODEC_ID_AAC where used
bcoudurier
parents:
3947
diff
changeset
|
338 #endif |
| 1245 | 339 |
| 340 #undef AAC_CODEC |
