FFmpeg
Data Structures | Macros | Functions | Variables
ilbcdec.c File Reference
#include "avcodec.h"
#include "internal.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)
 
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, int16_t *in1, int16_t *in2, int16_t coef, int size)
 
static void lsf2lsp (int16_t *lsf, int16_t *lsp, int order)
 
static void get_lsp_poly (int16_t *lsp, int32_t *f)
 
static void lsf2poly (int16_t *a, int16_t *lsf)
 
static void lsp_interpolate2polydec (int16_t *a, int16_t *lsf1, 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, int16_t *lsfdeq, int16_t length, ILBCContext *s)
 
static void filter_mafq12 (int16_t *in_ptr, int16_t *out_ptr, 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, int16_t *idx, 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, 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, int16_t *index, int16_t *gain_index, int16_t *mem, int16_t lMem, int16_t veclen)
 
static void reverse_memcpy (int16_t *dest, int16_t *source, int length)
 
static void decode_residual (ILBCContext *s, ILBCFrame *encbits, int16_t *decresidual, 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, 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, int16_t *decresidual, int16_t *lpc, int16_t inlag, ILBCContext *s)
 
static int xcorr_coeff (int16_t *target, 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, void *data, int *got_frame_ptr, AVPacket *avpkt)
 
static av_cold int ilbc_decode_init (AVCodecContext *avctx)
 

Variables

AVCodec ff_ilbc_decoder
 

Macro Definition Documentation

◆ LPC_N_20MS

#define LPC_N_20MS   1

Definition at line 38 of file ilbcdec.c.

◆ LPC_N_30MS

#define LPC_N_30MS   2

Definition at line 39 of file ilbcdec.c.

◆ LPC_N_MAX

#define LPC_N_MAX   2

Definition at line 40 of file ilbcdec.c.

◆ LSF_NSPLIT

#define LSF_NSPLIT   3

Definition at line 41 of file ilbcdec.c.

◆ NASUB_MAX [1/2]

#define NASUB_MAX   4

Definition at line 68 of file ilbcdec.c.

◆ LPC_FILTERORDER

#define LPC_FILTERORDER   10

Definition at line 43 of file ilbcdec.c.

◆ NSUB_MAX [1/2]

#define NSUB_MAX   6

Definition at line 65 of file ilbcdec.c.

◆ SUBL

#define SUBL   40

Definition at line 45 of file ilbcdec.c.

◆ ST_MEM_L_TBL

#define ST_MEM_L_TBL   85

Definition at line 47 of file ilbcdec.c.

◆ MEM_LF_TBL

#define MEM_LF_TBL   147

Definition at line 48 of file ilbcdec.c.

◆ STATE_SHORT_LEN_20MS [1/2]

#define STATE_SHORT_LEN_20MS   57

Definition at line 71 of file ilbcdec.c.

◆ STATE_SHORT_LEN_30MS [1/2]

#define STATE_SHORT_LEN_30MS   58

Definition at line 70 of file ilbcdec.c.

◆ BLOCKL_MAX [1/2]

#define BLOCKL_MAX   240

Definition at line 62 of file ilbcdec.c.

◆ CB_MEML

#define CB_MEML   147

Definition at line 53 of file ilbcdec.c.

◆ CB_NSTAGES

#define CB_NSTAGES   3

Definition at line 54 of file ilbcdec.c.

◆ CB_HALFFILTERLEN

#define CB_HALFFILTERLEN   4

Definition at line 55 of file ilbcdec.c.

◆ CB_FILTERLEN

#define CB_FILTERLEN   8

Definition at line 56 of file ilbcdec.c.

◆ ENH_NBLOCKS_TOT

#define ENH_NBLOCKS_TOT   8

Definition at line 58 of file ilbcdec.c.

◆ ENH_BLOCKL

#define ENH_BLOCKL   80

Definition at line 59 of file ilbcdec.c.

◆ ENH_BUFL

#define ENH_BUFL   (ENH_NBLOCKS_TOT)*ENH_BLOCKL

Definition at line 60 of file ilbcdec.c.

◆ ENH_BUFL_FILTEROVERHEAD

#define ENH_BUFL_FILTEROVERHEAD   3

Definition at line 61 of file ilbcdec.c.

◆ BLOCKL_MAX [2/2]

#define BLOCKL_MAX   240

Definition at line 62 of file ilbcdec.c.

◆ NSUB_20MS

#define NSUB_20MS   4

Definition at line 63 of file ilbcdec.c.

◆ NSUB_30MS

#define NSUB_30MS   6

Definition at line 64 of file ilbcdec.c.

◆ NSUB_MAX [2/2]

#define NSUB_MAX   6

Definition at line 65 of file ilbcdec.c.

◆ NASUB_20MS

#define NASUB_20MS   2

Definition at line 66 of file ilbcdec.c.

◆ NASUB_30MS

#define NASUB_30MS   4

Definition at line 67 of file ilbcdec.c.

◆ NASUB_MAX [2/2]

#define NASUB_MAX   4

Definition at line 68 of file ilbcdec.c.

◆ STATE_LEN

#define STATE_LEN   80

Definition at line 69 of file ilbcdec.c.

◆ STATE_SHORT_LEN_30MS [2/2]

#define STATE_SHORT_LEN_30MS   58

Definition at line 70 of file ilbcdec.c.

◆ STATE_SHORT_LEN_20MS [2/2]

#define STATE_SHORT_LEN_20MS   57

Definition at line 71 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 73 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 74 of file ilbcdec.c.

◆ SPL_SHIFT_W32

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

Definition at line 928 of file ilbcdec.c.

Function Documentation

◆ unpack_frame()

static int unpack_frame ( ILBCContext s)
static

Definition at line 128 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ index_conv()

static void index_conv ( int16_t *  index)
static

Definition at line 268 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 281 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 309 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ lsf_interpolate()

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

Definition at line 332 of file ilbcdec.c.

Referenced by lsp_interpolate2polydec().

◆ lsf2lsp()

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

Definition at line 342 of file ilbcdec.c.

Referenced by lsf2poly().

◆ get_lsp_poly()

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

Definition at line 365 of file ilbcdec.c.

Referenced by lsf2poly().

◆ lsf2poly()

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

Definition at line 392 of file ilbcdec.c.

Referenced by lsp_interpolate2polydec().

◆ lsp_interpolate2polydec()

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

Definition at line 419 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 428 of file ilbcdec.c.

Referenced by lsp_interpolate().

◆ lsp_interpolate()

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

Definition at line 437 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ filter_mafq12()

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

Definition at line 479 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 499 of file ilbcdec.c.

Referenced by ilbc_decode_frame(), and state_construct().

◆ state_construct()

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

Definition at line 521 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 600 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 607 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 615 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 623 of file ilbcdec.c.

Referenced by create_augmented_vector().

◆ create_augmented_vector()

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

Definition at line 631 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 646 of file ilbcdec.c.

Referenced by construct_vector().

◆ construct_vector()

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

Definition at line 715 of file ilbcdec.c.

Referenced by decode_residual().

◆ reverse_memcpy()

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

Definition at line 754 of file ilbcdec.c.

Referenced by decode_residual().

◆ decode_residual()

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

Definition at line 764 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 865 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 883 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 902 of file ilbcdec.c.

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

◆ correlation()

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

Definition at line 912 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 930 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 941 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,
int16_t *  decresidual,
int16_t *  lpc,
int16_t  inlag,
ILBCContext s 
)
static

Definition at line 949 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ xcorr_coeff()

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

Definition at line 1203 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 1315 of file ilbcdec.c.

Referenced by ilbc_decode_frame().

◆ ilbc_decode_frame()

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

Definition at line 1357 of file ilbcdec.c.

◆ ilbc_decode_init()

static av_cold int ilbc_decode_init ( AVCodecContext avctx)
static

Definition at line 1445 of file ilbcdec.c.

Variable Documentation

◆ ff_ilbc_decoder

AVCodec ff_ilbc_decoder
Initial value:
= {
.name = "ilbc",
.long_name = NULL_IF_CONFIG_SMALL("iLBC (Internet Low Bitrate Codec)"),
.decode = ilbc_decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
.priv_data_size = sizeof(ILBCContext),
}

Definition at line 1480 of file ilbcdec.c.

ilbc_decode_frame
static int ilbc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: ilbcdec.c:1357
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:50
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:188
ilbc_decode_init
static av_cold int ilbc_decode_init(AVCodecContext *avctx)
Definition: ilbcdec.c:1445
AV_CODEC_ID_ILBC
@ AV_CODEC_ID_ILBC
Definition: codec_id.h:469
ILBCContext
Definition: ilbcdec.c:87