Go to the documentation of this file.
25 #define LPC_USE_DOUBLE
41 c = 2.0 / (
len - 1.0);
72 for(j=0; j<lag; j+=2){
73 double sum0 = 1.0, sum1 = 1.0;
97 int max_shift,
int zero_shift)
105 qmax = (1 << (precision - 1)) - 1;
109 for(
i=0;
i<order;
i++) {
110 cmax=
FFMAX(cmax, fabs(lpc_in[
i]));
114 if(cmax * (1 << max_shift) < 1.0) {
116 memset(lpc_out, 0,
sizeof(
int32_t) * order);
122 while((cmax * (1 << sh) > qmax) && (sh > min_shift)) {
128 if(sh == 0 && cmax > qmax) {
129 double scale = ((double)qmax) / cmax;
130 for(
i=0;
i<order;
i++) {
137 for(
i=0;
i<order;
i++) {
138 error -= lpc_in[
i] * (1 << sh);
150 for(
i=max_order-1;
i>=min_order-1;
i--) {
164 s->lpc_apply_welch_window(
samples,
s->blocksize,
s->windowed_samples);
165 s->lpc_compute_autocorr(
s->windowed_samples,
s->blocksize, order, autoc);
172 int order,
double *
ref)
175 double signal = 0.0f, avg_err = 0.0f;
177 const double a = 0.5f,
b = 1.0f -
a;
180 for (
i = 0;
i <=
len / 2;
i++) {
186 s->lpc_compute_autocorr(
s->windowed_samples,
len, order, autoc);
189 for (
i = 0;
i < order;
i++)
190 avg_err = (avg_err +
error[
i])/2.0f;
191 return signal/avg_err;
202 int max_order,
int precision,
205 int omethod,
int min_shift,
int max_shift,
int zero_shift)
218 if (blocksize !=
s->blocksize || max_order !=
s->max_order ||
219 lpc_type !=
s->lpc_type) {
228 s->lpc_apply_welch_window(
samples, blocksize,
s->windowed_samples);
230 s->lpc_compute_autocorr(
s->windowed_samples, blocksize, max_order, autoc);
234 for(
i=0;
i<max_order;
i++)
246 for(j=0; j<max_order; j++)
247 m[0].
coeff[max_order-1][j] = -lpc[max_order-1][j];
253 for(
i=max_order;
i<blocksize;
i++){
254 for(j=0; j<=max_order; j++)
258 double eval, inv, rinv;
260 eval= (512>>
pass) + fabs(eval - var[0]);
263 for(j=0; j<=max_order; j++)
274 for(
i=0;
i<max_order;
i++){
275 for(j=0; j<max_order; j++)
277 ref[
i]= sqrt(m[(
pass-1)&1].variance[
i] /
weight) * (blocksize - max_order) / 4000;
279 for(
i=max_order-1;
i>0;
i--)
283 opt_order = max_order;
289 min_shift, max_shift, zero_shift);
291 for(
i=min_order-1;
i<max_order;
i++) {
293 min_shift, max_shift, zero_shift);
303 s->blocksize = blocksize;
304 s->max_order = max_order;
305 s->lpc_type = lpc_type;
308 sizeof(*
s->windowed_samples));
309 if (!
s->windowed_buffer)
311 s->windowed_samples =
s->windowed_buffer +
FFALIGN(max_order, 4);
static void error(const char *err)
Linear least squares model.
FFLPCType
LPC analysis type.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
@ FF_LPC_TYPE_CHOLESKY
Cholesky factorization.
static int AAC_RENAME() compute_lpc_coefs(const LPC_TYPE *autoc, int max_order, LPC_TYPE *lpc, int lpc_stride, int fail, int normalize)
Levinson-Durbin recursion.
static int estimate_best_order(double *ref, int min_order, int max_order)
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
static void lpc_apply_welch_window_c(const int32_t *data, int len, double *w_data)
Apply Welch window function to audio block.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
av_cold void avpriv_init_lls(LLSModel *m, int indep_count)
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.
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
static int weight(int i, int blen, int offset)
double ff_lpc_calc_ref_coefs_f(LPCContext *s, const float *samples, int len, int order, double *ref)
void(* update_lls)(struct LLSModel *m, const double *var)
Take the outer-product of var[] with itself, and add to the covariance matrix.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
int ff_lpc_calc_ref_coefs(LPCContext *s, const int32_t *samples, int order, double *ref)
double(* evaluate_lls)(struct LLSModel *m, const double *var, int order)
Inner product of var[] and the LPC coefs.
av_cold void ff_lpc_end(LPCContext *s)
Uninitialize LPCContext.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define i(width, name, range_min, range_max)
static void compute_ref_coefs(const LPC_TYPE *autoc, int max_order, LPC_TYPE *ref, LPC_TYPE *error)
Schur recursion.
static void quantize_lpc_coefs(double *lpc_in, int order, int precision, int32_t *lpc_out, int *shift, int min_shift, int max_shift, int zero_shift)
Quantize LPC coefficients.
static void lpc_compute_autocorr_c(const double *data, int len, int lag, double *autoc)
Calculate autocorrelation data from audio samples A Welch window function is applied before calculati...
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 please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo ug o o w
av_cold void ff_lpc_init_x86(LPCContext *c)
double coeff[32][MAX_VARS]
static int ref[MAX_W *MAX_W]
static int shift(int a, int b)
#define LOCAL_ALIGNED(a, t, v,...)
static const double coeff[2][5]
@ FF_LPC_TYPE_LEVINSON
Levinson-Durbin recursion.
void avpriv_solve_lls(LLSModel *m, double threshold, unsigned short min_order)
av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order, enum FFLPCType lpc_type)
Initialize LPCContext.
@ FF_LPC_TYPE_FIXED
fixed LPC coefficients