Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/libvorbis-1.2.0/vq/cascade.c @ 29

Last change on this file since 29 was 16, checked in by landauf, 17 years ago

added libvorbis

File size: 2.4 KB
RevLine 
[16]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 ********************************************************************
12
13 function: function call to do simple data cascading
14 last mod: $Id: cascade.c 13293 2007-07-24 00:09:47Z xiphmont $
15
16 ********************************************************************/
17
18/* this one outputs residue to stdout. */
19
20#include <stdlib.h>
21#include <unistd.h>
22#include <math.h>
23#include "bookutil.h"
24
25/* set up metrics */
26
27float count=0.f;
28
29
30void process_preprocess(codebook **bs,char *basename){
31}
32
33void process_postprocess(codebook **b,char *basename){
34  fprintf(stderr,"Done.                      \n");
35}
36
37float process_one(codebook *b,float *a,int dim,int step,int addmul,
38                   float base){
39  int j;
40
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;
46    }
47    base=temp;
48  }
49
50  vorbis_book_besterror(b,a,step,addmul);
51 
52  return base;
53}
54
55void process_vector(codebook **bs,int *addmul,int inter,float *a,int n){
56  int i,bi=0;
57  int booknum=0;
58 
59  while(*bs){
60    float base=0.f;
61    codebook *b=*bs;
62    int dim=b->dim;
63   
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);
70    }
71
72    bs++;
73    booknum++;
74    bi++;
75  }
76
77  for(i=0;i<n;i++)
78    fprintf(stdout,"%f, ",a[i]);
79  fprintf(stdout,"\n");
80 
81  if((long)(count++)%100)spinnit("working.... lines: ",count);
82}
83
84void 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");
90
91}
Note: See TracBrowser for help on using the repository browser.