FFmpeg
4.0
|
Real Audio 1.0 (14.4K) encoder. More...
#include <float.h>
#include "avcodec.h"
#include "audio_frame_queue.h"
#include "celp_filters.h"
#include "internal.h"
#include "mathops.h"
#include "put_bits.h"
#include "ra144.h"
Go to the source code of this file.
Functions | |
static av_cold int | ra144_encode_close (AVCodecContext *avctx) |
static av_cold int | ra144_encode_init (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. More... | |
static void | orthogonalize (float *v, const float *u) |
Orthogonalize a vector to another vector. More... | |
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 orthogonalizing it to up to two other vectors. More... | |
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. More... | |
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. More... | |
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 orthogonalizing them to up to two other vectors and matching the results with input data. More... | |
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. More... | |
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. More... | |
static int | ra144_encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) |
Variables | |
AVCodec | ff_ra_144_encoder |
Real Audio 1.0 (14.4K) encoder.
Definition in file ra144enc.c.
|
static |
Definition at line 38 of file ra144enc.c.
Referenced by ra144_encode_init().
|
static |
Definition at line 47 of file ra144enc.c.
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 89 of file ra144enc.c.
Referenced by ra144_encode_frame().
|
static |
Orthogonalize a vector to another vector.
v | vector to orthogonalize |
u | vector against which orthogonalization is performed |
Definition at line 114 of file ra144enc.c.
Referenced by fixed_cb_search(), and get_match_score().
|
static |
Calculate match score and gain of an LPC-filtered vector with respect to input data, possibly orthogonalizing it to up to two 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 142 of file ra144enc.c.
Referenced by adaptive_cb_search(), and find_best_vect().
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 175 of file ra144enc.c.
Referenced by adaptive_cb_search().
|
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 198 of file ra144enc.c.
Referenced by ra144_encode_subblock().
|
static |
Find the best vector of a fixed codebook by applying an LPC filter to codebook entries, possibly orthogonalizing them to up to two 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 246 of file ra144enc.c.
Referenced by fixed_cb_search().
|
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 281 of file ra144enc.c.
Referenced by ra144_encode_subblock().
|
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 330 of file ra144enc.c.
Referenced by ra144_encode_frame().
|
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 430 of file ra144enc.c.
AVCodec ff_ra_144_encoder |
Definition at line 545 of file ra144enc.c.