]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/lls.c
configure: Add check_cc/require_cc helper functions to simplify some expressions
[ffmpeg] / libavutil / lls.c
index 2061e6a5a92ed307cec77df4c9db14f5be2db49a..97bffb4018fdf0533580a94a8ed927e36c5afb02 100644 (file)
 #include <string.h>
 
 #include "attributes.h"
+#include "internal.h"
 #include "version.h"
 #include "lls.h"
 
-av_cold void avpriv_init_lls(LLSModel *m, int indep_count)
-{
-    memset(m, 0, sizeof(LLSModel));
-    m->indep_count = indep_count;
-}
-
-void avpriv_update_lls(LLSModel *m, double *var)
+static void update_lls(LLSModel *m, double *var)
 {
     int i, j;
 
@@ -52,8 +47,8 @@ void avpriv_update_lls(LLSModel *m, double *var)
 void avpriv_solve_lls(LLSModel *m, double threshold, unsigned short min_order)
 {
     int i, j, k;
-    double (*factor)[MAX_VARS + 1] = (void *) &m->covariance[1][0];
-    double (*covar) [MAX_VARS + 1] = (void *) &m->covariance[1][1];
+    double (*factor)[MAX_VARS_ALIGN] = (void *) &m->covariance[1][0];
+    double (*covar) [MAX_VARS_ALIGN] = (void *) &m->covariance[1][1];
     double *covar_y                = m->covariance[0];
     int count                      = m->indep_count;
 
@@ -106,7 +101,7 @@ void avpriv_solve_lls(LLSModel *m, double threshold, unsigned short min_order)
     }
 }
 
-double avpriv_evaluate_lls(LLSModel *m, double *param, int order)
+static double evaluate_lls(LLSModel *m, double *param, int order)
 {
     int i;
     double out = 0;
@@ -117,59 +112,12 @@ double avpriv_evaluate_lls(LLSModel *m, double *param, int order)
     return out;
 }
 
-#if FF_API_LLS_PRIVATE
-av_cold void av_init_lls(LLSModel *m, int indep_count)
-{
-    avpriv_init_lls(m, indep_count);
-}
-void av_update_lls(LLSModel *m, double *param, double decay)
-{
-    avpriv_update_lls(m, param);
-}
-void av_solve_lls(LLSModel *m, double threshold, int min_order)
-{
-    avpriv_solve_lls(m, threshold, min_order);
-}
-double av_evaluate_lls(LLSModel *m, double *param, int order)
-{
-    return avpriv_evaluate_lls(m, param, order);
-}
-#endif /* FF_API_LLS_PRIVATE */
-
-#ifdef TEST
-
-#include <stdio.h>
-#include <limits.h>
-#include "lfg.h"
-
-int main(void)
+av_cold void avpriv_init_lls(LLSModel *m, int indep_count)
 {
-    LLSModel m;
-    int i, order;
-    AVLFG lfg;
-
-    av_lfg_init(&lfg, 1);
-    avpriv_init_lls(&m, 3);
-
-    for (i = 0; i < 100; i++) {
-        double var[4];
-        double eval;
-
-        var[0] = (av_lfg_get(&lfg) / (double) UINT_MAX - 0.5) * 2;
-        var[1] = var[0] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
-        var[2] = var[1] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
-        var[3] = var[2] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
-        avpriv_update_lls(&m, var);
-        avpriv_solve_lls(&m, 0.001, 0);
-        for (order = 0; order < 3; order++) {
-            eval = avpriv_evaluate_lls(&m, var + 1, order);
-            printf("real:%9f order:%d pred:%9f var:%f coeffs:%f %9f %9f\n",
-                   var[0], order, eval, sqrt(m.variance[order] / (i + 1)),
-                   m.coeff[order][0], m.coeff[order][1],
-                   m.coeff[order][2]);
-        }
-    }
-    return 0;
+    memset(m, 0, sizeof(LLSModel));
+    m->indep_count = indep_count;
+    m->update_lls = update_lls;
+    m->evaluate_lls = evaluate_lls;
+    if (ARCH_X86)
+        ff_init_lls_x86(m);
 }
-
-#endif