# HG changeset patch # User ods15 # Date 1159769364 0 # Node ID bd0cb21d956d373ca1ca5a4fdbc0ff3da12a42fd # Parent e255692302f0c3dfa4fd6b59bd918220f03ec918 Original Commit: r103 | ods15 | 2006-10-01 18:00:43 +0200 (Sun, 01 Oct 2006) | 2 lines slight optimization, don't calculate average twice diff -r e255692302f0 -r bd0cb21d956d vorbis_enc.c --- a/vorbis_enc.c Mon Oct 02 06:09:22 2006 +0000 +++ b/vorbis_enc.c Mon Oct 02 06:09:24 2006 +0000 @@ -1116,13 +1116,14 @@ int range = 255 / fc->multiplier + 1; int i; float tot_average = 0.; - for (i = 0; i < fc->values; i++) tot_average += get_floor_average(fc, coeffs, i); + float averages[fc->values]; + for (i = 0; i < fc->values; i++) tot_average += averages[i] = get_floor_average(fc, coeffs, i); tot_average /= fc->values; tot_average /= venc->quality; for (i = 0; i < fc->values; i++) { int position = fc->list[fc->list[i].sort].x; - float average = get_floor_average(fc, coeffs, i); + float average = averages[i]; int j; average /= pow(average, 0.5) / tot_average * pow(0.8, position/200.); // MAGIC!