You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

674 lines
22KB

  1. /*
  2. * ALAC (Apple Lossless Audio Codec) decoder
  3. * Copyright (c) 2005 David Hammerton
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * ALAC (Apple Lossless Audio Codec) decoder
  24. * @author 2005 David Hammerton
  25. * @see http://crazney.net/programs/itunes/alac.html
  26. *
  27. * Note: This decoder expects a 36- (0x24-)byte QuickTime atom to be
  28. * passed through the extradata[_size] fields. This atom is tacked onto
  29. * the end of an 'alac' stsd atom and has the following format:
  30. * bytes 0-3 atom size (0x24), big-endian
  31. * bytes 4-7 atom type ('alac', not the 'alac' tag from start of stsd)
  32. * bytes 8-35 data bytes needed by decoder
  33. *
  34. * Extradata:
  35. * 32bit size
  36. * 32bit tag (=alac)
  37. * 32bit zero?
  38. * 32bit max sample per frame
  39. * 8bit ?? (zero?)
  40. * 8bit sample size
  41. * 8bit history mult
  42. * 8bit initial history
  43. * 8bit kmodifier
  44. * 8bit channels?
  45. * 16bit ??
  46. * 32bit max coded frame size
  47. * 32bit bitrate?
  48. * 32bit samplerate
  49. */
  50. #include "avcodec.h"
  51. #include "get_bits.h"
  52. #include "bytestream.h"
  53. #include "unary.h"
  54. #include "mathops.h"
  55. #define ALAC_EXTRADATA_SIZE 36
  56. #define MAX_CHANNELS 2
  57. typedef struct {
  58. AVCodecContext *avctx;
  59. AVFrame frame;
  60. GetBitContext gb;
  61. int numchannels;
  62. /* buffers */
  63. int32_t *predicterror_buffer[MAX_CHANNELS];
  64. int32_t *outputsamples_buffer[MAX_CHANNELS];
  65. int32_t *extra_bits_buffer[MAX_CHANNELS];
  66. /* stuff from setinfo */
  67. uint32_t setinfo_max_samples_per_frame; /* 0x1000 = 4096 */ /* max samples per frame? */
  68. uint8_t setinfo_sample_size; /* 0x10 */
  69. uint8_t setinfo_rice_historymult; /* 0x28 */
  70. uint8_t setinfo_rice_initialhistory; /* 0x0a */
  71. uint8_t setinfo_rice_kmodifier; /* 0x0e */
  72. /* end setinfo stuff */
  73. int extra_bits; /**< number of extra bits beyond 16-bit */
  74. } ALACContext;
  75. static inline int decode_scalar(GetBitContext *gb, int k, int limit, int readsamplesize){
  76. /* read x - number of 1s before 0 represent the rice */
  77. int x = get_unary_0_9(gb);
  78. if (x > 8) { /* RICE THRESHOLD */
  79. /* use alternative encoding */
  80. x = get_bits(gb, readsamplesize);
  81. } else {
  82. if (k >= limit)
  83. k = limit;
  84. if (k != 1) {
  85. int extrabits = show_bits(gb, k);
  86. /* multiply x by 2^k - 1, as part of their strange algorithm */
  87. x = (x << k) - x;
  88. if (extrabits > 1) {
  89. x += extrabits - 1;
  90. skip_bits(gb, k);
  91. } else
  92. skip_bits(gb, k - 1);
  93. }
  94. }
  95. return x;
  96. }
  97. static int bastardized_rice_decompress(ALACContext *alac,
  98. int32_t *output_buffer,
  99. int output_size,
  100. int readsamplesize, /* arg_10 */
  101. int rice_initialhistory, /* arg424->b */
  102. int rice_kmodifier, /* arg424->d */
  103. int rice_historymult, /* arg424->c */
  104. int rice_kmodifier_mask /* arg424->e */
  105. )
  106. {
  107. int output_count;
  108. unsigned int history = rice_initialhistory;
  109. int sign_modifier = 0;
  110. for (output_count = 0; output_count < output_size; output_count++) {
  111. int32_t x;
  112. int32_t x_modified;
  113. int32_t final_val;
  114. /* standard rice encoding */
  115. int k; /* size of extra bits */
  116. if(get_bits_left(&alac->gb) <= 0)
  117. return -1;
  118. /* read k, that is bits as is */
  119. k = av_log2((history >> 9) + 3);
  120. x= decode_scalar(&alac->gb, k, rice_kmodifier, readsamplesize);
  121. x_modified = sign_modifier + x;
  122. final_val = (x_modified + 1) / 2;
  123. if (x_modified & 1) final_val *= -1;
  124. output_buffer[output_count] = final_val;
  125. sign_modifier = 0;
  126. /* now update the history */
  127. history += x_modified * rice_historymult
  128. - ((history * rice_historymult) >> 9);
  129. if (x_modified > 0xffff)
  130. history = 0xffff;
  131. /* special case: there may be compressed blocks of 0 */
  132. if ((history < 128) && (output_count+1 < output_size)) {
  133. int k;
  134. unsigned int block_size;
  135. sign_modifier = 1;
  136. k = 7 - av_log2(history) + ((history + 16) >> 6 /* / 64 */);
  137. block_size= decode_scalar(&alac->gb, k, rice_kmodifier, 16);
  138. if (block_size > 0) {
  139. if(block_size >= output_size - output_count){
  140. av_log(alac->avctx, AV_LOG_ERROR, "invalid zero block size of %d %d %d\n", block_size, output_size, output_count);
  141. block_size= output_size - output_count - 1;
  142. }
  143. memset(&output_buffer[output_count+1], 0, block_size * 4);
  144. output_count += block_size;
  145. }
  146. if (block_size > 0xffff)
  147. sign_modifier = 0;
  148. history = 0;
  149. }
  150. }
  151. return 0;
  152. }
  153. static inline int sign_only(int v)
  154. {
  155. return v ? FFSIGN(v) : 0;
  156. }
  157. static void predictor_decompress_fir_adapt(int32_t *error_buffer,
  158. int32_t *buffer_out,
  159. int output_size,
  160. int readsamplesize,
  161. int16_t *predictor_coef_table,
  162. int predictor_coef_num,
  163. int predictor_quantitization)
  164. {
  165. int i;
  166. /* first sample always copies */
  167. *buffer_out = *error_buffer;
  168. if (!predictor_coef_num) {
  169. if (output_size <= 1)
  170. return;
  171. memcpy(buffer_out+1, error_buffer+1, (output_size-1) * 4);
  172. return;
  173. }
  174. if (predictor_coef_num == 0x1f) { /* 11111 - max value of predictor_coef_num */
  175. /* second-best case scenario for fir decompression,
  176. * error describes a small difference from the previous sample only
  177. */
  178. if (output_size <= 1)
  179. return;
  180. for (i = 0; i < output_size - 1; i++) {
  181. int32_t prev_value;
  182. int32_t error_value;
  183. prev_value = buffer_out[i];
  184. error_value = error_buffer[i+1];
  185. buffer_out[i+1] =
  186. sign_extend((prev_value + error_value), readsamplesize);
  187. }
  188. return;
  189. }
  190. /* read warm-up samples */
  191. if (predictor_coef_num > 0)
  192. for (i = 0; i < predictor_coef_num; i++) {
  193. int32_t val;
  194. val = buffer_out[i] + error_buffer[i+1];
  195. val = sign_extend(val, readsamplesize);
  196. buffer_out[i+1] = val;
  197. }
  198. /* 4 and 8 are very common cases (the only ones i've seen). these
  199. * should be unrolled and optimized
  200. */
  201. /* general case */
  202. if (predictor_coef_num > 0) {
  203. for (i = predictor_coef_num + 1; i < output_size; i++) {
  204. int j;
  205. int sum = 0;
  206. int outval;
  207. int error_val = error_buffer[i];
  208. for (j = 0; j < predictor_coef_num; j++) {
  209. sum += (buffer_out[predictor_coef_num-j] - buffer_out[0]) *
  210. predictor_coef_table[j];
  211. }
  212. outval = (1 << (predictor_quantitization-1)) + sum;
  213. outval = outval >> predictor_quantitization;
  214. outval = outval + buffer_out[0] + error_val;
  215. outval = sign_extend(outval, readsamplesize);
  216. buffer_out[predictor_coef_num+1] = outval;
  217. if (error_val > 0) {
  218. int predictor_num = predictor_coef_num - 1;
  219. while (predictor_num >= 0 && error_val > 0) {
  220. int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];
  221. int sign = sign_only(val);
  222. predictor_coef_table[predictor_num] -= sign;
  223. val *= sign; /* absolute value */
  224. error_val -= ((val >> predictor_quantitization) *
  225. (predictor_coef_num - predictor_num));
  226. predictor_num--;
  227. }
  228. } else if (error_val < 0) {
  229. int predictor_num = predictor_coef_num - 1;
  230. while (predictor_num >= 0 && error_val < 0) {
  231. int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];
  232. int sign = - sign_only(val);
  233. predictor_coef_table[predictor_num] -= sign;
  234. val *= sign; /* neg value */
  235. error_val -= ((val >> predictor_quantitization) *
  236. (predictor_coef_num - predictor_num));
  237. predictor_num--;
  238. }
  239. }
  240. buffer_out++;
  241. }
  242. }
  243. }
  244. static void decorrelate_stereo(int32_t *buffer[MAX_CHANNELS],
  245. int numsamples, uint8_t interlacing_shift,
  246. uint8_t interlacing_leftweight)
  247. {
  248. int i;
  249. for (i = 0; i < numsamples; i++) {
  250. int32_t a, b;
  251. a = buffer[0][i];
  252. b = buffer[1][i];
  253. a -= (b * interlacing_leftweight) >> interlacing_shift;
  254. b += a;
  255. buffer[0][i] = b;
  256. buffer[1][i] = a;
  257. }
  258. }
  259. static void append_extra_bits(int32_t *buffer[MAX_CHANNELS],
  260. int32_t *extra_bits_buffer[MAX_CHANNELS],
  261. int extra_bits, int numchannels, int numsamples)
  262. {
  263. int i, ch;
  264. for (ch = 0; ch < numchannels; ch++)
  265. for (i = 0; i < numsamples; i++)
  266. buffer[ch][i] = (buffer[ch][i] << extra_bits) | extra_bits_buffer[ch][i];
  267. }
  268. static void interleave_stereo_16(int32_t *buffer[MAX_CHANNELS],
  269. int16_t *buffer_out, int numsamples)
  270. {
  271. int i;
  272. for (i = 0; i < numsamples; i++) {
  273. *buffer_out++ = buffer[0][i];
  274. *buffer_out++ = buffer[1][i];
  275. }
  276. }
  277. static void interleave_stereo_24(int32_t *buffer[MAX_CHANNELS],
  278. int32_t *buffer_out, int numsamples)
  279. {
  280. int i;
  281. for (i = 0; i < numsamples; i++) {
  282. *buffer_out++ = buffer[0][i] << 8;
  283. *buffer_out++ = buffer[1][i] << 8;
  284. }
  285. }
  286. static int alac_decode_frame(AVCodecContext *avctx, void *data,
  287. int *got_frame_ptr, AVPacket *avpkt)
  288. {
  289. const uint8_t *inbuffer = avpkt->data;
  290. int input_buffer_size = avpkt->size;
  291. ALACContext *alac = avctx->priv_data;
  292. int channels;
  293. unsigned int outputsamples;
  294. int hassize;
  295. unsigned int readsamplesize;
  296. int isnotcompressed;
  297. uint8_t interlacing_shift;
  298. uint8_t interlacing_leftweight;
  299. int i, ch, ret;
  300. init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
  301. channels = get_bits(&alac->gb, 3) + 1;
  302. if (channels != avctx->channels) {
  303. av_log(avctx, AV_LOG_ERROR, "frame header channel count mismatch\n");
  304. return AVERROR_INVALIDDATA;
  305. }
  306. /* 2^result = something to do with output waiting.
  307. * perhaps matters if we read > 1 frame in a pass?
  308. */
  309. skip_bits(&alac->gb, 4);
  310. skip_bits(&alac->gb, 12); /* unknown, skip 12 bits */
  311. /* the output sample size is stored soon */
  312. hassize = get_bits1(&alac->gb);
  313. alac->extra_bits = get_bits(&alac->gb, 2) << 3;
  314. /* whether the frame is compressed */
  315. isnotcompressed = get_bits1(&alac->gb);
  316. if (hassize) {
  317. /* now read the number of samples as a 32bit integer */
  318. outputsamples = get_bits_long(&alac->gb, 32);
  319. if(outputsamples > alac->setinfo_max_samples_per_frame){
  320. av_log(avctx, AV_LOG_ERROR, "outputsamples %d > %d\n", outputsamples, alac->setinfo_max_samples_per_frame);
  321. return -1;
  322. }
  323. } else
  324. outputsamples = alac->setinfo_max_samples_per_frame;
  325. /* get output buffer */
  326. if (outputsamples > INT32_MAX) {
  327. av_log(avctx, AV_LOG_ERROR, "unsupported block size: %u\n", outputsamples);
  328. return AVERROR_INVALIDDATA;
  329. }
  330. alac->frame.nb_samples = outputsamples;
  331. if ((ret = avctx->get_buffer(avctx, &alac->frame)) < 0) {
  332. av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
  333. return ret;
  334. }
  335. readsamplesize = alac->setinfo_sample_size - alac->extra_bits + channels - 1;
  336. if (readsamplesize > MIN_CACHE_BITS) {
  337. av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", readsamplesize);
  338. return -1;
  339. }
  340. if (!isnotcompressed) {
  341. /* so it is compressed */
  342. int16_t predictor_coef_table[MAX_CHANNELS][32];
  343. int predictor_coef_num[MAX_CHANNELS];
  344. int prediction_type[MAX_CHANNELS];
  345. int prediction_quantitization[MAX_CHANNELS];
  346. int ricemodifier[MAX_CHANNELS];
  347. interlacing_shift = get_bits(&alac->gb, 8);
  348. interlacing_leftweight = get_bits(&alac->gb, 8);
  349. for (ch = 0; ch < channels; ch++) {
  350. prediction_type[ch] = get_bits(&alac->gb, 4);
  351. prediction_quantitization[ch] = get_bits(&alac->gb, 4);
  352. ricemodifier[ch] = get_bits(&alac->gb, 3);
  353. predictor_coef_num[ch] = get_bits(&alac->gb, 5);
  354. /* read the predictor table */
  355. for (i = 0; i < predictor_coef_num[ch]; i++)
  356. predictor_coef_table[ch][i] = (int16_t)get_bits(&alac->gb, 16);
  357. }
  358. if (alac->extra_bits) {
  359. for (i = 0; i < outputsamples; i++) {
  360. if(get_bits_left(&alac->gb) <= 0)
  361. return -1;
  362. for (ch = 0; ch < channels; ch++)
  363. alac->extra_bits_buffer[ch][i] = get_bits(&alac->gb, alac->extra_bits);
  364. }
  365. }
  366. for (ch = 0; ch < channels; ch++) {
  367. int ret = bastardized_rice_decompress(alac,
  368. alac->predicterror_buffer[ch],
  369. outputsamples,
  370. readsamplesize,
  371. alac->setinfo_rice_initialhistory,
  372. alac->setinfo_rice_kmodifier,
  373. ricemodifier[ch] * alac->setinfo_rice_historymult / 4,
  374. (1 << alac->setinfo_rice_kmodifier) - 1);
  375. if(ret<0)
  376. return ret;
  377. if (prediction_type[ch] == 0) {
  378. /* adaptive fir */
  379. predictor_decompress_fir_adapt(alac->predicterror_buffer[ch],
  380. alac->outputsamples_buffer[ch],
  381. outputsamples,
  382. readsamplesize,
  383. predictor_coef_table[ch],
  384. predictor_coef_num[ch],
  385. prediction_quantitization[ch]);
  386. } else {
  387. av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type[ch]);
  388. /* I think the only other prediction type (or perhaps this is
  389. * just a boolean?) runs adaptive fir twice.. like:
  390. * predictor_decompress_fir_adapt(predictor_error, tempout, ...)
  391. * predictor_decompress_fir_adapt(predictor_error, outputsamples ...)
  392. * little strange..
  393. */
  394. }
  395. }
  396. } else {
  397. /* not compressed, easy case */
  398. for (i = 0; i < outputsamples; i++) {
  399. if(get_bits_left(&alac->gb) <= 0)
  400. return -1;
  401. for (ch = 0; ch < channels; ch++) {
  402. alac->outputsamples_buffer[ch][i] = get_sbits_long(&alac->gb,
  403. alac->setinfo_sample_size);
  404. }
  405. }
  406. alac->extra_bits = 0;
  407. interlacing_shift = 0;
  408. interlacing_leftweight = 0;
  409. }
  410. if (get_bits(&alac->gb, 3) != 7)
  411. av_log(avctx, AV_LOG_ERROR, "Error : Wrong End Of Frame\n");
  412. if (channels == 2 && interlacing_leftweight) {
  413. decorrelate_stereo(alac->outputsamples_buffer, outputsamples,
  414. interlacing_shift, interlacing_leftweight);
  415. }
  416. if (alac->extra_bits) {
  417. append_extra_bits(alac->outputsamples_buffer, alac->extra_bits_buffer,
  418. alac->extra_bits, alac->numchannels, outputsamples);
  419. }
  420. switch(alac->setinfo_sample_size) {
  421. case 16:
  422. if (channels == 2) {
  423. interleave_stereo_16(alac->outputsamples_buffer,
  424. (int16_t *)alac->frame.data[0], outputsamples);
  425. } else {
  426. int16_t *outbuffer = (int16_t *)alac->frame.data[0];
  427. for (i = 0; i < outputsamples; i++) {
  428. outbuffer[i] = alac->outputsamples_buffer[0][i];
  429. }
  430. }
  431. break;
  432. case 24:
  433. if (channels == 2) {
  434. interleave_stereo_24(alac->outputsamples_buffer,
  435. (int32_t *)alac->frame.data[0], outputsamples);
  436. } else {
  437. int32_t *outbuffer = (int32_t *)alac->frame.data[0];
  438. for (i = 0; i < outputsamples; i++)
  439. outbuffer[i] = alac->outputsamples_buffer[0][i] << 8;
  440. }
  441. break;
  442. }
  443. if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8)
  444. av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n", input_buffer_size * 8 - get_bits_count(&alac->gb));
  445. *got_frame_ptr = 1;
  446. *(AVFrame *)data = alac->frame;
  447. return input_buffer_size;
  448. }
  449. static av_cold int alac_decode_close(AVCodecContext *avctx)
  450. {
  451. ALACContext *alac = avctx->priv_data;
  452. int ch;
  453. for (ch = 0; ch < alac->numchannels; ch++) {
  454. av_freep(&alac->predicterror_buffer[ch]);
  455. av_freep(&alac->outputsamples_buffer[ch]);
  456. av_freep(&alac->extra_bits_buffer[ch]);
  457. }
  458. return 0;
  459. }
  460. static int allocate_buffers(ALACContext *alac)
  461. {
  462. int ch;
  463. for (ch = 0; ch < alac->numchannels; ch++) {
  464. int buf_size = alac->setinfo_max_samples_per_frame * sizeof(int32_t);
  465. FF_ALLOC_OR_GOTO(alac->avctx, alac->predicterror_buffer[ch],
  466. buf_size, buf_alloc_fail);
  467. FF_ALLOC_OR_GOTO(alac->avctx, alac->outputsamples_buffer[ch],
  468. buf_size, buf_alloc_fail);
  469. FF_ALLOC_OR_GOTO(alac->avctx, alac->extra_bits_buffer[ch],
  470. buf_size, buf_alloc_fail);
  471. }
  472. return 0;
  473. buf_alloc_fail:
  474. alac_decode_close(alac->avctx);
  475. return AVERROR(ENOMEM);
  476. }
  477. static int alac_set_info(ALACContext *alac)
  478. {
  479. const unsigned char *ptr = alac->avctx->extradata;
  480. ptr += 4; /* size */
  481. ptr += 4; /* alac */
  482. ptr += 4; /* 0 ? */
  483. if(AV_RB32(ptr) >= UINT_MAX/4){
  484. av_log(alac->avctx, AV_LOG_ERROR, "setinfo_max_samples_per_frame too large\n");
  485. return -1;
  486. }
  487. /* buffer size / 2 ? */
  488. alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr);
  489. ptr++; /* ??? */
  490. alac->setinfo_sample_size = *ptr++;
  491. alac->setinfo_rice_historymult = *ptr++;
  492. alac->setinfo_rice_initialhistory = *ptr++;
  493. alac->setinfo_rice_kmodifier = *ptr++;
  494. alac->numchannels = *ptr++;
  495. bytestream_get_be16(&ptr); /* ??? */
  496. bytestream_get_be32(&ptr); /* max coded frame size */
  497. bytestream_get_be32(&ptr); /* bitrate ? */
  498. bytestream_get_be32(&ptr); /* samplerate */
  499. return 0;
  500. }
  501. static av_cold int alac_decode_init(AVCodecContext * avctx)
  502. {
  503. int ret;
  504. ALACContext *alac = avctx->priv_data;
  505. alac->avctx = avctx;
  506. /* initialize from the extradata */
  507. if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
  508. av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n",
  509. ALAC_EXTRADATA_SIZE);
  510. return -1;
  511. }
  512. if (alac_set_info(alac)) {
  513. av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n");
  514. return -1;
  515. }
  516. switch (alac->setinfo_sample_size) {
  517. case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16;
  518. break;
  519. case 24: avctx->sample_fmt = AV_SAMPLE_FMT_S32;
  520. break;
  521. default: av_log_ask_for_sample(avctx, "Sample depth %d is not supported.\n",
  522. alac->setinfo_sample_size);
  523. return AVERROR_PATCHWELCOME;
  524. }
  525. if (alac->numchannels < 1) {
  526. av_log(avctx, AV_LOG_WARNING, "Invalid channel count\n");
  527. alac->numchannels = avctx->channels;
  528. } else {
  529. if (alac->numchannels > MAX_CHANNELS)
  530. alac->numchannels = avctx->channels;
  531. else
  532. avctx->channels = alac->numchannels;
  533. }
  534. if (avctx->channels > MAX_CHANNELS) {
  535. av_log(avctx, AV_LOG_ERROR, "Unsupported channel count: %d\n",
  536. avctx->channels);
  537. return AVERROR_PATCHWELCOME;
  538. }
  539. if ((ret = allocate_buffers(alac)) < 0) {
  540. av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
  541. return ret;
  542. }
  543. avcodec_get_frame_defaults(&alac->frame);
  544. avctx->coded_frame = &alac->frame;
  545. return 0;
  546. }
  547. AVCodec ff_alac_decoder = {
  548. .name = "alac",
  549. .type = AVMEDIA_TYPE_AUDIO,
  550. .id = CODEC_ID_ALAC,
  551. .priv_data_size = sizeof(ALACContext),
  552. .init = alac_decode_init,
  553. .close = alac_decode_close,
  554. .decode = alac_decode_frame,
  555. .capabilities = CODEC_CAP_DR1,
  556. .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
  557. };