Mercurial > libavcodec.hg
comparison elbg.c @ 5122:753230e2dcf0 libavcodec
Cygwin compatibility workaround
patch by Eric Lasota: [ riot icculus org ]
original thread: [FFmpeg-devel] [PATCH] elbg.c Cygwin compatibility workaround
date: 06/09/2007 09:26 AM
author | benoit |
---|---|
date | Mon, 11 Jun 2007 07:57:15 +0000 |
parents | ed41cfae128d |
children | 661eff5542cb |
comparison
equal
deleted
inserted
replaced
5121:71d080656056 | 5122:753230e2dcf0 |
---|---|
113 | 113 |
114 /** | 114 /** |
115 * Implementation of the simple LBG algorithm for just two codebooks | 115 * Implementation of the simple LBG algorithm for just two codebooks |
116 */ | 116 */ |
117 static int simple_lbg(int dim, | 117 static int simple_lbg(int dim, |
118 int centroid[3][dim], | 118 int *centroid[3], |
119 int newutility[3], | 119 int newutility[3], |
120 int *points, | 120 int *points, |
121 cell *cells) | 121 cell *cells) |
122 { | 122 { |
123 int i, idx; | 123 int i, idx; |
184 * @param elbg Internal elbg data | 184 * @param elbg Internal elbg data |
185 * @param indexes {luc, huc, cluc} | 185 * @param indexes {luc, huc, cluc} |
186 * @param newcentroid A vector with the position of the new centroids | 186 * @param newcentroid A vector with the position of the new centroids |
187 */ | 187 */ |
188 static void shift_codebook(elbg_data *elbg, int *indexes, | 188 static void shift_codebook(elbg_data *elbg, int *indexes, |
189 int newcentroid[3][elbg->dim]) | 189 int *newcentroid[3]) |
190 { | 190 { |
191 cell *tempdata; | 191 cell *tempdata; |
192 cell **pp = &elbg->cells[indexes[2]]; | 192 cell **pp = &elbg->cells[indexes[2]]; |
193 | 193 |
194 while(*pp) | 194 while(*pp) |
244 static void try_shift_candidate(elbg_data *elbg, int idx[3]) | 244 static void try_shift_candidate(elbg_data *elbg, int idx[3]) |
245 { | 245 { |
246 int j, k, olderror=0, newerror, cont=0; | 246 int j, k, olderror=0, newerror, cont=0; |
247 int newutility[3]; | 247 int newutility[3]; |
248 int newcentroid[3][elbg->dim]; | 248 int newcentroid[3][elbg->dim]; |
249 int *newcentroid_ptrs[3] = { newcentroid[0], newcentroid[1], newcentroid[2] }; | |
249 cell *tempcell; | 250 cell *tempcell; |
250 | 251 |
251 for (j=0; j<3; j++) | 252 for (j=0; j<3; j++) |
252 olderror += elbg->utility[idx[j]]; | 253 olderror += elbg->utility[idx[j]]; |
253 | 254 |
267 newutility[2] = eval_error_cell(elbg, newcentroid[2], elbg->cells[idx[0]]); | 268 newutility[2] = eval_error_cell(elbg, newcentroid[2], elbg->cells[idx[0]]); |
268 newutility[2] += eval_error_cell(elbg, newcentroid[2], elbg->cells[idx[2]]); | 269 newutility[2] += eval_error_cell(elbg, newcentroid[2], elbg->cells[idx[2]]); |
269 | 270 |
270 newerror = newutility[2]; | 271 newerror = newutility[2]; |
271 | 272 |
272 newerror += simple_lbg(elbg->dim, newcentroid, newutility, elbg->points, | 273 newerror += simple_lbg(elbg->dim, newcentroid_ptrs, newutility, elbg->points, |
273 elbg->cells[idx[1]]); | 274 elbg->cells[idx[1]]); |
274 | 275 |
275 if (olderror > newerror) { | 276 if (olderror > newerror) { |
276 shift_codebook(elbg, idx, newcentroid); | 277 shift_codebook(elbg, idx, newcentroid_ptrs); |
277 | 278 |
278 elbg->error += newerror - olderror; | 279 elbg->error += newerror - olderror; |
279 | 280 |
280 for (j=0; j<3; j++) | 281 for (j=0; j<3; j++) |
281 update_utility_and_n_cb(elbg, idx[j], newutility[j]); | 282 update_utility_and_n_cb(elbg, idx[j], newutility[j]); |