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