vrshoot

annotate libs/vorbis/codebook.h @ 2:334d17aed7de

visual studio project files
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 02 Feb 2014 18:36:38 +0200
parents
children
rev   line source
nuclear@0 1 /********************************************************************
nuclear@0 2 * *
nuclear@0 3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
nuclear@0 4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
nuclear@0 5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
nuclear@0 6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
nuclear@0 7 * *
nuclear@0 8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
nuclear@0 9 * by the Xiph.Org Foundation http://www.xiph.org/ *
nuclear@0 10 * *
nuclear@0 11 ********************************************************************
nuclear@0 12
nuclear@0 13 function: basic shared codebook operations
nuclear@0 14 last mod: $Id: codebook.h 17030 2010-03-25 06:52:55Z xiphmont $
nuclear@0 15
nuclear@0 16 ********************************************************************/
nuclear@0 17
nuclear@0 18 #ifndef _V_CODEBOOK_H_
nuclear@0 19 #define _V_CODEBOOK_H_
nuclear@0 20
nuclear@0 21 #include <ogg/ogg.h>
nuclear@0 22
nuclear@0 23 /* This structure encapsulates huffman and VQ style encoding books; it
nuclear@0 24 doesn't do anything specific to either.
nuclear@0 25
nuclear@0 26 valuelist/quantlist are nonNULL (and q_* significant) only if
nuclear@0 27 there's entry->value mapping to be done.
nuclear@0 28
nuclear@0 29 If encode-side mapping must be done (and thus the entry needs to be
nuclear@0 30 hunted), the auxiliary encode pointer will point to a decision
nuclear@0 31 tree. This is true of both VQ and huffman, but is mostly useful
nuclear@0 32 with VQ.
nuclear@0 33
nuclear@0 34 */
nuclear@0 35
nuclear@0 36 typedef struct static_codebook{
nuclear@0 37 long dim; /* codebook dimensions (elements per vector) */
nuclear@0 38 long entries; /* codebook entries */
nuclear@0 39 long *lengthlist; /* codeword lengths in bits */
nuclear@0 40
nuclear@0 41 /* mapping ***************************************************************/
nuclear@0 42 int maptype; /* 0=none
nuclear@0 43 1=implicitly populated values from map column
nuclear@0 44 2=listed arbitrary values */
nuclear@0 45
nuclear@0 46 /* The below does a linear, single monotonic sequence mapping. */
nuclear@0 47 long q_min; /* packed 32 bit float; quant value 0 maps to minval */
nuclear@0 48 long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */
nuclear@0 49 int q_quant; /* bits: 0 < quant <= 16 */
nuclear@0 50 int q_sequencep; /* bitflag */
nuclear@0 51
nuclear@0 52 long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
nuclear@0 53 map == 2: list of dim*entries quantized entry vals
nuclear@0 54 */
nuclear@0 55 int allocedp;
nuclear@0 56 } static_codebook;
nuclear@0 57
nuclear@0 58 typedef struct codebook{
nuclear@0 59 long dim; /* codebook dimensions (elements per vector) */
nuclear@0 60 long entries; /* codebook entries */
nuclear@0 61 long used_entries; /* populated codebook entries */
nuclear@0 62 const static_codebook *c;
nuclear@0 63
nuclear@0 64 /* for encode, the below are entry-ordered, fully populated */
nuclear@0 65 /* for decode, the below are ordered by bitreversed codeword and only
nuclear@0 66 used entries are populated */
nuclear@0 67 float *valuelist; /* list of dim*entries actual entry values */
nuclear@0 68 ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */
nuclear@0 69
nuclear@0 70 int *dec_index; /* only used if sparseness collapsed */
nuclear@0 71 char *dec_codelengths;
nuclear@0 72 ogg_uint32_t *dec_firsttable;
nuclear@0 73 int dec_firsttablen;
nuclear@0 74 int dec_maxlength;
nuclear@0 75
nuclear@0 76 /* The current encoder uses only centered, integer-only lattice books. */
nuclear@0 77 int quantvals;
nuclear@0 78 int minval;
nuclear@0 79 int delta;
nuclear@0 80 } codebook;
nuclear@0 81
nuclear@0 82 extern void vorbis_staticbook_destroy(static_codebook *b);
nuclear@0 83 extern int vorbis_book_init_encode(codebook *dest,const static_codebook *source);
nuclear@0 84 extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
nuclear@0 85 extern void vorbis_book_clear(codebook *b);
nuclear@0 86
nuclear@0 87 extern float *_book_unquantize(const static_codebook *b,int n,int *map);
nuclear@0 88 extern float *_book_logdist(const static_codebook *b,float *vals);
nuclear@0 89 extern float _float32_unpack(long val);
nuclear@0 90 extern long _float32_pack(float val);
nuclear@0 91 extern int _best(codebook *book, float *a, int step);
nuclear@0 92 extern int _ilog(unsigned int v);
nuclear@0 93 extern long _book_maptype1_quantvals(const static_codebook *b);
nuclear@0 94
nuclear@0 95 extern int vorbis_book_besterror(codebook *book,float *a,int step,int addmul);
nuclear@0 96 extern long vorbis_book_codeword(codebook *book,int entry);
nuclear@0 97 extern long vorbis_book_codelen(codebook *book,int entry);
nuclear@0 98
nuclear@0 99
nuclear@0 100
nuclear@0 101 extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b);
nuclear@0 102 extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b);
nuclear@0 103
nuclear@0 104 extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b);
nuclear@0 105
nuclear@0 106 extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
nuclear@0 107 extern long vorbis_book_decodevs_add(codebook *book, float *a,
nuclear@0 108 oggpack_buffer *b,int n);
nuclear@0 109 extern long vorbis_book_decodev_set(codebook *book, float *a,
nuclear@0 110 oggpack_buffer *b,int n);
nuclear@0 111 extern long vorbis_book_decodev_add(codebook *book, float *a,
nuclear@0 112 oggpack_buffer *b,int n);
nuclear@0 113 extern long vorbis_book_decodevv_add(codebook *book, float **a,
nuclear@0 114 long off,int ch,
nuclear@0 115 oggpack_buffer *b,int n);
nuclear@0 116
nuclear@0 117
nuclear@0 118
nuclear@0 119 #endif