FFmpeg
|
QCELP decoder. More...
#include <stddef.h>
#include "libavutil/channel_layout.h"
#include "libavutil/float_dsp.h"
#include "avcodec.h"
#include "internal.h"
#include "get_bits.h"
#include "qcelpdata.h"
#include "celp_filters.h"
#include "acelp_filters.h"
#include "acelp_vectors.h"
#include "lsp.h"
#include <assert.h>
Go to the source code of this file.
Data Structures | |
struct | QCELPContext |
Enumerations | |
enum | qcelp_packet_rate { I_F_Q = -1, SILENCE, RATE_OCTAVE, RATE_QUARTER, RATE_HALF, RATE_FULL } |
Functions | |
static av_cold int | qcelp_decode_init (AVCodecContext *avctx) |
Initialize the speech codec according to the specification. More... | |
static int | decode_lspf (QCELPContext *q, float *lspf) |
Decode the 10 quantized LSP frequencies from the LSPV/LSP transmission codes of any bitrate and check for badly received packets. More... | |
static void | decode_gain_and_index (QCELPContext *q, float *gain) |
Convert codebook transmission codes to GAIN and INDEX. More... | |
static int | codebook_sanity_check_for_rate_quarter (const uint8_t *cbgain) |
If the received packet is Rate 1/4 a further sanity check is made of the codebook gain. More... | |
static void | compute_svector (QCELPContext *q, const float *gain, float *cdn_vector) |
Compute the scaled codebook vector Cdn From INDEX and GAIN for all rates. More... | |
static void | apply_gain_ctrl (float *v_out, const float *v_ref, const float *v_in) |
Apply generic gain control. More... | |
static const float * | do_pitchfilter (float memory[303], const float v_in[160], const float gain[4], const uint8_t *lag, const uint8_t pfrac[4]) |
Apply filter in pitch-subframe steps. More... | |
static void | apply_pitch_filters (QCELPContext *q, float *cdn_vector) |
Apply pitch synthesis filter and pitch prefilter to the scaled codebook vector. More... | |
static void | lspf2lpc (const float *lspf, float *lpc) |
Reconstruct LPC coefficients from the line spectral pair frequencies and perform bandwidth expansion. More... | |
static void | interpolate_lpc (QCELPContext *q, const float *curr_lspf, float *lpc, const int subframe_num) |
Interpolate LSP frequencies and compute LPC coefficients for a given bitrate & pitch subframe. More... | |
static qcelp_packet_rate | buf_size2bitrate (const int buf_size) |
static qcelp_packet_rate | determine_bitrate (AVCodecContext *avctx, const int buf_size, const uint8_t **buf) |
Determine the bitrate from the frame size and/or the first byte of the frame. More... | |
static void | warn_insufficient_frame_quality (AVCodecContext *avctx, const char *message) |
static void | postfilter (QCELPContext *q, float *samples, float *lpc) |
static int | qcelp_decode_frame (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) |
Variables | |
AVCodec | ff_qcelp_decoder |
Detailed Description
QCELP decoder.
- Remarks
- FFmpeg merging spearheaded by Kenan Gillet
- Development mentored by Benjamin Larson
Definition in file qcelpdec.c.
Enumeration Type Documentation
enum qcelp_packet_rate |
Enumerator | |
---|---|
I_F_Q |
insufficient frame quality |
SILENCE | |
RATE_OCTAVE | |
RATE_QUARTER | |
RATE_HALF | |
RATE_FULL |
Definition at line 46 of file qcelpdec.c.
Function Documentation
|
static |
Apply generic gain control.
- Parameters
-
v_out output vector v_in gain-controlled vector v_ref vector to control gain of
TIA/EIA/IS-733 2.4.8.3, 2.4.8.6
Definition at line 395 of file qcelpdec.c.
Referenced by apply_pitch_filters().
|
static |
Apply pitch synthesis filter and pitch prefilter to the scaled codebook vector.
TIA/EIA/IS-733 2.4.5.2, 2.4.8.7.2
- Parameters
-
q the context cdn_vector the scaled codebook vector
Definition at line 465 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Definition at line 585 of file qcelpdec.c.
Referenced by determine_bitrate().
|
static |
If the received packet is Rate 1/4 a further sanity check is made of the codebook gain.
- Parameters
-
cbgain the unpacked cbgain array
- Returns
- -1 if the sanity check fails, 0 otherwise
TIA/EIA/IS-733 2.4.8.7.3
Definition at line 275 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Compute the scaled codebook vector Cdn From INDEX and GAIN for all rates.
The specification lacks some information here.
TIA/EIA/IS-733 has an omission on the codebook index determination formula for RATE_FULL and RATE_HALF frames at section 2.4.8.1.1. It says you have to subtract the decoded index parameter from the given scaled codebook vector index 'n' to get the desired circular codebook index, but it does not mention that you have to clamp 'n' to [0-9] in order to get RI-compliant results.
The reason for this mistake seems to be the fact they forgot to mention you have to do these calculations per codebook subframe and adjust given equation values accordingly.
- Parameters
-
q the context gain array holding the 4 pitch subframe gain values cdn_vector array for the generated scaled codebook vector
Definition at line 311 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Convert codebook transmission codes to GAIN and INDEX.
- Parameters
-
q the context gain array holding the decoded gain
TIA/EIA/IS-733 2.4.6.2
Definition at line 197 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Decode the 10 quantized LSP frequencies from the LSPV/LSP transmission codes of any bitrate and check for badly received packets.
- Parameters
-
q the context lspf line spectral pair frequencies
- Returns
- 0 on success, -1 if the packet is badly received
TIA/EIA/IS-733 2.4.3.2.6.2-2, 2.4.8.7.3
Definition at line 113 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Determine the bitrate from the frame size and/or the first byte of the frame.
- Parameters
-
avctx the AV codec context buf_size length of the buffer buf the bufffer
- Returns
- the bitrate on success, I_F_Q if the bitrate cannot be satisfactorily determined
TIA/EIA/IS-733 2.4.8.7.1
Definition at line 610 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Apply filter in pitch-subframe steps.
- Parameters
-
memory buffer for the previous state of the filter - must be able to contain 303 elements
- the 143 first elements are from the previous state
- the next 160 are for output
v_in input filter vector gain per-subframe gain array, each element is between 0.0 and 2.0 lag per-subframe lag array, each element is - between 16 and 143 if its corresponding pfrac is 0,
- between 16 and 139 otherwise
pfrac per-subframe boolean array, 1 if the lag is fractional, 0 otherwise
- Returns
- filter output vector
Definition at line 422 of file qcelpdec.c.
Referenced by apply_pitch_filters().
|
static |
Interpolate LSP frequencies and compute LPC coefficients for a given bitrate & pitch subframe.
TIA/EIA/IS-733 2.4.3.3.4, 2.4.8.7.2
- Parameters
-
q the context curr_lspf LSP frequencies vector of the current frame lpc float vector for the resulting LPC subframe_num frame number in decoded stream
Definition at line 561 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Reconstruct LPC coefficients from the line spectral pair frequencies and perform bandwidth expansion.
- Parameters
-
lspf line spectral pair frequencies lpc linear predictive coding coefficients
- Note
- : bandwidth_expansion_coeff could be precalculated into a table but it seems to be slower on x86
TIA/EIA/IS-733 2.4.3.3.5
Definition at line 533 of file qcelpdec.c.
Referenced by interpolate_lpc().
|
static |
Definition at line 651 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Definition at line 683 of file qcelpdec.c.
|
static |
Initialize the speech codec according to the specification.
TIA/EIA/IS-733 2.4.9
Definition at line 87 of file qcelpdec.c.
|
static |
Definition at line 644 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
Variable Documentation
AVCodec ff_qcelp_decoder |
Definition at line 788 of file qcelpdec.c.
Generated on Mon Nov 18 2024 06:52:08 for FFmpeg by 1.8.11