From 404df9a1760c5e8a246cedcfe096cde4bcd5201b Mon Sep 17 00:00:00 2001 From: AngelCarpintero Date: Thu, 2 Oct 2008 15:22:34 +0000 Subject: [PATCH] Fix some ident, now looks better --- alg.c | 7 +++-- configure | 18 ++++++------ motion.c | 85 ++++++++++++++++++++++++++++++++----------------------- 3 files changed, 63 insertions(+), 47 deletions(-) diff --git a/alg.c b/alg.c index a3ab313e..e01734b8 100644 --- a/alg.c +++ b/alg.c @@ -159,7 +159,8 @@ void alg_locate_center_size(struct images *imgs, int width, int height, struct c /* draw a box around the movement */ -void alg_draw_location(struct coord *cent, struct images *imgs, int width, unsigned char *new, int style, int mode, int process_thisframe) +void alg_draw_location(struct coord *cent, struct images *imgs, int width, unsigned char *new, + int style, int mode, int process_thisframe) { unsigned char *out = imgs->out; int x, y; @@ -223,7 +224,8 @@ void alg_draw_location(struct coord *cent, struct images *imgs, int width, unsig /* draw a RED box around the movement */ -void alg_draw_red_location(struct coord *cent, struct images *imgs, int width, unsigned char *new, int style, int mode, int process_thisframe) +void alg_draw_red_location(struct coord *cent, struct images *imgs, int width, unsigned char *new, + int style, int mode, int process_thisframe) { unsigned char *out = imgs->out; unsigned char *new_u, *new_v; @@ -258,6 +260,7 @@ void alg_draw_red_location(struct coord *cent, struct images *imgs, int width, u out[width_maxx_y] =~out[width_maxx_y]; } } + if (style == LOCATE_REDBOX) { /* draw a red box on normal images */ int width_miny = width * cent->miny; int width_maxy = width * cent->maxy; diff --git a/configure b/configure index 57954caf..425ebbc5 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for motion trunk-r426. +# Generated by GNU Autoconf 2.61 for motion trunk-r428. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. @@ -572,8 +572,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='motion' PACKAGE_TARNAME='motion' -PACKAGE_VERSION='trunk-r426' -PACKAGE_STRING='motion trunk-r426' +PACKAGE_VERSION='trunk-r428' +PACKAGE_STRING='motion trunk-r428' PACKAGE_BUGREPORT='' ac_unique_file="motion.c" @@ -1177,7 +1177,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures motion trunk-r426 to adapt to many kinds of systems. +\`configure' configures motion trunk-r428 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1238,7 +1238,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of motion trunk-r426:";; + short | recursive ) echo "Configuration of motion trunk-r428:";; esac cat <<\_ACEOF @@ -1374,7 +1374,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -motion configure trunk-r426 +motion configure trunk-r428 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1388,7 +1388,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by motion $as_me trunk-r426, which was +It was created by motion $as_me trunk-r428, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -8122,7 +8122,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by motion $as_me trunk-r426, which was +This file was extended by motion $as_me trunk-r428, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -8171,7 +8171,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -motion config.status trunk-r426 +motion config.status trunk-r428 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/motion.c b/motion.c index d14ae24f..0ea1d17e 100644 --- a/motion.c +++ b/motion.c @@ -202,14 +202,20 @@ static void image_save_as_preview(struct context *cnt, struct image_data *img) /* draw locate box here when mode = LOCATE_PREVIEW */ if (cnt->locate_motion_mode == LOCATE_PREVIEW) { - if (cnt->locate_motion_style == LOCATE_BOX) - alg_draw_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, LOCATE_BOX, LOCATE_NORMAL, cnt->process_thisframe); - else if (cnt->locate_motion_style == LOCATE_REDBOX) - alg_draw_red_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, LOCATE_REDBOX, LOCATE_NORMAL, cnt->process_thisframe); - else if (cnt->locate_motion_style == LOCATE_CROSS) - alg_draw_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, LOCATE_CROSS, LOCATE_NORMAL, cnt->process_thisframe); - else if (cnt->locate_motion_style == LOCATE_REDCROSS) - alg_draw_red_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, LOCATE_REDCROSS, LOCATE_NORMAL, cnt->process_thisframe); + + if (cnt->locate_motion_style == LOCATE_BOX) { + alg_draw_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, + LOCATE_BOX, LOCATE_NORMAL, cnt->process_thisframe); + } else if (cnt->locate_motion_style == LOCATE_REDBOX) { + alg_draw_red_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, + LOCATE_REDBOX, LOCATE_NORMAL, cnt->process_thisframe); + } else if (cnt->locate_motion_style == LOCATE_CROSS) { + alg_draw_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, + LOCATE_CROSS, LOCATE_NORMAL, cnt->process_thisframe); + } else if (cnt->locate_motion_style == LOCATE_REDCROSS) { + alg_draw_red_location(&img->location, &cnt->imgs, cnt->imgs.width, cnt->imgs.preview_image.image, + LOCATE_REDCROSS, LOCATE_NORMAL, cnt->process_thisframe); + } } } @@ -391,14 +397,20 @@ static void motion_detected(struct context *cnt, int dev, struct image_data *img /* Draw location */ if (cnt->locate_motion_mode == LOCATE_ON) { - if (cnt->locate_motion_style == LOCATE_BOX) - alg_draw_location(location, imgs, imgs->width, img->image, LOCATE_BOX, LOCATE_BOTH, cnt->process_thisframe); - else if (cnt->locate_motion_style == LOCATE_REDBOX) - alg_draw_red_location(location, imgs, imgs->width, img->image, LOCATE_REDBOX, LOCATE_BOTH, cnt->process_thisframe); - else if (cnt->locate_motion_style == LOCATE_CROSS) - alg_draw_location(location, imgs, imgs->width, img->image, LOCATE_CROSS, LOCATE_BOTH, cnt->process_thisframe); - else if (cnt->locate_motion_style == LOCATE_REDCROSS) - alg_draw_red_location(location, imgs, imgs->width, img->image, LOCATE_REDCROSS, LOCATE_BOTH, cnt->process_thisframe); + + if (cnt->locate_motion_style == LOCATE_BOX) { + alg_draw_location(location, imgs, imgs->width, img->image, LOCATE_BOX, + LOCATE_BOTH, cnt->process_thisframe); + } else if (cnt->locate_motion_style == LOCATE_REDBOX) { + alg_draw_red_location(location, imgs, imgs->width, img->image, LOCATE_REDBOX, + LOCATE_BOTH, cnt->process_thisframe); + } else if (cnt->locate_motion_style == LOCATE_CROSS) { + alg_draw_location(location, imgs, imgs->width, img->image, LOCATE_CROSS, + LOCATE_BOTH, cnt->process_thisframe); + }else if (cnt->locate_motion_style == LOCATE_REDCROSS) { + alg_draw_red_location(location, imgs, imgs->width, img->image, LOCATE_REDCROSS, + LOCATE_BOTH, cnt->process_thisframe); + } } /* Calculate how centric motion is if configured preview center*/ @@ -513,10 +525,10 @@ static void process_image_ring(struct context *cnt, unsigned int max_images) mystrftime(cnt, tmp, sizeof(tmp), "%H%M%S-%q", &cnt->imgs.image_ring[cnt->imgs.image_ring_out].timestamp_tm, NULL, 0); - draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 20, cnt->imgs.width, tmp, - cnt->conf.text_double); - draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 30, cnt->imgs.width, t, - cnt->conf.text_double); + draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 20, + cnt->imgs.width, tmp, cnt->conf.text_double); + draw_text(cnt->imgs.image_ring[cnt->imgs.image_ring_out].image, 10, 30, + cnt->imgs.width, t, cnt->conf.text_double); } /* Output the picture to jpegs and ffmpeg */ @@ -1180,7 +1192,8 @@ static void *motion_loop(void *arg) memset(&cnt->current_image->location, 0, sizeof(cnt->current_image->location)); cnt->current_image->total_labels = 0; } else if (cnt->current_image && old_image) { - /* not processing this frame: save some important values for next image */ cnt->current_image->diffs = old_image->diffs; + /* not processing this frame: save some important values for next image */ + cnt->current_image->diffs = old_image->diffs; cnt->current_image->timestamp = old_image->timestamp; cnt->current_image->timestamp_tm = old_image->timestamp_tm; cnt->current_image->shot = old_image->shot; @@ -1338,6 +1351,7 @@ static void *motion_loop(void *arg) tmpin = "CONNECTION TO CAMERA LOST\\nSINCE %Y-%m-%d %T"; else tmpin = "UNABLE TO OPEN VIDEO DEVICE\\nSINCE %Y-%m-%d %T"; + localtime_r(&cnt->connectionlosttime, &tmptime); memset(cnt->current_image->image, 0x80, cnt->imgs.size); mystrftime(cnt, tmpout, sizeof(tmpout), tmpin, &tmptime, NULL, 0); @@ -1449,11 +1463,10 @@ static void *motion_loop(void *arg) } /* Manipulate smart_mask sensitivity (only every smartmask_ratio seconds) */ - if (cnt->smartmask_speed && (cnt->event_nr != cnt->prev_event)) { - if (!--smartmask_count) { - alg_tune_smartmask(cnt); - smartmask_count = smartmask_ratio; - } + if ((cnt->smartmask_speed && (cnt->event_nr != cnt->prev_event)) && + (!--smartmask_count)) { + alg_tune_smartmask(cnt); + smartmask_count = smartmask_ratio; } /* cnt->moved is set by the tracking code when camera has been asked to move. @@ -1474,10 +1487,10 @@ static void *motion_loop(void *arg) /* if noise tuning was selected, do it now. but only when * no frames have been recorded and only once per second */ - if (cnt->conf.noise_tune && cnt->shots == 0) { - if (!cnt->detecting_motion && (cnt->current_image->diffs <= cnt->threshold)) - alg_noise_tune(cnt, cnt->imgs.image_virgin); - } + if ((cnt->conf.noise_tune && cnt->shots == 0) && + (!cnt->detecting_motion && (cnt->current_image->diffs <= cnt->threshold))) + alg_noise_tune(cnt, cnt->imgs.image_virgin); + /* if we are not noise tuning lets make sure that remote controlled * changes of noise_level are used. @@ -1673,9 +1686,9 @@ static void *motion_loop(void *arg) } else { /* Done with postcap, so just have the image in the precap buffer */ cnt->current_image->flags |= IMAGE_PRECAP; - /* gapless movie feature */ - if ((cnt->conf.event_gap == 0) && (cnt->detecting_motion == 1)) - cnt->makemovie = 1; + /* gapless movie feature */ + if ((cnt->conf.event_gap == 0) && (cnt->detecting_motion == 1)) + cnt->makemovie = 1; cnt->detecting_motion = 0; } @@ -1711,9 +1724,9 @@ static void *motion_loop(void *arg) /* Is the movie too long? Then make movies * First test for max_movie_time */ - if (cnt->conf.max_movie_time && cnt->event_nr == cnt->prev_event) - if (cnt->currenttime - cnt->eventtime >= cnt->conf.max_movie_time) - cnt->makemovie = 1; + if ((cnt->conf.max_movie_time && cnt->event_nr == cnt->prev_event) && + (cnt->currenttime - cnt->eventtime >= cnt->conf.max_movie_time)) + cnt->makemovie = 1; /* Now test for quiet longer than 'gap' OR make movie as decided in * previous statement.