Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /******************************************************************** |
michael@0 | 2 | * * |
michael@0 | 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * |
michael@0 | 4 | * * |
michael@0 | 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
michael@0 | 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
michael@0 | 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
michael@0 | 8 | * * |
michael@0 | 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * |
michael@0 | 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * |
michael@0 | 11 | * * |
michael@0 | 12 | ******************************************************************** |
michael@0 | 13 | |
michael@0 | 14 | function: basic shared codebook operations |
michael@0 | 15 | |
michael@0 | 16 | ********************************************************************/ |
michael@0 | 17 | |
michael@0 | 18 | #ifndef _V_CODEBOOK_H_ |
michael@0 | 19 | #define _V_CODEBOOK_H_ |
michael@0 | 20 | |
michael@0 | 21 | #include <ogg/ogg.h> |
michael@0 | 22 | |
michael@0 | 23 | /* This structure encapsulates huffman and VQ style encoding books; it |
michael@0 | 24 | doesn't do anything specific to either. |
michael@0 | 25 | |
michael@0 | 26 | valuelist/quantlist are nonNULL (and q_* significant) only if |
michael@0 | 27 | there's entry->value mapping to be done. |
michael@0 | 28 | |
michael@0 | 29 | If encode-side mapping must be done (and thus the entry needs to be |
michael@0 | 30 | hunted), the auxiliary encode pointer will point to a decision |
michael@0 | 31 | tree. This is true of both VQ and huffman, but is mostly useful |
michael@0 | 32 | with VQ. |
michael@0 | 33 | |
michael@0 | 34 | */ |
michael@0 | 35 | |
michael@0 | 36 | typedef struct static_codebook{ |
michael@0 | 37 | long dim; /* codebook dimensions (elements per vector) */ |
michael@0 | 38 | long entries; /* codebook entries */ |
michael@0 | 39 | long *lengthlist; /* codeword lengths in bits */ |
michael@0 | 40 | |
michael@0 | 41 | /* mapping ***************************************************************/ |
michael@0 | 42 | int maptype; /* 0=none |
michael@0 | 43 | 1=implicitly populated values from map column |
michael@0 | 44 | 2=listed arbitrary values */ |
michael@0 | 45 | |
michael@0 | 46 | /* The below does a linear, single monotonic sequence mapping. */ |
michael@0 | 47 | long q_min; /* packed 32 bit float; quant value 0 maps to minval */ |
michael@0 | 48 | long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ |
michael@0 | 49 | int q_quant; /* bits: 0 < quant <= 16 */ |
michael@0 | 50 | int q_sequencep; /* bitflag */ |
michael@0 | 51 | |
michael@0 | 52 | long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map |
michael@0 | 53 | map == 2: list of dim*entries quantized entry vals |
michael@0 | 54 | */ |
michael@0 | 55 | } static_codebook; |
michael@0 | 56 | |
michael@0 | 57 | typedef struct codebook{ |
michael@0 | 58 | long dim; /* codebook dimensions (elements per vector) */ |
michael@0 | 59 | long entries; /* codebook entries */ |
michael@0 | 60 | long used_entries; /* populated codebook entries */ |
michael@0 | 61 | |
michael@0 | 62 | /* the below are ordered by bitreversed codeword and only used |
michael@0 | 63 | entries are populated */ |
michael@0 | 64 | int binarypoint; |
michael@0 | 65 | ogg_int32_t *valuelist; /* list of dim*entries actual entry values */ |
michael@0 | 66 | ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */ |
michael@0 | 67 | |
michael@0 | 68 | int *dec_index; |
michael@0 | 69 | char *dec_codelengths; |
michael@0 | 70 | ogg_uint32_t *dec_firsttable; |
michael@0 | 71 | int dec_firsttablen; |
michael@0 | 72 | int dec_maxlength; |
michael@0 | 73 | |
michael@0 | 74 | long q_min; /* packed 32 bit float; quant value 0 maps to minval */ |
michael@0 | 75 | long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ |
michael@0 | 76 | |
michael@0 | 77 | } codebook; |
michael@0 | 78 | |
michael@0 | 79 | extern void vorbis_staticbook_destroy(static_codebook *b); |
michael@0 | 80 | extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source); |
michael@0 | 81 | |
michael@0 | 82 | extern void vorbis_book_clear(codebook *b); |
michael@0 | 83 | extern long _book_maptype1_quantvals(const static_codebook *b); |
michael@0 | 84 | |
michael@0 | 85 | extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b); |
michael@0 | 86 | |
michael@0 | 87 | extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); |
michael@0 | 88 | extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a, |
michael@0 | 89 | oggpack_buffer *b,int n,int point); |
michael@0 | 90 | extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a, |
michael@0 | 91 | oggpack_buffer *b,int n,int point); |
michael@0 | 92 | extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a, |
michael@0 | 93 | oggpack_buffer *b,int n,int point); |
michael@0 | 94 | extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a, |
michael@0 | 95 | long off,int ch, |
michael@0 | 96 | oggpack_buffer *b,int n,int point); |
michael@0 | 97 | |
michael@0 | 98 | extern int _ilog(unsigned int v); |
michael@0 | 99 | |
michael@0 | 100 | |
michael@0 | 101 | #endif |