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