annotate tremor/codebook.h @ 15441:bc4bcea4c813

added x264enc options: direct_pred, log, (no)deblock deblock{alpha,beta}, (no)cabac, qp_{min,max} 1.933: misc corrections and clarifications in x264 options. 1.934: remove x264 option "cabacidc", because the default is always best. 1.935: Online audio switching now supports Matroska too
author kraymer
date Fri, 13 May 2005 20:19:01 +0000
parents 8631a3803289
children cd6b211be811
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
1 /********************************************************************
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
2 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
4 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
5 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
6 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
7 * ALL REDISTRIBUTION RIGHTS RESERVED. *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
8 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
9 ********************************************************************
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
10
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
11 function: basic shared codebook operations
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
12
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
13 ********************************************************************/
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
14
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
15 #ifndef _V_CODEBOOK_H_
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
16 #define _V_CODEBOOK_H_
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
17
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
18 #include "ogg.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
19
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
20 /* This structure encapsulates huffman and VQ style encoding books; it
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
21 doesn't do anything specific to either.
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
22
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
23 valuelist/quantlist are nonNULL (and q_* significant) only if
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
24 there's entry->value mapping to be done.
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
25
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
26 If encode-side mapping must be done (and thus the entry needs to be
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
27 hunted), the auxiliary encode pointer will point to a decision
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
28 tree. This is true of both VQ and huffman, but is mostly useful
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
29 with VQ.
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
30
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
31 */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
32
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
33 typedef struct static_codebook{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
34 long dim; /* codebook dimensions (elements per vector) */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
35 long entries; /* codebook entries */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
36 long *lengthlist; /* codeword lengths in bits */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
37
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
38 /* mapping ***************************************************************/
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
39 int maptype; /* 0=none
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
40 1=implicitly populated values from map column
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
41 2=listed arbitrary values */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
42
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
43 /* The below does a linear, single monotonic sequence mapping. */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
44 long q_min; /* packed 32 bit float; quant value 0 maps to minval */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
45 long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
46 int q_quant; /* bits: 0 < quant <= 16 */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
47 int q_sequencep; /* bitflag */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
48
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
49 long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
50 map == 2: list of dim*entries quantized entry vals
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
51 */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
52 } static_codebook;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
53
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
54 typedef struct codebook{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
55 long dim; /* codebook dimensions (elements per vector) */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
56 long entries; /* codebook entries */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
57 long used_entries; /* populated codebook entries */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
58
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
59 /* the below are ordered by bitreversed codeword and only used
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
60 entries are populated */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
61 int binarypoint;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
62 ogg_int32_t *valuelist; /* list of dim*entries actual entry values */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
63 ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
64
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
65 int *dec_index;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
66 char *dec_codelengths;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
67 ogg_uint32_t *dec_firsttable;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
68 int dec_firsttablen;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
69 int dec_maxlength;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
70
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
71 long q_min; /* packed 32 bit float; quant value 0 maps to minval */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
72 long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
73
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
74 } codebook;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
75
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
76 extern void vorbis_staticbook_clear(static_codebook *b);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
77 extern void vorbis_staticbook_destroy(static_codebook *b);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
78 extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
79
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
80 extern void vorbis_book_clear(codebook *b);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
81 extern long _book_maptype1_quantvals(const static_codebook *b);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
82
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
83 extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
84
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
85 extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
86 extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
87 oggpack_buffer *b,int n,int point);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
88 extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
89 oggpack_buffer *b,int n,int point);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
90 extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
91 oggpack_buffer *b,int n,int point);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
92 extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
93 long off,int ch,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
94 oggpack_buffer *b,int n,int point);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
95
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
96 extern int _ilog(unsigned int v);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
97
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
98
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
99 #endif