FFmpeg
Loading...
Searching...
No Matches
dec.c File Reference

Opus decoder. More...

#include <stdint.h>
#include "libavutil/attributes.h"
#include "libavutil/audio_fifo.h"
#include "libavutil/channel_layout.h"
#include "libavutil/ffmath.h"
#include "libavutil/float_dsp.h"
#include "libavutil/frame.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "libavutil/opt.h"
#include "libswresample/swresample.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/codec_internal.h"
#include "libavcodec/decode.h"
#include "opus.h"
#include "tab.h"
#include "celt.h"
#include "parse.h"
#include "rc.h"
#include "silk.h"

Go to the source code of this file.

Data Structures

struct  OpusStreamContext
 
struct  OpusContext
 

Macros

#define OFFSET(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)
 
static int opus_decode_packet (AVCodecContext *avctx, AVFrame *frame, 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 FFCodec 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 dec.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 759 of file dec.c.

◆ AD

Definition at line 760 of file dec.c.

Function Documentation

◆ get_silk_samplerate()

static int get_silk_samplerate ( int config)
static

Definition at line 132 of file dec.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 141 of file dec.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 150 of file dec.c.

Referenced by opus_decode_subpacket().

◆ opus_init_resample()

static int opus_init_resample ( OpusStreamContext * s)
static

Definition at line 193 of file dec.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 218 of file dec.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 238 of file dec.c.

Referenced by opus_decode_subpacket().

◆ opus_decode_subpacket()

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

Definition at line 397 of file dec.c.

Referenced by opus_decode_packet().

◆ opus_decode_packet()

static int opus_decode_packet ( AVCodecContext * avctx,
AVFrame * frame,
int * got_frame_ptr,
AVPacket * avpkt )
static

Definition at line 477 of file dec.c.

◆ opus_decode_flush()

static av_cold void opus_decode_flush ( AVCodecContext * ctx)
static

Definition at line 634 of file dec.c.

◆ opus_decode_close()

static av_cold int opus_decode_close ( AVCodecContext * avctx)
static

Definition at line 654 of file dec.c.

◆ opus_decode_init()

static av_cold int opus_decode_init ( AVCodecContext * avctx)
static

Definition at line 682 of file dec.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 61 of file dec.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 71 of file dec.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 },
}
#define NULL
Definition coverity.c:32
#define AD
Definition evrcdec.c:920
#define OFFSET(x)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326

Definition at line 761 of file dec.c.

◆ opus_class

const AVClass opus_class
static
Initial value:
= {
.class_name = "Opus Decoder",
.item_name = av_default_item_name,
.option = opus_options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
static const AVOption opus_options[]
Definition dec.c:761

Definition at line 766 of file dec.c.

◆ ff_opus_decoder

const FFCodec ff_opus_decoder
Initial value:
= {
.p.name = "opus",
CODEC_LONG_NAME("Opus"),
.p.priv_class = &opus_class,
.p.type = AVMEDIA_TYPE_AUDIO,
.priv_data_size = sizeof(OpusContext),
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#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:79
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition codec.h:94
@ AV_CODEC_ID_OPUS
Definition codec_id.h:513
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
static const AVClass opus_class
Definition dec.c:766
static av_cold int opus_decode_init(AVCodecContext *avctx)
Definition dec.c:682
static av_cold void opus_decode_flush(AVCodecContext *ctx)
Definition dec.c:634
static int opus_decode_packet(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition dec.c:477
static av_cold int opus_decode_close(AVCodecContext *avctx)
Definition dec.c:654

Definition at line 773 of file dec.c.