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.

632 lines
20KB

  1. /*
  2. * ALAC audio encoder
  3. * Copyright (c) 2008 Jaikrishnan Menon <realityman@gmx.net>
  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. #include "avcodec.h"
  22. #include "put_bits.h"
  23. #include "dsputil.h"
  24. #include "internal.h"
  25. #include "lpc.h"
  26. #include "mathops.h"
  27. #define DEFAULT_FRAME_SIZE 4096
  28. #define MAX_CHANNELS 8
  29. #define ALAC_EXTRADATA_SIZE 36
  30. #define ALAC_FRAME_HEADER_SIZE 55
  31. #define ALAC_FRAME_FOOTER_SIZE 3
  32. #define ALAC_ESCAPE_CODE 0x1FF
  33. #define ALAC_MAX_LPC_ORDER 30
  34. #define DEFAULT_MAX_PRED_ORDER 6
  35. #define DEFAULT_MIN_PRED_ORDER 4
  36. #define ALAC_MAX_LPC_PRECISION 9
  37. #define ALAC_MAX_LPC_SHIFT 9
  38. #define ALAC_CHMODE_LEFT_RIGHT 0
  39. #define ALAC_CHMODE_LEFT_SIDE 1
  40. #define ALAC_CHMODE_RIGHT_SIDE 2
  41. #define ALAC_CHMODE_MID_SIDE 3
  42. typedef struct RiceContext {
  43. int history_mult;
  44. int initial_history;
  45. int k_modifier;
  46. int rice_modifier;
  47. } RiceContext;
  48. typedef struct AlacLPCContext {
  49. int lpc_order;
  50. int lpc_coeff[ALAC_MAX_LPC_ORDER+1];
  51. int lpc_quant;
  52. } AlacLPCContext;
  53. typedef struct AlacEncodeContext {
  54. int frame_size; /**< current frame size */
  55. int verbatim; /**< current frame verbatim mode flag */
  56. int compression_level;
  57. int min_prediction_order;
  58. int max_prediction_order;
  59. int max_coded_frame_size;
  60. int write_sample_size;
  61. int extra_bits;
  62. int32_t sample_buf[MAX_CHANNELS][DEFAULT_FRAME_SIZE];
  63. int32_t predictor_buf[DEFAULT_FRAME_SIZE];
  64. int interlacing_shift;
  65. int interlacing_leftweight;
  66. PutBitContext pbctx;
  67. RiceContext rc;
  68. AlacLPCContext lpc[MAX_CHANNELS];
  69. LPCContext lpc_ctx;
  70. AVCodecContext *avctx;
  71. } AlacEncodeContext;
  72. static void init_sample_buffers(AlacEncodeContext *s,
  73. uint8_t * const *samples)
  74. {
  75. int ch, i;
  76. int shift = av_get_bytes_per_sample(s->avctx->sample_fmt) * 8 -
  77. s->avctx->bits_per_raw_sample;
  78. #define COPY_SAMPLES(type) do { \
  79. for (ch = 0; ch < s->avctx->channels; ch++) { \
  80. int32_t *bptr = s->sample_buf[ch]; \
  81. const type *sptr = (const type *)samples[ch]; \
  82. for (i = 0; i < s->frame_size; i++) \
  83. bptr[i] = sptr[i] >> shift; \
  84. } \
  85. } while (0)
  86. if (s->avctx->sample_fmt == AV_SAMPLE_FMT_S32P)
  87. COPY_SAMPLES(int32_t);
  88. else
  89. COPY_SAMPLES(int16_t);
  90. }
  91. static void encode_scalar(AlacEncodeContext *s, int x,
  92. int k, int write_sample_size)
  93. {
  94. int divisor, q, r;
  95. k = FFMIN(k, s->rc.k_modifier);
  96. divisor = (1<<k) - 1;
  97. q = x / divisor;
  98. r = x % divisor;
  99. if (q > 8) {
  100. // write escape code and sample value directly
  101. put_bits(&s->pbctx, 9, ALAC_ESCAPE_CODE);
  102. put_bits(&s->pbctx, write_sample_size, x);
  103. } else {
  104. if (q)
  105. put_bits(&s->pbctx, q, (1<<q) - 1);
  106. put_bits(&s->pbctx, 1, 0);
  107. if (k != 1) {
  108. if (r > 0)
  109. put_bits(&s->pbctx, k, r+1);
  110. else
  111. put_bits(&s->pbctx, k-1, 0);
  112. }
  113. }
  114. }
  115. static void write_frame_header(AlacEncodeContext *s)
  116. {
  117. int encode_fs = 0;
  118. if (s->frame_size < DEFAULT_FRAME_SIZE)
  119. encode_fs = 1;
  120. put_bits(&s->pbctx, 3, s->avctx->channels-1); // No. of channels -1
  121. put_bits(&s->pbctx, 16, 0); // Seems to be zero
  122. put_bits(&s->pbctx, 1, encode_fs); // Sample count is in the header
  123. put_bits(&s->pbctx, 2, s->extra_bits >> 3); // Extra bytes (for 24-bit)
  124. put_bits(&s->pbctx, 1, s->verbatim); // Audio block is verbatim
  125. if (encode_fs)
  126. put_bits32(&s->pbctx, s->frame_size); // No. of samples in the frame
  127. }
  128. static void calc_predictor_params(AlacEncodeContext *s, int ch)
  129. {
  130. int32_t coefs[MAX_LPC_ORDER][MAX_LPC_ORDER];
  131. int shift[MAX_LPC_ORDER];
  132. int opt_order;
  133. if (s->compression_level == 1) {
  134. s->lpc[ch].lpc_order = 6;
  135. s->lpc[ch].lpc_quant = 6;
  136. s->lpc[ch].lpc_coeff[0] = 160;
  137. s->lpc[ch].lpc_coeff[1] = -190;
  138. s->lpc[ch].lpc_coeff[2] = 170;
  139. s->lpc[ch].lpc_coeff[3] = -130;
  140. s->lpc[ch].lpc_coeff[4] = 80;
  141. s->lpc[ch].lpc_coeff[5] = -25;
  142. } else {
  143. opt_order = ff_lpc_calc_coefs(&s->lpc_ctx, s->sample_buf[ch],
  144. s->frame_size,
  145. s->min_prediction_order,
  146. s->max_prediction_order,
  147. ALAC_MAX_LPC_PRECISION, coefs, shift,
  148. FF_LPC_TYPE_LEVINSON, 0,
  149. ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);
  150. s->lpc[ch].lpc_order = opt_order;
  151. s->lpc[ch].lpc_quant = shift[opt_order-1];
  152. memcpy(s->lpc[ch].lpc_coeff, coefs[opt_order-1], opt_order*sizeof(int));
  153. }
  154. }
  155. static int estimate_stereo_mode(int32_t *left_ch, int32_t *right_ch, int n)
  156. {
  157. int i, best;
  158. int32_t lt, rt;
  159. uint64_t sum[4];
  160. uint64_t score[4];
  161. /* calculate sum of 2nd order residual for each channel */
  162. sum[0] = sum[1] = sum[2] = sum[3] = 0;
  163. for (i = 2; i < n; i++) {
  164. lt = left_ch[i] - 2 * left_ch[i - 1] + left_ch[i - 2];
  165. rt = right_ch[i] - 2 * right_ch[i - 1] + right_ch[i - 2];
  166. sum[2] += FFABS((lt + rt) >> 1);
  167. sum[3] += FFABS(lt - rt);
  168. sum[0] += FFABS(lt);
  169. sum[1] += FFABS(rt);
  170. }
  171. /* calculate score for each mode */
  172. score[0] = sum[0] + sum[1];
  173. score[1] = sum[0] + sum[3];
  174. score[2] = sum[1] + sum[3];
  175. score[3] = sum[2] + sum[3];
  176. /* return mode with lowest score */
  177. best = 0;
  178. for (i = 1; i < 4; i++) {
  179. if (score[i] < score[best])
  180. best = i;
  181. }
  182. return best;
  183. }
  184. static void alac_stereo_decorrelation(AlacEncodeContext *s)
  185. {
  186. int32_t *left = s->sample_buf[0], *right = s->sample_buf[1];
  187. int i, mode, n = s->frame_size;
  188. int32_t tmp;
  189. mode = estimate_stereo_mode(left, right, n);
  190. switch (mode) {
  191. case ALAC_CHMODE_LEFT_RIGHT:
  192. s->interlacing_leftweight = 0;
  193. s->interlacing_shift = 0;
  194. break;
  195. case ALAC_CHMODE_LEFT_SIDE:
  196. for (i = 0; i < n; i++)
  197. right[i] = left[i] - right[i];
  198. s->interlacing_leftweight = 1;
  199. s->interlacing_shift = 0;
  200. break;
  201. case ALAC_CHMODE_RIGHT_SIDE:
  202. for (i = 0; i < n; i++) {
  203. tmp = right[i];
  204. right[i] = left[i] - right[i];
  205. left[i] = tmp + (right[i] >> 31);
  206. }
  207. s->interlacing_leftweight = 1;
  208. s->interlacing_shift = 31;
  209. break;
  210. default:
  211. for (i = 0; i < n; i++) {
  212. tmp = left[i];
  213. left[i] = (tmp + right[i]) >> 1;
  214. right[i] = tmp - right[i];
  215. }
  216. s->interlacing_leftweight = 1;
  217. s->interlacing_shift = 1;
  218. break;
  219. }
  220. }
  221. static void alac_linear_predictor(AlacEncodeContext *s, int ch)
  222. {
  223. int i;
  224. AlacLPCContext lpc = s->lpc[ch];
  225. if (lpc.lpc_order == 31) {
  226. s->predictor_buf[0] = s->sample_buf[ch][0];
  227. for (i = 1; i < s->frame_size; i++) {
  228. s->predictor_buf[i] = s->sample_buf[ch][i ] -
  229. s->sample_buf[ch][i - 1];
  230. }
  231. return;
  232. }
  233. // generalised linear predictor
  234. if (lpc.lpc_order > 0) {
  235. int32_t *samples = s->sample_buf[ch];
  236. int32_t *residual = s->predictor_buf;
  237. // generate warm-up samples
  238. residual[0] = samples[0];
  239. for (i = 1; i <= lpc.lpc_order; i++)
  240. residual[i] = samples[i] - samples[i-1];
  241. // perform lpc on remaining samples
  242. for (i = lpc.lpc_order + 1; i < s->frame_size; i++) {
  243. int sum = 1 << (lpc.lpc_quant - 1), res_val, j;
  244. for (j = 0; j < lpc.lpc_order; j++) {
  245. sum += (samples[lpc.lpc_order-j] - samples[0]) *
  246. lpc.lpc_coeff[j];
  247. }
  248. sum >>= lpc.lpc_quant;
  249. sum += samples[0];
  250. residual[i] = sign_extend(samples[lpc.lpc_order+1] - sum,
  251. s->write_sample_size);
  252. res_val = residual[i];
  253. if (res_val) {
  254. int index = lpc.lpc_order - 1;
  255. int neg = (res_val < 0);
  256. while (index >= 0 && (neg ? (res_val < 0) : (res_val > 0))) {
  257. int val = samples[0] - samples[lpc.lpc_order - index];
  258. int sign = (val ? FFSIGN(val) : 0);
  259. if (neg)
  260. sign *= -1;
  261. lpc.lpc_coeff[index] -= sign;
  262. val *= sign;
  263. res_val -= (val >> lpc.lpc_quant) * (lpc.lpc_order - index);
  264. index--;
  265. }
  266. }
  267. samples++;
  268. }
  269. }
  270. }
  271. static void alac_entropy_coder(AlacEncodeContext *s)
  272. {
  273. unsigned int history = s->rc.initial_history;
  274. int sign_modifier = 0, i, k;
  275. int32_t *samples = s->predictor_buf;
  276. for (i = 0; i < s->frame_size;) {
  277. int x;
  278. k = av_log2((history >> 9) + 3);
  279. x = -2 * (*samples) -1;
  280. x ^= x >> 31;
  281. samples++;
  282. i++;
  283. encode_scalar(s, x - sign_modifier, k, s->write_sample_size);
  284. history += x * s->rc.history_mult -
  285. ((history * s->rc.history_mult) >> 9);
  286. sign_modifier = 0;
  287. if (x > 0xFFFF)
  288. history = 0xFFFF;
  289. if (history < 128 && i < s->frame_size) {
  290. unsigned int block_size = 0;
  291. k = 7 - av_log2(history) + ((history + 16) >> 6);
  292. while (*samples == 0 && i < s->frame_size) {
  293. samples++;
  294. i++;
  295. block_size++;
  296. }
  297. encode_scalar(s, block_size, k, 16);
  298. sign_modifier = (block_size <= 0xFFFF);
  299. history = 0;
  300. }
  301. }
  302. }
  303. static int write_frame(AlacEncodeContext *s, AVPacket *avpkt,
  304. uint8_t * const *samples)
  305. {
  306. int i, j;
  307. int prediction_type = 0;
  308. PutBitContext *pb = &s->pbctx;
  309. init_put_bits(pb, avpkt->data, avpkt->size);
  310. if (s->verbatim) {
  311. write_frame_header(s);
  312. /* samples are channel-interleaved in verbatim mode */
  313. if (s->avctx->sample_fmt == AV_SAMPLE_FMT_S32P) {
  314. int shift = 32 - s->avctx->bits_per_raw_sample;
  315. int32_t * const *samples_s32 = (int32_t * const *)samples;
  316. for (i = 0; i < s->frame_size; i++)
  317. for (j = 0; j < s->avctx->channels; j++)
  318. put_sbits(pb, s->avctx->bits_per_raw_sample,
  319. samples_s32[j][i] >> shift);
  320. } else {
  321. int16_t * const *samples_s16 = (int16_t * const *)samples;
  322. for (i = 0; i < s->frame_size; i++)
  323. for (j = 0; j < s->avctx->channels; j++)
  324. put_sbits(pb, s->avctx->bits_per_raw_sample,
  325. samples_s16[j][i]);
  326. }
  327. } else {
  328. init_sample_buffers(s, samples);
  329. write_frame_header(s);
  330. if (s->avctx->channels == 2)
  331. alac_stereo_decorrelation(s);
  332. put_bits(pb, 8, s->interlacing_shift);
  333. put_bits(pb, 8, s->interlacing_leftweight);
  334. for (i = 0; i < s->avctx->channels; i++) {
  335. calc_predictor_params(s, i);
  336. put_bits(pb, 4, prediction_type);
  337. put_bits(pb, 4, s->lpc[i].lpc_quant);
  338. put_bits(pb, 3, s->rc.rice_modifier);
  339. put_bits(pb, 5, s->lpc[i].lpc_order);
  340. // predictor coeff. table
  341. for (j = 0; j < s->lpc[i].lpc_order; j++)
  342. put_sbits(pb, 16, s->lpc[i].lpc_coeff[j]);
  343. }
  344. // write extra bits if needed
  345. if (s->extra_bits) {
  346. uint32_t mask = (1 << s->extra_bits) - 1;
  347. for (i = 0; i < s->frame_size; i++) {
  348. for (j = 0; j < s->avctx->channels; j++) {
  349. put_bits(pb, s->extra_bits, s->sample_buf[j][i] & mask);
  350. s->sample_buf[j][i] >>= s->extra_bits;
  351. }
  352. }
  353. }
  354. // apply lpc and entropy coding to audio samples
  355. for (i = 0; i < s->avctx->channels; i++) {
  356. alac_linear_predictor(s, i);
  357. // TODO: determine when this will actually help. for now it's not used.
  358. if (prediction_type == 15) {
  359. // 2nd pass 1st order filter
  360. for (j = s->frame_size - 1; j > 0; j--)
  361. s->predictor_buf[j] -= s->predictor_buf[j - 1];
  362. }
  363. alac_entropy_coder(s);
  364. }
  365. }
  366. put_bits(pb, 3, 7);
  367. flush_put_bits(pb);
  368. return put_bits_count(pb) >> 3;
  369. }
  370. static av_always_inline int get_max_frame_size(int frame_size, int ch, int bps)
  371. {
  372. int header_bits = 23 + 32 * (frame_size < DEFAULT_FRAME_SIZE);
  373. return FFALIGN(header_bits + bps * ch * frame_size + 3, 8) / 8;
  374. }
  375. static av_cold int alac_encode_close(AVCodecContext *avctx)
  376. {
  377. AlacEncodeContext *s = avctx->priv_data;
  378. ff_lpc_end(&s->lpc_ctx);
  379. av_freep(&avctx->extradata);
  380. avctx->extradata_size = 0;
  381. av_freep(&avctx->coded_frame);
  382. return 0;
  383. }
  384. static av_cold int alac_encode_init(AVCodecContext *avctx)
  385. {
  386. AlacEncodeContext *s = avctx->priv_data;
  387. int ret;
  388. uint8_t *alac_extradata;
  389. avctx->frame_size = s->frame_size = DEFAULT_FRAME_SIZE;
  390. /* TODO: Correctly implement multi-channel ALAC.
  391. It is similar to multi-channel AAC, in that it has a series of
  392. single-channel (SCE), channel-pair (CPE), and LFE elements. */
  393. if (avctx->channels > 2) {
  394. av_log(avctx, AV_LOG_ERROR, "only mono or stereo input is currently supported\n");
  395. return AVERROR_PATCHWELCOME;
  396. }
  397. if (avctx->sample_fmt == AV_SAMPLE_FMT_S32P) {
  398. if (avctx->bits_per_raw_sample != 24)
  399. av_log(avctx, AV_LOG_WARNING, "encoding as 24 bits-per-sample\n");
  400. avctx->bits_per_raw_sample = 24;
  401. } else {
  402. avctx->bits_per_raw_sample = 16;
  403. s->extra_bits = 0;
  404. }
  405. // Set default compression level
  406. if (avctx->compression_level == FF_COMPRESSION_DEFAULT)
  407. s->compression_level = 2;
  408. else
  409. s->compression_level = av_clip(avctx->compression_level, 0, 2);
  410. // Initialize default Rice parameters
  411. s->rc.history_mult = 40;
  412. s->rc.initial_history = 10;
  413. s->rc.k_modifier = 14;
  414. s->rc.rice_modifier = 4;
  415. s->max_coded_frame_size = get_max_frame_size(avctx->frame_size,
  416. avctx->channels,
  417. avctx->bits_per_raw_sample);
  418. avctx->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
  419. if (!avctx->extradata) {
  420. ret = AVERROR(ENOMEM);
  421. goto error;
  422. }
  423. avctx->extradata_size = ALAC_EXTRADATA_SIZE;
  424. alac_extradata = avctx->extradata;
  425. AV_WB32(alac_extradata, ALAC_EXTRADATA_SIZE);
  426. AV_WB32(alac_extradata+4, MKBETAG('a','l','a','c'));
  427. AV_WB32(alac_extradata+12, avctx->frame_size);
  428. AV_WB8 (alac_extradata+17, avctx->bits_per_raw_sample);
  429. AV_WB8 (alac_extradata+21, avctx->channels);
  430. AV_WB32(alac_extradata+24, s->max_coded_frame_size);
  431. AV_WB32(alac_extradata+28,
  432. avctx->sample_rate * avctx->channels * avctx->bits_per_raw_sample); // average bitrate
  433. AV_WB32(alac_extradata+32, avctx->sample_rate);
  434. // Set relevant extradata fields
  435. if (s->compression_level > 0) {
  436. AV_WB8(alac_extradata+18, s->rc.history_mult);
  437. AV_WB8(alac_extradata+19, s->rc.initial_history);
  438. AV_WB8(alac_extradata+20, s->rc.k_modifier);
  439. }
  440. s->min_prediction_order = DEFAULT_MIN_PRED_ORDER;
  441. if (avctx->min_prediction_order >= 0) {
  442. if (avctx->min_prediction_order < MIN_LPC_ORDER ||
  443. avctx->min_prediction_order > ALAC_MAX_LPC_ORDER) {
  444. av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n",
  445. avctx->min_prediction_order);
  446. ret = AVERROR(EINVAL);
  447. goto error;
  448. }
  449. s->min_prediction_order = avctx->min_prediction_order;
  450. }
  451. s->max_prediction_order = DEFAULT_MAX_PRED_ORDER;
  452. if (avctx->max_prediction_order >= 0) {
  453. if (avctx->max_prediction_order < MIN_LPC_ORDER ||
  454. avctx->max_prediction_order > ALAC_MAX_LPC_ORDER) {
  455. av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n",
  456. avctx->max_prediction_order);
  457. ret = AVERROR(EINVAL);
  458. goto error;
  459. }
  460. s->max_prediction_order = avctx->max_prediction_order;
  461. }
  462. if (s->max_prediction_order < s->min_prediction_order) {
  463. av_log(avctx, AV_LOG_ERROR,
  464. "invalid prediction orders: min=%d max=%d\n",
  465. s->min_prediction_order, s->max_prediction_order);
  466. ret = AVERROR(EINVAL);
  467. goto error;
  468. }
  469. avctx->coded_frame = avcodec_alloc_frame();
  470. if (!avctx->coded_frame) {
  471. ret = AVERROR(ENOMEM);
  472. goto error;
  473. }
  474. s->avctx = avctx;
  475. if ((ret = ff_lpc_init(&s->lpc_ctx, avctx->frame_size,
  476. s->max_prediction_order,
  477. FF_LPC_TYPE_LEVINSON)) < 0) {
  478. goto error;
  479. }
  480. return 0;
  481. error:
  482. alac_encode_close(avctx);
  483. return ret;
  484. }
  485. static int alac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
  486. const AVFrame *frame, int *got_packet_ptr)
  487. {
  488. AlacEncodeContext *s = avctx->priv_data;
  489. int out_bytes, max_frame_size, ret;
  490. s->frame_size = frame->nb_samples;
  491. if (frame->nb_samples < DEFAULT_FRAME_SIZE)
  492. max_frame_size = get_max_frame_size(s->frame_size, avctx->channels,
  493. avctx->bits_per_raw_sample);
  494. else
  495. max_frame_size = s->max_coded_frame_size;
  496. if ((ret = ff_alloc_packet(avpkt, 2 * max_frame_size))) {
  497. av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
  498. return ret;
  499. }
  500. /* use verbatim mode for compression_level 0 */
  501. if (s->compression_level) {
  502. s->verbatim = 0;
  503. s->extra_bits = avctx->bits_per_raw_sample - 16;
  504. } else {
  505. s->verbatim = 1;
  506. s->extra_bits = 0;
  507. }
  508. s->write_sample_size = avctx->bits_per_raw_sample - s->extra_bits +
  509. avctx->channels - 1;
  510. out_bytes = write_frame(s, avpkt, frame->extended_data);
  511. if (out_bytes > max_frame_size) {
  512. /* frame too large. use verbatim mode */
  513. s->verbatim = 1;
  514. s->extra_bits = 0;
  515. s->write_sample_size = avctx->bits_per_raw_sample + avctx->channels - 1;
  516. out_bytes = write_frame(s, avpkt, frame->extended_data);
  517. }
  518. avpkt->size = out_bytes;
  519. *got_packet_ptr = 1;
  520. return 0;
  521. }
  522. AVCodec ff_alac_encoder = {
  523. .name = "alac",
  524. .type = AVMEDIA_TYPE_AUDIO,
  525. .id = AV_CODEC_ID_ALAC,
  526. .priv_data_size = sizeof(AlacEncodeContext),
  527. .init = alac_encode_init,
  528. .encode2 = alac_encode_frame,
  529. .close = alac_encode_close,
  530. .capabilities = CODEC_CAP_SMALL_LAST_FRAME,
  531. .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32P,
  532. AV_SAMPLE_FMT_S16P,
  533. AV_SAMPLE_FMT_NONE },
  534. .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
  535. };