reinitialisation of qsmodel */ table array of int's to be used for initialisation (NULL ok) */
| 152 | /* reinitialisation of qsmodel */ |
| 153 | /* table array of int's to be used for initialisation (NULL ok) */ |
| 154 | void RangeModel::init(U32 *table) |
| 155 | { |
| 156 | U32 i, end, initval; |
| 157 | rescale = n >> 4 | 2; |
| 158 | nextleft = 0; |
| 159 | if (table) |
| 160 | { |
| 161 | I32 tmpn = 0; |
| 162 | for(i=0; i<n; i++) |
| 163 | { |
| 164 | if (table[i]) |
| 165 | { |
| 166 | tmpn++; |
| 167 | } |
| 168 | } |
| 169 | initval = cf[n] / tmpn; |
| 170 | end = cf[n] % tmpn; |
| 171 | for (i=0; i<n; i++) |
| 172 | { |
| 173 | if (table[i]) |
| 174 | { |
| 175 | if (end) |
| 176 | { |
| 177 | newf[i] = initval+1; |
| 178 | end--; |
| 179 | } |
| 180 | else |
| 181 | { |
| 182 | newf[i] = initval; |
| 183 | } |
| 184 | } |
| 185 | else |
| 186 | { |
| 187 | newf[i] = 0; |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | else |
| 192 | { |
| 193 | initval = cf[n] / n; |
| 194 | end = cf[n] % n; |
| 195 | for (i=0; i<end; i++) |
| 196 | { |
| 197 | newf[i] = initval+1; |
| 198 | } |
| 199 | for (; i<n; i++) |
| 200 | { |
| 201 | newf[i] = initval; |
| 202 | } |
| 203 | } |
| 204 | dorescale(); |
| 205 | } |
| 206 | |
| 207 | /* retrieval of estimated frequencies for a symbol */ |
| 208 | /* sym symbol for which data is desired; must be <n */ |
nothing calls this directly
no outgoing calls
no test coverage detected