3 * Copyright (c) 2012 Andrew D'Addesio
4 * Copyright (c) 2013-2014 Mozilla Corporation
6 * This file is part of Libav.
8 * Libav is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * Libav is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Libav; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 * @author Andrew D'Addesio, Anton Khirnov
28 * Codec homepage: http://opus-codec.org/
29 * Specification: http://tools.ietf.org/html/rfc6716
30 * Ogg Opus specification: https://tools.ietf.org/html/draft-ietf-codec-oggopus-03
32 * Ogg-contained .opus files can be produced with opus-tools:
33 * http://git.xiph.org/?p=opus-tools.git
38 #include "libavutil/attributes.h"
39 #include "libavutil/audio_fifo.h"
40 #include "libavutil/channel_layout.h"
41 #include "libavutil/opt.h"
43 #include "libavresample/avresample.h"
46 #include "bitstream.h"
47 #include "celp_filters.h"
53 static const uint16_t silk_frame_duration_ms
[16] = {
61 /* number of samples of silence to feed to the resampler
63 static const int silk_resample_delay
[] = {
67 static const uint8_t celt_band_end
[] = { 13, 17, 17, 19, 21 };
69 static int get_silk_samplerate(int config
)
81 static int opus_rc_init(OpusRangeCoder
*rc
, const uint8_t *data
, int size
)
83 int ret
= bitstream_init8(&rc
->bc
, data
, size
);
88 rc
->value
= 127 - bitstream_read(&rc
->bc
, 7);
89 rc
->total_read_bits
= 9;
90 opus_rc_normalize(rc
);
95 static void opus_raw_init(OpusRangeCoder
*rc
, const uint8_t *rightend
,
98 rc
->rb
.position
= rightend
;
104 static void opus_fade(float *out
,
105 const float *in1
, const float *in2
,
106 const float *window
, int len
)
109 for (i
= 0; i
< len
; i
++)
110 out
[i
] = in2
[i
] * window
[i
] + in1
[i
] * (1.0 - window
[i
]);
113 static int opus_flush_resample(OpusStreamContext
*s
, int nb_samples
)
115 int celt_size
= av_audio_fifo_size(s
->celt_delay
);
118 ret
= avresample_convert(s
->avr
, (uint8_t**)s
->out
, s
->out_size
, nb_samples
,
122 else if (ret
!= nb_samples
) {
123 av_log(s
->avctx
, AV_LOG_ERROR
, "Wrong number of flushed samples: %d\n",
129 if (celt_size
!= nb_samples
) {
130 av_log(s
->avctx
, AV_LOG_ERROR
, "Wrong number of CELT delay samples.\n");
133 av_audio_fifo_read(s
->celt_delay
, (void**)s
->celt_output
, nb_samples
);
134 for (i
= 0; i
< s
->output_channels
; i
++) {
135 s
->fdsp
->vector_fmac_scalar(s
->out
[i
],
136 s
->celt_output
[i
], 1.0,
141 if (s
->redundancy_idx
) {
142 for (i
= 0; i
< s
->output_channels
; i
++)
143 opus_fade(s
->out
[i
], s
->out
[i
],
144 s
->redundancy_output
[i
] + 120 + s
->redundancy_idx
,
145 ff_celt_window2
+ s
->redundancy_idx
, 120 - s
->redundancy_idx
);
146 s
->redundancy_idx
= 0;
149 s
->out
[0] += nb_samples
;
150 s
->out
[1] += nb_samples
;
151 s
->out_size
-= nb_samples
* sizeof(float);
156 static int opus_init_resample(OpusStreamContext
*s
)
158 float delay
[16] = { 0.0 };
159 uint8_t *delayptr
[2] = { (uint8_t*)delay
, (uint8_t*)delay
};
162 av_opt_set_int(s
->avr
, "in_sample_rate", s
->silk_samplerate
, 0);
163 ret
= avresample_open(s
->avr
);
165 av_log(s
->avctx
, AV_LOG_ERROR
, "Error opening the resampler.\n");
169 ret
= avresample_convert(s
->avr
, NULL
, 0, 0, delayptr
, sizeof(delay
),
170 silk_resample_delay
[s
->packet
.bandwidth
]);
172 av_log(s
->avctx
, AV_LOG_ERROR
,
173 "Error feeding initial silence to the resampler.\n");
180 static int opus_decode_redundancy(OpusStreamContext
*s
, const uint8_t *data
, int size
)
183 enum OpusBandwidth bw
= s
->packet
.bandwidth
;
185 if (s
->packet
.mode
== OPUS_MODE_SILK
&&
186 bw
== OPUS_BANDWIDTH_MEDIUMBAND
)
187 bw
= OPUS_BANDWIDTH_WIDEBAND
;
189 ret
= opus_rc_init(&s
->redundancy_rc
, data
, size
);
192 opus_raw_init(&s
->redundancy_rc
, data
+ size
, size
);
194 ret
= ff_celt_decode_frame(s
->celt
, &s
->redundancy_rc
,
195 s
->redundancy_output
,
196 s
->packet
.stereo
+ 1, 240,
197 0, celt_band_end
[s
->packet
.bandwidth
]);
203 av_log(s
->avctx
, AV_LOG_ERROR
, "Error decoding the redundancy frame.\n");
207 static int opus_decode_frame(OpusStreamContext
*s
, const uint8_t *data
, int size
)
209 int samples
= s
->packet
.frame_duration
;
211 int redundancy_size
, redundancy_pos
;
212 int ret
, i
, consumed
;
213 int delayed_samples
= s
->delayed_samples
;
215 ret
= opus_rc_init(&s
->rc
, data
, size
);
219 /* decode the silk frame */
220 if (s
->packet
.mode
== OPUS_MODE_SILK
|| s
->packet
.mode
== OPUS_MODE_HYBRID
) {
221 if (!avresample_is_open(s
->avr
)) {
222 ret
= opus_init_resample(s
);
227 samples
= ff_silk_decode_superframe(s
->silk
, &s
->rc
, s
->silk_output
,
228 FFMIN(s
->packet
.bandwidth
, OPUS_BANDWIDTH_WIDEBAND
),
229 s
->packet
.stereo
+ 1,
230 silk_frame_duration_ms
[s
->packet
.config
]);
232 av_log(s
->avctx
, AV_LOG_ERROR
, "Error decoding a SILK frame.\n");
236 samples
= avresample_convert(s
->avr
, (uint8_t**)s
->out
, s
->out_size
,
237 s
->packet
.frame_duration
,
238 (uint8_t**)s
->silk_output
,
239 sizeof(s
->silk_buf
[0]),
242 av_log(s
->avctx
, AV_LOG_ERROR
, "Error resampling SILK data.\n");
245 s
->delayed_samples
+= s
->packet
.frame_duration
- samples
;
247 ff_silk_flush(s
->silk
);
249 // decode redundancy information
250 consumed
= opus_rc_tell(&s
->rc
);
251 if (s
->packet
.mode
== OPUS_MODE_HYBRID
&& consumed
+ 37 <= size
* 8)
252 redundancy
= opus_rc_p2model(&s
->rc
, 12);
253 else if (s
->packet
.mode
== OPUS_MODE_SILK
&& consumed
+ 17 <= size
* 8)
257 redundancy_pos
= opus_rc_p2model(&s
->rc
, 1);
259 if (s
->packet
.mode
== OPUS_MODE_HYBRID
)
260 redundancy_size
= opus_rc_unimodel(&s
->rc
, 256) + 2;
262 redundancy_size
= size
- (consumed
+ 7) / 8;
263 size
-= redundancy_size
;
265 av_log(s
->avctx
, AV_LOG_ERROR
, "Invalid redundancy frame size.\n");
266 return AVERROR_INVALIDDATA
;
269 if (redundancy_pos
) {
270 ret
= opus_decode_redundancy(s
, data
+ size
, redundancy_size
);
273 ff_celt_flush(s
->celt
);
277 /* decode the CELT frame */
278 if (s
->packet
.mode
== OPUS_MODE_CELT
|| s
->packet
.mode
== OPUS_MODE_HYBRID
) {
279 float *out_tmp
[2] = { s
->out
[0], s
->out
[1] };
280 float **dst
= (s
->packet
.mode
== OPUS_MODE_CELT
) ?
281 out_tmp
: s
->celt_output
;
282 int celt_output_samples
= samples
;
283 int delay_samples
= av_audio_fifo_size(s
->celt_delay
);
286 if (s
->packet
.mode
== OPUS_MODE_HYBRID
) {
287 av_audio_fifo_read(s
->celt_delay
, (void**)s
->celt_output
, delay_samples
);
289 for (i
= 0; i
< s
->output_channels
; i
++) {
290 s
->fdsp
->vector_fmac_scalar(out_tmp
[i
], s
->celt_output
[i
], 1.0,
292 out_tmp
[i
] += delay_samples
;
294 celt_output_samples
-= delay_samples
;
296 av_log(s
->avctx
, AV_LOG_WARNING
,
297 "Spurious CELT delay samples present.\n");
298 av_audio_fifo_drain(s
->celt_delay
, delay_samples
);
299 if (s
->avctx
->err_recognition
& AV_EF_EXPLODE
)
304 opus_raw_init(&s
->rc
, data
+ size
, size
);
306 ret
= ff_celt_decode_frame(s
->celt
, &s
->rc
, dst
,
307 s
->packet
.stereo
+ 1,
308 s
->packet
.frame_duration
,
309 (s
->packet
.mode
== OPUS_MODE_HYBRID
) ? 17 : 0,
310 celt_band_end
[s
->packet
.bandwidth
]);
314 if (s
->packet
.mode
== OPUS_MODE_HYBRID
) {
315 int celt_delay
= s
->packet
.frame_duration
- celt_output_samples
;
316 void *delaybuf
[2] = { s
->celt_output
[0] + celt_output_samples
,
317 s
->celt_output
[1] + celt_output_samples
};
319 for (i
= 0; i
< s
->output_channels
; i
++) {
320 s
->fdsp
->vector_fmac_scalar(out_tmp
[i
],
321 s
->celt_output
[i
], 1.0,
322 celt_output_samples
);
325 ret
= av_audio_fifo_write(s
->celt_delay
, delaybuf
, celt_delay
);
330 ff_celt_flush(s
->celt
);
332 if (s
->redundancy_idx
) {
333 for (i
= 0; i
< s
->output_channels
; i
++)
334 opus_fade(s
->out
[i
], s
->out
[i
],
335 s
->redundancy_output
[i
] + 120 + s
->redundancy_idx
,
336 ff_celt_window2
+ s
->redundancy_idx
, 120 - s
->redundancy_idx
);
337 s
->redundancy_idx
= 0;
340 if (!redundancy_pos
) {
341 ff_celt_flush(s
->celt
);
342 ret
= opus_decode_redundancy(s
, data
+ size
, redundancy_size
);
346 for (i
= 0; i
< s
->output_channels
; i
++) {
347 opus_fade(s
->out
[i
] + samples
- 120 + delayed_samples
,
348 s
->out
[i
] + samples
- 120 + delayed_samples
,
349 s
->redundancy_output
[i
] + 120,
350 ff_celt_window2
, 120 - delayed_samples
);
352 s
->redundancy_idx
= 120 - delayed_samples
;
355 for (i
= 0; i
< s
->output_channels
; i
++) {
356 memcpy(s
->out
[i
] + delayed_samples
, s
->redundancy_output
[i
], 120 * sizeof(float));
357 opus_fade(s
->out
[i
] + 120 + delayed_samples
,
358 s
->redundancy_output
[i
] + 120,
359 s
->out
[i
] + 120 + delayed_samples
,
360 ff_celt_window2
, 120);
368 static int opus_decode_subpacket(OpusStreamContext
*s
,
369 const uint8_t *buf
, int buf_size
,
370 float **out
, int out_size
,
373 int output_samples
= 0;
374 int flush_needed
= 0;
379 s
->out_size
= out_size
;
381 /* check if we need to flush the resampler */
382 if (avresample_is_open(s
->avr
)) {
384 int64_t cur_samplerate
;
385 av_opt_get_int(s
->avr
, "in_sample_rate", 0, &cur_samplerate
);
386 flush_needed
= (s
->packet
.mode
== OPUS_MODE_CELT
) || (cur_samplerate
!= s
->silk_samplerate
);
388 flush_needed
= !!s
->delayed_samples
;
392 if (!buf
&& !flush_needed
)
395 /* use dummy output buffers if the channel is not mapped to anything */
397 (s
->output_channels
== 2 && !s
->out
[1])) {
398 av_fast_malloc(&s
->out_dummy
, &s
->out_dummy_allocated_size
, s
->out_size
);
400 return AVERROR(ENOMEM
);
402 s
->out
[0] = s
->out_dummy
;
404 s
->out
[1] = s
->out_dummy
;
407 /* flush the resampler if necessary */
409 ret
= opus_flush_resample(s
, s
->delayed_samples
);
411 av_log(s
->avctx
, AV_LOG_ERROR
, "Error flushing the resampler.\n");
414 avresample_close(s
->avr
);
415 output_samples
+= s
->delayed_samples
;
416 s
->delayed_samples
= 0;
422 /* decode all the frames in the packet */
423 for (i
= 0; i
< s
->packet
.frame_count
; i
++) {
424 int size
= s
->packet
.frame_size
[i
];
425 int samples
= opus_decode_frame(s
, buf
+ s
->packet
.frame_offset
[i
], size
);
428 av_log(s
->avctx
, AV_LOG_ERROR
, "Error decoding an Opus frame.\n");
429 if (s
->avctx
->err_recognition
& AV_EF_EXPLODE
)
432 for (j
= 0; j
< s
->output_channels
; j
++)
433 memset(s
->out
[j
], 0, s
->packet
.frame_duration
* sizeof(float));
434 samples
= s
->packet
.frame_duration
;
436 output_samples
+= samples
;
438 for (j
= 0; j
< s
->output_channels
; j
++)
439 s
->out
[j
] += samples
;
440 s
->out_size
-= samples
* sizeof(float);
444 s
->out
[0] = s
->out
[1] = NULL
;
447 return output_samples
;
450 static int opus_decode_packet(AVCodecContext
*avctx
, void *data
,
451 int *got_frame_ptr
, AVPacket
*avpkt
)
453 OpusContext
*c
= avctx
->priv_data
;
454 AVFrame
*frame
= data
;
455 const uint8_t *buf
= avpkt
->data
;
456 int buf_size
= avpkt
->size
;
457 int coded_samples
= 0;
458 int decoded_samples
= INT_MAX
;
459 int delayed_samples
= 0;
462 /* calculate the number of delayed samples */
463 for (i
= 0; i
< c
->nb_streams
; i
++) {
464 delayed_samples
= FFMAX(delayed_samples
,
465 c
->streams
[i
].delayed_samples
+ av_audio_fifo_size(c
->sync_buffers
[i
]));
468 /* decode the header of the first sub-packet to find out the sample count */
470 OpusPacket
*pkt
= &c
->streams
[0].packet
;
471 ret
= ff_opus_parse_packet(pkt
, buf
, buf_size
, c
->nb_streams
> 1);
473 av_log(avctx
, AV_LOG_ERROR
, "Error parsing the packet header.\n");
476 coded_samples
+= pkt
->frame_count
* pkt
->frame_duration
;
477 c
->streams
[0].silk_samplerate
= get_silk_samplerate(pkt
->config
);
480 frame
->nb_samples
= coded_samples
+ delayed_samples
;
482 /* no input or buffered data => nothing to do */
483 if (!frame
->nb_samples
) {
488 /* setup the data buffers */
489 ret
= ff_get_buffer(avctx
, frame
, 0);
491 av_log(avctx
, AV_LOG_ERROR
, "get_buffer() failed\n");
494 frame
->nb_samples
= 0;
496 memset(c
->out
, 0, c
->nb_streams
* 2 * sizeof(*c
->out
));
497 for (i
= 0; i
< avctx
->channels
; i
++) {
498 ChannelMap
*map
= &c
->channel_maps
[i
];
500 c
->out
[2 * map
->stream_idx
+ map
->channel_idx
] = (float*)frame
->extended_data
[i
];
503 /* read the data from the sync buffers */
504 for (i
= 0; i
< c
->nb_streams
; i
++) {
505 float **out
= c
->out
+ 2 * i
;
506 int sync_size
= av_audio_fifo_size(c
->sync_buffers
[i
]);
508 float sync_dummy
[32];
509 int out_dummy
= (!out
[0]) | ((!out
[1]) << 1);
515 if (out_dummy
&& sync_size
> FF_ARRAY_ELEMS(sync_dummy
))
518 ret
= av_audio_fifo_read(c
->sync_buffers
[i
], (void**)out
, sync_size
);
531 c
->out_size
[i
] = frame
->linesize
[0] - ret
* sizeof(float);
534 /* decode each sub-packet */
535 for (i
= 0; i
< c
->nb_streams
; i
++) {
536 OpusStreamContext
*s
= &c
->streams
[i
];
539 ret
= ff_opus_parse_packet(&s
->packet
, buf
, buf_size
, i
!= c
->nb_streams
- 1);
541 av_log(avctx
, AV_LOG_ERROR
, "Error parsing the packet header.\n");
544 if (coded_samples
!= s
->packet
.frame_count
* s
->packet
.frame_duration
) {
545 av_log(avctx
, AV_LOG_ERROR
,
546 "Mismatching coded sample count in substream %d.\n", i
);
547 return AVERROR_INVALIDDATA
;
550 s
->silk_samplerate
= get_silk_samplerate(s
->packet
.config
);
553 ret
= opus_decode_subpacket(&c
->streams
[i
], buf
, s
->packet
.data_size
,
554 c
->out
+ 2 * i
, c
->out_size
[i
], coded_samples
);
557 c
->decoded_samples
[i
] = ret
;
558 decoded_samples
= FFMIN(decoded_samples
, ret
);
560 buf
+= s
->packet
.packet_size
;
561 buf_size
-= s
->packet
.packet_size
;
564 /* buffer the extra samples */
565 for (i
= 0; i
< c
->nb_streams
; i
++) {
566 int buffer_samples
= c
->decoded_samples
[i
] - decoded_samples
;
567 if (buffer_samples
) {
568 float *buf
[2] = { c
->out
[2 * i
+ 0] ? c
->out
[2 * i
+ 0] : (float*)frame
->extended_data
[0],
569 c
->out
[2 * i
+ 1] ? c
->out
[2 * i
+ 1] : (float*)frame
->extended_data
[0] };
570 buf
[0] += decoded_samples
;
571 buf
[1] += decoded_samples
;
572 ret
= av_audio_fifo_write(c
->sync_buffers
[i
], (void**)buf
, buffer_samples
);
578 for (i
= 0; i
< avctx
->channels
; i
++) {
579 ChannelMap
*map
= &c
->channel_maps
[i
];
581 /* handle copied channels */
583 memcpy(frame
->extended_data
[i
],
584 frame
->extended_data
[map
->copy_idx
],
586 } else if (map
->silence
) {
587 memset(frame
->extended_data
[i
], 0, frame
->linesize
[0]);
590 if (c
->gain_i
&& decoded_samples
> 0) {
591 c
->fdsp
.vector_fmul_scalar((float*)frame
->extended_data
[i
],
592 (float*)frame
->extended_data
[i
],
593 c
->gain
, FFALIGN(decoded_samples
, 8));
597 frame
->nb_samples
= decoded_samples
;
598 *got_frame_ptr
= !!decoded_samples
;
603 static av_cold
void opus_decode_flush(AVCodecContext
*ctx
)
605 OpusContext
*c
= ctx
->priv_data
;
608 for (i
= 0; i
< c
->nb_streams
; i
++) {
609 OpusStreamContext
*s
= &c
->streams
[i
];
611 memset(&s
->packet
, 0, sizeof(s
->packet
));
612 s
->delayed_samples
= 0;
615 av_audio_fifo_drain(s
->celt_delay
, av_audio_fifo_size(s
->celt_delay
));
616 avresample_close(s
->avr
);
618 av_audio_fifo_drain(c
->sync_buffers
[i
], av_audio_fifo_size(c
->sync_buffers
[i
]));
620 ff_silk_flush(s
->silk
);
621 ff_celt_flush(s
->celt
);
625 static av_cold
int opus_decode_close(AVCodecContext
*avctx
)
627 OpusContext
*c
= avctx
->priv_data
;
630 for (i
= 0; i
< c
->nb_streams
; i
++) {
631 OpusStreamContext
*s
= &c
->streams
[i
];
633 ff_silk_free(&s
->silk
);
634 ff_celt_free(&s
->celt
);
636 av_freep(&s
->out_dummy
);
637 s
->out_dummy_allocated_size
= 0;
639 av_audio_fifo_free(s
->celt_delay
);
640 avresample_free(&s
->avr
);
643 av_freep(&c
->streams
);
645 if (c
->sync_buffers
) {
646 for (i
= 0; i
< c
->nb_streams
; i
++)
647 av_audio_fifo_free(c
->sync_buffers
[i
]);
649 av_freep(&c
->sync_buffers
);
650 av_freep(&c
->decoded_samples
);
652 av_freep(&c
->out_size
);
656 av_freep(&c
->channel_maps
);
661 static av_cold
int opus_decode_init(AVCodecContext
*avctx
)
663 OpusContext
*c
= avctx
->priv_data
;
666 avctx
->sample_fmt
= AV_SAMPLE_FMT_FLTP
;
667 avctx
->sample_rate
= 48000;
669 avpriv_float_dsp_init(&c
->fdsp
, 0);
671 /* find out the channel configuration */
672 ret
= ff_opus_parse_extradata(avctx
, c
);
676 /* allocate and init each independent decoder */
677 c
->streams
= av_mallocz_array(c
->nb_streams
, sizeof(*c
->streams
));
678 c
->out
= av_mallocz_array(c
->nb_streams
, 2 * sizeof(*c
->out
));
679 c
->out_size
= av_mallocz_array(c
->nb_streams
, sizeof(*c
->out_size
));
680 c
->sync_buffers
= av_mallocz_array(c
->nb_streams
, sizeof(*c
->sync_buffers
));
681 c
->decoded_samples
= av_mallocz_array(c
->nb_streams
, sizeof(*c
->decoded_samples
));
682 if (!c
->streams
|| !c
->sync_buffers
|| !c
->decoded_samples
|| !c
->out
|| !c
->out_size
) {
684 ret
= AVERROR(ENOMEM
);
688 for (i
= 0; i
< c
->nb_streams
; i
++) {
689 OpusStreamContext
*s
= &c
->streams
[i
];
692 s
->output_channels
= (i
< c
->nb_stereo_streams
) ? 2 : 1;
696 for (j
= 0; j
< s
->output_channels
; j
++) {
697 s
->silk_output
[j
] = s
->silk_buf
[j
];
698 s
->celt_output
[j
] = s
->celt_buf
[j
];
699 s
->redundancy_output
[j
] = s
->redundancy_buf
[j
];
704 s
->avr
= avresample_alloc_context();
708 layout
= (s
->output_channels
== 1) ? AV_CH_LAYOUT_MONO
: AV_CH_LAYOUT_STEREO
;
709 av_opt_set_int(s
->avr
, "in_sample_fmt", avctx
->sample_fmt
, 0);
710 av_opt_set_int(s
->avr
, "out_sample_fmt", avctx
->sample_fmt
, 0);
711 av_opt_set_int(s
->avr
, "in_channel_layout", layout
, 0);
712 av_opt_set_int(s
->avr
, "out_channel_layout", layout
, 0);
713 av_opt_set_int(s
->avr
, "out_sample_rate", avctx
->sample_rate
, 0);
715 ret
= ff_silk_init(avctx
, &s
->silk
, s
->output_channels
);
719 ret
= ff_celt_init(avctx
, &s
->celt
, s
->output_channels
);
723 s
->celt_delay
= av_audio_fifo_alloc(avctx
->sample_fmt
,
724 s
->output_channels
, 1024);
725 if (!s
->celt_delay
) {
726 ret
= AVERROR(ENOMEM
);
730 c
->sync_buffers
[i
] = av_audio_fifo_alloc(avctx
->sample_fmt
,
731 s
->output_channels
, 32);
732 if (!c
->sync_buffers
[i
]) {
733 ret
= AVERROR(ENOMEM
);
740 opus_decode_close(avctx
);
744 AVCodec ff_opus_decoder
= {
746 .long_name
= NULL_IF_CONFIG_SMALL("Opus"),
747 .type
= AVMEDIA_TYPE_AUDIO
,
748 .id
= AV_CODEC_ID_OPUS
,
749 .priv_data_size
= sizeof(OpusContext
),
750 .init
= opus_decode_init
,
751 .close
= opus_decode_close
,
752 .decode
= opus_decode_packet
,
753 .flush
= opus_decode_flush
,
754 .capabilities
= AV_CODEC_CAP_DR1
| AV_CODEC_CAP_DELAY
,