add window function memory reduction
[platform/upstream/libvorbis.git] / lib / codec_internal.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-2002             *
9  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
10  *                                                                  *
11  ********************************************************************
12
13  function: libvorbis codec headers
14  last mod: $Id: codec_internal.h,v 1.14 2002/01/22 11:59:00 xiphmont Exp $
15
16  ********************************************************************/
17
18 #ifndef _V_CODECI_H_
19 #define _V_CODECI_H_
20
21 #include "envelope.h"
22 #include "codebook.h"
23
24 #define BLOCKTYPE_IMPULSE    0
25 #define BLOCKTYPE_PADDING    1
26 #define BLOCKTYPE_TRANSITION 0 
27 #define BLOCKTYPE_LONG       1
28
29 typedef struct vorbis_block_internal{
30   float  **pcmdelay;  /* this is a pointer into local storage */ 
31   float  ampmax;
32   int    blocktype;
33
34   ogg_uint32_t *packet_markers;
35 } vorbis_block_internal;
36
37 typedef void vorbis_look_time;
38 typedef void vorbis_look_mapping;
39 typedef void vorbis_look_floor;
40 typedef void vorbis_look_residue;
41 typedef void vorbis_look_transform;
42
43 /* mode ************************************************************/
44 typedef struct {
45   int blockflag;
46   int windowtype;
47   int transformtype;
48   int mapping;
49 } vorbis_info_mode;
50
51 typedef void vorbis_info_time;
52 typedef void vorbis_info_floor;
53 typedef void vorbis_info_residue;
54 typedef void vorbis_info_mapping;
55
56 #include "psy.h"
57 #include "bitrate.h"
58
59 typedef struct backend_lookup_state {
60   /* local lookup storage */
61   envelope_lookup        *ve; /* envelope lookup */    
62   float                  *window[2];
63   vorbis_look_transform **transform[2];    /* block, type */
64   vorbis_look_psy_global *psy_g_look;
65
66   /* backend lookups are tied to the mode, not the backend or naked mapping */
67   int                     modebits;
68   vorbis_look_mapping   **mode;
69
70   /* local storage, only used on the encoding side.  This way the
71      application does not need to worry about freeing some packets'
72      memory and not others'; packet storage is always tracked.
73      Cleared next call to a _dsp_ function */
74   unsigned char *header;
75   unsigned char *header1;
76   unsigned char *header2;
77
78   bitrate_manager_state bms;
79
80 } backend_lookup_state;
81
82 /* high level configuration information for setting things up
83    step-by-step with the detaile vorbis_encode_ctl interface */
84
85 typedef struct highlevel_block {
86   double tone_mask_quality;
87   double tone_peaklimit_quality;
88
89   double noise_bias_quality;
90   double noise_compand_quality;
91
92   double ath_quality;
93
94 } highlevel_block;
95
96 typedef struct highlevel_encode_setup {
97   double base_quality;       /* these have to be tracked by the ctl */
98   double base_quality_short; /* interface so that the right books get */
99   double base_quality_long;  /* chosen... */
100
101   int short_block_p;
102   int long_block_p;
103   int impulse_block_p;
104
105   int stereo_couple_p;
106   int stereo_backfill_p;
107   int residue_backfill_p;
108
109   int    stereo_point_dB;
110   double stereo_point_kHz[2];
111   double lowpass_kHz[2];
112
113   double ath_floating_dB;
114   double ath_absolute_dB;
115
116   double amplitude_track_dBpersec;
117   double trigger_quality;
118
119   highlevel_block blocktype[4]; /* impulse, padding, trans, long */
120   
121 } highlevel_encode_setup;
122
123 /* codec_setup_info contains all the setup information specific to the
124    specific compression/decompression mode in progress (eg,
125    psychoacoustic settings, channel setup, options, codebook
126    etc).  
127 *********************************************************************/
128
129 typedef struct codec_setup_info {
130
131   /* Vorbis supports only short and long blocks, but allows the
132      encoder to choose the sizes */
133
134   long blocksizes[2];
135
136   /* modes are the primary means of supporting on-the-fly different
137      blocksizes, different channel mappings (LR or M/A),
138      different residue backends, etc.  Each mode consists of a
139      blocksize flag and a mapping (along with the mapping setup */
140
141   int        modes;
142   int        maps;
143   int        times;
144   int        floors;
145   int        residues;
146   int        books;
147   int        psys;     /* encode only */
148
149   vorbis_info_mode       *mode_param[64];
150   int                     map_type[64];
151   vorbis_info_mapping    *map_param[64];
152   int                     time_type[64];
153   vorbis_info_time       *time_param[64];
154   int                     floor_type[64];
155   vorbis_info_floor      *floor_param[64];
156   int                     residue_type[64];
157   vorbis_info_residue    *residue_param[64];
158   static_codebook        *book_param[256];
159   codebook               *fullbooks;
160
161   vorbis_info_psy        *psy_param[64]; /* encode only */
162   vorbis_info_psy_global psy_g_param;
163
164   bitrate_manager_info   bi;
165   highlevel_encode_setup hi;
166
167   int    passlimit[32];     /* iteration limit per couple/quant pass */
168   int    coupling_passes;
169 } codec_setup_info;
170
171 extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi);
172 extern void _vp_global_free(vorbis_look_psy_global *look);
173
174 #endif