|
Packit |
06404a |
/********************************************************************
|
|
Packit |
06404a |
* *
|
|
Packit |
06404a |
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
|
Packit |
06404a |
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
|
Packit |
06404a |
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
|
Packit |
06404a |
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
|
Packit |
06404a |
* *
|
|
Packit |
06404a |
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 *
|
|
Packit |
06404a |
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
|
Packit |
06404a |
* *
|
|
Packit |
06404a |
********************************************************************
|
|
Packit |
06404a |
|
|
Packit |
06404a |
function: basic shared codebook operations
|
|
Packit |
06404a |
last mod: $Id: codebook.h 19457 2015-03-03 00:15:29Z giles $
|
|
Packit |
06404a |
|
|
Packit |
06404a |
********************************************************************/
|
|
Packit |
06404a |
|
|
Packit |
06404a |
#ifndef _V_CODEBOOK_H_
|
|
Packit |
06404a |
#define _V_CODEBOOK_H_
|
|
Packit |
06404a |
|
|
Packit |
06404a |
#include <ogg/ogg.h>
|
|
Packit |
06404a |
|
|
Packit |
06404a |
/* This structure encapsulates huffman and VQ style encoding books; it
|
|
Packit |
06404a |
doesn't do anything specific to either.
|
|
Packit |
06404a |
|
|
Packit |
06404a |
valuelist/quantlist are nonNULL (and q_* significant) only if
|
|
Packit |
06404a |
there's entry->value mapping to be done.
|
|
Packit |
06404a |
|
|
Packit |
06404a |
If encode-side mapping must be done (and thus the entry needs to be
|
|
Packit |
06404a |
hunted), the auxiliary encode pointer will point to a decision
|
|
Packit |
06404a |
tree. This is true of both VQ and huffman, but is mostly useful
|
|
Packit |
06404a |
with VQ.
|
|
Packit |
06404a |
|
|
Packit |
06404a |
*/
|
|
Packit |
06404a |
|
|
Packit |
06404a |
typedef struct static_codebook{
|
|
Packit |
06404a |
long dim; /* codebook dimensions (elements per vector) */
|
|
Packit |
06404a |
long entries; /* codebook entries */
|
|
Packit |
06404a |
char *lengthlist; /* codeword lengths in bits */
|
|
Packit |
06404a |
|
|
Packit |
06404a |
/* mapping ***************************************************************/
|
|
Packit |
06404a |
int maptype; /* 0=none
|
|
Packit |
06404a |
1=implicitly populated values from map column
|
|
Packit |
06404a |
2=listed arbitrary values */
|
|
Packit |
06404a |
|
|
Packit |
06404a |
/* The below does a linear, single monotonic sequence mapping. */
|
|
Packit |
06404a |
long q_min; /* packed 32 bit float; quant value 0 maps to minval */
|
|
Packit |
06404a |
long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */
|
|
Packit |
06404a |
int q_quant; /* bits: 0 < quant <= 16 */
|
|
Packit |
06404a |
int q_sequencep; /* bitflag */
|
|
Packit |
06404a |
|
|
Packit |
06404a |
long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
|
|
Packit |
06404a |
map == 2: list of dim*entries quantized entry vals
|
|
Packit |
06404a |
*/
|
|
Packit |
06404a |
int allocedp;
|
|
Packit |
06404a |
} static_codebook;
|
|
Packit |
06404a |
|
|
Packit |
06404a |
typedef struct codebook{
|
|
Packit |
06404a |
long dim; /* codebook dimensions (elements per vector) */
|
|
Packit |
06404a |
long entries; /* codebook entries */
|
|
Packit |
06404a |
long used_entries; /* populated codebook entries */
|
|
Packit |
06404a |
const static_codebook *c;
|
|
Packit |
06404a |
|
|
Packit |
06404a |
/* for encode, the below are entry-ordered, fully populated */
|
|
Packit |
06404a |
/* for decode, the below are ordered by bitreversed codeword and only
|
|
Packit |
06404a |
used entries are populated */
|
|
Packit |
06404a |
float *valuelist; /* list of dim*entries actual entry values */
|
|
Packit |
06404a |
ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */
|
|
Packit |
06404a |
|
|
Packit |
06404a |
int *dec_index; /* only used if sparseness collapsed */
|
|
Packit |
06404a |
char *dec_codelengths;
|
|
Packit |
06404a |
ogg_uint32_t *dec_firsttable;
|
|
Packit |
06404a |
int dec_firsttablen;
|
|
Packit |
06404a |
int dec_maxlength;
|
|
Packit |
06404a |
|
|
Packit |
06404a |
/* The current encoder uses only centered, integer-only lattice books. */
|
|
Packit |
06404a |
int quantvals;
|
|
Packit |
06404a |
int minval;
|
|
Packit |
06404a |
int delta;
|
|
Packit |
06404a |
} codebook;
|
|
Packit |
06404a |
|
|
Packit |
06404a |
extern void vorbis_staticbook_destroy(static_codebook *b);
|
|
Packit |
06404a |
extern int vorbis_book_init_encode(codebook *dest,const static_codebook *source);
|
|
Packit |
06404a |
extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
|
|
Packit |
06404a |
extern void vorbis_book_clear(codebook *b);
|
|
Packit |
06404a |
|
|
Packit |
06404a |
extern float *_book_unquantize(const static_codebook *b,int n,int *map);
|
|
Packit |
06404a |
extern float *_book_logdist(const static_codebook *b,float *vals);
|
|
Packit |
06404a |
extern float _float32_unpack(long val);
|
|
Packit |
06404a |
extern long _float32_pack(float val);
|
|
Packit |
06404a |
extern int _best(codebook *book, float *a, int step);
|
|
Packit |
06404a |
extern long _book_maptype1_quantvals(const static_codebook *b);
|
|
Packit |
06404a |
|
|
Packit |
06404a |
extern int vorbis_book_besterror(codebook *book,float *a,int step,int addmul);
|
|
Packit |
06404a |
extern long vorbis_book_codeword(codebook *book,int entry);
|
|
Packit |
06404a |
extern long vorbis_book_codelen(codebook *book,int entry);
|
|
Packit |
06404a |
|
|
Packit |
06404a |
|
|
Packit |
06404a |
|
|
Packit |
06404a |
extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b);
|
|
Packit |
06404a |
extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b);
|
|
Packit |
06404a |
|
|
Packit |
06404a |
extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b);
|
|
Packit |
06404a |
|
|
Packit |
06404a |
extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
|
|
Packit |
06404a |
extern long vorbis_book_decodevs_add(codebook *book, float *a,
|
|
Packit |
06404a |
oggpack_buffer *b,int n);
|
|
Packit |
06404a |
extern long vorbis_book_decodev_set(codebook *book, float *a,
|
|
Packit |
06404a |
oggpack_buffer *b,int n);
|
|
Packit |
06404a |
extern long vorbis_book_decodev_add(codebook *book, float *a,
|
|
Packit |
06404a |
oggpack_buffer *b,int n);
|
|
Packit |
06404a |
extern long vorbis_book_decodevv_add(codebook *book, float **a,
|
|
Packit |
06404a |
long off,int ch,
|
|
Packit |
06404a |
oggpack_buffer *b,int n);
|
|
Packit |
06404a |
|
|
Packit |
06404a |
|
|
Packit |
06404a |
|
|
Packit |
06404a |
#endif
|