vrshoot

diff libs/vorbis/codebook.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/vorbis/codebook.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,119 @@
     1.4 +/********************************************************************
     1.5 + *                                                                  *
     1.6 + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
     1.7 + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
     1.8 + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
     1.9 + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
    1.10 + *                                                                  *
    1.11 + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009             *
    1.12 + * by the Xiph.Org Foundation http://www.xiph.org/                  *
    1.13 + *                                                                  *
    1.14 + ********************************************************************
    1.15 +
    1.16 + function: basic shared codebook operations
    1.17 + last mod: $Id: codebook.h 17030 2010-03-25 06:52:55Z xiphmont $
    1.18 +
    1.19 + ********************************************************************/
    1.20 +
    1.21 +#ifndef _V_CODEBOOK_H_
    1.22 +#define _V_CODEBOOK_H_
    1.23 +
    1.24 +#include <ogg/ogg.h>
    1.25 +
    1.26 +/* This structure encapsulates huffman and VQ style encoding books; it
    1.27 +   doesn't do anything specific to either.
    1.28 +
    1.29 +   valuelist/quantlist are nonNULL (and q_* significant) only if
    1.30 +   there's entry->value mapping to be done.
    1.31 +
    1.32 +   If encode-side mapping must be done (and thus the entry needs to be
    1.33 +   hunted), the auxiliary encode pointer will point to a decision
    1.34 +   tree.  This is true of both VQ and huffman, but is mostly useful
    1.35 +   with VQ.
    1.36 +
    1.37 +*/
    1.38 +
    1.39 +typedef struct static_codebook{
    1.40 +  long   dim;            /* codebook dimensions (elements per vector) */
    1.41 +  long   entries;        /* codebook entries */
    1.42 +  long  *lengthlist;     /* codeword lengths in bits */
    1.43 +
    1.44 +  /* mapping ***************************************************************/
    1.45 +  int    maptype;        /* 0=none
    1.46 +                            1=implicitly populated values from map column
    1.47 +                            2=listed arbitrary values */
    1.48 +
    1.49 +  /* The below does a linear, single monotonic sequence mapping. */
    1.50 +  long     q_min;       /* packed 32 bit float; quant value 0 maps to minval */
    1.51 +  long     q_delta;     /* packed 32 bit float; val 1 - val 0 == delta */
    1.52 +  int      q_quant;     /* bits: 0 < quant <= 16 */
    1.53 +  int      q_sequencep; /* bitflag */
    1.54 +
    1.55 +  long     *quantlist;  /* map == 1: (int)(entries^(1/dim)) element column map
    1.56 +                           map == 2: list of dim*entries quantized entry vals
    1.57 +                        */
    1.58 +  int allocedp;
    1.59 +} static_codebook;
    1.60 +
    1.61 +typedef struct codebook{
    1.62 +  long dim;           /* codebook dimensions (elements per vector) */
    1.63 +  long entries;       /* codebook entries */
    1.64 +  long used_entries;  /* populated codebook entries */
    1.65 +  const static_codebook *c;
    1.66 +
    1.67 +  /* for encode, the below are entry-ordered, fully populated */
    1.68 +  /* for decode, the below are ordered by bitreversed codeword and only
    1.69 +     used entries are populated */
    1.70 +  float        *valuelist;  /* list of dim*entries actual entry values */
    1.71 +  ogg_uint32_t *codelist;   /* list of bitstream codewords for each entry */
    1.72 +
    1.73 +  int          *dec_index;  /* only used if sparseness collapsed */
    1.74 +  char         *dec_codelengths;
    1.75 +  ogg_uint32_t *dec_firsttable;
    1.76 +  int           dec_firsttablen;
    1.77 +  int           dec_maxlength;
    1.78 +
    1.79 +  /* The current encoder uses only centered, integer-only lattice books. */
    1.80 +  int           quantvals;
    1.81 +  int           minval;
    1.82 +  int           delta;
    1.83 +} codebook;
    1.84 +
    1.85 +extern void vorbis_staticbook_destroy(static_codebook *b);
    1.86 +extern int vorbis_book_init_encode(codebook *dest,const static_codebook *source);
    1.87 +extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
    1.88 +extern void vorbis_book_clear(codebook *b);
    1.89 +
    1.90 +extern float *_book_unquantize(const static_codebook *b,int n,int *map);
    1.91 +extern float *_book_logdist(const static_codebook *b,float *vals);
    1.92 +extern float _float32_unpack(long val);
    1.93 +extern long   _float32_pack(float val);
    1.94 +extern int  _best(codebook *book, float *a, int step);
    1.95 +extern int _ilog(unsigned int v);
    1.96 +extern long _book_maptype1_quantvals(const static_codebook *b);
    1.97 +
    1.98 +extern int vorbis_book_besterror(codebook *book,float *a,int step,int addmul);
    1.99 +extern long vorbis_book_codeword(codebook *book,int entry);
   1.100 +extern long vorbis_book_codelen(codebook *book,int entry);
   1.101 +
   1.102 +
   1.103 +
   1.104 +extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b);
   1.105 +extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b);
   1.106 +
   1.107 +extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b);
   1.108 +
   1.109 +extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
   1.110 +extern long vorbis_book_decodevs_add(codebook *book, float *a,
   1.111 +                                     oggpack_buffer *b,int n);
   1.112 +extern long vorbis_book_decodev_set(codebook *book, float *a,
   1.113 +                                    oggpack_buffer *b,int n);
   1.114 +extern long vorbis_book_decodev_add(codebook *book, float *a,
   1.115 +                                    oggpack_buffer *b,int n);
   1.116 +extern long vorbis_book_decodevv_add(codebook *book, float **a,
   1.117 +                                     long off,int ch,
   1.118 +                                    oggpack_buffer *b,int n);
   1.119 +
   1.120 +
   1.121 +
   1.122 +#endif