Floor 1
[platform/upstream/libvorbis.git] / lib / backends.h
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-2001             *
9  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
10
11  ********************************************************************
12
13  function: libvorbis backend and mapping structures; needed for 
14            static mode headers
15  last mod: $Id: backends.h,v 1.7 2001/05/27 06:43:59 xiphmont Exp $
16
17  ********************************************************************/
18
19 /* this is exposed up here because we need it for static modes.
20    Lookups for each backend aren't exposed because there's no reason
21    to do so */
22
23 #ifndef _vorbis_backend_h_
24 #define _vorbis_backend_h_
25
26 #include "codec_internal.h"
27
28 /* this would all be simpler/shorter with templates, but.... */
29 /* Transform backend generic *************************************/
30
31 /* only mdct right now.  Flesh it out more if we ever transcend mdct
32    in the transform domain */
33
34 /* Time backend generic ******************************************/
35 typedef struct{
36   void              (*pack)  (vorbis_info_time *,oggpack_buffer *);
37   vorbis_info_time *(*unpack)(vorbis_info *,oggpack_buffer *);
38   vorbis_look_time *(*look)  (vorbis_dsp_state *,vorbis_info_mode *,
39                               vorbis_info_time *);
40   vorbis_info_time *(*copy_info)(vorbis_info_time *);
41
42   void (*free_info) (vorbis_info_time *);
43   void (*free_look) (vorbis_look_time *);
44   int  (*forward)   (struct vorbis_block *,vorbis_look_time *,
45                      float *,float *);
46   int  (*inverse)   (struct vorbis_block *,vorbis_look_time *,
47                      float *,float *);
48 } vorbis_func_time;
49
50 typedef struct{
51   int dummy;
52 } vorbis_info_time0;
53
54 /* Floor backend generic *****************************************/
55 typedef struct{
56   void                   (*pack)  (vorbis_info_floor *,oggpack_buffer *);
57   vorbis_info_floor     *(*unpack)(vorbis_info *,oggpack_buffer *);
58   vorbis_look_floor     *(*look)  (vorbis_dsp_state *,vorbis_info_mode *,
59                                    vorbis_info_floor *);
60   vorbis_info_floor     *(*copy_info)(vorbis_info_floor *);
61   void (*free_info) (vorbis_info_floor *);
62   void (*free_look) (vorbis_look_floor *);
63   int  (*forward)   (struct vorbis_block *,vorbis_look_floor *,
64                      const float *, const float *, /* in */
65                      const float *, const float *, /* in */
66                      float *, float *);            /* out */
67   int  (*inverse)   (struct vorbis_block *,vorbis_look_floor *,
68                      float *);
69 } vorbis_func_floor;
70
71 typedef struct{
72   int   order;
73   long  rate;
74   long  barkmap;
75
76   int   ampbits;
77   int   ampdB;
78
79   int   numbooks; /* <= 16 */
80   int   books[16];
81
82   float lessthan;     /* encode-only config setting hacks for libvorbis */
83   float greaterthan;  /* encode-only config setting hacks for libvorbis */
84
85 } vorbis_info_floor0;
86
87 #define VIF_POSIT 63
88 #define VIF_CLASS 16
89 #define VIF_PARTS 31
90 typedef struct{
91   int   partitions;                /* 0 to 31 */
92   int   partitionclass[VIF_PARTS]; /* 0 to 15 */
93
94   int   class_dim[VIF_CLASS];        /* 1 to 8 */
95   int   class_subs[VIF_CLASS];       /* 0,1,2,3 (bits: 1<<n poss) */
96   int   class_book[VIF_CLASS];       /* subs ^ dim entries */
97   int   class_subbook[VIF_CLASS][8]; /* [VIF_CLASS][subs] */
98
99
100   int   mult;                      /* 1 2 3 or 4 */ 
101   int   postlist[VIF_POSIT+2];    /* first two implicit */ 
102
103
104   /* encode side analysis parameters */
105   float maxover;     
106   float maxunder;  
107   float maxerr;    
108
109   int   twofitminsize;
110   int   twofitminused;
111   int   twofitweight;  
112   float twofitatten;
113   int   unusedminsize;
114   int   unusedmin_n;
115
116 } vorbis_info_floor1;
117
118 /* Residue backend generic *****************************************/
119 typedef struct{
120   void                 (*pack)  (vorbis_info_residue *,oggpack_buffer *);
121   vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
122   vorbis_look_residue *(*look)  (vorbis_dsp_state *,vorbis_info_mode *,
123                                  vorbis_info_residue *);
124   vorbis_info_residue *(*copy_info)(vorbis_info_residue *);
125   void (*free_info)    (vorbis_info_residue *);
126   void (*free_look)    (vorbis_look_residue *);
127   int  (*forward)      (struct vorbis_block *,vorbis_look_residue *,
128                         float **,int);
129   int  (*inverse)      (struct vorbis_block *,vorbis_look_residue *,
130                         float **,int);
131 } vorbis_func_residue;
132
133 typedef struct vorbis_info_residue0{
134 /* block-partitioned VQ coded straight residue */
135   long  begin;
136   long  end;
137
138   /* first stage (lossless partitioning) */
139   int    grouping;         /* group n vectors per partition */
140   int    partitions;       /* possible codebooks for a partition */
141   int    groupbook;        /* huffbook for partitioning */
142   int    secondstages[64]; /* expanded out to pointers in lookup */
143   int    booklist[256];    /* list of second stage books */
144
145   /* encode-only heuristic settings */
146   float  entmax[64];       /* book entropy threshholds*/
147   float  ampmax[64];       /* book amp threshholds*/
148   int    subgrp[64];       /* book heuristic subgroup size */
149   int    blimit[64];       /* subgroup position limits */
150
151 } vorbis_info_residue0;
152
153 /* Mapping backend generic *****************************************/
154 typedef struct{
155   void                 (*pack)  (vorbis_info *,vorbis_info_mapping *,
156                                  oggpack_buffer *);
157   vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
158   vorbis_look_mapping *(*look)  (vorbis_dsp_state *,vorbis_info_mode *,
159                                  vorbis_info_mapping *);
160   vorbis_info_mapping *(*copy_info)(vorbis_info_mapping *);
161   void (*free_info)    (vorbis_info_mapping *);
162   void (*free_look)    (vorbis_look_mapping *);
163   int  (*forward)      (struct vorbis_block *vb,vorbis_look_mapping *);
164   int  (*inverse)      (struct vorbis_block *vb,vorbis_look_mapping *);
165 } vorbis_func_mapping;
166
167 typedef struct vorbis_info_mapping0{
168   int   submaps;  /* <= 16 */
169   int   chmuxlist[256];   /* up to 256 channels in a Vorbis stream */
170   
171   int   timesubmap[16];    /* [mux] */
172   int   floorsubmap[16];   /* [mux] submap to floors */
173   int   residuesubmap[16]; /* [mux] submap to residue */
174   int   psysubmap[16];     /* [mux]; encode only */
175 } vorbis_info_mapping0;
176
177 #endif
178
179
180
181
182