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

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

#include "libavutil/channel_layout.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.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
 
#define OFFSET(x)
 
#define AD   AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 

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, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
 

Variables

static const struct PfCoeff postfilter_coeffs [5]
 
static const AVOption options []
 
static const AVClass evrcdec_class
 
const FFCodec 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

◆ MIN_LSP_SEP

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

Definition at line 39 of file evrcdec.c.

Referenced by decode_lspf().

◆ MIN_DELAY

#define MIN_DELAY   20

Definition at line 40 of file evrcdec.c.

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

◆ MAX_DELAY

#define MAX_DELAY   120

Definition at line 41 of file evrcdec.c.

◆ NB_SUBFRAMES

#define NB_SUBFRAMES   3

Definition at line 42 of file evrcdec.c.

Referenced by evrc_decode_frame(), and frame_erasure().

◆ SUBFRAME_SIZE

#define SUBFRAME_SIZE   54

◆ FILTER_ORDER

◆ ACB_SIZE

#define ACB_SIZE   128

Definition at line 45 of file evrcdec.c.

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

◆ OFFSET

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

Definition at line 919 of file evrcdec.c.

◆ AD

Definition at line 920 of file evrcdec.c.

Referenced by interpolate().

Enumeration Type Documentation

◆ evrc_packet_rate

Enumerator
RATE_ERRS 
SILENCE 
RATE_QUANT 
RATE_QUARTER 
RATE_HALF 
RATE_FULL 

Definition at line 47 of file evrcdec.c.

Function Documentation

◆ unpack_frame()

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 110 of file evrcdec.c.

Referenced by evrc_decode_frame().

◆ buf_size2bitrate()

static evrc_packet_rate buf_size2bitrate ( const int buf_size)
static

Definition at line 167 of file evrcdec.c.

Referenced by determine_bitrate().

◆ 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 buffer
Returns
the bitrate on success, RATE_ERRS if the bitrate cannot be satisfactorily determined

Definition at line 190 of file evrcdec.c.

Referenced by evrc_decode_frame(), and qcelp_decode_frame().

◆ warn_insufficient_frame_quality()

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

Definition at line 221 of file evrcdec.c.

Referenced by evrc_decode_frame().

◆ evrc_decode_init()

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 233 of file evrcdec.c.

◆ decode_lspf()

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 286 of file evrcdec.c.

Referenced by evrc_decode_frame().

◆ interpolate_lsp()

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

Definition at line 319 of file evrcdec.c.

Referenced by evrc_decode_frame(), and frame_erasure().

◆ interpolate_delay()

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

Definition at line 333 of file evrcdec.c.

Referenced by evrc_decode_frame(), and frame_erasure().

◆ decode_predictor_coeffs()

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

Definition at line 350 of file evrcdec.c.

Referenced by evrc_decode_frame(), and frame_erasure().

◆ bl_intrp()

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

Definition at line 380 of file evrcdec.c.

Referenced by acb_excitation().

◆ acb_excitation()

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

Definition at line 408 of file evrcdec.c.

Referenced by evrc_decode_frame(), and frame_erasure().

◆ decode_8_pulses_35bits()

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

Definition at line 435 of file evrcdec.c.

Referenced by fcb_excitation().

◆ decode_3_pulses_10bits()

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

Definition at line 460 of file evrcdec.c.

Referenced by fcb_excitation().

◆ 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 480 of file evrcdec.c.

Referenced by evrc_decode_frame().

◆ synthesis_filter()

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.

Parameters
[in]ininput signal
[in]filter_coeffsLPC coefficients
[in/out]memory synthesis filter memory
buffer_lengthamount of data to process
[out]samplesoutput samples

TIA/IS-127 5.2.3.15, 5.7.3.4

Definition at line 508 of file evrcdec.c.

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

◆ bandwidth_expansion()

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

Definition at line 524 of file evrcdec.c.

Referenced by evrc_decode_frame(), and postfilter().

◆ residual_filter()

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

Definition at line 535 of file evrcdec.c.

Referenced by postfilter().

◆ 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 575 of file evrcdec.c.

Referenced by evrc_decode_frame(), and frame_erasure().

◆ frame_erasure()

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

Definition at line 656 of file evrcdec.c.

Referenced by decode_frame(), and evrc_decode_frame().

◆ evrc_decode_frame()

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

Definition at line 746 of file evrcdec.c.

Variable Documentation

◆ postfilter_coeffs

const 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().

◆ options

const AVOption options[]
static
Initial value:
= {
{ "postfilter", "enable postfilter", OFFSET(postfilter), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AD },
{ NULL }
}
static void postfilter(AMRContext *p, float *lpc, float *buf_out)
Perform adaptive post-filtering to enhance the quality of the speech.
Definition amrnbdec.c:913
#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 922 of file evrcdec.c.

◆ evrcdec_class

const AVClass evrcdec_class
static
Initial value:
= {
.class_name = "evrc",
.item_name = av_default_item_name,
.option = 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

Definition at line 927 of file evrcdec.c.

◆ ff_evrc_decoder

const FFCodec ff_evrc_decoder
Initial value:
= {
.p.name = "evrc",
CODEC_LONG_NAME("EVRC (Enhanced Variable Rate Codec)"),
.p.type = AVMEDIA_TYPE_AUDIO,
.priv_data_size = sizeof(EVRCContext),
.p.priv_class = &evrcdec_class,
}
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
static int evrc_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition evrcdec.c:746
static const AVClass evrcdec_class
Definition evrcdec.c:927
static av_cold int evrc_decode_init(AVCodecContext *avctx)
Initialize the speech codec according to the specification.
Definition evrcdec.c:233
#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_EVRC
Definition codec_id.h:524
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201

Definition at line 934 of file evrcdec.c.