summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-12-28 12:58:59 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2014-12-28 12:58:59 +0100
commit4e47b342b8ab6128989aec2d8bb293f1dd25fff1 (patch)
tree7eed3bc58c42a6cc4b29c7b0935f0f89eef518fd
parentbd353a73e52a4b55259d7b333095a5661d8d425a (diff)
Slight optimisation.
-rw-r--r--tools/clkcalc.c10
1 files 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 <stdio.h>
+#include <stdint.h>
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;