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.

638 lines
21KB

  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-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. *
  31. * 32 bits atom size
  32. * 32 bits tag ("alac")
  33. * 32 bits tag version (0)
  34. * 32 bits samples per frame (used when not set explicitly in the frames)
  35. * 8 bits compatible version (0)
  36. * 8 bits sample size
  37. * 8 bits history mult (40)
  38. * 8 bits initial history (10)
  39. * 8 bits rice param limit (14)
  40. * 8 bits channels
  41. * 16 bits maxRun (255)
  42. * 32 bits max coded frame size (0 means unknown)
  43. * 32 bits average bitrate (0 means unknown)
  44. * 32 bits samplerate
  45. */
  46. #include <inttypes.h>
  47. #include "libavutil/channel_layout.h"
  48. #include "libavutil/opt.h"
  49. #include "avcodec.h"
  50. #include "get_bits.h"
  51. #include "bytestream.h"
  52. #include "internal.h"
  53. #include "thread.h"
  54. #include "unary.h"
  55. #include "mathops.h"
  56. #include "alac_data.h"
  57. #include "alacdsp.h"
  58. #define ALAC_EXTRADATA_SIZE 36
  59. typedef struct ALACContext {
  60. AVClass *class;
  61. AVCodecContext *avctx;
  62. GetBitContext gb;
  63. int channels;
  64. int32_t *predict_error_buffer[2];
  65. int32_t *output_samples_buffer[2];
  66. int32_t *extra_bits_buffer[2];
  67. uint32_t max_samples_per_frame;
  68. uint8_t sample_size;
  69. uint8_t rice_history_mult;
  70. uint8_t rice_initial_history;
  71. uint8_t rice_limit;
  72. int sample_rate;
  73. int extra_bits; /**< number of extra bits beyond 16-bit */
  74. int nb_samples; /**< number of samples in the current frame */
  75. int direct_output;
  76. int extra_bit_bug;
  77. ALACDSPContext dsp;
  78. } ALACContext;
  79. static inline unsigned int decode_scalar(GetBitContext *gb, int k, int bps)
  80. {
  81. unsigned int x = get_unary_0_9(gb);
  82. if (x > 8) { /* RICE THRESHOLD */
  83. /* use alternative encoding */
  84. x = get_bits_long(gb, bps);
  85. } else if (k != 1) {
  86. int extrabits = show_bits(gb, k);
  87. /* multiply x by 2^k - 1, as part of their strange algorithm */
  88. x = (x << k) - x;
  89. if (extrabits > 1) {
  90. x += extrabits - 1;
  91. skip_bits(gb, k);
  92. } else
  93. skip_bits(gb, k - 1);
  94. }
  95. return x;
  96. }
  97. static int rice_decompress(ALACContext *alac, int32_t *output_buffer,
  98. int nb_samples, int bps, int rice_history_mult)
  99. {
  100. int i;
  101. unsigned int history = alac->rice_initial_history;
  102. int sign_modifier = 0;
  103. for (i = 0; i < nb_samples; i++) {
  104. int k;
  105. unsigned int x;
  106. if(get_bits_left(&alac->gb) <= 0)
  107. return -1;
  108. /* calculate rice param and decode next value */
  109. k = av_log2((history >> 9) + 3);
  110. k = FFMIN(k, alac->rice_limit);
  111. x = decode_scalar(&alac->gb, k, bps);
  112. x += sign_modifier;
  113. sign_modifier = 0;
  114. output_buffer[i] = (x >> 1) ^ -(x & 1);
  115. /* update the history */
  116. if (x > 0xffff)
  117. history = 0xffff;
  118. else
  119. history += x * rice_history_mult -
  120. ((history * rice_history_mult) >> 9);
  121. /* special case: there may be compressed blocks of 0 */
  122. if ((history < 128) && (i + 1 < nb_samples)) {
  123. int block_size;
  124. /* calculate rice param and decode block size */
  125. k = 7 - av_log2(history) + ((history + 16) >> 6);
  126. k = FFMIN(k, alac->rice_limit);
  127. block_size = decode_scalar(&alac->gb, k, 16);
  128. if (block_size > 0) {
  129. if (block_size >= nb_samples - i) {
  130. av_log(alac->avctx, AV_LOG_ERROR,
  131. "invalid zero block size of %d %d %d\n", block_size,
  132. nb_samples, i);
  133. block_size = nb_samples - i - 1;
  134. }
  135. memset(&output_buffer[i + 1], 0,
  136. block_size * sizeof(*output_buffer));
  137. i += block_size;
  138. }
  139. if (block_size <= 0xffff)
  140. sign_modifier = 1;
  141. history = 0;
  142. }
  143. }
  144. return 0;
  145. }
  146. static inline int sign_only(int v)
  147. {
  148. return v ? FFSIGN(v) : 0;
  149. }
  150. static void lpc_prediction(int32_t *error_buffer, uint32_t *buffer_out,
  151. int nb_samples, int bps, int16_t *lpc_coefs,
  152. int lpc_order, int lpc_quant)
  153. {
  154. int i;
  155. uint32_t *pred = buffer_out;
  156. /* first sample always copies */
  157. *buffer_out = *error_buffer;
  158. if (nb_samples <= 1)
  159. return;
  160. if (!lpc_order) {
  161. memcpy(&buffer_out[1], &error_buffer[1],
  162. (nb_samples - 1) * sizeof(*buffer_out));
  163. return;
  164. }
  165. if (lpc_order == 31) {
  166. /* simple 1st-order prediction */
  167. for (i = 1; i < nb_samples; i++) {
  168. buffer_out[i] = sign_extend(buffer_out[i - 1] + error_buffer[i],
  169. bps);
  170. }
  171. return;
  172. }
  173. /* read warm-up samples */
  174. for (i = 1; i <= lpc_order && i < nb_samples; i++)
  175. buffer_out[i] = sign_extend(buffer_out[i - 1] + error_buffer[i], bps);
  176. /* NOTE: 4 and 8 are very common cases that could be optimized. */
  177. for (; i < nb_samples; i++) {
  178. int j;
  179. int val = 0;
  180. unsigned error_val = error_buffer[i];
  181. int error_sign;
  182. int d = *pred++;
  183. /* LPC prediction */
  184. for (j = 0; j < lpc_order; j++)
  185. val += (pred[j] - d) * lpc_coefs[j];
  186. val = (val + (1 << (lpc_quant - 1))) >> lpc_quant;
  187. val += d + error_val;
  188. buffer_out[i] = sign_extend(val, bps);
  189. /* adapt LPC coefficients */
  190. error_sign = sign_only(error_val);
  191. if (error_sign) {
  192. for (j = 0; j < lpc_order && (int)error_val * error_sign > 0; j++) {
  193. int sign;
  194. val = d - pred[j];
  195. sign = sign_only(val) * error_sign;
  196. lpc_coefs[j] -= sign;
  197. val *= sign;
  198. error_val -= (val >> lpc_quant) * (j + 1);
  199. }
  200. }
  201. }
  202. }
  203. static int decode_element(AVCodecContext *avctx, AVFrame *frame, int ch_index,
  204. int channels)
  205. {
  206. ALACContext *alac = avctx->priv_data;
  207. int has_size, bps, is_compressed, decorr_shift, decorr_left_weight, ret;
  208. uint32_t output_samples;
  209. int i, ch;
  210. skip_bits(&alac->gb, 4); /* element instance tag */
  211. skip_bits(&alac->gb, 12); /* unused header bits */
  212. /* the number of output samples is stored in the frame */
  213. has_size = get_bits1(&alac->gb);
  214. alac->extra_bits = get_bits(&alac->gb, 2) << 3;
  215. bps = alac->sample_size - alac->extra_bits + channels - 1;
  216. if (bps > 32U) {
  217. avpriv_report_missing_feature(avctx, "bps %d", bps);
  218. return AVERROR_PATCHWELCOME;
  219. }
  220. /* whether the frame is compressed */
  221. is_compressed = !get_bits1(&alac->gb);
  222. if (has_size)
  223. output_samples = get_bits_long(&alac->gb, 32);
  224. else
  225. output_samples = alac->max_samples_per_frame;
  226. if (!output_samples || output_samples > alac->max_samples_per_frame) {
  227. av_log(avctx, AV_LOG_ERROR, "invalid samples per frame: %"PRIu32"\n",
  228. output_samples);
  229. return AVERROR_INVALIDDATA;
  230. }
  231. if (!alac->nb_samples) {
  232. ThreadFrame tframe = { .f = frame };
  233. /* get output buffer */
  234. frame->nb_samples = output_samples;
  235. if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0)
  236. return ret;
  237. } else if (output_samples != alac->nb_samples) {
  238. av_log(avctx, AV_LOG_ERROR, "sample count mismatch: %"PRIu32" != %d\n",
  239. output_samples, alac->nb_samples);
  240. return AVERROR_INVALIDDATA;
  241. }
  242. alac->nb_samples = output_samples;
  243. if (alac->direct_output) {
  244. for (ch = 0; ch < channels; ch++)
  245. alac->output_samples_buffer[ch] = (int32_t *)frame->extended_data[ch_index + ch];
  246. }
  247. if (is_compressed) {
  248. int16_t lpc_coefs[2][32];
  249. int lpc_order[2];
  250. int prediction_type[2];
  251. int lpc_quant[2];
  252. int rice_history_mult[2];
  253. if (!alac->rice_limit) {
  254. avpriv_request_sample(alac->avctx,
  255. "Compression with rice limit 0");
  256. return AVERROR(ENOSYS);
  257. }
  258. decorr_shift = get_bits(&alac->gb, 8);
  259. decorr_left_weight = get_bits(&alac->gb, 8);
  260. for (ch = 0; ch < channels; ch++) {
  261. prediction_type[ch] = get_bits(&alac->gb, 4);
  262. lpc_quant[ch] = get_bits(&alac->gb, 4);
  263. rice_history_mult[ch] = get_bits(&alac->gb, 3);
  264. lpc_order[ch] = get_bits(&alac->gb, 5);
  265. if (lpc_order[ch] >= alac->max_samples_per_frame || !lpc_quant[ch])
  266. return AVERROR_INVALIDDATA;
  267. /* read the predictor table */
  268. for (i = lpc_order[ch] - 1; i >= 0; i--)
  269. lpc_coefs[ch][i] = get_sbits(&alac->gb, 16);
  270. }
  271. if (alac->extra_bits) {
  272. for (i = 0; i < alac->nb_samples; i++) {
  273. if(get_bits_left(&alac->gb) <= 0)
  274. return -1;
  275. for (ch = 0; ch < channels; ch++)
  276. alac->extra_bits_buffer[ch][i] = get_bits(&alac->gb, alac->extra_bits);
  277. }
  278. }
  279. for (ch = 0; ch < channels; ch++) {
  280. int ret=rice_decompress(alac, alac->predict_error_buffer[ch],
  281. alac->nb_samples, bps,
  282. rice_history_mult[ch] * alac->rice_history_mult / 4);
  283. if(ret<0)
  284. return ret;
  285. /* adaptive FIR filter */
  286. if (prediction_type[ch] == 15) {
  287. /* Prediction type 15 runs the adaptive FIR twice.
  288. * The first pass uses the special-case coef_num = 31, while
  289. * the second pass uses the coefs from the bitstream.
  290. *
  291. * However, this prediction type is not currently used by the
  292. * reference encoder.
  293. */
  294. lpc_prediction(alac->predict_error_buffer[ch],
  295. alac->predict_error_buffer[ch],
  296. alac->nb_samples, bps, NULL, 31, 0);
  297. } else if (prediction_type[ch] > 0) {
  298. av_log(avctx, AV_LOG_WARNING, "unknown prediction type: %i\n",
  299. prediction_type[ch]);
  300. }
  301. lpc_prediction(alac->predict_error_buffer[ch],
  302. alac->output_samples_buffer[ch], alac->nb_samples,
  303. bps, lpc_coefs[ch], lpc_order[ch], lpc_quant[ch]);
  304. }
  305. } else {
  306. /* not compressed, easy case */
  307. for (i = 0; i < alac->nb_samples; i++) {
  308. if(get_bits_left(&alac->gb) <= 0)
  309. return -1;
  310. for (ch = 0; ch < channels; ch++) {
  311. alac->output_samples_buffer[ch][i] =
  312. get_sbits_long(&alac->gb, alac->sample_size);
  313. }
  314. }
  315. alac->extra_bits = 0;
  316. decorr_shift = 0;
  317. decorr_left_weight = 0;
  318. }
  319. if (channels == 2) {
  320. if (alac->extra_bits && alac->extra_bit_bug) {
  321. alac->dsp.append_extra_bits[1](alac->output_samples_buffer, alac->extra_bits_buffer,
  322. alac->extra_bits, channels, alac->nb_samples);
  323. }
  324. if (decorr_left_weight) {
  325. alac->dsp.decorrelate_stereo(alac->output_samples_buffer, alac->nb_samples,
  326. decorr_shift, decorr_left_weight);
  327. }
  328. if (alac->extra_bits && !alac->extra_bit_bug) {
  329. alac->dsp.append_extra_bits[1](alac->output_samples_buffer, alac->extra_bits_buffer,
  330. alac->extra_bits, channels, alac->nb_samples);
  331. }
  332. } else if (alac->extra_bits) {
  333. alac->dsp.append_extra_bits[0](alac->output_samples_buffer, alac->extra_bits_buffer,
  334. alac->extra_bits, channels, alac->nb_samples);
  335. }
  336. switch(alac->sample_size) {
  337. case 16: {
  338. for (ch = 0; ch < channels; ch++) {
  339. int16_t *outbuffer = (int16_t *)frame->extended_data[ch_index + ch];
  340. for (i = 0; i < alac->nb_samples; i++)
  341. *outbuffer++ = alac->output_samples_buffer[ch][i];
  342. }}
  343. break;
  344. case 20: {
  345. for (ch = 0; ch < channels; ch++) {
  346. for (i = 0; i < alac->nb_samples; i++)
  347. alac->output_samples_buffer[ch][i] <<= 12;
  348. }}
  349. break;
  350. case 24: {
  351. for (ch = 0; ch < channels; ch++) {
  352. for (i = 0; i < alac->nb_samples; i++)
  353. alac->output_samples_buffer[ch][i] <<= 8;
  354. }}
  355. break;
  356. }
  357. return 0;
  358. }
  359. static int alac_decode_frame(AVCodecContext *avctx, void *data,
  360. int *got_frame_ptr, AVPacket *avpkt)
  361. {
  362. ALACContext *alac = avctx->priv_data;
  363. AVFrame *frame = data;
  364. enum AlacRawDataBlockType element;
  365. int channels;
  366. int ch, ret, got_end;
  367. if ((ret = init_get_bits8(&alac->gb, avpkt->data, avpkt->size)) < 0)
  368. return ret;
  369. got_end = 0;
  370. alac->nb_samples = 0;
  371. ch = 0;
  372. while (get_bits_left(&alac->gb) >= 3) {
  373. element = get_bits(&alac->gb, 3);
  374. if (element == TYPE_END) {
  375. got_end = 1;
  376. break;
  377. }
  378. if (element > TYPE_CPE && element != TYPE_LFE) {
  379. avpriv_report_missing_feature(avctx, "Syntax element %d", element);
  380. return AVERROR_PATCHWELCOME;
  381. }
  382. channels = (element == TYPE_CPE) ? 2 : 1;
  383. if (ch + channels > alac->channels ||
  384. ff_alac_channel_layout_offsets[alac->channels - 1][ch] + channels > alac->channels) {
  385. av_log(avctx, AV_LOG_ERROR, "invalid element channel count\n");
  386. return AVERROR_INVALIDDATA;
  387. }
  388. ret = decode_element(avctx, frame,
  389. ff_alac_channel_layout_offsets[alac->channels - 1][ch],
  390. channels);
  391. if (ret < 0 && get_bits_left(&alac->gb))
  392. return ret;
  393. ch += channels;
  394. }
  395. if (!got_end) {
  396. av_log(avctx, AV_LOG_ERROR, "no end tag found. incomplete packet.\n");
  397. return AVERROR_INVALIDDATA;
  398. }
  399. if (avpkt->size * 8 - get_bits_count(&alac->gb) > 8) {
  400. av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n",
  401. avpkt->size * 8 - get_bits_count(&alac->gb));
  402. }
  403. if (alac->channels == ch && alac->nb_samples)
  404. *got_frame_ptr = 1;
  405. else
  406. av_log(avctx, AV_LOG_WARNING, "Failed to decode all channels\n");
  407. return avpkt->size;
  408. }
  409. static av_cold int alac_decode_close(AVCodecContext *avctx)
  410. {
  411. ALACContext *alac = avctx->priv_data;
  412. int ch;
  413. for (ch = 0; ch < FFMIN(alac->channels, 2); ch++) {
  414. av_freep(&alac->predict_error_buffer[ch]);
  415. if (!alac->direct_output)
  416. av_freep(&alac->output_samples_buffer[ch]);
  417. av_freep(&alac->extra_bits_buffer[ch]);
  418. }
  419. return 0;
  420. }
  421. static int allocate_buffers(ALACContext *alac)
  422. {
  423. int ch;
  424. int buf_size = alac->max_samples_per_frame * sizeof(int32_t);
  425. for (ch = 0; ch < 2; ch++) {
  426. alac->predict_error_buffer[ch] = NULL;
  427. alac->output_samples_buffer[ch] = NULL;
  428. alac->extra_bits_buffer[ch] = NULL;
  429. }
  430. for (ch = 0; ch < FFMIN(alac->channels, 2); ch++) {
  431. FF_ALLOC_OR_GOTO(alac->avctx, alac->predict_error_buffer[ch],
  432. buf_size, buf_alloc_fail);
  433. alac->direct_output = alac->sample_size > 16;
  434. if (!alac->direct_output) {
  435. FF_ALLOC_OR_GOTO(alac->avctx, alac->output_samples_buffer[ch],
  436. buf_size + AV_INPUT_BUFFER_PADDING_SIZE, buf_alloc_fail);
  437. }
  438. FF_ALLOC_OR_GOTO(alac->avctx, alac->extra_bits_buffer[ch],
  439. buf_size + AV_INPUT_BUFFER_PADDING_SIZE, buf_alloc_fail);
  440. }
  441. return 0;
  442. buf_alloc_fail:
  443. alac_decode_close(alac->avctx);
  444. return AVERROR(ENOMEM);
  445. }
  446. static int alac_set_info(ALACContext *alac)
  447. {
  448. GetByteContext gb;
  449. bytestream2_init(&gb, alac->avctx->extradata,
  450. alac->avctx->extradata_size);
  451. bytestream2_skipu(&gb, 12); // size:4, alac:4, version:4
  452. alac->max_samples_per_frame = bytestream2_get_be32u(&gb);
  453. if (!alac->max_samples_per_frame ||
  454. alac->max_samples_per_frame > 4096 * 4096) {
  455. av_log(alac->avctx, AV_LOG_ERROR,
  456. "max samples per frame invalid: %"PRIu32"\n",
  457. alac->max_samples_per_frame);
  458. return AVERROR_INVALIDDATA;
  459. }
  460. bytestream2_skipu(&gb, 1); // compatible version
  461. alac->sample_size = bytestream2_get_byteu(&gb);
  462. alac->rice_history_mult = bytestream2_get_byteu(&gb);
  463. alac->rice_initial_history = bytestream2_get_byteu(&gb);
  464. alac->rice_limit = bytestream2_get_byteu(&gb);
  465. alac->channels = bytestream2_get_byteu(&gb);
  466. bytestream2_get_be16u(&gb); // maxRun
  467. bytestream2_get_be32u(&gb); // max coded frame size
  468. bytestream2_get_be32u(&gb); // average bitrate
  469. alac->sample_rate = bytestream2_get_be32u(&gb);
  470. return 0;
  471. }
  472. static av_cold int alac_decode_init(AVCodecContext * avctx)
  473. {
  474. int ret;
  475. ALACContext *alac = avctx->priv_data;
  476. alac->avctx = avctx;
  477. /* initialize from the extradata */
  478. if (alac->avctx->extradata_size < ALAC_EXTRADATA_SIZE) {
  479. av_log(avctx, AV_LOG_ERROR, "extradata is too small\n");
  480. return AVERROR_INVALIDDATA;
  481. }
  482. if (alac_set_info(alac)) {
  483. av_log(avctx, AV_LOG_ERROR, "set_info failed\n");
  484. return -1;
  485. }
  486. switch (alac->sample_size) {
  487. case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
  488. break;
  489. case 20:
  490. case 24:
  491. case 32: avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
  492. break;
  493. default: avpriv_request_sample(avctx, "Sample depth %d", alac->sample_size);
  494. return AVERROR_PATCHWELCOME;
  495. }
  496. avctx->bits_per_raw_sample = alac->sample_size;
  497. avctx->sample_rate = alac->sample_rate;
  498. if (alac->channels < 1) {
  499. av_log(avctx, AV_LOG_WARNING, "Invalid channel count\n");
  500. alac->channels = avctx->channels;
  501. } else {
  502. if (alac->channels > ALAC_MAX_CHANNELS)
  503. alac->channels = avctx->channels;
  504. else
  505. avctx->channels = alac->channels;
  506. }
  507. if (avctx->channels > ALAC_MAX_CHANNELS || avctx->channels <= 0 ) {
  508. avpriv_report_missing_feature(avctx, "Channel count %d",
  509. avctx->channels);
  510. return AVERROR_PATCHWELCOME;
  511. }
  512. avctx->channel_layout = ff_alac_channel_layouts[alac->channels - 1];
  513. if ((ret = allocate_buffers(alac)) < 0) {
  514. av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
  515. return ret;
  516. }
  517. ff_alacdsp_init(&alac->dsp);
  518. return 0;
  519. }
  520. #if HAVE_THREADS
  521. static int init_thread_copy(AVCodecContext *avctx)
  522. {
  523. ALACContext *alac = avctx->priv_data;
  524. alac->avctx = avctx;
  525. return allocate_buffers(alac);
  526. }
  527. #endif
  528. static const AVOption options[] = {
  529. { "extra_bits_bug", "Force non-standard decoding process",
  530. offsetof(ALACContext, extra_bit_bug), AV_OPT_TYPE_BOOL, { .i64 = 0 },
  531. 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM },
  532. { NULL },
  533. };
  534. static const AVClass alac_class = {
  535. .class_name = "alac",
  536. .item_name = av_default_item_name,
  537. .option = options,
  538. .version = LIBAVUTIL_VERSION_INT,
  539. };
  540. AVCodec ff_alac_decoder = {
  541. .name = "alac",
  542. .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
  543. .type = AVMEDIA_TYPE_AUDIO,
  544. .id = AV_CODEC_ID_ALAC,
  545. .priv_data_size = sizeof(ALACContext),
  546. .init = alac_decode_init,
  547. .close = alac_decode_close,
  548. .decode = alac_decode_frame,
  549. .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy),
  550. .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
  551. .priv_class = &alac_class
  552. };