FFmpeg
4.0
|
QCELP decoder. More...
#include <stddef.h>
#include "libavutil/avassert.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"
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 |
QCELP decoder.
Definition in file qcelpdec.c.
enum qcelp_packet_rate |
Enumerator | |
---|---|
I_F_Q | insufficient frame quality |
SILENCE | |
RATE_OCTAVE | |
RATE_QUARTER | |
RATE_HALF | |
RATE_FULL |
Definition at line 44 of file qcelpdec.c.
|
static |
Initialize the speech codec according to the specification.
TIA/EIA/IS-733 2.4.9
Definition at line 85 of file qcelpdec.c.
|
static |
Decode the 10 quantized LSP frequencies from the LSPV/LSP transmission codes of any bitrate and check for badly received packets.
q | the context |
lspf | line spectral pair frequencies |
TIA/EIA/IS-733 2.4.3.2.6.2-2, 2.4.8.7.3
Definition at line 111 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Convert codebook transmission codes to GAIN and INDEX.
q | the context |
gain | array holding the decoded gain |
TIA/EIA/IS-733 2.4.6.2
Definition at line 195 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
If the received packet is Rate 1/4 a further sanity check is made of the codebook gain.
cbgain | the unpacked cbgain array |
TIA/EIA/IS-733 2.4.8.7.3
Definition at line 273 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.
q | the context |
gain | array holding the 4 pitch subframe gain values |
cdn_vector | array for the generated scaled codebook vector |
Definition at line 309 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Apply generic gain control.
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 396 of file qcelpdec.c.
Referenced by apply_pitch_filters().
|
static |
Apply filter in pitch-subframe steps.
memory | buffer for the previous state of the filter
|
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
|
pfrac | per-subframe boolean array, 1 if the lag is fractional, 0 otherwise |
Definition at line 423 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
q | the context |
cdn_vector | the scaled codebook vector |
Definition at line 467 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Reconstruct LPC coefficients from the line spectral pair frequencies and perform bandwidth expansion.
lspf | line spectral pair frequencies |
lpc | linear predictive coding coefficients |
TIA/EIA/IS-733 2.4.3.3.5
Definition at line 536 of file qcelpdec.c.
Referenced by interpolate_lpc().
|
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
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 564 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Definition at line 588 of file qcelpdec.c.
Referenced by determine_bitrate().
|
static |
Determine the bitrate from the frame size and/or the first byte of the frame.
avctx | the AV codec context |
buf_size | length of the buffer |
buf | the buffer |
TIA/EIA/IS-733 2.4.8.7.1
Definition at line 613 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Definition at line 647 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Definition at line 654 of file qcelpdec.c.
Referenced by qcelp_decode_frame().
|
static |
Definition at line 686 of file qcelpdec.c.
AVCodec ff_qcelp_decoder |
Definition at line 793 of file qcelpdec.c.