Go to the documentation of this file.
91 unsigned int low = 0, high =
size - 1;
94 int index = (low + high) >> 1;
117 float num = 0, den = 0;
143 const float *ortho1,
const float *ortho2,
144 const float *
data,
float *score,
float *gain)
184 vect[lag +
i] =
cb[
i];
199 const float *coefs,
float *
data)
202 float score, gain, best_score,
av_uninit(best_gain);
205 gain = best_score = 0;
209 if (score > best_score) {
248 const float *ortho2,
float *
data,
int *idx,
252 float g, score, best_score;
255 *idx = *gain = best_score = 0;
260 if (score > best_score) {
282 int cba_idx,
int *cb1_idx,
int *cb2_idx)
294 memcpy(cba_vect,
work,
sizeof(cba_vect));
297 data, cb1_idx, &gain);
311 memcpy(cb1_vect,
work,
sizeof(cb1_vect));
317 ortho_cb1 ? cb1_vect :
NULL,
data, cb2_idx, &gain);
331 const int16_t *sblock_data,
332 const int16_t *lpc_coefs,
unsigned int rms,
338 int cba_idx, cb1_idx, cb2_idx, gain;
342 float error, best_error;
346 coefs[
i] = lpc_coefs[
i] * (1/4096.0);
392 best_error = FLT_MAX;
394 for (n = 0; n < 256; n++) {
407 (
data[
i] - sblock_data[
i]);
413 (
data[
i] - sblock_data[
i]);
416 if (
error < best_error) {
442 unsigned int refl_rms[
NBLOCKS];
462 energy += (lpc_data[
i] * lpc_data[
i]) >> 4;
468 energy += (lpc_data[
i] * lpc_data[
i]) >> 4;
495 memset(lpc_refl, 0,
sizeof(lpc_refl));
507 refl_rms[1] =
ff_interp(ractx, block_coefs[1], 2,
508 energy <= ractx->old_energy,
510 refl_rms[2] =
ff_interp(ractx, block_coefs[2], 3, 0, energy);
516 block_coefs[
i], refl_rms[
i], &pb);
525 for (;
i <
frame->nb_samples;
i++)
557 .supported_samplerates = (
const int[]){ 8000, 0 },
static void error(const char *err)
int frame_size
Number of samples per channel in an audio frame.
static av_cold int init(AVCodecContext *avctx)
#define NBLOCKS
number of subblocks within a block
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.
void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, int64_t *duration)
Remove frame(s) from the queue.
#define FFSWAP(type, a, b)
static double cb(void *priv, double x, double y)
void ff_af_queue_close(AudioFrameQueue *afq)
Close AudioFrameQueue.
#define u(width, name, range_min, range_max)
static enum AVSampleFormat sample_fmts[]
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.
#define AV_CH_LAYOUT_MONO
const int16_t ff_energy_tab[32]
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq)
Initialize AudioFrameQueue.
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.
This structure describes decoded (raw) audio or video data.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
void ff_eval_coefs(int *coefs, const int *refl)
Evaluate the LPC filter coefficients from the reflection coefficients.
static const uint16_t table[]
av_cold void ff_audiodsp_init(AudioDSPContext *c)
#define FIXED_CB_SIZE
size of fixed codebooks
const int8_t ff_cb2_vects[128][40]
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new samples
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
#define BUFFERSIZE
the size of the adaptive codebook
void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP synthesis filter.
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,...
int16_t buffer_a[FFALIGN(BLOCKSIZE, 16)]
const int8_t ff_cb1_vects[128][40]
int initial_padding
Audio only.
unsigned int * lpc_coef[2]
LPC coefficients: lpc_coef[0] is the coefficients of the current frame and lpc_coef[1] of the previou...
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.
int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
Add a frame to the queue.
int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx)
Evaluate the reflection coefficients from the filter coefficients.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const int16_t *const ff_lpc_refl_cb[10]
int ff_irms(AudioDSPContext *adsp, const int16_t *data)
inverse root mean square
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.
int16_t curr_block[NBLOCKS *BLOCKSIZE]
unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy)
const uint16_t ff_cb2_base[128]
static const int sizes[][2]
int64_t bit_rate
the average bitrate
must be printed separately If there s no standard function for printing the type you the WRITE_1D_FUNC_ARGV macro is a very quick way to create one See libavcodec dv_tablegen c for an example The h file This file should the initialization functions should not do and instead of the variable declarations the generated *_tables h file should be included Since that will be generated in the build the path must be i e not Makefile changes To make the automatic table creation work
unsigned int lpc_tables[2][10]
int ff_lpc_calc_coefs(LPCContext *s, const int32_t *samples, int blocksize, int min_order, int max_order, int precision, int32_t coefs[][MAX_LPC_ORDER], int *shift, enum FFLPCType lpc_type, int lpc_passes, int omethod, int min_shift, int max_shift, int zero_shift)
Calculate LPC coefficients for multiple orders.
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,...
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int16_t curr_sblock[50]
The current subblock padded by the last 10 values of the previous one.
AVCodec ff_ra_144_encoder
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
const uint16_t ff_cb1_base[128]
void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset)
Copy the last offset values of *source to *target.
unsigned int ff_rms(const int *data)
av_cold void ff_lpc_end(LPCContext *s)
Uninitialize LPCContext.
int channels
number of audio channels
const int16_t ff_gain_val_tab[256][3]
void ff_int_to_int16(int16_t *out, const int *inp)
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
unsigned int old_energy
previous frame energy
static av_cold int ra144_encode_close(AVCodecContext *avctx)
AVSampleFormat
Audio sample formats.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
@ AV_SAMPLE_FMT_S16
signed 16 bits
const char * name
Name of the codec implementation.
void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs, int cba_idx, int cb1_idx, int cb2_idx, int gval, int gain)
static void orthogonalize(float *v, const float *u)
Orthogonalize a vector to another vector.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int16_t adapt_cb[146+2]
Adaptive codebook, its size is two units bigger to avoid a buffer overflow.
main external API structure.
int ff_t_sqrt(unsigned int x)
Evaluate sqrt(x << 24).
int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold, int energy)
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
static int ra144_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
static int shift(int a, int b)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
This structure stores compressed data.
unsigned int lpc_refl_rms[2]
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
#define BLOCKSIZE
subblock size in 16-bit words
@ FF_LPC_TYPE_LEVINSON
Levinson-Durbin recursion.
const uint8_t ff_gain_exp_tab[256]
static av_cold int ra144_encode_init(AVCodecContext *avctx)
av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order, enum FFLPCType lpc_type)
Initialize LPCContext.