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