Credit Andrew fix Alpha Bug of BT558 + small cleanup
[goodguy/cinelerra.git] / cinelerra-5.1 / thirdparty / src / ffmpeg-4.4.patch_99
1 --- ffmpeg-4.4/libavcodec/pcm-bluenc.c  2022-04-24 09:45:43.921091116 +0300
2 +++ ffmpeg-4.4/libavcodec/pcm-bluenc.c  2022-04-24 16:07:28.537982120 +0300
3 @@ -1,6 +1,5 @@
4  /*
5   * LPCM codecs for PCM formats found in Blu-ray m2ts streams
6 - * Copyright (c) 2018 Paul B Mahol
7   *
8   * This file is part of FFmpeg.
9   *
10 @@ -19,314 +18,305 @@
11   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
12   */
13  
14 +#include "libavutil/channel_layout.h"
15  #include "avcodec.h"
16  #include "bytestream.h"
17 +//#include "codec_internal.h"
18 +#include "encode.h"
19  #include "internal.h"
20  
21 -typedef struct PCMBDContext {
22 -    uint8_t header[4];       // Header added to every frame
23 -    int block_size;          // Size of a block of samples in bytes
24 -    int samples_per_block;   // Number of samples per channel per block
25 -    int groups_per_block;    // Number of 20/24-bit sample groups per block
26 -    uint8_t *extra_samples;  // Pointer to leftover samples from a frame
27 -    int extra_sample_count;  // Number of leftover samples in the buffer
28 -} PCMBDContext;
29 +typedef struct BlurayPCMEncContext {
30 +    uint16_t header;      // Header added to every frame
31 +} BlurayPCMEncContext;
32  
33 -static av_cold int pcm_bd_encode_init(AVCodecContext *avctx)
34 +static av_cold int pcm_bluray_encode_init(AVCodecContext *avctx)
35  {
36 -    PCMBDContext *s = avctx->priv_data;
37 -    int quant, freq;
38 -    uint16_t frame_size;
39 -    uint8_t ch_layout = 0;
40 -
41 +    BlurayPCMEncContext *s = avctx->priv_data;
42 +    uint8_t ch_layout;
43 +    int quant, freq, frame_size;
44 +    
45 +    switch(avctx->sample_fmt) {
46 +    case AV_SAMPLE_FMT_S16:
47 +       avctx->bits_per_coded_sample = 16;
48 +       frame_size = 240;
49 +       quant =1;
50 +       break;
51 +    case AV_SAMPLE_FMT_S32:
52 +       avctx->bits_per_coded_sample = 24;
53 +       frame_size = 360;
54 +       quant =3;
55 +       break;
56 +    default:
57 +    return AVERROR_BUG;
58 +    }
59 +    
60      switch (avctx->sample_rate) {
61      case 48000:
62          freq = 1;
63          break;
64      case 96000:
65 +        //frame_size *= 2;
66          freq = 4;
67          break;
68      case 192000:
69 -       freq = 5;
70 -       break;
71 +       //frame_size *= 4;
72 +        freq = 5;
73 +        break;
74 +    default:
75 +        return AVERROR_BUG;
76      }
77  
78 -    switch (avctx->sample_fmt) {
79 -    case AV_SAMPLE_FMT_S16:
80 -        avctx->bits_per_coded_sample = 16;
81 -        quant = 1;
82 +    //frame_size *= avctx->channels;
83 +    
84 +    switch (avctx->channel_layout) {
85 +    case AV_CH_LAYOUT_MONO:
86 +        ch_layout = 1;
87          break;
88 -/*    case AV_SAMPLE_FMT_S20:
89 -        avctx->bits_per_coded_sample = 20;
90 -        quant = 2;
91 +    case AV_CH_LAYOUT_STEREO:
92 +        ch_layout = 3;
93          break;
94 -*/
95 -    case AV_SAMPLE_FMT_S32:
96 -        avctx->bits_per_coded_sample = 24;
97 -        quant = 3;
98 +    case AV_CH_LAYOUT_SURROUND:
99 +        ch_layout = 4;
100          break;
101 -    }
102 -
103 -    avctx->block_align           = avctx->channels * avctx->bits_per_coded_sample / 8;
104 -    avctx->bit_rate              = avctx->block_align * 8LL * avctx->sample_rate;
105 -    if (avctx->bit_rate > 19800000) {
106 -        av_log(avctx, AV_LOG_ERROR, "Too big bitrate: reduce sample rate, bitdepth or channels.\n");
107 -        return AVERROR(EINVAL);
108 -    }
109 -
110 -    if (avctx->sample_fmt == AV_SAMPLE_FMT_S16) {
111 -       switch (avctx->channels) {
112 -       case 1:
113 -           s->block_size = avctx->channels * 4;
114 -           break;
115 -       default:
116 -        s->block_size        = avctx->channels * 2;
117 +    case AV_CH_LAYOUT_2_1:
118 +        ch_layout = 5;
119          break;
120 -        }
121 -        s->samples_per_block = 1;
122 -        frame_size           = 2008 / s->block_size;
123 -    } else {
124 -        switch (avctx->channels) {
125 -        case 1:
126 -            s->block_size        = 2 * avctx->channels * avctx->bits_per_coded_sample / 8;
127 -           s->samples_per_block = 1;
128 -        break;
129 -        case 2:
130 -        case 4:
131 -            /* one group has all the samples needed */
132 -            s->block_size        = avctx->channels * avctx->bits_per_coded_sample / 8;
133 -            s->samples_per_block = 1;
134 -            s->groups_per_block  = 2;
135 -            break;
136 -        case 8:
137 -        case 6:
138 -            /* two groups have all the samples needed */
139 -            s->block_size        = avctx->channels * avctx->bits_per_coded_sample / 8;
140 -            s->samples_per_block = 1;
141 -            // s->groups_per_block  = 2;
142 -            break;
143 -        default:
144 -            /* need avctx->channels groups */
145 -            s->block_size        = 4 * avctx->channels *
146 -                                   avctx->bits_per_coded_sample / 8;
147 -            s->samples_per_block = 4;
148 -            s->groups_per_block  = avctx->channels;
149 -            break;
150 -        }
151 -
152 -        frame_size = FFALIGN(2008 / s->block_size, s->samples_per_block);
153 +    case AV_CH_LAYOUT_4POINT0:
154 +        ch_layout = 6;
155 +        break;
156 +    case AV_CH_LAYOUT_2_2:
157 +        ch_layout = 7;
158 +        break;
159 +    case AV_CH_LAYOUT_5POINT0:
160 +        ch_layout = 8;
161 +        break;
162 +    case AV_CH_LAYOUT_5POINT1_BACK:
163 +        ch_layout = 9;
164 +        break;
165 +    case AV_CH_LAYOUT_7POINT0:
166 +        ch_layout = 10;
167 +        break;
168 +    case AV_CH_LAYOUT_7POINT1:
169 +        ch_layout = 11;
170 +        break;
171 +    default:
172 +        return AVERROR_BUG;
173      }
174  
175 -    switch(avctx->channel_layout) {
176 -       case AV_CH_LAYOUT_MONO:
177 -               ch_layout = 1;
178 -               break;
179 -       case AV_CH_LAYOUT_STEREO:
180 -               ch_layout = 3;
181 -               break;
182 -       case AV_CH_LAYOUT_5POINT1:
183 -       case AV_CH_LAYOUT_5POINT1_BACK:
184 -               ch_layout = 9;
185 -               break;
186 -       case AV_CH_LAYOUT_7POINT1:
187 -               ch_layout = 11;
188 -               break;
189 -       default:
190 -               av_log(avctx, AV_LOG_ERROR, "Not yet implemented ch layout!\n");
191 -       }
192 -// description on the web:
193 -/* http://forum.doom9.org/showthread.php?t=152897
194 -
195 -It's a header.
196 -
197 -size in bytes = 16 bits (big endian)
198 -channel assignment = 4 bits
199 -sampling frequency = 4 bits
200 -bits per sample = 2 bits
201 -start flag = 1 bit
202 -reserved = 5 bits
203 -
204 -channel assignment
205 -1 = mono
206 -3 = stereo
207 -4 = 3/0
208 -5 = 2/1
209 -6 = 3/1
210 -7 = 2/2
211 -8 = 3/2
212 -9 = 3/2+lfe
213 -10 = 3/4
214 -11 = 3/4+lfe
215 -
216 -sampling frequency
217 -1 = 48 kHz
218 -4 = 96 kHz
219 -5 = 192 kHz
220 -
221 -bits per sample
222 -1 = 16
223 -2 = 20
224 -3 = 24
225 -*/
226 -
227 -    s->header[2] = (ch_layout << 4) | (freq);
228 -    s->header[3] = (quant << 6) | 0x1 ;
229 -
230 -
231 -        avctx->frame_size = frame_size; // in num. of samples
232 +    s->header = (((ch_layout << 4) | freq) << 8) | (quant << 6);
233 +    avctx->frame_size = frame_size;
234  
235      return 0;
236  }
237  
238 -static int pcm_bd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
239 -                                const AVFrame *frame, int *got_packet_ptr)
240 +static int pcm_bluray_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
241 +                                   const AVFrame *frame, int *got_packet_ptr)
242  {
243 -    PCMBDContext *s = avctx->priv_data;
244 -    int samples, channels;
245 -    int64_t pkt_size = (frame->nb_samples / s->samples_per_block) * s->block_size + 4;
246 +    BlurayPCMEncContext *s = avctx->priv_data;
247 +    int sample_size, samples, channel, num_dest_channels;
248      const int16_t *src16;
249      const int32_t *src32;
250 +    unsigned pkt_size;
251      PutByteContext pb;
252      int ret;
253  
254 -    if ((ret = ff_alloc_packet2(avctx, avpkt, pkt_size, 0)) < 0)
255 +    num_dest_channels = FFALIGN(avctx->channels, 2);
256 +    sample_size = (num_dest_channels *
257 +                   (avctx->sample_fmt == AV_SAMPLE_FMT_S16 ? 16 : 24)) >> 3;
258 +    samples = frame->nb_samples;
259 +
260 +    pkt_size = sample_size * samples + 4;
261 +
262 +    if ((ret = ff_get_encode_buffer(avctx, avpkt, pkt_size, 0)) < 0)
263          return ret;
264  
265 -    AV_WB16(s->header, pkt_size - 4);
266 -    memcpy(avpkt->data, s->header, 4);
267 +    AV_WB16(avpkt->data, pkt_size - 4);
268 +    AV_WB16(avpkt->data + 2, s->header);
269  
270      src16 = (const int16_t *)frame->data[0];
271      src32 = (const int32_t *)frame->data[0];
272  
273      bytestream2_init_writer(&pb, avpkt->data + 4, avpkt->size - 4);
274  
275 -    int num_source_channels = FFALIGN(avctx->channels, 2);
276 -    // int num_source_channels = avctx->channels;
277 -    // int sample_size = (num_source_channels *
278 -    //               (avctx->sample_fmt == AV_SAMPLE_FMT_S16 ? 16 : 24)) >> 3;
279 -    samples = frame->nb_samples * num_source_channels;
280 -
281 -    switch (avctx->sample_fmt) {
282 -    case AV_SAMPLE_FMT_S16:
283 -    switch (avctx->channels) {
284 -       case 1:
285 -           do {
286 -                   do {
287 -                       channels = avctx->channels;
288 -                           bytestream2_put_be16(&pb, *src16++);
289 -               } while (--channels);
290 -               bytestream2_put_be16(&pb, 0);
291 -               } while (--samples);
292 -        break;
293 -       case 2:
294 -       do {
295 -            bytestream2_put_be16(&pb, *src16++);
296 -        } while (--samples);
297 -        break;
298 -       case 6:
299 -       do {
300 -           bytestream2_put_be16(&pb, src16[0]);
301 -           bytestream2_put_be16(&pb, src16[1]);
302 -           bytestream2_put_be16(&pb, src16[2]);
303 -           bytestream2_put_be16(&pb, src16[4]);
304 -           bytestream2_put_be16(&pb, src16[5]);
305 -           bytestream2_put_be16(&pb, src16[3]);
306 -           src16+=6;
307 -        } while (--samples);
308 -       break;
309 -       case 8:
310 -       do {
311 -           bytestream2_put_be16(&pb, src16[0]);
312 -           bytestream2_put_be16(&pb, src16[1]);
313 -           bytestream2_put_be16(&pb, src16[2]);
314 -           bytestream2_put_be16(&pb, src16[6]);
315 -           bytestream2_put_be16(&pb, src16[4]);
316 -           bytestream2_put_be16(&pb, src16[5]);
317 -           bytestream2_put_be16(&pb, src16[7]);
318 -           bytestream2_put_be16(&pb, src16[3]);
319 -           src16+=8;
320 -        } while (--samples);
321 -       break;
322 -
323 -       default:
324 -       av_log(avctx, AV_LOG_ERROR, "this ch config not implemented for s16!\n");
325 +    switch (avctx->channel_layout) {
326 +    /* cases with same number of source and coded channels */
327 +    case AV_CH_LAYOUT_STEREO:
328 +    case AV_CH_LAYOUT_4POINT0:
329 +    case AV_CH_LAYOUT_2_2:
330 +        samples *= num_dest_channels;
331 +        if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
332 +#if HAVE_BIGENDIAN
333 +            bytestream2_put_bufferu(&pb, frame->data[0], samples * 2);
334 +#else
335 +            do {
336 +                bytestream2_put_be16u(&pb, *src16++);
337 +            } while (--samples);
338 +#endif
339 +        } else {
340 +            do {
341 +                bytestream2_put_be24u(&pb, (*src32++) >> 8);
342 +            } while (--samples);
343 +        }
344          break;
345 +    /* cases where number of source channels = coded channels + 1 */
346 +    case AV_CH_LAYOUT_MONO:
347 +    case AV_CH_LAYOUT_SURROUND:
348 +    case AV_CH_LAYOUT_2_1:
349 +    case AV_CH_LAYOUT_5POINT0:
350 +        if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
351 +            do {
352 +#if HAVE_BIGENDIAN
353 +                bytestream2_put_bufferu(&pb, (const uint8_t *)src16, avctx->ch_layout.nb_channels * 2);
354 +                src16 += avctx->channels;
355 +#else
356 +                channel = avctx->channels;
357 +                do {
358 +                    bytestream2_put_be16u(&pb, *src16++);
359 +                } while (--channel);
360 +#endif
361 +                bytestream2_put_ne16(&pb, 0);
362 +            } while (--samples);
363 +        } else {
364 +            do {
365 +                channel = avctx->channels;
366 +                do {
367 +                    bytestream2_put_be24u(&pb, (*src32++) >> 8);
368 +                } while (--channel);
369 +                bytestream2_put_ne24(&pb, 0);
370 +            } while (--samples);
371          }
372          break;
373 -    case AV_SAMPLE_FMT_S32:
374 -               switch (avctx->channels) {
375 -                       case 2:
376 -                       case 4:
377 -                           do {
378 -                               bytestream2_put_be24(&pb, (*src32++) >> 8);
379 -                           } while (--samples);
380 -                    break;
381 -                        case 8:
382 -                            do {
383 -                           bytestream2_put_be24(&pb, src32[0] >> 8);
384 -                           bytestream2_put_be24(&pb, src32[1] >> 8);
385 -                           bytestream2_put_be24(&pb, src32[2] >> 8);
386 -                           bytestream2_put_be24(&pb, src32[6] >> 8);
387 -                           bytestream2_put_be24(&pb, src32[4] >> 8);
388 -                           bytestream2_put_be24(&pb, src32[5] >> 8);
389 -                           bytestream2_put_be24(&pb, src32[7] >> 8);
390 -                           bytestream2_put_be24(&pb, src32[3] >> 8);
391 -                           src32+=8;
392 -                           } while (--samples);
393 -                   break;
394 -                       case 6:
395 -                       do {
396 -                           bytestream2_put_be24(&pb, src32[0] >> 8);
397 -                           bytestream2_put_be24(&pb, src32[1] >> 8);
398 -                           bytestream2_put_be24(&pb, src32[2] >> 8);
399 -                           bytestream2_put_be24(&pb, src32[4] >> 8);
400 -                           bytestream2_put_be24(&pb, src32[5] >> 8);
401 -                           bytestream2_put_be24(&pb, src32[3] >> 8);
402 -                           src32+=6;
403 -                           } while (--samples);
404 -                   break;
405 -                       case 1:
406 -                           do {
407 -                              do {
408 -                                   channels = avctx->channels;
409 -                               bytestream2_put_be24(&pb, (*src32++) >> 8);
410 -                               } while (--channels);
411 -                           bytestream2_put_be24(&pb, 0);
412 -                           } while (--samples);
413 -                    break;
414 -                       default:
415 -                       av_log(avctx, AV_LOG_ERROR, "this bitdepth not implemented!\n");
416 -                    break;
417 -                }
418 -    break;
419 +        /* remapping: L, R, C, LBack, RBack, LF */
420 +    case AV_CH_LAYOUT_5POINT1_BACK:
421 +        if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
422 +            do {
423 +                bytestream2_put_be16u(&pb, src16[0]);
424 +                bytestream2_put_be16u(&pb, src16[1]);
425 +                bytestream2_put_be16u(&pb, src16[2]);
426 +                bytestream2_put_be16u(&pb, src16[4]);
427 +                bytestream2_put_be16u(&pb, src16[5]);
428 +                bytestream2_put_be16u(&pb, src16[3]);
429 +                src16 += 6;
430 +            } while (--samples);
431 +        } else {
432 +            do {
433 +                bytestream2_put_be24u(&pb, src32[0] >> 8);
434 +                bytestream2_put_be24u(&pb, src32[1] >> 8);
435 +                bytestream2_put_be24u(&pb, src32[2] >> 8);
436 +                bytestream2_put_be24u(&pb, src32[4] >> 8);
437 +                bytestream2_put_be24u(&pb, src32[5] >> 8);
438 +                bytestream2_put_be24u(&pb, src32[3] >> 8);
439 +                src32 += 6;
440 +            } while (--samples);
441 +        }
442 +        break;
443 +        /* remapping: L, R, C, LSide, LBack, RBack, RSide, <unused> */
444 +    case AV_CH_LAYOUT_7POINT0:
445 +        if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
446 +            do {
447 +                bytestream2_put_be16u(&pb, src16[0]);
448 +                bytestream2_put_be16u(&pb, src16[1]);
449 +                bytestream2_put_be16u(&pb, src16[2]);
450 +                bytestream2_put_be16u(&pb, src16[5]);
451 +                bytestream2_put_be16u(&pb, src16[3]);
452 +                bytestream2_put_be16u(&pb, src16[4]);
453 +                bytestream2_put_be16u(&pb, src16[6]);
454 +                src16 += 7;
455 +                bytestream2_put_ne16(&pb, 0);
456 +            } while (--samples);
457 +        } else {
458 +            do {
459 +                bytestream2_put_be24u(&pb, src32[0] >> 8);
460 +                bytestream2_put_be24u(&pb, src32[1] >> 8);
461 +                bytestream2_put_be24u(&pb, src32[2] >> 8);
462 +                bytestream2_put_be24u(&pb, src32[5] >> 8);
463 +                bytestream2_put_be24u(&pb, src32[3] >> 8);
464 +                bytestream2_put_be24u(&pb, src32[4] >> 8);
465 +                bytestream2_put_be24u(&pb, src32[6] >> 8);
466 +                src32 += 7;
467 +                bytestream2_put_ne24(&pb, 0);
468 +            } while (--samples);
469 +        }
470 +        break;
471 +        /* remapping: L, R, C, LSide, LBack, RBack, RSide, LF */
472 +    case AV_CH_LAYOUT_7POINT1:
473 +        if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) {
474 +            do {
475 +                bytestream2_put_be16u(&pb, src16[0]);
476 +                bytestream2_put_be16u(&pb, src16[1]);
477 +                bytestream2_put_be16u(&pb, src16[2]);
478 +                bytestream2_put_be16u(&pb, src16[6]);
479 +                bytestream2_put_be16u(&pb, src16[4]);
480 +                bytestream2_put_be16u(&pb, src16[5]);
481 +                bytestream2_put_be16u(&pb, src16[7]);
482 +                bytestream2_put_be16u(&pb, src16[3]);
483 +                src16 += 8;
484 +            } while (--samples);
485 +        } else {
486 +            do {
487 +                bytestream2_put_be24u(&pb, src32[0]);
488 +                bytestream2_put_be24u(&pb, src32[1]);
489 +                bytestream2_put_be24u(&pb, src32[2]);
490 +                bytestream2_put_be24u(&pb, src32[6]);
491 +                bytestream2_put_be24u(&pb, src32[4]);
492 +                bytestream2_put_be24u(&pb, src32[5]);
493 +                bytestream2_put_be24u(&pb, src32[7]);
494 +                bytestream2_put_be24u(&pb, src32[3]);
495 +                src32 += 8;
496 +            } while (--samples);
497 +        }
498 +        break;
499 +    default:
500 +        return AVERROR_BUG;
501      }
502  
503 -    avpkt->pts      = frame->pts;
504 -    avpkt->size     = pkt_size;
505 +    avpkt->pts = frame->pts;
506      avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples);
507      *got_packet_ptr = 1;
508  
509      return 0;
510  }
511  
512 -AVCodec ff_pcm_bluray_encoder = {
513 -    .name           = "pcm_bluray",
514 -    .long_name      = NULL_IF_CONFIG_SMALL("PCM signed 16|24-bit big-endian for bluray media"),
515 -    .type           = AVMEDIA_TYPE_AUDIO,
516 -    .id             = AV_CODEC_ID_PCM_BLURAY,
517 -    .priv_data_size = sizeof(PCMBDContext),
518 -    .init           = pcm_bd_encode_init,
519 -    .encode2        = pcm_bd_encode_frame,
520 -    .capabilities   = AV_CODEC_CAP_SMALL_LAST_FRAME,
521 -    .supported_samplerates = (const int[]) { 48000, 96000, 192000, 0},
522 -    .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO,
523 -                                            AV_CH_LAYOUT_STEREO,
524 -                                            AV_CH_LAYOUT_5POINT1,
525 -                                            AV_CH_LAYOUT_5POINT1_BACK,
526 -                                            AV_CH_LAYOUT_7POINT1,
527 -                                            0 },
528 -    .sample_fmts    = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
529 -                                                     AV_SAMPLE_FMT_S32,
530 -                                                     AV_SAMPLE_FMT_NONE },
531 -    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
532 +const AVCodec ff_pcm_bluray_encoder = {
533 +    .name               = "pcm_bluray",
534 +    .long_name          = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for Blu-ray media"),
535 +    .type               = AVMEDIA_TYPE_AUDIO,
536 +    .id                 = AV_CODEC_ID_PCM_BLURAY,
537 +    .priv_data_size     = sizeof(BlurayPCMEncContext),
538 +    .init               = pcm_bluray_encode_init,
539 +    .encode2           = pcm_bluray_encode_frame,
540 +    .supported_samplerates = (const int[]) { 48000, 96000, 192000, 0 },
541 +//#define FF_API_OLD_CHANNEL_LAYOUT 1
542 +#if 1
543 +    .channel_layouts = (const uint64_t[]) {
544 +        AV_CH_LAYOUT_MONO,
545 +        AV_CH_LAYOUT_STEREO,
546 +        AV_CH_LAYOUT_SURROUND,
547 +        AV_CH_LAYOUT_2_1,
548 +        AV_CH_LAYOUT_4POINT0,
549 +        AV_CH_LAYOUT_2_2,
550 +        AV_CH_LAYOUT_5POINT0,
551 +        AV_CH_LAYOUT_5POINT1_BACK,
552 +        AV_CH_LAYOUT_7POINT0,
553 +        AV_CH_LAYOUT_7POINT1,
554 +        0 },
555 +#endif
556 +#if 0
557 +    .p.ch_layouts   = (const AVChannelLayout[]) {
558 +        AV_CHANNEL_LAYOUT_MONO,
559 +        AV_CHANNEL_LAYOUT_STEREO,
560 +        AV_CHANNEL_LAYOUT_SURROUND,
561 +        AV_CHANNEL_LAYOUT_2_1,
562 +        AV_CHANNEL_LAYOUT_4POINT0,
563 +        AV_CHANNEL_LAYOUT_2_2,
564 +        AV_CHANNEL_LAYOUT_5POINT0,
565 +        AV_CHANNEL_LAYOUT_5POINT1,
566 +        AV_CHANNEL_LAYOUT_7POINT0,
567 +        AV_CHANNEL_LAYOUT_7POINT1,
568 +        { 0 } },
569 +#endif
570 +    .sample_fmts         = (const enum AVSampleFormat[]) {
571 +        AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE },
572 +    .caps_internal         = FF_CODEC_CAP_INIT_THREADSAFE,
573 +    .capabilities        = AV_CODEC_CAP_DR1,
574  };