renamed limit to clamp

master
Ahmet Inan 2011-09-08 14:43:23 +02:00
rodzic 5fe8cca16f
commit bee90c3feb
1 zmienionych plików z 5 dodań i 5 usunięć

Wyświetl plik

@ -22,7 +22,7 @@ int64_t gcd(int64_t a, int64_t b)
return b; return b;
} }
float flimitf(float min, float max, float x) float fclampf(float x, float min, float max)
{ {
float tmp = x < min ? min : x; float tmp = x < min ? min : x;
return tmp > max ? max : tmp; return tmp > max ? max : tmp;
@ -183,8 +183,8 @@ int main(int argc, char **argv)
do_ddc(dat_ddc, dat_amp, dat_q); do_ddc(dat_ddc, dat_amp, dat_q);
} }
float cnt_freq = flimitf(1100.0, 1300.0, 1200.0 + cargf(cnt_q[out] * conjf(cnt_last)) / (2.0 * M_PI * dstep)); float cnt_freq = fclampf(1200.0 + cargf(cnt_q[out] * conjf(cnt_last)) / (2.0 * M_PI * dstep), 1100.0, 1300.0);
float dat_freq = flimitf(1500.0, 2300.0, 1900.0 + cargf(dat_q[out] * conjf(dat_last)) / (2.0 * M_PI * dstep)); float dat_freq = fclampf(1900.0 + cargf(dat_q[out] * conjf(dat_last)) / (2.0 * M_PI * dstep), 1500.0, 2300.0);
cnt_last = cnt_q[out]; cnt_last = cnt_q[out];
dat_last = dat_q[out]; dat_last = dat_q[out];
@ -384,10 +384,10 @@ int main(int argc, char **argv)
// TODO: need better way to compensate for pulse decay time // TODO: need better way to compensate for pulse decay time
float fixme = 0.0007; float fixme = 0.0007;
if (y_pixel_x < y_width && hor_ticks >= (int)((fixme + sync_porch_len) * drate)) if (y_pixel_x < y_width && hor_ticks >= (int)((fixme + sync_porch_len) * drate))
y_pixel[y_pixel_x++ + (y % 2) * y_width] = flimitf(0.0, 255.0, 255.0 * (dat_freq - 1500.0) / 800.0); y_pixel[y_pixel_x++ + (y % 2) * y_width] = fclampf(255.0 * (dat_freq - 1500.0) / 800.0, 0.0, 255.0);
if (uv_pixel_x < uv_width && hor_ticks >= (int)((fixme + sync_porch_len + y_len + seperator_len + porch_len) * drate)) if (uv_pixel_x < uv_width && hor_ticks >= (int)((fixme + sync_porch_len + y_len + seperator_len + porch_len) * drate))
uv_pixel[uv_pixel_x++ + odd * uv_width] = flimitf(0.0, 255.0, 255.0 * (dat_freq - 1500.0) / 800.0); uv_pixel[uv_pixel_x++ + odd * uv_width] = fclampf(255.0 * (dat_freq - 1500.0) / 800.0, 0.0, 255.0);
} }
if (pixel) { if (pixel) {