Generated from configure.in
[swftools.git] / lib / bladeenc / loop-pvt.h
1 /*
2                         (c) Copyright 1998-2000 - Tord Jansson
3                         ======================================
4
5                 This file is part of the BladeEnc MP3 Encoder, based on
6                 ISO's reference code for MPEG Layer 3 compression, and might
7                 contain smaller or larger sections that are directly taken
8                 from ISO's reference code.
9
10                 All changes to the ISO reference code herein are either
11                 copyrighted by Tord Jansson (tord.jansson@swipnet.se)
12                 or sublicensed to Tord Jansson by a third party.
13
14         BladeEnc is free software; you can redistribute this file
15         and/or modify it under the terms of the GNU Lesser General Public
16         License as published by the Free Software Foundation; either
17         version 2.1 of the License, or (at your option) any later version.
18
19
20
21         ------------    Changes    ------------
22
23         2000-02-15  Pirandot
24
25         -       reformatted, used 'static', less parameters
26
27         2000-12-03  ap
28         -       adapted according to changes to "loop.h"
29 */
30
31 #ifndef         __LOOP_PVT__
32 #define         __LOOP_PVT__
33
34
35
36
37
38 static  int                             outer_loop
39 (
40         int                                             max_bits,
41         frame_params                    *fr_ps
42 );
43
44 static  int                             needed_bits_for_storing_scalefactors
45 (
46         frame_params                    *fr_ps
47 );
48
49 static  void                    calc_noise (void);
50
51 static  int                             loop_break (void);
52
53 static  int                             amplify
54 (
55         int                                             iteration
56 );
57
58 static  int INLINE              cutting_crew (FLOAT in);
59
60 static  void                    quantize (void);
61
62 static  void                    partial_quantize (void);
63
64 static  int                             bin_search_StepSize
65 (
66         int                                             desired_rate,
67         double                                  start
68 );
69
70
71
72 /*  ------------    bit counting    --------------------------------------------------------  */
73
74
75
76 static  int                             count_bits (void);
77
78 static  int                             count_bits_short (void);
79
80 static  int                             count_bits_long (void);
81
82 static  void                    choose_table_long
83 (
84         unsigned                                start,
85         unsigned                                end,
86         unsigned                                max,
87         unsigned                                *table,
88         unsigned                                *bit_sum
89 );
90
91 static  void                    choose_table_short
92 (
93         unsigned                                start_sfb,
94         unsigned                                end_sfb,
95         unsigned                                max,
96         unsigned                                *table,
97         unsigned                                *bit_sum
98 );
99
100
101
102 /*  ------------    Huffmania    -----------------------------------------------------------  */
103
104
105
106 static  void                    single_Huffman
107 (
108         unsigned                                start,
109         unsigned                                end,
110 /*      unsigned                                table0, == 1 */
111         unsigned                                *choice,
112         unsigned                                *sum
113 );
114
115 static  void                    double_Huffman
116 (
117         unsigned                                start,
118         unsigned                                end,
119         unsigned                                table0,   /* 2, 5, 13 */
120         unsigned                                table1,   /* 3, 6, 15 */
121         unsigned                                *choice,
122         unsigned                                *sum
123 );
124
125 static  void                    triple_Huffman
126 (
127         unsigned                                start,
128         unsigned                                end,
129         unsigned                                table0,   /* 7, 10 */
130         unsigned                                table1,   /* 8, 11 */
131         unsigned                                table2,   /* 9, 12 */
132         unsigned                                *choice,
133         unsigned                                *sum
134 );
135
136 static  void                    triple_Huffman_2
137 (
138         unsigned                                start,
139         unsigned                                end,
140 /*      unsigned                                table0,   == 13 */
141 /*      unsigned                                table1,   == 15 */
142 /*      unsigned                                table2,   == 24 */
143         unsigned                                *choice,
144         unsigned                                *sum
145 );
146
147 static  void                    double_Huffman_2   /* Escape tables */
148 (
149         unsigned                                start,
150         unsigned                                end,
151         unsigned                                table0,   /* 16... */
152         unsigned                                table1,   /* 24... */
153         unsigned                                *choice,
154         unsigned                                *sum
155 );
156
157
158
159 /*  ------------    the struggle continues    ----------------------------------------------  */
160
161
162
163 static  void                    tiny_single_Huffman
164 (
165         unsigned                                start,
166         unsigned                                end,
167 #if ORG_HUFFMAN_CODING
168         unsigned                                table0,
169 #else
170 /*      unsigned                                table0, == 1 */
171 #endif
172         unsigned                                *choice,
173         unsigned                                *sum
174 );
175
176 static  void                    tiny_double_Huffman
177 (
178         unsigned                                start,
179         unsigned                                end,
180         unsigned                                table0,   /* 2, 5, 13 */
181         unsigned                                table1,   /* 3, 6, 15 */
182         unsigned                                *choice,
183         unsigned                                *sum
184 );
185
186 static  void                    tiny_triple_Huffman
187 (
188         unsigned                                start,
189         unsigned                                end,
190         unsigned                                table0,   /* 7, 10 */
191         unsigned                                table1,   /* 8, 11 */
192         unsigned                                table2,   /* 9, 12 */
193         unsigned                                *choice,
194         unsigned                                *sum
195 );
196
197 static  void                    tiny_triple_Huffman_2
198 (
199         unsigned                                start,
200         unsigned                                end,
201 /*      unsigned                                table0,   == 13 */
202 /*      unsigned                                table1,   == 15 */
203 /*      unsigned                                table2,   == 24 */
204         unsigned                                *choice,
205         unsigned                                *sum
206 );
207
208 static  void                    tiny_double_Huffman_2   /* Escape tables */
209 (
210         unsigned                                start,
211         unsigned                                end,
212         unsigned                                table0,   /* 16... */
213         unsigned                                table1,   /* 24... */
214         unsigned                                *choice,
215         unsigned                                *sum
216 );
217
218
219
220
221
222 #endif          /* __LOOP_PVT__ */