FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
evrcdec.c File Reference

Enhanced Variable Rate Codec, Service Option 3 decoder. More...

#include "libavutil/mathematics.h"
#include "avcodec.h"
#include "internal.h"
#include "get_bits.h"
#include "evrcdata.h"
#include "acelp_vectors.h"
#include "lsp.h"

Go to the source code of this file.

Data Structures

struct  EVRCAFrame
 EVRC-A unpacked data frame. More...
 
struct  EVRCContext
 
struct  PfCoeff
 

Macros

#define MIN_LSP_SEP   (0.05 / (2.0 * M_PI))
 
#define MIN_DELAY   20
 
#define MAX_DELAY   120
 
#define NB_SUBFRAMES   3
 
#define SUBFRAME_SIZE   54
 
#define FILTER_ORDER   10
 
#define ACB_SIZE   128
 

Enumerations

enum  evrc_packet_rate {
  RATE_ERRS = -1, SILENCE, RATE_QUANT, RATE_QUARTER,
  RATE_HALF, RATE_FULL
}
 

Functions

static void unpack_frame (EVRCContext *e)
 Frame unpacking for RATE_FULL, RATE_HALF and RATE_QUANT.
 
static evrc_packet_rate buf_size2bitrate (const int buf_size)
 
static evrc_packet_rate determine_bitrate (AVCodecContext *avctx, int *buf_size, const uint8_t **buf)
 Determine the bitrate from the frame size and/or the first byte of the frame.
 
static void warn_insufficient_frame_quality (AVCodecContext *avctx, const char *message)
 
static av_cold int evrc_decode_init (AVCodecContext *avctx)
 Initialize the speech codec according to the specification.
 
static int decode_lspf (EVRCContext *e)
 Decode the 10 vector quantized line spectral pair frequencies from the LSP transmission codes of any bitrate and check for badly received packets.
 
static void interpolate_lsp (float *ilsp, const float *lsp, const float *prev, int index)
 
static void interpolate_delay (float *dst, float current, float prev, int index)
 
static void decode_predictor_coeffs (const float *ilspf, float *ilpc)
 
static void bl_intrp (EVRCContext *e, float *ex, float delay)
 
static void acb_excitation (EVRCContext *e, float *excitation, float gain, const float delay[3], int length)
 
static void decode_8_pulses_35bits (const uint16_t *fixed_index, float *cod)
 
static void decode_3_pulses_10bits (uint16_t fixed_index, float *cod)
 
static void fcb_excitation (EVRCContext *e, const uint16_t *codebook, float *excitation, float pitch_gain, int pitch_lag, int subframe_size)
 
static void synthesis_filter (const float *in, const float *filter_coeffs, float *memory, int buffer_length, float *samples)
 Synthesis of the decoder output signal.
 
static void bandwidth_expansion (float *coeff, const float *inbuf, float gamma)
 
static void residual_filter (float *output, const float *input, const float *coef, float *memory, int length)
 
static void postfilter (EVRCContext *e, float *in, const float *coeff, float *out, int idx, const struct PfCoeff *pfc, int length)
 
static void frame_erasure (EVRCContext *e, float *samples)
 
static int evrc_decode_frame (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
 

Variables

static struct PfCoeff postfilter_coeffs [5]
 
AVCodec ff_evrc_decoder
 

Detailed Description

Enhanced Variable Rate Codec, Service Option 3 decoder.

Author
Paul B Mahol

Definition in file evrcdec.c.

Macro Definition Documentation

#define MIN_LSP_SEP   (0.05 / (2.0 * M_PI))

Definition at line 36 of file evrcdec.c.

Referenced by decode_lspf().

#define MIN_DELAY   20

Definition at line 37 of file evrcdec.c.

Referenced by evrc_decode_frame(), frame_erasure(), and postfilter().

#define MAX_DELAY   120

Definition at line 38 of file evrcdec.c.

Referenced by evrc_decode_frame(), and postfilter().

#define NB_SUBFRAMES   3

Definition at line 39 of file evrcdec.c.

Referenced by evrc_decode_frame(), and frame_erasure().

#define SUBFRAME_SIZE   54
#define FILTER_ORDER   10
#define ACB_SIZE   128

Definition at line 42 of file evrcdec.c.

Referenced by evrc_decode_frame(), evrc_decode_init(), frame_erasure(), and postfilter().

Enumeration Type Documentation

Enumerator:
RATE_ERRS 
SILENCE 
RATE_QUANT 
RATE_QUARTER 
RATE_HALF 
RATE_FULL 

Definition at line 44 of file evrcdec.c.

Function Documentation

static void unpack_frame ( EVRCContext e)
static

Frame unpacking for RATE_FULL, RATE_HALF and RATE_QUANT.

Parameters
ethe context

TIA/IS-127 Table 4.21-1

Definition at line 103 of file evrcdec.c.

Referenced by evrc_decode_frame().

static evrc_packet_rate buf_size2bitrate ( const int  buf_size)
static

Definition at line 160 of file evrcdec.c.

Referenced by determine_bitrate().

static evrc_packet_rate determine_bitrate ( AVCodecContext avctx,
int *  buf_size,
const uint8_t **  buf 
)
static

Determine the bitrate from the frame size and/or the first byte of the frame.

Parameters
avctxthe AV codec context
buf_sizelength of the buffer
bufthe bufffer
Returns
the bitrate on success, RATE_ERRS if the bitrate cannot be satisfactorily determined

Definition at line 183 of file evrcdec.c.

Referenced by evrc_decode_frame().

static void warn_insufficient_frame_quality ( AVCodecContext avctx,
const char *  message 
)
static

Definition at line 214 of file evrcdec.c.

Referenced by evrc_decode_frame().

static av_cold int evrc_decode_init ( AVCodecContext avctx)
static

Initialize the speech codec according to the specification.

TIA/IS-127 5.2

Definition at line 226 of file evrcdec.c.

static int decode_lspf ( EVRCContext e)
static

Decode the 10 vector quantized line spectral pair frequencies from the LSP transmission codes of any bitrate and check for badly received packets.

Parameters
ethe context
Returns
0 on success, -1 if the packet is badly received

TIA/IS-127 5.2.1, 5.7.1

Definition at line 277 of file evrcdec.c.

Referenced by evrc_decode_frame().

static void interpolate_lsp ( float *  ilsp,
const float *  lsp,
const float *  prev,
int  index 
)
static

Definition at line 310 of file evrcdec.c.

Referenced by evrc_decode_frame(), and frame_erasure().

static void interpolate_delay ( float *  dst,
float  current,
float  prev,
int  index 
)
static

Definition at line 324 of file evrcdec.c.

Referenced by evrc_decode_frame(), and frame_erasure().

static void decode_predictor_coeffs ( const float *  ilspf,
float *  ilpc 
)
static

Definition at line 341 of file evrcdec.c.

Referenced by evrc_decode_frame(), and frame_erasure().

static void bl_intrp ( EVRCContext e,
float *  ex,
float  delay 
)
static

Definition at line 371 of file evrcdec.c.

Referenced by acb_excitation().

static void acb_excitation ( EVRCContext e,
float *  excitation,
float  gain,
const float  delay[3],
int  length 
)
static

Definition at line 399 of file evrcdec.c.

Referenced by evrc_decode_frame(), and frame_erasure().

static void decode_8_pulses_35bits ( const uint16_t *  fixed_index,
float *  cod 
)
static

Definition at line 426 of file evrcdec.c.

Referenced by fcb_excitation().

static void decode_3_pulses_10bits ( uint16_t  fixed_index,
float *  cod 
)
static

Definition at line 451 of file evrcdec.c.

Referenced by fcb_excitation().

static void fcb_excitation ( EVRCContext e,
const uint16_t *  codebook,
float *  excitation,
float  pitch_gain,
int  pitch_lag,
int  subframe_size 
)
static

Definition at line 471 of file evrcdec.c.

Referenced by evrc_decode_frame().

static void synthesis_filter ( const float *  in,
const float *  filter_coeffs,
float *  memory,
int  buffer_length,
float *  samples 
)
static

Synthesis of the decoder output signal.

param[in] in input signal param[in] filter_coeffs LPC coefficients param[in/out] memory synthesis filter memory param buffer_length amount of data to process param[out] samples output samples

TIA/IS-127 5.2.3.15, 5.7.3.4

Definition at line 499 of file evrcdec.c.

Referenced by evrc_decode_frame(), frame_erasure(), and postfilter().

static void bandwidth_expansion ( float *  coeff,
const float *  inbuf,
float  gamma 
)
static

Definition at line 515 of file evrcdec.c.

Referenced by evrc_decode_frame(), and postfilter().

static void residual_filter ( float *  output,
const float *  input,
const float *  coef,
float *  memory,
int  length 
)
static

Definition at line 526 of file evrcdec.c.

Referenced by postfilter().

static void postfilter ( EVRCContext e,
float *  in,
const float *  coeff,
float *  out,
int  idx,
const struct PfCoeff pfc,
int  length 
)
static

Definition at line 566 of file evrcdec.c.

Referenced by evrc_decode_frame(), and frame_erasure().

static void frame_erasure ( EVRCContext e,
float *  samples 
)
static

Definition at line 647 of file evrcdec.c.

Referenced by decode_frame(), and evrc_decode_frame().

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

Definition at line 737 of file evrcdec.c.

Variable Documentation

struct PfCoeff postfilter_coeffs[5]
static
Initial value:
= {
{ 0.0 , 0.0 , 0.0 , 0.0 },
{ 0.0 , 0.0 , 0.57, 0.57 },
{ 0.0 , 0.0 , 0.0 , 0.0 },
{ 0.35, 0.50, 0.50, 0.75 },
{ 0.20, 0.50, 0.57, 0.75 },
}

Referenced by evrc_decode_frame(), and frame_erasure().

AVCodec ff_evrc_decoder
Initial value:
= {
.name = "evrc",
.long_name = NULL_IF_CONFIG_SMALL("EVRC (Enhanced Variable Rate Codec)"),
.decode = evrc_decode_frame,
.capabilities = CODEC_CAP_DR1,
.priv_data_size = sizeof(EVRCContext),
}

Definition at line 908 of file evrcdec.c.