libopusenc.c File Reference
#include <opus.h>
#include <opus_multistream.h>
#include "libavutil/opt.h"
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
#include "libopus.h"
#include "vorbis.h"
#include "audio_frame_queue.h"
Include dependency graph for libopusenc.c:

Go to the source code of this file.

Data Structures

struct  LibopusEncOpts
 
struct  LibopusEncContext
 

Macros

#define OFFSET(x)   offsetof(LibopusEncContext, opts.x)
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Typedefs

typedef struct LibopusEncOpts LibopusEncOpts
 
typedef struct LibopusEncContext LibopusEncContext
 

Functions

static void libopus_write_header (AVCodecContext *avctx, int stream_count, int coupled_stream_count, const uint8_t *channel_mapping)
 
static int libopus_configure_encoder (AVCodecContext *avctx, OpusMSEncoder *enc, LibopusEncOpts *opts)
 
static int av_cold libopus_encode_init (AVCodecContext *avctx)
 
static int libopus_encode (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 
static int av_cold libopus_encode_close (AVCodecContext *avctx)
 

Variables

static const uint8_t opus_coupled_streams [8]
 
static const uint8_t opus_vorbis_channel_map [8][8]
 
static const uint8_t libavcodec_libopus_channel_map [8][8]
 
static const AVOption libopus_options []
 
static const AVClass libopus_class
 
static const AVCodecDefault libopus_defaults []
 
static const int libopus_sample_rates []
 
AVCodec ff_libopus_encoder
 

Macro Definition Documentation

Definition at line 377 of file libopusenc.c.

#define OFFSET (   x)    offsetof(LibopusEncContext, opts.x)

Definition at line 376 of file libopusenc.c.

Typedef Documentation

Function Documentation

static int libopus_configure_encoder ( AVCodecContext avctx,
OpusMSEncoder *  enc,
LibopusEncOpts opts 
)
static

Definition at line 105 of file libopusenc.c.

Referenced by libopus_encode_init().

static int libopus_encode ( AVCodecContext avctx,
AVPacket avpkt,
const AVFrame frame,
int *  got_packet_ptr 
)
static

Definition at line 308 of file libopusenc.c.

static int av_cold libopus_encode_close ( AVCodecContext avctx)
static

Definition at line 362 of file libopusenc.c.

static int av_cold libopus_encode_init ( AVCodecContext avctx)
static

Definition at line 159 of file libopusenc.c.

static void libopus_write_header ( AVCodecContext avctx,
int  stream_count,
int  coupled_stream_count,
const uint8_t channel_mapping 
)
static

Definition at line 80 of file libopusenc.c.

Referenced by libopus_encode_init().

Variable Documentation

AVCodec ff_libopus_encoder
Initial value:
= {
.name = "libopus",
.priv_data_size = sizeof(LibopusEncContext),
.encode2 = libopus_encode,
.channel_layouts = ff_vorbis_channel_layouts,
.supported_samplerates = libopus_sample_rates,
.long_name = NULL_IF_CONFIG_SMALL("libopus Opus"),
.priv_class = &libopus_class,
.defaults = libopus_defaults,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static int av_cold libopus_encode_close(AVCodecContext *avctx)
Definition: libopusenc.c:362
signed 16 bits
Definition: samplefmt.h:52
static const AVClass libopus_class
Definition: libopusenc.c:392
static int av_cold libopus_encode_init(AVCodecContext *avctx)
Definition: libopusenc.c:159
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
struct LibopusEncContext LibopusEncContext
static const int libopus_sample_rates[]
Definition: libopusenc.c:405
static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition: libopusenc.c:308
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:375
const uint64_t ff_vorbis_channel_layouts[9]
Definition: vorbis_data.c:47
static const AVCodecDefault libopus_defaults[]
Definition: libopusenc.c:399
AVSampleFormat
Audio Sample Formats.
Definition: samplefmt.h:49
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:700

Definition at line 409 of file libopusenc.c.

const uint8_t libavcodec_libopus_channel_map[8][8]
static
Initial value:
= {
{ 0 },
{ 0, 1 },
{ 0, 1, 2 },
{ 0, 1, 2, 3 },
{ 0, 1, 3, 4, 2 },
{ 0, 1, 4, 5, 2, 3 },
{ 0, 1, 5, 6, 2, 4, 3 },
{ 0, 1, 6, 7, 4, 5, 2, 3 },
}

Definition at line 69 of file libopusenc.c.

Referenced by libopus_encode_init().

const AVClass libopus_class
static
Initial value:
= {
.class_name = "libopus",
.item_name = av_default_item_name,
.option = libopus_options,
}
av_default_item_name
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
static const AVOption libopus_options[]
Definition: libopusenc.c:378

Definition at line 392 of file libopusenc.c.

const AVCodecDefault libopus_defaults[]
static
Initial value:
= {
{ "b", "0" },
{ "compression_level", "10" },
{ NULL },
}
NULL
Definition: eval.c:55

Definition at line 399 of file libopusenc.c.

const AVOption libopus_options[]
static
Initial value:
= {
{ "application", "Intended application type", OFFSET(application), AV_OPT_TYPE_INT, { .i64 = OPUS_APPLICATION_AUDIO }, OPUS_APPLICATION_VOIP, OPUS_APPLICATION_RESTRICTED_LOWDELAY, FLAGS, "application" },
{ "voip", "Favor improved speech intelligibility", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_VOIP }, 0, 0, FLAGS, "application" },
{ "audio", "Favor faithfulness to the input", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_AUDIO }, 0, 0, FLAGS, "application" },
{ "lowdelay", "Restrict to only the lowest delay modes", 0, AV_OPT_TYPE_CONST, { .i64 = OPUS_APPLICATION_RESTRICTED_LOWDELAY }, 0, 0, FLAGS, "application" },
{ "frame_duration", "Duration of a frame in milliseconds", OFFSET(frame_duration), AV_OPT_TYPE_FLOAT, { .dbl = 10.0 }, 2.5, 60.0, FLAGS },
{ "packet_loss", "Expected packet loss percentage", OFFSET(packet_loss), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, FLAGS },
{ "vbr", "Variable bit rate mode", OFFSET(vbr), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 2, FLAGS, "vbr" },
{ "off", "Use constant bit rate", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "vbr" },
{ "on", "Use variable bit rate", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, "vbr" },
{ "constrained", "Use constrained VBR", 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, FLAGS, "vbr" },
{ NULL },
}
#define OFFSET(x)
Definition: libopusenc.c:376
NULL
Definition: eval.c:55
#define FLAGS
Definition: libopusenc.c:377

Definition at line 378 of file libopusenc.c.

const int libopus_sample_rates[]
static
Initial value:
= {
48000, 24000, 16000, 12000, 8000, 0,
}

Definition at line 405 of file libopusenc.c.

const uint8_t opus_coupled_streams[8]
static
Initial value:
= {
0, 1, 1, 2, 2, 2, 2, 3
}

Definition at line 52 of file libopusenc.c.

Referenced by libopus_encode_init().

const uint8_t opus_vorbis_channel_map[8][8]
static
Initial value:
= {
{ 0 },
{ 0, 1 },
{ 0, 2, 1 },
{ 0, 1, 2, 3 },
{ 0, 4, 1, 2, 3 },
{ 0, 4, 1, 2, 3, 5 },
{ 0, 4, 1, 2, 3, 5, 6 },
{ 0, 6, 1, 2, 3, 4, 5, 7 },
}

Definition at line 57 of file libopusenc.c.

Referenced by libopus_encode_init().