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.

661 lines
20KB

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