dbf-halloween2015

annotate libs/vorbis/codebook.h @ 1:c3f5c32cb210

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