#include <float.h>
#include "avcodec.h"
#include "put_bits.h"
#include "celp_filters.h"
#include "ra144.h"
Go to the source code of this file.
Functions | |
static av_cold int | ra144_encode_init (AVCodecContext *avctx) |
static av_cold int | ra144_encode_close (AVCodecContext *avctx) |
static int | quantize (int value, const int16_t *table, unsigned int size) |
Quantize a value by searching a sorted table for the element with the nearest value. | |
static void | orthogonalize (float *v, const float *u) |
Orthogonalize a vector to another vector. | |
static void | get_match_score (float *work, const float *coefs, float *vect, const float *ortho1, const float *ortho2, const float *data, float *score, float *gain) |
Calculate match score and gain of an LPC-filtered vector with respect to input data, possibly othogonalizing it to up to 2 other vectors. | |
static void | create_adapt_vect (float *vect, const int16_t *cb, int lag) |
Create a vector from the adaptive codebook at a given lag value. | |
static int | adaptive_cb_search (const int16_t *adapt_cb, float *work, const float *coefs, float *data) |
Search the adaptive codebook for the best entry and gain and remove its contribution from input data. | |
static void | find_best_vect (float *work, const float *coefs, const int8_t cb[][BLOCKSIZE], const float *ortho1, const float *ortho2, float *data, int *idx, float *gain) |
Find the best vector of a fixed codebook by applying an LPC filter to codebook entries, possibly othogonalizing them to up to 2 other vectors and matching the results with input data. | |
static void | fixed_cb_search (float *work, const float *coefs, float *data, int cba_idx, int *cb1_idx, int *cb2_idx) |
Search the two fixed codebooks for the best entry and gain. | |
static void | ra144_encode_subblock (RA144Context *ractx, const int16_t *sblock_data, const int16_t *lpc_coefs, unsigned int rms, PutBitContext *pb) |
Encode a subblock of the current frame. | |
static int | ra144_encode_frame (AVCodecContext *avctx, uint8_t *frame, int buf_size, void *data) |
Variables | |
AVCodec | ff_ra_144_encoder |
Definition in file ra144enc.c.
static int adaptive_cb_search | ( | const int16_t * | adapt_cb, | |
float * | work, | |||
const float * | coefs, | |||
float * | data | |||
) | [static] |
Search the adaptive codebook for the best entry and gain and remove its contribution from input data.
adapt_cb | array from which the adaptive codebook is extracted | |
work | array used to calculate LPC-filtered vectors | |
coefs | coefficients of the LPC filter | |
data | input data |
Re-calculate the filtered vector from the vector with maximum match score and remove its contribution from input data.
Definition at line 189 of file ra144enc.c.
Referenced by ra144_encode_subblock().
static void create_adapt_vect | ( | float * | vect, | |
const int16_t * | cb, | |||
int | lag | |||
) | [static] |
Create a vector from the adaptive codebook at a given lag value.
vect | array where vector is stored | |
cb | adaptive codebook | |
lag | lag value |
Definition at line 166 of file ra144enc.c.
Referenced by adaptive_cb_search().
static void find_best_vect | ( | float * | work, | |
const float * | coefs, | |||
const int8_t | cb[][BLOCKSIZE], | |||
const float * | ortho1, | |||
const float * | ortho2, | |||
float * | data, | |||
int * | idx, | |||
float * | gain | |||
) | [static] |
Find the best vector of a fixed codebook by applying an LPC filter to codebook entries, possibly othogonalizing them to up to 2 other vectors and matching the results with input data.
work | array used to calculate the filtered vectors | |
coefs | coefficients of the LPC filter | |
cb | fixed codebook | |
ortho1 | first vector against which orthogonalization is performed | |
ortho2 | second vector against which orthogonalization is performed | |
data | input data | |
idx | pointer to variable where the index of the best codebook entry is returned | |
gain | pointer to variable where the gain of the best codebook entry is returned |
Definition at line 237 of file ra144enc.c.
Referenced by fixed_cb_search().
static void fixed_cb_search | ( | float * | work, | |
const float * | coefs, | |||
float * | data, | |||
int | cba_idx, | |||
int * | cb1_idx, | |||
int * | cb2_idx | |||
) | [static] |
Search the two fixed codebooks for the best entry and gain.
work | array used to calculate LPC-filtered vectors | |
coefs | coefficients of the LPC filter | |
data | input data | |
cba_idx | index of the best entry of the adaptive codebook | |
cb1_idx | pointer to variable where the index of the best entry of the first fixed codebook is returned | |
cb2_idx | pointer to variable where the index of the best entry of the second fixed codebook is returned |
The filtered vector from the adaptive codebook can be retrieved from work, because this function is called just after adaptive_cb_search().
Re-calculate the filtered vector from the vector with maximum match score and remove its contribution from input data.
Definition at line 272 of file ra144enc.c.
Referenced by ra144_encode_subblock().
static void get_match_score | ( | float * | work, | |
const float * | coefs, | |||
float * | vect, | |||
const float * | ortho1, | |||
const float * | ortho2, | |||
const float * | data, | |||
float * | score, | |||
float * | gain | |||
) | [static] |
Calculate match score and gain of an LPC-filtered vector with respect to input data, possibly othogonalizing it to up to 2 other vectors.
work | array used to calculate the filtered vector | |
coefs | coefficients of the LPC filter | |
vect | original vector | |
ortho1 | first vector against which orthogonalization is performed | |
ortho2 | second vector against which orthogonalization is performed | |
data | input data | |
score | pointer to variable where match score is returned | |
gain | pointer to variable where gain is returned |
Definition at line 133 of file ra144enc.c.
Referenced by adaptive_cb_search(), and find_best_vect().
static void orthogonalize | ( | float * | v, | |
const float * | u | |||
) | [static] |
Orthogonalize a vector to another vector.
v | vector to orthogonalize | |
u | vector against which orthogonalization is performed |
Definition at line 105 of file ra144enc.c.
Referenced by fixed_cb_search(), and get_match_score().
static int quantize | ( | int | value, | |
const int16_t * | table, | |||
unsigned int | size | |||
) | [static] |
Quantize a value by searching a sorted table for the element with the nearest value.
value | value to quantize | |
table | array containing the quantization table | |
size | size of the quantization table |
Definition at line 80 of file ra144enc.c.
static av_cold int ra144_encode_close | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 62 of file ra144enc.c.
static int ra144_encode_frame | ( | AVCodecContext * | avctx, | |
uint8_t * | frame, | |||
int | buf_size, | |||
void * | data | |||
) | [static] |
< reflection coefficients of the frame
< RMS of the reflection coefficients
Since the LPC coefficients are calculated on a frame centered over the fourth subframe, to encode a given frame, data from the next frame is needed. In each call to this function, the previous frame (whose data are saved in the encoder context) is encoded, and data from the current frame are saved in the encoder context to be used in the next function call.
TODO: apply perceptual weighting of the input speech through bandwidth expansion of the LPC filter.
The filter is unstable: use the coefficients of the previous frame.
Definition at line 422 of file ra144enc.c.
static av_cold int ra144_encode_init | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 36 of file ra144enc.c.
static void ra144_encode_subblock | ( | RA144Context * | ractx, | |
const int16_t * | sblock_data, | |||
const int16_t * | lpc_coefs, | |||
unsigned int | rms, | |||
PutBitContext * | pb | |||
) | [static] |
Encode a subblock of the current frame.
ractx | encoder context | |
sblock_data | input data of the subblock | |
lpc_coefs | coefficients of the LPC filter | |
rms | RMS of the reflection coefficients | |
pb | pointer to PutBitContext of the current frame |
Calculate the zero-input response of the LPC filter and subtract it from input data.
Codebook search is performed without taking into account the contribution of the previous subblock, since it has been just subtracted from input data.
The filtered vector from the adaptive codebook can be retrieved from work, see implementation of adaptive_cb_search().
Definition at line 321 of file ra144enc.c.
Referenced by ra144_encode_frame().
Initial value:
{ "real_144", AVMEDIA_TYPE_AUDIO, CODEC_ID_RA_144, sizeof(RA144Context), ra144_encode_init, ra144_encode_frame, ra144_encode_close, .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K) encoder"), }
Definition at line 511 of file ra144enc.c.