VirtualBox

source: vbox/trunk/src/libs/libvorbis-1.3.7/lib/codebook.h

Last change on this file was 96468, checked in by vboxsync, 22 months ago

libs/libvorbis-1.3.7: Re-exporting, hopefully this time everything is there. bugref:10275

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

© 2023 Oracle
ContactPrivacy policyTerms of Use