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.

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