FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
opus.h File Reference
#include <stdint.h>
#include "libavutil/audio_fifo.h"
#include "libavutil/float_dsp.h"
#include "libavutil/frame.h"
#include "libswresample/swresample.h"
#include "avcodec.h"
#include "get_bits.h"

Go to the source code of this file.

Data Structures

struct  RawBitsContext
 
struct  OpusRangeCoder
 
struct  OpusPacket
 
struct  OpusStreamContext
 
struct  ChannelMap
 
struct  OpusContext
 

Macros

#define MAX_FRAME_SIZE   1275
 
#define MAX_FRAMES   48
 
#define MAX_PACKET_DUR   5760
 
#define CELT_SHORT_BLOCKSIZE   120
 
#define CELT_OVERLAP   CELT_SHORT_BLOCKSIZE
 
#define CELT_MAX_LOG_BLOCKS   3
 
#define CELT_MAX_FRAME_SIZE   (CELT_SHORT_BLOCKSIZE * (1 << CELT_MAX_LOG_BLOCKS))
 
#define CELT_MAX_BANDS   21
 
#define CELT_VECTORS   11
 
#define CELT_ALLOC_STEPS   6
 
#define CELT_FINE_OFFSET   21
 
#define CELT_MAX_FINE_BITS   8
 
#define CELT_NORM_SCALE   16384
 
#define CELT_QTHETA_OFFSET   4
 
#define CELT_QTHETA_OFFSET_TWOPHASE   16
 
#define CELT_DEEMPH_COEFF   0.85000610f
 
#define CELT_POSTFILTER_MINPERIOD   15
 
#define CELT_ENERGY_SILENCE   (-28.0f)
 
#define SILK_HISTORY   322
 
#define SILK_MAX_LPC   16
 
#define ROUND_MULL(a, b, s)   (((MUL64(a, b) >> ((s) - 1)) + 1) >> 1)
 
#define ROUND_MUL16(a, b)   ((MUL16(a, b) + 16384) >> 15)
 
#define opus_ilog(i)   (av_log2(i) + !!(i))
 
#define OPUS_TS_HEADER   0x7FE0
 
#define OPUS_TS_MASK   0xFFE0
 

Enumerations

enum  OpusMode { OPUS_MODE_SILK, OPUS_MODE_HYBRID, OPUS_MODE_CELT }
 
enum  OpusBandwidth {
  OPUS_BANDWIDTH_NARROWBAND, OPUS_BANDWIDTH_MEDIUMBAND, OPUS_BANDWIDTH_WIDEBAND, OPUS_BANDWIDTH_SUPERWIDEBAND,
  OPUS_BANDWIDTH_FULLBAND
}
 

Functions

static av_always_inline void opus_rc_normalize (OpusRangeCoder *rc)
 
static av_always_inline void opus_rc_update (OpusRangeCoder *rc, unsigned int scale, unsigned int low, unsigned int high, unsigned int total)
 
static av_always_inline
unsigned int 
opus_rc_getsymbol (OpusRangeCoder *rc, const uint16_t *cdf)
 
static av_always_inline
unsigned int 
opus_rc_p2model (OpusRangeCoder *rc, unsigned int bits)
 
static av_always_inline
unsigned int 
opus_rc_tell (const OpusRangeCoder *rc)
 CELT: estimate bits of entropy that have thus far been consumed for the current CELT frame, to integer and fractional (1/8th bit) precision.
 
static av_always_inline
unsigned int 
opus_rc_tell_frac (const OpusRangeCoder *rc)
 
static av_always_inline
unsigned int 
opus_getrawbits (OpusRangeCoder *rc, unsigned int count)
 CELT: read 1-25 raw bits at the end of the frame, backwards byte-wise.
 
static av_always_inline
unsigned int 
opus_rc_unimodel (OpusRangeCoder *rc, unsigned int size)
 CELT: read a uniform distribution.
 
static av_always_inline int opus_rc_laplace (OpusRangeCoder *rc, unsigned int symbol, int decay)
 
static av_always_inline
unsigned int 
opus_rc_stepmodel (OpusRangeCoder *rc, int k0)
 
static av_always_inline
unsigned int 
opus_rc_trimodel (OpusRangeCoder *rc, int qn)
 
int ff_opus_parse_packet (OpusPacket *pkt, const uint8_t *buf, int buf_size, int self_delimited)
 Parse Opus packet info from raw packet data.
 
int ff_opus_parse_extradata (AVCodecContext *avctx, OpusContext *s)
 
int ff_silk_init (AVCodecContext *avctx, SilkContext **ps, int output_channels)
 
void ff_silk_free (SilkContext **ps)
 
void ff_silk_flush (SilkContext *s)
 
int ff_silk_decode_superframe (SilkContext *s, OpusRangeCoder *rc, float *output[2], enum OpusBandwidth bandwidth, int coded_channels, int duration_ms)
 Decode the LP layer of one Opus frame (which may correspond to several SILK frames).
 
int ff_celt_init (AVCodecContext *avctx, CeltContext **s, int output_channels)
 
void ff_celt_free (CeltContext **s)
 
void ff_celt_flush (CeltContext *s)
 
int ff_celt_decode_frame (CeltContext *s, OpusRangeCoder *rc, float **output, int coded_channels, int frame_size, int startband, int endband)
 

Variables

static const uint8_t opus_default_extradata [30]
 
const float ff_celt_window2 [120]
 

Macro Definition Documentation

#define MAX_FRAME_SIZE   1275

Definition at line 37 of file opus.h.

#define MAX_FRAMES   48

Definition at line 38 of file opus.h.

#define MAX_PACKET_DUR   5760

Definition at line 39 of file opus.h.

Referenced by ff_opus_parse_packet().

#define CELT_SHORT_BLOCKSIZE   120

Definition at line 41 of file opus.h.

Referenced by ff_celt_decode_frame().

#define CELT_OVERLAP   CELT_SHORT_BLOCKSIZE

Definition at line 42 of file opus.h.

Referenced by celt_postfilter(), celt_postfilter_apply_transition(), and ff_celt_decode_frame().

#define CELT_MAX_LOG_BLOCKS   3

Definition at line 43 of file opus.h.

Referenced by ff_celt_decode_frame().

#define CELT_MAX_FRAME_SIZE   (CELT_SHORT_BLOCKSIZE * (1 << CELT_MAX_LOG_BLOCKS))

Definition at line 44 of file opus.h.

Referenced by ff_imdct15_init().

#define CELT_MAX_BANDS   21
#define CELT_VECTORS   11

Definition at line 46 of file opus.h.

Referenced by celt_decode_allocation().

#define CELT_ALLOC_STEPS   6

Definition at line 47 of file opus.h.

Referenced by celt_decode_allocation().

#define CELT_FINE_OFFSET   21

Definition at line 48 of file opus.h.

Referenced by celt_decode_allocation().

#define CELT_MAX_FINE_BITS   8

Definition at line 49 of file opus.h.

Referenced by celt_decode_allocation(), and celt_decode_final_energy().

#define CELT_NORM_SCALE   16384

Definition at line 50 of file opus.h.

#define CELT_QTHETA_OFFSET   4

Definition at line 51 of file opus.h.

Referenced by celt_decode_band().

#define CELT_QTHETA_OFFSET_TWOPHASE   16

Definition at line 52 of file opus.h.

Referenced by celt_decode_band().

#define CELT_DEEMPH_COEFF   0.85000610f

Definition at line 53 of file opus.h.

Referenced by ff_celt_decode_frame().

#define CELT_POSTFILTER_MINPERIOD   15

Definition at line 54 of file opus.h.

Referenced by parse_postfilter().

#define CELT_ENERGY_SILENCE   (-28.0f)

Definition at line 55 of file opus.h.

Referenced by ff_celt_decode_frame(), and ff_celt_flush().

#define SILK_HISTORY   322

Definition at line 57 of file opus.h.

Referenced by ff_silk_decode_superframe(), silk_decode_frame(), and silk_unmix_ms().

#define SILK_MAX_LPC   16

Definition at line 58 of file opus.h.

#define ROUND_MULL (   a,
  b,
  s 
)    (((MUL64(a, b) >> ((s) - 1)) + 1) >> 1)

Definition at line 60 of file opus.h.

Referenced by silk_is_lpc_stable(), silk_lsf2lpc(), and silk_lsp2poly().

#define ROUND_MUL16 (   a,
  b 
)    ((MUL16(a, b) + 16384) >> 15)

Definition at line 61 of file opus.h.

Referenced by celt_cos(), celt_decode_band(), and celt_log2tan().

#define opus_ilog (   i)    (av_log2(i) + !!(i))

Definition at line 62 of file opus.h.

Referenced by celt_log2tan(), opus_rc_unimodel(), silk_decode_lpc(), and silk_is_lpc_stable().

#define OPUS_TS_HEADER   0x7FE0

Definition at line 64 of file opus.h.

Referenced by opus_find_frame_end().

#define OPUS_TS_MASK   0xFFE0

Definition at line 65 of file opus.h.

Referenced by opus_find_frame_end().

Enumeration Type Documentation

enum OpusMode
Enumerator:
OPUS_MODE_SILK 
OPUS_MODE_HYBRID 
OPUS_MODE_CELT 

Definition at line 73 of file opus.h.

Enumerator:
OPUS_BANDWIDTH_NARROWBAND 
OPUS_BANDWIDTH_MEDIUMBAND 
OPUS_BANDWIDTH_WIDEBAND 
OPUS_BANDWIDTH_SUPERWIDEBAND 
OPUS_BANDWIDTH_FULLBAND 

Definition at line 79 of file opus.h.

Function Documentation

static av_always_inline void opus_rc_normalize ( OpusRangeCoder rc)
static

Definition at line 186 of file opus.h.

Referenced by opus_rc_init(), opus_rc_p2model(), and opus_rc_update().

static av_always_inline void opus_rc_update ( OpusRangeCoder rc,
unsigned int  scale,
unsigned int  low,
unsigned int  high,
unsigned int  total 
)
static
static av_always_inline unsigned int opus_rc_getsymbol ( OpusRangeCoder rc,
const uint16_t *  cdf 
)
static
static av_always_inline unsigned int opus_rc_p2model ( OpusRangeCoder rc,
unsigned int  bits 
)
static
static av_always_inline unsigned int opus_rc_tell ( const OpusRangeCoder rc)
static

CELT: estimate bits of entropy that have thus far been consumed for the current CELT frame, to integer and fractional (1/8th bit) precision.

Definition at line 245 of file opus.h.

Referenced by celt_decode_allocation(), celt_decode_coarse_energy(), celt_decode_tf_changes(), ff_celt_decode_frame(), opus_decode_frame(), and parse_postfilter().

static av_always_inline unsigned int opus_rc_tell_frac ( const OpusRangeCoder rc)
static

Definition at line 250 of file opus.h.

Referenced by celt_decode_allocation(), celt_decode_band(), and celt_decode_bands().

static av_always_inline unsigned int opus_getrawbits ( OpusRangeCoder rc,
unsigned int  count 
)
static

CELT: read 1-25 raw bits at the end of the frame, backwards byte-wise.

Definition at line 272 of file opus.h.

Referenced by celt_decode_band(), celt_decode_final_energy(), celt_decode_fine_energy(), ff_celt_decode_frame(), opus_rc_unimodel(), and parse_postfilter().

static av_always_inline unsigned int opus_rc_unimodel ( OpusRangeCoder rc,
unsigned int  size 
)
static

CELT: read a uniform distribution.

Definition at line 293 of file opus.h.

Referenced by celt_decode_allocation(), celt_decode_band(), celt_decode_pulses(), opus_decode_frame(), and parse_postfilter().

static av_always_inline int opus_rc_laplace ( OpusRangeCoder rc,
unsigned int  symbol,
int  decay 
)
static

Definition at line 312 of file opus.h.

Referenced by celt_decode_coarse_energy().

static av_always_inline unsigned int opus_rc_stepmodel ( OpusRangeCoder rc,
int  k0 
)
static

Definition at line 351 of file opus.h.

Referenced by celt_decode_band().

static av_always_inline unsigned int opus_rc_trimodel ( OpusRangeCoder rc,
int  qn 
)
static

Definition at line 366 of file opus.h.

Referenced by celt_decode_band().

int ff_opus_parse_packet ( OpusPacket pkt,
const uint8_t buf,
int  buf_size,
int  self_delimited 
)

Parse Opus packet info from raw packet data.

Definition at line 88 of file opus.c.

Referenced by opus_decode_packet(), and opus_find_frame_end().

int ff_opus_parse_extradata ( AVCodecContext avctx,
OpusContext s 
)

Definition at line 289 of file opus.c.

Referenced by opus_decode_init(), and opus_find_frame_end().

int ff_silk_init ( AVCodecContext avctx,
SilkContext **  ps,
int  output_channels 
)

Definition at line 1575 of file opus_silk.c.

Referenced by opus_decode_init().

void ff_silk_free ( SilkContext **  ps)

Definition at line 1562 of file opus_silk.c.

Referenced by opus_decode_close().

void ff_silk_flush ( SilkContext s)

Definition at line 1567 of file opus_silk.c.

Referenced by ff_silk_init(), opus_decode_flush(), and opus_decode_frame().

int ff_silk_decode_superframe ( SilkContext s,
OpusRangeCoder rc,
float *  output[2],
enum OpusBandwidth  bandwidth,
int  coded_channels,
int  duration_ms 
)

Decode the LP layer of one Opus frame (which may correspond to several SILK frames).

Definition at line 1498 of file opus_silk.c.

Referenced by opus_decode_frame().

int ff_celt_init ( AVCodecContext avctx,
CeltContext **  s,
int  output_channels 
)

Definition at line 2188 of file opus_celt.c.

Referenced by opus_decode_init().

void ff_celt_free ( CeltContext **  s)

Definition at line 2173 of file opus_celt.c.

Referenced by ff_celt_init(), and opus_decode_close().

void ff_celt_flush ( CeltContext s)

Definition at line 2146 of file opus_celt.c.

Referenced by ff_celt_init(), opus_decode_flush(), and opus_decode_frame().

int ff_celt_decode_frame ( CeltContext s,
OpusRangeCoder rc,
float **  output,
int  coded_channels,
int  frame_size,
int  startband,
int  endband 
)

Definition at line 1976 of file opus_celt.c.

Referenced by opus_decode_frame(), and opus_decode_redundancy().

Variable Documentation

const uint8_t opus_default_extradata[30]
static
Initial value:
= {
'O', 'p', 'u', 's', 'H', 'e', 'a', 'd',
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}

Definition at line 67 of file opus.h.

Referenced by ff_opus_parse_extradata(), and ff_parse_mpeg2_descriptor().

const float ff_celt_window2[120]