From 4e47b342b8ab6128989aec2d8bb293f1dd25fff1 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 28 Dec 2014 12:58:59 +0100 Subject: Slight optimisation. --- tools/clkcalc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/clkcalc.c b/tools/clkcalc.c index 2829ca9..cc5b932 100644 --- a/tools/clkcalc.c +++ b/tools/clkcalc.c @@ -1,4 +1,5 @@ #include +#include double _fabs(double a) { @@ -31,19 +32,19 @@ int main(int argc, char *argv[]) int fs = atoi(argv[1]); int bw = atoi(argv[2]); int ch = atoi(argv[3]); - + int target = fs * bw * ch; int cclk = 100000000; result_t res; - res.pclkdiv_idx = 0; + res.pclkdiv_idx = 3; res.bitrate = 0; res.x = 1; res.y = 1; - for(;res.pclkdiv_idx < 4; res.pclkdiv_idx++) { + for(;res.pclkdiv_idx >= 0; res.pclkdiv_idx--) { double clk = (cclk / pclkdiv[res.pclkdiv_idx]); @@ -51,7 +52,8 @@ int main(int argc, char *argv[]) double clk_y = clk / (double)res.y; - for(res.x = 1; res.x < 256; res.x++) { + // Note y must be greater than or equal to x. + for(res.x = 1; res.x <= res.y; res.x++) { double clk_y_x_2 = (clk_y * (double)res.x) / 2.0; -- cgit v1.2.3