Lines Matching defs:opus
22 #include <opus.h>
260 LibopusEncContext *opus = avctx->priv_data;
269 frame_size = opus->opts.frame_duration * 48000 / 1000;
273 if (opus->opts.application != OPUS_APPLICATION_RESTRICTED_LOWDELAY)
280 opus->opts.application = OPUS_APPLICATION_RESTRICTED_LOWDELAY;
290 opus->opts.packet_size =
301 opus->opts.frame_duration);
309 opus->opts.complexity = 10;
311 opus->opts.complexity = avctx->compression_level;
317 opus->opts.max_bandwidth = OPUS_BANDWIDTH_NARROWBAND;
320 opus->opts.max_bandwidth = OPUS_BANDWIDTH_MEDIUMBAND;
323 opus->opts.max_bandwidth = OPUS_BANDWIDTH_WIDEBAND;
326 opus->opts.max_bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND;
329 opus->opts.max_bandwidth = OPUS_BANDWIDTH_FULLBAND;
340 /* Channels may need to be reordered to match opus mapping. */
341 av_ret = libopus_validate_layout_and_get_channel_map(avctx, opus->opts.mapping_family,
342 &opus->encoder_channel_map);
347 if (opus->opts.mapping_family == -1) {
354 opus->stream_count = channels - coupled_stream_count;
360 avctx->sample_rate, channels, opus->stream_count,
363 opus->opts.application, &ret);
368 mapping_family = opus->opts.mapping_family;
371 &opus->stream_count, &coupled_stream_count, libopus_channel_mapping,
372 opus->opts.application, &ret);
383 avctx->bit_rate = 64000 * opus->stream_count +
397 ret = libopus_configure_encoder(avctx, enc, &opus->opts);
413 opus->samples = av_calloc(frame_size, channels *
415 if (!opus->samples) {
427 libopus_write_header(avctx, opus->stream_count, coupled_stream_count,
430 ff_af_queue_init(avctx, &opus->afq);
432 opus->enc = enc;
458 LibopusEncContext *opus = avctx->priv_data;
467 ret = ff_af_queue_add(&opus->afq, frame);
470 if (opus->encoder_channel_map != NULL) {
471 audio = opus->samples;
473 audio, frame->data[0], opus->encoder_channel_map,
475 } else if (frame->nb_samples < opus->opts.packet_size) {
476 audio = opus->samples;
481 if (!opus->afq.remaining_samples || (!opus->afq.frame_alloc && !opus->afq.frame_count))
483 audio = opus->samples;
484 memset(audio, 0, opus->opts.packet_size * sample_size);
487 /* Maximum packet size taken from opusenc in opus-tools. 120ms packets
490 if ((ret = ff_alloc_packet(avctx, avpkt, (1275 * 6 + 7) * opus->stream_count)) < 0)
494 ret = opus_multistream_encode_float(opus->enc, (float *)audio,
495 opus->opts.packet_size,
498 ret = opus_multistream_encode(opus->enc, (opus_int16 *)audio,
499 opus->opts.packet_size,
510 ff_af_queue_remove(&opus->afq, opus->opts.packet_size,
513 discard_padding = opus->opts.packet_size - avpkt->duration;
515 if ((discard_padding < opus->opts.packet_size) != (avpkt->duration > 0)) {
537 LibopusEncContext *opus = avctx->priv_data;
539 opus_multistream_encoder_destroy(opus->enc);
541 ff_af_queue_close(&opus->afq);
543 av_freep(&opus->samples);