Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / libvorbis / vq / cascade.c
blob89a47c74a5c6bfc81c57b79d07ba11c66ea3ef8c
1 /********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7 * *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
10 * *
11 ********************************************************************
13 function: function call to do simple data cascading
14 last mod: $Id: cascade.c 16037 2009-05-26 21:10:58Z xiphmont $
16 ********************************************************************/
18 /* this one outputs residue to stdout. */
20 #include <stdlib.h>
21 #include <unistd.h>
22 #include <math.h>
23 #include "bookutil.h"
25 /* set up metrics */
27 float count=0.f;
30 void process_preprocess(codebook **bs,char *basename){
33 void process_postprocess(codebook **b,char *basename){
34 fprintf(stderr,"Done. \n");
37 float process_one(codebook *b,float *a,int dim,int step,int addmul,
38 float base){
39 int j;
41 if(b->c->q_sequencep){
42 float temp;
43 for(j=0;j<dim;j++){
44 temp=a[j*step];
45 a[j*step]-=base;
47 base=temp;
50 vorbis_book_besterror(b,a,step,addmul);
52 return base;
55 void process_vector(codebook **bs,int *addmul,int inter,float *a,int n){
56 int i,bi=0;
57 int booknum=0;
59 while(*bs){
60 float base=0.f;
61 codebook *b=*bs;
62 int dim=b->dim;
64 if(inter){
65 for(i=0;i<n/dim;i++)
66 base=process_one(b,a+i,dim,n/dim,addmul[bi],base);
67 }else{
68 for(i=0;i<=n-dim;i+=dim)
69 base=process_one(b,a+i,dim,1,addmul[bi],base);
72 bs++;
73 booknum++;
74 bi++;
77 for(i=0;i<n;i++)
78 fprintf(stdout,"%f, ",a[i]);
79 fprintf(stdout,"\n");
81 if((long)(count++)%100)spinnit("working.... lines: ",count);
84 void process_usage(void){
85 fprintf(stderr,
86 "usage: vqcascade [-i] +|*<codebook>.vqh [ +|*<codebook.vqh> ]... \n"
87 " datafile.vqd [datafile.vqd]...\n\n"
88 " data can be taken on stdin. residual error data sent to\n"
89 " stdout.\n\n");