FFmpeg
Macros | Functions | Variables
opusdec.c File Reference
#include <stdint.h>
#include "libavutil/attributes.h"
#include "libavutil/audio_fifo.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "libswresample/swresample.h"
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
#include "mathops.h"
#include "opus.h"
#include "opustab.h"
#include "opus_celt.h"

Go to the source code of this file.

Macros

#define OFFSET(x)   offsetof(OpusContext, x)
 
#define AD   AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 

Functions

static int get_silk_samplerate (int config)
 
static void opus_fade (float *out, const float *in1, const float *in2, const float *window, int len)
 
static int opus_flush_resample (OpusStreamContext *s, int nb_samples)
 
static int opus_init_resample (OpusStreamContext *s)
 
static int opus_decode_redundancy (OpusStreamContext *s, const uint8_t *data, int size)
 
static int opus_decode_frame (OpusStreamContext *s, const uint8_t *data, int size)
 
static int opus_decode_subpacket (OpusStreamContext *s, const uint8_t *buf, int buf_size, int nb_samples)
 
static int opus_decode_packet (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
 
static av_cold void opus_decode_flush (AVCodecContext *ctx)
 
static av_cold int opus_decode_close (AVCodecContext *avctx)
 
static av_cold int opus_decode_init (AVCodecContext *avctx)
 

Variables

static const uint16_t silk_frame_duration_ms [16]
 
static const int silk_resample_delay []
 
static const AVOption opus_options []
 
static const AVClass opus_class
 
const AVCodec ff_opus_decoder
 

Detailed Description

Opus decoder

Author
Andrew D'Addesio, Anton Khirnov

Codec homepage: http://opus-codec.org/ Specification: http://tools.ietf.org/html/rfc6716 Ogg Opus specification: https://tools.ietf.org/html/draft-ietf-codec-oggopus-03

Ogg-contained .opus files can be produced with opus-tools: http://git.xiph.org/?p=opus-tools.git

Definition in file opusdec.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(OpusContext, x)

Definition at line 693 of file opusdec.c.

◆ AD

Definition at line 694 of file opusdec.c.

Function Documentation

◆ get_silk_samplerate()

static int get_silk_samplerate ( int  config)
static

Definition at line 67 of file opusdec.c.

Referenced by opus_decode_packet().

◆ opus_fade()

static void opus_fade ( float *  out,
const float *  in1,
const float *  in2,
const float *  window,
int  len 
)
static

Definition at line 76 of file opusdec.c.

Referenced by opus_decode_frame(), and opus_flush_resample().

◆ opus_flush_resample()

static int opus_flush_resample ( OpusStreamContext s,
int  nb_samples 
)
static

Definition at line 85 of file opusdec.c.

Referenced by opus_decode_subpacket().

◆ opus_init_resample()

static int opus_init_resample ( OpusStreamContext s)
static

Definition at line 128 of file opusdec.c.

Referenced by opus_decode_frame().

◆ opus_decode_redundancy()

static int opus_decode_redundancy ( OpusStreamContext s,
const uint8_t *  data,
int  size 
)
static

Definition at line 153 of file opusdec.c.

Referenced by opus_decode_frame().

◆ opus_decode_frame()

static int opus_decode_frame ( OpusStreamContext s,
const uint8_t *  data,
int  size 
)
static

Definition at line 173 of file opusdec.c.

Referenced by opus_decode_subpacket().

◆ opus_decode_subpacket()

static int opus_decode_subpacket ( OpusStreamContext s,
const uint8_t *  buf,
int  buf_size,
int  nb_samples 
)
static

Definition at line 332 of file opusdec.c.

Referenced by opus_decode_packet().

◆ opus_decode_packet()

static int opus_decode_packet ( AVCodecContext avctx,
void *  data,
int got_frame_ptr,
AVPacket avpkt 
)
static

Definition at line 414 of file opusdec.c.

◆ opus_decode_flush()

static av_cold void opus_decode_flush ( AVCodecContext ctx)
static

Definition at line 569 of file opusdec.c.

◆ opus_decode_close()

static av_cold int opus_decode_close ( AVCodecContext avctx)
static

Definition at line 590 of file opusdec.c.

◆ opus_decode_init()

static av_cold int opus_decode_init ( AVCodecContext avctx)
static

Definition at line 619 of file opusdec.c.

Variable Documentation

◆ silk_frame_duration_ms

const uint16_t silk_frame_duration_ms[16]
static
Initial value:
= {
10, 20, 40, 60,
10, 20, 40, 60,
10, 20, 40, 60,
10, 20,
10, 20,
}

Definition at line 53 of file opusdec.c.

Referenced by opus_decode_frame().

◆ silk_resample_delay

const int silk_resample_delay[]
static
Initial value:
= {
4, 8, 11, 11, 11
}

Definition at line 63 of file opusdec.c.

Referenced by opus_init_resample().

◆ opus_options

const AVOption opus_options[]
static
Initial value:
= {
{ "apply_phase_inv", "Apply intensity stereo phase inversion", OFFSET(apply_phase_inv), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, AD },
{ NULL },
}

Definition at line 695 of file opusdec.c.

◆ opus_class

const AVClass opus_class
static
Initial value:
= {
.class_name = "Opus Decoder",
.item_name = av_default_item_name,
.option = opus_options,
}

Definition at line 700 of file opusdec.c.

◆ ff_opus_decoder

const AVCodec ff_opus_decoder
Initial value:
= {
.name = "opus",
.long_name = NULL_IF_CONFIG_SMALL("Opus"),
.priv_class = &opus_class,
.priv_data_size = sizeof(OpusContext),
}

Definition at line 707 of file opusdec.c.

FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:42
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
opus_decode_close
static av_cold int opus_decode_close(AVCodecContext *avctx)
Definition: opusdec.c:590
OFFSET
#define OFFSET(x)
Definition: opusdec.c:693
opus_options
static const AVOption opus_options[]
Definition: opusdec.c:695
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
flush
static void flush(AVCodecContext *avctx)
Definition: aacdec_template.c:593
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
opus_class
static const AVClass opus_class
Definition: opusdec.c:700
opus_decode_init
static av_cold int opus_decode_init(AVCodecContext *avctx)
Definition: opusdec.c:619
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:109
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AV_CODEC_ID_OPUS
@ AV_CODEC_ID_OPUS
Definition: codec_id.h:482
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:50
opus_decode_flush
static av_cold void opus_decode_flush(AVCodecContext *ctx)
Definition: opusdec.c:569
AD
#define AD
Definition: opusdec.c:694
opus_decode_packet
static int opus_decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: opusdec.c:414
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:82
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
OpusContext
Definition: opus.h:162