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.

703 lines
23KB

  1. /*
  2. * ALAC (Apple Lossless Audio Codec) decoder
  3. * Copyright (c) 2005 David Hammerton
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav 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. * Libav 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 Libav; 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. GetBitContext gb;
  60. int numchannels;
  61. int bytespersample;
  62. /* buffers */
  63. int32_t *predicterror_buffer[MAX_CHANNELS];
  64. int32_t *outputsamples_buffer[MAX_CHANNELS];
  65. int32_t *wasted_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 wasted_bits;
  74. } ALACContext;
  75. static void allocate_buffers(ALACContext *alac)
  76. {
  77. int chan;
  78. for (chan = 0; chan < MAX_CHANNELS; chan++) {
  79. alac->predicterror_buffer[chan] =
  80. av_malloc(alac->setinfo_max_samples_per_frame * 4);
  81. alac->outputsamples_buffer[chan] =
  82. av_malloc(alac->setinfo_max_samples_per_frame * 4);
  83. alac->wasted_bits_buffer[chan] = av_malloc(alac->setinfo_max_samples_per_frame * 4);
  84. }
  85. }
  86. static int alac_set_info(ALACContext *alac)
  87. {
  88. const unsigned char *ptr = alac->avctx->extradata;
  89. ptr += 4; /* size */
  90. ptr += 4; /* alac */
  91. ptr += 4; /* 0 ? */
  92. if(AV_RB32(ptr) >= UINT_MAX/4){
  93. av_log(alac->avctx, AV_LOG_ERROR, "setinfo_max_samples_per_frame too large\n");
  94. return -1;
  95. }
  96. /* buffer size / 2 ? */
  97. alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr);
  98. ptr++; /* ??? */
  99. alac->setinfo_sample_size = *ptr++;
  100. if (alac->setinfo_sample_size > 32) {
  101. av_log(alac->avctx, AV_LOG_ERROR, "setinfo_sample_size too large\n");
  102. return -1;
  103. }
  104. alac->setinfo_rice_historymult = *ptr++;
  105. alac->setinfo_rice_initialhistory = *ptr++;
  106. alac->setinfo_rice_kmodifier = *ptr++;
  107. ptr++; /* channels? */
  108. bytestream_get_be16(&ptr); /* ??? */
  109. bytestream_get_be32(&ptr); /* max coded frame size */
  110. bytestream_get_be32(&ptr); /* bitrate ? */
  111. bytestream_get_be32(&ptr); /* samplerate */
  112. allocate_buffers(alac);
  113. return 0;
  114. }
  115. static inline int decode_scalar(GetBitContext *gb, int k, int limit, int readsamplesize){
  116. /* read x - number of 1s before 0 represent the rice */
  117. int x = get_unary_0_9(gb);
  118. if (x > 8) { /* RICE THRESHOLD */
  119. /* use alternative encoding */
  120. x = get_bits(gb, readsamplesize);
  121. } else {
  122. if (k >= limit)
  123. k = limit;
  124. if (k != 1) {
  125. int extrabits = show_bits(gb, k);
  126. /* multiply x by 2^k - 1, as part of their strange algorithm */
  127. x = (x << k) - x;
  128. if (extrabits > 1) {
  129. x += extrabits - 1;
  130. skip_bits(gb, k);
  131. } else
  132. skip_bits(gb, k - 1);
  133. }
  134. }
  135. return x;
  136. }
  137. static void bastardized_rice_decompress(ALACContext *alac,
  138. int32_t *output_buffer,
  139. int output_size,
  140. int readsamplesize, /* arg_10 */
  141. int rice_initialhistory, /* arg424->b */
  142. int rice_kmodifier, /* arg424->d */
  143. int rice_historymult, /* arg424->c */
  144. int rice_kmodifier_mask /* arg424->e */
  145. )
  146. {
  147. int output_count;
  148. unsigned int history = rice_initialhistory;
  149. int sign_modifier = 0;
  150. for (output_count = 0; output_count < output_size; output_count++) {
  151. int32_t x;
  152. int32_t x_modified;
  153. int32_t final_val;
  154. /* standard rice encoding */
  155. int k; /* size of extra bits */
  156. /* read k, that is bits as is */
  157. k = av_log2((history >> 9) + 3);
  158. x= decode_scalar(&alac->gb, k, rice_kmodifier, readsamplesize);
  159. x_modified = sign_modifier + x;
  160. final_val = (x_modified + 1) / 2;
  161. if (x_modified & 1) final_val *= -1;
  162. output_buffer[output_count] = final_val;
  163. sign_modifier = 0;
  164. /* now update the history */
  165. history += x_modified * rice_historymult
  166. - ((history * rice_historymult) >> 9);
  167. if (x_modified > 0xffff)
  168. history = 0xffff;
  169. /* special case: there may be compressed blocks of 0 */
  170. if ((history < 128) && (output_count+1 < output_size)) {
  171. int k;
  172. unsigned int block_size;
  173. sign_modifier = 1;
  174. k = 7 - av_log2(history) + ((history + 16) >> 6 /* / 64 */);
  175. block_size= decode_scalar(&alac->gb, k, rice_kmodifier, 16);
  176. if (block_size > 0) {
  177. if(block_size >= output_size - output_count){
  178. av_log(alac->avctx, AV_LOG_ERROR, "invalid zero block size of %d %d %d\n", block_size, output_size, output_count);
  179. block_size= output_size - output_count - 1;
  180. }
  181. memset(&output_buffer[output_count+1], 0, block_size * 4);
  182. output_count += block_size;
  183. }
  184. if (block_size > 0xffff)
  185. sign_modifier = 0;
  186. history = 0;
  187. }
  188. }
  189. }
  190. static inline int sign_only(int v)
  191. {
  192. return v ? FFSIGN(v) : 0;
  193. }
  194. static void predictor_decompress_fir_adapt(int32_t *error_buffer,
  195. int32_t *buffer_out,
  196. int output_size,
  197. int readsamplesize,
  198. int16_t *predictor_coef_table,
  199. int predictor_coef_num,
  200. int predictor_quantitization)
  201. {
  202. int i;
  203. /* first sample always copies */
  204. *buffer_out = *error_buffer;
  205. if (!predictor_coef_num) {
  206. if (output_size <= 1)
  207. return;
  208. memcpy(buffer_out+1, error_buffer+1, (output_size-1) * 4);
  209. return;
  210. }
  211. if (predictor_coef_num == 0x1f) { /* 11111 - max value of predictor_coef_num */
  212. /* second-best case scenario for fir decompression,
  213. * error describes a small difference from the previous sample only
  214. */
  215. if (output_size <= 1)
  216. return;
  217. for (i = 0; i < output_size - 1; i++) {
  218. int32_t prev_value;
  219. int32_t error_value;
  220. prev_value = buffer_out[i];
  221. error_value = error_buffer[i+1];
  222. buffer_out[i+1] =
  223. sign_extend((prev_value + error_value), readsamplesize);
  224. }
  225. return;
  226. }
  227. /* read warm-up samples */
  228. if (predictor_coef_num > 0)
  229. for (i = 0; i < predictor_coef_num; i++) {
  230. int32_t val;
  231. val = buffer_out[i] + error_buffer[i+1];
  232. val = sign_extend(val, readsamplesize);
  233. buffer_out[i+1] = val;
  234. }
  235. #if 0
  236. /* 4 and 8 are very common cases (the only ones i've seen). these
  237. * should be unrolled and optimized
  238. */
  239. if (predictor_coef_num == 4) {
  240. /* FIXME: optimized general case */
  241. return;
  242. }
  243. if (predictor_coef_table == 8) {
  244. /* FIXME: optimized general case */
  245. return;
  246. }
  247. #endif
  248. /* general case */
  249. if (predictor_coef_num > 0) {
  250. for (i = predictor_coef_num + 1; i < output_size; i++) {
  251. int j;
  252. int sum = 0;
  253. int outval;
  254. int error_val = error_buffer[i];
  255. for (j = 0; j < predictor_coef_num; j++) {
  256. sum += (buffer_out[predictor_coef_num-j] - buffer_out[0]) *
  257. predictor_coef_table[j];
  258. }
  259. outval = (1 << (predictor_quantitization-1)) + sum;
  260. outval = outval >> predictor_quantitization;
  261. outval = outval + buffer_out[0] + error_val;
  262. outval = sign_extend(outval, readsamplesize);
  263. buffer_out[predictor_coef_num+1] = outval;
  264. if (error_val > 0) {
  265. int predictor_num = predictor_coef_num - 1;
  266. while (predictor_num >= 0 && error_val > 0) {
  267. int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];
  268. int sign = sign_only(val);
  269. predictor_coef_table[predictor_num] -= sign;
  270. val *= sign; /* absolute value */
  271. error_val -= ((val >> predictor_quantitization) *
  272. (predictor_coef_num - predictor_num));
  273. predictor_num--;
  274. }
  275. } else if (error_val < 0) {
  276. int predictor_num = predictor_coef_num - 1;
  277. while (predictor_num >= 0 && error_val < 0) {
  278. int val = buffer_out[0] - buffer_out[predictor_coef_num - predictor_num];
  279. int sign = - sign_only(val);
  280. predictor_coef_table[predictor_num] -= sign;
  281. val *= sign; /* neg value */
  282. error_val -= ((val >> predictor_quantitization) *
  283. (predictor_coef_num - predictor_num));
  284. predictor_num--;
  285. }
  286. }
  287. buffer_out++;
  288. }
  289. }
  290. }
  291. static void reconstruct_stereo_16(int32_t *buffer[MAX_CHANNELS],
  292. int16_t *buffer_out,
  293. int numchannels, int numsamples,
  294. uint8_t interlacing_shift,
  295. uint8_t interlacing_leftweight)
  296. {
  297. int i;
  298. if (numsamples <= 0)
  299. return;
  300. /* weighted interlacing */
  301. if (interlacing_leftweight) {
  302. for (i = 0; i < numsamples; i++) {
  303. int32_t a, b;
  304. a = buffer[0][i];
  305. b = buffer[1][i];
  306. a -= (b * interlacing_leftweight) >> interlacing_shift;
  307. b += a;
  308. buffer_out[i*numchannels] = b;
  309. buffer_out[i*numchannels + 1] = a;
  310. }
  311. return;
  312. }
  313. /* otherwise basic interlacing took place */
  314. for (i = 0; i < numsamples; i++) {
  315. int16_t left, right;
  316. left = buffer[0][i];
  317. right = buffer[1][i];
  318. buffer_out[i*numchannels] = left;
  319. buffer_out[i*numchannels + 1] = right;
  320. }
  321. }
  322. static void decorrelate_stereo_24(int32_t *buffer[MAX_CHANNELS],
  323. int32_t *buffer_out,
  324. int32_t *wasted_bits_buffer[MAX_CHANNELS],
  325. int wasted_bits,
  326. int numchannels, int numsamples,
  327. uint8_t interlacing_shift,
  328. uint8_t interlacing_leftweight)
  329. {
  330. int i;
  331. if (numsamples <= 0)
  332. return;
  333. /* weighted interlacing */
  334. if (interlacing_leftweight) {
  335. for (i = 0; i < numsamples; i++) {
  336. int32_t a, b;
  337. a = buffer[0][i];
  338. b = buffer[1][i];
  339. a -= (b * interlacing_leftweight) >> interlacing_shift;
  340. b += a;
  341. if (wasted_bits) {
  342. b = (b << wasted_bits) | wasted_bits_buffer[0][i];
  343. a = (a << wasted_bits) | wasted_bits_buffer[1][i];
  344. }
  345. buffer_out[i * numchannels] = b << 8;
  346. buffer_out[i * numchannels + 1] = a << 8;
  347. }
  348. } else {
  349. for (i = 0; i < numsamples; i++) {
  350. int32_t left, right;
  351. left = buffer[0][i];
  352. right = buffer[1][i];
  353. if (wasted_bits) {
  354. left = (left << wasted_bits) | wasted_bits_buffer[0][i];
  355. right = (right << wasted_bits) | wasted_bits_buffer[1][i];
  356. }
  357. buffer_out[i * numchannels] = left << 8;
  358. buffer_out[i * numchannels + 1] = right << 8;
  359. }
  360. }
  361. }
  362. static int alac_decode_frame(AVCodecContext *avctx,
  363. void *outbuffer, int *outputsize,
  364. AVPacket *avpkt)
  365. {
  366. const uint8_t *inbuffer = avpkt->data;
  367. int input_buffer_size = avpkt->size;
  368. ALACContext *alac = avctx->priv_data;
  369. int channels;
  370. unsigned int outputsamples;
  371. int hassize;
  372. unsigned int readsamplesize;
  373. int isnotcompressed;
  374. uint8_t interlacing_shift;
  375. uint8_t interlacing_leftweight;
  376. /* short-circuit null buffers */
  377. if (!inbuffer || !input_buffer_size)
  378. return -1;
  379. init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
  380. channels = get_bits(&alac->gb, 3) + 1;
  381. if (channels > MAX_CHANNELS) {
  382. av_log(avctx, AV_LOG_ERROR, "channels > %d not supported\n",
  383. MAX_CHANNELS);
  384. return -1;
  385. }
  386. /* 2^result = something to do with output waiting.
  387. * perhaps matters if we read > 1 frame in a pass?
  388. */
  389. skip_bits(&alac->gb, 4);
  390. skip_bits(&alac->gb, 12); /* unknown, skip 12 bits */
  391. /* the output sample size is stored soon */
  392. hassize = get_bits1(&alac->gb);
  393. alac->wasted_bits = get_bits(&alac->gb, 2) << 3;
  394. /* whether the frame is compressed */
  395. isnotcompressed = get_bits1(&alac->gb);
  396. if (hassize) {
  397. /* now read the number of samples as a 32bit integer */
  398. outputsamples = get_bits_long(&alac->gb, 32);
  399. if(outputsamples > alac->setinfo_max_samples_per_frame){
  400. av_log(avctx, AV_LOG_ERROR, "outputsamples %d > %d\n", outputsamples, alac->setinfo_max_samples_per_frame);
  401. return -1;
  402. }
  403. } else
  404. outputsamples = alac->setinfo_max_samples_per_frame;
  405. switch (alac->setinfo_sample_size) {
  406. case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16;
  407. alac->bytespersample = channels << 1;
  408. break;
  409. case 24: avctx->sample_fmt = AV_SAMPLE_FMT_S32;
  410. alac->bytespersample = channels << 2;
  411. break;
  412. default: av_log(avctx, AV_LOG_ERROR, "Sample depth %d is not supported.\n",
  413. alac->setinfo_sample_size);
  414. return -1;
  415. }
  416. if(outputsamples > *outputsize / alac->bytespersample){
  417. av_log(avctx, AV_LOG_ERROR, "sample buffer too small\n");
  418. return -1;
  419. }
  420. *outputsize = outputsamples * alac->bytespersample;
  421. readsamplesize = alac->setinfo_sample_size - (alac->wasted_bits) + channels - 1;
  422. if (readsamplesize > MIN_CACHE_BITS) {
  423. av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", readsamplesize);
  424. return -1;
  425. }
  426. if (!isnotcompressed) {
  427. /* so it is compressed */
  428. int16_t predictor_coef_table[MAX_CHANNELS][32];
  429. int predictor_coef_num[MAX_CHANNELS];
  430. int prediction_type[MAX_CHANNELS];
  431. int prediction_quantitization[MAX_CHANNELS];
  432. int ricemodifier[MAX_CHANNELS];
  433. int i, chan;
  434. interlacing_shift = get_bits(&alac->gb, 8);
  435. interlacing_leftweight = get_bits(&alac->gb, 8);
  436. for (chan = 0; chan < channels; chan++) {
  437. prediction_type[chan] = get_bits(&alac->gb, 4);
  438. prediction_quantitization[chan] = get_bits(&alac->gb, 4);
  439. ricemodifier[chan] = get_bits(&alac->gb, 3);
  440. predictor_coef_num[chan] = get_bits(&alac->gb, 5);
  441. /* read the predictor table */
  442. for (i = 0; i < predictor_coef_num[chan]; i++)
  443. predictor_coef_table[chan][i] = (int16_t)get_bits(&alac->gb, 16);
  444. }
  445. if (alac->wasted_bits) {
  446. int i, ch;
  447. for (i = 0; i < outputsamples; i++) {
  448. for (ch = 0; ch < channels; ch++)
  449. alac->wasted_bits_buffer[ch][i] = get_bits(&alac->gb, alac->wasted_bits);
  450. }
  451. }
  452. for (chan = 0; chan < channels; chan++) {
  453. bastardized_rice_decompress(alac,
  454. alac->predicterror_buffer[chan],
  455. outputsamples,
  456. readsamplesize,
  457. alac->setinfo_rice_initialhistory,
  458. alac->setinfo_rice_kmodifier,
  459. ricemodifier[chan] * alac->setinfo_rice_historymult / 4,
  460. (1 << alac->setinfo_rice_kmodifier) - 1);
  461. if (prediction_type[chan] == 0) {
  462. /* adaptive fir */
  463. predictor_decompress_fir_adapt(alac->predicterror_buffer[chan],
  464. alac->outputsamples_buffer[chan],
  465. outputsamples,
  466. readsamplesize,
  467. predictor_coef_table[chan],
  468. predictor_coef_num[chan],
  469. prediction_quantitization[chan]);
  470. } else {
  471. av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type[chan]);
  472. /* I think the only other prediction type (or perhaps this is
  473. * just a boolean?) runs adaptive fir twice.. like:
  474. * predictor_decompress_fir_adapt(predictor_error, tempout, ...)
  475. * predictor_decompress_fir_adapt(predictor_error, outputsamples ...)
  476. * little strange..
  477. */
  478. }
  479. }
  480. } else {
  481. /* not compressed, easy case */
  482. int i, chan;
  483. if (alac->setinfo_sample_size <= 16) {
  484. for (i = 0; i < outputsamples; i++)
  485. for (chan = 0; chan < channels; chan++) {
  486. int32_t audiobits;
  487. audiobits = get_sbits_long(&alac->gb, alac->setinfo_sample_size);
  488. alac->outputsamples_buffer[chan][i] = audiobits;
  489. }
  490. } else {
  491. for (i = 0; i < outputsamples; i++) {
  492. for (chan = 0; chan < channels; chan++) {
  493. alac->outputsamples_buffer[chan][i] = get_bits(&alac->gb,
  494. alac->setinfo_sample_size);
  495. alac->outputsamples_buffer[chan][i] = sign_extend(alac->outputsamples_buffer[chan][i],
  496. alac->setinfo_sample_size);
  497. }
  498. }
  499. }
  500. alac->wasted_bits = 0;
  501. interlacing_shift = 0;
  502. interlacing_leftweight = 0;
  503. }
  504. if (get_bits(&alac->gb, 3) != 7)
  505. av_log(avctx, AV_LOG_ERROR, "Error : Wrong End Of Frame\n");
  506. switch(alac->setinfo_sample_size) {
  507. case 16:
  508. if (channels == 2) {
  509. reconstruct_stereo_16(alac->outputsamples_buffer,
  510. (int16_t*)outbuffer,
  511. alac->numchannels,
  512. outputsamples,
  513. interlacing_shift,
  514. interlacing_leftweight);
  515. } else {
  516. int i;
  517. for (i = 0; i < outputsamples; i++) {
  518. ((int16_t*)outbuffer)[i] = alac->outputsamples_buffer[0][i];
  519. }
  520. }
  521. break;
  522. case 24:
  523. if (channels == 2) {
  524. decorrelate_stereo_24(alac->outputsamples_buffer,
  525. outbuffer,
  526. alac->wasted_bits_buffer,
  527. alac->wasted_bits,
  528. alac->numchannels,
  529. outputsamples,
  530. interlacing_shift,
  531. interlacing_leftweight);
  532. } else {
  533. int i;
  534. for (i = 0; i < outputsamples; i++)
  535. ((int32_t *)outbuffer)[i] = alac->outputsamples_buffer[0][i] << 8;
  536. }
  537. break;
  538. }
  539. if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8)
  540. av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n", input_buffer_size * 8 - get_bits_count(&alac->gb));
  541. return input_buffer_size;
  542. }
  543. static av_cold int alac_decode_init(AVCodecContext * avctx)
  544. {
  545. ALACContext *alac = avctx->priv_data;
  546. alac->avctx = avctx;
  547. alac->numchannels = alac->avctx->channels;
  548. /* initialize from the extradata */
  549. if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
  550. av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n",
  551. ALAC_EXTRADATA_SIZE);
  552. return -1;
  553. }
  554. if (alac_set_info(alac)) {
  555. av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n");
  556. return -1;
  557. }
  558. return 0;
  559. }
  560. static av_cold int alac_decode_close(AVCodecContext *avctx)
  561. {
  562. ALACContext *alac = avctx->priv_data;
  563. int chan;
  564. for (chan = 0; chan < MAX_CHANNELS; chan++) {
  565. av_freep(&alac->predicterror_buffer[chan]);
  566. av_freep(&alac->outputsamples_buffer[chan]);
  567. av_freep(&alac->wasted_bits_buffer[chan]);
  568. }
  569. return 0;
  570. }
  571. AVCodec ff_alac_decoder = {
  572. "alac",
  573. AVMEDIA_TYPE_AUDIO,
  574. CODEC_ID_ALAC,
  575. sizeof(ALACContext),
  576. alac_decode_init,
  577. NULL,
  578. alac_decode_close,
  579. alac_decode_frame,
  580. .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
  581. };