1 /********************************************************************
2  *                                                                  *
3  * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE.   *
4  *                                                                  *
5  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
6  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
8  *                                                                  *
9  * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002    *
10  * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
11  *                                                                  *
12  ********************************************************************
13 
14  function: backend and mapping structures
15 
16  ********************************************************************/
17 
18 /* this is exposed up here because we need it for static modes.
19    Lookups for each backend aren't exposed because there's no reason
20    to do so */
21 
22 #ifndef _vorbis_backend_h_
23 #define _vorbis_backend_h_
24 
25 #include "codec_internal.h"
26 
27 /* this would all be simpler/shorter with templates, but.... */
28 /* Transform backend generic *************************************/
29 
30 /* only mdct right now.  Flesh it out more if we ever transcend mdct
31    in the transform domain */
32 
33 /* Floor backend generic *****************************************/
34 typedef struct{
35   vorbis_info_floor     *(*unpack)(vorbis_info *,oggpack_buffer *);
36   vorbis_look_floor     *(*look)  (vorbis_dsp_state *,vorbis_info_mode *,
37 				   vorbis_info_floor *);
38   void (*free_info) (vorbis_info_floor *);
39   void (*free_look) (vorbis_look_floor *);
40   void *(*inverse1)  (struct vorbis_block *,vorbis_look_floor *);
41   int   (*inverse2)  (struct vorbis_block *,vorbis_look_floor *,
42 		     void *buffer,ogg_int32_t *);
43 } vorbis_func_floor;
44 
45 typedef struct{
46   int   order;
47   long  rate;
48   long  barkmap;
49 
50   int   ampbits;
51   int   ampdB;
52 
53   int   numbooks; /* <= 16 */
54   int   books[16];
55 
56 } vorbis_info_floor0;
57 
58 #define VIF_POSIT 63
59 #define VIF_CLASS 16
60 #define VIF_PARTS 31
61 typedef struct{
62   int   partitions;                /* 0 to 31 */
63   int   partitionclass[VIF_PARTS]; /* 0 to 15 */
64 
65   int   class_dim[VIF_CLASS];        /* 1 to 8 */
66   int   class_subs[VIF_CLASS];       /* 0,1,2,3 (bits: 1<<n poss) */
67   int   class_book[VIF_CLASS];       /* subs ^ dim entries */
68   int   class_subbook[VIF_CLASS][8]; /* [VIF_CLASS][subs] */
69 
70 
71   int   mult;                      /* 1 2 3 or 4 */
72   int   postlist[VIF_POSIT+2];    /* first two implicit */
73 
74 } vorbis_info_floor1;
75 
76 /* Residue backend generic *****************************************/
77 typedef struct{
78   vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
79   vorbis_look_residue *(*look)  (vorbis_dsp_state *,vorbis_info_mode *,
80 				 vorbis_info_residue *);
81   void (*free_info)    (vorbis_info_residue *);
82   void (*free_look)    (vorbis_look_residue *);
83   int  (*inverse)      (struct vorbis_block *,vorbis_look_residue *,
84 			ogg_int32_t **,int *,int);
85 } vorbis_func_residue;
86 
87 typedef struct vorbis_info_residue0{
88 /* block-partitioned VQ coded straight residue */
89   long  begin;
90   long  end;
91 
92   /* first stage (lossless partitioning) */
93   int    grouping;         /* group n vectors per partition */
94   int    partitions;       /* possible codebooks for a partition */
95   int    partvals;         /* partitions ^ groupbook dim */
96   int    groupbook;        /* huffbook for partitioning */
97   int    secondstages[64]; /* expanded out to pointers in lookup */
98   int    booklist[512];    /* list of second stage books */
99 } vorbis_info_residue0;
100 
101 /* Mapping backend generic *****************************************/
102 typedef struct{
103   vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
104   vorbis_look_mapping *(*look)  (vorbis_dsp_state *,vorbis_info_mode *,
105 				 vorbis_info_mapping *);
106   void (*free_info)    (vorbis_info_mapping *);
107   void (*free_look)    (vorbis_look_mapping *);
108   int  (*inverse)      (struct vorbis_block *vb,vorbis_look_mapping *);
109 } vorbis_func_mapping;
110 
111 typedef struct vorbis_info_mapping0{
112   int   submaps;  /* <= 16 */
113   int   chmuxlist[256];   /* up to 256 channels in a Vorbis stream */
114 
115   int   floorsubmap[16];   /* [mux] submap to floors */
116   int   residuesubmap[16]; /* [mux] submap to residue */
117 
118   int   psy[2]; /* by blocktype; impulse/padding for short,
119                    transition/normal for long */
120 
121   int   coupling_steps;
122   int   coupling_mag[256];
123   int   coupling_ang[256];
124 } vorbis_info_mapping0;
125 
126 #endif
127 
128 
129 
130 
131 
132