Merge branch_beta3 onto the mainline.
[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 SOURCE IS GOVERNED BY *
5  * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH    *
6  * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.        *
7  *                                                                  *
8  * THE OggVorbis 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: generic euclidian distance metric for VQ codebooks
15  last mod: $Id: genericdata.c,v 1.7 2000/11/06 00:07:25 xiphmont Exp $
16
17  ********************************************************************/
18
19 #include <stdlib.h>
20 #include <math.h>
21 #include <stdio.h>
22 #include "vqgen.h"
23 #include "vqext.h"
24
25 char *vqext_booktype="GENERICdata";  
26 int vqext_aux=0;                
27 quant_meta q={0,0,0,0};          /* non sequence data; each scalar 
28                                     independent */
29
30 void vqext_quantize(vqgen *v,quant_meta *q){
31   vqgen_quantize(v,q);
32 }
33
34 float *vqext_weight(vqgen *v,float *p){
35   /*noop*/
36   return(p);
37 }
38
39                             /* candidate,actual */
40 float vqext_metric(vqgen *v,float *e, float *p){
41   int i;
42   float acc=0.;
43   for(i=0;i<v->elements;i++){
44     float val=p[i]-e[i];
45     acc+=val*val;
46   }
47   return sqrt(acc/v->elements);
48 }
49
50 void vqext_addpoint_adj(vqgen *v,float *b,int start,int dim,int cols,int num){
51   vqgen_addpoint(v,b+start,NULL);
52 }
53
54 void vqext_preprocess(vqgen *v){
55   /* noop */
56 }
57
58
59
60
61
62