FFmpeg
Data Structures | Macros | Functions | Variables
ilbcdec.c File Reference
#include "libavutil/channel_layout.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"
#include "ilbcdata.h"

Go to the source code of this file.

Data Structures

struct  ILBCFrame
 
struct  ILBCContext
 

Macros

#define LPC_N_20MS   1
 
#define LPC_N_30MS   2
 
#define LPC_N_MAX   2
 
#define LSF_NSPLIT   3
 
#define NASUB_MAX   4
 
#define LPC_FILTERORDER   10
 
#define NSUB_MAX   6
 
#define SUBL   40
 
#define ST_MEM_L_TBL   85
 
#define MEM_LF_TBL   147
 
#define STATE_SHORT_LEN_20MS   57
 
#define STATE_SHORT_LEN_30MS   58
 
#define BLOCKL_MAX   240
 
#define CB_MEML   147
 
#define CB_NSTAGES   3
 
#define CB_HALFFILTERLEN   4
 
#define CB_FILTERLEN   8
 
#define ENH_NBLOCKS_TOT   8
 
#define ENH_BLOCKL   80
 
#define ENH_BUFL   (ENH_NBLOCKS_TOT)*ENH_BLOCKL
 
#define ENH_BUFL_FILTEROVERHEAD   3
 
#define BLOCKL_MAX   240
 
#define NSUB_20MS   4
 
#define NSUB_30MS   6
 
#define NSUB_MAX   6
 
#define NASUB_20MS   2
 
#define NASUB_30MS   4
 
#define NASUB_MAX   4
 
#define STATE_LEN   80
 
#define STATE_SHORT_LEN_30MS   58
 
#define STATE_SHORT_LEN_20MS   57
 
#define SPL_MUL_16_16(a, b)   ((int32_t) (((int16_t)(a)) * ((int16_t)(b))))
 
#define SPL_MUL_16_16_RSFT(a, b, c)   (SPL_MUL_16_16(a, b) >> (c))
 
#define SPL_SHIFT_W32(x, c)   (((c) >= 0) ? ((x) << (c)) : ((x) >> (-(c))))
 

Functions

static int unpack_frame (ILBCContext *s, const uint8_t *buf, int size)
 
static void index_conv (int16_t *index)
 
static void lsf_dequantization (int16_t *lsfdeq, int16_t *index, int16_t lpc_n)
 
static void lsf_check_stability (int16_t *lsf, int dim, int nb_vectors)
 
static void lsf_interpolate (int16_t *out, const int16_t *in1, const int16_t *in2, int16_t coef, int size)
 
static void lsf2lsp (const int16_t *lsf, int16_t *lsp, int order)
 
static void get_lsp_poly (const int16_t *lsp, int32_t *f)
 
static void lsf2poly (int16_t *a, const int16_t *lsf)
 
static void lsp_interpolate2polydec (int16_t *a, const int16_t *lsf1, const int16_t *lsf2, int coef, int length)
 
static void bw_expand (int16_t *out, const int16_t *in, const int16_t *coef, int length)
 
static void lsp_interpolate (int16_t *syntdenum, int16_t *weightdenum, const int16_t *lsfdeq, int16_t length, ILBCContext *s)
 
static void filter_mafq12 (const int16_t *in_ptr, int16_t *out_ptr, const int16_t *B, int16_t B_length, int16_t length)
 
static void filter_arfq12 (const int16_t *data_in, int16_t *data_out, const int16_t *coefficients, int coefficients_length, int data_length)
 
static void state_construct (int16_t ifm, const int16_t *idx, const int16_t *synt_denum, int16_t *Out_fix, int16_t len)
 
static int16_t gain_dequantization (int index, int max_in, int stage)
 
static void vector_rmultiplication (int16_t *out, const int16_t *in, const int16_t *win, int length, int shift)
 
static void vector_multiplication (int16_t *out, const int16_t *in, const int16_t *win, int length, int shift)
 
static void add_vector_and_shift (int16_t *out, const int16_t *in1, const int16_t *in2, int length, int shift)
 
static void create_augmented_vector (int index, const int16_t *buffer, int16_t *cbVec)
 
static void get_codebook (int16_t *cbvec, int16_t *mem, int16_t index, int16_t lMem, int16_t cbveclen)
 
static void construct_vector (int16_t *decvector, const int16_t *index, const int16_t *gain_index, int16_t *mem, int16_t lMem, int16_t veclen)
 
static void reverse_memcpy (int16_t *dest, const int16_t *source, int length)
 
static void decode_residual (ILBCContext *s, ILBCFrame *encbits, int16_t *decresidual, const int16_t *syntdenum)
 
static int16_t max_abs_value_w16 (const int16_t *vector, int length)
 
static int16_t get_size_in_bits (uint32_t n)
 
static int32_t scale_dot_product (const int16_t *v1, const int16_t *v2, int length, int scaling)
 
static void correlation (int32_t *corr, int32_t *ener, const int16_t *buffer, int16_t lag, int16_t blen, int16_t srange, int16_t scale)
 
static int16_t norm_w32 (int32_t a)
 
static int32_t div_w32_w16 (int32_t num, int16_t den)
 
static void do_plc (int16_t *plc_residual, int16_t *plc_lpc, int16_t PLI, const int16_t *decresidual, const int16_t *lpc, int16_t inlag, ILBCContext *s)
 
static int xcorr_coeff (const int16_t *target, const int16_t *regressor, int16_t subl, int16_t searchLen, int16_t offset, int16_t step)
 
static void hp_output (int16_t *signal, const int16_t *ba, int16_t *y, int16_t *x, int16_t len)
 
static int ilbc_decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
 
static av_cold int ilbc_decode_init (AVCodecContext *avctx)
 

Variables

const FFCodec ff_ilbc_decoder
 

Macro Definition Documentation

◆ LPC_N_20MS

#define LPC_N_20MS   1

Definition at line 40 of file ilbcdec.c.

◆ LPC_N_30MS

#define LPC_N_30MS   2

Definition at line 41 of file ilbcdec.c.

◆ LPC_N_MAX

#define LPC_N_MAX   2

Definition at line 42 of file ilbcdec.c.

◆ LSF_NSPLIT

#define LSF_NSPLIT   3

Definition at line 43 of file ilbcdec.c.

◆ NASUB_MAX [1/2]

#define NASUB_MAX   4

Definition at line 70 of file ilbcdec.c.

◆ LPC_FILTERORDER

#define LPC_FILTERORDER   10

Definition at line 45 of file ilbcdec.c.

◆ NSUB_MAX [1/2]

#define NSUB_MAX   6

Definition at line 67 of file ilbcdec.c.

◆ SUBL

#define SUBL   40

Definition at line 47 of file ilbcdec.c.

◆ ST_MEM_L_TBL

#define ST_MEM_L_TBL   85

Definition at line 49 of file ilbcdec.c.

◆ MEM_LF_TBL

#define MEM_LF_TBL   147

Definition at line 50 of file ilbcdec.c.

◆ STATE_SHORT_LEN_20MS [1/2]

#define STATE_SHORT_LEN_20MS   57

Definition at line 73 of file ilbcdec.c.

◆ STATE_SHORT_LEN_30MS [1/2]

#define STATE_SHORT_LEN_30MS   58

Definition at line 72 of file ilbcdec.c.

◆ BLOCKL_MAX [1/2]

#define BLOCKL_MAX   240

Definition at line 64 of file ilbcdec.c.

◆ CB_MEML

#define CB_MEML   147

Definition at line 55 of file ilbcdec.c.

◆ CB_NSTAGES

#define CB_NSTAGES   3

Definition at line 56 of file ilbcdec.c.

◆ CB_HALFFILTERLEN

#define CB_HALFFILTERLEN   4

Definition at line 57 of file ilbcdec.c.

◆ CB_FILTERLEN

#define CB_FILTERLEN   8

Definition at line 58 of file ilbcdec.c.

◆ ENH_NBLOCKS_TOT

#define ENH_NBLOCKS_TOT   8

Definition at line 60 of file ilbcdec.c.

◆ ENH_BLOCKL

#define ENH_BLOCKL   80

Definition at line 61 of file ilbcdec.c.

◆ ENH_BUFL

#define ENH_BUFL   (ENH_NBLOCKS_TOT)*ENH_BLOCKL

Definition at line 62 of file ilbcdec.c.

◆ ENH_BUFL_FILTEROVERHEAD

#define ENH_BUFL_FILTEROVERHEAD   3

Definition at line 63 of file ilbcdec.c.

◆ BLOCKL_MAX [2/2]

#define BLOCKL_MAX   240

Definition at line 64 of file ilbcdec.c.

◆ NSUB_20MS

#define NSUB_20MS   4

Definition at line 65 of file ilbcdec.c.

◆ NSUB_30MS

#define NSUB_30MS   6

Definition at line 66 of file ilbcdec.c.

◆ NSUB_MAX [2/2]

#define NSUB_MAX   6

Definition at line 67 of file ilbcdec.c.

◆ NASUB_20MS

#define NASUB_20MS   2

Definition at line 68 of file ilbcdec.c.

◆ NASUB_30MS

#define NASUB_30MS   4

Definition at line 69 of file ilbcdec.c.

◆ NASUB_MAX [2/2]

#define NASUB_MAX   4

Definition at line 70 of file ilbcdec.c.

◆ STATE_LEN

#define STATE_LEN   80

Definition at line 71 of file ilbcdec.c.

◆ STATE_SHORT_LEN_30MS [2/2]

#define STATE_SHORT_LEN_30MS   58

Definition at line 72 of file ilbcdec.c.

◆ STATE_SHORT_LEN_20MS [2/2]

#define STATE_SHORT_LEN_20MS   57

Definition at line 73 of file ilbcdec.c.

◆ SPL_MUL_16_16

#define SPL_MUL_16_16 (   a,
  b 
)    ((int32_t) (((int16_t)(a)) * ((int16_t)(b))))

Definition at line 75 of file ilbcdec.c.

◆ SPL_MUL_16_16_RSFT

#define SPL_MUL_16_16_RSFT (   a,
  b,
  c 
)    (SPL_MUL_16_16(a, b) >> (c))

Definition at line 76 of file ilbcdec.c.

◆ SPL_SHIFT_W32

#define SPL_SHIFT_W32 (   x,
  c 
)    (((c) >= 0) ? ((x) << (c)) : ((x) >> (-(c))))

Definition at line 931 of file ilbcdec.c.

Function Documentation

◆ unpack_frame()

static int unpack_frame ( ILBCContext s,
const uint8_t *  buf,
int  size 
)
static

Definition at line 129 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ index_conv()

static void index_conv ( int16_t *  index)
static

Definition at line 272 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ lsf_dequantization()

static void lsf_dequantization ( int16_t *  lsfdeq,
int16_t *  index,
int16_t  lpc_n 
)
static

Definition at line 285 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ lsf_check_stability()

static void lsf_check_stability ( int16_t *  lsf,
int  dim,
int  nb_vectors 
)
static

Definition at line 313 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ lsf_interpolate()

static void lsf_interpolate ( int16_t *  out,
const int16_t *  in1,
const int16_t *  in2,
int16_t  coef,
int  size 
)
static

Definition at line 336 of file ilbcdec.c.

Referenced by lsp_interpolate2polydec().

◆ lsf2lsp()

static void lsf2lsp ( const int16_t *  lsf,
int16_t *  lsp,
int  order 
)
static

Definition at line 346 of file ilbcdec.c.

Referenced by lsf2poly().

◆ get_lsp_poly()

static void get_lsp_poly ( const int16_t *  lsp,
int32_t f 
)
static

Definition at line 369 of file ilbcdec.c.

Referenced by lsf2poly().

◆ lsf2poly()

static void lsf2poly ( int16_t *  a,
const int16_t *  lsf 
)
static

Definition at line 396 of file ilbcdec.c.

Referenced by lsp_interpolate2polydec().

◆ lsp_interpolate2polydec()

static void lsp_interpolate2polydec ( int16_t *  a,
const int16_t *  lsf1,
const int16_t *  lsf2,
int  coef,
int  length 
)
static

Definition at line 423 of file ilbcdec.c.

Referenced by lsp_interpolate().

◆ bw_expand()

static void bw_expand ( int16_t *  out,
const int16_t *  in,
const int16_t *  coef,
int  length 
)
static

Definition at line 432 of file ilbcdec.c.

Referenced by lsp_interpolate().

◆ lsp_interpolate()

static void lsp_interpolate ( int16_t *  syntdenum,
int16_t *  weightdenum,
const int16_t *  lsfdeq,
int16_t  length,
ILBCContext s 
)
static

Definition at line 441 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ filter_mafq12()

static void filter_mafq12 ( const int16_t *  in_ptr,
int16_t *  out_ptr,
const int16_t *  B,
int16_t  B_length,
int16_t  length 
)
static

Definition at line 483 of file ilbcdec.c.

Referenced by get_codebook(), and state_construct().

◆ filter_arfq12()

static void filter_arfq12 ( const int16_t *  data_in,
int16_t *  data_out,
const int16_t *  coefficients,
int  coefficients_length,
int  data_length 
)
static

Definition at line 503 of file ilbcdec.c.

Referenced by ilbc_decode_frame(), and state_construct().

◆ state_construct()

static void state_construct ( int16_t  ifm,
const int16_t *  idx,
const int16_t *  synt_denum,
int16_t *  Out_fix,
int16_t  len 
)
static

Definition at line 525 of file ilbcdec.c.

Referenced by decode_residual().

◆ gain_dequantization()

static int16_t gain_dequantization ( int  index,
int  max_in,
int  stage 
)
static

Definition at line 605 of file ilbcdec.c.

Referenced by construct_vector().

◆ vector_rmultiplication()

static void vector_rmultiplication ( int16_t *  out,
const int16_t *  in,
const int16_t *  win,
int  length,
int  shift 
)
static

Definition at line 612 of file ilbcdec.c.

Referenced by create_augmented_vector().

◆ vector_multiplication()

static void vector_multiplication ( int16_t *  out,
const int16_t *  in,
const int16_t *  win,
int  length,
int  shift 
)
static

Definition at line 620 of file ilbcdec.c.

Referenced by create_augmented_vector().

◆ add_vector_and_shift()

static void add_vector_and_shift ( int16_t *  out,
const int16_t *  in1,
const int16_t *  in2,
int  length,
int  shift 
)
static

Definition at line 628 of file ilbcdec.c.

Referenced by create_augmented_vector().

◆ create_augmented_vector()

static void create_augmented_vector ( int  index,
const int16_t *  buffer,
int16_t *  cbVec 
)
static

Definition at line 636 of file ilbcdec.c.

Referenced by get_codebook().

◆ get_codebook()

static void get_codebook ( int16_t *  cbvec,
int16_t *  mem,
int16_t  index,
int16_t  lMem,
int16_t  cbveclen 
)
static

Definition at line 651 of file ilbcdec.c.

Referenced by construct_vector().

◆ construct_vector()

static void construct_vector ( int16_t *  decvector,
const int16_t *  index,
const int16_t *  gain_index,
int16_t *  mem,
int16_t  lMem,
int16_t  veclen 
)
static

Definition at line 720 of file ilbcdec.c.

Referenced by decode_residual().

◆ reverse_memcpy()

static void reverse_memcpy ( int16_t *  dest,
const int16_t *  source,
int  length 
)
static

Definition at line 759 of file ilbcdec.c.

Referenced by decode_residual().

◆ decode_residual()

static void decode_residual ( ILBCContext s,
ILBCFrame encbits,
int16_t *  decresidual,
const int16_t *  syntdenum 
)
static

Definition at line 769 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ max_abs_value_w16()

static int16_t max_abs_value_w16 ( const int16_t *  vector,
int  length 
)
static

Definition at line 870 of file ilbcdec.c.

Referenced by do_plc(), and xcorr_coeff().

◆ get_size_in_bits()

static int16_t get_size_in_bits ( uint32_t  n)
static

Definition at line 888 of file ilbcdec.c.

Referenced by do_plc().

◆ scale_dot_product()

static int32_t scale_dot_product ( const int16_t *  v1,
const int16_t *  v2,
int  length,
int  scaling 
)
static

Definition at line 907 of file ilbcdec.c.

Referenced by correlation(), do_plc(), and xcorr_coeff().

◆ correlation()

static void correlation ( int32_t corr,
int32_t ener,
const int16_t *  buffer,
int16_t  lag,
int16_t  blen,
int16_t  srange,
int16_t  scale 
)
static

Definition at line 917 of file ilbcdec.c.

Referenced by do_plc(), and yae_align().

◆ norm_w32()

static int16_t norm_w32 ( int32_t  a)
static

Definition at line 933 of file ilbcdec.c.

Referenced by do_plc(), and xcorr_coeff().

◆ div_w32_w16()

static int32_t div_w32_w16 ( int32_t  num,
int16_t  den 
)
static

Definition at line 944 of file ilbcdec.c.

Referenced by do_plc().

◆ do_plc()

static void do_plc ( int16_t *  plc_residual,
int16_t *  plc_lpc,
int16_t  PLI,
const int16_t *  decresidual,
const int16_t *  lpc,
int16_t  inlag,
ILBCContext s 
)
static

Definition at line 952 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ xcorr_coeff()

static int xcorr_coeff ( const int16_t *  target,
const int16_t *  regressor,
int16_t  subl,
int16_t  searchLen,
int16_t  offset,
int16_t  step 
)
static

Definition at line 1200 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ hp_output()

static void hp_output ( int16_t *  signal,
const int16_t *  ba,
int16_t *  y,
int16_t *  x,
int16_t  len 
)
static

Definition at line 1311 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ ilbc_decode_frame()

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

Definition at line 1353 of file ilbcdec.c.

◆ ilbc_decode_init()

static av_cold int ilbc_decode_init ( AVCodecContext avctx)
static

Definition at line 1440 of file ilbcdec.c.

Variable Documentation

◆ ff_ilbc_decoder

const FFCodec ff_ilbc_decoder
Initial value:
= {
.p.name = "ilbc",
CODEC_LONG_NAME("iLBC (Internet Low Bitrate Codec)"),
.p.type = AVMEDIA_TYPE_AUDIO,
.priv_data_size = sizeof(ILBCContext),
}

Definition at line 1475 of file ilbcdec.c.

FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:311
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
ilbc_decode_frame
static int ilbc_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition: ilbcdec.c:1353
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:106
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
ilbc_decode_init
static av_cold int ilbc_decode_init(AVCodecContext *avctx)
Definition: ilbcdec.c:1440
AV_CODEC_ID_ILBC
@ AV_CODEC_ID_ILBC
Definition: codec_id.h:506
ILBCContext
Definition: ilbcdec.c:89