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.

665 lines
20KB

  1. /*
  2. * Shorten decoder
  3. * Copyright (c) 2005 Jeff Muizelaar
  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. * Shorten decoder
  24. * @author Jeff Muizelaar
  25. *
  26. */
  27. #include <limits.h>
  28. #include "avcodec.h"
  29. #include "bytestream.h"
  30. #include "get_bits.h"
  31. #include "golomb.h"
  32. #include "internal.h"
  33. #define MAX_CHANNELS 8
  34. #define MAX_BLOCKSIZE 65535
  35. #define OUT_BUFFER_SIZE 16384
  36. #define ULONGSIZE 2
  37. #define WAVE_FORMAT_PCM 0x0001
  38. #define DEFAULT_BLOCK_SIZE 256
  39. #define TYPESIZE 4
  40. #define CHANSIZE 0
  41. #define LPCQSIZE 2
  42. #define ENERGYSIZE 3
  43. #define BITSHIFTSIZE 2
  44. #define TYPE_S16HL 3
  45. #define TYPE_S16LH 5
  46. #define NWRAP 3
  47. #define NSKIPSIZE 1
  48. #define LPCQUANT 5
  49. #define V2LPCQOFFSET (1 << LPCQUANT)
  50. #define FNSIZE 2
  51. #define FN_DIFF0 0
  52. #define FN_DIFF1 1
  53. #define FN_DIFF2 2
  54. #define FN_DIFF3 3
  55. #define FN_QUIT 4
  56. #define FN_BLOCKSIZE 5
  57. #define FN_BITSHIFT 6
  58. #define FN_QLPC 7
  59. #define FN_ZERO 8
  60. #define FN_VERBATIM 9
  61. /** indicates if the FN_* command is audio or non-audio */
  62. static const uint8_t is_audio_command[10] = { 1, 1, 1, 1, 0, 0, 0, 1, 1, 0 };
  63. #define VERBATIM_CKSIZE_SIZE 5
  64. #define VERBATIM_BYTE_SIZE 8
  65. #define CANONICAL_HEADER_SIZE 44
  66. typedef struct ShortenContext {
  67. AVCodecContext *avctx;
  68. GetBitContext gb;
  69. int min_framesize, max_framesize;
  70. unsigned channels;
  71. int32_t *decoded[MAX_CHANNELS];
  72. int32_t *decoded_base[MAX_CHANNELS];
  73. int32_t *offset[MAX_CHANNELS];
  74. int *coeffs;
  75. uint8_t *bitstream;
  76. int bitstream_size;
  77. int bitstream_index;
  78. unsigned int allocated_bitstream_size;
  79. int header_size;
  80. uint8_t header[OUT_BUFFER_SIZE];
  81. int version;
  82. int cur_chan;
  83. int bitshift;
  84. int nmean;
  85. int internal_ftype;
  86. int nwrap;
  87. int blocksize;
  88. int bitindex;
  89. int32_t lpcqoffset;
  90. int got_header;
  91. int got_quit_command;
  92. } ShortenContext;
  93. static av_cold int shorten_decode_init(AVCodecContext *avctx)
  94. {
  95. ShortenContext *s = avctx->priv_data;
  96. s->avctx = avctx;
  97. avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
  98. return 0;
  99. }
  100. static int allocate_buffers(ShortenContext *s)
  101. {
  102. int i, chan, err;
  103. for (chan = 0; chan < s->channels; chan++) {
  104. if (FFMAX(1, s->nmean) >= UINT_MAX / sizeof(int32_t)) {
  105. av_log(s->avctx, AV_LOG_ERROR, "nmean too large\n");
  106. return AVERROR_INVALIDDATA;
  107. }
  108. if (s->blocksize + s->nwrap >= UINT_MAX / sizeof(int32_t) ||
  109. s->blocksize + s->nwrap <= (unsigned)s->nwrap) {
  110. av_log(s->avctx, AV_LOG_ERROR,
  111. "s->blocksize + s->nwrap too large\n");
  112. return AVERROR_INVALIDDATA;
  113. }
  114. if ((err = av_reallocp(&s->offset[chan],
  115. sizeof(int32_t) *
  116. FFMAX(1, s->nmean))) < 0)
  117. return err;
  118. if ((err = av_reallocp(&s->decoded_base[chan], (s->blocksize + s->nwrap) *
  119. sizeof(s->decoded_base[0][0]))) < 0)
  120. return err;
  121. for (i = 0; i < s->nwrap; i++)
  122. s->decoded_base[chan][i] = 0;
  123. s->decoded[chan] = s->decoded_base[chan] + s->nwrap;
  124. }
  125. if ((err = av_reallocp(&s->coeffs, s->nwrap * sizeof(*s->coeffs))) < 0)
  126. return err;
  127. return 0;
  128. }
  129. static inline unsigned int get_uint(ShortenContext *s, int k)
  130. {
  131. if (s->version != 0)
  132. k = get_ur_golomb_shorten(&s->gb, ULONGSIZE);
  133. return get_ur_golomb_shorten(&s->gb, k);
  134. }
  135. static void fix_bitshift(ShortenContext *s, int32_t *buffer)
  136. {
  137. int i;
  138. if (s->bitshift != 0)
  139. for (i = 0; i < s->blocksize; i++)
  140. buffer[i] <<= s->bitshift;
  141. }
  142. static int init_offset(ShortenContext *s)
  143. {
  144. int32_t mean = 0;
  145. int chan, i;
  146. int nblock = FFMAX(1, s->nmean);
  147. /* initialise offset */
  148. switch (s->internal_ftype) {
  149. case TYPE_S16HL:
  150. case TYPE_S16LH:
  151. mean = 0;
  152. break;
  153. default:
  154. av_log(s->avctx, AV_LOG_ERROR, "unknown audio type");
  155. return AVERROR_INVALIDDATA;
  156. }
  157. for (chan = 0; chan < s->channels; chan++)
  158. for (i = 0; i < nblock; i++)
  159. s->offset[chan][i] = mean;
  160. return 0;
  161. }
  162. static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header,
  163. int header_size)
  164. {
  165. int len;
  166. short wave_format;
  167. GetByteContext gb;
  168. bytestream2_init(&gb, header, header_size);
  169. if (bytestream2_get_le32(&gb) != MKTAG('R', 'I', 'F', 'F')) {
  170. av_log(avctx, AV_LOG_ERROR, "missing RIFF tag\n");
  171. return AVERROR_INVALIDDATA;
  172. }
  173. bytestream2_skip(&gb, 4); /* chunk size */
  174. if (bytestream2_get_le32(&gb) != MKTAG('W', 'A', 'V', 'E')) {
  175. av_log(avctx, AV_LOG_ERROR, "missing WAVE tag\n");
  176. return AVERROR_INVALIDDATA;
  177. }
  178. while (bytestream2_get_le32(&gb) != MKTAG('f', 'm', 't', ' ')) {
  179. len = bytestream2_get_le32(&gb);
  180. bytestream2_skip(&gb, len);
  181. if (bytestream2_get_bytes_left(&gb) < 16) {
  182. av_log(avctx, AV_LOG_ERROR, "no fmt chunk found\n");
  183. return AVERROR_INVALIDDATA;
  184. }
  185. }
  186. len = bytestream2_get_le32(&gb);
  187. if (len < 16) {
  188. av_log(avctx, AV_LOG_ERROR, "fmt chunk was too short\n");
  189. return AVERROR_INVALIDDATA;
  190. }
  191. wave_format = bytestream2_get_le16(&gb);
  192. switch (wave_format) {
  193. case WAVE_FORMAT_PCM:
  194. break;
  195. default:
  196. av_log(avctx, AV_LOG_ERROR, "unsupported wave format\n");
  197. return AVERROR(ENOSYS);
  198. }
  199. bytestream2_skip(&gb, 2); // skip channels (already got from shorten header)
  200. avctx->sample_rate = bytestream2_get_le32(&gb);
  201. bytestream2_skip(&gb, 4); // skip bit rate (represents original uncompressed bit rate)
  202. bytestream2_skip(&gb, 2); // skip block align (not needed)
  203. avctx->bits_per_coded_sample = bytestream2_get_le16(&gb);
  204. if (avctx->bits_per_coded_sample != 16) {
  205. av_log(avctx, AV_LOG_ERROR, "unsupported number of bits per sample\n");
  206. return AVERROR(ENOSYS);
  207. }
  208. len -= 16;
  209. if (len > 0)
  210. av_log(avctx, AV_LOG_INFO, "%d header bytes unparsed\n", len);
  211. return 0;
  212. }
  213. static void output_buffer(int16_t **samples, int nchan, int blocksize,
  214. int32_t **buffer)
  215. {
  216. int i, ch;
  217. for (ch = 0; ch < nchan; ch++) {
  218. int32_t *in = buffer[ch];
  219. int16_t *out = samples[ch];
  220. for (i = 0; i < blocksize; i++)
  221. out[i] = av_clip_int16(in[i]);
  222. }
  223. }
  224. static const int fixed_coeffs[][3] = {
  225. { 0, 0, 0 },
  226. { 1, 0, 0 },
  227. { 2, -1, 0 },
  228. { 3, -3, 1 }
  229. };
  230. static int decode_subframe_lpc(ShortenContext *s, int command, int channel,
  231. int residual_size, int32_t coffset)
  232. {
  233. int pred_order, sum, qshift, init_sum, i, j;
  234. const int *coeffs;
  235. if (command == FN_QLPC) {
  236. /* read/validate prediction order */
  237. pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE);
  238. if (pred_order > s->nwrap) {
  239. av_log(s->avctx, AV_LOG_ERROR, "invalid pred_order %d\n",
  240. pred_order);
  241. return AVERROR(EINVAL);
  242. }
  243. /* read LPC coefficients */
  244. for (i = 0; i < pred_order; i++)
  245. s->coeffs[i] = get_sr_golomb_shorten(&s->gb, LPCQUANT);
  246. coeffs = s->coeffs;
  247. qshift = LPCQUANT;
  248. } else {
  249. /* fixed LPC coeffs */
  250. pred_order = command;
  251. if (pred_order >= FF_ARRAY_ELEMS(fixed_coeffs)) {
  252. av_log(s->avctx, AV_LOG_ERROR, "invalid pred_order %d\n",
  253. pred_order);
  254. return AVERROR_INVALIDDATA;
  255. }
  256. coeffs = fixed_coeffs[pred_order];
  257. qshift = 0;
  258. }
  259. /* subtract offset from previous samples to use in prediction */
  260. if (command == FN_QLPC && coffset)
  261. for (i = -pred_order; i < 0; i++)
  262. s->decoded[channel][i] -= coffset;
  263. /* decode residual and do LPC prediction */
  264. init_sum = pred_order ? (command == FN_QLPC ? s->lpcqoffset : 0) : coffset;
  265. for (i = 0; i < s->blocksize; i++) {
  266. sum = init_sum;
  267. for (j = 0; j < pred_order; j++)
  268. sum += coeffs[j] * s->decoded[channel][i - j - 1];
  269. s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) +
  270. (sum >> qshift);
  271. }
  272. /* add offset to current samples */
  273. if (command == FN_QLPC && coffset)
  274. for (i = 0; i < s->blocksize; i++)
  275. s->decoded[channel][i] += coffset;
  276. return 0;
  277. }
  278. static int read_header(ShortenContext *s)
  279. {
  280. int i, ret;
  281. int maxnlpc = 0;
  282. /* shorten signature */
  283. if (get_bits_long(&s->gb, 32) != AV_RB32("ajkg")) {
  284. av_log(s->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n");
  285. return AVERROR_INVALIDDATA;
  286. }
  287. s->lpcqoffset = 0;
  288. s->blocksize = DEFAULT_BLOCK_SIZE;
  289. s->nmean = -1;
  290. s->version = get_bits(&s->gb, 8);
  291. s->internal_ftype = get_uint(s, TYPESIZE);
  292. s->channels = get_uint(s, CHANSIZE);
  293. if (!s->channels) {
  294. av_log(s->avctx, AV_LOG_ERROR, "No channels reported\n");
  295. return AVERROR_INVALIDDATA;
  296. }
  297. if (s->channels > MAX_CHANNELS) {
  298. av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels);
  299. s->channels = 0;
  300. return AVERROR_INVALIDDATA;
  301. }
  302. s->avctx->channels = s->channels;
  303. /* get blocksize if version > 0 */
  304. if (s->version > 0) {
  305. int skip_bytes;
  306. unsigned blocksize;
  307. blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE));
  308. if (!blocksize || blocksize > MAX_BLOCKSIZE) {
  309. av_log(s->avctx, AV_LOG_ERROR,
  310. "invalid or unsupported block size: %d\n",
  311. blocksize);
  312. return AVERROR(EINVAL);
  313. }
  314. s->blocksize = blocksize;
  315. maxnlpc = get_uint(s, LPCQSIZE);
  316. s->nmean = get_uint(s, 0);
  317. skip_bytes = get_uint(s, NSKIPSIZE);
  318. for (i = 0; i < skip_bytes; i++)
  319. skip_bits(&s->gb, 8);
  320. }
  321. s->nwrap = FFMAX(NWRAP, maxnlpc);
  322. if ((ret = allocate_buffers(s)) < 0)
  323. return ret;
  324. if ((ret = init_offset(s)) < 0)
  325. return ret;
  326. if (s->version > 1)
  327. s->lpcqoffset = V2LPCQOFFSET;
  328. if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) {
  329. av_log(s->avctx, AV_LOG_ERROR,
  330. "missing verbatim section at beginning of stream\n");
  331. return AVERROR_INVALIDDATA;
  332. }
  333. s->header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);
  334. if (s->header_size >= OUT_BUFFER_SIZE ||
  335. s->header_size < CANONICAL_HEADER_SIZE) {
  336. av_log(s->avctx, AV_LOG_ERROR, "header is wrong size: %d\n",
  337. s->header_size);
  338. return AVERROR_INVALIDDATA;
  339. }
  340. for (i = 0; i < s->header_size; i++)
  341. s->header[i] = (char)get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);
  342. if ((ret = decode_wave_header(s->avctx, s->header, s->header_size)) < 0)
  343. return ret;
  344. s->cur_chan = 0;
  345. s->bitshift = 0;
  346. s->got_header = 1;
  347. return 0;
  348. }
  349. static int shorten_decode_frame(AVCodecContext *avctx, void *data,
  350. int *got_frame_ptr, AVPacket *avpkt)
  351. {
  352. AVFrame *frame = data;
  353. const uint8_t *buf = avpkt->data;
  354. int buf_size = avpkt->size;
  355. ShortenContext *s = avctx->priv_data;
  356. int i, input_buf_size = 0;
  357. int ret;
  358. /* allocate internal bitstream buffer */
  359. if (s->max_framesize == 0) {
  360. void *tmp_ptr;
  361. s->max_framesize = 1024; // should hopefully be enough for the first header
  362. tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size,
  363. s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE);
  364. if (!tmp_ptr) {
  365. av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n");
  366. return AVERROR(ENOMEM);
  367. }
  368. s->bitstream = tmp_ptr;
  369. }
  370. /* append current packet data to bitstream buffer */
  371. if (1 && s->max_framesize) { //FIXME truncated
  372. buf_size = FFMIN(buf_size, s->max_framesize - s->bitstream_size);
  373. input_buf_size = buf_size;
  374. if (s->bitstream_index + s->bitstream_size + buf_size >
  375. s->allocated_bitstream_size) {
  376. memmove(s->bitstream, &s->bitstream[s->bitstream_index],
  377. s->bitstream_size);
  378. s->bitstream_index = 0;
  379. }
  380. if (buf)
  381. memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf,
  382. buf_size);
  383. buf = &s->bitstream[s->bitstream_index];
  384. buf_size += s->bitstream_size;
  385. s->bitstream_size = buf_size;
  386. /* do not decode until buffer has at least max_framesize bytes or
  387. * the end of the file has been reached */
  388. if (buf_size < s->max_framesize && avpkt->data) {
  389. *got_frame_ptr = 0;
  390. return input_buf_size;
  391. }
  392. }
  393. /* init and position bitstream reader */
  394. init_get_bits(&s->gb, buf, buf_size * 8);
  395. skip_bits(&s->gb, s->bitindex);
  396. /* process header or next subblock */
  397. if (!s->got_header) {
  398. if ((ret = read_header(s)) < 0)
  399. return ret;
  400. *got_frame_ptr = 0;
  401. goto finish_frame;
  402. }
  403. /* if quit command was read previously, don't decode anything */
  404. if (s->got_quit_command) {
  405. *got_frame_ptr = 0;
  406. return avpkt->size;
  407. }
  408. s->cur_chan = 0;
  409. while (s->cur_chan < s->channels) {
  410. unsigned cmd;
  411. int len;
  412. if (get_bits_left(&s->gb) < 3 + FNSIZE) {
  413. *got_frame_ptr = 0;
  414. break;
  415. }
  416. cmd = get_ur_golomb_shorten(&s->gb, FNSIZE);
  417. if (cmd > FN_VERBATIM) {
  418. av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd);
  419. *got_frame_ptr = 0;
  420. break;
  421. }
  422. if (!is_audio_command[cmd]) {
  423. /* process non-audio command */
  424. switch (cmd) {
  425. case FN_VERBATIM:
  426. len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE);
  427. while (len--)
  428. get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE);
  429. break;
  430. case FN_BITSHIFT:
  431. s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
  432. if (s->bitshift < 0)
  433. return AVERROR_INVALIDDATA;
  434. break;
  435. case FN_BLOCKSIZE: {
  436. unsigned blocksize = get_uint(s, av_log2(s->blocksize));
  437. if (blocksize > s->blocksize) {
  438. av_log(avctx, AV_LOG_ERROR,
  439. "Increasing block size is not supported\n");
  440. return AVERROR_PATCHWELCOME;
  441. }
  442. if (!blocksize || blocksize > MAX_BLOCKSIZE) {
  443. av_log(avctx, AV_LOG_ERROR, "invalid or unsupported "
  444. "block size: %d\n", blocksize);
  445. return AVERROR(EINVAL);
  446. }
  447. s->blocksize = blocksize;
  448. break;
  449. }
  450. case FN_QUIT:
  451. s->got_quit_command = 1;
  452. break;
  453. }
  454. if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) {
  455. *got_frame_ptr = 0;
  456. break;
  457. }
  458. } else {
  459. /* process audio command */
  460. int residual_size = 0;
  461. int channel = s->cur_chan;
  462. int32_t coffset;
  463. /* get Rice code for residual decoding */
  464. if (cmd != FN_ZERO) {
  465. residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE);
  466. /* This is a hack as version 0 differed in the definition
  467. * of get_sr_golomb_shorten(). */
  468. if (s->version == 0)
  469. residual_size--;
  470. }
  471. /* calculate sample offset using means from previous blocks */
  472. if (s->nmean == 0)
  473. coffset = s->offset[channel][0];
  474. else {
  475. int32_t sum = (s->version < 2) ? 0 : s->nmean / 2;
  476. for (i = 0; i < s->nmean; i++)
  477. sum += s->offset[channel][i];
  478. coffset = sum / s->nmean;
  479. if (s->version >= 2)
  480. coffset >>= FFMIN(1, s->bitshift);
  481. }
  482. /* decode samples for this channel */
  483. if (cmd == FN_ZERO) {
  484. for (i = 0; i < s->blocksize; i++)
  485. s->decoded[channel][i] = 0;
  486. } else {
  487. if ((ret = decode_subframe_lpc(s, cmd, channel,
  488. residual_size, coffset)) < 0)
  489. return ret;
  490. }
  491. /* update means with info from the current block */
  492. if (s->nmean > 0) {
  493. int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2;
  494. for (i = 0; i < s->blocksize; i++)
  495. sum += s->decoded[channel][i];
  496. for (i = 1; i < s->nmean; i++)
  497. s->offset[channel][i - 1] = s->offset[channel][i];
  498. if (s->version < 2)
  499. s->offset[channel][s->nmean - 1] = sum / s->blocksize;
  500. else
  501. s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift;
  502. }
  503. /* copy wrap samples for use with next block */
  504. for (i = -s->nwrap; i < 0; i++)
  505. s->decoded[channel][i] = s->decoded[channel][i + s->blocksize];
  506. /* shift samples to add in unused zero bits which were removed
  507. * during encoding */
  508. fix_bitshift(s, s->decoded[channel]);
  509. /* if this is the last channel in the block, output the samples */
  510. s->cur_chan++;
  511. if (s->cur_chan == s->channels) {
  512. /* get output buffer */
  513. frame->nb_samples = s->blocksize;
  514. if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
  515. av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
  516. return ret;
  517. }
  518. /* interleave output */
  519. output_buffer((int16_t **)frame->extended_data, s->channels,
  520. s->blocksize, s->decoded);
  521. *got_frame_ptr = 1;
  522. }
  523. }
  524. }
  525. if (s->cur_chan < s->channels)
  526. *got_frame_ptr = 0;
  527. finish_frame:
  528. s->bitindex = get_bits_count(&s->gb) - 8 * (get_bits_count(&s->gb) / 8);
  529. i = get_bits_count(&s->gb) / 8;
  530. if (i > buf_size) {
  531. av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
  532. s->bitstream_size = 0;
  533. s->bitstream_index = 0;
  534. return AVERROR_INVALIDDATA;
  535. }
  536. if (s->bitstream_size) {
  537. s->bitstream_index += i;
  538. s->bitstream_size -= i;
  539. return input_buf_size;
  540. } else
  541. return i;
  542. }
  543. static av_cold int shorten_decode_close(AVCodecContext *avctx)
  544. {
  545. ShortenContext *s = avctx->priv_data;
  546. int i;
  547. for (i = 0; i < s->channels; i++) {
  548. s->decoded[i] = NULL;
  549. av_freep(&s->decoded_base[i]);
  550. av_freep(&s->offset[i]);
  551. }
  552. av_freep(&s->bitstream);
  553. av_freep(&s->coeffs);
  554. return 0;
  555. }
  556. AVCodec ff_shorten_decoder = {
  557. .name = "shorten",
  558. .long_name = NULL_IF_CONFIG_SMALL("Shorten"),
  559. .type = AVMEDIA_TYPE_AUDIO,
  560. .id = AV_CODEC_ID_SHORTEN,
  561. .priv_data_size = sizeof(ShortenContext),
  562. .init = shorten_decode_init,
  563. .close = shorten_decode_close,
  564. .decode = shorten_decode_frame,
  565. .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1,
  566. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
  567. AV_SAMPLE_FMT_NONE },
  568. };