Additional optimizations, rearrangement.
[platform/upstream/libvorbis.git] / vq / genericdata.c
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 XIPHOPHORUS Company http://www.xiph.org/                  *
10
11  ********************************************************************
12
13  function: generic euclidian distance metric for VQ codebooks
14  last mod: $Id: genericdata.c,v 1.10 2001/02/26 03:51:12 xiphmont Exp $
15
16  ********************************************************************/
17
18 #include <stdlib.h>
19 #include <math.h>
20 #include <stdio.h>
21 #include "vqgen.h"
22 #include "vqext.h"
23
24 char *vqext_booktype="GENERICdata";  
25 int vqext_aux=0;                
26 quant_meta q={0,0,0,0};          /* non sequence data; each scalar 
27                                     independent */
28
29 void vqext_quantize(vqgen *v,quant_meta *q){
30   vqgen_quantize(v,q);
31 }
32
33 float *vqext_weight(vqgen *v,float *p){
34   /*noop*/
35   return(p);
36 }
37
38                             /* candidate,actual */
39 float vqext_metric(vqgen *v,float *e, float *p){
40   int i;
41   float acc=0.f;
42   for(i=0;i<v->elements;i++){
43     float val=p[i]-e[i];
44     acc+=val*val;
45   }
46   return sqrt(acc/v->elements);
47 }
48
49 void vqext_addpoint_adj(vqgen *v,float *b,int start,int dim,int cols,int num){
50   vqgen_addpoint(v,b+start,NULL);
51 }
52
53 void vqext_preprocess(vqgen *v){
54   /* noop */
55 }
56
57
58
59
60
61