51819d0112533946f7375c196de4466dd9c4fa8b
[platform/upstream/libvorbis.git] / vq / cascade.c
1 /********************************************************************
2  *                                                                  *
3  * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE.  *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5  * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
6  * PLEASE READ THESE TERMS DISTRIBUTING.                            *
7  *                                                                  *
8  * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000             *
9  * by Monty <monty@xiph.org> and The XIPHOPHORUS Company            *
10  * http://www.xiph.org/                                             *
11  *                                                                  *
12  ********************************************************************
13
14  function: function call to do simple data cascading
15  last mod: $Id: cascade.c,v 1.3 2000/01/06 13:57:12 xiphmont Exp $
16
17  ********************************************************************/
18
19 /* this one outputs residue to stdout. */
20
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <math.h>
24 #include "bookutil.h"
25
26 /* set up metrics */
27
28 double count=0.;
29
30 void process_preprocess(codebook *b,char *basename){
31 }
32 void process_postprocess(codebook *b,char *basename){
33   fprintf(stderr,"Done.                      \n");
34 }
35
36 void process_vector(codebook *b,double *a){
37   int entry=codebook_entry(b,a);
38   double *e=b->valuelist+b->dim*entry;
39   int i;
40
41   for(i=0;i<b->dim;i++)
42     fprintf(stdout,"%f, ",a[i]-e[i]);
43   fprintf(stdout,"\n");
44
45   if((long)(count++)%100)spinnit("working.... lines: ",count);
46 }
47
48 void process_usage(void){
49   fprintf(stderr,
50           "usage: vqcascade <codebook>.vqh datafile.vqd [datafile.vqd]...\n\n"
51           "       data can be taken on stdin.  residual error data sent to\n"
52           "       stdout.\n\n");
53
54 }