From 5c418133bff32c2df292a551dc24c1515f5dcf2d Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Fri, 29 Apr 2011 17:26:50 +0300 Subject: [PATCH 01/56] Lots accomplished! 1) Delta and blend SSE and standard alogirthms inside 2) Changed event streaming to use sendfile() syscall if available 3) Direct memory capture (Less memcpys required) 4) Added macros for BGR24 and RGB32(and its variants) formats 5) Modified Monitors database table to add a target colorspace option 6) Changed most image buffer allocations to be on 16 byte boundary, work still in progress 7) Added Target colorspace instead of the old colours selection. this one also visible to local cameras 8) Replacing Y deltas option with ZM_CPU_EXTENSIONS 9) Added SSE detection code 10) Changed some code to make linking success with inlining enabled. 11) Some other changes and work still in progress for some listed above --- config.h.in | 6 + configure.ac | 4 +- db/zm_create.sql.in | 1 + db/zm_update-1.24.2.sql | 3 + src/Makefile.am | 2 +- src/zm_camera.cpp | 7 +- src/zm_camera.h | 8 +- src/zm_config_defines.h | 4 +- src/zm_event.cpp | 56 +- src/zm_ffmpeg_camera.cpp | 2 +- src/zm_file_camera.cpp | 4 +- src/zm_file_camera.h | 2 +- src/zm_image.cpp | 1814 ++++++++++++++++++++++++++++++++------ src/zm_image.h | 99 ++- src/zm_local_camera.cpp | 313 +++++-- src/zm_local_camera.h | 2 +- src/zm_mem_utils.h | 31 + src/zm_monitor.cpp | 124 ++- src/zm_monitor.h | 8 +- src/zm_remote_camera.cpp | 4 +- src/zm_rgb.h | 119 ++- src/zm_thread.h | 26 +- src/zm_utils.cpp | 47 + src/zm_utils.h | 5 + src/zm_zone.cpp | 6 +- 25 files changed, 2239 insertions(+), 458 deletions(-) diff --git a/config.h.in b/config.h.in index 4831ff9aa..c735aa992 100644 --- a/config.h.in +++ b/config.h.in @@ -192,6 +192,9 @@ /* Define to 1 if you have the `sigaction' function. */ #undef HAVE_SIGACTION +/* Define to 1 if you have the `sendfile' function. */ +#undef HAVE_SENDFILE + /* Define to 1 if the system has the type `siginfo_t'. */ #undef HAVE_SIGINFO_T @@ -292,6 +295,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SENDFILE_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SHM_H diff --git a/configure.ac b/configure.ac index 53b0e7ae4..1c7c93f63 100644 --- a/configure.ac +++ b/configure.ac @@ -246,7 +246,7 @@ AC_FUNC_STAT AC_FUNC_STRFTIME AC_FUNC_STRTOD AC_FUNC_VPRINTF -AC_CHECK_FUNCS([gethostbyname gethostname gettimeofday memmove memset mkdir munmap putenv select socket sqrt strcasecmp strchr strcspn strerror strncasecmp strrchr strsignal strspn strstr strtol strtoull]) +AC_CHECK_FUNCS([gethostbyname gethostname gettimeofday memmove memset mkdir munmap posix_memalign putenv select sendfile socket sqrt strcasecmp strchr strcspn strerror strncasecmp strrchr strsignal strspn strstr strtol strtoull]) AC_CHECK_FUNCS([syscall sleep usleep ioctl ioctlsocket sigaction]) # Other programs @@ -287,7 +287,7 @@ AC_CHECK_LIB(z,compress,,) AC_FUNC_ALLOCA AC_HEADER_STDC AC_CHECK_HEADERS([fcntl.h limits.h memory.h stddef.h stdlib.h string.h strings.h sys/param.h sys/time.h syslog.h unistd.h values.h]) -AC_CHECK_HEADERS([netdb.h netinet/in.h arpa/inet.h sys/ioctl.h sys/socket.h sys/un.h glob.h]) +AC_CHECK_HEADERS([netdb.h netinet/in.h arpa/inet.h sys/ioctl.h sys/socket.h sys/un.h glob.h sys/sendfile.h]) AC_CHECK_HEADERS(execinfo.h,,,) AC_CHECK_HEADERS(syscall.h,,,) AC_CHECK_HEADERS(pthread.h,,,) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index d43bd19d6..cee85f83d 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -329,6 +329,7 @@ CREATE TABLE `Monitors` ( `Path` varchar(255) NOT NULL default '', `Width` smallint(5) unsigned NOT NULL default '0', `Height` smallint(5) unsigned NOT NULL default '0', + `Colours` tinyint(3) unsigned NOT NULL default '1', `Palette` int(10) unsigned NOT NULL default '0', `Orientation` enum('0','90','180','270','hori','vert') NOT NULL default '0', `Brightness` mediumint(7) NOT NULL default '-1', diff --git a/db/zm_update-1.24.2.sql b/db/zm_update-1.24.2.sql index 0d93185e6..d0ff2cd20 100644 --- a/db/zm_update-1.24.2.sql +++ b/db/zm_update-1.24.2.sql @@ -2,6 +2,9 @@ -- This updates a 1.24.2 database to the next version -- +--Add Colours colum. This is a harmless change for ZM 1.24.2 or ZM 1.24.3 without the patch, but is required to use the patch +ALTER TABLE `Monitors` ADD `Colours` TINYINT UNSIGNED NOT NULL DEFAULT '1' AFTER `Height`; + -- -- Add in remote ZoneMinder preset. -- diff --git a/src/Makefile.am b/src/Makefile.am index abf6f90a3..95dca309f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = gnu -AM_CPPFLAGS = @MYSQL_CFLAGS@ @FFMPEG_CFLAGS@ -Wall -Wno-sign-compare -fno-inline +AM_CPPFLAGS = @MYSQL_CFLAGS@ @FFMPEG_CFLAGS@ -Wall -Wno-sign-compare -finline-functions #AM_CXXFLAGS = -frepo CLEANFILES = *.rpo diff --git a/src/zm_camera.cpp b/src/zm_camera.cpp index 03dcd0dc4..d0e27b334 100644 --- a/src/zm_camera.cpp +++ b/src/zm_camera.cpp @@ -20,19 +20,22 @@ #include "zm.h" #include "zm_camera.h" -Camera::Camera( int p_id, SourceType p_type, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : +Camera::Camera( int p_id, SourceType p_type, int p_width, int p_height, int p_colours, int p_subpixelorder, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : id( p_id ), type( p_type ), width( p_width), height( p_height ), colours( p_colours ), + subpixelorder( p_subpixelorder ), brightness( p_brightness ), hue( p_hue ), colour( p_colour ), contrast( p_contrast ), capture( p_capture ) { - pixels = width * height * colours; + pixels = width * height; + imagesize = pixels * colours; + } Camera::~Camera() diff --git a/src/zm_camera.h b/src/zm_camera.h index 57d981e52..0b24c5169 100644 --- a/src/zm_camera.h +++ b/src/zm_camera.h @@ -39,7 +39,9 @@ protected: unsigned int width; unsigned int height; unsigned int colours; + unsigned int subpixelorder; unsigned int pixels; + unsigned int imagesize; int brightness; int hue; int colour; @@ -47,7 +49,7 @@ protected: bool capture; public: - Camera( int p_id, SourceType p_type, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ); + Camera( int p_id, SourceType p_type, int p_width, int p_height, int p_colours, int p_subpixelorder, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ); virtual ~Camera(); int getId() const { return( id ); } @@ -59,7 +61,9 @@ public: unsigned int Width() const { return( width ); } unsigned int Height() const { return( height ); } unsigned int Colours() const { return( colours ); } - unsigned int ImageSize() const { return( pixels ); } + unsigned int SubpixelOrder const { return( subpixelorder ); } + unsigned int Pixels() const { return( pixels ); } + unsigned int ImageSize() const { return( imagesize ); } virtual int Brightness( int/*p_brightness*/=-1 ) { return( -1 ); } virtual int Hue( int/*p_hue*/=-1 ) { return( -1 ); } diff --git a/src/zm_config_defines.h b/src/zm_config_defines.h index bf9a460d8..87ed3c36e 100644 --- a/src/zm_config_defines.h +++ b/src/zm_config_defines.h @@ -28,7 +28,7 @@ #define ZM_RELOAD_CAMBOZOLA 24 #define ZM_TIMESTAMP_ON_CAPTURE 25 #define ZM_LOCAL_BGR_INVERT 26 -#define ZM_Y_IMAGE_DELTAS 27 +#define ZM_CPU_EXTENSIONS 27 #define ZM_FAST_IMAGE_BLENDS 28 #define ZM_OPT_ADAPTIVE_SKIP 29 #define ZM_BLEND_ALARMED_IMAGES 30 @@ -251,7 +251,7 @@ int reload_cambozola;\ bool timestamp_on_capture;\ bool local_bgr_invert;\ - bool y_image_deltas;\ + bool cpu_extensions;\ bool fast_image_blends;\ bool opt_adaptive_skip;\ bool blend_alarmed_images;\ diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 009267993..f2ef9d5b1 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -28,6 +28,10 @@ #include #include +#if defined(HAVE_SYS_SENDFILE_H) && defined(HAVE_SENDFILE) +#include +#endif + #include "zm.h" #include "zm_db.h" #include "zm_time.h" @@ -751,7 +755,10 @@ bool EventStream::loadEventData( int event_id ) if ( config.use_deep_storage ) { struct tm *event_time = localtime( &event_data->start_time ); - snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", staticConfig.PATH_WEB.c_str(), config.dir_events, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec ); + if ( config.dir_events[0] == '/' ) + snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", config.dir_events, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec ); + else + snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", staticConfig.PATH_WEB.c_str(), config.dir_events, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec ); } else { @@ -1185,6 +1192,9 @@ bool EventStream::sendFrame( int delta_us ) Debug( 2, "Sending frame %d", curr_frame_id ); static char filepath[PATH_MAX]; + static struct stat filestat; + FILE *fdj = NULL; + snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id ); #if HAVE_LIBAVCODEC @@ -1219,14 +1229,20 @@ bool EventStream::sendFrame( int delta_us ) if ( send_raw ) { - FILE *fdj = fopen( filepath, "r" ); + fdj = fopen( filepath, "rb" ); if ( !fdj ) { Error( "Can't open %s: %s", filepath, strerror(errno) ); return( false ); } - img_buffer_size = fread( img_buffer, 1, sizeof(temp_img_buffer), fdj ); - fclose( fdj ); +#if HAVE_SENDFILE + if( fstat(fileno(fdj),&filestat) < 0 ) { + Error( "Failed getting information about file %s: %s", filepath, strerror(errno) ); + return( false ); + } +#else + img_buffer_size = fread( img_buffer, 1, sizeof(temp_img_buffer), fdj ); +#endif } else { @@ -1269,12 +1285,31 @@ bool EventStream::sendFrame( int delta_us ) Fatal( "Unexpected frame type %d", type ); break; } - fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size ); - if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) - { - Error( "Unable to send stream frame: %s", strerror(errno) ); - return( false ); - } + + + if(send_raw) { +#if HAVE_SENDFILE + fprintf( stdout, "Content-Length: %d\r\n\r\n", (int)filestat.st_size ); + if(sendfile(fileno(stdout), fileno(fdj), 0, (int)filestat.st_size) != (int)filestat.st_size) { + Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno)); + return( false ); + } +#else + if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) { + Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno)); + return( false ); + } +#endif + fclose(fdj); /* Close the file handle */ + } else { + fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size ); + if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) + { + Error( "Unable to send stream frame: %s", strerror(errno) ); + return( false ); + } + } + fprintf( stdout, "\r\n\r\n" ); fflush( stdout ); } @@ -1413,3 +1448,4 @@ void EventStream::runStream() closeComms(); } + diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 8b3bd57ef..f956fddf0 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -24,7 +24,7 @@ #include "zm_ffmpeg_camera.h" FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : - Camera( p_id, FFMPEG_SRC, p_width, p_height, p_colours, p_brightness, p_contrast, p_hue, p_colour, p_capture ), + Camera( p_id, FFMPEG_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ), mPath( p_path ) { if ( capture ) diff --git a/src/zm_file_camera.cpp b/src/zm_file_camera.cpp index c41521000..28ce2b155 100644 --- a/src/zm_file_camera.cpp +++ b/src/zm_file_camera.cpp @@ -34,7 +34,7 @@ #include "zm.h" #include "zm_file_camera.h" -FileCamera::FileCamera( int p_id, const char *p_path, int p_width, int p_height, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : Camera( p_id, FILE_SRC, p_width, p_height, p_palette, p_brightness, p_contrast, p_hue, p_colour, p_capture ) +FileCamera::FileCamera( int p_id, const char *p_path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : Camera( p_id, FILE_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ) { strncpy( path, p_path, sizeof(path) ); if ( capture ) @@ -82,7 +82,7 @@ int FileCamera::PreCapture() int FileCamera::Capture( Image &image ) { - return( image.ReadJpeg( path )?0:-1 ); + return( image.ReadJpeg( path, colours, subpixelorder )?0:-1 ); } int FileCamera::PostCapture() diff --git a/src/zm_file_camera.h b/src/zm_file_camera.h index e8ad5142b..ad972e372 100644 --- a/src/zm_file_camera.h +++ b/src/zm_file_camera.h @@ -36,7 +36,7 @@ protected: char path[PATH_MAX]; public: - FileCamera( int p_id, const char *p_path, int p_width, int p_height, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ); + FileCamera( int p_id, const char *p_path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ); ~FileCamera(); const char *Path() const { return( path ); } diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 4c55c978d..c30483154 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -19,6 +19,7 @@ #include "zm.h" #include "zm_font.h" #include "zm_image.h" +#include "zm_utils.h" #include #include @@ -30,12 +31,27 @@ unsigned char *Image::abs_table; unsigned char *Image::y_r_table; unsigned char *Image::y_g_table; unsigned char *Image::y_b_table; -Image::BlendTablePtr Image::blend_tables[101]; jpeg_compress_struct *Image::jpg_ccinfo[100] = { 0 }; jpeg_decompress_struct *Image::jpg_dcinfo = 0; struct zm_error_mgr Image::jpg_err; + +/* Pointer to blend function. Blend operates on colours and not pixels, so palette doesn't matter */ +blend_fptr_t fptr_blend; + +/* Pointer to delta8 functions */ +delta_fptr_t fptr_delta8_rgb; +delta_fptr_t fptr_delta8_bgr; +delta_fptr_t fptr_delta8_rgba; +delta_fptr_t fptr_delta8_bgra; +delta_fptr_t fptr_delta8_argb; +delta_fptr_t fptr_delta8_abgr; +delta_fptr_t fptr_delta8_gray8; + + + + Image::Image() { if ( !initialised ) @@ -44,10 +60,12 @@ Image::Image() height = 0; pixels = 0; colours = 0; + subpixelorder = 0; size = 0; allocation = 0; buffer = 0; - blend_buffer = 0; + buffertype = 0; + holdbuffer = 0; text[0] = '\0'; } @@ -59,15 +77,17 @@ Image::Image( const char *filename ) height = 0; pixels = 0; colours = 0; + subpixelorder = 0; size = 0; allocation = 0; buffer = 0; + buffertype = 0; + holdbuffer = 0; ReadJpeg( filename ); - blend_buffer = 0; text[0] = '\0'; } -Image::Image( int p_width, int p_height, int p_colours, uint8_t *p_buffer ) +Image::Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer ) { if ( !initialised ) Initialise(); @@ -75,19 +95,21 @@ Image::Image( int p_width, int p_height, int p_colours, uint8_t *p_buffer ) height = p_height; pixels = width*height; colours = p_colours; + subpixelorder = p_subpixelorder; size = width*height*colours; + holdbuffer = 0; if ( p_buffer ) { - allocation = 0; + /* Don't free the supplied buffer, but don't hold it either */ + allocation = size; + buffertype = ZM_BUFTYPE_DONTFREE; buffer = p_buffer; } else { allocation = size; - buffer = new uint8_t[allocation]; - memset( buffer, 0, size ); + AllocBuffer(allocation); } - blend_buffer = 0; text[0] = '\0'; } @@ -99,120 +121,233 @@ Image::Image( const Image &p_image ) height = p_image.height; pixels = p_image.pixels; colours = p_image.colours; + subpixelorder = p_image.subpixelorder; size = allocation = p_image.size; - buffer = new uint8_t[allocation]; - memcpy( buffer, p_image.buffer, size ); - blend_buffer = 0; + holdbuffer = 0; + AllocBuffer(allocation); + sse2_aligned_memcpy(buffer, p_image.buffer, size); strncpy( text, p_image.text, sizeof(text) ); } Image::~Image() { - if ( allocation ) - { - delete[] buffer; - } - delete[] blend_buffer; + DumpBuffer(); } void Image::Initialise() { initialised = true; + + /* Assign the blend pointer to function */ + if(config.fast_image_blends) { + if(sseversion >= 20) { + fptr_blend = &sse2_fastblend; /* SSE2 fast blend */ + Debug(2,"Blend: using SSE2 fast blending"); + } else { + fptr_blend = &std_fastblend; /* standard fast blend */ + Debug(2,"Blend: using standard fast blending"); + } + } else { + fptr_blend = &std_blend; + Debug(2,"Blend: using standard blending"); + } + + __attribute__((aligned(16))) uint8_t blend1[16] = {142,255,159,91,88,227,0,52,37,80,152,97,104,252,90,82}; + __attribute__((aligned(16))) uint8_t blend2[16] = {129,56,136,96,119,149,94,29,96,176,1,144,230,203,111,172}; + __attribute__((aligned(16))) uint8_t blendres[16]; + __attribute__((aligned(16))) uint8_t blendexp[16] = {141,231,157,92,91,217,11,49,45,92,133,103,119,246,92,93}; /* Expected results for 12.5% blend */ + + (*fptr_blend)(blend1,blend2,blendres,16,12.5); - abs_table = new unsigned char[(6*255)+1]; - abs_table += (3*255); - y_r_table = new unsigned char[511]; - y_r_table += 255; - y_g_table = new unsigned char[511]; - y_g_table += 255; - y_b_table = new unsigned char[511]; - y_b_table += 255; - for ( int i = -(3*255); i <= (3*255); i++ ) - { - abs_table[i] = abs(i); - } - for ( int i = -255; i <= 255; i++ ) - { - y_r_table[i] = (2990*abs(i))/10000; - y_g_table[i] = (5670*abs(i))/10000; - y_b_table[i] = (1140*abs(i))/10000; - //Info( "I:%d, R:%d, G:%d, B:%d", i, y_r_table[i], y_g_table[i], y_b_table[i] ); - } - for ( int i = 0; i <= 100; i++ ) - { - blend_tables[i] = 0; - } -} - -Image::BlendTablePtr Image::GetBlendTable( int transparency ) -{ - BlendTablePtr blend_ptr = blend_tables[transparency]; - if ( !blend_ptr ) - { - blend_ptr = blend_tables[transparency] = new BlendTable[1]; - //Info( "Generating blend table for transparency %d", transparency ); - int opacity = 100-transparency; - for ( int i = 0; i < 256; i++ ) - { - for ( int j = 0; j < 256; j++ ) - { - (*blend_ptr)[i][j] = (uint8_t)round(((i * opacity)+(j * transparency))/100.0L); - //printf( "I:%d, J:%d, B:%d\n", i, j, (*blend_ptr)[i][j] ); - } + /* Compare results with expected results */ + for(int i=0;i<16;i++) { + if(abs(blendexp[i] - blendres[i]) > 3) { + Panic("Blend function failed self-test: Results differ from the expected results"); } } - return( blend_ptr ); + + } -void Image::Empty() -{ - if ( allocation ) - { - delete[] buffer; - buffer = 0; - allocation = 0; - } - width = height = colours = size = 0; +/* Requests a writeable buffer to the image. This is safer than buffer() because this way we can gurantee that a buffer of required size exists */ +uint8_t* Image::WriteBuffer(const int p_width, const int p_height, const int p_colours, const int p_subpixelorder) { + unsigned int newsize; + + if(p_colours != 1 && p_colours != 3 && p_colours != 4) { + Error("WriteBuffer called with unexpected colours: %d",p_colours); + return NULL; + } + + if(!p_height || !p_width) { + Error("WriteBuffer called with invaid width or height: %d %d",p_width,p_height); + return NULL; + } + + if(p_width != width || p_height != height || p_colours != colours || p_subpixelorder != p_subpixelorder) { + newsize = p_width * p_height * p_colours; + + if(buffer == NULL) { + AllocBuffer(newsize); + } else { + if(allocation < newsize) { + if(holdbuffer) { + Error("Held buffer is undersized for requested buffer"); + return NULL; + } else { + /* Replace buffer with a bigger one */ + DumpBuffer(); + AllocBuffer(newsize); + } + } + } + + width = p_width; + height = p_height; + colours = p_colours; + subpixelorder = p_subpixelorder; + pixels = height*width; + size = newsize; + } + + return buffer; + } -void Image::Assign( int p_width, int p_height, int p_colours, unsigned char *new_buffer ) +/* Assign an existing buffer to the image instead of copying from a source buffer. The goal is to reduce the amount of memory copying and increase efficiency and buffer reusing. */ +void Image::AssignDirect( const int p_width, const int p_height, const int p_colours, const int p_subpixelorder, uint8_t *new_buffer, const size_t buffer_size, const int p_buffertype) { { - if ( !buffer || p_width != width || p_height != height || p_colours != colours ) - { - width = p_width; - height = p_height; - pixels = width*height; - colours = p_colours; - size = width*height*colours; - if ( allocation < size ) - { - allocation = size; - delete[] buffer; - buffer = new uint8_t[allocation]; - memset( buffer, 0, size ); - } - } - memcpy( buffer, new_buffer, size ); + if(new_buffer == NULL) { + Error("Attempt to directly assign buffer from a NULL pointer"); + return; + } + + if(buffer_size < (p_width*p_height*p_colours)) { + Error("Attempt to directly assign buffer from an undersized buffer of size: %u",buffer_size); + return; + } + + if(!p_height || !p_width) { + Error("Attempt to directly assign buffer with invalid width or height: %d %d",p_width,p_height); + return; + } + + if(p_colours != 1 && p_colours != 3 && p_colours != 4) { + Error("Attempt to directly assign buffer with unexpected colours per pixel: %d",p_colours); + return; + } + + if(holdbuffer && buffer) { + if((p_height * p_height * p_colours) > allocation) { + Error("Held buffer is undersized for assigned buffer"); + return; + } else { + /* Copy into the held buffer */ + Assign(p_width,p_height,p_colours,p_subpixelorder,new_buffer); + } + } else { + /* Free an existing buffer if any */ + DumpBuffer(); + + width = p_width; + height = p_height; + colours = p_colours; + subpixelorder = p_subpixelorder; + pixels = height*width; + size = pixels*colours; + + allocation = buffer_size; + buffertype = p_buffertype; + buffer = new_buffer; + } + } -void Image::Assign( const Image &image ) -{ - if ( !buffer || image.width != width || image.height != height || image.colours != colours ) - { - width = image.width; - height = image.height; - pixels = width*height; - colours = image.colours; - size = width*height*colours; - if ( allocation < size ) - { - allocation = size; - delete[] buffer; - buffer = new uint8_t[allocation]; - memset( buffer, 0, size ); - } - } - memcpy( buffer, image.buffer, size ); +void Image::Assign(const int p_width, const int p_height, const int p_colours, const int p_subpixelorder, const uint8_t* new_buffer, const size_t buffer_size) { + unsigned int new_size = p_width * p_height * p_colours; + + if(new_buffer == NULL) { + Error("Attempt to assign buffer from a NULL pointer"); + return; + } + + if(buffer_size < new_size) { + Error("Attempt to assign buffer from an undersized buffer of size: %u",buffer_size); + return; + } + + if(!p_height || !p_width) { + Error("Attempt to assign buffer with invalid width or height: %d %d",p_width,p_height); + return; + } + + if(p_colours != 1 && p_colours != 3 && p_colours != 4) { + Error("Attempt to assign buffer with unexpected colours per pixel: %d",p_colours); + return; + } + + if ( !buffer || p_width != width || p_height != height || p_colours != colours || p_subpixelorder != subpixelorder) { + + if (holdbuffer && buffer) { + if (new_size > allocation) { + Error("Held buffer is undersized for assigned buffer"); + return; + } + } else { + if(new_size > allocation || !buffer) { + DumpBuffer(); + AllocBuffer(new_size); + } + } + + width = p_width; + height = p_height; + pixels = width*height; + colours = p_colours; + subpixelorder = p_subpixelorder; + size = new_size; + } + + if(new_buffer != buffer) + sse2_aligned_memcpy(buffer, new_buffer, size); +} + +void Image::Assign( const Image &image ) { + unsigned int new_size = image.width * image.height * image.colours; + + if(image.buffer == NULL) { + Error("Attempt to assign image with an empty buffer"); + return; + } + + if(image.colours != 1 && image.colours != 3 && image.colours != 4) { + Error("Attempt to assign image with unexpected colours per pixel: %d",p_colours); + return; + } + + if ( !buffer || image.width != width || image.height != height || image.colours != colours || image.subpixelorder != subpixelorder) { + + if (holdbuffer && buffer) { + if (new_size > allocation) { + Error("Held buffer is undersized for assigned buffer"); + return; + } + } else { + if(new_size > allocation || !buffer) { + DumpBuffer(); + AllocBuffer(new_size); + } + } + + width = image.width; + height = image.height; + pixels = width*height; + colours = image.colours; + subpixelorder = image.subpixelorder; + size = new_size; + } + + if(image.buffer != buffer) + sse2_aligned_memcpy(buffer, image.buffer, size); } Image *Image::HighlightEdges( Rgb colour, const Box *limits ) @@ -304,7 +439,7 @@ bool Image::WriteRaw( const char *filename ) const return( true ); } -bool Image::ReadJpeg( const char *filename ) +bool Image::ReadJpeg( const char *filename, int p_colours, int p_subpixelorder) { struct jpeg_decompress_struct *cinfo = jpg_dcinfo; @@ -312,8 +447,8 @@ bool Image::ReadJpeg( const char *filename ) { cinfo = jpg_dcinfo = new jpeg_decompress_struct; cinfo->err = jpeg_std_error( &jpg_err.pub ); - jpg_err.pub.error_exit = zm_jpeg_error_exit; - jpg_err.pub.emit_message = zm_jpeg_emit_message; + jpg_err.pub.error_exit = zm_jpeg_error_exit; + jpg_err.pub.emit_message = zm_jpeg_emit_message; jpeg_create_decompress( cinfo ); } @@ -335,32 +470,94 @@ bool Image::ReadJpeg( const char *filename ) jpeg_read_header( cinfo, TRUE ); - if ( cinfo->image_width != width || cinfo->image_height != height || cinfo->num_components != colours ) + if ( cinfo->image_width != width || cinfo->image_height != height) { width = cinfo->image_width; height = cinfo->image_height; pixels = width*height; - colours = cinfo->num_components; - if ( !(colours == 1 || colours == 3) ) - { - Error( "Unexpected colours (%d) when reading jpeg image", colours ); - jpeg_abort_decompress( cinfo ); - fclose( infile ); - return( false ); - } - size = width*height*colours; - if ( !buffer || allocation < size ) - { - allocation = size; - delete[] buffer; - buffer = new uint8_t[allocation]; + } + + if ( cinfo->num_components != 1 && cinfo->num_components != 3) ) + { + Error( "Unexpected colours when reading jpeg image: %d", colours ); + jpeg_abort_decompress( cinfo ); + fclose( infile ); + return( false ); + } + + switch(p_colours) { + case ZM_COLOUR_GRAY8: + { + cinfo->out_color_space = JCS_GRAYSCALE; + colours = ZM_COLOUR_GRAY8; + subpixelorder = ZM_SUBPIX_ORDER_NONE; + break; + } + case ZM_COLOUR_RGB32: + { +#ifdef JCS_EXTENSIONS + colours = ZM_COLOUR_RGB32; + if(p_subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + cinfo->out_color_space = JCS_EXT_BGRX; + subpixelorder = ZM_SUBPIX_ORDER_BGRA; + } else if(p_subpixelorder == ZM_SUBPIX_ORDER_ARGB) { + cinfo->out_color_space = JCS_EXT_XRGB; + subpixelorder = ZM_SUBPIX_ORDER_ARGB; + } else if(p_subpixelorder == ZM_SUBPIX_ORDER_ABGR) { + cinfo->out_color_space = JCS_EXT_XBGR; + subpixelorder = ZM_SUBPIX_ORDER_ABGR; + } else { + /* Assume RGBA */ + cinfo->out_color_space = JCS_EXT_RGBX; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } + break; +#else + Warning("libjpeg-turbo is required for reading a JPEG directly into a RGB32 buffer, reading into a RGB24 buffer instead."); +#endif + } + case ZM_COLOUR_RGB24: + default: + { + colours = ZM_COLOUR_RGB24; + if(p_subpixelorder == ZM_SUBPIX_ORDER_BGR) { +#ifdef JCS_EXTENSIONS + cinfo->out_color_space = JCS_EXT_BGR; + subpixelorder = ZM_SUBPIX_ORDER_BGR; +#else + Warning("libjpeg-turbo is required for reading a JPEG directly into a BGR24 buffer, reading into a RGB24 buffer instead."); + cinfo->out_color_space = JCS_EXT_RGB; + subpixelorder = ZM_SUBPIX_ORDER_RGB; +#endif + } else { + /* Assume RGB */ + cinfo->out_color_space = JCS_RGB; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } + break; + } + } + + size = pixels*colours; + + if(buffer == NULL) { + AllocBuffer(size); + } else { + if(allocation < size) { + if(holdbuffer) { + Error("Held buffer is undersized for the requested image"); + return (false); + } else { + DumpBuffer(); + AllocBuffer(newsize); + } } } jpeg_start_decompress( cinfo ); JSAMPROW row_pointer; /* pointer to a single row */ - int row_stride = width * colours; /* physical row width in buffer */ + int row_stride = width * colours; /* physical row width in buffer */ while ( cinfo->output_scanline < cinfo->output_height ) { row_pointer = &buffer[cinfo->output_scanline * row_stride]; @@ -391,8 +588,8 @@ bool Image::WriteJpeg( const char *filename, int quality_override ) const { cinfo = jpg_ccinfo[quality] = new jpeg_compress_struct; cinfo->err = jpeg_std_error( &jpg_err.pub ); - jpg_err.pub.error_exit = zm_jpeg_error_exit; - jpg_err.pub.emit_message = zm_jpeg_emit_message; + jpg_err.pub.error_exit = zm_jpeg_error_exit; + jpg_err.pub.emit_message = zm_jpeg_emit_message; jpeg_create_compress( cinfo ); } @@ -406,15 +603,57 @@ bool Image::WriteJpeg( const char *filename, int quality_override ) const cinfo->image_width = width; /* image width and height, in pixels */ cinfo->image_height = height; - cinfo->input_components = colours; /* # of color components per pixel */ - if ( colours == 1 ) - { - cinfo->in_color_space = JCS_GRAYSCALE; /* colorspace of input image */ - } - else - { - cinfo->in_color_space = JCS_RGB; /* colorspace of input image */ + + switch(colours) { + case ZM_COLOUR_GRAY8: + { + cinfo->input_components = 1; + cinfo->in_color_space = JCS_GRAYSCALE; + break; + } + case ZM_COLOUR_RGB32: + { +#ifdef JCS_EXTENSIONS + cinfo->input_components = 3; + if(subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + cinfo->in_color_space = JCS_EXT_BGRX; + } else if(subpixelorder == ZM_SUBPIX_ORDER_ARGB) { + cinfo->in_color_space = JCS_EXT_XRGB; + } else if(subpixelorder == ZM_SUBPIX_ORDER_ABGR) { + cinfo->in_color_space = JCS_EXT_XBGR; + } else { + /* Assume RGBA */ + cinfo->in_color_space = JCS_EXT_RGBX; + } +#else + Error("libjpeg-turbo is required for JPEG encoding directly from RGB32 source"); + jpeg_abort_compress( cinfo ); + fclose(outfile); + return(false); +#endif + break; + } + case ZM_COLOUR_RGB24: + default: + { + cinfo->input_components = 3; + if(subpixelorder == ZM_SUBPIX_ORDER_BGR) { +#ifdef JCS_EXTENSIONS + cinfo->in_color_space = JCS_EXT_BGR; +#else + Error("libjpeg-turbo is required for JPEG encoding directly from BGR24 source"); + jpeg_abort_compress( cinfo ); + fclose(outfile); + return(false); +#endif + } else { + /* Assume RGB */ + cinfo->out_color_space = JCS_RGB; + } + break; + } } + jpeg_set_defaults( cinfo ); jpeg_set_quality( cinfo, quality, false ); cinfo->dct_method = JDCT_FASTEST; @@ -426,7 +665,7 @@ bool Image::WriteJpeg( const char *filename, int quality_override ) const } JSAMPROW row_pointer; /* pointer to a single row */ - int row_stride = cinfo->image_width * cinfo->input_components; /* physical row width in buffer */ + int row_stride = cinfo->image_width * colours; /* physical row width in buffer */ while ( cinfo->next_scanline < cinfo->image_height ) { row_pointer = &buffer[cinfo->next_scanline * row_stride]; @@ -440,7 +679,7 @@ bool Image::WriteJpeg( const char *filename, int quality_override ) const return( true ); } -bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size ) +bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, int p_colours, int p_subpixelorder) { struct jpeg_decompress_struct *cinfo = jpg_dcinfo; @@ -448,8 +687,8 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size ) { cinfo = jpg_dcinfo = new jpeg_decompress_struct; cinfo->err = jpeg_std_error( &jpg_err.pub ); - jpg_err.pub.error_exit = zm_jpeg_error_exit; - jpg_err.pub.emit_message = zm_jpeg_emit_message; + jpg_err.pub.error_exit = zm_jpeg_error_exit; + jpg_err.pub.emit_message = zm_jpeg_emit_message; jpeg_create_decompress( cinfo ); } @@ -463,31 +702,93 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size ) jpeg_read_header( cinfo, TRUE ); - if ( cinfo->image_width != width || cinfo->image_height != height || cinfo->num_components != colours ) + if ( cinfo->image_width != width || cinfo->image_height != height) { width = cinfo->image_width; height = cinfo->image_height; pixels = width*height; - colours = cinfo->num_components; - if ( !(colours == 1 || colours == 3) ) - { - Error( "Unexpected colours (%d) when decoding jpeg image", colours ); - jpeg_abort_decompress( cinfo ); - return( false ); - } - size = width*height*colours; - if ( !buffer || allocation < size ) - { - allocation = size; - delete[] buffer; - buffer = new uint8_t[allocation]; + } + + if ( cinfo->num_components != 1 && cinfo->num_components != 3) ) + { + Error( "Unexpected colours when reading jpeg image: %d", colours ); + jpeg_abort_decompress( cinfo ); + return( false ); + } + + switch(p_colours) { + case ZM_COLOUR_GRAY8: + { + cinfo->out_color_space = JCS_GRAYSCALE; + colours = ZM_COLOUR_GRAY8; + subpixelorder = ZM_SUBPIX_ORDER_NONE; + break; + } + case ZM_COLOUR_RGB32: + { +#ifdef JCS_EXTENSIONS + colours = ZM_COLOUR_RGB32; + if(p_subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + cinfo->out_color_space = JCS_EXT_BGRX; + subpixelorder = ZM_SUBPIX_ORDER_BGRA; + } else if(p_subpixelorder == ZM_SUBPIX_ORDER_ARGB) { + cinfo->out_color_space = JCS_EXT_XRGB; + subpixelorder = ZM_SUBPIX_ORDER_ARGB; + } else if(p_subpixelorder == ZM_SUBPIX_ORDER_ABGR) { + cinfo->out_color_space = JCS_EXT_XBGR; + subpixelorder = ZM_SUBPIX_ORDER_ABGR; + } else { + /* Assume RGBA */ + cinfo->out_color_space = JCS_EXT_RGBX; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } + break; +#else + Warning("libjpeg-turbo is required for reading a JPEG directly into a RGB32 buffer, reading into a RGB24 buffer instead."); +#endif + } + case ZM_COLOUR_RGB24: + default: + { + colours = ZM_COLOUR_RGB24; + if(p_subpixelorder == ZM_SUBPIX_ORDER_BGR) { +#ifdef JCS_EXTENSIONS + cinfo->out_color_space = JCS_EXT_BGR; + subpixelorder = ZM_SUBPIX_ORDER_BGR; +#else + Warning("libjpeg-turbo is required for reading a JPEG directly into a BGR24 buffer, reading into a RGB24 buffer instead."); + cinfo->out_color_space = JCS_EXT_RGB; + subpixelorder = ZM_SUBPIX_ORDER_RGB; +#endif + } else { + /* Assume RGB */ + cinfo->out_color_space = JCS_RGB; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } + break; + } + } + + size = pixels*colours; + + if(buffer == NULL) { + AllocBuffer(size); + } else { + if(allocation < size) { + if(holdbuffer) { + Error("Held buffer is undersized for the requested image"); + return (false); + } else { + DumpBuffer(); + AllocBuffer(newsize); + } } } jpeg_start_decompress( cinfo ); JSAMPROW row_pointer; /* pointer to a single row */ - int row_stride = width * colours; /* physical row width in buffer */ + int row_stride = width * colours; /* physical row width in buffer */ while ( cinfo->output_scanline < cinfo->output_height ) { row_pointer = &buffer[cinfo->output_scanline * row_stride]; @@ -516,8 +817,8 @@ bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_over { cinfo = jpg_ccinfo[quality] = new jpeg_compress_struct; cinfo->err = jpeg_std_error( &jpg_err.pub ); - jpg_err.pub.error_exit = zm_jpeg_error_exit; - jpg_err.pub.emit_message = zm_jpeg_emit_message; + jpg_err.pub.error_exit = zm_jpeg_error_exit; + jpg_err.pub.emit_message = zm_jpeg_emit_message; jpeg_create_compress( cinfo ); } @@ -525,15 +826,55 @@ bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_over cinfo->image_width = width; /* image width and height, in pixels */ cinfo->image_height = height; - cinfo->input_components = colours; /* # of color components per pixel */ - if ( colours == 1 ) - { - cinfo->in_color_space = JCS_GRAYSCALE; /* colorspace of input image */ - } - else - { - cinfo->in_color_space = JCS_RGB; /* colorspace of input image */ + + switch(colours) { + case ZM_COLOUR_GRAY8: + { + cinfo->input_components = 1; + cinfo->in_color_space = JCS_GRAYSCALE; + break; + } + case ZM_COLOUR_RGB32: + { +#ifdef JCS_EXTENSIONS + cinfo->input_components = 3; + if(subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + cinfo->in_color_space = JCS_EXT_BGRX; + } else if(subpixelorder == ZM_SUBPIX_ORDER_ARGB) { + cinfo->in_color_space = JCS_EXT_XRGB; + } else if(subpixelorder == ZM_SUBPIX_ORDER_ABGR) { + cinfo->in_color_space = JCS_EXT_XBGR; + } else { + /* Assume RGBA */ + cinfo->in_color_space = JCS_EXT_RGBX; + } +#else + Error("libjpeg-turbo is required for JPEG encoding directly from RGB32 source"); + jpeg_abort_compress( cinfo ); + return(false); +#endif + break; + } + case ZM_COLOUR_RGB24: + default: + { + cinfo->input_components = 3; + if(subpixelorder == ZM_SUBPIX_ORDER_BGR) { +#ifdef JCS_EXTENSIONS + cinfo->in_color_space = JCS_EXT_BGR; +#else + Error("libjpeg-turbo is required for JPEG encoding directly from BGR24 source"); + jpeg_abort_compress( cinfo ); + return(false); +#endif + } else { + /* Assume RGB */ + cinfo->out_color_space = JCS_RGB; + } + break; + } } + jpeg_set_defaults( cinfo ); jpeg_set_quality( cinfo, quality, false ); cinfo->dct_method = JDCT_FASTEST; @@ -541,7 +882,7 @@ bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_over jpeg_start_compress( cinfo, TRUE ); JSAMPROW row_pointer; /* pointer to a single row */ - int row_stride = cinfo->image_width * cinfo->input_components; /* physical row width in buffer */ + int row_stride = cinfo->image_width * colours; /* physical row width in buffer */ while ( cinfo->next_scanline < cinfo->image_height ) { row_pointer = &buffer[cinfo->next_scanline * row_stride]; @@ -605,7 +946,9 @@ bool Image::Crop( int lo_x, int lo_y, int hi_x, int hi_y ) } int new_size = new_width*new_height*colours; - uint8_t *new_buffer = new uint8_t[new_size]; + uint8_t *new_buffer = zm_allocaligned(16,new_size); + if(new_buffer == NULL) + Panic("Memory allocation failed, out of memory?"); int new_stride = new_width*colours; for ( int y = lo_y, ny = 0; y <= hi_y; y++, ny++ ) @@ -615,20 +958,13 @@ bool Image::Crop( int lo_x, int lo_y, int hi_x, int hi_y ) memcpy( pnbuf, pbuf, new_stride ); } - if ( allocation ) - { - delete[] buffer; - } + DumpBuffer(); width = new_width; height = new_height; pixels = width*height; size = allocation = new_size; buffer = new_buffer; - if ( blend_buffer ) - { - delete[] blend_buffer; - blend_buffer = 0; - } + buffertype = ZM_BUFTYPE_MALLOC; return( true ); } @@ -914,22 +1250,32 @@ Image *Image::Highlight( int n_images, Image *images[], const Rgb threshold, con return( result ); } -Image *Image::Delta( const Image &image ) const +/* New function to allow buffer re-using instead of allocationg memory for the delta image everytime */ +void Image::Delta( const Image &image, Image* targetimage) const { if ( !(width == image.width && height == image.height && colours == image.colours) ) - { - Panic( "Attempt to get delta of different sized images, expected %dx%dx%d, got %dx%dx%d", width, height, colours, image.width, image.height, image.colours ); - } - - Image *result = new Image( width, height, 1 ); - - unsigned char *psrc = buffer; - unsigned char *pref = image.buffer; - unsigned char *pdiff = result->buffer; + { + Panic( "Attempt to get delta of different sized images, expected %dx%dx%d, got %dx%dx%d", width, height, colours, image.width, image.height, image.colours ); + } + + if(bufsize < this->Size()) + { + /* Graceful handling */ + Error("Mismatched buffer size for storing delta image. Required: %u bytes Supplied: %u bytes. Trimming output buffer to match.",this->Size(),bufsize); + } + else if (bufsize > this->Size()) + { + /* Target buffer is larger. match the size to original image size */ + bufsize = this->Size(); + } + + uint8_t *psrc = buffer; + uint8_t *pref = image->Buffer(); + uint8_t *pdiff = targetbuf; if ( colours == 1 ) { - while( psrc < (buffer+size) ) + while( psrc < (buffer+bufsize) ) { //*pdiff++ = abs( *psrc++ - *pref++ ); //*pdiff++ = ABSDIFF( *psrc, *pref ); @@ -938,10 +1284,10 @@ Image *Image::Delta( const Image &image ) const //pref++; } } - else + else if ( colours == 3 ) { - register int red, green, blue; - while( psrc < (buffer+size) ) + int red, green, blue; + while( psrc < (buffer+bufsize) ) { if ( config.y_image_deltas ) { @@ -966,11 +1312,28 @@ Image *Image::Delta( const Image &image ) const //*pdiff++ = (uint8_t)sqrt((red*red + green*green + blue*blue)/3); // This just uses the average difference, much faster - *pdiff++ = (uint8_t)((red + green + blue)/3); + // *pdiff++ = (uint8_t)((red + green + blue)/3); + + /* Use fast algorithm for almost identical ITU-R BT.709 weighting */ + *pdiff++ = (red + red + blue + green + (green<<2))>>3; } } } - return( result ); + + else if ( colours == 4 ) /* RGB32 */ + { + + } +} + +/* Backwards compatibility */ +Image *Image::Delta( const Image &image ) const +{ + Image *result = new Image( width, height, 1, subpixelorder); + if(result == NULL) + Panic("Memory allocation failed, out of memory?"); + Delta(image,result->buffer,result->Size()); + return result; } const Coord Image::centreCoord( const char *text ) @@ -1010,16 +1373,19 @@ void Image::Annotate( const char *p_text, const Coord &coord, const Rgb fg_colou int line_len = 0; const char *line = text; - char fg_r_col = RGB_RED_VAL(fg_colour); - char fg_g_col = RGB_GREEN_VAL(fg_colour); - char fg_b_col = RGB_BLUE_VAL(fg_colour); - char fg_bw_col = (fg_r_col+fg_g_col+fg_b_col)/3; - bool fg_trans = (fg_colour == RGB_TRANSPARENT); - char bg_r_col = RGB_RED_VAL(bg_colour); - char bg_g_col = RGB_GREEN_VAL(bg_colour); - char bg_b_col = RGB_BLUE_VAL(bg_colour); - char bg_bw_col = (bg_r_col+bg_g_col+bg_b_col)/3; - bool bg_trans = (bg_colour == RGB_TRANSPARENT); + const uint8_t fg_r_col = RGB_RED_VAL(fg_colour); + const uint8_t fg_g_col = RGB_GREEN_VAL(fg_colour); + const uint8_t fg_b_col = RGB_BLUE_VAL(fg_colour); + const uint8_t fg_bw_col = fg_colour & 0xff; + const Rgb fg_rgb_col = rgb_convert(fg_colour,subpixelorder) + const bool fg_trans = (fg_colour == RGB_TRANSPARENT); + + const uint8_t bg_r_col = RGB_RED_VAL(bg_colour); + const uint8_t bg_g_col = RGB_GREEN_VAL(bg_colour); + const uint8_t bg_b_col = RGB_BLUE_VAL(bg_colour); + const uint8_t bg_bw_col = bg_colour & 0xff; + const Rgb bg_rgb_col = rgb_convert(bg_colour,subpixelorder); + const bool bg_trans = (bg_colour == RGB_TRANSPARENT); while ( (index < text_len) && (line_len = strcspn( line, "\n" )) ) { @@ -1075,7 +1441,7 @@ void Image::Annotate( const char *p_text, const Coord &coord, const Rgb fg_colou } } } - else + else if ( colours == 3 ) { int wc = width * colours; @@ -1106,7 +1472,40 @@ void Image::Annotate( const char *p_text, const Coord &coord, const Rgb fg_colou } } } - } + } + else if ( colours == 4) + { + int wc = width * colours; + + unsigned char *ptr = &buffer[((lo_line_y*width)+lo_line_x)*colours]; + for ( int y = lo_line_y, r = 0; y < hi_line_y && r < CHAR_HEIGHT; y++, r++, ptr += wc ) + { + Rgb* temp_ptr = ptr; + for ( int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ ) + { + int f = fontdata[(line[c] * CHAR_HEIGHT) + r]; + for ( int i = 0; i < CHAR_WIDTH && x < hi_line_x; i++, x++, temp_ptr++ ) + { + if ( f & (0x80 >> i) ) + { + if ( !fg_trans ) + { + *temp_ptr = fg_rgb_col; + } + } + else if ( !bg_trans ) + { + *temp_ptr = bg_rgb_col; + } + } + } + } + + } else { + Panic("Annontate called with unexpected colours: %d",colours); + return; + } + index += line_len; while ( text[index] == '\n' ) { @@ -1133,13 +1532,51 @@ void Image::Timestamp( const char *label, const time_t when, const Coord &coord } } -void Image::Colourise() +void Image::Colourise(const int p_reqcolours, const int p_reqsubpixelorder) { - if ( colours == 1 ) - { - colours = 3; + + Debug(9, "Colourise: Req colours: %u Req subpixel order: %u Current colours: %u Current subpixel order: %u",p_reqcolours,p_reqsubpixelorder,colours,subpixelorder); + + if ( colours != ZM_COLOUR_GRAY8) { + Warning("Target image is already colourised, colours: %u",colours); + return; + } + + if ( p_reqcolours == ZM_COLOUR_RGB32 ) { + /* RGB32 */ + unsigned int totalpixels = width * height; + Rgb* new_buffer = (Rgb*)memalign(16,totalpixels*4); + + const uint8_t *psrc = buffer; + Rgb* pdest = new_buffer; + Rgb subpixel; + Rgb newpixel; + + if ( p_reqsubpixelorder == ZM_SUBPIX_ORDER_ABGR || p_reqsubpixelorder == ZM_SUBPIX_ORDER_ARGB) { + /* ARGB\ABGR subpixel order. alpha byte is first (mem+0), so we need to shift the pixel left in the end */ + for(int i=0;iLo().X():0; int lo_y = limits?limits->Lo().Y():0; int hi_x = limits?limits->Hi().X():width-1; @@ -1205,44 +1681,112 @@ void Image::Fill( Rgb colour, const Box *limits ) } } } + else if ( colors == 4 ) /* RGB32 [R,G,B,A] */ + { + for ( unsigned int y = lo_y; y <= hi_y; y++ ) + { + Rgb *p = &buffer[colours*((y*width)+lo_x)]; +#ifdef ZM_HAS_SSE2 + unsigned int count = (hi_x+1) - lo_x; + + if(count > 32) { /* Don't bother with less than 32 pixels */ + __m128i xmm0; + Rgb srcpixels[4] __attribute__((aligned(16))) = {colour,colour,colour,colour}; + unsigned int remainder = count % 4; + count -= remainder; /* Only process multiples of 4 */ + + /* Aligned load into a XMM register */ + _mm_store_si128(&xmm0,*(__m128i*)srcpixels); + + /* Fill 4 pixels at a time */ + for (unsigned int i=0; i < count; p += 4, i += 4) + _mm_stream_si128((__m128i*)p,xmm0); + + /* Fill the remaining pixels */ + for (unsigned int i=0;iLo().X():0; int lo_y = limits?limits->Lo().Y():0; int hi_x = limits?limits->Hi().X():width-1; int hi_y = limits?limits->Hi().Y():height-1; - for ( int y = lo_y; y <= hi_y; y++ ) + if ( colours == 1 ) { - unsigned char *p = &buffer[colours*((y*width)+lo_x)]; - for ( int x = lo_x; x <= hi_x; x++, p += colours ) + for ( int y = lo_y; y <= hi_y; y++ ) { - if ( ( x == lo_x || x == hi_x || y == lo_y || y == hi_y ) || (!(x%density) && !(y%density) ) ) + unsigned char *p = &buffer[(y*width)+lo_x]; + for ( int x = lo_x; x <= hi_x; x++ ) { - if ( colours == 1 ) - { - *p = colour; - } - else if ( colours == 3 ) - { + if ( ( x == lo_x || x == hi_x || y == lo_y || y == hi_y ) || (!(x%density) && !(y%density) ) ) + *p++ = colour; + } + } + } + else if ( colours == 3 ) + { + for ( int y = lo_y; y <= hi_y; y++ ) + { + unsigned char *p = &buffer[colours*((y*width)+lo_x)]; + for ( int x = lo_x; x <= hi_x; x++ ) + { + if ( ( x == lo_x || x == hi_x || y == lo_y || y == hi_y ) || (!(x%density) && !(y%density) ) ) { RED(p) = RGB_RED_VAL(colour); GREEN(p) = RGB_GREEN_VAL(colour); BLUE(p) = RGB_BLUE_VAL(colour); + p += colours; } } } } + else if ( colours == 4 ) /* RGB32 [R,G,B,A] */ + { + for ( int y = lo_y; y <= hi_y; y++ ) + { + Rgb* p = &buffer[colours*((y*width)+lo_x)]; + /* Not possible to use SSE2 here, SSE2 doesn't have modulus instructions */ + for ( int x = lo_x; x <= hi_x; x++ ) + { + if ( ( x == lo_x || x == hi_x || y == lo_y || y == hi_y ) || (!(x%density) && !(y%density) ) ) + /* Fast, copies the entire pixel in a single pass */ + *p++ = colour; + } + } + } + } +/* RGB32 compatible: complete */ void Image::Outline( Rgb colour, const Polygon &polygon ) { - if ( !(colours == 1 || colours == 3 ) ) + if ( !(colours == 1 || colours == 3 || colours == 4 ) ) { Panic( "Attempt to outline image with unexpected colours %d", colours ); } @@ -1293,6 +1837,13 @@ void Image::Outline( Rgb colour, const Polygon &polygon ) BLUE(p) = RGB_BLUE_VAL(colour); } } + else if ( colours == 4 ) + { + for ( x = x1, y = y1; y != y2; y += yinc, x += grad ) + { + *(Rgb*)(buffer+(colours*((y*width)+int(round(x)))) = colour; + } + } } else { @@ -1325,16 +1876,24 @@ void Image::Outline( Rgb colour, const Polygon &polygon ) BLUE(p) = RGB_BLUE_VAL(colour); } } + else if ( colours == 4 ) + { + for ( y = y1, x = x1; x != x2; x += xinc, y += grad ) + { + *(Rgb*)buffer+(colours*((int(round(y))*width)+x)) = colour; + } + } + } } } void Image::Fill( Rgb colour, int density, const Polygon &polygon ) { - if ( !(colours == 1 || colours == 3 ) ) - { - Panic( "Attempt to fill image with unexpected colours %d", colours ); - } + if ( !(colours == 1 || colours == 3 || colours == 4 ) ) + { + Panic( "Attempt to fill image with unexpected colours %d", colours ); + } int n_coords = polygon.getNumCoords(); int n_global_edges = 0; @@ -1415,21 +1974,37 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon ) { int lo_x = int(round(active_edges[i++].min_x)); int hi_x = int(round(active_edges[i++].min_x)); - unsigned char *p = &buffer[colours*((y*width)+lo_x)]; - for ( int x = lo_x; x <= hi_x; x++, p += colours ) - { - if ( !(x%density) ) + if( colours == 1) { + unsigned char *p = &buffer[(y*width)+lo_x]; + for ( int x = lo_x; x <= hi_x; x++) { - //Debug( 9, " %d", x ); - if ( colours == 1 ) + if ( !(x%density) ) { - *p = colour; + //Debug( 9, " %d", x ); + *p++ = colour; } - else - { + } + } else if( colours == 3) { + unsigned char *p = &buffer[colours*((y*width)+lo_x)]; + for ( int x = lo_x; x <= hi_x; x++) + { + if ( !(x%density) ) + { RED(p) = RGB_RED_VAL(colour); GREEN(p) = RGB_GREEN_VAL(colour); BLUE(p) = RGB_BLUE_VAL(colour); + p += colours; + } + } + } else if( colours == 4) { + Rgb *p = &buffer[colours*((y*width)+lo_x)]; + /* Not possible to use SSE2 here, SSE2 doesn't have modulus instructions */ + for ( int x = lo_x; x <= hi_x; x++ ) + { + if ( !(x%density) ) + { + /* Fast, copies the entire pixel in a single pass */ + *p++ = colour; } } } @@ -1473,7 +2048,17 @@ void Image::Rotate( int angle ) { return; } - static unsigned char rotate_buffer[ZM_MAX_IMAGE_SIZE]; + + if(buffertype == ZM_BUFTYPE_DONTFREE) { + /* Don't free the buffer. Work on another one and copy back into original buffer */ + uint8_t rotate_buffer[height*width*colours]; + } else { + /* Use a new buffer, faster */ + uint8_t* rotate_buffer = memalign(16,size); + if(rotate_buffer == NULL) + Panic("Memory allocation failed: %s",strerror(errno)); + } + switch( angle ) { case 90 : @@ -1581,12 +2166,26 @@ void Image::Rotate( int angle ) break; } } - memcpy( buffer, rotate_buffer, size ); + if(buffertype == ZM_BUFTYPE_DONTFREE) { + memcpy( buffer, rotate_buffer, size ); + } else { + /* Directly assign the new buffer and make sure it will be freed when not needed anymore */ + AssignDirect( width, height, colours, subpixelorder, rotate_buffer, size, ZM_BUFTYPE_MALLOC); + } } void Image::Flip( bool leftright ) { - static unsigned char flip_buffer[ZM_MAX_IMAGE_SIZE]; + if(buffertype == ZM_BUFTYPE_DONTFREE) { + /* Don't free the buffer. Work on another one and copy back into original buffer */ + uint8_t flip_buffer[ZM_MAX_IMAGE_SIZE]; + } else { + /* Use a new buffer, faster */ + uint8_t* flip_buffer = memalign(16,size); + if(flip_buffer == NULL) + Panic("Memory allocation failed: %s",strerror(errno)); + } + int line_bytes = width*colours; int line_bytes2 = 2*line_bytes; if ( leftright ) @@ -1636,7 +2235,12 @@ void Image::Flip( bool leftright ) d_ptr += line_bytes; } } - memcpy( buffer, flip_buffer, size ); + if(buffertype == ZM_BUFTYPE_DONTFREE) { + memcpy( buffer, flip_buffer, size ); + } else { + /* Directly assign the new buffer and make sure it will be freed when not needed anymore */ + AssignDirect( width, height, colours, subpixelorder, flip_buffer, size, ZM_BUFTYPE_MALLOC); + } } void Image::Scale( unsigned int factor ) @@ -1651,9 +2255,21 @@ void Image::Scale( unsigned int factor ) return; } - static unsigned char scale_buffer[ZM_MAX_IMAGE_SIZE]; unsigned int new_width = (width*factor)/ZM_SCALE_BASE; unsigned int new_height = (height*factor)/ZM_SCALE_BASE; + + size_t scale_buffer_size = new_width * new_height * colours; + + if(buffertype == ZM_BUFTYPE_DONTFREE) { + /* Don't free the buffer. Work on another one and copy back into original buffer */ + uint8_t scale_buffer[scale_buffer_size]; + } else { + /* Use a new buffer, faster */ + uint8_t* scale_buffer = memalign(16,scale_buffer_size); + if(scale_buffer == NULL) + Panic("Memory allocation failed: %s",strerror(errno)); + } + if ( factor > ZM_SCALE_BASE ) { unsigned char *pd = scale_buffer; @@ -1740,5 +2356,705 @@ void Image::Scale( unsigned int factor ) new_width = last_w_index; new_height = last_h_index; } - Assign( new_width, new_height, colours, scale_buffer ); + + if(buffertype == ZM_BUFTYPE_DONTFREE) { + Assign( new_width, new_height, colours, subpixelorder, scale_buffer ); + } else { + /* Directly assign the new buffer and make sure it will be freed when not needed anymore */ + AssignDirect( new_width, new_height, colours, subpixelorder, scale_buffer, scale_buffer_size, ZM_BUFTYPE_MALLOC); + } } + + +/************************************************* BLEND FUNCTIONS *************************************************/ + + +__attribute__ ((noinline)) void sse2_fastblend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { + int divider; + uint32_t clearmask; + unsigned long i = 0; + + /* Attempt to match the blending percent to one of the possible values */ + if(blendpercent < 2.34375) { + // 1.5625% blending + divider = 6; + clearmask = 0x03030303; + } else if(blendpercent >= 2.34375 && blendpercent < 4.6875) { + // 3.125% blending + divider = 5; + clearmask = 0x07070707; + } else if(blendpercent >= 4.6875 && blendpercent < 9.375) { + // 6.25% blending + divider = 4; + clearmask = 0x0F0F0F0F; + } else if(blendpercent >= 9.375 && blendpercent < 18.75) { + // 12.5% blending + divider = 3; + clearmask = 0x1F1F1F1F; + } else if(blendpercent >= 18.75 && blendpercent < 37.5) { + // 25% blending + divider = 2; + clearmask = 0x3F3F3F3F; + } else if(blendpercent >= 37.5) { + // 50% blending + divider = 1; + clearmask = 0x7F7F7F7F; + } + + __asm__ __volatile__( + "movd %5, %%xmm3\n\t" + "movd %6, %%xmm4\n\t" + "pshufd $0x0, %%xmm3, %%xmm3\n\t" + "algo_sse2_blend:\n\t" + "movdqa (%0,%4),%%xmm0\n\t" + "movdqa (%1,%4),%%xmm1\n\t" + "movdqa %%xmm0,%%xmm2\n\t" + "psrlq %%xmm4,%%xmm0\n\t" + "psrlq %%xmm4,%%xmm1\n\t" + "pand %%xmm3,%%xmm1\n\t" + "pand %%xmm3,%%xmm0\n\t" + "psubb %%xmm0,%%xmm1\n\t" + "paddb %%xmm2,%%xmm1\n\t" + "movntdq %%xmm1,(%2,%4)\n\t" + "add $0x10,%4\n\t" + "cmp %3, %4\n\t" + "jb algo_sse2_blend\n\t" + : + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (clearmask), "m" (divider) + : "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "cc", "memory" + ); + +} + +__attribute__ ((noinline)) void std_fastblend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { + int divider; + unsigned long i = 0; + + /* Attempt to match the blending percent to one of the possible values */ + if(blendpercent < 2.34375) { + // 1.5625% blending + divider = 6; + } else if(blendpercent >= 2.34375 && blendpercent < 4.6875) { + // 3.125% blending + divider = 5; + } else if(blendpercent >= 4.6875 && blendpercent < 9.375) { + // 6.25% blending + divider = 4; + } else if(blendpercent >= 9.375 && blendpercent < 18.75) { + // 12.5% blending + divider = 3; + } else if(blendpercent >= 18.75 && blendpercent < 37.5) { + // 25% blending + divider = 2; + } else if(blendpercent >= 37.5) { + // 50% blending + divider = 1; + } + + for(register unsigned long i=0; i < count; i += 16, col1 += 16, col2 += 16, result += 16) { + result[0] = ((col2[0] - col1[0])>>divider) + col1[0]; + result[1] = ((col2[1] - col1[1])>>divider) + col1[1]; + result[2] = ((col2[2] - col1[2])>>divider) + col1[2]; + result[3] = ((col2[3] - col1[3])>>divider) + col1[3]; + result[4] = ((col2[4] - col1[4])>>divider) + col1[4]; + result[5] = ((col2[5] - col1[5])>>divider) + col1[5]; + result[6] = ((col2[6] - col1[6])>>divider) + col1[6]; + result[7] = ((col2[7] - col1[7])>>divider) + col1[7]; + result[8] = ((col2[8] - col1[8])>>divider) + col1[8]; + result[9] = ((col2[9] - col1[9])>>divider) + col1[9]; + result[10] = ((col2[10] - col1[10])>>divider) + col1[10]; + result[11] = ((col2[11] - col1[11])>>divider) + col1[11]; + result[12] = ((col2[12] - col1[12])>>divider) + col1[12]; + result[13] = ((col2[13] - col1[13])>>divider) + col1[13]; + result[14] = ((col2[14] - col1[14])>>divider) + col1[14]; + result[15] = ((col2[15] - col1[15])>>divider) + col1[15]; + } +} + +__attribute__ ((noinline)) void std_blend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { + double divide = blendpercent / 100.0; + double opacity = 1.0 - divide; + for(register unsigned long i=0; i < count; i++) { + result[i] = (col1[i] * opacity) + (col2[i] * divide); + } +} + + + + +/************************************************* DELTA FUNCTIONS *************************************************/ + +/* Grayscale */ +__attribute__ ((noinline)) int std_delta8_gray8(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { + /* Loop unrolling is used to work on 16 bytes (16 grayscale pixels) at a time */ + for(unsigned int i=0;i>3; + r = abs(col1[3] - col2[3]); + g = abs(col1[4] - col2[4]); + b = abs(col1[5] - col2[5]); + result[1] = (r + r + b + g + g + g + g + g)>>3; + r = abs(col1[6] - col2[6]); + g = abs(col1[7] - col2[7]); + b = abs(col1[8] - col2[8]); + result[2] = (r + r + b + g + g + g + g + g)>>3; + r = abs(col1[9] - col2[9]); + g = abs(col1[10] - col2[10]); + b = abs(col1[11] - col2[11]); + result[3] = (r + r + b + g + g + g + g + g)>>3; + } +} + +/* RGB24: BGR */ +__attribute__ ((noinline)) int std_delta8_bgr(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { + /* Loop unrolling is used to work on 12 bytes (4 rgb24 pixels) at a time */ + int r,g,b; + for(unsigned int i=0; i>3; + b = abs(col1[3] - col2[3]); + g = abs(col1[4] - col2[4]); + r = abs(col1[5] - col2[5]); + result[1] = (r + r + b + g + g + g + g + g)>>3; + b = abs(col1[6] - col2[6]); + g = abs(col1[7] - col2[7]); + r = abs(col1[8] - col2[8]); + result[2] = (r + r + b + g + g + g + g + g)>>3; + b = abs(col1[9] - col2[9]); + g = abs(col1[10] - col2[10]); + r = abs(col1[11] - col2[11]); + result[3] = (r + r + b + g + g + g + g + g)>>3; + } +} + +/* RGB32: RGBA */ +__attribute__ ((noinline)) int std_delta8_rgba(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { + /* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */ + int r,g,b; + for(unsigned int i=0; i>3; + r = abs(col1[4] - col2[4]); + g = abs(col1[5] - col2[5]); + b = abs(col1[6] - col2[6]); + result[1] = (r + r + b + g + g + g + g + g)>>3; + r = abs(col1[8] - col2[8]); + g = abs(col1[9] - col2[9]); + b = abs(col1[10] - col2[10]); + result[2] = (r + r + b + g + g + g + g + g)>>3; + r = abs(col1[12] - col2[12]); + g = abs(col1[13] - col2[13]); + b = abs(col1[14] - col2[14]); + result[3] = (r + r + b + g + g + g + g + g)>>3; + } +} + +/* RGB32: BGRA */ +__attribute__ ((noinline)) int std_delta8_bgra(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { + /* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */ + int r,g,b; + for(unsigned int i=0; i>3; + b = abs(col1[4] - col2[4]); + g = abs(col1[5] - col2[5]); + r = abs(col1[6] - col2[6]); + result[1] = (r + r + b + g + g + g + g + g)>>3; + b = abs(col1[8] - col2[8]); + g = abs(col1[9] - col2[9]); + r = abs(col1[10] - col2[10]); + result[2] = (r + r + b + g + g + g + g + g)>>3; + b = abs(col1[12] - col2[12]); + g = abs(col1[13] - col2[13]); + r = abs(col1[14] - col2[14]); + result[3] = (r + r + b + g + g + g + g + g)>>3; + } +} + +/* RGB32: ARGB */ +__attribute__ ((noinline)) int std_delta8_argb(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { + /* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */ + int r,g,b; + for(unsigned int i=0; i>3; + r = abs(col1[5] - col2[5]); + g = abs(col1[6] - col2[6]); + b = abs(col1[7] - col2[7]); + result[1] = (r + r + b + g + g + g + g + g)>>3; + r = abs(col1[9] - col2[9]); + g = abs(col1[10] - col2[10]); + b = abs(col1[11] - col2[11]); + result[2] = (r + r + b + g + g + g + g + g)>>3; + r = abs(col1[13] - col2[13]); + g = abs(col1[14] - col2[14]); + b = abs(col1[15] - col2[15]); + result[3] = (r + r + b + g + g + g + g + g)>>3; + } +} + +/* RGB32: ABGR */ +__attribute__ ((noinline)) int std_delta8_abgr(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { + /* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */ + int r,g,b; + for(unsigned int i=0; i>3; + b = abs(col1[5] - col2[5]); + g = abs(col1[6] - col2[6]); + r = abs(col1[7] - col2[7]); + result[1] = (r + r + b + g + g + g + g + g)>>3; + b = abs(col1[9] - col2[9]); + g = abs(col1[10] - col2[10]); + r = abs(col1[11] - col2[11]); + result[2] = (r + r + b + g + g + g + g + g)>>3; + b = abs(col1[13] - col2[13]); + g = abs(col1[14] - col2[14]); + r = abs(col1[15] - col2[15]); + result[3] = (r + r + b + g + g + g + g + g)>>3; + } +} + +/* Grayscale SSE2 */ +__attribute__ ((noinline)) int sse2_delta8_gray8(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { + unsigned long i = 0; + + /* Works on 16 grayscale pixels per iteration, similar to the non-SSE version above */ + /* XMM0 - unused */ + /* XMM1,2,3,4 - General purpose */ + /* XMM5 - unused */ + /* XMM6 - unused */ + /* XMM7 - unused */ + + __asm__ __volatile__ ( + "algo_sse2_delta8_gray8:\n\t" + "movdqa (%0,%4), %%xmm1\n\t" + "movdqa (%1,%4), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm3\n\t" + "movdqa %%xmm2, %%xmm4\n\t" + "pmaxub %%xmm1, %%xmm2\n\t" + "pminub %%xmm3, %%xmm4\n\t" + "psubb %%xmm4, %%xmm2\n\t" + "movntdq %%xmm2, (%2,%4)\n\t" + "add $0x10, %4\n\t" + "cmp %3, %4\n\t" + "jb algo_sse2_delta8_gray8\n\t" + : + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i) + : "%xmm1", "%xmm2", "%xmm3", "%xmm4", "cc", "memory" + ); + +} + +/* RGB32: RGBA SSSE3 */ +__attribute__ ((noinline)) int ssse3_delta8_rgba(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { + + __attribute__((aligned(16))) static uint8_t movemask[16] = {0,4,8,12,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; + unsigned long i = 0; + + /* XMM0 - clear mask - kept */ + /* XMM1,2,3 - General purpose */ + /* XMM4 - divide mask - kept */ + /* XMM5 - shuffle mask - kept */ + /* XMM6 - unused */ + /* XMM7 - unused */ + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "mov $0xff, %%eax\n\t" + "movd %%eax, %%xmm0\n\t" + "pshufd $0x0, %%xmm0, %%xmm0\n\t" + "movdqa %5, %%xmm5\n\t" + "algo_ssse3_delta8_rgba:\n\t" + "movdqa (%0,%4,4), %%xmm1\n\t" + "movdqa (%1,%4,4), %%xmm2\n\t" + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm3\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x8, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "pslld $0x2, %%xmm2\n\t" + "paddd %%xmm1, %%xmm2\n\t" + "movdqa %%xmm3, %%xmm1\n\t" + "pand %%xmm0, %%xmm1\n\t" + "paddd %%xmm1, %%xmm1\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x10, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "pshufb %%xmm5, %%xmm1\n\t" + "movd %%xmm1, %%eax\n\t" + "movnti %%eax, (%2,%4)\n\t" + "add $0x4, %4\n\t" + "cmp %3, %4\n\t" + "jb algo_ssse3_delta8_rgba\n\t" + : + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" + ); + +} + +/* RGB32: BGRA SSSE3 */ +__attribute__ ((noinline)) int ssse3_delta8_bgra(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { + + __attribute__((aligned(16))) static uint8_t movemask[16] = {0,4,8,12,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; + unsigned long i = 0; + + /* XMM0 - clear mask - kept */ + /* XMM1,2,3 - General purpose */ + /* XMM4 - divide mask - kept */ + /* XMM5 - shuffle mask - kept */ + /* XMM6 - unused */ + /* XMM7 - unused */ + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "mov $0xff, %%eax\n\t" + "movd %%eax, %%xmm0\n\t" + "pshufd $0x0, %%xmm0, %%xmm0\n\t" + "movdqa %5, %%xmm5\n\t" + "algo_ssse3_delta8_bgra:\n\t" + "movdqa (%0,%4,4), %%xmm1\n\t" + "movdqa (%1,%4,4), %%xmm2\n\t" + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm3\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x8, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "pslld $0x2, %%xmm2\n\t" + "paddd %%xmm1, %%xmm2\n\t" + "movdqa %%xmm3, %%xmm1\n\t" + "pand %%xmm0, %%xmm1\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x10, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "paddd %%xmm2, %%xmm2\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "pshufb %%xmm5, %%xmm1\n\t" + "movd %%xmm1, %%eax\n\t" + "movnti %%eax, (%2,%4)\n\t" + "add $0x4, %4\n\t" + "cmp %3, %4\n\t" + "jb algo_ssse3_delta8_bgra\n\t" + : + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" + ); + +} + +/* RGB32: ARGB SSSE3 */ +__attribute__ ((noinline)) int ssse3_delta8_argb(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { + + __attribute__((aligned(16))) static uint8_t movemask[16] = {0,4,8,12,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; + unsigned long i = 0; + + /* XMM0 - clear mask - kept */ + /* XMM1,2,3 - General purpose */ + /* XMM4 - divide mask - kept */ + /* XMM5 - shuffle mask - kept */ + /* XMM6 - unused */ + /* XMM7 - unused */ + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "mov $0xff, %%eax\n\t" + "movd %%eax, %%xmm0\n\t" + "pshufd $0x0, %%xmm0, %%xmm0\n\t" + "movdqa %5, %%xmm5\n\t" + "algo_ssse3_delta8_argb:\n\t" + "movdqa (%0,%4,4), %%xmm1\n\t" + "movdqa (%1,%4,4), %%xmm2\n\t" + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm3\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x10, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "pslld $0x2, %%xmm2\n\t" + "paddd %%xmm1, %%xmm2\n\t" + "movdqa %%xmm3, %%xmm1\n\t" + "psrld $0x8, %%xmm1\n\t" + "pand %%xmm0, %%xmm1\n\t" + "paddd %%xmm1, %%xmm1\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x18, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "pshufb %%xmm5, %%xmm1\n\t" + "movd %%xmm1, %%eax\n\t" + "movnti %%eax, (%2,%4)\n\t" + "add $0x4, %4\n\t" + "cmp %3, %4\n\t" + "jb algo_ssse3_delta8_argb\n\t" + : + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" + ); + +} + +/* RGB32: ABGR SSSE3 */ +__attribute__ ((noinline)) int ssse3_delta8_abgr(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { + + __attribute__((aligned(16))) static uint8_t movemask[16] = {0,4,8,12,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; + unsigned long i = 0; + + /* XMM0 - clear mask - kept */ + /* XMM1,2,3 - General purpose */ + /* XMM4 - divide mask - kept */ + /* XMM5 - shuffle mask - kept */ + /* XMM6 - unused */ + /* XMM7 - unused */ + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "mov $0xff, %%eax\n\t" + "movd %%eax, %%xmm0\n\t" + "pshufd $0x0, %%xmm0, %%xmm0\n\t" + "movdqa %5, %%xmm5\n\t" + "algo_ssse3_delta8_abgr:\n\t" + "movdqa (%0,%4,4), %%xmm1\n\t" + "movdqa (%1,%4,4), %%xmm2\n\t" + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm3\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x10, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "pslld $0x2, %%xmm2\n\t" + "paddd %%xmm1, %%xmm2\n\t" + "movdqa %%xmm3, %%xmm1\n\t" + "psrld $0x8, %%xmm1\n\t" + "pand %%xmm0, %%xmm1\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x18, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "paddd %%xmm2, %%xmm2\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "pshufb %%xmm5, %%xmm1\n\t" + "movd %%xmm1, %%eax\n\t" + "movnti %%eax, (%2,%4)\n\t" + "add $0x4, %4\n\t" + "cmp %3, %4\n\t" + "jb algo_ssse3_delta8_abgr\n\t" + : + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" + ); + +} + + +/************************************************* CONVERT FUNCTIONS *************************************************/ + +/* RGBA to grayscale */ +__attribute__ ((noinline)) int std_convert_rgba_gray8(uint8_t* col1, uint8_t* result, int count) { + int r,g,b; + for(unsigned int i=0; i>3; + r = col1[4]; + g = col1[5]; + b = col1[6]; + result[1] = (r + r + b + g + g + g + g + g)>>3; + r = col1[8]; + g = col1[9]; + b = col1[10]; + result[2] = (r + r + b + g + g + g + g + g)>>3; + r = col1[12]; + g = col1[13]; + b = col1[14]; + result[3] = (r + r + b + g + g + g + g + g)>>3; + } +} + +/* BGRA to grayscale */ +__attribute__ ((noinline)) int std_convert_bgra_gray8(uint8_t* col1, uint8_t* result, int count) { + int r,g,b; + for(unsigned int i=0; i>3; + b = col1[4]; + g = col1[5]; + r = col1[6]; + result[1] = (r + r + b + g + g + g + g + g)>>3; + b = col1[8]; + g = col1[9]; + r = col1[10]; + result[2] = (r + r + b + g + g + g + g + g)>>3; + b = col1[12]; + g = col1[13]; + r = col1[14]; + result[3] = (r + r + b + g + g + g + g + g)>>3; + } +} + +/* ARGB to grayscale */ +__attribute__ ((noinline)) int std_convert_argb_gray8(uint8_t* col1, uint8_t* result, int count) { + int r,g,b; + for(unsigned int i=0; i>3; + r = col1[5]; + g = col1[6]; + b = col1[7]; + result[1] = (r + r + b + g + g + g + g + g)>>3; + r = col1[9]; + g = col1[10]; + b = col1[11]; + result[2] = (r + r + b + g + g + g + g + g)>>3; + r = col1[13]; + g = col1[14]; + b = col1[15]; + result[3] = (r + r + b + g + g + g + g + g)>>3; + } +} + +/* ABGR to grayscale */ +__attribute__ ((noinline)) int std_convert_abgr_gray8(uint8_t* col1, uint8_t* result, int count) { + int r,g,b; + for(unsigned int i=0; i>3; + b = col1[5]; + g = col1[6]; + r = col1[7]; + result[1] = (r + r + b + g + g + g + g + g)>>3; + b = col1[9]; + g = col1[10]; + r = col1[11]; + result[2] = (r + r + b + g + g + g + g + g)>>3; + b = col1[13]; + g = col1[14]; + r = col1[15]; + result[3] = (r + r + b + g + g + g + g + g)>>3; + } +} + +/* RGBA to grayscale SSSE3 */ +__attribute__ ((noinline)) int ssse3_convert_rgba_gray8(uint8_t* col1, uint8_t* result, unsigned long count) { + + __attribute__((aligned(16))) uint8_t movemask[16] = {0,4,8,12,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; + unsigned long i = 0; + + /* XMM0 - clear mask - kept */ + /* XMM1,2,3 - General purpose */ + /* XMM4 - divide mask - kept */ + /* XMM5 - shuffle mask - kept */ + /* XMM6 - unused */ + /* XMM7 - unused */ + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "mov $0xff, %%eax\n\t" + "movd %%eax, %%xmm0\n\t" + "pshufd $0x0, %%xmm0, %%xmm0\n\t" + "movdqa %4, %%xmm5\n\t" + "algo_ssse3_convert_rgba_gray8:\n\t" + "movdqa (%0,%3,4), %%xmm3\n\t" + "psrlq $0x3, %%xmm3\n\t" + "pand %%xmm4, %%xmm3\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x8, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "pslld $0x2, %%xmm2\n\t" + "paddd %%xmm1, %%xmm2\n\t" + "movdqa %%xmm3, %%xmm1\n\t" + "pand %%xmm0, %%xmm1\n\t" + "paddd %%xmm1, %%xmm1\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x10, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "pshufb %%xmm5, %%xmm1\n\t" + "movd %%xmm1, %%eax\n\t" + "movnti %%eax, (%1,%3)\n\t" + "add $0x4, %3\n\t" + "cmp %2, %3\n\t" + "jb algo_ssse3_convert_rgba_gray8\n\t" + : + : "r" (col1), "r" (result), "r" (count), "r" (i), "m" (*movemask) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" + ); +} + diff --git a/src/zm_image.h b/src/zm_image.h index 9d57df5a2..f8d831e94 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -34,6 +34,12 @@ extern "C" #include #endif // HAVE_ZLIB_H +#define ZM_BUFTYPE_DONTFREE 0 +#define ZM_BUFTYPE_MALLOC 1 +#define ZM_BUFTYPE_NEW 2 +#define ZM_BUFTYPE_AVMALLOC 3 +#define ZM_BUFTYPE_ZM 4 + // // This is image class, and represents a frame captured from a // camera in raw form. @@ -41,8 +47,6 @@ extern "C" class Image { protected: - typedef unsigned char BlendTable[256][256]; - typedef BlendTable *BlendTablePtr; struct Edge { @@ -65,10 +69,37 @@ protected: return( int(e1->min_x - e2->min_x) ); } }; + + inline void DumpBuffer() { + if (buffer && buffertype != ZM_BUFTYPE_DONTFREE) { + if(buffertype == ZM_BUFTYPE_ZM) + zm_freealigned(buffer); + else if(buffertype == ZM_BUFTYPE_MALLOC) + free(buffer); + else if(buffertype == ZM_BUFTYPE_NEW) + delete buffer; + else if(buffertype == ZM_BUFTYPE_AVMALLOC) + av_free(buffer); + } + buffer = NULL; + allocation = 0; + } + + inline void AllocBuffer(size_t p_bufsize) { + if(buffer) + DumpBuffer(); + + buffer = (uint8_t*)zm_mallocaligned(16,p_bufsize); + if(buffer == NULL) + Panic("Memory allocation failed: %s",strerror(errno)); + + buffertype = ZM_BUFTYPE_ZM; + allocation = p_bufsize; + } public: enum { CHAR_HEIGHT=11, CHAR_WIDTH=6 }; - enum { LINE_HEIGHT=CHAR_HEIGHT+0 }; + enum { LINE_HEIGHT=CHAR_HEIGHT+0 }; protected: static bool initialised; @@ -76,33 +107,30 @@ protected: static unsigned char *y_r_table; static unsigned char *y_g_table; static unsigned char *y_b_table; - static BlendTablePtr blend_tables[101]; static jpeg_compress_struct *jpg_ccinfo[100]; static jpeg_decompress_struct *jpg_dcinfo; static struct zm_error_mgr jpg_err; protected: - int width; + int width; int height; int pixels; int colours; int size; - int allocation; + int subpixelorder; + unsigned long allocation; uint8_t *buffer; - bool our_buffer; + int buffertype; /* 0=not ours, no need to call free(), 1=malloc() buffer, 2=new buffer */ + int holdbuffer; /* Hold the buffer instead of replacing it with new one */ char text[1024]; -protected: - mutable uint16_t *blend_buffer; - protected: static void Initialise(); - static BlendTablePtr GetBlendTable( int ); public: Image(); Image( const char *filename ); - Image( int p_width, int p_height, int p_colours, uint8_t *p_buffer=0 ); + Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer=0); Image( const Image &p_image ); ~Image(); @@ -110,13 +138,33 @@ public: inline int Height() const { return( height ); } inline int Pixels() const { return( pixels ); } inline int Colours() const { return( colours ); } + inline int SubpixelOrder const { return( subpixelorder ); } inline int Size() const { return( size ); } - inline uint8_t *Buffer() const { return( buffer ); } - inline uint8_t *Buffer( unsigned int x, unsigned int y= 0 ) const { return( &buffer[colours*((y*width)+x)] ); } - void Empty(); - void Assign( int p_width, int p_height, int p_colours, unsigned char *new_buffer ); + /* Internal buffer should not be modified from functions outside of this class */ + inline const uint8_t* Buffer() const { return( buffer ); } + inline const uint8_t* Buffer( unsigned int x, unsigned int y= 0 ) const { return( &buffer[colours*((y*width)+x)] ); } + /* Request writeable buffer */ + uint8_t* WriteBuffer(const int p_width, const int p_height, const int p_colours, const int p_subpixelorder); + + inline int IsBufferHeld() const { + return holdbuffer; + } + + inline void HoldBuffer(int tohold) { + holdbuffer = tohold; + } + + inline void Empty() { + if(!holdbuffer) + DumpBuffer(); + + width = height = colours = size = pixels = subpixelorder = 0; + } + + void Assign( int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t* new_buffer ); void Assign( const Image &image ); + void AssignDirect( const int p_width, const int p_height, const int p_colours, const int p_subpixelorder, const uint8_t *new_buffer, const size_t buffer_size, const int p_buffertype); inline void CopyBuffer( const Image &image ) { @@ -124,20 +172,20 @@ public: { Panic( "Attempt to copy different size image buffers, expected %d, got %d", size, image.size ); } - memcpy( buffer, image.buffer, size ); + sse2_aligned_memcpy( buffer, image->Buffer(), size ); } inline Image &operator=( const unsigned char *new_buffer ) { - memcpy( buffer, new_buffer, size ); + sse2_aligned_memcpy( buffer, new_buffer, size ); return( *this ); } bool ReadRaw( const char *filename ); bool WriteRaw( const char *filename ) const; - bool ReadJpeg( const char *filename ); + bool ReadJpeg( const char *filename, int p_colours, int p_subpixelorder); bool WriteJpeg( const char *filename, int quality_override=0 ) const; - bool DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size ); + bool DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, int p_colours, int p_subpixelorder); bool EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_override=0 ) const; #if HAVE_ZLIB_H @@ -154,9 +202,10 @@ public: static Image *Merge( int n_images, Image *images[] ); static Image *Merge( int n_images, Image *images[], double weight ); static Image *Highlight( int n_images, Image *images[], const Rgb threshold=RGB_BLACK, const Rgb ref_colour=RGB_RED ); - Image *Delta( const Image &image ) const; + //Image *Delta( const Image &image ) const; + void Image::Delta( const Image &image, Image* targetimage) const; - const Coord centreCoord( const char *text ); + const Coord centreCoord( const char *text ) const; void Annotate( const char *p_text, const Coord &coord, const Rgb fg_colour=RGB_WHITE, const Rgb bg_colour=RGB_BLACK ); Image *HighlightEdges( Rgb colour, const Box *limits=0 ); //Image *HighlightEdges( Rgb colour, const Polygon &polygon ); @@ -173,8 +222,12 @@ public: void Rotate( int angle ); void Flip( bool leftright ); - void Scale( unsigned int factor ); }; #endif // ZM_IMAGE_H + + +typedef void (*blend_fptr_t)(uint8_t*, uint8_t*, uint8_t*, unsigned long, double); +typedef void (*delta_fptr_t)(uint8_t*, uint8_t*, uint8_t*, unsigned long); + diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 49d08d3a6..d8494c557 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -46,6 +46,19 @@ static int vidioctl( int fd, int request, void *arg ) static PixelFormat getFfPixFormatFromV4lPalette( int v4l_version, int palette ) { PixelFormat pixFormat = PIX_FMT_NONE; + + /* Check the endianness of the machine */ + uint32_t checkval = 0xAABBCCDD; + int BigEndian; + if(*(unsigned char*)&checkval == 0xDD) + BigEndian = 0; + else if(*(unsigned char*)&checkval == 0xAA) + BigEndian = 1; + else { + Error("Unable to detect the processor's endianness. Assuming little-endian."); + BigEndian = 0; + } + #if ZM_HAS_V4L2 if ( v4l_version == 2 ) { @@ -53,7 +66,7 @@ static PixelFormat getFfPixFormatFromV4lPalette( int v4l_version, int palette ) { #ifdef V4L2_PIX_FMT_RGB444 case V4L2_PIX_FMT_RGB444 : - pixFormat = PIX_FMT_RGB32; + pixFormat = PIX_FMT_RGB444; break; #endif // V4L2_PIX_FMT_RGB444 case V4L2_PIX_FMT_RGB555 : @@ -177,21 +190,27 @@ static PixelFormat getFfPixFormatFromV4lPalette( int v4l_version, int palette ) { switch( palette ) { + case VIDEO_PALETTE_RGB32 : + if(BigEndian) + pixFormat = PIX_FMT_RGBA; + else + pixFormat = PIX_FMT_BGRA; // Or should it be ABGR? + break; + case VIDEO_PALETTE_RGB24 : + if(BigEndian) + pixFormat = PIX_FMT_RGB24; + else + pixFormat = PIX_FMT_BGR24; + break; + case VIDEO_PALETTE_GREY : + pixFormat = PIX_FMT_GRAY8; + break; case VIDEO_PALETTE_RGB555 : pixFormat = PIX_FMT_RGB555; break; case VIDEO_PALETTE_RGB565 : pixFormat = PIX_FMT_RGB565; break; - case VIDEO_PALETTE_RGB24 : - if ( config.local_bgr_invert ) - pixFormat = PIX_FMT_BGR24; - else - pixFormat = PIX_FMT_RGB24; - break; - case VIDEO_PALETTE_GREY : - pixFormat = PIX_FMT_GRAY8; - break; case VIDEO_PALETTE_YUYV : case VIDEO_PALETTE_YUV422 : pixFormat = PIX_FMT_YUYV422; @@ -270,12 +289,8 @@ short *LocalCamera::b_u_table; LocalCamera *LocalCamera::last_camera = NULL; -LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, int p_standard, const std::string &p_method, int p_width, int p_height, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : -#if ZM_HAS_V4L2 - Camera( p_id, LOCAL_SRC, p_width, p_height, (p_palette==V4L2_PIX_FMT_GREY?1:3), p_brightness, p_contrast, p_hue, p_colour, p_capture ), -#elif ZM_HAS_V4L1 - Camera( p_id, LOCAL_SRC, p_width, p_height, (p_palette==VIDEO_PALETTE_GREY?1:3), p_brightness, p_contrast, p_hue, p_colour, p_capture ), -#endif // ZM_HAS_V4L2 +LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, int p_standard, const std::string &p_method, int p_width, int p_height, int p_colours, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : + Camera( p_id, LOCAL_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ), device( p_device ), channel( p_channel ), standard( p_standard ), @@ -322,8 +337,128 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, if ( width != last_camera->width || height != last_camera->height ) Warning( "Different capture sizes defined for monitors sharing same device, results may be unpredictable or completely wrong" ); } + + /* The V4L1 API doesn't care about endianness, which is why RGB32 and RGB24 in V4L1 are actually BGR32 and BGR24 on little endian machines. */ + /* Check the endianness of the machine */ + uint32_t checkval = 0xAABBCCDD; + int BigEndian; + if(*(unsigned char*)&checkval == 0xDD) + BigEndian = 0; + else if(*(unsigned char*)&checkval == 0xAA) + BigEndian = 1; + else { + Error("Unable to detect the processor's endianness. Assuming little-endian."); + BigEndian = 0; + } + + /* Set the correct colours, subpixel order and ffmpeg image format based on colours, palette and endianness */ +#if ZM_HAS_V4L2 + if ( v4l_version == 2 ) { + switch( palette ) + { + case V4L2_PIX_FMT_RGB32 : + colours = 4; + /* Not sure whats the correct format here, Some say ARGB, some say RGBA. */ + subpixelorder = ZM_SUBPIX_ORDER_ARGB; +#if HAVE_LIBSWSCALE + imagePixFormat = PIX_FMT_ARGB; +#endif + break; + case V4L2_PIX_FMT_BGR32 : + colours = 4; + subpixelorder = ZM_SUBPIX_ORDER_BGRA; +#if HAVE_LIBSWSCALE + imagePixFormat = PIX_FMT_BGRA; +#endif + break; + case V4L2_PIX_FMT_RGB24 : + colours = 3; + subpixelorder = ZM_SUBPIX_ORDER_RGB; +#if HAVE_LIBSWSCALE + imagePixFormat = PIX_FMT_RGB24; +#endif + break; + case V4L2_PIX_FMT_BGR24 : + colours = 3; + subpixelorder = ZM_SUBPIX_ORDER_BGR; +#if HAVE_LIBSWSCALE + imagePixFormat = PIX_FMT_BGR24; +#endif + break; + case V4L2_PIX_FMT_GREY : + colours = 1; + subpixelorder = ZM_SUBPIX_ORDER_NONE; /* Not needed but just in case */ +#if HAVE_LIBSWSCALE + imagePixFormat = PIX_FMT_GRAY8; +#endif + break; + default : + /* Use RGB24 for formas other than grayscale and RGB32\BGR32 and use RGB subpixel order */ + colours = 3; + subpixelorder = ZM_SUBPIX_ORDER_RGB; +#if HAVE_LIBSWSCALE + imagePixFormat = PIX_FMT_RGB24; +#endif + break; + } + } +#endif // ZM_HAS_V4L2 +#if ZM_HAS_V4L1 + if ( v4l_version == 1) { + switch( palette ) + { + case VIDEO_PALETTE_RGB32 : + colours = 4; + if(BigEndian) { + subpixelorder = ZM_SUBPIX_ORDER_RGBA; +#if HAVE_LIBSWSCALE + imagePixFormat = PIX_FMT_RGBA; +#endif + } else { + /* TODO: Verify that RGB32 in V4L1 on little-endian is BGRA and not ABGR */ + subpixelorder = ZM_SUBPIX_ORDER_BGRA; +#if HAVE_LIBSWSCALE + imagePixFormat = PIX_FMT_BGRA; // Or should it be ABGR? +#endif + } + break; + case VIDEO_PALETTE_RGB24 : + colours = 3; + if(BigEndian) { + subpixelorder = ZM_SUBPIX_ORDER_RGB; +#if HAVE_LIBSWSCALE + imagePixFormat = PIX_FMT_RGB24; +#endif + } else { + subpixelorder = ZM_SUBPIX_ORDER_BGR; +#if HAVE_LIBSWSCALE + imagePixFormat = PIX_FMT_BGR24; +#endif + } + break; + case VIDEO_PALETTE_GREY : + colours = 3; + subpixelorder = ZM_SUBPIX_ORDER_NONE; +#if HAVE_LIBSWSCALE + imagePixFormat = PIX_FMT_GRAY8; +#endif + break; + default : + /* Use RGB24 for formas other than grayscale and RGB32\BGR32 and use RGB subpixel order */ + colours = 3; + subpixelorder = ZM_SUBPIX_ORDER_RGB; +#if HAVE_LIBSWSCALE + imagePixFormat = PIX_FMT_RGB24; +#endif + break; + } + } +#endif // ZM_HAS_V4L1 + + /* Fix the image size to be correct, based on the colours */ + imagesize = pixels * colours; + #if HAVE_LIBSWSCALE - imagePixFormat = (colours==1)?PIX_FMT_GRAY8:PIX_FMT_RGB24; capturePixFormat = getFfPixFormatFromV4lPalette( v4l_version, palette ); #endif // HAVE_LIBSWSCALE } @@ -404,8 +539,6 @@ void LocalCamera::Initialise() { Warning( "Failed to set V4L2 field to %d, falling back to auto", config.v4l2_capture_fields ); v4l2_data.fmt.fmt.pix.field = V4L2_FIELD_ANY; - if ( vidioctl( vid_fd, VIDIOC_S_FMT, &v4l2_data.fmt ) < 0 ) - Fatal( "Failed to set video format: %s", strerror(errno) ); } } if ( vidioctl( vid_fd, VIDIOC_S_FMT, &v4l2_data.fmt ) < 0 ) @@ -550,25 +683,31 @@ void LocalCamera::Initialise() switch (vid_pic.palette = palette) { + case VIDEO_PALETTE_RGB32 : + { + vid_pic.depth = 32; + break; + } + case VIDEO_PALETTE_RGB24 : + { + vid_pic.depth = 24; + break; + } case VIDEO_PALETTE_GREY : { vid_pic.depth = 8; break; - } + } case VIDEO_PALETTE_RGB565 : case VIDEO_PALETTE_YUYV : case VIDEO_PALETTE_YUV422 : case VIDEO_PALETTE_YUV420P : case VIDEO_PALETTE_YUV422P : + default: { vid_pic.depth = 16; break; } - case VIDEO_PALETTE_RGB24 : - { - vid_pic.depth = 24; - break; - } } if ( brightness >= 0 ) vid_pic.brightness = brightness; @@ -964,7 +1103,8 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers else sprintf( output, "error%d\n", errno ); - return( false ); + /* Crop detection failure is not fatal and cropping is not used anyway, so no reason not to continue */ + /* return( false ); */ } else if ( verbose ) { @@ -1081,6 +1221,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers if ( version == 1 ) { struct video_capability vid_cap; + memset( &vid_cap, 0, sizeof(video_capability) ); if ( ioctl( vid_fd, VIDIOCGCAP, &vid_cap ) < 0 ) { Error( "Failed to get video capabilities: %s", strerror(errno) ); @@ -1130,6 +1271,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers } struct video_window vid_win; + memset( &vid_win, 0, sizeof(video_window) ); if ( ioctl( vid_fd, VIDIOCGWIN, &vid_win ) < 0 ) { Error( "Failed to get window attributes: %s", strerror(errno) ); @@ -1156,6 +1298,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers } struct video_picture vid_pic; + memset( &vid_cap, 0, sizeof(video_picture) ); if ( ioctl( vid_fd, VIDIOCGPICT, &vid_pic ) < 0 ) { Error( "Failed to get picture attributes: %s", strerror(errno) ); @@ -1209,6 +1352,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers for ( int chan = 0; chan < vid_cap.channels; chan++ ) { struct video_channel vid_src; + memset( &vid_src, 0, sizeof(video_channel) ); vid_src.channel = chan; if ( ioctl( vid_fd, VIDIOCGCHAN, &vid_src ) < 0 ) { @@ -1300,6 +1444,7 @@ int LocalCamera::Brightness( int p_brightness ) if ( v4l_version == 1 ) { struct video_picture vid_pic; + memset( &vid_pic, 0, sizeof(video_picture) ); if ( ioctl( vid_fd, VIDIOCGPICT, &vid_pic) < 0 ) { Error( "Failed to get picture attributes: %s", strerror(errno) ); @@ -1358,6 +1503,7 @@ int LocalCamera::Hue( int p_hue ) if ( v4l_version == 1 ) { struct video_picture vid_pic; + memset( &vid_pic, 0, sizeof(video_picture) ); if ( ioctl( vid_fd, VIDIOCGPICT, &vid_pic) < 0 ) { Error( "Failed to get picture attributes: %s", strerror(errno) ); @@ -1416,6 +1562,7 @@ int LocalCamera::Colour( int p_colour ) if ( v4l_version == 1 ) { struct video_picture vid_pic; + memset( &vid_pic, 0, sizeof(video_picture) ); if ( ioctl( vid_fd, VIDIOCGPICT, &vid_pic) < 0 ) { Error( "Failed to get picture attributes: %s", strerror(errno) ); @@ -1474,6 +1621,7 @@ int LocalCamera::Contrast( int p_contrast ) if ( v4l_version == 1 ) { struct video_picture vid_pic; + memset( &vid_pic, 0, sizeof(video_picture) ); if ( ioctl( vid_fd, VIDIOCGPICT, &vid_pic) < 0 ) { Error( "Failed to get picture attributes: %s", strerror(errno) ); @@ -1554,7 +1702,7 @@ int LocalCamera::Capture( Image &image ) { Debug( 3, "Capturing" ); - static unsigned char *buffer = 0; + uint8_t* buffer = NULL; int captures_per_frame = 1; if ( channel_count > 1 ) @@ -1641,31 +1789,45 @@ int LocalCamera::Capture( Image &image ) #if HAVE_LIBSWSCALE Debug( 3, "Doing format conversion" ); - static struct SwsContext *imgConversionContext = 0; + static struct SwsContext *imgConversionContext = NULL; static AVFrame *tmpPicture = NULL; - + static int pSize = ZM_MAX_IMAGE_SIZE; + uint8_t* swscale_buffer = NULL; if ( imagePixFormat != capturePixFormat || captureWidth != width || captureHeight != height ) { if ( !imgConversionContext ) { +#ifdef ZM_HAS_SSE2 + imgConversionContext = sws_getCachedContext( NULL, captureWidth, captureHeight, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL ); +#else imgConversionContext = sws_getCachedContext( NULL, captureWidth, captureHeight, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL ); +#endif if ( !imgConversionContext ) Fatal( "Unable to initialise image scaling context" ); tmpPicture = avcodec_alloc_frame(); if ( !tmpPicture ) Fatal( "Could not allocate temporary picture" ); - int pictureSize = avpicture_get_size( imagePixFormat, width, height ); - uint8_t *tmpPictureBuf = (uint8_t *)av_malloc(pictureSize); - if (!tmpPictureBuf) - Fatal( "Could not allocate temporary picture buffer" ); - avpicture_fill( (AVPicture *)tmpPicture, tmpPictureBuf, imagePixFormat, width, height ); - } - sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize ); - buffer = tmpPicture->data[0]; + pSize = avpicture_get_size( imagePixFormat, width, height ); + } + /* Write the output image directly into the shared memory */ + swscale_buffer = image.WriteBuffer(width,height,colours,subpixelorder); + if(swscale_buffer == NULL) { + Error("Failed requesting writeable buffer for swscale conversion for the captured image."); + return (-1); + } + avpicture_fill( (AVPicture *)tmpPicture, swscale_buffer, imagePixFormat, width, height ); + sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize ); + + buffer = tmpPicture->data[0]; } #else // HAVE_LIBSWSCALE - static unsigned char temp_buffer[ZM_MAX_IMAGE_SIZE]; + uint8_t* directbuffer = image.WriteBuffer(width,height,colours,subpixelorder); + if(directbuffer == NULL) { + Error("Failed requesting writeable buffer for the captured image."); + return (-1); + } + switch( palette ) { #if ZM_HAS_V4L1 @@ -1679,7 +1841,7 @@ int LocalCamera::Capture( Image &image ) static char u_plane[ZM_MAX_IMAGE_DIM]; static char v_plane[ZM_MAX_IMAGE_DIM]; - unsigned char *rgb_ptr = temp_buffer; + unsigned char *rgb_ptr = directbuffer; unsigned char *y_ptr = y_plane; char *u1_ptr = u_plane; char *u2_ptr = u_plane+width; @@ -1742,7 +1904,7 @@ int LocalCamera::Capture( Image &image ) *rgb_ptr++ = g<0?0:(g>255?255:g); *rgb_ptr++ = b<0?0:(b>255?255:b); } - buffer = temp_buffer; + buffer = directbuffer; break; } #if ZM_HAS_V4L1 @@ -1756,7 +1918,7 @@ int LocalCamera::Capture( Image &image ) static char u_plane[ZM_MAX_IMAGE_DIM]; static char v_plane[ZM_MAX_IMAGE_DIM]; - unsigned char *rgb_ptr = temp_buffer; + unsigned char *rgb_ptr = directbuffer; unsigned char *y_ptr = y_plane; char *u1_ptr = u_plane; char *v1_ptr = v_plane; @@ -1804,7 +1966,7 @@ int LocalCamera::Capture( Image &image ) *rgb_ptr++ = g<0?0:(g>255?255:g); *rgb_ptr++ = b<0?0:(b>255?255:b); } - buffer = temp_buffer; + buffer = directbuffer; break; } #if ZM_HAS_V4L1 @@ -1817,7 +1979,7 @@ int LocalCamera::Capture( Image &image ) { int size = width*height*2; unsigned char *s_ptr = buffer; - unsigned char *d_ptr = temp_buffer; + unsigned char *d_ptr = directbuffer; int y1,y2,u,v; int r,g,b; @@ -1844,7 +2006,7 @@ int LocalCamera::Capture( Image &image ) *d_ptr++ = g<0?0:(g>255?255:g); *d_ptr++ = b<0?0:(b>255?255:b); } - buffer = temp_buffer; + buffer = directbuffer; break; } #if ZM_HAS_V4L1 @@ -1857,7 +2019,7 @@ int LocalCamera::Capture( Image &image ) int size = width*height*2; unsigned char r,g,b; unsigned char *s_ptr = buffer; - unsigned char *d_ptr = temp_buffer; + unsigned char *d_ptr = directbuffer; for ( int i = 0; i < size; i += 2 ) { b = ((*s_ptr)<<3)&0xf8; @@ -1869,7 +2031,7 @@ int LocalCamera::Capture( Image &image ) *d_ptr++ = b; s_ptr += 2; } - buffer = temp_buffer; + buffer = directbuffer; break; } #if ZM_HAS_V4L1 @@ -1882,7 +2044,7 @@ int LocalCamera::Capture( Image &image ) int size = width*height*2; unsigned char r,g,b; unsigned char *s_ptr = buffer; - unsigned char *d_ptr = temp_buffer; + unsigned char *d_ptr = directbuffer; for ( int i = 0; i < size; i += 2 ) { b = ((*s_ptr)<<3)&0xf8; @@ -1894,46 +2056,9 @@ int LocalCamera::Capture( Image &image ) *d_ptr++ = b; s_ptr += 2; } - buffer = temp_buffer; + buffer = directbuffer; break; } -#if ZM_HAS_V4L1 - case VIDEO_PALETTE_RGB24 : - { - if ( config.local_bgr_invert ) - { - int size = width*height*3; - unsigned char *s_ptr = buffer; - unsigned char *d_ptr = temp_buffer; - for ( int i = 0; i < size; i += 3 ) - { - *d_ptr++ = *(s_ptr+2); - *d_ptr++ = *(s_ptr+1); - *d_ptr++ = *s_ptr; - s_ptr += 3; - } - buffer = temp_buffer; - } - break; - } -#endif // ZM_HAS_V4L1 -#if ZM_HAS_V4L2 - case V4L2_PIX_FMT_BGR24 : - { - int size = width*height*3; - unsigned char *s_ptr = buffer; - unsigned char *d_ptr = temp_buffer; - for ( int i = 0; i < size; i += 3 ) - { - *d_ptr++ = *(s_ptr+2); - *d_ptr++ = *(s_ptr+1); - *d_ptr++ = *s_ptr; - s_ptr += 3; - } - buffer = temp_buffer; - break; - } -#endif // ZM_HAS_V4L2 #if ZM_HAS_V4L1 case VIDEO_PALETTE_GREY : #endif // ZM_HAS_V4L1 @@ -1958,8 +2083,22 @@ int LocalCamera::Capture( Image &image ) #endif // HAVE_LIBSWSCALE } - Debug( 3, "Assigning image" ); - image.Assign( width, height, colours, buffer ); + Debug( 3, "Assigning image" ); +#if HAVE_LIBSWSCALE + if(swscale_buffer) + /* A swsscale conversion was peformed with the output being stored directly into the shared memory */ + image.AssignDirect( width, height, colours, subpixelorder, buffer, imagesize, ZM_BUFTYPE_DONTFREE); + else + /* No conversion was performed, the image is in the V4L buffers and needs to be copied into the shared memory */ + image.Assign( width, height, colours, subpixelorder, buffer, imagesize); +#else + if(directbuffer == buffer) + /* A conversion was performed with the output being stored directly into the shared memory */ + image.AssignDirect( width, height, colours, subpixelorder, buffer, imagesize, ZM_BUFTYPE_DONTFREE); + else + /* No conversion was performed, the image is in the V4L buffers and needs to be copied into the shared memory */ + image.Assign( width, height, colours, subpixelorder, buffer, imagesize); +#endif return( 0 ); } diff --git a/src/zm_local_camera.h b/src/zm_local_camera.h index 55b0808a7..b3b75a328 100644 --- a/src/zm_local_camera.h +++ b/src/zm_local_camera.h @@ -113,7 +113,7 @@ protected: static LocalCamera *last_camera; public: - LocalCamera( int p_id, const std::string &device, int p_channel, int p_format, const std::string &p_method, int p_width, int p_height, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ); + LocalCamera( int p_id, const std::string &device, int p_channel, int p_format, const std::string &p_method, int p_width, int p_height, int p_colours, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ); ~LocalCamera(); void Initialise(); diff --git a/src/zm_mem_utils.h b/src/zm_mem_utils.h index 50804b813..0a462073b 100644 --- a/src/zm_mem_utils.h +++ b/src/zm_mem_utils.h @@ -20,6 +20,37 @@ #ifndef ZM_MEM_UTILS_H #define ZM_MEM_UTILS_H + +inline void* zm_mallocaligned(unsigned int reqalignment, size_t reqsize) { + uint8_t* alloc; + uint8_t* retptr; +#if HAVE_POSIX_MEMALIGN + if(posix_memalign(&alloc,reqalignment,reqsize) != 0) + return NULL; +#else + retptr = (uint8_t*)malloc(reqsize+reqalignment+sizeof(void*)); + + if(retptr == NULL) + return NULL; + + if((retptr % reqalignment) != 0) + alloc = retptr + (reqalignment - (retptr % reqalignment)); + + /* Store a pointer before to the start of the block, just before returned aligned memory */ + *(alloc - sizeof(void*)) = retptr; +#endif + return alloc; +} + +inline void zm_freealigned(void* ptr) { +#if HAVE_POSIX_MEMALIGN + free(ptr); +#else + /* Start of block is stored before the block if it was allocated by zm_mallocaligned */ + free((void*)*((uint8_t*)ptr - sizeof(void*))); +#endif +} + inline char *mempbrk( register const char *s, const char *accept, size_t limit ) { if ( limit <= 0 || !s || !accept || !*accept ) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index ea167c812..89de1b1c0 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -285,8 +285,8 @@ Monitor::Monitor( ref_blend_perc( p_ref_blend_perc ), track_motion( p_track_motion ), signal_check_colour( p_signal_check_colour ), - image( width, height, p_camera->Colours() ), - ref_image( width, height, p_camera->Colours() ), + delta_image( width, height, ZM_COLOUR_GRAY8, ZM_SUBPIX_ORDER_NONE ), + ref_image( width, height, p_camera->Colours(), p_camera->SubpixelOrder() ), purpose( p_purpose ), camera( p_camera ), n_zones( p_n_zones ), @@ -342,7 +342,8 @@ Monitor::Monitor( mem_size = sizeof(SharedData) + sizeof(TriggerData) + (image_buffer_count*sizeof(struct timeval)) - + (image_buffer_count*camera->ImageSize()); + + (image_buffer_count*camera->ImageSize()) + + 64; /* Padding used to permit aligning the images buffer to 16 byte boundary */ Debug( 1, "mem.size=%d", mem_size ); #if ZM_MEM_MAPPED @@ -392,6 +393,11 @@ Monitor::Monitor( trigger_data = (TriggerData *)((char *)shared_data + sizeof(SharedData)); struct timeval *shared_timestamps = (struct timeval *)((char *)trigger_data + sizeof(TriggerData)); unsigned char *shared_images = (unsigned char *)((char *)shared_timestamps + (image_buffer_count*sizeof(struct timeval))); + + if((shared_images % 16) != 0) { + /* Align images buffer to nearest 16 byte boundary */ + shared_images += (16 - (shared_images % 16)); + } if ( purpose == CAPTURE ) { @@ -444,7 +450,8 @@ Monitor::Monitor( for ( int i = 0; i < image_buffer_count; i++ ) { image_buffer[i].timestamp = &(shared_timestamps[i]); - image_buffer[i].image = new Image( width, height, camera->Colours(), &(shared_images[i*camera->ImageSize()]) ); + image_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder(), &(shared_images[i*camera->ImageSize()]) ); + image_buffer[i].image->HoldBuffer(true); /* Don't release the internal buffer or replace it with another */ } if ( !n_zones ) { @@ -503,7 +510,7 @@ Monitor::Monitor( Warning( "Waiting for capture daemon" ); sleep( 1 ); } - ref_image.Assign( width, height, camera->Colours(), image_buffer[shared_data->last_write_index].image->Buffer() ); + ref_image.Assign( width, height, camera->Colours(), camera->SubpixelOrder(), image_buffer[shared_data->last_write_index].image->Buffer()); n_linked_monitors = 0; linked_monitors = 0; @@ -997,9 +1004,13 @@ void Monitor::DumpImage( Image *dump_image ) const bool Monitor::CheckSignal( const Image *image ) { static bool static_undef = true; + /* RGB24 colors */ static unsigned char red_val; static unsigned char green_val; static unsigned char blue_val; + + static Rgb color_val; /* RGB32 color */ + static uint8_t grayscale_val; /* 8bit grayscale color */ if ( config.signal_check_points > 0 ) { @@ -1009,9 +1020,11 @@ bool Monitor::CheckSignal( const Image *image ) red_val = RGB_RED_VAL(signal_check_colour); green_val = RGB_GREEN_VAL(signal_check_colour); blue_val = RGB_BLUE_VAL(signal_check_colour); + color_val = RGB_ZEROALPHA(signal_check_colour); /* Clear alpha byte */ + grayscale_val = 0x000000ffu & signal_check_colour; /* Clear all bytes but lowest byte */ } - const unsigned char *buffer = image->Buffer(); + const uint8_t *buffer = image->Buffer(); int pixels = image->Pixels(); int width = image->Width(); int colours = image->Colours(); @@ -1028,11 +1041,21 @@ bool Monitor::CheckSignal( const Image *image ) if ( index < (label_coord.Y()*width) || index >= (label_coord.Y()+Image::LINE_HEIGHT)*width ) break; } - const unsigned char *ptr = buffer+(index*colours); - if ( (RED(ptr) != red_val) || (GREEN(ptr) != green_val) || (BLUE(ptr) != blue_val) ) - { - return( true ); - } + + if(colours == 1) { + if ( *(buffer+index) != grayscale_val ) + return true; + + } else if(colours == 3) { + const uint8_t *ptr = buffer+(index*colours); + if ( (RED(ptr) != red_val) || (GREEN(ptr) != green_val) || (BLUE(ptr) != blue_val) ) + return true; + + } else if(colours == 4) { + if ( RGB_ZEROALPHA(*(((const Rgb*)buffer)+index)) != color_val ) + return true; + } + } return( false ); } @@ -1733,11 +1756,11 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose static char sql[ZM_SQL_MED_BUFSIZ]; if ( !device[0] ) { - strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Method, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' order by Device, Channel", sizeof(sql) ); + strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Method, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' order by Device, Channel", sizeof(sql) ); } else { - snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Method, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' and Device = '%s' order by Channel", device ); + snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Method, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' and Device = '%s' order by Channel", device ); } if ( mysql_query( &dbconn, sql ) ) { @@ -1772,6 +1795,7 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose int width = atoi(dbrow[col]); col++; int height = atoi(dbrow[col]); col++; + int colours = atoi(dbrow[col]); col++; int palette = atoi(dbrow[col]); col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; @@ -1816,6 +1840,7 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose method, cam_width, cam_height, + colours, palette, brightness, contrast, @@ -1873,11 +1898,11 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c static char sql[ZM_SQL_MED_BUFSIZ]; if ( !protocol ) { - strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote'", sizeof(sql) ); + strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote'", sizeof(sql) ); } else { - snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote' and Protocol = '%s' and Host = '%s' and Port = '%s' and Path = '%s'", protocol, host, port, path ); + snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote' and Protocol = '%s' and Host = '%s' and Port = '%s' and Path = '%s'", protocol, host, port, path ); } if ( mysql_query( &dbconn, sql ) ) { @@ -1913,6 +1938,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c int width = atoi(dbrow[col]); col++; int height = atoi(dbrow[col]); col++; + int colours = atoi(dbrow[col]); col++; int palette = atoi(dbrow[col]); col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; @@ -1954,7 +1980,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c path, // Path cam_width, cam_height, - palette, + colours, brightness, contrast, hue, @@ -1973,7 +1999,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c path, // Path cam_width, cam_height, - palette, + colours, brightness, contrast, hue, @@ -2035,11 +2061,11 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu static char sql[ZM_SQL_MED_BUFSIZ]; if ( !file[0] ) { - strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File'", sizeof(sql) ); + strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File'", sizeof(sql) ); } else { - snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File' and Path = '%s'", file ); + snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File' and Path = '%s'", file ); } if ( mysql_query( &dbconn, sql ) ) { @@ -2071,6 +2097,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu int width = atoi(dbrow[col]); col++; int height = atoi(dbrow[col]); col++; + int colours = atoi(dbrow[col]); col++; int palette = atoi(dbrow[col]); col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; @@ -2106,7 +2133,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu path, // File cam_width, cam_height, - palette, + colours, brightness, contrast, hue, @@ -2163,11 +2190,11 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose static char sql[ZM_SQL_MED_BUFSIZ]; if ( !file[0] ) { - strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg'", sizeof(sql) ); + strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg'", sizeof(sql) ); } else { - snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg' and Path = '%s'", file ); + snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg' and Path = '%s'", file ); } if ( mysql_query( &dbconn, sql ) ) { @@ -2199,6 +2226,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose int width = atoi(dbrow[col]); col++; int height = atoi(dbrow[col]); col++; + int colours = atoi(dbrow[col]); col++; int palette = atoi(dbrow[col]); col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; @@ -2234,7 +2262,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose path, // File cam_width, cam_height, - palette, + colours, brightness, contrast, hue, @@ -2289,7 +2317,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) { static char sql[ZM_SQL_MED_BUFSIZ]; - snprintf( sql, sizeof(sql), "select Id, Name, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Protocol, Method, Host, Port, Path, Width, Height, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = %d", id ); + snprintf( sql, sizeof(sql), "select Id, Name, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = %d", id ); if ( mysql_query( &dbconn, sql ) ) { Error( "Can't run query: %s", mysql_error( &dbconn ) ); @@ -2328,6 +2356,7 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) int width = atoi(dbrow[col]); col++; int height = atoi(dbrow[col]); col++; + int colours = atoi(dbrow[col]); col++; int palette = atoi(dbrow[col]); col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; @@ -2375,6 +2404,7 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) method, cam_width, cam_height, + colours, palette, brightness, contrast, @@ -2398,7 +2428,7 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) path.c_str(), cam_width, cam_height, - palette, + colours, brightness, contrast, hue, @@ -2417,7 +2447,7 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) path.c_str(), cam_width, cam_height, - palette, + colours, brightness, contrast, hue, @@ -2440,7 +2470,7 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) path.c_str(), cam_width, cam_height, - palette, + colours, brightness, contrast, hue, @@ -2456,7 +2486,7 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) path.c_str(), cam_width, cam_height, - palette, + colours, brightness, contrast, hue, @@ -2521,12 +2551,17 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) int Monitor::Capture() { - int captureResult = camera->Capture( image ); - if ( captureResult == 1 ) + int index = image_count%image_buffer_count; + Image* capture_image = image_buffer[index].image; + + /* Capture directly into image buffer, avoiding the need to memcpy() */ + int captureResult = camera->Capture(*capture_image); + + if ( captureResult != 0 ) { // Unable to capture image for temporary reason // Fake a signal loss image - image.Fill( signal_check_colour ); + capture_image->Fill( signal_check_colour ); captureResult = 0; } if ( captureResult == 0 ) @@ -2544,25 +2579,25 @@ int Monitor::Capture() case ROTATE_180 : case ROTATE_270 : { - image.Rotate( (orientation-1)*90 ); + capture_image->Rotate( (orientation-1)*90 ); break; } case FLIP_HORI : case FLIP_VERT : { - image.Flip( orientation==FLIP_HORI ); + capture_image->Flip( orientation==FLIP_HORI ); break; } } } - if ( image.Size() != camera->ImageSize() ) + if ( capture_image->Size() != camera->ImageSize() ) { Error( "Captured image does not match expected size, check width, height and colour depth" ); return( -1 ); } - int index = image_count%image_buffer_count; + if ( (index == shared_data->last_read_index) && (function > MONITOR) ) { Warning( "Buffer overrun at index %d, image %d, slow down capture, speed up analysis or increase ring buffer size", index, image_count ); @@ -2579,11 +2614,9 @@ int Monitor::Capture() gettimeofday( image_buffer[index].timestamp, NULL ); if ( config.timestamp_on_capture ) { - TimestampImage( &image, image_buffer[index].timestamp ); + TimestampImage( capture_image, image_buffer[index].timestamp ); } - image_buffer[index].image->CopyBuffer( image ); - - shared_data->signal = CheckSignal( &image ); + shared_data->signal = CheckSignal(capture_image); shared_data->last_write_index = index; shared_data->last_write_time = image_buffer[index].timestamp->tv_sec; @@ -2706,7 +2739,7 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z { snprintf( diag_path, sizeof(diag_path), "%s/%d/diag-d.jpg", config.dir_events, id ); } - delta_image->WriteJpeg( diag_path ); + delta_image.WriteJpeg( diag_path ); } // Blank out all exclusion zones @@ -2719,7 +2752,7 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z continue; } Debug( 3, "Blanking inactive zone %s", zone->Label() ); - delta_image->Fill( RGB_BLACK, zone->GetPolygon() ); + delta_image.Fill( RGB_BLACK, zone->GetPolygon() ); } // Check preclusive zones first @@ -2731,7 +2764,7 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z continue; } Debug( 3, "Checking preclusive zone %s", zone->Label() ); - if ( zone->CheckAlarms( delta_image ) ) + if ( zone->CheckAlarms( &delta_image ) ) { alarm = true; score += zone->Score(); @@ -2760,7 +2793,7 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z continue; } Debug( 3, "Checking active zone %s", zone->Label() ); - if ( zone->CheckAlarms( delta_image ) ) + if ( zone->CheckAlarms( &delta_image ) ) { alarm = true; score += zone->Score(); @@ -2788,7 +2821,7 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z continue; } Debug( 3, "Checking inclusive zone %s", zone->Label() ); - if ( zone->CheckAlarms( delta_image ) ) + if ( zone->CheckAlarms( &delta_image ) ) { alarm = true; score += zone->Score(); @@ -2817,7 +2850,7 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z continue; } Debug( 3, "Checking exclusive zone %s", zone->Label() ); - if ( zone->CheckAlarms( delta_image ) ) + if ( zone->CheckAlarms( &delta_image ) ) { alarm = true; score += zone->Score(); @@ -2841,7 +2874,6 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z shared_data->alarm_x = shared_data->alarm_y = -1; } - delete delta_image; // This is a small and innocent hack to prevent scores of 0 being returned in alarm state return( score?score:alarm ); } diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 841637709..9cb28b8d0 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -97,7 +97,7 @@ protected: time_t last_write_time; time_t last_read_time; int last_event; - int action; + unsigned int action; int brightness; int hue; int colour; @@ -210,7 +210,7 @@ protected: Rgb signal_check_colour; // The colour that the camera will emit when no video signal detected double fps; - Image image; + Image delta_image; Image ref_image; Purpose purpose; // What this monitor has been created to do @@ -300,7 +300,9 @@ public: unsigned int Width() const { return( width ); } unsigned int Height() const { return( height ); } - unsigned int Colours() const { return( camera->Colours() ); } + unsigned int Colours() const { return( camera->Colours() ); } + unsigned int SubpixelOrder const { return( camera->SubpixelOrder() ); } + State GetState() const; int GetImage( int index=-1, int scale=100 ) const; diff --git a/src/zm_remote_camera.cpp b/src/zm_remote_camera.cpp index 1bec75137..8c54c0ad7 100644 --- a/src/zm_remote_camera.cpp +++ b/src/zm_remote_camera.cpp @@ -21,8 +21,8 @@ #include "zm_utils.h" -RemoteCamera::RemoteCamera( int p_id, const std::string &p_protocol, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : - Camera( p_id, REMOTE_SRC, p_width, p_height, p_palette, p_brightness, p_contrast, p_hue, p_colour, p_capture ), +RemoteCamera::RemoteCamera( int p_id, const std::string &p_protocol, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : + Camera( p_id, REMOTE_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ), protocol( p_protocol ), host( p_host ), port( p_port ), diff --git a/src/zm_rgb.h b/src/zm_rgb.h index c6dd60ad3..a5f8d5d82 100644 --- a/src/zm_rgb.h +++ b/src/zm_rgb.h @@ -20,11 +20,7 @@ #ifndef ZM_RGB_H #define ZM_RGB_H -typedef unsigned int Rgb; // RGB colour type - -#define RED(ptr) (*(ptr)) -#define GREEN(ptr) (*(ptr+1)) -#define BLUE(ptr) (*(ptr+2)) +typedef uint32_t Rgb; // RGB colour type #define WHITE 0xff #define WHITE_R 0xff @@ -46,8 +42,115 @@ typedef unsigned int Rgb; // RGB colour type #define RGB_TRANSPARENT (0x01000000) #define RGB_VAL(v,c) (((v)>>(16-((c)*8)))&0xff) -#define RGB_RED_VAL(v) (((v)>>16)&0xff) -#define RGB_GREEN_VAL(v) (((v)>>8)&0xff) -#define RGB_BLUE_VAL(v) ((v)&0xff) + +/* RGB or RGBA macros */ +#define BLUE_VAL_RGBA(v) (((v)>>16)&0xff) +#define GREEN_VAL_RGBA(v) (((v)>>8)&0xff) +#define RED_VAL_RGBA(v) ((v)&0xff) +#define ALPHA_VAL_RGBA(v) ((v)>>24)&0xff) +#define RED_PTR_RGBA(ptr) (*((uint8_t*)ptr)) +#define GREEN_PTR_RGBA(ptr) (*((uint8_t*)ptr+1)) +#define BLUE_PTR_RGBA(ptr) (*((uint8_t*)ptr+2)) +#define ALPHA_PTR_RGBA(ptr) (*((uint8_t*)ptr+3)) + +/* BGR or BGRA */ +#define RED_VAL_BGRA(v) (((v)>>16)&0xff) +#define GREEN_VAL_BGRA(v) (((v)>>8)&0xff) +#define BLUE_VAL_BGRA(v) ((v)&0xff) +#define ALPHA_VAL_BGRA(v) ((v)>>24)&0xff) +#define RED_PTR_BGRA(ptr) (*((uint8_t*)ptr+2)) +#define GREEN_PTR_BGRA(ptr) (*((uint8_t*)ptr+1)) +#define BLUE_PTR_BGRA(ptr) (*((uint8_t*)ptr)) +#define ALPHA_PTR_BGRA(ptr) (*((uint8_t*)ptr+3)) + +/* ARGB */ +#define BLUE_VAL_ARGB(v) (((v)>>24)&0xff) +#define GREEN_VAL_ARGB(v) (((v)>>16)&0xff) +#define RED_VAL_ARGB(v) (((v)>>8)&0xff) +#define ALPHA_VAL_ARGB(v) ((v)&0xff) +#define RED_PTR_ARGB(ptr) (*((uint8_t*)ptr+1)) +#define GREEN_PTR_ARGB(ptr) (*((uint8_t*)ptr+2)) +#define BLUE_PTR_ARGB(ptr) (*((uint8_t*)ptr+3)) +#define ALPHA_PTR_ARGB(ptr) (*((uint8_t*)ptr)) + +/* ABGR */ +#define BLUE_VAL_ABGR(v) (((v)>>8)&0xff) +#define GREEN_VAL_ABGR(v) (((v)>>16)&0xff) +#define RED_VAL_ABGR(v) (((v)>>24)&0xff) +#define ALPHA_VAL_ABGR(v) ((v)&0xff) +#define RED_PTR_ABGR(ptr) (*((uint8_t*)ptr+3)) +#define GREEN_PTR_ABGR(ptr) (*((uint8_t*)ptr+2)) +#define BLUE_PTR_ABGR(ptr) (*((uint8_t*)ptr+1)) +#define ALPHA_PTR_ABGR(ptr) (*((uint8_t*)ptr)) + + +#define RGBA_BGRA_ZEROALPHA(v) ((v)&0x00ffffff)) +#define ARGB_ABGR_ZEROALPHA(v) ((v)&0xffffff00)) + +/* ITU-R BT.709: Y = (0.2126 * R) + (0.7152 * G) + (0.0722 * B) */ +/* ITU-R BT.601: Y = (0.299 * R) + (0.587 * G) + (0.114 * B) */ +/* The formulas below produce an almost identical result to the weighted algorithms from the ITU-R BT.601 standard and the newer ITU-R BT.709 standard, but a lot faster */ +// #define RGB_FASTLUM_SINGLE_ITU709(v) ((RED(v)+RED(v)+BLUE(v)+GREEN(v)+GREEN(v)+GREEN(v)+GREEN(v)+GREEN(v))>>3) +// #define RGB_FASTLUM_VALUES_ITU709(ra,ga,ba) (((ra)+(ra)+(ba)+(ga)+(ga)+(ga)+(ga)+(ga))>>3) +// #define RGB_FASTLUM_SINGLE_ITU601(v) ((RED(v)+RED(v)+RED(v)+BLUE(v)+GREEN(v)+GREEN(v)+GREEN(v)+GREEN(v))>>3) +// #define RGB_FASTLUM_VALUES_ITU601(ra,ga,ba) (((ra)+(ra)+(ra)+(ba)+(ga)+(ga)+(ga)+(ga))>>3) + +/* ZM colours */ +#define ZM_COLOUR_RGB32 4 +#define ZM_COLOUR_RGB24 3 +#define ZM_COLOUR_GRAY8 1 + +/* Subpixel ordering */ +/* Based on byte order naming. For example, for ARGB (on both little endian or big endian) byte+0 should be alpha, byte+1 should be red, and so on. */ +#define ZM_SUBPIX_ORDER_NONE 2 +#define ZM_SUBPIX_ORDER_RGB 6 +#define ZM_SUBPIX_ORDER_BGR 5 +#define ZM_SUBPIX_ORDER_BGRA 7 +#define ZM_SUBPIX_ORDER_RGBA 8 +#define ZM_SUBPIX_ORDER_ABGR 9 +#define ZM_SUBPIX_ORDER_ARGB 10 + +/* A macro to use default subpixel order for a specified colour. */ +/* for grayscale it will use NONE, for 3 colours it will use R,G,B, for 4 colours it will use R,G,B,A */ +#define ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(c) ((c)<<1) + +/* Convert RGB colour value into BGR\ARGB\ABGR */ +inline Rgb rgb_convert(Rgb p_col, int p_subpixorder) { + Rgb result; + + switch(p_subpixorder) { + + case ZM_SUBPIX_ORDER_BGR: + case ZM_SUBPIX_ORDER_BGRA: + { + BLUE_PTR_BGRA(&result) = BLUE_VAL_RGBA(p_col); + GREEN_PTR_BGRA(&result) = GREEN_VAL_RGBA(p_col); + RED_PTR_BGRA(&result) = RED_VAL_RGBA(p_col); + return result; + } + case ZM_SUBPIX_ORDER_ARGB: + { + BLUE_PTR_ARGB(&result) = BLUE_VAL_RGBA(p_col); + GREEN_PTR_ARGB(&result) = GREEN_VAL_RGBA(p_col); + RED_PTR_ARGB(&result) = RED_VAL_RGBA(p_col); + return result; + } + case ZM_SUBPIX_ORDER_ABGR: + { + BLUE_PTR_ABGR(&result) = BLUE_VAL_RGBA(p_col); + GREEN_PTR_ABGR(&result) = GREEN_VAL_RGBA(p_col); + RED_PTR_ABGR(&result) = RED_VAL_RGBA(p_col); + return result; + } + /* Grayscale */ + case ZM_SUBPIX_ORDER_NONE: + { + result = p_col & 0xff; + } + default: + return p_col; + + } +} #endif // ZM_RGB_H diff --git a/src/zm_thread.h b/src/zm_thread.h index 0ac2538b1..49fb73bcc 100644 --- a/src/zm_thread.h +++ b/src/zm_thread.h @@ -146,38 +146,38 @@ private: mutable Condition mCondition; public: - ThreadData() : mCondition( mMutex ) + __attribute__((used)) ThreadData() : mCondition( mMutex ) { } - ThreadData( T value ) : mValue( value ), mCondition( mMutex ) + __attribute__((used)) ThreadData( T value ) : mValue( value ), mCondition( mMutex ) { } //~ThreadData() {} - operator T() const + __attribute__((used)) operator T() const { return( getValue() ); } - const T operator=( const T value ) + __attribute__((used)) const T operator=( const T value ) { return( setValue( value ) ); } - const T getValueImmediate() const + __attribute__((used)) const T getValueImmediate() const { return( mValue ); } - T setValueImmediate( const T value ) + __attribute__((used)) T setValueImmediate( const T value ) { return( mValue = value ); } - const T getValue() const; - T setValue( const T value ); - const T getUpdatedValue() const; - const T getUpdatedValue( double secs ) const; - const T getUpdatedValue( int secs ) const; - void updateValueSignal( const T value ); - void updateValueBroadcast( const T value ); + __attribute__((used)) const T getValue() const; + __attribute__((used)) T setValue( const T value ); + __attribute__((used)) const T getUpdatedValue() const; + __attribute__((used)) const T getUpdatedValue( double secs ) const; + __attribute__((used)) const T getUpdatedValue( int secs ) const; + __attribute__((used)) void updateValueSignal( const T value ); + __attribute__((used)) void updateValueBroadcast( const T value ); }; class Thread diff --git a/src/zm_utils.cpp b/src/zm_utils.cpp index e4bb53162..4f13af1b8 100644 --- a/src/zm_utils.cpp +++ b/src/zm_utils.cpp @@ -23,6 +23,8 @@ #include #include +unsigned int sseversion = 0; + const std::string stringtf( const char *format, ... ) { va_list ap; @@ -147,3 +149,48 @@ const std::string base64Encode( const std::string &inString ) } return( outString ); } + +/* Sets sse_version */ +void ssedetect() { +#if (defined(__i386__) || defined(__x86_64__)) + /* x86 or x86-64 processor */ + uint32_t r_edx, r_ecx; + + __asm__ __volatile__( + "mov $0x1,%%eax\n\t" + "cpuid\n\t" + : "=d" (r_edx), "=c" (r_ecx) + : + : "%eax", "%ebx" + ); + + if (r_ecx & 0x00000100) { + sseversion = 35; /* SSSE3 */ + Debug(1,"Detected a x86\\x86-64 processor with SSSE3."); + } else if (r_ecx & 0x00000001) { + sseversion = 30; /* SSE3 */ + Debug(1,"Detected a x86\\x86-64 processor with SSE3."); + } else if (r_edx & 0x04000000) { + sseversion = 20; /* SSE2 */ + Debug(1,"Detected a x86\\x86-64 processor with SSE2."); + } else if (r_edx & 0x02000000) { + sseversion = 10; /* SSE */ + Debug(1,"Detected a x86\\x86-64 processor with SSE."); + } else { + sseversion = 0; + Debug(1,"Detected a x86\\x86-64 processor."); + } + +#else + /* Non x86 or x86-64 processor, SSE2 is not available */ + Debug(1,"Detected a non x86\\x86-64 processor."); + sseversion = 0; +#endif +} + +/* Aligned SSE2 memory copy. Useful for copying big things like image buffers in ZM */ +/* This requires source and target memory to be aligned on 16byte boundary, or a general protection fault will occur, therefore we check for unaligned memory */ +void sse2memcpy(unsigned char* dest, const unsigned char* src, const size_t bytes) { + memcpy(dest,src,bytes); +} + diff --git a/src/zm_utils.h b/src/zm_utils.h index 2c6fa8c48..74b90743b 100644 --- a/src/zm_utils.h +++ b/src/zm_utils.h @@ -43,4 +43,9 @@ inline int min( int a, int b ) return( a<=b?a:b ); } +void ssedetect(); +void sse2memcpy(unsigned char* dest, const unsigned char* src, const size_t bytes); + +extern unsigned int sseversion; + #endif // ZM_UTILS_H diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index 99b221fa5..247151425 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -62,7 +62,7 @@ void Zone::Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_ overload_count = 0; - pg_image = new Image( monitor->Width(), monitor->Height(), 1 ); + pg_image = new Image( monitor->Width(), monitor->Height(), 1, ZM_SUBPIX_ORDER_NONE); pg_image->Fill( 0xff, polygon ); pg_image->Outline( 0xff, polygon ); pg_image->Crop( polygon.LoX(), polygon.LoY(), polygon.HiX(), polygon.HiY() ); @@ -662,11 +662,11 @@ bool Zone::CheckAlarms( const Image *delta_image ) if ( type == INCLUSIVE ) { - score /= 2; + score <<= 1; } else if ( type == EXCLUSIVE ) { - score *= 2; + score >>= 1; } Debug( 5, "Adjusted score is %d", score ); From 4a59761bcc2ab43bba797fd45a060eaa77c673f0 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sat, 30 Apr 2011 21:39:34 +0300 Subject: [PATCH 02/56] Getting closer and closer everyday. 1) Fixed many errors to get it to compile 2) Fixed some small bugs 3) Small other changes --- config.h.in | 3 + db/zm_update-1.24.2.sql | 5 + .../lib/ZoneMinder/ConfigData.pm.in | 6 +- src/zm_camera.cpp | 2 + src/zm_camera.h | 2 +- src/zm_config_defines.h | 2 +- src/zm_event.cpp | 6 +- src/zm_ffmpeg_camera.cpp | 2 +- src/zm_image.cpp | 637 ++++++++---------- src/zm_image.h | 37 +- src/zm_local_camera.cpp | 33 +- src/zm_mem_utils.h | 23 +- src/zm_monitor.cpp | 26 +- src/zm_monitor.h | 3 +- src/zm_mpeg.cpp | 2 +- src/zm_mpeg.h | 2 +- src/zm_remote_camera_http.cpp | 6 +- src/zm_remote_camera_rtsp.cpp | 2 +- src/zm_rgb.h | 16 +- src/zm_stream.cpp | 2 +- src/zm_utils.cpp | 16 +- src/zm_utils.h | 2 +- src/zm_zone.cpp | 26 +- src/zma.cpp | 2 + src/zmc.cpp | 2 + src/zmf.cpp | 2 + src/zms.cpp | 2 + src/zmstreamer.cpp | 3 + 28 files changed, 419 insertions(+), 453 deletions(-) diff --git a/config.h.in b/config.h.in index c735aa992..c432ceaba 100644 --- a/config.h.in +++ b/config.h.in @@ -183,6 +183,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_PTHREAD_H +/* Define to 1 if you have the `posix_memalign' function. */ +#undef HAVE_POSIX_MEMALIGN + /* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV diff --git a/db/zm_update-1.24.2.sql b/db/zm_update-1.24.2.sql index d0ff2cd20..3026bc53a 100644 --- a/db/zm_update-1.24.2.sql +++ b/db/zm_update-1.24.2.sql @@ -5,6 +5,11 @@ --Add Colours colum. This is a harmless change for ZM 1.24.2 or ZM 1.24.3 without the patch, but is required to use the patch ALTER TABLE `Monitors` ADD `Colours` TINYINT UNSIGNED NOT NULL DEFAULT '1' AFTER `Height`; +-- Replace now unused ZM_Y_IMAGE_DELTAS option with ZM_CPU_EXTENSIONS. +UPDATE `zm`.`Config` SET `Name` = 'ZM_CPU_EXTENSIONS', +`Prompt` = 'Use advanced CPU extensions to increase performance', +`Help` = 'When advanced processor extensions such as SSE2 or SSSE3 are available, ZoneMinder can use them, which should increase performance and reduce system load. Enabling this option on processors that do not support the advanced processors extensions used by ZoneMinder is harmless and will have no effect.' WHERE `Config`.`Id` = '27'; + -- -- Add in remote ZoneMinder preset. -- diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index dc8a07263..677ce8353 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -316,10 +316,10 @@ our @options = category => "config", }, { - name => "ZM_Y_IMAGE_DELTAS", + name => "ZM_CPU_EXTENSIONS", default => "yes", - description => "Calculate image differences using Y channel", - help => "When ZoneMinder tries to establish the differences between two colour images it generates a greyscale 'delta' image between the two sets of images. In order to do this it determines the differences found between the different RGB colour components and calculates a greyscale value representing this. If this option is set then a calculation will be made to convert each pixel of the image into a brightness value (Y from YUV) and then find the difference between the two. If this option is not set then the resulting difference is determined as the average of the differences of each colour which is a simple calculation. Using the Y value is likely to be more accurate and is up to 15% faster. Only switch this option off if Y based deltas do not work as well for you as RGB ones.", + description => "Use advanced CPU extensions to increase performance", + help => "When advanced processor extensions such as SSE2 or SSSE3 are available, ZoneMinder can use them, which should increase performance and reduce system load. Enabling this option on processors that do not support the advanced processors extensions used by ZoneMinder is harmless and will have no effect.", type => $types{boolean}, category => "config", }, diff --git a/src/zm_camera.cpp b/src/zm_camera.cpp index d0e27b334..4bb349585 100644 --- a/src/zm_camera.cpp +++ b/src/zm_camera.cpp @@ -35,6 +35,8 @@ Camera::Camera( int p_id, SourceType p_type, int p_width, int p_height, int p_co { pixels = width * height; imagesize = pixels * colours; + + Debug(2,"New camera id: %d width: %d height: %d colours: %d subpixelorder: %d capture: %d",id,width,height,colours,subpixelorder,capture); } diff --git a/src/zm_camera.h b/src/zm_camera.h index 0b24c5169..8713d3956 100644 --- a/src/zm_camera.h +++ b/src/zm_camera.h @@ -61,7 +61,7 @@ public: unsigned int Width() const { return( width ); } unsigned int Height() const { return( height ); } unsigned int Colours() const { return( colours ); } - unsigned int SubpixelOrder const { return( subpixelorder ); } + unsigned int SubpixelOrder() const { return( subpixelorder ); } unsigned int Pixels() const { return( pixels ); } unsigned int ImageSize() const { return( imagesize ); } diff --git a/src/zm_config_defines.h b/src/zm_config_defines.h index 87ed3c36e..3e57de1d9 100644 --- a/src/zm_config_defines.h +++ b/src/zm_config_defines.h @@ -472,7 +472,7 @@ reload_cambozola = (int)config.Item( ZM_RELOAD_CAMBOZOLA );\ timestamp_on_capture = (bool)config.Item( ZM_TIMESTAMP_ON_CAPTURE );\ local_bgr_invert = (bool)config.Item( ZM_LOCAL_BGR_INVERT );\ - y_image_deltas = (bool)config.Item( ZM_Y_IMAGE_DELTAS );\ + cpu_extensions = (bool)config.Item( ZM_CPU_EXTENSIONS );\ fast_image_blends = (bool)config.Item( ZM_FAST_IMAGE_BLENDS );\ opt_adaptive_skip = (bool)config.Item( ZM_OPT_ADAPTIVE_SKIP );\ blend_alarmed_images = (bool)config.Item( ZM_BLEND_ALARMED_IMAGES );\ diff --git a/src/zm_event.cpp b/src/zm_event.cpp index f2ef9d5b1..bab35225a 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -28,9 +28,7 @@ #include #include -#if defined(HAVE_SYS_SENDFILE_H) && defined(HAVE_SENDFILE) #include -#endif #include "zm.h" #include "zm_db.h" @@ -1218,7 +1216,7 @@ bool EventStream::sendFrame( int delta_us ) static unsigned char temp_img_buffer[ZM_MAX_IMAGE_SIZE]; int img_buffer_size = 0; - unsigned char *img_buffer = temp_img_buffer; + uint8_t *img_buffer = temp_img_buffer; bool send_raw = ((scale>=ZM_SCALE_BASE)&&(zoom==ZM_SCALE_BASE)); @@ -1256,7 +1254,7 @@ bool EventStream::sendFrame( int delta_us ) send_image->EncodeJpeg( img_buffer, &img_buffer_size ); break; case STREAM_RAW : - img_buffer = send_image->Buffer(); + img_buffer = (uint8_t*)(send_image->Buffer()); img_buffer_size = send_image->Size(); break; case STREAM_ZIP : diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index f956fddf0..7ca98aefe 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -185,7 +185,7 @@ int FfmpegCamera::Capture( Image &image ) Fatal( "You must compile ffmpeg with the --enable-swscale option to use ffmpeg cameras" ); #endif // HAVE_LIBSWSCALE - image.Assign( mCodecContext->width, mCodecContext->height, colours, (unsigned char *)mFrame->data[0] ); + image.Assign( mCodecContext->width, mCodecContext->height, colours, subpixelorder, (unsigned char *)mFrame->data[0], imagesize); frameCount++; } diff --git a/src/zm_image.cpp b/src/zm_image.cpp index c30483154..f715997ad 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -20,12 +20,11 @@ #include "zm_font.h" #include "zm_image.h" #include "zm_utils.h" +#include "zm_rgb.h" #include #include -#define ABSDIFF(a,b) (((a)<(b))?((b)-(a)):((a)-(b))) - bool Image::initialised = false; unsigned char *Image::abs_table; unsigned char *Image::y_r_table; @@ -50,8 +49,6 @@ delta_fptr_t fptr_delta8_abgr; delta_fptr_t fptr_delta8_gray8; - - Image::Image() { if ( !initialised ) @@ -83,7 +80,7 @@ Image::Image( const char *filename ) buffer = 0; buffertype = 0; holdbuffer = 0; - ReadJpeg( filename ); + ReadJpeg( filename, ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB); text[0] = '\0'; } @@ -97,18 +94,18 @@ Image::Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uin colours = p_colours; subpixelorder = p_subpixelorder; size = width*height*colours; + buffer = 0; holdbuffer = 0; if ( p_buffer ) { /* Don't free the supplied buffer, but don't hold it either */ - allocation = size; + allocation = size; buffertype = ZM_BUFTYPE_DONTFREE; buffer = p_buffer; } else { - allocation = size; - AllocBuffer(allocation); + AllocBuffer(size); } text[0] = '\0'; } @@ -123,6 +120,7 @@ Image::Image( const Image &p_image ) colours = p_image.colours; subpixelorder = p_image.subpixelorder; size = allocation = p_image.size; + buffer = 0; holdbuffer = 0; AllocBuffer(allocation); sse2_aligned_memcpy(buffer, p_image.buffer, size); @@ -136,11 +134,9 @@ Image::~Image() void Image::Initialise() { - initialised = true; - /* Assign the blend pointer to function */ if(config.fast_image_blends) { - if(sseversion >= 20) { + if(config.cpu_extensions && sseversion >= 20) { fptr_blend = &sse2_fastblend; /* SSE2 fast blend */ Debug(2,"Blend: using SSE2 fast blending"); } else { @@ -166,7 +162,47 @@ void Image::Initialise() } } + fptr_delta8_rgb = &std_delta8_rgb; + fptr_delta8_bgr = &std_delta8_bgr; + /* Assign the delta functions */ + if(config.cpu_extensions) { + if(sseversion >= 35) { + /* SSSE3 available */ + fptr_delta8_rgba = &ssse3_delta8_rgba; + fptr_delta8_bgra = &ssse3_delta8_bgra; + fptr_delta8_argb = &ssse3_delta8_argb; + fptr_delta8_abgr = &ssse3_delta8_abgr; + fptr_delta8_gray8 = &sse2_delta8_gray8; + Debug(2,"Delta: Using SSSE3 delta functions"); + } else if(sseversion >= 20) { + /* SSE2 available */ + fptr_delta8_rgba = &std_delta8_rgba; + fptr_delta8_bgra = &std_delta8_bgra; + fptr_delta8_argb = &std_delta8_argb; + fptr_delta8_abgr = &std_delta8_abgr; + fptr_delta8_gray8 = &sse2_delta8_gray8; + Debug(2,"Delta: Using standard and SSE2 delta functions"); + } else { + /* No SSE available */ + fptr_delta8_rgba = &std_delta8_rgba; + fptr_delta8_bgra = &std_delta8_bgra; + fptr_delta8_argb = &std_delta8_argb; + fptr_delta8_abgr = &std_delta8_abgr; + fptr_delta8_gray8 = &std_delta8_gray8; + Debug(2,"Delta: Using standard delta functions"); + } + } else { + /* CPU extensions disabled */ + fptr_delta8_rgba = &std_delta8_rgba; + fptr_delta8_bgra = &std_delta8_bgra; + fptr_delta8_argb = &std_delta8_argb; + fptr_delta8_abgr = &std_delta8_abgr; + fptr_delta8_gray8 = &std_delta8_gray8; + Debug(2,"Delta: CPU extensions disabled, using standard delta functions"); + } + + initialised = true; } /* Requests a writeable buffer to the image. This is safer than buffer() because this way we can gurantee that a buffer of required size exists */ @@ -215,7 +251,6 @@ uint8_t* Image::WriteBuffer(const int p_width, const int p_height, const int p_c /* Assign an existing buffer to the image instead of copying from a source buffer. The goal is to reduce the amount of memory copying and increase efficiency and buffer reusing. */ void Image::AssignDirect( const int p_width, const int p_height, const int p_colours, const int p_subpixelorder, uint8_t *new_buffer, const size_t buffer_size, const int p_buffertype) { -{ if(new_buffer == NULL) { Error("Attempt to directly assign buffer from a NULL pointer"); return; @@ -241,8 +276,16 @@ void Image::AssignDirect( const int p_width, const int p_height, const int p_col Error("Held buffer is undersized for assigned buffer"); return; } else { + width = p_width; + height = p_height; + colours = p_colours; + subpixelorder = p_subpixelorder; + pixels = height*width; + size = pixels*colours; + /* Copy into the held buffer */ - Assign(p_width,p_height,p_colours,p_subpixelorder,new_buffer); + if(new_buffer != buffer) + sse2_aligned_memcpy(buffer, new_buffer, size); } } else { /* Free an existing buffer if any */ @@ -309,6 +352,7 @@ void Image::Assign(const int p_width, const int p_height, const int p_colours, c if(new_buffer != buffer) sse2_aligned_memcpy(buffer, new_buffer, size); + } void Image::Assign( const Image &image ) { @@ -320,7 +364,7 @@ void Image::Assign( const Image &image ) { } if(image.colours != 1 && image.colours != 3 && image.colours != 4) { - Error("Attempt to assign image with unexpected colours per pixel: %d",p_colours); + Error("Attempt to assign image with unexpected colours per pixel: %d",image.colours); return; } @@ -356,7 +400,7 @@ Image *Image::HighlightEdges( Rgb colour, const Box *limits ) { Panic( "Attempt to highlight image edges when colours = %d", colours ); } - Image *high_image = new Image( width, height, 3 ); + Image *high_image = new Image( width, height, 3, ZM_SUBPIX_ORDER_RGB); int lo_x = limits?limits->Lo().X():0; int lo_y = limits?limits->Lo().Y():0; int hi_x = limits?limits->Hi().X():width-1; @@ -364,7 +408,7 @@ Image *Image::HighlightEdges( Rgb colour, const Box *limits ) for ( int y = lo_y; y <= hi_y; y++ ) { unsigned char *p = &buffer[(y*width)+lo_x]; - unsigned char *phigh = high_image->Buffer( lo_x, y ); + unsigned char *phigh = (uint8_t*)high_image->Buffer( lo_x, y ); for ( int x = lo_x; x <= hi_x; x++, p++, phigh += 3 ) { bool edge = false; @@ -377,9 +421,9 @@ Image *Image::HighlightEdges( Rgb colour, const Box *limits ) } if ( edge ) { - RED(phigh) = RGB_RED_VAL(colour); - GREEN(phigh) = RGB_GREEN_VAL(colour); - BLUE(phigh) = RGB_BLUE_VAL(colour); + RED_PTR_RGBA(phigh) = RED_VAL_RGBA(colour); + GREEN_PTR_RGBA(phigh) = GREEN_VAL_RGBA(colour); + BLUE_PTR_RGBA(phigh) = BLUE_VAL_RGBA(colour); } } } @@ -477,14 +521,14 @@ bool Image::ReadJpeg( const char *filename, int p_colours, int p_subpixelorder) pixels = width*height; } - if ( cinfo->num_components != 1 && cinfo->num_components != 3) ) + if ( cinfo->num_components != 1 && cinfo->num_components != 3 ) { Error( "Unexpected colours when reading jpeg image: %d", colours ); jpeg_abort_decompress( cinfo ); fclose( infile ); return( false ); } - + switch(p_colours) { case ZM_COLOUR_GRAY8: { @@ -549,7 +593,7 @@ bool Image::ReadJpeg( const char *filename, int p_colours, int p_subpixelorder) return (false); } else { DumpBuffer(); - AllocBuffer(newsize); + AllocBuffer(size); } } } @@ -576,7 +620,7 @@ bool Image::WriteJpeg( const char *filename, int quality_override ) const if ( config.colour_jpeg_files && colours == 1 ) { Image temp_image( *this ); - temp_image.Colourise(); + temp_image.Colourise( ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB ); return( temp_image.WriteJpeg( filename, quality_override ) ); } @@ -614,7 +658,7 @@ bool Image::WriteJpeg( const char *filename, int quality_override ) const case ZM_COLOUR_RGB32: { #ifdef JCS_EXTENSIONS - cinfo->input_components = 3; + cinfo->input_components = 4; if(subpixelorder == ZM_SUBPIX_ORDER_BGRA) { cinfo->in_color_space = JCS_EXT_BGRX; } else if(subpixelorder == ZM_SUBPIX_ORDER_ARGB) { @@ -648,7 +692,7 @@ bool Image::WriteJpeg( const char *filename, int quality_override ) const #endif } else { /* Assume RGB */ - cinfo->out_color_space = JCS_RGB; + cinfo->in_color_space = JCS_RGB; } break; } @@ -709,7 +753,7 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, int p_colours pixels = width*height; } - if ( cinfo->num_components != 1 && cinfo->num_components != 3) ) + if ( cinfo->num_components != 1 && cinfo->num_components != 3 ) { Error( "Unexpected colours when reading jpeg image: %d", colours ); jpeg_abort_decompress( cinfo ); @@ -780,7 +824,7 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, int p_colours return (false); } else { DumpBuffer(); - AllocBuffer(newsize); + AllocBuffer(size); } } } @@ -805,7 +849,7 @@ bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_over if ( config.colour_jpeg_files && colours == 1 ) { Image temp_image( *this ); - temp_image.Colourise(); + temp_image.Colourise(ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB ); return( temp_image.EncodeJpeg( outbuffer, outbuffer_size, quality_override ) ); } @@ -837,7 +881,7 @@ bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_over case ZM_COLOUR_RGB32: { #ifdef JCS_EXTENSIONS - cinfo->input_components = 3; + cinfo->input_components = 4; if(subpixelorder == ZM_SUBPIX_ORDER_BGRA) { cinfo->in_color_space = JCS_EXT_BGRX; } else if(subpixelorder == ZM_SUBPIX_ORDER_ARGB) { @@ -869,7 +913,7 @@ bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_over #endif } else { /* Assume RGB */ - cinfo->out_color_space = JCS_RGB; + cinfo->in_color_space = JCS_RGB; } break; } @@ -946,7 +990,8 @@ bool Image::Crop( int lo_x, int lo_y, int hi_x, int hi_y ) } int new_size = new_width*new_height*colours; - uint8_t *new_buffer = zm_allocaligned(16,new_size); + + uint8_t *new_buffer = (uint8_t*)zm_mallocaligned(16,new_size); if(new_buffer == NULL) Panic("Memory allocation failed, out of memory?"); @@ -958,13 +1003,7 @@ bool Image::Crop( int lo_x, int lo_y, int hi_x, int hi_y ) memcpy( pnbuf, pbuf, new_stride ); } - DumpBuffer(); - width = new_width; - height = new_height; - pixels = width*height; - size = allocation = new_size; - buffer = new_buffer; - buffertype = ZM_BUFTYPE_MALLOC; + AssignDirect(new_width, new_height, colours, subpixelorder, new_buffer, new_size, ZM_BUFTYPE_ZM); return( true ); } @@ -974,6 +1013,7 @@ bool Image::Crop( const Box &limits ) return( Crop( limits.LoX(), limits.LoY(), limits.HiX(), limits.HiY() ) ); } + void Image::Overlay( const Image &image ) { if ( !(width == image.width && height == image.height) ) @@ -1000,15 +1040,15 @@ void Image::Overlay( const Image &image ) } else { - Colourise(); + Colourise(ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB ); pdest = buffer; while( pdest < (buffer+size) ) { - if ( RED(psrc) || GREEN(psrc) || BLUE(psrc) ) + if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) { - RED(pdest) = RED(psrc); - GREEN(pdest) = GREEN(psrc); - BLUE(pdest) = BLUE(psrc); + RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); + GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); + BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); } psrc += 3; pdest += 3; @@ -1023,7 +1063,7 @@ void Image::Overlay( const Image &image ) { if ( *psrc ) { - RED(pdest) = GREEN(pdest) = BLUE(pdest) = *psrc++; + RED_PTR_RGBA(pdest) = GREEN_PTR_RGBA(pdest) = BLUE_PTR_RGBA(pdest) = *psrc++; } pdest += 3; } @@ -1032,11 +1072,11 @@ void Image::Overlay( const Image &image ) { while( pdest < (buffer+size) ) { - if ( RED(psrc) || GREEN(psrc) || BLUE(psrc) ) + if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) { - RED(pdest) = RED(psrc); - GREEN(pdest) = GREEN(psrc); - BLUE(pdest) = BLUE(psrc); + RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); + GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); + BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); } psrc += 3; pdest += 3; @@ -1045,6 +1085,7 @@ void Image::Overlay( const Image &image ) } } +/* RGB32 compatible: complete */ void Image::Overlay( const Image &image, int x, int y ) { if ( !(width < image.width || height < image.height) ) @@ -1066,24 +1107,24 @@ void Image::Overlay( const Image &image, int x, int y ) int lo_y = y; int hi_x = (x+image.width)-1; int hi_y = (y+image.height-1); - if ( colours == 1 ) + if ( colours == ZM_COLOUR_GRAY8 ) { - unsigned char *psrc = image.buffer; + const uint8_t *psrc = image.buffer; for ( int y = lo_y; y <= hi_y; y++ ) { - unsigned char *pdest = &buffer[(y*width)+lo_x]; + uint8_t *pdest = &buffer[(y*width)+lo_x]; for ( int x = lo_x; x <= hi_x; x++ ) { *pdest++ = *psrc++; } } } - else if ( colours == 3 ) + else if ( colours == ZM_COLOUR_RGB24 ) { - unsigned char *psrc = image.buffer; + const uint8_t *psrc = image.buffer; for ( int y = lo_y; y <= hi_y; y++ ) { - unsigned char *pdest = &buffer[colours*((y*width)+lo_x)]; + uint8_t *pdest = &buffer[colours*((y*width)+lo_x)]; for ( int x = lo_x; x <= hi_x; x++ ) { *pdest++ = *psrc++; @@ -1092,53 +1133,36 @@ void Image::Overlay( const Image &image, int x, int y ) } } } + else if ( colours == ZM_COLOUR_RGB32 ) + { + const Rgb *psrc = (Rgb*)(image.buffer); + for ( int y = lo_y; y <= hi_y; y++ ) + { + Rgb *pdest = (Rgb*)&buffer[((y*width)+lo_x)<<2]; + for ( int x = lo_x; x <= hi_x; x++ ) + { + *pdest++ = *psrc++; + } + } + } else { + Error("Overlay called with unexpected colours: %d", colours); + } + } void Image::Blend( const Image &image, int transparency ) const { - if ( !(width == image.width && height == image.height && colours == image.colours) ) - { - Panic( "Attempt to blend different sized images, expected %dx%dx%d, got %dx%dx%d", width, height, colours, image.width, image.height, image.colours ); - } - - if ( config.fast_image_blends ) + if ( !(width == image.width && height == image.height && colours == image.colours && subpixelorder == image.subpixelorder) ) { - BlendTablePtr blend_ptr = GetBlendTable( transparency ); - - uint8_t *psrc = image.buffer; - uint8_t *pdest = buffer; - - while( pdest < (buffer+size) ) - { - *pdest++ = (*blend_ptr)[*pdest][*psrc++]; - } + Panic( "Attempt to blend different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, image.width, image.height, image.colours, image.subpixelorder ); } - else - { - if ( !blend_buffer ) - { - blend_buffer = new uint16_t[size]; - - uint16_t *pb = blend_buffer; - uint8_t *p = buffer; - - while( p < (buffer+size) ) - { - *pb++ = (uint16_t)((*p++)<<8); - } - } - - uint8_t *psrc = image.buffer; - uint8_t *pdest = buffer; - uint16_t *pblend = blend_buffer; - int opacity = 100-transparency; - - while( pdest < (buffer+size) ) - { - *pblend = (uint16_t)(((*pblend * opacity)+(((*psrc++)<<8) * transparency))/100); - *pdest++ = (uint8_t)((*pblend++)>>8); - } + + if((size % 16) != 0) { + Warning("Image size is not multiples of 16"); } + + /* Do the blending */ + (*fptr_blend)(buffer, image.buffer, buffer, size, transparency); } Image *Image::Merge( int n_images, Image *images[] ) @@ -1157,7 +1181,7 @@ Image *Image::Merge( int n_images, Image *images[] ) } } - Image *result = new Image( width, height, images[0]->colours ); + Image *result = new Image( width, height, images[0]->colours, images[0]->subpixelorder); int size = result->size; for ( int i = 0; i < size; i++ ) { @@ -1225,7 +1249,7 @@ Image *Image::Highlight( int n_images, Image *images[], const Rgb threshold, con } } - Image *result = new Image( width, height, images[0]->colours ); + Image *result = new Image( width, height, images[0]->colours, images[0]->subpixelorder ); int size = result->size; for ( int c = 0; c < 3; c++ ) { @@ -1253,90 +1277,56 @@ Image *Image::Highlight( int n_images, Image *images[], const Rgb threshold, con /* New function to allow buffer re-using instead of allocationg memory for the delta image everytime */ void Image::Delta( const Image &image, Image* targetimage) const { - if ( !(width == image.width && height == image.height && colours == image.colours) ) + if ( !(width == image.width && height == image.height && colours == image.colours && subpixelorder == image.subpixelorder) ) { - Panic( "Attempt to get delta of different sized images, expected %dx%dx%d, got %dx%dx%d", width, height, colours, image.width, image.height, image.colours ); + Panic( "Attempt to get delta of different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, image.width, image.height, image.colours, image.subpixelorder); } - if(bufsize < this->Size()) - { - /* Graceful handling */ - Error("Mismatched buffer size for storing delta image. Required: %u bytes Supplied: %u bytes. Trimming output buffer to match.",this->Size(),bufsize); - } - else if (bufsize > this->Size()) - { - /* Target buffer is larger. match the size to original image size */ - bufsize = this->Size(); - } + uint8_t *pdiff = targetimage->WriteBuffer(width, height, ZM_COLOUR_GRAY8, ZM_SUBPIX_ORDER_NONE); - uint8_t *psrc = buffer; - uint8_t *pref = image->Buffer(); - uint8_t *pdiff = targetbuf; - - if ( colours == 1 ) - { - while( psrc < (buffer+bufsize) ) - { - //*pdiff++ = abs( *psrc++ - *pref++ ); - //*pdiff++ = ABSDIFF( *psrc, *pref ); - *pdiff++ = abs_table[*psrc++ - *pref++]; - //psrc++; - //pref++; - } + if(pdiff == NULL) { + Panic("Failed requesting writeable buffer for storing the delta image"); } - else if ( colours == 3 ) - { - int red, green, blue; - while( psrc < (buffer+bufsize) ) - { - if ( config.y_image_deltas ) - { - //Info( "RS:%d, RR: %d", *psrc, *pref ); - red = y_r_table[*psrc++ - *pref++]; - //Info( "GS:%d, GR: %d", *psrc, *pref ); - green = y_g_table[*psrc++ - *pref++]; - //Info( "BS:%d, BR: %d", *psrc, *pref ); - blue = y_b_table[*psrc++ - *pref++]; - - //Info( "R:%d, G:%d, B:%d, D:%d", red, green, blue, abs_table[red + green + blue] ); - *pdiff++ = abs_table[red + green + blue]; - } - else - { - red = abs_table[*psrc++ - *pref++]; - green = abs_table[*psrc++ - *pref++]; - blue = abs_table[*psrc++ - *pref++]; - - // This is uses an RMS function, all floating point and - // rather too slow - //*pdiff++ = (uint8_t)sqrt((red*red + green*green + blue*blue)/3); - - // This just uses the average difference, much faster - // *pdiff++ = (uint8_t)((red + green + blue)/3); - - /* Use fast algorithm for almost identical ITU-R BT.709 weighting */ - *pdiff++ = (red + red + blue + green + (green<<2))>>3; - } - } - } - - else if ( colours == 4 ) /* RGB32 */ - { + switch(colours) { + case ZM_COLOUR_RGB24: + { + if(subpixelorder == ZM_SUBPIX_ORDER_BGR) { + /* BGR subpixel order */ + (*fptr_delta8_bgr)(buffer, image.buffer, pdiff, pixels); + } else { + /* Assume RGB subpixel order */ + (*fptr_delta8_rgb)(buffer, image.buffer, pdiff, pixels); + } + break; + } + case ZM_COLOUR_RGB32: + { + if(subpixelorder == ZM_SUBPIX_ORDER_ARGB) { + /* ARGB subpixel order */ + (*fptr_delta8_argb)(buffer, image.buffer, pdiff, pixels); + } else if(subpixelorder == ZM_SUBPIX_ORDER_ABGR) { + /* ABGR subpixel order */ + (*fptr_delta8_abgr)(buffer, image.buffer, pdiff, pixels); + } else if(subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + /* BGRA subpixel order */ + (*fptr_delta8_bgra)(buffer, image.buffer, pdiff, pixels); + } else { + /* Assume RGBA subpixel order */ + (*fptr_delta8_rgba)(buffer, image.buffer, pdiff, pixels); + } + break; + } + case ZM_COLOUR_GRAY8: + (*fptr_delta8_gray8)(buffer, image.buffer, pdiff, pixels); + break; + default: + Panic("Delta called with unexpected colours: %d",colours); + break; } } -/* Backwards compatibility */ -Image *Image::Delta( const Image &image ) const -{ - Image *result = new Image( width, height, 1, subpixelorder); - if(result == NULL) - Panic("Memory allocation failed, out of memory?"); - Delta(image,result->buffer,result->Size()); - return result; -} - -const Coord Image::centreCoord( const char *text ) +const Coord Image::centreCoord( const char *text ) const { int index = 0; int line_no = 0; @@ -1363,6 +1353,7 @@ const Coord Image::centreCoord( const char *text ) return( Coord( x, y ) ); } +/* RGB32 compatible: complete */ void Image::Annotate( const char *p_text, const Coord &coord, const Rgb fg_colour, const Rgb bg_colour ) { strncpy( text, p_text, sizeof(text) ); @@ -1373,22 +1364,25 @@ void Image::Annotate( const char *p_text, const Coord &coord, const Rgb fg_colou int line_len = 0; const char *line = text; - const uint8_t fg_r_col = RGB_RED_VAL(fg_colour); - const uint8_t fg_g_col = RGB_GREEN_VAL(fg_colour); - const uint8_t fg_b_col = RGB_BLUE_VAL(fg_colour); + const uint8_t fg_r_col = RED_VAL_RGBA(fg_colour); + const uint8_t fg_g_col = GREEN_VAL_RGBA(fg_colour); + const uint8_t fg_b_col = BLUE_VAL_RGBA(fg_colour); const uint8_t fg_bw_col = fg_colour & 0xff; - const Rgb fg_rgb_col = rgb_convert(fg_colour,subpixelorder) + const Rgb fg_rgb_col = rgb_convert(fg_colour,subpixelorder); const bool fg_trans = (fg_colour == RGB_TRANSPARENT); - const uint8_t bg_r_col = RGB_RED_VAL(bg_colour); - const uint8_t bg_g_col = RGB_GREEN_VAL(bg_colour); - const uint8_t bg_b_col = RGB_BLUE_VAL(bg_colour); + const uint8_t bg_r_col = RED_VAL_RGBA(bg_colour); + const uint8_t bg_g_col = GREEN_VAL_RGBA(bg_colour); + const uint8_t bg_b_col = BLUE_VAL_RGBA(bg_colour); const uint8_t bg_bw_col = bg_colour & 0xff; const Rgb bg_rgb_col = rgb_convert(bg_colour,subpixelorder); const bool bg_trans = (bg_colour == RGB_TRANSPARENT); while ( (index < text_len) && (line_len = strcspn( line, "\n" )) ) { + /* REMOVE LATER */ + Debug(3,"annotate iteration!"); + int line_width = line_len * CHAR_WIDTH; int lo_line_x = coord.X(); @@ -1458,16 +1452,16 @@ void Image::Annotate( const char *p_text, const Coord &coord, const Rgb fg_colou { if ( !fg_trans ) { - RED(temp_ptr) = fg_r_col; - GREEN(temp_ptr) = fg_g_col; - BLUE(temp_ptr) = fg_b_col; + RED_PTR_RGBA(temp_ptr) = fg_r_col; + GREEN_PTR_RGBA(temp_ptr) = fg_g_col; + BLUE_PTR_RGBA(temp_ptr) = fg_b_col; } } else if ( !bg_trans ) { - RED(temp_ptr) = bg_r_col; - GREEN(temp_ptr) = bg_g_col; - BLUE(temp_ptr) = bg_b_col; + RED_PTR_RGBA(temp_ptr) = bg_r_col; + GREEN_PTR_RGBA(temp_ptr) = bg_g_col; + BLUE_PTR_RGBA(temp_ptr) = bg_b_col; } } } @@ -1477,10 +1471,10 @@ void Image::Annotate( const char *p_text, const Coord &coord, const Rgb fg_colou { int wc = width * colours; - unsigned char *ptr = &buffer[((lo_line_y*width)+lo_line_x)*colours]; + uint8_t *ptr = &buffer[((lo_line_y*width)+lo_line_x)<<2]; for ( int y = lo_line_y, r = 0; y < hi_line_y && r < CHAR_HEIGHT; y++, r++, ptr += wc ) { - Rgb* temp_ptr = ptr; + Rgb* temp_ptr = (Rgb*)ptr; for ( int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ ) { int f = fontdata[(line[c] * CHAR_HEIGHT) + r]; @@ -1534,7 +1528,6 @@ void Image::Timestamp( const char *label, const time_t when, const Coord &coord void Image::Colourise(const int p_reqcolours, const int p_reqsubpixelorder) { - Debug(9, "Colourise: Req colours: %u Req subpixel order: %u Current colours: %u Current subpixel order: %u",p_reqcolours,p_reqsubpixelorder,colours,subpixelorder); if ( colours != ZM_COLOUR_GRAY8) { @@ -1544,8 +1537,7 @@ void Image::Colourise(const int p_reqcolours, const int p_reqsubpixelorder) if ( p_reqcolours == ZM_COLOUR_RGB32 ) { /* RGB32 */ - unsigned int totalpixels = width * height; - Rgb* new_buffer = (Rgb*)memalign(16,totalpixels*4); + Rgb* new_buffer = (Rgb*)zm_mallocaligned(16,pixels*sizeof(Rgb)); const uint8_t *psrc = buffer; Rgb* pdest = new_buffer; @@ -1554,7 +1546,7 @@ void Image::Colourise(const int p_reqcolours, const int p_reqsubpixelorder) if ( p_reqsubpixelorder == ZM_SUBPIX_ORDER_ABGR || p_reqsubpixelorder == ZM_SUBPIX_ORDER_ARGB) { /* ARGB\ABGR subpixel order. alpha byte is first (mem+0), so we need to shift the pixel left in the end */ - for(int i=0;i>3; + } else { /* RGB subpixel order */ - *pdest++ = RGB_FASTLUM_VALUES_ITU709(RED_RGBA(psrc),GREEN_RGBA(psrc),BLUE_RGBA(psrc)); + r = RED_PTR_RGBA(psrc); + g = GREEN_PTR_RGBA(psrc); + b = BLUE_PTR_RGBA(psrc); + *pdest++ = (r + r + b + g + g + g + g + g)>>3; + } psrc += 3; } } - else if ( colours == 4 ) - { - const Rgb *psrc = buffer; - - switch(subpixelorder) { - case ZM_SUBPIX_ORDER_BGRA: - /* BGRA subpixel order */ - for(unsigned int=0; i 32) { /* Don't bother with less than 32 pixels */ - __m128i xmm0; - Rgb srcpixels[4] __attribute__((aligned(16))) = {colour,colour,colour,colour}; - unsigned int remainder = count % 4; - count -= remainder; /* Only process multiples of 4 */ - - /* Aligned load into a XMM register */ - _mm_store_si128(&xmm0,*(__m128i*)srcpixels); - - /* Fill 4 pixels at a time */ - for (unsigned int i=0; i < count; p += 4, i += 4) - _mm_stream_si128((__m128i*)p,xmm0); - - /* Fill the remaining pixels */ - for (unsigned int i=0;i ZM_SCALE_BASE ) { @@ -2357,12 +2287,8 @@ void Image::Scale( unsigned int factor ) new_height = last_h_index; } - if(buffertype == ZM_BUFTYPE_DONTFREE) { - Assign( new_width, new_height, colours, subpixelorder, scale_buffer ); - } else { - /* Directly assign the new buffer and make sure it will be freed when not needed anymore */ - AssignDirect( new_width, new_height, colours, subpixelorder, scale_buffer, scale_buffer_size, ZM_BUFTYPE_MALLOC); - } + AssignDirect( new_width, new_height, colours, subpixelorder, scale_buffer, scale_buffer_size, ZM_BUFTYPE_ZM); + } @@ -2370,8 +2296,8 @@ void Image::Scale( unsigned int factor ) __attribute__ ((noinline)) void sse2_fastblend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { - int divider; - uint32_t clearmask; + int divider = 0; + uint32_t clearmask = 0; unsigned long i = 0; /* Attempt to match the blending percent to one of the possible values */ @@ -2427,8 +2353,7 @@ __attribute__ ((noinline)) void sse2_fastblend(uint8_t* col1, uint8_t* col2, uin } __attribute__ ((noinline)) void std_fastblend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { - int divider; - unsigned long i = 0; + int divider = 0; /* Attempt to match the blending percent to one of the possible values */ if(blendpercent < 2.34375) { @@ -2485,7 +2410,7 @@ __attribute__ ((noinline)) void std_blend(uint8_t* col1, uint8_t* col2, uint8_t* /************************************************* DELTA FUNCTIONS *************************************************/ /* Grayscale */ -__attribute__ ((noinline)) int std_delta8_gray8(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__ ((noinline)) void std_delta8_gray8(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 16 bytes (16 grayscale pixels) at a time */ for(unsigned int i=0;i #if HAVE_ZLIB_H #include @@ -78,8 +82,9 @@ protected: free(buffer); else if(buffertype == ZM_BUFTYPE_NEW) delete buffer; - else if(buffertype == ZM_BUFTYPE_AVMALLOC) + /*else if(buffertype == ZM_BUFTYPE_AVMALLOC) av_free(buffer); + */ } buffer = NULL; allocation = 0; @@ -138,7 +143,7 @@ public: inline int Height() const { return( height ); } inline int Pixels() const { return( pixels ); } inline int Colours() const { return( colours ); } - inline int SubpixelOrder const { return( subpixelorder ); } + inline int SubpixelOrder() const { return( subpixelorder ); } inline int Size() const { return( size ); } /* Internal buffer should not be modified from functions outside of this class */ @@ -162,9 +167,9 @@ public: width = height = colours = size = pixels = subpixelorder = 0; } - void Assign( int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t* new_buffer ); + void Assign( int p_width, int p_height, int p_colours, int p_subpixelorder, const uint8_t* new_buffer, const size_t buffer_size); void Assign( const Image &image ); - void AssignDirect( const int p_width, const int p_height, const int p_colours, const int p_subpixelorder, const uint8_t *new_buffer, const size_t buffer_size, const int p_buffertype); + void AssignDirect( const int p_width, const int p_height, const int p_colours, const int p_subpixelorder, uint8_t *new_buffer, const size_t buffer_size, const int p_buffertype); inline void CopyBuffer( const Image &image ) { @@ -172,7 +177,7 @@ public: { Panic( "Attempt to copy different size image buffers, expected %d, got %d", size, image.size ); } - sse2_aligned_memcpy( buffer, image->Buffer(), size ); + sse2_aligned_memcpy( buffer, image.buffer, size ); } inline Image &operator=( const unsigned char *new_buffer ) { @@ -203,14 +208,14 @@ public: static Image *Merge( int n_images, Image *images[], double weight ); static Image *Highlight( int n_images, Image *images[], const Rgb threshold=RGB_BLACK, const Rgb ref_colour=RGB_RED ); //Image *Delta( const Image &image ) const; - void Image::Delta( const Image &image, Image* targetimage) const; + void Delta( const Image &image, Image* targetimage) const; const Coord centreCoord( const char *text ) const; void Annotate( const char *p_text, const Coord &coord, const Rgb fg_colour=RGB_WHITE, const Rgb bg_colour=RGB_BLACK ); Image *HighlightEdges( Rgb colour, const Box *limits=0 ); //Image *HighlightEdges( Rgb colour, const Polygon &polygon ); void Timestamp( const char *label, const time_t when, const Coord &coord ); - void Colourise(); + void Colourise(const int p_reqcolours, const int p_reqsubpixelorder); void DeColourise(); void Clear() { memset( buffer, 0, size ); } @@ -231,3 +236,21 @@ public: typedef void (*blend_fptr_t)(uint8_t*, uint8_t*, uint8_t*, unsigned long, double); typedef void (*delta_fptr_t)(uint8_t*, uint8_t*, uint8_t*, unsigned long); +/* Blend functions */ +void sse2_fastblend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent); +void std_fastblend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent); +void std_blend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent); + +/* Delta functions */ +void std_delta8_gray8(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); +void std_delta8_rgb(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); +void std_delta8_bgr(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); +void std_delta8_rgba(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); +void std_delta8_bgra(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); +void std_delta8_argb(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); +void std_delta8_abgr(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); +void sse2_delta8_gray8(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); +void ssse3_delta8_rgba(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); +void ssse3_delta8_bgra(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); +void ssse3_delta8_argb(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); +void ssse3_delta8_abgr(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); \ No newline at end of file diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index d8494c557..a005e013b 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -82,10 +82,10 @@ static PixelFormat getFfPixFormatFromV4lPalette( int v4l_version, int palette ) pixFormat = PIX_FMT_RGB24; break; case V4L2_PIX_FMT_BGR32 : - pixFormat = PIX_FMT_BGR32; + pixFormat = PIX_FMT_BGRA; break; case V4L2_PIX_FMT_RGB32 : - pixFormat = PIX_FMT_RGB32; + pixFormat = PIX_FMT_ARGB; break; case V4L2_PIX_FMT_GREY : pixFormat = PIX_FMT_GRAY8; @@ -192,9 +192,9 @@ static PixelFormat getFfPixFormatFromV4lPalette( int v4l_version, int palette ) { case VIDEO_PALETTE_RGB32 : if(BigEndian) - pixFormat = PIX_FMT_RGBA; + pixFormat = PIX_FMT_ARGB; else - pixFormat = PIX_FMT_BGRA; // Or should it be ABGR? + pixFormat = PIX_FMT_BGRA; break; case VIDEO_PALETTE_RGB24 : if(BigEndian) @@ -357,36 +357,30 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, switch( palette ) { case V4L2_PIX_FMT_RGB32 : - colours = 4; - /* Not sure whats the correct format here, Some say ARGB, some say RGBA. */ subpixelorder = ZM_SUBPIX_ORDER_ARGB; #if HAVE_LIBSWSCALE imagePixFormat = PIX_FMT_ARGB; #endif break; case V4L2_PIX_FMT_BGR32 : - colours = 4; subpixelorder = ZM_SUBPIX_ORDER_BGRA; #if HAVE_LIBSWSCALE imagePixFormat = PIX_FMT_BGRA; #endif break; case V4L2_PIX_FMT_RGB24 : - colours = 3; subpixelorder = ZM_SUBPIX_ORDER_RGB; #if HAVE_LIBSWSCALE imagePixFormat = PIX_FMT_RGB24; #endif break; case V4L2_PIX_FMT_BGR24 : - colours = 3; subpixelorder = ZM_SUBPIX_ORDER_BGR; #if HAVE_LIBSWSCALE imagePixFormat = PIX_FMT_BGR24; #endif break; case V4L2_PIX_FMT_GREY : - colours = 1; subpixelorder = ZM_SUBPIX_ORDER_NONE; /* Not needed but just in case */ #if HAVE_LIBSWSCALE imagePixFormat = PIX_FMT_GRAY8; @@ -394,7 +388,6 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, break; default : /* Use RGB24 for formas other than grayscale and RGB32\BGR32 and use RGB subpixel order */ - colours = 3; subpixelorder = ZM_SUBPIX_ORDER_RGB; #if HAVE_LIBSWSCALE imagePixFormat = PIX_FMT_RGB24; @@ -408,22 +401,19 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, switch( palette ) { case VIDEO_PALETTE_RGB32 : - colours = 4; if(BigEndian) { - subpixelorder = ZM_SUBPIX_ORDER_RGBA; + subpixelorder = ZM_SUBPIX_ORDER_ARGB; #if HAVE_LIBSWSCALE - imagePixFormat = PIX_FMT_RGBA; + imagePixFormat = PIX_FMT_ARGB; #endif } else { - /* TODO: Verify that RGB32 in V4L1 on little-endian is BGRA and not ABGR */ subpixelorder = ZM_SUBPIX_ORDER_BGRA; #if HAVE_LIBSWSCALE - imagePixFormat = PIX_FMT_BGRA; // Or should it be ABGR? + imagePixFormat = PIX_FMT_BGRA; #endif } break; case VIDEO_PALETTE_RGB24 : - colours = 3; if(BigEndian) { subpixelorder = ZM_SUBPIX_ORDER_RGB; #if HAVE_LIBSWSCALE @@ -437,15 +427,12 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, } break; case VIDEO_PALETTE_GREY : - colours = 3; subpixelorder = ZM_SUBPIX_ORDER_NONE; #if HAVE_LIBSWSCALE imagePixFormat = PIX_FMT_GRAY8; #endif break; default : - /* Use RGB24 for formas other than grayscale and RGB32\BGR32 and use RGB subpixel order */ - colours = 3; subpixelorder = ZM_SUBPIX_ORDER_RGB; #if HAVE_LIBSWSCALE imagePixFormat = PIX_FMT_RGB24; @@ -454,9 +441,6 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, } } #endif // ZM_HAS_V4L1 - - /* Fix the image size to be correct, based on the colours */ - imagesize = pixels * colours; #if HAVE_LIBSWSCALE capturePixFormat = getFfPixFormatFromV4lPalette( v4l_version, palette ); @@ -1703,6 +1687,7 @@ int LocalCamera::Capture( Image &image ) Debug( 3, "Capturing" ); uint8_t* buffer = NULL; + uint8_t* swscale_buffer = NULL; int captures_per_frame = 1; if ( channel_count > 1 ) @@ -1792,7 +1777,7 @@ int LocalCamera::Capture( Image &image ) static struct SwsContext *imgConversionContext = NULL; static AVFrame *tmpPicture = NULL; static int pSize = ZM_MAX_IMAGE_SIZE; - uint8_t* swscale_buffer = NULL; + swscale_buffer = NULL; if ( imagePixFormat != capturePixFormat || captureWidth != width || captureHeight != height ) { if ( !imgConversionContext ) diff --git a/src/zm_mem_utils.h b/src/zm_mem_utils.h index 0a462073b..0f9d9acac 100644 --- a/src/zm_mem_utils.h +++ b/src/zm_mem_utils.h @@ -20,26 +20,33 @@ #ifndef ZM_MEM_UTILS_H #define ZM_MEM_UTILS_H +#include +#include "zm.h" inline void* zm_mallocaligned(unsigned int reqalignment, size_t reqsize) { - uint8_t* alloc; uint8_t* retptr; #if HAVE_POSIX_MEMALIGN - if(posix_memalign(&alloc,reqalignment,reqsize) != 0) + if(posix_memalign((void**)&retptr,reqalignment,reqsize) != 0) return NULL; + + return retptr; #else + uint8_t* alloc; retptr = (uint8_t*)malloc(reqsize+reqalignment+sizeof(void*)); if(retptr == NULL) return NULL; - if((retptr % reqalignment) != 0) - alloc = retptr + (reqalignment - (retptr % reqalignment)); + alloc = retptr + sizeof(void*); - /* Store a pointer before to the start of the block, just before returned aligned memory */ - *(alloc - sizeof(void*)) = retptr; + if(((long)alloc % reqalignment) != 0) + alloc = alloc + (reqalignment - ((long)alloc % reqalignment)); + + /* Store a pointer before to the start of the block, just before returned aligned memory */ + *(void**)(alloc - sizeof(void*)) = retptr; + + return alloc; #endif - return alloc; } inline void zm_freealigned(void* ptr) { @@ -47,7 +54,7 @@ inline void zm_freealigned(void* ptr) { free(ptr); #else /* Start of block is stored before the block if it was allocated by zm_mallocaligned */ - free((void*)*((uint8_t*)ptr - sizeof(void*))); + free(*(void**)((uint8_t*)ptr - sizeof(void*))); #endif } diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 89de1b1c0..40cb8280f 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -394,9 +394,9 @@ Monitor::Monitor( struct timeval *shared_timestamps = (struct timeval *)((char *)trigger_data + sizeof(TriggerData)); unsigned char *shared_images = (unsigned char *)((char *)shared_timestamps + (image_buffer_count*sizeof(struct timeval))); - if((shared_images % 16) != 0) { + if(((unsigned long)shared_images % 16) != 0) { /* Align images buffer to nearest 16 byte boundary */ - shared_images += (16 - (shared_images % 16)); + shared_images = (uint8_t*)((unsigned long)shared_images + (16 - ((unsigned long)shared_images % 16))); } if ( purpose == CAPTURE ) @@ -510,7 +510,7 @@ Monitor::Monitor( Warning( "Waiting for capture daemon" ); sleep( 1 ); } - ref_image.Assign( width, height, camera->Colours(), camera->SubpixelOrder(), image_buffer[shared_data->last_write_index].image->Buffer()); + ref_image.Assign( width, height, camera->Colours(), camera->SubpixelOrder(), image_buffer[shared_data->last_write_index].image->Buffer(), camera->ImageSize()); n_linked_monitors = 0; linked_monitors = 0; @@ -939,7 +939,7 @@ void Monitor::DumpZoneImage( const char *zone_string ) Image *snap_image = snap->image; Image zone_image( *snap_image ); - zone_image.Colourise(); + zone_image.Colourise(ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB ); for( int i = 0; i < n_zones; i++ ) { if ( exclude_id && (!extra_colour || extra_zone.getNumCoords()) && zones[i]->Id() == exclude_id ) @@ -1017,11 +1017,11 @@ bool Monitor::CheckSignal( const Image *image ) if ( static_undef ) { static_undef = false; - red_val = RGB_RED_VAL(signal_check_colour); - green_val = RGB_GREEN_VAL(signal_check_colour); - blue_val = RGB_BLUE_VAL(signal_check_colour); - color_val = RGB_ZEROALPHA(signal_check_colour); /* Clear alpha byte */ - grayscale_val = 0x000000ffu & signal_check_colour; /* Clear all bytes but lowest byte */ + red_val = RED_VAL_RGBA(signal_check_colour); + green_val = GREEN_VAL_RGBA(signal_check_colour); + blue_val = BLUE_VAL_RGBA(signal_check_colour); + color_val = RGBA_BGRA_ZEROALPHA(signal_check_colour); /* Clear alpha byte */ + grayscale_val = 0xff & signal_check_colour; /* Clear all bytes but lowest byte */ } const uint8_t *buffer = image->Buffer(); @@ -1048,11 +1048,11 @@ bool Monitor::CheckSignal( const Image *image ) } else if(colours == 3) { const uint8_t *ptr = buffer+(index*colours); - if ( (RED(ptr) != red_val) || (GREEN(ptr) != green_val) || (BLUE(ptr) != blue_val) ) + if ( (RED_PTR_RGBA(ptr) != red_val) || (GREEN_PTR_RGBA(ptr) != green_val) || (BLUE_PTR_RGBA(ptr) != blue_val) ) return true; } else if(colours == 4) { - if ( RGB_ZEROALPHA(*(((const Rgb*)buffer)+index)) != color_val ) + if ( RGBA_BGRA_ZEROALPHA(*(((const Rgb*)buffer)+index)) != color_val ) return true; } @@ -2730,7 +2730,7 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z ref_image.WriteJpeg( diag_path ); } - Image *delta_image = ref_image.Delta( comp_image ); + ref_image.Delta( comp_image, &delta_image); if ( config.record_diag_images ) { @@ -3391,7 +3391,7 @@ bool MonitorStream::sendFrame( Image *image, struct timeval *timestamp ) break; case STREAM_RAW : fprintf( stdout, "Content-Type: image/x-rgb\r\n" ); - img_buffer = send_image->Buffer(); + img_buffer = (uint8_t*)send_image->Buffer(); img_buffer_size = send_image->Size(); break; case STREAM_ZIP : diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 9cb28b8d0..a08b218c9 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -23,6 +23,7 @@ #include "zm.h" #include "zm_coord.h" #include "zm_image.h" +#include "zm_rgb.h" #include "zm_zone.h" #include "zm_event.h" #include "zm_camera.h" @@ -301,7 +302,7 @@ public: unsigned int Width() const { return( width ); } unsigned int Height() const { return( height ); } unsigned int Colours() const { return( camera->Colours() ); } - unsigned int SubpixelOrder const { return( camera->SubpixelOrder() ); } + unsigned int SubpixelOrder() const { return( camera->SubpixelOrder() ); } State GetState() const; diff --git a/src/zm_mpeg.cpp b/src/zm_mpeg.cpp index 5dd4c176b..ca06449df 100644 --- a/src/zm_mpeg.cpp +++ b/src/zm_mpeg.cpp @@ -303,7 +303,7 @@ VideoStream::~VideoStream() av_free(ofc); } -double VideoStream::EncodeFrame( uint8_t *buffer, int buffer_size, bool add_timestamp, unsigned int timestamp ) +double VideoStream::EncodeFrame( const uint8_t *buffer, int buffer_size, bool add_timestamp, unsigned int timestamp ) { #ifdef HAVE_LIBSWSCALE static struct SwsContext *img_convert_ctx = 0; diff --git a/src/zm_mpeg.h b/src/zm_mpeg.h index ff363bb39..4ac88e5ec 100644 --- a/src/zm_mpeg.h +++ b/src/zm_mpeg.h @@ -62,7 +62,7 @@ public: ~VideoStream(); const char *MimeType() const; void OpenStream(); - double EncodeFrame( uint8_t *buffer, int buffer_size, bool add_timestamp=false, unsigned int timestamp=0 ); + double EncodeFrame( const uint8_t *buffer, int buffer_size, bool add_timestamp=false, unsigned int timestamp=0 ); }; #endif // HAVE_LIBAVCODEC diff --git a/src/zm_remote_camera_http.cpp b/src/zm_remote_camera_http.cpp index 9e8e31fdf..7f714d960 100644 --- a/src/zm_remote_camera_http.cpp +++ b/src/zm_remote_camera_http.cpp @@ -1102,7 +1102,7 @@ int RemoteCameraHttp::Capture( Image &image ) { case JPEG : { - if ( !image.DecodeJpeg( buffer.extract( content_length ), content_length ) ) + if ( !image.DecodeJpeg( buffer.extract( content_length ), content_length, colours, subpixelorder ) ) { Error( "Unable to decode jpeg" ); Disconnect(); @@ -1118,7 +1118,7 @@ int RemoteCameraHttp::Capture( Image &image ) Disconnect(); return( -1 ); } - image.Assign( width, height, colours, buffer ); + image.Assign( width, height, colours, subpixelorder, buffer, imagesize ); break; } case X_RGBZ : @@ -1129,7 +1129,7 @@ int RemoteCameraHttp::Capture( Image &image ) Disconnect(); return( -1 ); } - image.Assign( width, height, colours, buffer ); + image.Assign( width, height, colours, subpixelorder, buffer, imagesize ); break; } default : diff --git a/src/zm_remote_camera_rtsp.cpp b/src/zm_remote_camera_rtsp.cpp index 56618aa64..a390f546c 100644 --- a/src/zm_remote_camera_rtsp.cpp +++ b/src/zm_remote_camera_rtsp.cpp @@ -247,7 +247,7 @@ int RemoteCameraRtsp::Capture( Image &image ) sws_scale( img_convert_ctx, picture->data, picture->linesize, 0, height, tmp_picture->data, tmp_picture->linesize ); - image.Assign( width, height, colours, tmp_picture->data[0] ); + image.Assign( width, height, colours, subpixelorder, tmp_picture->data[0], imagesize); frameCount++; diff --git a/src/zm_rgb.h b/src/zm_rgb.h index a5f8d5d82..64af4b975 100644 --- a/src/zm_rgb.h +++ b/src/zm_rgb.h @@ -84,8 +84,8 @@ typedef uint32_t Rgb; // RGB colour type #define ALPHA_PTR_ABGR(ptr) (*((uint8_t*)ptr)) -#define RGBA_BGRA_ZEROALPHA(v) ((v)&0x00ffffff)) -#define ARGB_ABGR_ZEROALPHA(v) ((v)&0xffffff00)) +#define RGBA_BGRA_ZEROALPHA(v) ((v)&0x00ffffff) +#define ARGB_ABGR_ZEROALPHA(v) ((v)&0xffffff00) /* ITU-R BT.709: Y = (0.2126 * R) + (0.7152 * G) + (0.0722 * B) */ /* ITU-R BT.601: Y = (0.299 * R) + (0.587 * G) + (0.114 * B) */ @@ -119,29 +119,29 @@ inline Rgb rgb_convert(Rgb p_col, int p_subpixorder) { Rgb result; switch(p_subpixorder) { - + case ZM_SUBPIX_ORDER_BGR: case ZM_SUBPIX_ORDER_BGRA: { BLUE_PTR_BGRA(&result) = BLUE_VAL_RGBA(p_col); GREEN_PTR_BGRA(&result) = GREEN_VAL_RGBA(p_col); RED_PTR_BGRA(&result) = RED_VAL_RGBA(p_col); - return result; } + break; case ZM_SUBPIX_ORDER_ARGB: { BLUE_PTR_ARGB(&result) = BLUE_VAL_RGBA(p_col); GREEN_PTR_ARGB(&result) = GREEN_VAL_RGBA(p_col); RED_PTR_ARGB(&result) = RED_VAL_RGBA(p_col); - return result; } + break; case ZM_SUBPIX_ORDER_ABGR: { BLUE_PTR_ABGR(&result) = BLUE_VAL_RGBA(p_col); GREEN_PTR_ABGR(&result) = GREEN_VAL_RGBA(p_col); RED_PTR_ABGR(&result) = RED_VAL_RGBA(p_col); - return result; } + break; /* Grayscale */ case ZM_SUBPIX_ORDER_NONE: { @@ -149,8 +149,10 @@ inline Rgb rgb_convert(Rgb p_col, int p_subpixorder) { } default: return p_col; - + break; } + + return result; } #endif // ZM_RGB_H diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index 487477820..dc1412b96 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -233,7 +233,7 @@ bool StreamBase::sendTextFrame( const char *frame_text ) { Debug( 2, "Sending text frame '%s'", frame_text ); - Image image( monitor->Width(), monitor->Height(), monitor->Colours() ); + Image image( monitor->Width(), monitor->Height(), monitor->Colours(), monitor->SubpixelOrder() ); image.Annotate( frame_text, image.centreCoord( frame_text ) ); if ( scale != 100 ) diff --git a/src/zm_utils.cpp b/src/zm_utils.cpp index 4f13af1b8..6383084b2 100644 --- a/src/zm_utils.cpp +++ b/src/zm_utils.cpp @@ -18,8 +18,10 @@ // //#include "zm_logger.h" +#include "zm.h" #include "zm_utils.h" +#include #include #include @@ -166,31 +168,31 @@ void ssedetect() { if (r_ecx & 0x00000100) { sseversion = 35; /* SSSE3 */ - Debug(1,"Detected a x86\\x86-64 processor with SSSE3."); + Debug(1,"Detected a x86\\x86-64 processor with SSSE3"); } else if (r_ecx & 0x00000001) { sseversion = 30; /* SSE3 */ - Debug(1,"Detected a x86\\x86-64 processor with SSE3."); + Debug(1,"Detected a x86\\x86-64 processor with SSE3"); } else if (r_edx & 0x04000000) { sseversion = 20; /* SSE2 */ - Debug(1,"Detected a x86\\x86-64 processor with SSE2."); + Debug(1,"Detected a x86\\x86-64 processor with SSE2"); } else if (r_edx & 0x02000000) { sseversion = 10; /* SSE */ - Debug(1,"Detected a x86\\x86-64 processor with SSE."); + Debug(1,"Detected a x86\\x86-64 processor with SSE"); } else { sseversion = 0; - Debug(1,"Detected a x86\\x86-64 processor."); + Debug(1,"Detected a x86\\x86-64 processor"); } #else /* Non x86 or x86-64 processor, SSE2 is not available */ - Debug(1,"Detected a non x86\\x86-64 processor."); + Debug(1,"Detected a non x86\\x86-64 processor"); sseversion = 0; #endif } /* Aligned SSE2 memory copy. Useful for copying big things like image buffers in ZM */ /* This requires source and target memory to be aligned on 16byte boundary, or a general protection fault will occur, therefore we check for unaligned memory */ -void sse2memcpy(unsigned char* dest, const unsigned char* src, const size_t bytes) { +void sse2_aligned_memcpy(unsigned char* dest, const unsigned char* src, const size_t bytes) { memcpy(dest,src,bytes); } diff --git a/src/zm_utils.h b/src/zm_utils.h index 74b90743b..fa55624bd 100644 --- a/src/zm_utils.h +++ b/src/zm_utils.h @@ -44,7 +44,7 @@ inline int min( int a, int b ) } void ssedetect(); -void sse2memcpy(unsigned char* dest, const unsigned char* src, const size_t bytes); +void sse2_aligned_memcpy(unsigned char* dest, const unsigned char* src, const size_t bytes); extern unsigned int sseversion; diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index 247151425..125a23b8a 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -75,7 +75,7 @@ void Zone::Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_ ranges[py].lo_x = -1; ranges[py].hi_x = -1; ranges[py].off_x = 0; - unsigned char *ppoly = pg_image->Buffer( 0, py ); + const uint8_t *ppoly = pg_image->Buffer( 0, py ); for ( int px = 0; px < polygon.Width(); px++, x++, ppoly++ ) { if ( *ppoly ) @@ -131,6 +131,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) // Get the difference image Image *diff_image = image = new Image( *delta_image ); int diff_width = diff_image->Width(); + uint8_t* diff_buff = (uint8_t*)diff_image->Buffer(); unsigned long pixel_diff_count = 0; @@ -150,7 +151,8 @@ bool Zone::CheckAlarms( const Image *delta_image ) Debug( 4, "Checking alarms for zone %d/%s in lines %d -> %d", id, label, lo_y, hi_y ); Debug( 5, "Checking for alarmed pixels" ); - unsigned char *pdiff, *ppoly; + uint8_t *pdiff; + const uint8_t *ppoly; // Create an upper margin if ( lo_y > 0 ) { @@ -160,7 +162,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) hi_x = ranges[0].hi_x; if ( hi_x < (diff_width-1) ) hi_x++; - pdiff = diff_image->Buffer( lo_x, lo_y-1 ); + pdiff = diff_buff + ( lo_x * (lo_y-1) ); memset( pdiff, BLACK, (hi_x-lo_x)+1 ); } for ( int y = lo_y, py = 0; y <= hi_y; y++, py++ ) @@ -169,7 +171,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) hi_x = ranges[py].hi_x; Debug( 7, "Checking line %d from %d -> %d", y, lo_x, hi_x ); - pdiff = diff_image->Buffer( lo_x, y ); + pdiff = diff_buff + (lo_x * y); ppoly = pg_image->Buffer( ranges[py].off_x, py ); // Left margin if ( y < hi_y ) @@ -258,7 +260,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) int lo_x = ranges[py].lo_x; int hi_x = ranges[py].hi_x; - pdiff = diff_image->Buffer( lo_x, y ); + pdiff = diff_buff + (lo_x * y); for ( int x = lo_x; x <= hi_x; x++, pdiff++ ) { @@ -279,7 +281,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) { for ( int dx2 = 0; block && dx2 < bx; dx2++ ) { - cpdiff = diff_image->Buffer( x+dx+dx2, y+dy+dy2 ); + cpdiff = diff_buff + ( (x+dx+dx2) * (y+dy+dy2) ); if ( !*cpdiff ) { block = false; @@ -345,7 +347,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) int lo_x = ranges[py].lo_x; int hi_x = ranges[py].hi_x; - pdiff = diff_image->Buffer( lo_x, y ); + pdiff = diff_buff + ( lo_x * y ); for ( int x = lo_x; x <= hi_x; x++, pdiff++ ) { if ( *pdiff == WHITE ) @@ -391,7 +393,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) Debug( 9, "Changing %d(%d), %d->%d", sy, psy, lo_sx, hi_sx ); Debug( 9, "Range %d(%d), %d->%d", sy, psy, ranges[psy].lo_x, ranges[psy].hi_x ); - spdiff = diff_image->Buffer( lo_sx, sy ); + spdiff = diff_buff + ( lo_sx * sy ); for ( int sx = lo_sx; sx <= hi_sx; sx++, spdiff++ ) { Debug( 9, "Pixel at %d,%d (%p) is %d", sx, sy, spdiff, *spdiff ); @@ -474,7 +476,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) { for ( int sy = bs->lo_y; sy <= bs->hi_y; sy++ ) { - unsigned char *spdiff = diff_image->Buffer( bs->lo_x, sy ); + unsigned char *spdiff = diff_buff + ( bs->lo_x * sy ); for ( int sx = bs->lo_x; sx <= bs->hi_x; sx++, spdiff++ ) { if ( *spdiff == bs->tag ) @@ -551,7 +553,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) { for ( int sy = bs->lo_y; sy <= bs->hi_y; sy++ ) { - unsigned char *spdiff = diff_image->Buffer( bs->lo_x, sy ); + unsigned char *spdiff = diff_buff + ( bs->lo_x * sy ); for ( int sx = bs->lo_x; sx <= bs->hi_x; sx++, spdiff++ ) { if ( *spdiff == bs->tag ) @@ -624,7 +626,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) for ( int sy = bs->lo_y; sy <= bs->hi_y; sy++ ) { - unsigned char *spdiff = diff_image->Buffer( bs->lo_x, sy ); + unsigned char *spdiff = diff_buff + ( bs->lo_x * sy ); for ( int sx = bs->lo_x; sx <= bs->hi_x; sx++, spdiff++ ) { if ( *spdiff == bs->tag ) @@ -697,7 +699,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) // First mask out anything we don't want for ( int y = lo_y, py = 0; y <= hi_y; y++, py++ ) { - pdiff = diff_image->Buffer( lo_x, y ); + pdiff = diff_buff + ( lo_x * y ); int lo_x2 = ranges[py].lo_x; int hi_x2 = ranges[py].hi_x; diff --git a/src/zma.cpp b/src/zma.cpp index 4a8fb1778..7c54d0c05 100644 --- a/src/zma.cpp +++ b/src/zma.cpp @@ -91,6 +91,8 @@ int main( int argc, char *argv[] ) snprintf( log_id_string, sizeof(log_id_string), "zma_m%d", id ); zmLoadConfig(); + + ssedetect(); logInit( log_id_string ); diff --git a/src/zmc.cpp b/src/zmc.cpp index 17f40c4b0..734e4606b 100644 --- a/src/zmc.cpp +++ b/src/zmc.cpp @@ -149,6 +149,8 @@ int main( int argc, char *argv[] ) } zmLoadConfig(); + + ssedetect(); logInit( log_id_string ); diff --git a/src/zmf.cpp b/src/zmf.cpp index 2f789fe98..998f7a0ec 100644 --- a/src/zmf.cpp +++ b/src/zmf.cpp @@ -159,6 +159,8 @@ int main( int argc, char *argv[] ) snprintf( log_id_string, sizeof(log_id_string), "m%d", id ); zmLoadConfig(); + + ssedetect(); logInit( "zmf" ); diff --git a/src/zms.cpp b/src/zms.cpp index 98e7e45b7..db7902303 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -86,6 +86,8 @@ int main( int argc, const char *argv[] ) } zmLoadConfig(); + + ssedetect(); logInit( "zms" ); diff --git a/src/zmstreamer.cpp b/src/zmstreamer.cpp index b528947f7..26384412a 100644 --- a/src/zmstreamer.cpp +++ b/src/zmstreamer.cpp @@ -145,7 +145,10 @@ int main(int argc, char** argv) { printf("Loading ZoneMinder configurations..."); zmLoadConfig(); printf("Done.\n"); + logInit("zmstreamer"); + + ssedetect(); // Setting stream parameters MonitorStream stream; From c3ecdd00e045f90467a6a642d424d37923e5b5c0 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 5 May 2011 12:52:00 +0300 Subject: [PATCH 03/56] 1) Relocated conversion functions and tables to zm_image.cpp 2) SSE2 aligned memcpy now functional 3) Fixed fill functions bug from an earlier commit 4) Many changes to zm_local_camera.cpp format selection 5) Fixed memory leak in AssignDirect() 6) Fixed Target Colorspace webinterface issues 7) Small other changes --- src/zm_image.cpp | 452 +++++++++---- src/zm_image.h | 111 +-- src/zm_local_camera.cpp | 787 +++++++++------------- src/zm_local_camera.h | 18 +- src/zm_utils.cpp | 51 +- src/zm_utils.h | 2 +- web/skins/classic/views/js/monitor.js.php | 8 +- web/skins/classic/views/monitor.php | 59 +- 8 files changed, 817 insertions(+), 671 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index f715997ad..935fb3687 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -26,17 +26,19 @@ #include bool Image::initialised = false; -unsigned char *Image::abs_table; -unsigned char *Image::y_r_table; -unsigned char *Image::y_g_table; -unsigned char *Image::y_b_table; +static unsigned char *y_table; +static signed char *uv_table; +static short *r_v_table; +static short *g_v_table; +static short *g_u_table; +static short *b_u_table; +__attribute__((aligned(16))) static const uint8_t movemask[16] = {0,4,8,12,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; jpeg_compress_struct *Image::jpg_ccinfo[100] = { 0 }; jpeg_decompress_struct *Image::jpg_dcinfo = 0; struct zm_error_mgr Image::jpg_err; - -/* Pointer to blend function. Blend operates on colours and not pixels, so palette doesn't matter */ +/* Pointer to blend function. */ blend_fptr_t fptr_blend; /* Pointer to delta8 functions */ @@ -48,6 +50,8 @@ delta_fptr_t fptr_delta8_argb; delta_fptr_t fptr_delta8_abgr; delta_fptr_t fptr_delta8_gray8; +/* Pointer to big memory copy function */ +imgbufcpy_fptr_t fptr_imgbufcpy; Image::Image() { @@ -105,7 +109,7 @@ Image::Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uin } else { - AllocBuffer(size); + AllocImgBuffer(size); } text[0] = '\0'; } @@ -122,8 +126,8 @@ Image::Image( const Image &p_image ) size = allocation = p_image.size; buffer = 0; holdbuffer = 0; - AllocBuffer(allocation); - sse2_aligned_memcpy(buffer, p_image.buffer, size); + AllocImgBuffer(allocation); + (*fptr_imgbufcpy)(buffer, p_image.buffer, size); strncpy( text, p_image.text, sizeof(text) ); } @@ -154,7 +158,7 @@ void Image::Initialise() __attribute__((aligned(16))) uint8_t blendexp[16] = {141,231,157,92,91,217,11,49,45,92,133,103,119,246,92,93}; /* Expected results for 12.5% blend */ (*fptr_blend)(blend1,blend2,blendres,16,12.5); - + /* Compare results with expected results */ for(int i=0;i<16;i++) { if(abs(blendexp[i] - blendres[i]) > 3) { @@ -202,6 +206,54 @@ void Image::Initialise() Debug(2,"Delta: CPU extensions disabled, using standard delta functions"); } + /* Use SSE2 aligned memory copy? */ + if(config.cpu_extensions && sseversion >= 20) { + fptr_imgbufcpy = &sse2_aligned_memcpy; + Debug(2,"Image buffer copy: Using SSE2 aligned memcpy"); + } else { + fptr_imgbufcpy = &memcpy; + Debug(2,"Image buffer copy: Using standard memcpy"); + } + + /* Code below relocated from zm_local_camera */ + Debug( 3, "Setting up static colour tables" ); + + y_table = new unsigned char[256]; + for ( int i = 0; i <= 255; i++ ) + { + unsigned char c = i; + if ( c <= 16 ) + y_table[c] = 0; + else if ( c >= 235 ) + y_table[c] = 255; + else + y_table[c] = (255*(c-16))/219; + } + + uv_table = new signed char[256]; + for ( int i = 0; i <= 255; i++ ) + { + unsigned char c = i; + if ( c <= 16 ) + uv_table[c] = -127; + else if ( c >= 240 ) + uv_table[c] = 127; + else + uv_table[c] = (127*(c-128))/112; + } + + r_v_table = new short[255]; + g_v_table = new short[255]; + g_u_table = new short[255]; + b_u_table = new short[255]; + for ( int i = 0; i < 255; i++ ) + { + r_v_table[i] = (1402*(i-128))/1000; + g_u_table[i] = (344*(i-128))/1000; + g_v_table[i] = (714*(i-128))/1000; + b_u_table[i] = (1772*(i-128))/1000; + } + initialised = true; } @@ -219,11 +271,11 @@ uint8_t* Image::WriteBuffer(const int p_width, const int p_height, const int p_c return NULL; } - if(p_width != width || p_height != height || p_colours != colours || p_subpixelorder != p_subpixelorder) { + if(p_width != width || p_height != height || p_colours != colours || p_subpixelorder != subpixelorder) { newsize = p_width * p_height * p_colours; if(buffer == NULL) { - AllocBuffer(newsize); + AllocImgBuffer(newsize); } else { if(allocation < newsize) { if(holdbuffer) { @@ -231,8 +283,8 @@ uint8_t* Image::WriteBuffer(const int p_width, const int p_height, const int p_c return NULL; } else { /* Replace buffer with a bigger one */ - DumpBuffer(); - AllocBuffer(newsize); + DumpImgBuffer(); + AllocImgBuffer(newsize); } } } @@ -285,7 +337,10 @@ void Image::AssignDirect( const int p_width, const int p_height, const int p_col /* Copy into the held buffer */ if(new_buffer != buffer) - sse2_aligned_memcpy(buffer, new_buffer, size); + (*fptr_imgbufcpy)(buffer, new_buffer, size); + + /* Free the new buffer */ + DumpBuffer(new_buffer, p_buffertype); } } else { /* Free an existing buffer if any */ @@ -337,8 +392,8 @@ void Image::Assign(const int p_width, const int p_height, const int p_colours, c } } else { if(new_size > allocation || !buffer) { - DumpBuffer(); - AllocBuffer(new_size); + DumpImgBuffer(); + AllocImgBuffer(new_size); } } @@ -351,7 +406,7 @@ void Image::Assign(const int p_width, const int p_height, const int p_colours, c } if(new_buffer != buffer) - sse2_aligned_memcpy(buffer, new_buffer, size); + (*fptr_imgbufcpy)(buffer, new_buffer, size); } @@ -377,8 +432,8 @@ void Image::Assign( const Image &image ) { } } else { if(new_size > allocation || !buffer) { - DumpBuffer(); - AllocBuffer(new_size); + DumpImgBuffer(); + AllocImgBuffer(new_size); } } @@ -391,7 +446,7 @@ void Image::Assign( const Image &image ) { } if(image.buffer != buffer) - sse2_aligned_memcpy(buffer, image.buffer, size); + (*fptr_imgbufcpy)(buffer, image.buffer, size); } Image *Image::HighlightEdges( Rgb colour, const Box *limits ) @@ -585,15 +640,15 @@ bool Image::ReadJpeg( const char *filename, int p_colours, int p_subpixelorder) size = pixels*colours; if(buffer == NULL) { - AllocBuffer(size); + AllocImgBuffer(size); } else { if(allocation < size) { if(holdbuffer) { Error("Held buffer is undersized for the requested image"); return (false); } else { - DumpBuffer(); - AllocBuffer(size); + DumpImgBuffer(); + AllocImgBuffer(size); } } } @@ -816,15 +871,15 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, int p_colours size = pixels*colours; if(buffer == NULL) { - AllocBuffer(size); + AllocImgBuffer(size); } else { if(allocation < size) { if(holdbuffer) { Error("Held buffer is undersized for the requested image"); return (false); } else { - DumpBuffer(); - AllocBuffer(size); + DumpImgBuffer(); + AllocImgBuffer(size); } } } @@ -990,11 +1045,8 @@ bool Image::Crop( int lo_x, int lo_y, int hi_x, int hi_y ) } int new_size = new_width*new_height*colours; + uint8_t *new_buffer = AllocBuffer(new_size); - uint8_t *new_buffer = (uint8_t*)zm_mallocaligned(16,new_size); - if(new_buffer == NULL) - Panic("Memory allocation failed, out of memory?"); - int new_stride = new_width*colours; for ( int y = lo_y, ny = 0; y <= hi_y; y++, ny++ ) { @@ -1251,7 +1303,7 @@ Image *Image::Highlight( int n_images, Image *images[], const Rgb threshold, con Image *result = new Image( width, height, images[0]->colours, images[0]->subpixelorder ); int size = result->size; - for ( int c = 0; c < 3; c++ ) + for ( int c = 0; c < colours; c++ ) { for ( int i = 0; i < size; i++ ) { @@ -1265,7 +1317,7 @@ Image *Image::Highlight( int n_images, Image *images[], const Rgb threshold, con { count++; } - psrc += 3; + psrc += colours; } *pdest = (count*255)/n_images; pdest += 3; @@ -1380,9 +1432,7 @@ void Image::Annotate( const char *p_text, const Coord &coord, const Rgb fg_colou while ( (index < text_len) && (line_len = strcspn( line, "\n" )) ) { - /* REMOVE LATER */ - Debug(3,"annotate iteration!"); - + int line_width = line_len * CHAR_WIDTH; int lo_line_x = coord.X(); @@ -1537,7 +1587,7 @@ void Image::Colourise(const int p_reqcolours, const int p_reqsubpixelorder) if ( p_reqcolours == ZM_COLOUR_RGB32 ) { /* RGB32 */ - Rgb* new_buffer = (Rgb*)zm_mallocaligned(16,pixels*sizeof(Rgb)); + Rgb* new_buffer = (Rgb*)AllocBuffer(pixels*sizeof(Rgb)); const uint8_t *psrc = buffer; Rgb* pdest = new_buffer; @@ -1547,18 +1597,18 @@ void Image::Colourise(const int p_reqcolours, const int p_reqsubpixelorder) if ( p_reqsubpixelorder == ZM_SUBPIX_ORDER_ABGR || p_reqsubpixelorder == ZM_SUBPIX_ORDER_ARGB) { /* ARGB\ABGR subpixel order. alpha byte is first (mem+0), so we need to shift the pixel left in the end */ for(int i=0;i ZM_SCALE_BASE ) { @@ -2295,7 +2334,8 @@ void Image::Scale( unsigned int factor ) /************************************************* BLEND FUNCTIONS *************************************************/ -__attribute__ ((noinline)) void sse2_fastblend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { +__attribute__ ((noinline)) void sse2_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { +#if (defined(__i386__) || defined(__x86_64__)) int divider = 0; uint32_t clearmask = 0; unsigned long i = 0; @@ -2349,10 +2389,12 @@ __attribute__ ((noinline)) void sse2_fastblend(uint8_t* col1, uint8_t* col2, uin : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (clearmask), "m" (divider) : "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "cc", "memory" ); - +#else + Panic("SSE function called on a non x86\\x86-64 platform"); +#endif } -__attribute__ ((noinline)) void std_fastblend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { +__attribute__ ((noinline)) void std_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { int divider = 0; /* Attempt to match the blending percent to one of the possible values */ @@ -2396,7 +2438,7 @@ __attribute__ ((noinline)) void std_fastblend(uint8_t* col1, uint8_t* col2, uint } } -__attribute__ ((noinline)) void std_blend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { +__attribute__ ((noinline)) void std_blend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { double divide = blendpercent / 100.0; double opacity = 1.0 - divide; for(register unsigned long i=0; i < count; i++) { @@ -2410,7 +2452,7 @@ __attribute__ ((noinline)) void std_blend(uint8_t* col1, uint8_t* col2, uint8_t* /************************************************* DELTA FUNCTIONS *************************************************/ /* Grayscale */ -__attribute__ ((noinline)) void std_delta8_gray8(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__ ((noinline)) void std_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 16 bytes (16 grayscale pixels) at a time */ for(unsigned int i=0;i255?255:r); + result[1] = g<0?0:(g>255?255:g); + result[2] = b<0?0:(b>255?255:b); + + r = y2 + r_v_table[v]; + g = y2 - (g_u_table[u]+g_v_table[v]); + b = y2 + b_u_table[u]; + + result[3] = r<0?0:(r>255?255:r); + result[4] = g<0?0:(g>255?255:g); + result[5] = b<0?0:(b>255?255:b); + } + +} + +/* YUYV to RGBA - modified the one above */ +__attribute__ ((noinline)) void zm_convert_yuyv_rgba(const uint8_t* col1, uint8_t* result, unsigned long count) { + unsigned int r,g,b; + unsigned int y1,y2,u,v; + for(unsigned int i=0; i < count; i += 2, col1 += 4, result += 8) { + y1 = col1[0]; + u = col1[1]; + y2 = col1[2]; + v = col1[3]; + + r = y1 + r_v_table[v]; + g = y1 - (g_u_table[u]+g_v_table[v]); + b = y1 + b_u_table[u]; + + result[0] = r<0?0:(r>255?255:r); + result[1] = g<0?0:(g>255?255:g); + result[2] = b<0?0:(b>255?255:b); + + r = y2 + r_v_table[v]; + g = y2 - (g_u_table[u]+g_v_table[v]); + b = y2 + b_u_table[u]; + + result[4] = r<0?0:(r>255?255:r); + result[5] = g<0?0:(g>255?255:g); + result[6] = b<0?0:(b>255?255:b); + } + +} + +/* RGB555 to RGB24 - relocated from zm_local_camera.cpp */ +__attribute__ ((noinline)) void zm_convert_rgb555_rgb(const uint8_t* col1, uint8_t* result, unsigned long count) { + unsigned int r,g,b; + for(unsigned int i=0; i < count; i++, col1 += 2, result += 3) { + b = ((*col1)<<3)&0xf8; + g = (((*(col1+1))<<6)|((*col1)>>2))&0xf8; + r = ((*(col1+1))<<1)&0xf8; + result[0] = r; + result[1] = g; + result[2] = b; + } +} + +/* RGB555 to RGBA - modified the one above */ +__attribute__ ((noinline)) void zm_convert_rgb555_rgba(const uint8_t* col1, uint8_t* result, unsigned long count) { + unsigned int r,g,b; + for(unsigned int i=0; i < count; i++, col1 += 2, result += 4) { + b = ((*col1)<<3)&0xf8; + g = (((*(col1+1))<<6)|((*col1)>>2))&0xf8; + r = ((*(col1+1))<<1)&0xf8; + result[0] = r; + result[1] = g; + result[2] = b; + } +} + +/* RGB565 to RGB24 - relocated from zm_local_camera.cpp */ +__attribute__ ((noinline)) void zm_convert_rgb565_rgb(const uint8_t* col1, uint8_t* result, unsigned long count) { + unsigned int r,g,b; + for(unsigned int i=0; i < count; i++, col1 += 2, result += 3) { + b = ((*col1)<<3)&0xf8; + g = (((*(col1+1))<<5)|((*col1)>>3))&0xfc; + r = (*(col1+1))&0xf8; + result[0] = r; + result[1] = g; + result[2] = b; + } +} + +/* RGB565 to RGBA - modified the one above */ +__attribute__ ((noinline)) void zm_convert_rgb565_rgba(const uint8_t* col1, uint8_t* result, unsigned long count) { + unsigned int r,g,b; + for(unsigned int i=0; i < count; i++, col1 += 2, result += 4) { + b = ((*col1)<<3)&0xf8; + g = (((*(col1+1))<<5)|((*col1)>>3))&0xfc; + r = (*(col1+1))&0xf8; + result[0] = r; + result[1] = g; + result[2] = b; + } } diff --git a/src/zm_image.h b/src/zm_image.h index 00368073d..102c4e48d 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -74,30 +74,17 @@ protected: } }; - inline void DumpBuffer() { - if (buffer && buffertype != ZM_BUFTYPE_DONTFREE) { - if(buffertype == ZM_BUFTYPE_ZM) - zm_freealigned(buffer); - else if(buffertype == ZM_BUFTYPE_MALLOC) - free(buffer); - else if(buffertype == ZM_BUFTYPE_NEW) - delete buffer; - /*else if(buffertype == ZM_BUFTYPE_AVMALLOC) - av_free(buffer); - */ - } + inline void DumpImgBuffer() { + DumpBuffer(buffer,buffertype); buffer = NULL; allocation = 0; } - inline void AllocBuffer(size_t p_bufsize) { + inline void AllocImgBuffer(size_t p_bufsize) { if(buffer) - DumpBuffer(); - - buffer = (uint8_t*)zm_mallocaligned(16,p_bufsize); - if(buffer == NULL) - Panic("Memory allocation failed: %s",strerror(errno)); + DumpImgBuffer(); + buffer = AllocBuffer(p_bufsize); buffertype = ZM_BUFTYPE_ZM; allocation = p_bufsize; } @@ -152,17 +139,12 @@ public: /* Request writeable buffer */ uint8_t* WriteBuffer(const int p_width, const int p_height, const int p_colours, const int p_subpixelorder); - inline int IsBufferHeld() const { - return holdbuffer; - } - - inline void HoldBuffer(int tohold) { - holdbuffer = tohold; - } + inline int IsBufferHeld() const { return holdbuffer; } + inline void HoldBuffer(int tohold) { holdbuffer = tohold; } inline void Empty() { if(!holdbuffer) - DumpBuffer(); + DumpImgBuffer(); width = height = colours = size = pixels = subpixelorder = 0; } @@ -230,27 +212,70 @@ public: void Scale( unsigned int factor ); }; +inline static uint8_t* AllocBuffer(size_t p_bufsize) { + uint8_t* buffer = (uint8_t*)zm_mallocaligned(16,p_bufsize); + if(buffer == NULL) + Fatal("Memory allocation failed: %s",strerror(errno)); + + return buffer; +} + +inline static void DumpBuffer(void* buffer, int buffertype) { + if (buffer && buffertype != ZM_BUFTYPE_DONTFREE) { + if(buffertype == ZM_BUFTYPE_ZM) + zm_freealigned(buffer); + else if(buffertype == ZM_BUFTYPE_MALLOC) + free(buffer); + else if(buffertype == ZM_BUFTYPE_NEW) + delete buffer; + /*else if(buffertype == ZM_BUFTYPE_AVMALLOC) + av_free(buffer); + */ + } +} + + + #endif // ZM_IMAGE_H -typedef void (*blend_fptr_t)(uint8_t*, uint8_t*, uint8_t*, unsigned long, double); -typedef void (*delta_fptr_t)(uint8_t*, uint8_t*, uint8_t*, unsigned long); +typedef void (*blend_fptr_t)(const uint8_t*, const uint8_t*, uint8_t*, unsigned long, double); +typedef void (*delta_fptr_t)(const uint8_t*, const uint8_t*, uint8_t*, unsigned long); +typedef void (*convert_fptr_t)(const uint8_t*, uint8_t*, unsigned long); +typedef void* (*imgbufcpy_fptr_t)(void*, const void*, size_t); /* Blend functions */ -void sse2_fastblend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent); -void std_fastblend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent); -void std_blend(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent); +void sse2_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent); +void std_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent); +void std_blend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent); /* Delta functions */ -void std_delta8_gray8(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); -void std_delta8_rgb(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); -void std_delta8_bgr(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); -void std_delta8_rgba(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); -void std_delta8_bgra(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); -void std_delta8_argb(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); -void std_delta8_abgr(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); -void sse2_delta8_gray8(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); -void ssse3_delta8_rgba(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); -void ssse3_delta8_bgra(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); -void ssse3_delta8_argb(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); -void ssse3_delta8_abgr(uint8_t* col1, uint8_t* col2, uint8_t* result, unsigned long count); \ No newline at end of file +void std_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void std_delta8_rgb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void std_delta8_bgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void std_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void std_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void sse2_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void ssse3_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void ssse3_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void ssse3_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void ssse3_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); + +/* Convert functions */ +void std_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count); +void std_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long count); +void std_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count); +void std_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count); +void std_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count); +void ssse3_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count); +void ssse3_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count); +void zm_convert_yuyv_rgb(const uint8_t* col1, uint8_t* result, unsigned long count); +void zm_convert_yuyv_rgba(const uint8_t* col1, uint8_t* result, unsigned long count); +void zm_convert_rgb555_rgb(const uint8_t* col1, uint8_t* result, unsigned long count); +void zm_convert_rgb555_rgba(const uint8_t* col1, uint8_t* result, unsigned long count); +void zm_convert_rgb565_rgb(const uint8_t* col1, uint8_t* result, unsigned long count); +void zm_convert_rgb565_rgba(const uint8_t* col1, uint8_t* result, unsigned long count); + + diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index a005e013b..3f59ca46e 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -32,6 +32,8 @@ #include #include +static unsigned int BigEndian; + static int vidioctl( int fd, int request, void *arg ) { int result = -1; @@ -46,19 +48,7 @@ static int vidioctl( int fd, int request, void *arg ) static PixelFormat getFfPixFormatFromV4lPalette( int v4l_version, int palette ) { PixelFormat pixFormat = PIX_FMT_NONE; - - /* Check the endianness of the machine */ - uint32_t checkval = 0xAABBCCDD; - int BigEndian; - if(*(unsigned char*)&checkval == 0xDD) - BigEndian = 0; - else if(*(unsigned char*)&checkval == 0xAA) - BigEndian = 1; - else { - Error("Unable to detect the processor's endianness. Assuming little-endian."); - BigEndian = 0; - } - + #if ZM_HAS_V4L2 if ( v4l_version == 2 ) { @@ -280,13 +270,6 @@ LocalCamera::V4L1Data LocalCamera::v4l1_data; AVFrame **LocalCamera::capturePictures = 0; #endif // HAVE_LIBSWSCALE -unsigned char *LocalCamera::y_table; -signed char *LocalCamera::uv_table; -short *LocalCamera::r_v_table; -short *LocalCamera::g_v_table; -short *LocalCamera::g_u_table; -short *LocalCamera::b_u_table; - LocalCamera *LocalCamera::last_camera = NULL; LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, int p_standard, const std::string &p_method, int p_width, int p_height, int p_colours, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : @@ -300,12 +283,12 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, // If we are the first, or only, input on this device then // do the initial opening etc device_prime = (camera_count++ == 0); - + v4l_version = (p_method=="v4l2"?2:1); + if ( capture ) { if ( device_prime ) { - v4l_version = (p_method=="v4l2"?2:1); Debug( 2, "V4L support enabled, using V4L%d api", v4l_version ); } @@ -338,115 +321,241 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, Warning( "Different capture sizes defined for monitors sharing same device, results may be unpredictable or completely wrong" ); } - /* The V4L1 API doesn't care about endianness, which is why RGB32 and RGB24 in V4L1 are actually BGR32 and BGR24 on little endian machines. */ - /* Check the endianness of the machine */ + } + + /* The V4L1 API doesn't care about endianness, we need to check the endianness of the machine */ uint32_t checkval = 0xAABBCCDD; - int BigEndian; - if(*(unsigned char*)&checkval == 0xDD) + if(*(unsigned char*)&checkval == 0xDD) { BigEndian = 0; - else if(*(unsigned char*)&checkval == 0xAA) + Debug(2,"little-endian processor detected"); + } else if(*(unsigned char*)&checkval == 0xAA) { BigEndian = 1; - else { + Debug(2,"Big-endian processor detected"); + } else { Error("Unable to detect the processor's endianness. Assuming little-endian."); BigEndian = 0; - } + } + + +#if HAVE_LIBSWSCALE + /* Get ffmpeg pixel format based on capture palette and endianness */ + capturePixFormat = getFfPixFormatFromV4lPalette( v4l_version, palette ); + imagePixFormat = PIX_FMT_NONE; +#endif // HAVE_LIBSWSCALE - /* Set the correct colours, subpixel order and ffmpeg image format based on colours, palette and endianness */ + + /* V4L2 format matching */ #if ZM_HAS_V4L2 if ( v4l_version == 2 ) { - switch( palette ) - { - case V4L2_PIX_FMT_RGB32 : - subpixelorder = ZM_SUBPIX_ORDER_ARGB; + /* Try to find a match for the selected palette and target colourspace */ + + /* RGB32 palette and 32bit target colourspace */ + if(palette == V4L2_PIX_FMT_RGB32 && colours == ZM_COLOUR_RGB32) { + conversion_type = 0; + subpixelorder = ZM_SUBPIX_ORDER_ARGB; + + /* BGR32 palette and 32bit target colourspace */ + } else if(palette == V4L2_PIX_FMT_BGR32 && colours == ZM_COLOUR_RGB32) { + conversion_type = 0; + subpixelorder = ZM_SUBPIX_ORDER_BGRA; + + /* RGB24 palette and 24bit target colourspace */ + } else if(palette == V4L2_PIX_FMT_RGB24 && colours == ZM_COLOUR_RGB24) { + conversion_type = 0; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + + /* BGR24 palette and 24bit target colourspace */ + } else if(palette == V4L2_PIX_FMT_BGR24 && colours == ZM_COLOUR_RGB24) { + conversion_type = 0; + subpixelorder = ZM_SUBPIX_ORDER_BGR; + + /* Grayscale palette and grayscale target colourspace */ + } else if(palette == V4L2_PIX_FMT_GREY && colours == ZM_COLOUR_GRAY8) { + conversion_type = 0; + subpixelorder = ZM_SUBPIX_ORDER_NONE; + + /* Special case: allow extremely fast conversion of YUYV to grayscale by extracting the Y channel */ + /* YUYV->Grayscale conversion is not available in swscale */ + /* Added especially for my friend jzaw */ + } else if(palette == V4L2_PIX_FMT_YUYV && colours == ZM_COLOUR_GRAY8) { + conversion_type = 2; + if(config.cpu_extensions && sseversion >= 35) { + conversion_fptr = &ssse3_convert_yuyv_gray8; + Debug(2,"Using SSSE3 YUYV->grayscale fast conversion"); + } else { + conversion_fptr = &std_convert_yuyv_gray8; + Debug(2,"Using standard YUYV->grayscale fast conversion"); + } + subpixelorder = ZM_SUBPIX_ORDER_NONE; + + /* Unable to find a solution for the selected palette and target colourspace. Conversion required */ + } else { + Warning("Unable to find a match for the selected palette and target colourspace. Conversion required, performance penalty expected"); #if HAVE_LIBSWSCALE - imagePixFormat = PIX_FMT_ARGB; -#endif - break; - case V4L2_PIX_FMT_BGR32 : - subpixelorder = ZM_SUBPIX_ORDER_BGRA; -#if HAVE_LIBSWSCALE - imagePixFormat = PIX_FMT_BGRA; -#endif - break; - case V4L2_PIX_FMT_RGB24 : + /* Use swscale for the conversion */ + conversion_type = 1; + Debug(2,"Using swscale for image conversion"); + if(colours == ZM_COLOUR_RGB32) { + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + imagePixFormat = PIX_FMT_RGBA; + } else if(colours == ZM_COLOUR_RGB24) { subpixelorder = ZM_SUBPIX_ORDER_RGB; -#if HAVE_LIBSWSCALE imagePixFormat = PIX_FMT_RGB24; -#endif - break; - case V4L2_PIX_FMT_BGR24 : - subpixelorder = ZM_SUBPIX_ORDER_BGR; -#if HAVE_LIBSWSCALE - imagePixFormat = PIX_FMT_BGR24; -#endif - break; - case V4L2_PIX_FMT_GREY : - subpixelorder = ZM_SUBPIX_ORDER_NONE; /* Not needed but just in case */ -#if HAVE_LIBSWSCALE + } else if(colours == ZM_COLOUR_GRAY8) { + subpixelorder = ZM_SUBPIX_ORDER_NONE; imagePixFormat = PIX_FMT_GRAY8; -#endif - break; - default : - /* Use RGB24 for formas other than grayscale and RGB32\BGR32 and use RGB subpixel order */ + } else { + Panic("Unexpected colours: %d",colours); + } + if(!sws_isSupportedInput(capturePixFormat)) { + Fatal("swscale does not support the used capture format"); + } + if(!sws_isSupportedOutput(imagePixFormat)) { + Fatal("swscale does not support the target format"); + } +#else + /* Don't have swscale, see what we can do */ + conversion_type = 2; + Debug(2,"Using ZM for image conversion"); + if(palette == V4L2_PIX_FMT_RGB32 && colours == ZM_COLOUR_GRAY8) { + conversion_fptr = &std_convert_argb_gray8; + subpixelorder = ZM_SUBPIX_ORDER_ARGB; + } else if(palette == V4L2_PIX_FMT_BGR32 && colours == ZM_COLOUR_GRAY8) { + conversion_fptr = &std_convert_bgra_gray8; + subpixelorder = ZM_SUBPIX_ORDER_BGRA; + } else if(palette == V4L2_PIX_FMT_YUYV && colours == ZM_COLOUR_RGB24) { + conversion_fptr = &zm_convert_yuyv_rgb; subpixelorder = ZM_SUBPIX_ORDER_RGB; -#if HAVE_LIBSWSCALE - imagePixFormat = PIX_FMT_RGB24; + } else if(palette == V4L2_PIX_FMT_YUYV && colours == ZM_COLOUR_RGB32) { + conversion_fptr = &zm_convert_yuyv_rgba; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } else if(palette == V4L2_PIX_FMT_RGB555 && colours == ZM_COLOUR_RGB24) { + conversion_fptr = &zm_convert_rgb555_rgb; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } else if(palette == V4L2_PIX_FMT_RGB555 && colours == ZM_COLOUR_RGB32) { + conversion_fptr = &zm_convert_rgb555_rgba; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } else if(palette == V4L2_PIX_FMT_RGB565 && colours == ZM_COLOUR_RGB24) { + conversion_fptr = &zm_convert_rgb565_rgb; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } else if(palette == V4L2_PIX_FMT_RGB565 && colours == ZM_COLOUR_RGB32) { + conversion_fptr = &zm_convert_rgb565_rgba; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } else { + Panic("Unable to find suitable conversion for selected palette and target colourspace."); + } #endif - break; } } #endif // ZM_HAS_V4L2 + + /* V4L1 format matching */ #if ZM_HAS_V4L1 if ( v4l_version == 1) { - switch( palette ) - { - case VIDEO_PALETTE_RGB32 : - if(BigEndian) { - subpixelorder = ZM_SUBPIX_ORDER_ARGB; -#if HAVE_LIBSWSCALE - imagePixFormat = PIX_FMT_ARGB; -#endif - } else { - subpixelorder = ZM_SUBPIX_ORDER_BGRA; -#if HAVE_LIBSWSCALE - imagePixFormat = PIX_FMT_BGRA; -#endif - } - break; - case VIDEO_PALETTE_RGB24 : - if(BigEndian) { - subpixelorder = ZM_SUBPIX_ORDER_RGB; -#if HAVE_LIBSWSCALE - imagePixFormat = PIX_FMT_RGB24; -#endif - } else { - subpixelorder = ZM_SUBPIX_ORDER_BGR; -#if HAVE_LIBSWSCALE - imagePixFormat = PIX_FMT_BGR24; -#endif - } - break; - case VIDEO_PALETTE_GREY : - subpixelorder = ZM_SUBPIX_ORDER_NONE; -#if HAVE_LIBSWSCALE - imagePixFormat = PIX_FMT_GRAY8; -#endif - break; - default : + /* Try to find a match for the selected palette and target colourspace */ + + /* RGB32 palette and 32bit target colourspace */ + if(palette == VIDEO_PALETTE_RGB32 && colours == ZM_COLOUR_RGB32) { + conversion_type = 0; + if(BigEndian) { + subpixelorder = ZM_SUBPIX_ORDER_ARGB; + } else { + subpixelorder = ZM_SUBPIX_ORDER_BGRA; + } + + /* RGB24 palette and 24bit target colourspace */ + } else if(palette == VIDEO_PALETTE_RGB24 && colours == ZM_COLOUR_RGB24) { + conversion_type = 0; + if(BigEndian) { subpixelorder = ZM_SUBPIX_ORDER_RGB; + } else { + subpixelorder = ZM_SUBPIX_ORDER_BGR; + } + + /* Grayscale palette and grayscale target colourspace */ + } else if(palette == VIDEO_PALETTE_GREY && colours == ZM_COLOUR_GRAY8) { + conversion_type = 0; + subpixelorder = ZM_SUBPIX_ORDER_NONE; + + /* Special case: allow extremely fast conversion of YUYV to grayscale by extracting the Y channel */ + /* YUYV->Grayscale conversion is not available in swscale */ + /* Added especially for my friend jzaw */ + } else if((palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422) && colours == ZM_COLOUR_GRAY8) { + conversion_type = 2; + if(config.cpu_extensions && sseversion >= 35) { + conversion_fptr = &ssse3_convert_yuyv_gray8; + Debug(2,"Using SSSE3 YUYV->grayscale fast conversion"); + } else { + conversion_fptr = &std_convert_yuyv_gray8; + Debug(2,"Using standard YUYV->grayscale fast conversion"); + } + subpixelorder = ZM_SUBPIX_ORDER_NONE; + + /* Unable to find a solution for the selected palette and target colourspace. Conversion required. Notify the user of performance penalty */ + } else { + Warning("Unable to find a match for the selected palette and target colourspace. Conversion required, performance penalty expected"); #if HAVE_LIBSWSCALE + /* Use swscale for the conversion */ + conversion_type = 1; + Debug(2,"Using swscale for image conversion"); + if(colours == ZM_COLOUR_RGB32) { + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + imagePixFormat = PIX_FMT_RGBA; + } else if(colours == ZM_COLOUR_RGB24) { + subpixelorder = ZM_SUBPIX_ORDER_RGB; imagePixFormat = PIX_FMT_RGB24; + } else if(colours == ZM_COLOUR_GRAY8) { + subpixelorder = ZM_SUBPIX_ORDER_NONE; + imagePixFormat = PIX_FMT_GRAY8; + } else { + Panic("Unexpected colours: %d",colours); + } + if(!sws_isSupportedInput(capturePixFormat)) { + Fatal("swscale does not support the used capture format"); + } + if(!sws_isSupportedOutput(imagePixFormat)) { + Fatal("swscale does not support the target format"); + } +#else + /* Don't have swscale, see what we can do */ + conversion_type = 2; + Debug(2,"Using ZM for image conversion"); + if(palette == VIDEO_PALETTE_RGB32 && colours == ZM_COLOUR_GRAY8) { + if(BigEndian) { + conversion_fptr = &std_convert_argb_gray8; + subpixelorder = ZM_SUBPIX_ORDER_ARGB; + } else { + conversion_fptr = &std_convert_bgra_gray8; + subpixelorder = ZM_SUBPIX_ORDER_BGRA; + } + } else if((palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422) && colours == ZM_COLOUR_RGB24) { + conversion_fptr = &zm_convert_yuyv_rgb; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } else if((palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422) && colours == ZM_COLOUR_RGB32) { + conversion_fptr = &zm_convert_yuyv_rgba; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } else if(palette == VIDEO_PALETTE_RGB555 && colours == ZM_COLOUR_RGB24) { + conversion_fptr = &zm_convert_rgb555_rgb; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } else if(palette == VIDEO_PALETTE_RGB555 && colours == ZM_COLOUR_RGB32) { + conversion_fptr = &zm_convert_rgb555_rgba; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } else if(palette == VIDEO_PALETTE_RGB565 && colours == ZM_COLOUR_RGB24) { + conversion_fptr = &zm_convert_rgb565_rgb; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } else if(palette == VIDEO_PALETTE_RGB565 && colours == ZM_COLOUR_RGB32) { + conversion_fptr = &zm_convert_rgb565_rgba; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } else { + Panic("Unable to find suitable conversion for selected palette and target colourspace."); + } #endif - break; } } -#endif // ZM_HAS_V4L1 - -#if HAVE_LIBSWSCALE - capturePixFormat = getFfPixFormatFromV4lPalette( v4l_version, palette ); -#endif // HAVE_LIBSWSCALE - } - last_camera = this; +#endif // ZM_HAS_V4L1 + + last_camera = this; + Debug(3,"Selected subpixelorder: %d",subpixelorder); } LocalCamera::~LocalCamera() @@ -604,13 +713,12 @@ void LocalCamera::Initialise() Fatal( "Can't map video buffer %d (%d bytes) to memory: %s(%d)", i, vid_buf.length, strerror(errno), errno ); #if HAVE_LIBSWSCALE - if ( imagePixFormat != capturePixFormat || v4l2_data.fmt.fmt.pix.width != width || v4l2_data.fmt.fmt.pix.height != height ) - { - capturePictures[i] = avcodec_alloc_frame(); - if ( !capturePictures[i] ) - Fatal( "Could not allocate picture" ); - avpicture_fill( (AVPicture *)capturePictures[i], (unsigned char *)v4l2_data.buffers[i].start, capturePixFormat, v4l2_data.fmt.fmt.pix.width, v4l2_data.fmt.fmt.pix.height ); - } + if (conversion_type == 1) { + capturePictures[i] = avcodec_alloc_frame(); + if ( !capturePictures[i] ) + Fatal( "Could not allocate picture" ); + avpicture_fill( (AVPicture *)capturePictures[i], (uint8_t*)v4l2_data.buffers[i].start, capturePixFormat, v4l2_data.fmt.fmt.pix.width, v4l2_data.fmt.fmt.pix.height ); + } #endif // HAVE_LIBSWSCALE } @@ -761,7 +869,7 @@ void LocalCamera::Initialise() v4l1_data.buffers[i].height = height; v4l1_data.buffers[i].format = palette; - if ( imagePixFormat != capturePixFormat ) + if (conversion_type == 1) { capturePictures[i] = avcodec_alloc_frame(); if ( !capturePictures[i] ) @@ -818,43 +926,23 @@ void LocalCamera::Initialise() } #endif // ZM_HAS_V4L1 - Debug( 3, "Setting up static colour tables" ); - - y_table = new unsigned char[256]; - for ( int i = 0; i <= 255; i++ ) - { - unsigned char c = i; - if ( c <= 16 ) - y_table[c] = 0; - else if ( c >= 235 ) - y_table[c] = 255; - else - y_table[c] = (255*(c-16))/219; +#if HAVE_LIBSWSCALE + if(conversion_type == 1) { + tmpPicture = avcodec_alloc_frame(); + if ( !tmpPicture ) + Fatal( "Could not allocate temporary picture" ); + + if(config.cpu_extensions && sseversion >= 20) { + imgConversionContext = sws_getContext(width, height, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL ); + } else { + imgConversionContext = sws_getContext(width, height, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL ); + } + + if ( !imgConversionContext ) + Fatal( "Unable to initialise image scaling context" ); + } - - uv_table = new signed char[256]; - for ( int i = 0; i <= 255; i++ ) - { - unsigned char c = i; - if ( c <= 16 ) - uv_table[c] = -127; - else if ( c >= 240 ) - uv_table[c] = 127; - else - uv_table[c] = (127*(c-128))/112; - } - - r_v_table = new short[255]; - g_v_table = new short[255]; - g_u_table = new short[255]; - b_u_table = new short[255]; - for ( int i = 0; i < 255; i++ ) - { - r_v_table[i] = (1402*(i-128))/1000; - g_u_table[i] = (344*(i-128))/1000; - g_v_table[i] = (714*(i-128))/1000; - b_u_table[i] = (1772*(i-128))/1000; - } +#endif } void LocalCamera::Terminate() @@ -869,15 +957,36 @@ void LocalCamera::Terminate() Error( "Failed to stop capture stream: %s", strerror(errno) ); Debug( 3, "Unmapping video buffers" ); - for ( int i = 0; i < v4l2_data.reqbufs.count; i++ ) + for ( int i = 0; i < v4l2_data.reqbufs.count; i++ ) { +#if HAVE_LIBSWSCALE + if(conversion_type == 1) { + /* Free capture pictures */ + av_free(capturePictures[i]); + capturePictures[i] = NULL; + } +#endif if ( munmap( v4l2_data.buffers[i].start, v4l2_data.buffers[i].length ) < 0 ) Error( "Failed to munmap buffer %d: %s", i, strerror(errno) ); + } + } else #endif // ZM_HAS_V4L2 + + #if ZM_HAS_V4L1 if ( v4l_version == 1 ) { +#if HAVE_LIBSWSCALE + if(conversion_type == 1) { + for(unsigned int i=0; i < v4l1_data.frames.frames; i++) { + /* Free capture pictures */ + av_free(capturePictures[i]); + capturePictures[i] = NULL; + } + } +#endif + Debug( 3, "Unmapping video buffers" ); if ( munmap((char*)v4l1_data.bufptr, v4l1_data.frames.size) < 0 ) Error( "Failed to munmap buffers: %s", strerror(errno) ); @@ -887,6 +996,16 @@ void LocalCamera::Terminate() #endif // ZM_HAS_V4L1 close( vid_fd ); + + /* Clean up swscale stuff */ + if(conversion_type == 1) { + sws_freeContext(imgConversionContext); + imgConversionContext = NULL; + + av_free(tmpPicture); + tmpPicture = NULL; + } + } #define capString(test,prefix,yesString,noString,capability) \ @@ -1684,17 +1803,15 @@ int LocalCamera::PreCapture() int LocalCamera::Capture( Image &image ) { - Debug( 3, "Capturing" ); - - uint8_t* buffer = NULL; - uint8_t* swscale_buffer = NULL; - + Debug( 3, "Capturing" ); + uint8_t* buffer = NULL; + uint8_t* directbuffer = NULL; + int captures_per_frame = 1; if ( channel_count > 1 ) captures_per_frame = config.captures_per_frame; - int captureWidth = width; - int captureHeight = height; - + + // Do the capture, unless we are the second or subsequent camera on a channel, in which case just reuse the buffer if ( channel_prime ) { @@ -1738,8 +1855,10 @@ int LocalCamera::Capture( Image &image ) buffer = (unsigned char *)v4l2_data.buffers[v4l2_data.bufptr->index].start; - captureWidth = v4l2_data.fmt.fmt.pix.width; - captureHeight = v4l2_data.fmt.fmt.pix.height; + if(v4l2_data.fmt.fmt.pix.width != width && v4l2_data.fmt.fmt.pix.height != height) { + Fatal("Captured image dimensions differ: V4L2: %dx%d monitor: %dx%d",v4l2_data.fmt.fmt.pix.width,v4l2_data.fmt.fmt.pix.height,width,height); + } + } #endif // ZM_HAS_V4L2 #if ZM_HAS_V4L1 @@ -1769,322 +1888,44 @@ int LocalCamera::Capture( Image &image ) Debug( 3, "Captured %d for channel %d", capture_frame, channel ); buffer = v4l1_data.bufptr+v4l1_data.frames.offsets[capture_frame]; - } #endif // ZM_HAS_V4L1 -#if HAVE_LIBSWSCALE - Debug( 3, "Doing format conversion" ); - - static struct SwsContext *imgConversionContext = NULL; - static AVFrame *tmpPicture = NULL; - static int pSize = ZM_MAX_IMAGE_SIZE; - swscale_buffer = NULL; - if ( imagePixFormat != capturePixFormat || captureWidth != width || captureHeight != height ) - { - if ( !imgConversionContext ) - { -#ifdef ZM_HAS_SSE2 - imgConversionContext = sws_getCachedContext( NULL, captureWidth, captureHeight, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL ); -#else - imgConversionContext = sws_getCachedContext( NULL, captureWidth, captureHeight, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL ); -#endif - if ( !imgConversionContext ) - Fatal( "Unable to initialise image scaling context" ); - - tmpPicture = avcodec_alloc_frame(); - if ( !tmpPicture ) - Fatal( "Could not allocate temporary picture" ); - pSize = avpicture_get_size( imagePixFormat, width, height ); - } - /* Write the output image directly into the shared memory */ - swscale_buffer = image.WriteBuffer(width,height,colours,subpixelorder); - if(swscale_buffer == NULL) { - Error("Failed requesting writeable buffer for swscale conversion for the captured image."); - return (-1); - } - avpicture_fill( (AVPicture *)tmpPicture, swscale_buffer, imagePixFormat, width, height ); - sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize ); - - buffer = tmpPicture->data[0]; - } -#else // HAVE_LIBSWSCALE - uint8_t* directbuffer = image.WriteBuffer(width,height,colours,subpixelorder); - if(directbuffer == NULL) { - Error("Failed requesting writeable buffer for the captured image."); - return (-1); - } - - switch( palette ) - { -#if ZM_HAS_V4L1 - case VIDEO_PALETTE_YUV420P : -#endif // ZM_HAS_V4L1 -#if ZM_HAS_V4L2 - case V4L2_PIX_FMT_YUV420 : -#endif // ZM_HAS_V4L2 - { - static unsigned char y_plane[ZM_MAX_IMAGE_DIM]; - static char u_plane[ZM_MAX_IMAGE_DIM]; - static char v_plane[ZM_MAX_IMAGE_DIM]; - - unsigned char *rgb_ptr = directbuffer; - unsigned char *y_ptr = y_plane; - char *u1_ptr = u_plane; - char *u2_ptr = u_plane+width; - char *v1_ptr = v_plane; - char *v2_ptr = v_plane+width; - - int Y_size = width*height; - int C_size = Y_size>>2; // Every little bit helps... - unsigned char *Y_ptr = buffer; - unsigned char *Cb_ptr = buffer + Y_size; - unsigned char *Cr_ptr = Cb_ptr + C_size; - - int y,u,v; - for ( int i = 0; i < Y_size; i++ ) - { - *y_ptr++ = y_table[*Y_ptr++]; - } - int half_width = width>>1; // We are the king of optimisations! - for ( int i = 0, j = 0; i < C_size; i++, j++ ) - { - if ( j == half_width ) - { - j = 0; - u1_ptr += width; - u2_ptr += width; - v1_ptr += width; - v2_ptr += width; - } - u = uv_table[*Cb_ptr++]; - - *u1_ptr++ = u; - *u1_ptr++ = u; - *u2_ptr++ = u; - *u2_ptr++ = u; - - v = uv_table[*Cr_ptr++]; - - *v1_ptr++ = v; - *v1_ptr++ = v; - *v2_ptr++ = v; - *v2_ptr++ = v; - } - - y_ptr = y_plane; - u1_ptr = u_plane; - v1_ptr = v_plane; - int size = Y_size*3; - int r,g,b; - for ( int i = 0; i < size; i += 3 ) - { - y = *y_ptr++; - u = *u1_ptr++; - v = *v1_ptr++; - - r = y + r_v_table[v]; - g = y - (g_u_table[u]+g_v_table[v]); - b = y + b_u_table[u]; - - *rgb_ptr++ = r<0?0:(r>255?255:r); - *rgb_ptr++ = g<0?0:(g>255?255:g); - *rgb_ptr++ = b<0?0:(b>255?255:b); - } - buffer = directbuffer; - break; - } -#if ZM_HAS_V4L1 - case VIDEO_PALETTE_YUV422P : -#endif // ZM_HAS_V4L1 -#if ZM_HAS_V4L2 - case V4L2_PIX_FMT_YUV422P : -#endif // ZM_HAS_V4L2 - { - static unsigned char y_plane[ZM_MAX_IMAGE_DIM]; - static char u_plane[ZM_MAX_IMAGE_DIM]; - static char v_plane[ZM_MAX_IMAGE_DIM]; - - unsigned char *rgb_ptr = directbuffer; - unsigned char *y_ptr = y_plane; - char *u1_ptr = u_plane; - char *v1_ptr = v_plane; - - int Y_size = width*height; - int C_size = Y_size>>1; // Every little bit helps... - unsigned char *Y_ptr = buffer; - unsigned char *Cb_ptr = buffer + Y_size; - unsigned char *Cr_ptr = Cb_ptr + C_size; - - int y,u,v; - for ( int i = 0; i < Y_size; i++ ) - { - *y_ptr++ = y_table[*Y_ptr++]; - } - for ( int i = 0, j = 0; i < C_size; i++, j++ ) - { - u = uv_table[*Cb_ptr++]; - - *u1_ptr++ = u; - *u1_ptr++ = u; - - v = uv_table[*Cr_ptr++]; - - *v1_ptr++ = v; - *v1_ptr++ = v; - } - - y_ptr = y_plane; - u1_ptr = u_plane; - v1_ptr = v_plane; - int size = Y_size*3; - int r,g,b; - for ( int i = 0; i < size; i += 3 ) - { - y = *y_ptr++; - u = *u1_ptr++; - v = *v1_ptr++; - - r = y + r_v_table[v]; - g = y - (g_u_table[u]+g_v_table[v]); - b = y + b_u_table[u]; - - *rgb_ptr++ = r<0?0:(r>255?255:r); - *rgb_ptr++ = g<0?0:(g>255?255:g); - *rgb_ptr++ = b<0?0:(b>255?255:b); - } - buffer = directbuffer; - break; - } -#if ZM_HAS_V4L1 - case VIDEO_PALETTE_YUYV : - case VIDEO_PALETTE_YUV422 : -#endif // ZM_HAS_V4L1 -#if ZM_HAS_V4L2 - case V4L2_PIX_FMT_YUYV : -#endif // ZM_HAS_V4L2 - { - int size = width*height*2; - unsigned char *s_ptr = buffer; - unsigned char *d_ptr = directbuffer; - - int y1,y2,u,v; - int r,g,b; - for ( int i = 0; i < size; i += 4 ) - { - y1 = *s_ptr++; - u = *s_ptr++; - y2 = *s_ptr++; - v = *s_ptr++; - - r = y1 + r_v_table[v]; - g = y1 - (g_u_table[u]+g_v_table[v]); - b = y1 + b_u_table[u]; - - *d_ptr++ = r<0?0:(r>255?255:r); - *d_ptr++ = g<0?0:(g>255?255:g); - *d_ptr++ = b<0?0:(b>255?255:b); - - r = y2 + r_v_table[v]; - g = y2 - (g_u_table[u]+g_v_table[v]); - b = y2 + b_u_table[u]; - - *d_ptr++ = r<0?0:(r>255?255:r); - *d_ptr++ = g<0?0:(g>255?255:g); - *d_ptr++ = b<0?0:(b>255?255:b); - } - buffer = directbuffer; - break; - } -#if ZM_HAS_V4L1 - case VIDEO_PALETTE_RGB555 : -#endif // ZM_HAS_V4L1 -#if ZM_HAS_V4L2 - case V4L2_PIX_FMT_RGB555 : -#endif // ZM_HAS_V4L2 - { - int size = width*height*2; - unsigned char r,g,b; - unsigned char *s_ptr = buffer; - unsigned char *d_ptr = directbuffer; - for ( int i = 0; i < size; i += 2 ) - { - b = ((*s_ptr)<<3)&0xf8; - g = (((*(s_ptr+1))<<6)|((*s_ptr)>>2))&0xf8; - r = ((*(s_ptr+1))<<1)&0xf8; - - *d_ptr++ = r; - *d_ptr++ = g; - *d_ptr++ = b; - s_ptr += 2; - } - buffer = directbuffer; - break; - } -#if ZM_HAS_V4L1 - case VIDEO_PALETTE_RGB565 : -#endif // ZM_HAS_V4L1 -#if ZM_HAS_V4L2 - case V4L2_PIX_FMT_RGB565 : -#endif // ZM_HAS_V4L2 - { - int size = width*height*2; - unsigned char r,g,b; - unsigned char *s_ptr = buffer; - unsigned char *d_ptr = directbuffer; - for ( int i = 0; i < size; i += 2 ) - { - b = ((*s_ptr)<<3)&0xf8; - g = (((*(s_ptr+1))<<5)|((*s_ptr)>>3))&0xfc; - r = (*(s_ptr+1))&0xf8; - - *d_ptr++ = r; - *d_ptr++ = g; - *d_ptr++ = b; - s_ptr += 2; - } - buffer = directbuffer; - break; - } -#if ZM_HAS_V4L1 - case VIDEO_PALETTE_GREY : -#endif // ZM_HAS_V4L1 -#if ZM_HAS_V4L2 - case V4L2_PIX_FMT_GREY : -#endif // ZM_HAS_V4L2 - { - //int size = width*height; - //for ( int i = 0; i < size; i++ ) - //{ - //if ( buffer[i] < 16 ) - //Info( "Lo grey %d", buffer[i] ); - //if ( buffer[i] > 235 ) - //Info( "Hi grey %d", buffer[i] ); - //} - } - default : // Everything else is straightforward, for now. - { - break; - } - } -#endif // HAVE_LIBSWSCALE } - - Debug( 3, "Assigning image" ); -#if HAVE_LIBSWSCALE - if(swscale_buffer) - /* A swsscale conversion was peformed with the output being stored directly into the shared memory */ - image.AssignDirect( width, height, colours, subpixelorder, buffer, imagesize, ZM_BUFTYPE_DONTFREE); - else + if(conversion_type != 0) { + + Debug( 3, "Performing format conversion" ); + + /* Request a writeable buffer of the target image */ + directbuffer = image.WriteBuffer(width, height, colours, subpixelorder); + if(directbuffer == NULL) { + Error("Failed requesting writeable buffer for the captured image."); + return (-1); + } + + if(conversion_type == 1) { + /* Use swscale to convert the image directly into the shared memory */ + + unsigned int pSize = avpicture_fill( (AVPicture *)tmpPicture, directbuffer, imagePixFormat, width, height ); + if( pSize != imagesize) { + Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize); + } + + sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize ); + + } else if(conversion_type == 2) { + + /* Call the image conversion function and convert directly into the shared memory */ + (*conversion_fptr)(buffer, directbuffer, pixels); + } + + } else { + Debug( 3, "No format conversion performed. Assigning the image" ); + /* No conversion was performed, the image is in the V4L buffers and needs to be copied into the shared memory */ image.Assign( width, height, colours, subpixelorder, buffer, imagesize); -#else - if(directbuffer == buffer) - /* A conversion was performed with the output being stored directly into the shared memory */ - image.AssignDirect( width, height, colours, subpixelorder, buffer, imagesize, ZM_BUFTYPE_DONTFREE); - else - /* No conversion was performed, the image is in the V4L buffers and needs to be copied into the shared memory */ - image.Assign( width, height, colours, subpixelorder, buffer, imagesize); -#endif - + + } + } /* prime capture */ + return( 0 ); } diff --git a/src/zm_local_camera.h b/src/zm_local_camera.h index b3b75a328..89baaf2f3 100644 --- a/src/zm_local_camera.h +++ b/src/zm_local_camera.h @@ -22,6 +22,7 @@ #include "zm.h" #include "zm_camera.h" +#include "zm_image.h" #if ZM_HAS_V4L @@ -101,16 +102,19 @@ protected: PixelFormat imagePixFormat; PixelFormat capturePixFormat; static AVFrame **capturePictures; + struct SwsContext *imgConversionContext; + AVFrame *tmpPicture; #endif // HAVE_LIBSWSCALE - static unsigned char *y_table; - static signed char *uv_table; - static short *r_v_table; - static short *g_v_table; - static short *g_u_table; - static short *b_u_table; + static LocalCamera *last_camera; - static LocalCamera *last_camera; + /* 0 = no conversion needed, 1 = use libswscale, 2 = zm internal conversion */ + unsigned int conversion_type; + /* Pointer to conversion function used */ + convert_fptr_t conversion_fptr; + + + public: LocalCamera( int p_id, const std::string &device, int p_channel, int p_format, const std::string &p_method, int p_width, int p_height, int p_colours, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ); diff --git a/src/zm_utils.cpp b/src/zm_utils.cpp index 6383084b2..4853b4cc0 100644 --- a/src/zm_utils.cpp +++ b/src/zm_utils.cpp @@ -190,9 +190,54 @@ void ssedetect() { #endif } -/* Aligned SSE2 memory copy. Useful for copying big things like image buffers in ZM */ -/* This requires source and target memory to be aligned on 16byte boundary, or a general protection fault will occur, therefore we check for unaligned memory */ -void sse2_aligned_memcpy(unsigned char* dest, const unsigned char* src, const size_t bytes) { +/* SSE2 aligned memory copy. Useful for big copying of aligned memory like image buffers in ZM */ +/* For platforms without SSE2 we will use standard x86 asm memcpy or glibc's memcpy() */ +__attribute__((noinline)) void* sse2_aligned_memcpy(void* dest, const void* src, size_t bytes) { +#if (defined(__i386__) || defined(__x86_64__)) + if(bytes > 128) { + unsigned int remainder = bytes % 128; + const uint8_t* lastsrc = (uint8_t*)src + (bytes - remainder); + + __asm__ __volatile__( + "sse2copy_begin:\n\t" + "movdqa (%0),%%xmm0\n\t" + "movdqa 0x10(%0),%%xmm1\n\t" + "movdqa 0x20(%0),%%xmm2\n\t" + "movdqa 0x30(%0),%%xmm3\n\t" + "movdqa 0x40(%0),%%xmm4\n\t" + "movdqa 0x50(%0),%%xmm5\n\t" + "movdqa 0x60(%0),%%xmm6\n\t" + "movdqa 0x70(%0),%%xmm7\n\t" + "movntdq %%xmm0,(%1)\n\t" + "movntdq %%xmm1,0x10(%1)\n\t" + "movntdq %%xmm2,0x20(%1)\n\t" + "movntdq %%xmm3,0x30(%1)\n\t" + "movntdq %%xmm4,0x40(%1)\n\t" + "movntdq %%xmm5,0x50(%1)\n\t" + "movntdq %%xmm6,0x60(%1)\n\t" + "movntdq %%xmm7,0x70(%1)\n\t" + "add $0x80, %0\n\t" + "add $0x80, %1\n\t" + "cmp %2, %0\n\t" + "jb sse2copy_begin\n\t" + "test %3, %3\n\t" + "jz sse2copy_finish\n\t" + "cld\n\t" + "rep movsb\n\t" + "sse2copy_finish:\n\t" + : + : "S" (src), "D" (dest), "r" (lastsrc), "c" (remainder) + : "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "cc", "memory" + ); + + } else { + /* Standard memcpy */ + __asm__ __volatile__("cld; rep movsb" :: "S"(src), "D"(dest), "c"(bytes) : "cc", "memory"); + } +#else + /* Non x86\x86-64 platform, use memcpy */ memcpy(dest,src,bytes); +#endif + return dest; } diff --git a/src/zm_utils.h b/src/zm_utils.h index fa55624bd..9313a0125 100644 --- a/src/zm_utils.h +++ b/src/zm_utils.h @@ -44,7 +44,7 @@ inline int min( int a, int b ) } void ssedetect(); -void sse2_aligned_memcpy(unsigned char* dest, const unsigned char* src, const size_t bytes); +void* sse2_aligned_memcpy(void* dest, const void* src, size_t bytes); extern unsigned int sseversion; diff --git a/web/skins/classic/views/js/monitor.js.php b/web/skins/classic/views/js/monitor.js.php index c0ba63a0e..1574c1cf4 100644 --- a/web/skins/classic/views/js/monitor.js.php +++ b/web/skins/classic/views/js/monitor.js.php @@ -70,6 +70,8 @@ function validateForm( form ) errors[errors.length] = ""; if ( form.elements['newMonitor[Type]'].value == 'Local' ) { + if ( !form.elements['newMonitor[Palette]'].value || !form.elements['newMonitor[Palette]'].value.match( /^\d+$/ ) ) + errors[errors.length] = ""; if ( !form.elements['newMonitor[Device]'].value ) errors[errors.length] = ""; if ( !form.elements['newMonitor[Channel]'].value || !form.elements['newMonitor[Channel]'].value.match( /^\d+$/ ) ) @@ -91,8 +93,8 @@ function validateForm( form ) if ( !form.elements['newMonitor[Path]'].value ) errors[errors.length] = ""; } - if ( !form.elements['newMonitor[Palette]'].value || !form.elements['newMonitor[Palette]'].value.match( /^\d+$/ ) ) - errors[errors.length] = ""; + if ( !form.elements['newMonitor[Colours]'].value || (parseInt(form.elements['newMonitor[Colours]'].value) != 1 && parseInt(form.elements['newMonitor[Colours]'].value) != 3 && parseInt(form.elements['newMonitor[Colours]'].value) != 4 ) ) + errors[errors.length] = ""; if ( !form.elements['newMonitor[Width]'].value || !(parseInt(form.elements['newMonitor[Width]'].value) > 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[Height]'].value || !(parseInt(form.elements['newMonitor[Height]'].value) > 0 ) ) @@ -115,7 +117,7 @@ function validateForm( form ) errors[errors.length] = ""; if ( !form.elements['newMonitor[SectionLength]'].value || !(parseInt(form.elements['newMonitor[SectionLength]'].value) >= 30 ) ) errors[errors.length] = ""; - if ( !form.elements['newMonitor[FPSReportInterval]'].value || !(parseInt(form.elements['newMonitor[FPSReportInterval]'].value) >= 0 ) ) + if ( !form.elements['newMonitor[FPSReportInterval]'].value || !(parseInt(form.elements['newMonitor[FPSReportInterval]'].value) >= 100 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[FrameSkip]'].value || !(parseInt(form.elements['newMonitor[FrameSkip]'].value) >= 0 ) ) errors[errors.length] = ""; diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index fbbc1f8c1..f253377d4 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -64,6 +64,7 @@ else 'Host' => "", 'Path' => "", 'Port' => "80", + 'Colours' => "", 'Palette' => "", 'Width' => "", 'Height' => "", @@ -138,7 +139,7 @@ if ( $newMonitor['AlarmMaxFPS'] == '0.00' ) if ( !empty($_REQUEST['preset']) ) { - $preset = dbFetchOne( "select Type, Device, Channel, Format, Protocol, Method, Host, Port, Path, Width, Height, Palette, MaxFPS, Controllable, ControlId, ControlDevice, ControlAddress, DefaultRate, DefaultScale from MonitorPresets where Id = '".dbEscape($_REQUEST['preset'])."'" ); + $preset = dbFetchOne( "select Type, Device, Channel, Format, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, MaxFPS, Controllable, ControlId, ControlDevice, ControlAddress, DefaultRate, DefaultScale from MonitorPresets where Id = '".dbEscape($_REQUEST['preset'])."'" ); foreach ( $preset as $name=>$value ) { if ( isset($value) ) @@ -231,13 +232,14 @@ if ( ZM_HAS_V4L1 ) $v4l1LocalPalettes = array( $SLANG['Undefined'] => '', $SLANG['Grey'] => 1, - "RGB24" => 4, - "RGB565" => 3, - "RGB555" => 6, - "YUV422" => 7, - "YUYV" => 8, - "YUV422P" => 13, - "YUV420P" => 15 + "BGR32" => 5, + "BGR24" => 4, + "*RGB565" => 3, + "*RGB555" => 6, + "*YUV422" => 7, + "*YUYV" => 8, + "*YUV422P" => 13, + "*YUV420P" => 15 ); } @@ -284,27 +286,27 @@ if ( ZM_HAS_V4L2 ) $SLANG['Undefined'] => '', /* Pixel format FOURCC depth Description */ - //"RGB332" => fourcc('R','G','B','1'), /* 8 RGB-3-3-2 */ - "RGB444" => fourcc('R','4','4','4'), /* 16 xxxxrrrr ggggbbbb */ - "RGB555" => fourcc('R','G','B','O'), /* 16 RGB-5-5-5 */ - "RGB565" => fourcc('R','G','B','P'), /* 16 RGB-5-6-5 */ - //"RGB555X" => fourcc('R','G','B','Q'), /* 16 RGB-5-5-5 BE */ - //"RGB565X" => fourcc('R','G','B','R'), /* 16 RGB-5-6-5 BE */ - "BGR24" => fourcc('B','G','R','3'), /* 24 BGR-8-8-8 */ - "RGB24" => fourcc('R','G','B','3'), /* 24 RGB-8-8-8 */ + $SLANG['Grey'] => fourcc('G','R','E','Y'), /* 8 Greyscale */ "BGR32" => fourcc('B','G','R','4'), /* 32 BGR-8-8-8-8 */ "RGB32" => fourcc('R','G','B','4'), /* 32 RGB-8-8-8-8 */ - "GREY" => fourcc('G','R','E','Y'), /* 8 Greyscale */ + "BGR24" => fourcc('B','G','R','3'), /* 24 BGR-8-8-8 */ + "RGB24" => fourcc('R','G','B','3'), /* 24 RGB-8-8-8 */ + //"RGB332" => fourcc('R','G','B','1'), /* 8 RGB-3-3-2 */ + "*RGB444" => fourcc('R','4','4','4'), /* 16 xxxxrrrr ggggbbbb */ + "*RGB555" => fourcc('R','G','B','O'), /* 16 RGB-5-5-5 */ + "*RGB565" => fourcc('R','G','B','P'), /* 16 RGB-5-6-5 */ + //"RGB555X" => fourcc('R','G','B','Q'), /* 16 RGB-5-5-5 BE */ + //"RGB565X" => fourcc('R','G','B','R'), /* 16 RGB-5-6-5 BE */ //"Y16" => fourcc('Y','1','6',''), /* 16 Greyscale */ //"PAL8" => fourcc('P','A','L','8'), /* 8 8-bit palette */ //"YVU410" => fourcc('Y','V','U','9'), /* 9 YVU 4:1:0 */ //"YVU420" => fourcc('Y','V','1','2'), /* 12 YVU 4:2:0 */ - "YUYV" => fourcc('Y','U','Y','V'), /* 16 YUV 4:2:2 */ + "*YUYV" => fourcc('Y','U','Y','V'), /* 16 YUV 4:2:2 */ //"UYVY" => fourcc('U','Y','V','Y'), /* 16 YUV 4:2:2 */ - "YUV422P" => fourcc('4','2','2','P'), /* 16 YVU422 planar */ - "YUV411P" => fourcc('4','1','1','P'), /* 16 YVU411 planar */ + "*YUV422P" => fourcc('4','2','2','P'), /* 16 YVU422 planar */ + "*YUV411P" => fourcc('4','1','1','P'), /* 16 YVU411 planar */ //"Y41P" => fourcc('Y','4','1','P'), /* 12 YUV 4:1:1 */ - "YUV444" => fourcc('Y','4','4','4'), /* 16 xxxxyyyy uuuuvvvv */ + "*YUV444" => fourcc('Y','4','4','4'), /* 16 xxxxyyyy uuuuvvvv */ //"YUV555" => fourcc('Y','U','V','O'), /* 16 YUV-5-5-5 */ //"YUV565" => fourcc('Y','U','V','P'), /* 16 YUV-5-6-5 */ //"YUV32" => fourcc('Y','U','V','4'), /* 32 YUV-8-8-8-8 */ @@ -314,8 +316,8 @@ if ( ZM_HAS_V4L2 ) //"NV21" => fourcc('N','V','2','1'), /* 12 Y/CrCb 4:2:0 */ /* The following formats are not defined in the V4L2 specification */ - "YUV410" => fourcc('Y','U','V','9'), /* 9 YUV 4:1:0 */ - "YUV420" => fourcc('Y','U','1','2'), /* 12 YUV 4:2:0 */ + "*YUV410" => fourcc('Y','U','V','9'), /* 9 YUV 4:1:0 */ + "*YUV420" => fourcc('Y','U','1','2'), /* 12 YUV 4:2:0 */ //"YYUV" => fourcc('Y','Y','U','V'), /* 16 YUV 4:2:2 */ //"HI240" => fourcc('H','I','2','4'), /* 8 8-bit color */ //"HM12" => fourcc('H','M','1','2'), /* 8 YUV 4:2:0 16x16 macroblocks */ @@ -347,9 +349,10 @@ if ( ZM_HAS_V4L2 ) ); } -$remoteColours = $fileColours = array( +$Colours = array( $SLANG['8BitGrey'] => 1, - $SLANG['24BitColour'] => 3 + $SLANG['24BitColour'] => 3, + "32 bit colour" => 4 ); $orientations = array( @@ -435,6 +438,7 @@ if ( ZM_HAS_V4L && ($tab != 'source' || $newMonitor['Type'] != 'Local') ) + - + @@ -656,17 +660,16 @@ switch ( $tab ) - - + () () From 33119c6dc5310d05b1c3fea6257c320b598ab4f3 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Fri, 6 May 2011 15:01:16 +0300 Subject: [PATCH 04/56] 1) Added image size requirements to ensure proper alignment 2) Changed image class buffer related functions 3) Improved format selection for local cameras 4) Removed imagesize check for swscale 5) Fixed mmap unexpected memory size when changing capture options 6) Fixed unrelated bug in zmdc.pl: sockets directory doesn't exist --- scripts/zmdc.pl.in | 3 + src/zm_camera.cpp | 8 +- src/zm_image.cpp | 4 +- src/zm_image.h | 48 ++++----- src/zm_local_camera.cpp | 204 ++++++++++++++++++++------------------- src/zm_monitor.cpp | 3 + web/includes/actions.php | 6 +- 7 files changed, 149 insertions(+), 127 deletions(-) diff --git a/scripts/zmdc.pl.in b/scripts/zmdc.pl.in index 47e50cc39..86b23ea31 100644 --- a/scripts/zmdc.pl.in +++ b/scripts/zmdc.pl.in @@ -128,6 +128,9 @@ foreach my $arg ( @ARGV ) } } +# Create the directory first if it doesn't exist +mkdir(ZM_PATH_SOCKS); + socket( CLIENT, PF_UNIX, SOCK_STREAM, 0 ) or Fatal( "Can't open socket: $!" ); my $saddr = sockaddr_un( SOCK_FILE ); diff --git a/src/zm_camera.cpp b/src/zm_camera.cpp index 4bb349585..18950d341 100644 --- a/src/zm_camera.cpp +++ b/src/zm_camera.cpp @@ -37,7 +37,13 @@ Camera::Camera( int p_id, SourceType p_type, int p_width, int p_height, int p_co imagesize = pixels * colours; Debug(2,"New camera id: %d width: %d height: %d colours: %d subpixelorder: %d capture: %d",id,width,height,colours,subpixelorder,capture); - + + /* Because many loops are unrolled and work on 16 colours/time or 4 pixels/time, we have to meet requirements */ + if((colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB32) && (imagesize % 16) != 0) { + Fatal("Image size is not multiples of 16"); + } else if(colours == ZM_COLOUR_RGB24 && ((imagesize % 16) != 0 || (imagesize % 12) != 0)) { + Fatal("Image size is not multiples of 12 and 16"); + } } Camera::~Camera() diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 935fb3687..749b4141d 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -133,7 +133,7 @@ Image::Image( const Image &p_image ) Image::~Image() { - DumpBuffer(); + DumpImgBuffer(); } void Image::Initialise() @@ -344,7 +344,7 @@ void Image::AssignDirect( const int p_width, const int p_height, const int p_col } } else { /* Free an existing buffer if any */ - DumpBuffer(); + DumpImgBuffer(); width = p_width; height = p_height; diff --git a/src/zm_image.h b/src/zm_image.h index 102c4e48d..c26db5e5d 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -44,6 +44,30 @@ extern "C" #define ZM_BUFTYPE_AVMALLOC 3 #define ZM_BUFTYPE_ZM 4 + +/* Should be called from Image class functions */ +inline static uint8_t* AllocBuffer(size_t p_bufsize) { + uint8_t* buffer = (uint8_t*)zm_mallocaligned(16,p_bufsize); + if(buffer == NULL) + Fatal("Memory allocation failed: %s",strerror(errno)); + + return buffer; +} + +inline static void DumpBuffer(uint8_t* buffer, int buffertype) { + if (buffer && buffertype != ZM_BUFTYPE_DONTFREE) { + if(buffertype == ZM_BUFTYPE_ZM) + zm_freealigned(buffer); + else if(buffertype == ZM_BUFTYPE_MALLOC) + free(buffer); + else if(buffertype == ZM_BUFTYPE_NEW) + delete buffer; + /*else if(buffertype == ZM_BUFTYPE_AVMALLOC) + av_free(buffer); + */ + } +} + // // This is image class, and represents a frame captured from a // camera in raw form. @@ -212,30 +236,6 @@ public: void Scale( unsigned int factor ); }; -inline static uint8_t* AllocBuffer(size_t p_bufsize) { - uint8_t* buffer = (uint8_t*)zm_mallocaligned(16,p_bufsize); - if(buffer == NULL) - Fatal("Memory allocation failed: %s",strerror(errno)); - - return buffer; -} - -inline static void DumpBuffer(void* buffer, int buffertype) { - if (buffer && buffertype != ZM_BUFTYPE_DONTFREE) { - if(buffertype == ZM_BUFTYPE_ZM) - zm_freealigned(buffer); - else if(buffertype == ZM_BUFTYPE_MALLOC) - free(buffer); - else if(buffertype == ZM_BUFTYPE_NEW) - delete buffer; - /*else if(buffertype == ZM_BUFTYPE_AVMALLOC) - av_free(buffer); - */ - } -} - - - #endif // ZM_IMAGE_H diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 3f59ca46e..b8f15f22d 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -373,26 +373,11 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, } else if(palette == V4L2_PIX_FMT_GREY && colours == ZM_COLOUR_GRAY8) { conversion_type = 0; subpixelorder = ZM_SUBPIX_ORDER_NONE; - - /* Special case: allow extremely fast conversion of YUYV to grayscale by extracting the Y channel */ - /* YUYV->Grayscale conversion is not available in swscale */ - /* Added especially for my friend jzaw */ - } else if(palette == V4L2_PIX_FMT_YUYV && colours == ZM_COLOUR_GRAY8) { - conversion_type = 2; - if(config.cpu_extensions && sseversion >= 35) { - conversion_fptr = &ssse3_convert_yuyv_gray8; - Debug(2,"Using SSSE3 YUYV->grayscale fast conversion"); - } else { - conversion_fptr = &std_convert_yuyv_gray8; - Debug(2,"Using standard YUYV->grayscale fast conversion"); - } - subpixelorder = ZM_SUBPIX_ORDER_NONE; - - /* Unable to find a solution for the selected palette and target colourspace. Conversion required */ + /* Unable to find a solution for the selected palette and target colourspace. Conversion required. Notify the user of performance penalty */ } else { Warning("Unable to find a match for the selected palette and target colourspace. Conversion required, performance penalty expected"); #if HAVE_LIBSWSCALE - /* Use swscale for the conversion */ + /* Try using swscale for the conversion */ conversion_type = 1; Debug(2,"Using swscale for image conversion"); if(colours == ZM_COLOUR_RGB32) { @@ -408,43 +393,62 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, Panic("Unexpected colours: %d",colours); } if(!sws_isSupportedInput(capturePixFormat)) { - Fatal("swscale does not support the used capture format"); + Error("swscale does not support the used capture format"); + conversion_type = 2; /* Try ZM format conversions */ } if(!sws_isSupportedOutput(imagePixFormat)) { - Fatal("swscale does not support the target format"); + Error("swscale does not support the target format"); + conversion_type = 2; /* Try ZM format conversions */ } #else /* Don't have swscale, see what we can do */ conversion_type = 2; - Debug(2,"Using ZM for image conversion"); - if(palette == V4L2_PIX_FMT_RGB32 && colours == ZM_COLOUR_GRAY8) { - conversion_fptr = &std_convert_argb_gray8; - subpixelorder = ZM_SUBPIX_ORDER_ARGB; - } else if(palette == V4L2_PIX_FMT_BGR32 && colours == ZM_COLOUR_GRAY8) { - conversion_fptr = &std_convert_bgra_gray8; - subpixelorder = ZM_SUBPIX_ORDER_BGRA; - } else if(palette == V4L2_PIX_FMT_YUYV && colours == ZM_COLOUR_RGB24) { - conversion_fptr = &zm_convert_yuyv_rgb; - subpixelorder = ZM_SUBPIX_ORDER_RGB; - } else if(palette == V4L2_PIX_FMT_YUYV && colours == ZM_COLOUR_RGB32) { - conversion_fptr = &zm_convert_yuyv_rgba; - subpixelorder = ZM_SUBPIX_ORDER_RGBA; - } else if(palette == V4L2_PIX_FMT_RGB555 && colours == ZM_COLOUR_RGB24) { - conversion_fptr = &zm_convert_rgb555_rgb; - subpixelorder = ZM_SUBPIX_ORDER_RGB; - } else if(palette == V4L2_PIX_FMT_RGB555 && colours == ZM_COLOUR_RGB32) { - conversion_fptr = &zm_convert_rgb555_rgba; - subpixelorder = ZM_SUBPIX_ORDER_RGBA; - } else if(palette == V4L2_PIX_FMT_RGB565 && colours == ZM_COLOUR_RGB24) { - conversion_fptr = &zm_convert_rgb565_rgb; - subpixelorder = ZM_SUBPIX_ORDER_RGB; - } else if(palette == V4L2_PIX_FMT_RGB565 && colours == ZM_COLOUR_RGB32) { - conversion_fptr = &zm_convert_rgb565_rgba; - subpixelorder = ZM_SUBPIX_ORDER_RGBA; - } else { - Panic("Unable to find suitable conversion for selected palette and target colourspace."); - } #endif + /* Our YUYV->Grayscale conversion is a lot faster than swscale's */ + if(conversion_type == 1 && colours == ZM_COLOUR_GRAY8 && palette == V4L2_PIX_FMT_YUYV) { + conversion_type = 2; + } + + if(conversion_type == 2) { + Debug(2,"Using ZM for image conversion"); + if(palette == V4L2_PIX_FMT_RGB32 && colours == ZM_COLOUR_GRAY8) { + conversion_fptr = &std_convert_argb_gray8; + subpixelorder = ZM_SUBPIX_ORDER_ARGB; + } else if(palette == V4L2_PIX_FMT_BGR32 && colours == ZM_COLOUR_GRAY8) { + conversion_fptr = &std_convert_bgra_gray8; + subpixelorder = ZM_SUBPIX_ORDER_BGRA; + } else if(palette == V4L2_PIX_FMT_YUYV && colours == ZM_COLOUR_GRAY8) { + /* Fast YUYV->Grayscale conversion by extracting the Y channel */ + if(config.cpu_extensions && sseversion >= 35) { + conversion_fptr = &ssse3_convert_yuyv_gray8; + Debug(2,"Using SSSE3 YUYV->grayscale fast conversion"); + } else { + conversion_fptr = &std_convert_yuyv_gray8; + Debug(2,"Using standard YUYV->grayscale fast conversion"); + } + subpixelorder = ZM_SUBPIX_ORDER_NONE; + } else if(palette == V4L2_PIX_FMT_YUYV && colours == ZM_COLOUR_RGB24) { + conversion_fptr = &zm_convert_yuyv_rgb; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } else if(palette == V4L2_PIX_FMT_YUYV && colours == ZM_COLOUR_RGB32) { + conversion_fptr = &zm_convert_yuyv_rgba; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } else if(palette == V4L2_PIX_FMT_RGB555 && colours == ZM_COLOUR_RGB24) { + conversion_fptr = &zm_convert_rgb555_rgb; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } else if(palette == V4L2_PIX_FMT_RGB555 && colours == ZM_COLOUR_RGB32) { + conversion_fptr = &zm_convert_rgb555_rgba; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } else if(palette == V4L2_PIX_FMT_RGB565 && colours == ZM_COLOUR_RGB24) { + conversion_fptr = &zm_convert_rgb565_rgb; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } else if(palette == V4L2_PIX_FMT_RGB565 && colours == ZM_COLOUR_RGB32) { + conversion_fptr = &zm_convert_rgb565_rgba; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } else { + Panic("Unable to find suitable conversion for selected palette and target colourspace."); + } + } } } #endif // ZM_HAS_V4L2 @@ -476,26 +480,11 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, } else if(palette == VIDEO_PALETTE_GREY && colours == ZM_COLOUR_GRAY8) { conversion_type = 0; subpixelorder = ZM_SUBPIX_ORDER_NONE; - - /* Special case: allow extremely fast conversion of YUYV to grayscale by extracting the Y channel */ - /* YUYV->Grayscale conversion is not available in swscale */ - /* Added especially for my friend jzaw */ - } else if((palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422) && colours == ZM_COLOUR_GRAY8) { - conversion_type = 2; - if(config.cpu_extensions && sseversion >= 35) { - conversion_fptr = &ssse3_convert_yuyv_gray8; - Debug(2,"Using SSSE3 YUYV->grayscale fast conversion"); - } else { - conversion_fptr = &std_convert_yuyv_gray8; - Debug(2,"Using standard YUYV->grayscale fast conversion"); - } - subpixelorder = ZM_SUBPIX_ORDER_NONE; - /* Unable to find a solution for the selected palette and target colourspace. Conversion required. Notify the user of performance penalty */ } else { Warning("Unable to find a match for the selected palette and target colourspace. Conversion required, performance penalty expected"); #if HAVE_LIBSWSCALE - /* Use swscale for the conversion */ + /* Try using swscale for the conversion */ conversion_type = 1; Debug(2,"Using swscale for image conversion"); if(colours == ZM_COLOUR_RGB32) { @@ -511,45 +500,64 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, Panic("Unexpected colours: %d",colours); } if(!sws_isSupportedInput(capturePixFormat)) { - Fatal("swscale does not support the used capture format"); + Error("swscale does not support the used capture format"); + conversion_type = 2; /* Try ZM format conversions */ } if(!sws_isSupportedOutput(imagePixFormat)) { - Fatal("swscale does not support the target format"); + Error("swscale does not support the target format"); + conversion_type = 2; /* Try ZM format conversions */ } #else /* Don't have swscale, see what we can do */ conversion_type = 2; - Debug(2,"Using ZM for image conversion"); - if(palette == VIDEO_PALETTE_RGB32 && colours == ZM_COLOUR_GRAY8) { - if(BigEndian) { - conversion_fptr = &std_convert_argb_gray8; - subpixelorder = ZM_SUBPIX_ORDER_ARGB; - } else { - conversion_fptr = &std_convert_bgra_gray8; - subpixelorder = ZM_SUBPIX_ORDER_BGRA; - } - } else if((palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422) && colours == ZM_COLOUR_RGB24) { - conversion_fptr = &zm_convert_yuyv_rgb; - subpixelorder = ZM_SUBPIX_ORDER_RGB; - } else if((palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422) && colours == ZM_COLOUR_RGB32) { - conversion_fptr = &zm_convert_yuyv_rgba; - subpixelorder = ZM_SUBPIX_ORDER_RGBA; - } else if(palette == VIDEO_PALETTE_RGB555 && colours == ZM_COLOUR_RGB24) { - conversion_fptr = &zm_convert_rgb555_rgb; - subpixelorder = ZM_SUBPIX_ORDER_RGB; - } else if(palette == VIDEO_PALETTE_RGB555 && colours == ZM_COLOUR_RGB32) { - conversion_fptr = &zm_convert_rgb555_rgba; - subpixelorder = ZM_SUBPIX_ORDER_RGBA; - } else if(palette == VIDEO_PALETTE_RGB565 && colours == ZM_COLOUR_RGB24) { - conversion_fptr = &zm_convert_rgb565_rgb; - subpixelorder = ZM_SUBPIX_ORDER_RGB; - } else if(palette == VIDEO_PALETTE_RGB565 && colours == ZM_COLOUR_RGB32) { - conversion_fptr = &zm_convert_rgb565_rgba; - subpixelorder = ZM_SUBPIX_ORDER_RGBA; - } else { - Panic("Unable to find suitable conversion for selected palette and target colourspace."); - } #endif + /* Our YUYV->Grayscale conversion is a lot faster than swscale's */ + if(conversion_type == 1 && colours == ZM_COLOUR_GRAY8 && (palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422)) { + conversion_type = 2; + } + + if(conversion_type == 2) { + Debug(2,"Using ZM for image conversion"); + if(palette == VIDEO_PALETTE_RGB32 && colours == ZM_COLOUR_GRAY8) { + if(BigEndian) { + conversion_fptr = &std_convert_argb_gray8; + subpixelorder = ZM_SUBPIX_ORDER_ARGB; + } else { + conversion_fptr = &std_convert_bgra_gray8; + subpixelorder = ZM_SUBPIX_ORDER_BGRA; + } + } else if((palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422) && colours == ZM_COLOUR_GRAY8) { + /* Fast YUYV->Grayscale conversion by extracting the Y channel */ + if(config.cpu_extensions && sseversion >= 35) { + conversion_fptr = &ssse3_convert_yuyv_gray8; + Debug(2,"Using SSSE3 YUYV->grayscale fast conversion"); + } else { + conversion_fptr = &std_convert_yuyv_gray8; + Debug(2,"Using standard YUYV->grayscale fast conversion"); + } + subpixelorder = ZM_SUBPIX_ORDER_NONE; + } else if((palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422) && colours == ZM_COLOUR_RGB24) { + conversion_fptr = &zm_convert_yuyv_rgb; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } else if((palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422) && colours == ZM_COLOUR_RGB32) { + conversion_fptr = &zm_convert_yuyv_rgba; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } else if(palette == VIDEO_PALETTE_RGB555 && colours == ZM_COLOUR_RGB24) { + conversion_fptr = &zm_convert_rgb555_rgb; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } else if(palette == VIDEO_PALETTE_RGB555 && colours == ZM_COLOUR_RGB32) { + conversion_fptr = &zm_convert_rgb555_rgba; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } else if(palette == VIDEO_PALETTE_RGB565 && colours == ZM_COLOUR_RGB24) { + conversion_fptr = &zm_convert_rgb565_rgb; + subpixelorder = ZM_SUBPIX_ORDER_RGB; + } else if(palette == VIDEO_PALETTE_RGB565 && colours == ZM_COLOUR_RGB32) { + conversion_fptr = &zm_convert_rgb565_rgba; + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + } else { + Panic("Unable to find suitable conversion for selected palette and target colourspace."); + } + } } } #endif // ZM_HAS_V4L1 @@ -1905,9 +1913,9 @@ int LocalCamera::Capture( Image &image ) /* Use swscale to convert the image directly into the shared memory */ unsigned int pSize = avpicture_fill( (AVPicture *)tmpPicture, directbuffer, imagePixFormat, width, height ); - if( pSize != imagesize) { - Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize); - } + //if( pSize != imagesize) { + // Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize); + //} sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize ); diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 40cb8280f..86c9c579f 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -556,6 +556,9 @@ Monitor::~Monitor() if ( munmap( mem_ptr, mem_size ) < 0 ) Fatal( "Can't munmap: %s", strerror(errno) ); close( map_fd ); + /* Remove the memory file to avoid getting unexpected memory size error */ + if( purpose == CAPTURE ) + unlink(mem_file); #else // ZM_MEM_MAPPED struct shmid_ds shm_data; if ( shmctl( shm_id, IPC_STAT, &shm_data ) < 0 ) diff --git a/web/includes/actions.php b/web/includes/actions.php index 7c7ddcec1..3204ef4a7 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -299,8 +299,9 @@ if ( !empty($action) ) if ( daemonCheck() ) { $restart = ($oldFunction == 'None') || ($newFunction == 'None') || ($newEnabled != $oldEnabled); + zmaControl( $monitor, "stop" ); zmcControl( $monitor, $restart?"restart":"" ); - zmaControl( $monitor, "reload" ); + zmaControl( $monitor, "start" ); } $refreshParent = true; } @@ -530,8 +531,9 @@ if ( !empty($action) ) //session_write_close(); if ( daemonCheck() ) { + zmaControl( $monitor, "stop" ); zmcControl( $monitor, "restart" ); - zmaControl( $monitor, "restart" ); + zmaControl( $monitor, "start" ); } //daemonControl( 'restart', 'zmwatch.pl' ); $refreshParent = true; From f2aaeb78e0ef3764fa900c337d254f3784088094 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Fri, 6 May 2011 23:07:40 +0300 Subject: [PATCH 05/56] 1) Completed ffmpeg code 2) Minor changes to zm_local_camera.cpp --- src/zm_ffmpeg_camera.cpp | 91 ++++++++++++++++++++++++++++------------ src/zm_ffmpeg_camera.h | 6 ++- src/zm_local_camera.cpp | 13 +++--- 3 files changed, 76 insertions(+), 34 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 7ca98aefe..d2f19dd95 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -31,14 +31,31 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, int p_width, in { Initialise(); } - - mFormatContext = NULL; - mVideoStreamId = -1; - mCodecContext = NULL; - mCodec = NULL; - mConvertContext = NULL; - mRawFrame = NULL; - mFrame = NULL; + + mFormatContext = NULL; + mVideoStreamId = -1; + mCodecContext = NULL; + mCodec = NULL; + mRawFrame = NULL; + mFrame = NULL; + +#if HAVE_LIBSWSCALE + mConvertContext = NULL; +#endif + /* Has to be located inside the constructor so other components such as zma will receive correct colours and subpixel order */ + if(colours == ZM_COLOUR_RGB32) { + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + imagePixFormat = PIX_FMT_RGBA; + } else if(colours == ZM_COLOUR_RGB24) { + subpixelorder = ZM_SUBPIX_ORDER_RGB; + imagePixFormat = PIX_FMT_RGB24; + } else if(colours == ZM_COLOUR_GRAY8) { + subpixelorder = ZM_SUBPIX_ORDER_NONE; + imagePixFormat = PIX_FMT_GRAY8; + } else { + Panic("Unexpected colours: %d",colours); + } + } FfmpegCamera::~FfmpegCamera() @@ -46,11 +63,14 @@ FfmpegCamera::~FfmpegCamera() av_freep( &mFrame ); av_freep( &mRawFrame ); +#if HAVE_LIBSWSCALE if ( mConvertContext ) { sws_freeContext( mConvertContext ); mConvertContext = NULL; } +#endif + if ( mCodecContext ) { avcodec_close( mCodecContext ); @@ -70,10 +90,6 @@ FfmpegCamera::~FfmpegCamera() void FfmpegCamera::Initialise() { - int max_size = width*height*colours; - - mBuffer.size( max_size ); - if ( logDebugging() ) av_log_set_level( AV_LOG_DEBUG ); else @@ -130,16 +146,28 @@ int FfmpegCamera::PrimeCapture() // Allocate space for the converted video frame mFrame = avcodec_alloc_frame(); - - // Determine required buffer size and allocate buffer - int pictureSize = avpicture_get_size( PIX_FMT_RGB24, mCodecContext->width, mCodecContext->height ); - mBuffer.size( pictureSize ); - avpicture_fill( (AVPicture *)mFrame, (unsigned char *)mBuffer, PIX_FMT_RGB24, mCodecContext->width, mCodecContext->height); - + if(mRawFrame == NULL || mFrame == NULL) + Fatal( "Unable to allocate frame for %s", mPath.c_str() ); + + int pSize = avpicture_get_size( imagePixFormat, width, height ); + if( pSize != imagesize) { + Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize); + } + #if HAVE_LIBSWSCALE - if ( (mConvertContext = sws_getCachedContext( mConvertContext, mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL )) == NULL ) - Fatal( "Unable to create conversion context for %s", mPath.c_str() ); + if(!sws_isSupportedOutput(imagePixFormat)) { + Fatal("swscale does not support the target format"); + } + + if(config.cpu_extensions && sseversion >= 20) { + mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL ); + } else { + mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL ); + } + + if(mConvertContext == NULL) + Fatal( "Unable to create conversion context for %s", mPath.c_str() ); #else // HAVE_LIBSWSCALE Fatal( "You must compile ffmpeg with the --enable-swscale option to use ffmpeg cameras" ); #endif // HAVE_LIBSWSCALE @@ -157,6 +185,15 @@ int FfmpegCamera::Capture( Image &image ) { static int frameCount = 0; AVPacket packet; + uint8_t* directbuffer; + + /* Request a writeable buffer of the target image */ + directbuffer = image.WriteBuffer(width, height, colours, subpixelorder); + if(directbuffer == NULL) { + Error("Failed requesting writeable buffer for the captured image."); + return (-1); + } + int frameComplete = false; while ( !frameComplete ) { @@ -172,21 +209,21 @@ int FfmpegCamera::Capture( Image &image ) if ( avcodec_decode_video2( mCodecContext, mRawFrame, &frameComplete, &packet ) < 0 ) Fatal( "Unable to decode frame at frame %d", frameCount ); - Debug( 3, "Decoded video packet at frame %d", frameCount ); + Debug( 4, "Decoded video packet at frame %d", frameCount ); if ( frameComplete ) { - Debug( 1, "Got frame %d", frameCount ); + Debug( 3, "Got frame %d", frameCount ); + avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height); + #if HAVE_LIBSWSCALE - if ( sws_scale( mConvertContext, mRawFrame->data, mRawFrame->linesize, 0, mCodecContext->height, mFrame->data, mFrame->linesize ) < 0 ) - Fatal( "Unable to convert raw format %d to RGB at frame %d", mCodecContext->pix_fmt, frameCount ); + if ( sws_scale( mConvertContext, mRawFrame->data, mRawFrame->linesize, 0, mCodecContext->height, mFrame->data, mFrame->linesize ) < 0 ) + Fatal( "Unable to convert raw format %u to target format %u at frame %d", mCodecContext->pix_fmt, imagePixFormat, frameCount ); #else // HAVE_LIBSWSCALE - Fatal( "You must compile ffmpeg with the --enable-swscale option to use ffmpeg cameras" ); + Fatal( "You must compile ffmpeg with the --enable-swscale option to use ffmpeg cameras" ); #endif // HAVE_LIBSWSCALE - image.Assign( mCodecContext->width, mCodecContext->height, colours, subpixelorder, (unsigned char *)mFrame->data[0], imagesize); - frameCount++; } } diff --git a/src/zm_ffmpeg_camera.h b/src/zm_ffmpeg_camera.h index c421c54c0..d5fb3b817 100644 --- a/src/zm_ffmpeg_camera.h +++ b/src/zm_ffmpeg_camera.h @@ -40,12 +40,14 @@ protected: int mVideoStreamId; AVCodecContext *mCodecContext; AVCodec *mCodec; - struct SwsContext *mConvertContext; AVFrame *mRawFrame; AVFrame *mFrame; + PixelFormat imagePixFormat; #endif // HAVE_LIBAVFORMAT - Buffer mBuffer; +#if HAVE_LIBSWSCALE + struct SwsContext *mConvertContext; +#endif public: FfmpegCamera( int p_id, const std::string &path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ); diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index b8f15f22d..7d20053f8 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -482,7 +482,8 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, subpixelorder = ZM_SUBPIX_ORDER_NONE; /* Unable to find a solution for the selected palette and target colourspace. Conversion required. Notify the user of performance penalty */ } else { - Warning("Unable to find a match for the selected palette and target colourspace. Conversion required, performance penalty expected"); + if( capture ) + Warning("Unable to find a match for the selected palette and target colourspace. Conversion required, performance penalty expected"); #if HAVE_LIBSWSCALE /* Try using swscale for the conversion */ conversion_type = 1; @@ -940,6 +941,11 @@ void LocalCamera::Initialise() if ( !tmpPicture ) Fatal( "Could not allocate temporary picture" ); + int pSize = avpicture_get_size( imagePixFormat, width, height ); + if( pSize != imagesize) { + Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize); + } + if(config.cpu_extensions && sseversion >= 20) { imgConversionContext = sws_getContext(width, height, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL ); } else { @@ -1912,10 +1918,7 @@ int LocalCamera::Capture( Image &image ) if(conversion_type == 1) { /* Use swscale to convert the image directly into the shared memory */ - unsigned int pSize = avpicture_fill( (AVPicture *)tmpPicture, directbuffer, imagePixFormat, width, height ); - //if( pSize != imagesize) { - // Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize); - //} + avpicture_fill( (AVPicture *)tmpPicture, directbuffer, imagePixFormat, width, height ); sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize ); From 37cc9199b221ad5585d842e3658c5ed048493ca4 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sat, 7 May 2011 18:39:16 +0300 Subject: [PATCH 06/56] 1) Changed ZM static colours to RGB order instead of HTML(BGR) order 2) Allow ZM to compile without swscale - hopefully 3) Saved few cpu cycles during image blending 4) Fixed wrong zone colours showing up 5) Unrelated fix: Allow ZM to be compiled with the latest ffmpeg revisions --- src/zm_image.cpp | 148 +++++++++++++++++++++++----------------- src/zm_local_camera.cpp | 14 ++-- src/zm_mpeg.cpp | 2 +- src/zm_rgb.h | 16 ++--- 4 files changed, 103 insertions(+), 77 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 749b4141d..af5c0133e 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -451,19 +451,22 @@ void Image::Assign( const Image &image ) { Image *Image::HighlightEdges( Rgb colour, const Box *limits ) { - if ( colours != 1 ) - { - Panic( "Attempt to highlight image edges when colours = %d", colours ); - } - Image *high_image = new Image( width, height, 3, ZM_SUBPIX_ORDER_RGB); + if ( colours != 1 ) + { + Panic( "Attempt to highlight image edges when colours = %d", colours ); + } + + Image *high_image = new Image( width, height, ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB); + uint8_t* high_buff = high_image->WriteBuffer(width, height, ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB); + int lo_x = limits?limits->Lo().X():0; int lo_y = limits?limits->Lo().Y():0; int hi_x = limits?limits->Hi().X():width-1; int hi_y = limits?limits->Hi().Y():height-1; for ( int y = lo_y; y <= hi_y; y++ ) { - unsigned char *p = &buffer[(y*width)+lo_x]; - unsigned char *phigh = (uint8_t*)high_image->Buffer( lo_x, y ); + uint8_t *p = &buffer[(y*width)+lo_x]; + uint8_t *phigh = high_buff + ( lo_x * y ); for ( int x = lo_x; x <= hi_x; x++, p++, phigh += 3 ) { bool edge = false; @@ -1209,10 +1212,6 @@ void Image::Blend( const Image &image, int transparency ) const Panic( "Attempt to blend different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, image.width, image.height, image.colours, image.subpixelorder ); } - if((size % 16) != 0) { - Warning("Image size is not multiples of 16"); - } - /* Do the blending */ (*fptr_blend)(buffer, image.buffer, buffer, size, transparency); } @@ -1678,6 +1677,10 @@ void Image::Fill( Rgb colour, const Box *limits ) { Panic( "Attempt to fill image with unexpected colours %d", colours ); } + + /* Convert the colour's RGBA subpixel order into the image's subpixel order */ + colour = rgb_convert(colour,subpixelorder); + int lo_x = limits?limits->Lo().X():0; int lo_y = limits?limits->Lo().Y():0; int hi_x = limits?limits->Hi().X():width-1; @@ -1733,6 +1736,9 @@ void Image::Fill( Rgb colour, int density, const Box *limits ) { Panic( "Attempt to fill image with unexpected colours %d", colours ); } + + /* Convert the colour's RGBA subpixel order into the image's subpixel order */ + colour = rgb_convert(colour,subpixelorder); int lo_x = limits?limits->Lo().X():0; int lo_y = limits?limits->Lo().Y():0; @@ -1786,9 +1792,13 @@ void Image::Fill( Rgb colour, int density, const Box *limits ) void Image::Outline( Rgb colour, const Polygon &polygon ) { if ( !(colours == 1 || colours == 3 || colours == 4 ) ) - { - Panic( "Attempt to outline image with unexpected colours %d", colours ); - } + { + Panic( "Attempt to outline image with unexpected colours %d", colours ); + } + + /* Convert the colour's RGBA subpixel order into the image's subpixel order */ + colour = rgb_convert(colour,subpixelorder); + int n_coords = polygon.getNumCoords(); for ( int j = 0, i = n_coords-1; j < n_coords; i = j++ ) { @@ -1894,6 +1904,9 @@ void Image::Fill( Rgb colour, int density, const Polygon &polygon ) { Panic( "Attempt to fill image with unexpected colours %d", colours ); } + + /* Convert the colour's RGBA subpixel order into the image's subpixel order */ + colour = rgb_convert(colour,subpixelorder); int n_coords = polygon.getNumCoords(); int n_global_edges = 0; @@ -2336,35 +2349,39 @@ void Image::Scale( unsigned int factor ) __attribute__ ((noinline)) void sse2_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { #if (defined(__i386__) || defined(__x86_64__)) - int divider = 0; - uint32_t clearmask = 0; + static uint32_t divider = 0; + static uint32_t clearmask = 0; + static double current_blendpercent = 0.0; unsigned long i = 0; - - /* Attempt to match the blending percent to one of the possible values */ - if(blendpercent < 2.34375) { - // 1.5625% blending - divider = 6; - clearmask = 0x03030303; - } else if(blendpercent >= 2.34375 && blendpercent < 4.6875) { - // 3.125% blending - divider = 5; - clearmask = 0x07070707; - } else if(blendpercent >= 4.6875 && blendpercent < 9.375) { - // 6.25% blending - divider = 4; - clearmask = 0x0F0F0F0F; - } else if(blendpercent >= 9.375 && blendpercent < 18.75) { - // 12.5% blending - divider = 3; - clearmask = 0x1F1F1F1F; - } else if(blendpercent >= 18.75 && blendpercent < 37.5) { - // 25% blending - divider = 2; - clearmask = 0x3F3F3F3F; - } else if(blendpercent >= 37.5) { - // 50% blending - divider = 1; - clearmask = 0x7F7F7F7F; + + if(current_blendpercent != blendpercent) { + /* Attempt to match the blending percent to one of the possible values */ + if(blendpercent < 2.34375) { + // 1.5625% blending + divider = 6; + clearmask = 0x03030303; + } else if(blendpercent >= 2.34375 && blendpercent < 4.6875) { + // 3.125% blending + divider = 5; + clearmask = 0x07070707; + } else if(blendpercent >= 4.6875 && blendpercent < 9.375) { + // 6.25% blending + divider = 4; + clearmask = 0x0F0F0F0F; + } else if(blendpercent >= 9.375 && blendpercent < 18.75) { + // 12.5% blending + divider = 3; + clearmask = 0x1F1F1F1F; + } else if(blendpercent >= 18.75 && blendpercent < 37.5) { + // 25% blending + divider = 2; + clearmask = 0x3F3F3F3F; + } else if(blendpercent >= 37.5) { + // 50% blending + divider = 1; + clearmask = 0x7F7F7F7F; + } + current_blendpercent = blendpercent; } __asm__ __volatile__( @@ -2395,28 +2412,33 @@ __attribute__ ((noinline)) void sse2_fastblend(const uint8_t* col1, const uint8_ } __attribute__ ((noinline)) void std_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { - int divider = 0; - - /* Attempt to match the blending percent to one of the possible values */ - if(blendpercent < 2.34375) { - // 1.5625% blending - divider = 6; - } else if(blendpercent >= 2.34375 && blendpercent < 4.6875) { - // 3.125% blending - divider = 5; - } else if(blendpercent >= 4.6875 && blendpercent < 9.375) { - // 6.25% blending - divider = 4; - } else if(blendpercent >= 9.375 && blendpercent < 18.75) { - // 12.5% blending - divider = 3; - } else if(blendpercent >= 18.75 && blendpercent < 37.5) { - // 25% blending - divider = 2; - } else if(blendpercent >= 37.5) { - // 50% blending - divider = 1; + static int divider = 0; + static double current_blendpercent = 0.0; + + if(current_blendpercent != blendpercent) { + /* Attempt to match the blending percent to one of the possible values */ + if(blendpercent < 2.34375) { + // 1.5625% blending + divider = 6; + } else if(blendpercent >= 2.34375 && blendpercent < 4.6875) { + // 3.125% blending + divider = 5; + } else if(blendpercent >= 4.6875 && blendpercent < 9.375) { + // 6.25% blending + divider = 4; + } else if(blendpercent >= 9.375 && blendpercent < 18.75) { + // 12.5% blending + divider = 3; + } else if(blendpercent >= 18.75 && blendpercent < 37.5) { + // 25% blending + divider = 2; + } else if(blendpercent >= 37.5) { + // 50% blending + divider = 1; + } + current_blendpercent = blendpercent; } + for(register unsigned long i=0; i < count; i += 16, col1 += 16, col2 += 16, result += 16) { result[0] = ((col2[0] - col1[0])>>divider) + col1[0]; diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 7d20053f8..63c1188d1 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -375,7 +375,8 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, subpixelorder = ZM_SUBPIX_ORDER_NONE; /* Unable to find a solution for the selected palette and target colourspace. Conversion required. Notify the user of performance penalty */ } else { - Warning("Unable to find a match for the selected palette and target colourspace. Conversion required, performance penalty expected"); + if( capture ) + Warning("Unable to find a match for the selected palette and target colourspace. Conversion required, performance penalty expected"); #if HAVE_LIBSWSCALE /* Try using swscale for the conversion */ conversion_type = 1; @@ -1011,6 +1012,7 @@ void LocalCamera::Terminate() close( vid_fd ); +#if HAVE_LIBSWSCALE /* Clean up swscale stuff */ if(conversion_type == 1) { sws_freeContext(imgConversionContext); @@ -1019,7 +1021,8 @@ void LocalCamera::Terminate() av_free(tmpPicture); tmpPicture = NULL; } - +#endif + } #define capString(test,prefix,yesString,noString,capability) \ @@ -1914,15 +1917,16 @@ int LocalCamera::Capture( Image &image ) Error("Failed requesting writeable buffer for the captured image."); return (-1); } - +#if HAVE_LIBSWSCALE if(conversion_type == 1) { /* Use swscale to convert the image directly into the shared memory */ avpicture_fill( (AVPicture *)tmpPicture, directbuffer, imagePixFormat, width, height ); sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize ); - - } else if(conversion_type == 2) { + } +#endif + if(conversion_type == 2) { /* Call the image conversion function and convert directly into the shared memory */ (*conversion_fptr)(buffer, directbuffer, pixels); diff --git a/src/zm_mpeg.cpp b/src/zm_mpeg.cpp index ca06449df..ff5ba944d 100644 --- a/src/zm_mpeg.cpp +++ b/src/zm_mpeg.cpp @@ -337,7 +337,7 @@ double VideoStream::EncodeFrame( const uint8_t *buffer, int buffer_size, bool ad } sws_scale( img_convert_ctx, tmp_opicture->data, tmp_opicture->linesize, 0, c->height, opicture->data, opicture->linesize ); #else // HAVE_LIBSWSCALE - img_convert( (AVPicture *)opicture, c->pix_fmt, (AVPicture *)tmp_opicture, pf, c->width, c->height ); + Fatal("swscale is required for MPEG mode"); #endif // HAVE_LIBSWSCALE } else diff --git a/src/zm_rgb.h b/src/zm_rgb.h index 64af4b975..5694eff19 100644 --- a/src/zm_rgb.h +++ b/src/zm_rgb.h @@ -34,11 +34,11 @@ typedef uint32_t Rgb; // RGB colour type #define RGB_WHITE (0x00ffffff) #define RGB_BLACK (0x00000000) -#define RGB_RED (0x00ff0000) +#define RGB_RED (0x000000ff) #define RGB_GREEN (0x0000ff00) -#define RGB_BLUE (0x000000ff) -#define RGB_ORANGE (0x00ffa500) -#define RGB_PURPLE (0x00800080) +#define RGB_BLUE (0x00ff0000) +#define RGB_ORANGE (0x0000a5ff) +#define RGB_PURPLE (0x00800080) #define RGB_TRANSPARENT (0x01000000) #define RGB_VAL(v,c) (((v)>>(16-((c)*8)))&0xff) @@ -46,7 +46,7 @@ typedef uint32_t Rgb; // RGB colour type /* RGB or RGBA macros */ #define BLUE_VAL_RGBA(v) (((v)>>16)&0xff) #define GREEN_VAL_RGBA(v) (((v)>>8)&0xff) -#define RED_VAL_RGBA(v) ((v)&0xff) +#define RED_VAL_RGBA(v) ((v)&0xff) #define ALPHA_VAL_RGBA(v) ((v)>>24)&0xff) #define RED_PTR_RGBA(ptr) (*((uint8_t*)ptr)) #define GREEN_PTR_RGBA(ptr) (*((uint8_t*)ptr+1)) @@ -54,7 +54,7 @@ typedef uint32_t Rgb; // RGB colour type #define ALPHA_PTR_RGBA(ptr) (*((uint8_t*)ptr+3)) /* BGR or BGRA */ -#define RED_VAL_BGRA(v) (((v)>>16)&0xff) +#define RED_VAL_BGRA(v) (((v)>>16)&0xff) #define GREEN_VAL_BGRA(v) (((v)>>8)&0xff) #define BLUE_VAL_BGRA(v) ((v)&0xff) #define ALPHA_VAL_BGRA(v) ((v)>>24)&0xff) @@ -66,7 +66,7 @@ typedef uint32_t Rgb; // RGB colour type /* ARGB */ #define BLUE_VAL_ARGB(v) (((v)>>24)&0xff) #define GREEN_VAL_ARGB(v) (((v)>>16)&0xff) -#define RED_VAL_ARGB(v) (((v)>>8)&0xff) +#define RED_VAL_ARGB(v) (((v)>>8)&0xff) #define ALPHA_VAL_ARGB(v) ((v)&0xff) #define RED_PTR_ARGB(ptr) (*((uint8_t*)ptr+1)) #define GREEN_PTR_ARGB(ptr) (*((uint8_t*)ptr+2)) @@ -76,7 +76,7 @@ typedef uint32_t Rgb; // RGB colour type /* ABGR */ #define BLUE_VAL_ABGR(v) (((v)>>8)&0xff) #define GREEN_VAL_ABGR(v) (((v)>>16)&0xff) -#define RED_VAL_ABGR(v) (((v)>>24)&0xff) +#define RED_VAL_ABGR(v) (((v)>>24)&0xff) #define ALPHA_VAL_ABGR(v) ((v)&0xff) #define RED_PTR_ABGR(ptr) (*((uint8_t*)ptr+3)) #define GREEN_PTR_ABGR(ptr) (*((uint8_t*)ptr+2)) From ea3a1a9072d7beff43cef85fb6b372a024499344 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sun, 8 May 2011 16:32:42 +0300 Subject: [PATCH 07/56] 1) Removed the mmap file removal at shutdown. 2) ZoneMinder should now compile cleanly wihout swscale 3) Fixed multiple monitors capturing from the same device and channel. Current code allows for multiple monitors sharing the same device, each on a different channel Or, multiple monitors sharing the same device, all on the same channel. In both cases, capture method, width, height and palette must be identical on all monitors. However, target colorspace can be different because each monitor handles the format conversion separately. --- src/zm_local_camera.cpp | 149 +++++++++++++++++----------------- src/zm_local_camera.h | 10 +-- src/zm_monitor.cpp | 3 - src/zm_remote_camera_rtsp.cpp | 4 +- 4 files changed, 81 insertions(+), 85 deletions(-) diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 63c1188d1..53ba9ce1f 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -338,9 +338,11 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, #if HAVE_LIBSWSCALE - /* Get ffmpeg pixel format based on capture palette and endianness */ - capturePixFormat = getFfPixFormatFromV4lPalette( v4l_version, palette ); - imagePixFormat = PIX_FMT_NONE; + if( capture ) { + /* Get ffmpeg pixel format based on capture palette and endianness */ + capturePixFormat = getFfPixFormatFromV4lPalette( v4l_version, palette ); + imagePixFormat = PIX_FMT_NONE; + } #endif // HAVE_LIBSWSCALE @@ -393,13 +395,15 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, } else { Panic("Unexpected colours: %d",colours); } - if(!sws_isSupportedInput(capturePixFormat)) { - Error("swscale does not support the used capture format"); - conversion_type = 2; /* Try ZM format conversions */ - } - if(!sws_isSupportedOutput(imagePixFormat)) { - Error("swscale does not support the target format"); - conversion_type = 2; /* Try ZM format conversions */ + if( capture ) { + if(!sws_isSupportedInput(capturePixFormat)) { + Error("swscale does not support the used capture format"); + conversion_type = 2; /* Try ZM format conversions */ + } + if(!sws_isSupportedOutput(imagePixFormat)) { + Error("swscale does not support the target format"); + conversion_type = 2; /* Try ZM format conversions */ + } } #else /* Don't have swscale, see what we can do */ @@ -447,7 +451,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, conversion_fptr = &zm_convert_rgb565_rgba; subpixelorder = ZM_SUBPIX_ORDER_RGBA; } else { - Panic("Unable to find suitable conversion for selected palette and target colourspace."); + Fatal("Unable to find suitable conversion for selected palette and target colourspace."); } } } @@ -501,13 +505,15 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, } else { Panic("Unexpected colours: %d",colours); } - if(!sws_isSupportedInput(capturePixFormat)) { - Error("swscale does not support the used capture format"); - conversion_type = 2; /* Try ZM format conversions */ - } - if(!sws_isSupportedOutput(imagePixFormat)) { - Error("swscale does not support the target format"); - conversion_type = 2; /* Try ZM format conversions */ + if( capture ) { + if(!sws_isSupportedInput(capturePixFormat)) { + Error("swscale does not support the used capture format"); + conversion_type = 2; /* Try ZM format conversions */ + } + if(!sws_isSupportedOutput(imagePixFormat)) { + Error("swscale does not support the target format"); + conversion_type = 2; /* Try ZM format conversions */ + } } #else /* Don't have swscale, see what we can do */ @@ -566,12 +572,47 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, last_camera = this; Debug(3,"Selected subpixelorder: %d",subpixelorder); + +#if HAVE_LIBSWSCALE + /* Initialize swscale stuff */ + if(capture && conversion_type == 1) { + tmpPicture = avcodec_alloc_frame(); + if ( !tmpPicture ) + Fatal( "Could not allocate temporary picture" ); + + int pSize = avpicture_get_size( imagePixFormat, width, height ); + if( pSize != imagesize) { + Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize); + } + + if(config.cpu_extensions && sseversion >= 20) { + imgConversionContext = sws_getContext(width, height, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL ); + } else { + imgConversionContext = sws_getContext(width, height, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL ); + } + + if ( !imgConversionContext ) + Fatal( "Unable to initialise image scaling context" ); + + } +#endif } LocalCamera::~LocalCamera() { if ( device_prime && capture ) Terminate(); + +#if HAVE_LIBSWSCALE + /* Clean up swscale stuff */ + if(capture && conversion_type == 1) { + sws_freeContext(imgConversionContext); + imgConversionContext = NULL; + + av_free(tmpPicture); + tmpPicture = NULL; + } +#endif } void LocalCamera::Initialise() @@ -723,12 +764,10 @@ void LocalCamera::Initialise() Fatal( "Can't map video buffer %d (%d bytes) to memory: %s(%d)", i, vid_buf.length, strerror(errno), errno ); #if HAVE_LIBSWSCALE - if (conversion_type == 1) { - capturePictures[i] = avcodec_alloc_frame(); - if ( !capturePictures[i] ) - Fatal( "Could not allocate picture" ); - avpicture_fill( (AVPicture *)capturePictures[i], (uint8_t*)v4l2_data.buffers[i].start, capturePixFormat, v4l2_data.fmt.fmt.pix.width, v4l2_data.fmt.fmt.pix.height ); - } + capturePictures[i] = avcodec_alloc_frame(); + if ( !capturePictures[i] ) + Fatal( "Could not allocate picture" ); + avpicture_fill( (AVPicture *)capturePictures[i], (uint8_t*)v4l2_data.buffers[i].start, capturePixFormat, v4l2_data.fmt.fmt.pix.width, v4l2_data.fmt.fmt.pix.height ); #endif // HAVE_LIBSWSCALE } @@ -879,13 +918,10 @@ void LocalCamera::Initialise() v4l1_data.buffers[i].height = height; v4l1_data.buffers[i].format = palette; - if (conversion_type == 1) - { - capturePictures[i] = avcodec_alloc_frame(); - if ( !capturePictures[i] ) - Fatal( "Could not allocate picture" ); - avpicture_fill( (AVPicture *)capturePictures[i], (unsigned char *)v4l1_data.bufptr+v4l1_data.frames.offsets[i], capturePixFormat, width, height ); - } + capturePictures[i] = avcodec_alloc_frame(); + if ( !capturePictures[i] ) + Fatal( "Could not allocate picture" ); + avpicture_fill( (AVPicture *)capturePictures[i], (unsigned char *)v4l1_data.bufptr+v4l1_data.frames.offsets[i], capturePixFormat, width, height ); } #endif // HAVE_LIBSWSCALE @@ -935,29 +971,6 @@ void LocalCamera::Initialise() Debug( 4, "New Cn:%d", vid_pic.contrast ); } #endif // ZM_HAS_V4L1 - -#if HAVE_LIBSWSCALE - if(conversion_type == 1) { - tmpPicture = avcodec_alloc_frame(); - if ( !tmpPicture ) - Fatal( "Could not allocate temporary picture" ); - - int pSize = avpicture_get_size( imagePixFormat, width, height ); - if( pSize != imagesize) { - Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize); - } - - if(config.cpu_extensions && sseversion >= 20) { - imgConversionContext = sws_getContext(width, height, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL ); - } else { - imgConversionContext = sws_getContext(width, height, capturePixFormat, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL ); - } - - if ( !imgConversionContext ) - Fatal( "Unable to initialise image scaling context" ); - - } -#endif } void LocalCamera::Terminate() @@ -974,11 +987,9 @@ void LocalCamera::Terminate() Debug( 3, "Unmapping video buffers" ); for ( int i = 0; i < v4l2_data.reqbufs.count; i++ ) { #if HAVE_LIBSWSCALE - if(conversion_type == 1) { /* Free capture pictures */ av_free(capturePictures[i]); capturePictures[i] = NULL; - } #endif if ( munmap( v4l2_data.buffers[i].start, v4l2_data.buffers[i].length ) < 0 ) Error( "Failed to munmap buffer %d: %s", i, strerror(errno) ); @@ -993,13 +1004,11 @@ void LocalCamera::Terminate() if ( v4l_version == 1 ) { #if HAVE_LIBSWSCALE - if(conversion_type == 1) { for(unsigned int i=0; i < v4l1_data.frames.frames; i++) { /* Free capture pictures */ av_free(capturePictures[i]); capturePictures[i] = NULL; } - } #endif Debug( 3, "Unmapping video buffers" ); @@ -1012,17 +1021,6 @@ void LocalCamera::Terminate() close( vid_fd ); -#if HAVE_LIBSWSCALE - /* Clean up swscale stuff */ - if(conversion_type == 1) { - sws_freeContext(imgConversionContext); - imgConversionContext = NULL; - - av_free(tmpPicture); - tmpPicture = NULL; - } -#endif - } #define capString(test,prefix,yesString,noString,capability) \ @@ -1821,8 +1819,9 @@ int LocalCamera::PreCapture() int LocalCamera::Capture( Image &image ) { Debug( 3, "Capturing" ); - uint8_t* buffer = NULL; - uint8_t* directbuffer = NULL; + static uint8_t* buffer = NULL; + static uint8_t* directbuffer = NULL; + static int capture_frame = -1; int captures_per_frame = 1; if ( channel_count > 1 ) @@ -1832,7 +1831,6 @@ int LocalCamera::Capture( Image &image ) // Do the capture, unless we are the second or subsequent camera on a channel, in which case just reuse the buffer if ( channel_prime ) { - int capture_frame = -1; #if ZM_HAS_V4L2 if ( v4l_version == 2 ) { @@ -1906,7 +1904,9 @@ int LocalCamera::Capture( Image &image ) buffer = v4l1_data.bufptr+v4l1_data.frames.offsets[capture_frame]; #endif // ZM_HAS_V4L1 - } + } + } /* prime capture */ + if(conversion_type != 0) { Debug( 3, "Performing format conversion" ); @@ -1939,7 +1939,6 @@ int LocalCamera::Capture( Image &image ) image.Assign( width, height, colours, subpixelorder, buffer, imagesize); } - } /* prime capture */ return( 0 ); } @@ -1948,7 +1947,7 @@ int LocalCamera::PostCapture() { Debug( 2, "Post-capturing" ); // Requeue the buffer unless we need to switch or are a duplicate camera on a channel - if ( channel_count == 1 || channel_prime ) + if ( channel_count > 1 || channel_prime ) { #if ZM_HAS_V4L2 if ( v4l_version == 2 ) diff --git a/src/zm_local_camera.h b/src/zm_local_camera.h index 89baaf2f3..6de50b417 100644 --- a/src/zm_local_camera.h +++ b/src/zm_local_camera.h @@ -99,11 +99,11 @@ protected: #endif // ZM_HAS_V4L1 #if HAVE_LIBSWSCALE - PixelFormat imagePixFormat; - PixelFormat capturePixFormat; - static AVFrame **capturePictures; - struct SwsContext *imgConversionContext; - AVFrame *tmpPicture; + static AVFrame **capturePictures; + PixelFormat imagePixFormat; + PixelFormat capturePixFormat; + struct SwsContext *imgConversionContext; + AVFrame *tmpPicture; #endif // HAVE_LIBSWSCALE static LocalCamera *last_camera; diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 86c9c579f..40cb8280f 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -556,9 +556,6 @@ Monitor::~Monitor() if ( munmap( mem_ptr, mem_size ) < 0 ) Fatal( "Can't munmap: %s", strerror(errno) ); close( map_fd ); - /* Remove the memory file to avoid getting unexpected memory size error */ - if( purpose == CAPTURE ) - unlink(mem_file); #else // ZM_MEM_MAPPED struct shmid_ds shm_data; if ( shmctl( shm_id, IPC_STAT, &shm_data ) < 0 ) diff --git a/src/zm_remote_camera_rtsp.cpp b/src/zm_remote_camera_rtsp.cpp index a390f546c..e575e9f36 100644 --- a/src/zm_remote_camera_rtsp.cpp +++ b/src/zm_remote_camera_rtsp.cpp @@ -235,7 +235,7 @@ int RemoteCameraRtsp::Capture( Image &image ) { /* the picture is allocated by the decoder. no need to free it */ Debug( 1, "Got picture %d", frameCount ); - +#if HAVE_LIBSWSCALE static struct SwsContext *img_convert_ctx = 0; if ( !img_convert_ctx ) @@ -246,7 +246,7 @@ int RemoteCameraRtsp::Capture( Image &image ) } sws_scale( img_convert_ctx, picture->data, picture->linesize, 0, height, tmp_picture->data, tmp_picture->linesize ); - +#endif image.Assign( width, height, colours, subpixelorder, tmp_picture->data[0], imagesize); frameCount++; From b0bc22723253491d720d9e03c7e85affd49e2fad Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 10 May 2011 13:50:54 +0300 Subject: [PATCH 08/56] 1) Made shared memory 16 byte aligned and identical size and layout for all platforms. 2) Fixed a bug in zmwatch.pl: Not freeing shared memory handles between iterations. 3) Modified default monitor options to simplify new monitor creation. --- .../ZoneMinder/lib/ZoneMinder/Memory.pm.in | 75 ++++++++++++------- scripts/zmwatch.pl.in | 8 +- src/zm_monitor.cpp | 4 +- src/zm_monitor.h | 66 ++++++++++------ web/skins/classic/views/monitor.php | 40 ++++------ 5 files changed, 115 insertions(+), 78 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in index 537c6af61..a6f7395ff 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in @@ -134,30 +134,35 @@ our $mem_seq = 0; our $mem_data = { "shared_data" => { "type"=>"SharedData", "seq"=>$mem_seq++, "contents"=> { - "size" => { "type"=>"int", "seq"=>$mem_seq++ }, - "valid" => { "type"=>"bool1", "seq"=>$mem_seq++ }, - "active" => { "type"=>"bool1", "seq"=>$mem_seq++ }, - "signal" => { "type"=>"bool1", "seq"=>$mem_seq++ }, - "state" => { "type"=>"enum", "seq"=>$mem_seq++}, - "last_write_index" => { "type"=>"int", "seq"=>$mem_seq++ }, - "last_read_index" => { "type"=>"int", "seq"=>$mem_seq++ }, - "last_write_time" => { "type"=>"time_t", "seq"=>$mem_seq++ }, - "last_read_time" => { "type"=>"time_t", "seq"=>$mem_seq++ }, - "last_event" => { "type"=>"int", "seq"=>$mem_seq++ }, - "action" => { "type"=>"enum", "seq"=>$mem_seq++ }, - "brightness" => { "type"=>"int", "seq"=>$mem_seq++ }, - "hue" => { "type"=>"int", "seq"=>$mem_seq++ }, - "colour" => { "type"=>"int", "seq"=>$mem_seq++ }, - "contrast" => { "type"=>"int", "seq"=>$mem_seq++ }, - "alarm_x" => { "type"=>"int", "seq"=>$mem_seq++ }, - "alarm_y" => { "type"=>"int", "seq"=>$mem_seq++ }, + "size" => { "type"=>"uint32", "seq"=>$mem_seq++ }, + "last_write_index" => { "type"=>"uint32", "seq"=>$mem_seq++ }, + "last_read_index" => { "type"=>"uint32", "seq"=>$mem_seq++ }, + "state" => { "type"=>"uint32", "seq"=>$mem_seq++ }, + "last_event" => { "type"=>"uint32", "seq"=>$mem_seq++ }, + "action" => { "type"=>"uint32", "seq"=>$mem_seq++ }, + "brightness" => { "type"=>"int32", "seq"=>$mem_seq++ }, + "hue" => { "type"=>"int32", "seq"=>$mem_seq++ }, + "colour" => { "type"=>"int32", "seq"=>$mem_seq++ }, + "contrast" => { "type"=>"int32", "seq"=>$mem_seq++ }, + "alarm_x" => { "type"=>"int32", "seq"=>$mem_seq++ }, + "alarm_y" => { "type"=>"int32", "seq"=>$mem_seq++ }, + "valid" => { "type"=>"uchar", "seq"=>$mem_seq++ }, + "active" => { "type"=>"uchar", "seq"=>$mem_seq++ }, + "signal" => { "type"=>"uchar", "seq"=>$mem_seq++ }, + "bpadding" => { "type"=>"uchar", "seq"=>$mem_seq++ }, + "epadding1" => { "type"=>"uint32", "seq"=>$mem_seq++ }, + "epadding2" => { "type"=>"uint32", "seq"=>$mem_seq++ }, + "epadding3" => { "type"=>"uint32", "seq"=>$mem_seq++ }, + "last_write_time" => { "type"=>"time_t64", "seq"=>$mem_seq++ }, + "last_read_time" => { "type"=>"time_t64", "seq"=>$mem_seq++ }, "control_state" => { "type"=>"uchar[256]", "seq"=>$mem_seq++ }, } }, "trigger_data" => { "type"=>"TriggerData", "seq"=>$mem_seq++, "contents"=> { - "size" => { "type"=>"int", "seq"=>$mem_seq++ }, - "trigger_state" => { "type"=>"enum", "seq"=>$mem_seq++ }, - "trigger_score" => { "type"=>"int", "seq"=>$mem_seq++ }, + "size" => { "type"=>"uint32", "seq"=>$mem_seq++ }, + "trigger_state" => { "type"=>"uint32", "seq"=>$mem_seq++ }, + "trigger_score" => { "type"=>"uint32", "seq"=>$mem_seq++ }, + "padding" => { "type"=>"uint32", "seq"=>$mem_seq++ }, "trigger_cause" => { "type"=>"char[32]", "seq"=>$mem_seq++ }, "trigger_text" => { "type"=>"char[256]", "seq"=>$mem_seq++ }, "trigger_showtext" => { "type"=>"char[256]", "seq"=>$mem_seq++ }, @@ -176,7 +181,7 @@ sub zmMemInit foreach my $section_data ( sort { $a->{seq} <=> $b->{seq} } values( %$mem_data ) ) { $section_data->{offset} = $offset; - $section_data->{align} = 4; + $section_data->{align} = 0; if ( $section_data->{align} > 1 ) { @@ -188,11 +193,15 @@ sub zmMemInit } foreach my $member_data ( sort { $a->{seq} <=> $b->{seq} } values( %{$section_data->{contents}} ) ) { - if ( $member_data->{type} eq "long" || $member_data->{type} eq "time_t" || $member_data->{type} eq "size_t" || $member_data->{type} eq "bool8" ) + if ( $member_data->{type} eq "long" || $member_data->{type} eq "ulong" || $member_data->{type} eq "size_t") { $member_data->{size} = $member_data->{align} = $native; } - elsif ( $member_data->{type} eq "int" || $member_data->{type} eq "enum" || $member_data->{type} eq "bool4" ) + elsif( $member_data->{type} eq "int64" || $member_data->{type} eq "uint64" || $member_data->{type} eq "time_t64") + { + $member_data->{size} = $member_data->{align} = 8; + } + elsif ( $member_data->{type} eq "int32" || $member_data->{type} eq "uint32" || $member_data->{type} eq "bool4" ) { $member_data->{size} = $member_data->{align} = 4; } @@ -200,7 +209,7 @@ sub zmMemInit { $member_data->{size} = $member_data->{align} = 2; } - elsif ( $member_data->{type} =~ "/^u?char$/" || $member_data->{type} eq "bool1" ) + elsif ( $member_data->{type} eq "char" || $member_data->{type} eq "uchar" || $member_data->{type} eq "bool1" ) { $member_data->{size} = $member_data->{align} = 1; } @@ -304,11 +313,16 @@ sub zmMemRead( $$;$ ) return( undef ); } my $value; - if ( $type eq "long" || $type eq "time_t" || $type eq "size_t" || $type eq "bool8" ) + if ( $type eq "long" || $type eq "ulong" || $type eq "size_t") { ( $value ) = unpack( "l!", $data ); } - elsif ( $type eq "int" || $type eq "enum" || $type eq "bool4" ) + elsif ( $type eq "int64" || $type eq "uint64" || $type eq "time_t64" ) + { + # The "q" type is only available on 64bit platforms. + ( $value ) = unpack( "l!", $data ); + } + elsif ( $type eq "int32" || $type eq "uint32" || $type eq "bool4" ) { ( $value ) = unpack( "l", $data ); } @@ -382,11 +396,16 @@ sub zmMemWrite( $$;$ ) my $size = $mem_data->{$section}->{contents}->{$element}->{size}; my $data; - if ( $type eq "long" || $type eq "time_t" || $type eq "size_t" || $type eq "bool8" ) + if ( $type eq "long" || $type eq "ulong" || $type eq "size_t") { $data = pack( "l!", $value ); } - elsif ( $type eq "int" || $type eq "enum" || $type eq "bool4" ) + elsif ( $type eq "int64" || $type eq "uint64" || $type eq "time_t64" ) + { + # The "q" type is only available on 64bit platforms. + $data = pack( "l!", $value ); + } + elsif ( $type eq "int32" || $type eq "uint32" || $type eq "bool4" ) { $data = pack( "l", $value ); } diff --git a/scripts/zmwatch.pl.in b/scripts/zmwatch.pl.in index 4d50f0496..8df23d226 100644 --- a/scripts/zmwatch.pl.in +++ b/scripts/zmwatch.pl.in @@ -87,6 +87,7 @@ while( 1 ) { # Check we have got an image recently my $image_time = zmGetLastWriteTime( $monitor ); + zmMemInvalidate( $monitor ); next if ( !defined($image_time) ); # Can't read from shared data next if ( !$image_time ); # We can't get the last capture time so can't be sure it's died. @@ -95,9 +96,9 @@ while( 1 ) Debug( "Monitor $monitor->{Id} last captured $image_delay seconds ago, max is $max_image_delay\n" ); if ( $image_delay > $max_image_delay ) { - Info( "Restarting capture daemon for ".$monitor->{Name}.", time since last capture $image_delay seconds ($now-$image_time)\n" ); - $restart = 1; - } + Info( "Restarting capture daemon for ".$monitor->{Name}.", time since last capture $image_delay seconds ($now-$image_time)\n" ); + $restart = 1; + } } else { @@ -124,6 +125,7 @@ while( 1 ) { # Check we have got an image recently my $image_time = zmGetLastReadTime( $monitor ); + zmMemInvalidate( $monitor ); next if ( !defined($image_time) ); # Can't read from shared data next if ( !$image_time ); # We can't get the last capture time so can't be sure it's died. diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 40cb8280f..625650ed8 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -394,8 +394,10 @@ Monitor::Monitor( struct timeval *shared_timestamps = (struct timeval *)((char *)trigger_data + sizeof(TriggerData)); unsigned char *shared_images = (unsigned char *)((char *)shared_timestamps + (image_buffer_count*sizeof(struct timeval))); + /* This shouldn't be needed if the shared memory start address is multiple of 16, but just in case */ if(((unsigned long)shared_images % 16) != 0) { /* Align images buffer to nearest 16 byte boundary */ + Debug(3,"Aligning shared memory images to the next 16 byte boundary"); shared_images = (uint8_t*)((unsigned long)shared_images + (16 - ((unsigned long)shared_images % 16))); } @@ -585,7 +587,7 @@ void Monitor::AddZones( int p_n_zones, Zone *p_zones[] ) Monitor::State Monitor::GetState() const { - return( shared_data->state ); + return( (State)shared_data->state ); } int Monitor::GetImage( int index, int scale ) const diff --git a/src/zm_monitor.h b/src/zm_monitor.h index a08b218c9..7b65265f2 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -29,6 +29,7 @@ #include "zm_camera.h" #include +#include #define SIGNAL_CAUSE "Signal" #define MOTION_CAUSE "Motion" @@ -86,43 +87,64 @@ protected: typedef enum { CLOSE_TIME, CLOSE_IDLE, CLOSE_ALARM } EventCloseMode; + /* sizeof(SharedData) expected to be 336 bytes on 32bit and 64bit */ typedef struct { - int size; - bool valid; - bool active; - bool signal; - State state; - int last_write_index; - int last_read_index; - time_t last_write_time; - time_t last_read_time; - int last_event; - unsigned int action; - int brightness; - int hue; - int colour; - int contrast; - int alarm_x; - int alarm_y; - char control_state[256]; + uint32_t size; /* +0 */ + uint32_t last_write_index; /* +4 */ + uint32_t last_read_index; /* +8 */ + uint32_t state; /* +12 */ + uint32_t last_event; /* +16 */ + uint32_t action; /* +20 */ + int32_t brightness; /* +24 */ + int32_t hue; /* +28 */ + int32_t colour; /* +32 */ + int32_t contrast; /* +36 */ + int32_t alarm_x; /* +40 */ + int32_t alarm_y; /* +44 */ + uint8_t valid; /* +48 */ + uint8_t active; /* +49 */ + uint8_t signal; /* +50 */ + uint8_t bpadding; /* +51 */ + uint32_t epadding1; /* +52 */ + uint32_t epadding2; /* +56 */ + uint32_t epadding3; /* +60 */ + /* + ** This keeps 32bit time_t and 64bit time_t identical and compatible as long as time is before 2038. + ** Shared memory layout should be identical for both 32bit and 64bit and is multiples of 16. + */ + union { /* +64 */ + time_t last_write_time; + uint64_t extrapad1; + }; + union { /* +72 */ + time_t last_read_time; + uint64_t extrapad2; + }; + uint8_t control_state[256]; /* +80 */ + } SharedData; typedef enum { TRIGGER_CANCEL, TRIGGER_ON, TRIGGER_OFF } TriggerState; + + /* sizeof(TriggerData) expected to be 560 on 32bit & and 64bit */ typedef struct { - int size; - TriggerState trigger_state; - int trigger_score; + uint32_t size; + uint32_t trigger_state; + uint32_t trigger_score; + uint32_t padding; char trigger_cause[32]; char trigger_text[256]; char trigger_showtext[256]; } TriggerData; + /* sizeof(Snapshot) expected to be 16 bytes on 32bit and 32 bytes on 64bit */ struct Snapshot { struct timeval *timestamp; Image *image; + void* padding; }; class MonitorLink @@ -317,7 +339,7 @@ public: void ForceAlarmOn( int force_score, const char *force_case, const char *force_text="" ); void ForceAlarmOff(); void CancelForced(); - TriggerState GetTriggerState() const { return( trigger_data?trigger_data->trigger_state:TRIGGER_CANCEL ); } + TriggerState GetTriggerState() const { return( (TriggerState)(trigger_data?trigger_data->trigger_state:TRIGGER_CANCEL )); } void actionReload(); void actionEnable(); diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index f253377d4..75f318cb9 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -56,26 +56,26 @@ else 'Enabled' => true, 'LinkedMonitors' => "", 'Type' => "", - 'Device' => "/dev/video", + 'Device' => "/dev/video0", 'Channel' => "0", - 'Format' => "", + 'Format' => 0x000000ff, 'Protocol' => "", 'Method' => "", 'Host' => "", 'Path' => "", 'Port' => "80", - 'Colours' => "", - 'Palette' => "", - 'Width' => "", - 'Height' => "", + 'Colours' => 4, + 'Palette' => fourcc('B','G','R','4'), + 'Width' => "320", + 'Height' => "240", 'Orientation' => "0", - 'LabelFormat' => '%N - %y/%m/%d %H:%M:%S', + 'LabelFormat' => '%N - %d/%m/%y %H:%M:%S', 'LabelX' => 0, 'LabelY' => 0, - 'ImageBufferCount' => 40, + 'ImageBufferCount' => 60, 'WarmupCount' => 25, - 'PreEventCount' => 10, - 'PostEventCount' => 10, + 'PreEventCount' => 25, + 'PostEventCount' => 25, 'StreamReplayBuffer' => 1000, 'AlarmFrameCount' => 1, 'Controllable' => 0, @@ -91,14 +91,14 @@ else 'SectionLength' => 600, 'FrameSkip' => 0, 'EventPrefix' => 'Event-', - 'MaxFPS' => "", - 'AlarmMaxFPS' => "", + 'MaxFPS' => "5", + 'AlarmMaxFPS' => "5", 'FPSReportInterval' => 1000, 'RefBlendPerc' => 7, 'DefaultView' => 'Events', 'DefaultRate' => '100', 'DefaultScale' => '100', - 'SignalCheckColour' => '#0100BE', + 'SignalCheckColour' => '#0000C0', 'WebColour' => 'red', 'Triggers' => "", ); @@ -328,8 +328,8 @@ if ( ZM_HAS_V4L2 ) //"SBGGR16" => fourcc('B','Y','R','2'), /* 16 BGBG.. GRGR.. */ /* compressed formats */ - //"MJPEG" => fourcc('M','J','P','G'), /* Motion-JPEG */ - "JPEG" => fourcc('J','P','E','G'), /* JFIF JPEG */ + "*JPEG" => fourcc('J','P','E','G'), /* JFIF JPEG */ + "*MJPEG" => fourcc('M','J','P','G'), /* Motion-JPEG */ //"DV" => fourcc('d','v','s','d'), /* 1394 */ //"MPEG" => fourcc('M','P','E','G'), /* MPEG-1/2/4 */ @@ -608,14 +608,6 @@ switch ( $tab ) } case 'source' : { - // Set up initial palette value - if ( $newMonitor['Palette'] == '' ) - { - if ( ZM_HAS_V4L && $newMonitor['Type'] == 'Local' ) - $newMonitor['Palette'] = 4; - else - $newMonitor['Palette'] = 3; - } if ( ZM_HAS_V4L && $newMonitor['Type'] == "Local" ) { ?> @@ -630,7 +622,7 @@ switch ( $tab ) From 642a1bfdb2521997b0443ef9095ae3879d9646f9 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sun, 22 May 2011 12:25:33 +0300 Subject: [PATCH 09/56] 1) RTSP support for direct capture and target colorspace. 2) Hopefully fixed the mmap unexpected shared memory size completely this time. 3) Added 32bit RGB and grayscale support to the signal checking. 4) Fixed zms\nph-zms keeps running after changing capture options, eating CPU and has to be killed with -9. 5) Default monitor options changed again. 6) Fixed unrelated bug: Undefined constant ZM_V4L2 in monitor probe. 7) Fixed unrelated bug: Error in offset X in monitor probe. 8) Changed monitor probe's prefered capture settings. 9) Small other minor changes. --- src/zm_ffmpeg_camera.cpp | 4 +- src/zm_ffmpeg_camera.h | 2 + src/zm_monitor.cpp | 69 ++++---- src/zm_remote_camera_rtsp.cpp | 198 ++++++++++++++--------- src/zm_remote_camera_rtsp.h | 18 ++- src/zm_zone.cpp | 4 +- web/skins/classic/views/monitor.php | 12 +- web/skins/classic/views/monitorprobe.php | 22 ++- 8 files changed, 200 insertions(+), 129 deletions(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index d2f19dd95..a217c32f6 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -38,6 +38,7 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, int p_width, in mCodec = NULL; mRawFrame = NULL; mFrame = NULL; + frameCount = 0; #if HAVE_LIBSWSCALE mConvertContext = NULL; @@ -183,8 +184,7 @@ int FfmpegCamera::PreCapture() int FfmpegCamera::Capture( Image &image ) { - static int frameCount = 0; - AVPacket packet; + AVPacket packet; uint8_t* directbuffer; /* Request a writeable buffer of the target image */ diff --git a/src/zm_ffmpeg_camera.h b/src/zm_ffmpeg_camera.h index d5fb3b817..3b256d5d6 100644 --- a/src/zm_ffmpeg_camera.h +++ b/src/zm_ffmpeg_camera.h @@ -35,6 +35,8 @@ class FfmpegCamera : public Camera protected: std::string mPath; + int frameCount; + #if HAVE_LIBAVFORMAT AVFormatContext *mFormatContext; int mVideoStreamId; diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 625650ed8..ce70d7fa3 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -354,7 +354,7 @@ Monitor::Monitor( struct stat map_stat; if ( fstat( map_fd, &map_stat ) < 0 ) Fatal( "Can't stat memory map file %s: %s", mem_file, strerror(errno) ); - if ( map_stat.st_size == 0 ) + if ( map_stat.st_size != mem_size && purpose == CAPTURE ) { // Allocate the size if ( ftruncate( map_fd, mem_size ) < 0 ) @@ -1007,23 +1007,25 @@ bool Monitor::CheckSignal( const Image *image ) { static bool static_undef = true; /* RGB24 colors */ - static unsigned char red_val; - static unsigned char green_val; - static unsigned char blue_val; - - static Rgb color_val; /* RGB32 color */ - static uint8_t grayscale_val; /* 8bit grayscale color */ + static uint8_t red_val; + static uint8_t green_val; + static uint8_t blue_val; + static uint8_t grayscale_val; /* 8bit grayscale color */ + static Rgb colour_val; /* RGB32 color */ + static int usedsubpixorder; if ( config.signal_check_points > 0 ) { if ( static_undef ) { static_undef = false; - red_val = RED_VAL_RGBA(signal_check_colour); - green_val = GREEN_VAL_RGBA(signal_check_colour); - blue_val = BLUE_VAL_RGBA(signal_check_colour); - color_val = RGBA_BGRA_ZEROALPHA(signal_check_colour); /* Clear alpha byte */ - grayscale_val = 0xff & signal_check_colour; /* Clear all bytes but lowest byte */ + usedsubpixorder = camera->SubpixelOrder(); + colour_val = rgb_convert(signal_check_colour, ZM_SUBPIX_ORDER_BGR); /* HTML colour code is actually BGR in memory, we want RGB */ + colour_val = rgb_convert(colour_val, usedsubpixorder); + red_val = RED_VAL_BGRA(signal_check_colour); + green_val = GREEN_VAL_BGRA(signal_check_colour); + blue_val = BLUE_VAL_BGRA(signal_check_colour); + grayscale_val = signal_check_colour & 0xff; /* Clear all bytes but lowest byte */ } const uint8_t *buffer = image->Buffer(); @@ -1044,20 +1046,33 @@ bool Monitor::CheckSignal( const Image *image ) break; } - if(colours == 1) { - if ( *(buffer+index) != grayscale_val ) - return true; - - } else if(colours == 3) { - const uint8_t *ptr = buffer+(index*colours); - if ( (RED_PTR_RGBA(ptr) != red_val) || (GREEN_PTR_RGBA(ptr) != green_val) || (BLUE_PTR_RGBA(ptr) != blue_val) ) - return true; - - } else if(colours == 4) { - if ( RGBA_BGRA_ZEROALPHA(*(((const Rgb*)buffer)+index)) != color_val ) - return true; - } - + if(colours == ZM_COLOUR_GRAY8) { + if ( *(buffer+index) != grayscale_val ) + return true; + + } else if(colours == ZM_COLOUR_RGB24) { + const uint8_t *ptr = buffer+(index*colours); + + if ( usedsubpixorder == ZM_SUBPIX_ORDER_BGR) { + if ( (RED_PTR_BGRA(ptr) != red_val) || (GREEN_PTR_BGRA(ptr) != green_val) || (BLUE_PTR_BGRA(ptr) != blue_val) ) + return true; + } else { + /* Assume RGB */ + if ( (RED_PTR_RGBA(ptr) != red_val) || (GREEN_PTR_RGBA(ptr) != green_val) || (BLUE_PTR_RGBA(ptr) != blue_val) ) + return true; + } + + } else if(colours == ZM_COLOUR_RGB32) { + if ( usedsubpixorder == ZM_SUBPIX_ORDER_ARGB || usedsubpixorder == ZM_SUBPIX_ORDER_ABGR) { + if ( ARGB_ABGR_ZEROALPHA(*(((const Rgb*)buffer)+index)) != ARGB_ABGR_ZEROALPHA(colour_val) ) + return true; + } else { + /* Assume RGBA or BGRA */ + if ( RGBA_BGRA_ZEROALPHA(*(((const Rgb*)buffer)+index)) != RGBA_BGRA_ZEROALPHA(colour_val) ) + return true; + } + } + } return( false ); } @@ -3498,7 +3513,7 @@ void MonitorStream::runStream() while ( !zm_terminate ) { bool got_command = false; - if ( feof( stdout ) || ferror( stdout ) ) + if ( feof( stdout ) || ferror( stdout ) || !monitor->ShmValid() ) { break; } diff --git a/src/zm_remote_camera_rtsp.cpp b/src/zm_remote_camera_rtsp.cpp index e575e9f36..3b873e84e 100644 --- a/src/zm_remote_camera_rtsp.cpp +++ b/src/zm_remote_camera_rtsp.cpp @@ -47,10 +47,53 @@ RemoteCameraRtsp::RemoteCameraRtsp( int p_id, const std::string &p_method, const { Initialise(); } + + mFormatContext = NULL; + mVideoStreamId = -1; + mCodecContext = NULL; + mCodec = NULL; + mRawFrame = NULL; + mFrame = NULL; + frameCount = 0; + +#if HAVE_LIBSWSCALE + mConvertContext = NULL; +#endif + /* Has to be located inside the constructor so other components such as zma will receive correct colours and subpixel order */ + if(colours == ZM_COLOUR_RGB32) { + subpixelorder = ZM_SUBPIX_ORDER_RGBA; + imagePixFormat = PIX_FMT_RGBA; + } else if(colours == ZM_COLOUR_RGB24) { + subpixelorder = ZM_SUBPIX_ORDER_RGB; + imagePixFormat = PIX_FMT_RGB24; + } else if(colours == ZM_COLOUR_GRAY8) { + subpixelorder = ZM_SUBPIX_ORDER_NONE; + imagePixFormat = PIX_FMT_GRAY8; + } else { + Panic("Unexpected colours: %d",colours); + } + } RemoteCameraRtsp::~RemoteCameraRtsp() { + av_freep( &mFrame ); + av_freep( &mRawFrame ); + +#if HAVE_LIBSWSCALE + if ( mConvertContext ) + { + sws_freeContext( mConvertContext ); + mConvertContext = NULL; + } +#endif + + if ( mCodecContext ) + { + avcodec_close( mCodecContext ); + mCodecContext = NULL; // Freed by av_close_input_file + } + if ( capture ) { Terminate(); @@ -72,17 +115,11 @@ void RemoteCameraRtsp::Initialise() av_register_all(); - frameCount = 0; - Connect(); } void RemoteCameraRtsp::Terminate() { - avcodec_close( codecContext ); - av_free( codecContext ); - av_free( picture ); - Disconnect(); } @@ -119,36 +156,67 @@ int RemoteCameraRtsp::PrimeCapture() Debug( 2, "Got sources" ); - formatContext = rtspThread->getFormatContext(); + mFormatContext = rtspThread->getFormatContext(); - // Find the first video stream - int videoStream=-1; - for ( int i = 0; i < formatContext->nb_streams; i++ ) + // Find first video stream present + mVideoStreamId = -1; + + for ( int i = 0; i < mFormatContext->nb_streams; i++ ) #if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1) - if ( formatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO ) + if ( mFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO ) #else - if ( formatContext->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO ) + if ( mFormatContext->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO ) #endif { - videoStream = i; + mVideoStreamId = i; break; } - if ( videoStream == -1 ) + if ( mVideoStreamId == -1 ) Fatal( "Unable to locate video stream" ); // Get a pointer to the codec context for the video stream - codecContext = formatContext->streams[videoStream]->codec; + mCodecContext = mFormatContext->streams[mVideoStreamId]->codec; // Find the decoder for the video stream - codec = avcodec_find_decoder( codecContext->codec_id ); - if ( codec == NULL ) - Panic( "Unable to locate codec %d decoder", codecContext->codec_id ); + mCodec = avcodec_find_decoder( mCodecContext->codec_id ); + if ( mCodec == NULL ) + Panic( "Unable to locate codec %d decoder", mCodecContext->codec_id ); // Open codec - if ( avcodec_open( codecContext, codec ) < 0 ) + if ( avcodec_open( mCodecContext, mCodec ) < 0 ) Panic( "Can't open codec" ); - picture = avcodec_alloc_frame(); + // Allocate space for the native video frame + mRawFrame = avcodec_alloc_frame(); + + // Allocate space for the converted video frame + mFrame = avcodec_alloc_frame(); + + if(mRawFrame == NULL || mFrame == NULL) + Fatal( "Unable to allocate frame(s)"); + + int pSize = avpicture_get_size( imagePixFormat, width, height ); + if( pSize != imagesize) { + Fatal("Image size mismatch. Required: %d Available: %d",pSize,imagesize); + } + +#if HAVE_LIBSWSCALE + if(!sws_isSupportedOutput(imagePixFormat)) { + Fatal("swscale does not support the target format"); + } + + if(config.cpu_extensions && sseversion >= 20) { + mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL ); + } else { + mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL ); + } + + if(mConvertContext == NULL) + Fatal( "Unable to create conversion context"); +#else // HAVE_LIBSWSCALE + Fatal( "You must compile ffmpeg with the --enable-swscale option to use RTSP cameras" ); +#endif // HAVE_LIBSWSCALE + return( 0 ); } @@ -167,101 +235,71 @@ int RemoteCameraRtsp::PreCapture() int RemoteCameraRtsp::Capture( Image &image ) { + AVPacket packet; + uint8_t* directbuffer; + + /* Request a writeable buffer of the target image */ + directbuffer = image.WriteBuffer(width, height, colours, subpixelorder); + if(directbuffer == NULL) { + Error("Failed requesting writeable buffer for the captured image."); + return (-1); + } + while ( true ) { buffer.clear(); if ( !rtspThread->isRunning() ) - break; - //if ( rtspThread->stopped() ) - //break; + return (-1); + if ( rtspThread->getFrame( buffer ) ) { Debug( 3, "Read frame %d bytes", buffer.size() ); Debug( 4, "Address %p", buffer.head() ); Hexdump( 4, buffer.head(), 16 ); - static AVFrame *tmp_picture = NULL; - - if ( !tmp_picture ) - { - //if ( c->pix_fmt != pf ) - //{ - tmp_picture = avcodec_alloc_frame(); - if ( !tmp_picture ) - { - Panic( "Could not allocate temporary opicture" ); - } - int size = avpicture_get_size( PIX_FMT_RGB24, width, height); - uint8_t *tmp_picture_buf = (uint8_t *)malloc(size); - if (!tmp_picture_buf) - { - av_free( tmp_picture ); - Panic( "Could not allocate temporary opicture" ); - } - avpicture_fill( (AVPicture *)tmp_picture, tmp_picture_buf, PIX_FMT_RGB24, width, height ); - //} - } - if ( !buffer.size() ) return( -1 ); - AVPacket packet; av_init_packet( &packet ); - int initialFrameCount = frameCount; - while ( buffer.size() > 0 ) + int frameComplete = false; + + while ( !frameComplete ) { - int got_picture = false; packet.data = buffer.head(); packet.size = buffer.size(); - int len = avcodec_decode_video2( codecContext, picture, &got_picture, &packet ); + int len = avcodec_decode_video2( mCodecContext, mRawFrame, &frameComplete, &packet ); if ( len < 0 ) { - if ( frameCount > initialFrameCount ) - { - // Decoded at least one frame - return( 0 ); - } Error( "Error while decoding frame %d", frameCount ); Hexdump( Logger::ERROR, buffer.head(), buffer.size()>256?256:buffer.size() ); buffer.clear(); continue; - //return( -1 ); } Debug( 2, "Frame: %d - %d/%d", frameCount, len, buffer.size() ); //if ( buffer.size() < 400 ) //Hexdump( 0, buffer.head(), buffer.size() ); - if ( got_picture ) + if ( frameComplete ) { - /* the picture is allocated by the decoder. no need to free it */ - Debug( 1, "Got picture %d", frameCount ); + Debug( 3, "Got frame %d", frameCount ); + + avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height); + #if HAVE_LIBSWSCALE - static struct SwsContext *img_convert_ctx = 0; - - if ( !img_convert_ctx ) - { - img_convert_ctx = sws_getCachedContext( NULL, codecContext->width, codecContext->height, codecContext->pix_fmt, width, height, PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL ); - if ( !img_convert_ctx ) - Panic( "Unable to initialise image scaling context" ); - } - - sws_scale( img_convert_ctx, picture->data, picture->linesize, 0, height, tmp_picture->data, tmp_picture->linesize ); -#endif - image.Assign( width, height, colours, subpixelorder, tmp_picture->data[0], imagesize); - - frameCount++; - - return( 0 ); - } - else - { - Warning( "Unable to get picture from frame" ); + if ( sws_scale( mConvertContext, mRawFrame->data, mRawFrame->linesize, 0, mCodecContext->height, mFrame->data, mFrame->linesize ) < 0 ) + Fatal( "Unable to convert raw format %u to target format %u at frame %d", mCodecContext->pix_fmt, imagePixFormat, frameCount ); +#else // HAVE_LIBSWSCALE + Fatal( "You must compile ffmpeg with the --enable-swscale option to use RTSP cameras" ); +#endif // HAVE_LIBSWSCALE + + frameCount++; } buffer -= len; } + av_free_packet( &packet ); } } - return( -1 ); + return (0) ; } int RemoteCameraRtsp::PostCapture() diff --git a/src/zm_remote_camera_rtsp.h b/src/zm_remote_camera_rtsp.h index 1e966ca46..3295c9363 100644 --- a/src/zm_remote_camera_rtsp.h +++ b/src/zm_remote_camera_rtsp.h @@ -46,11 +46,21 @@ protected: RtspThread *rtspThread; - AVFormatContext *formatContext; - AVCodec *codec; - AVCodecContext *codecContext; - AVFrame *picture; int frameCount; + +#if HAVE_LIBAVFORMAT + AVFormatContext *mFormatContext; + int mVideoStreamId; + AVCodecContext *mCodecContext; + AVCodec *mCodec; + AVFrame *mRawFrame; + AVFrame *mFrame; + PixelFormat imagePixFormat; +#endif // HAVE_LIBAVFORMAT + +#if HAVE_LIBSWSCALE + struct SwsContext *mConvertContext; +#endif public: RemoteCameraRtsp( int p_id, const std::string &method, const std::string &host, const std::string &port, const std::string &path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ); diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index 125a23b8a..a2e799720 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -664,11 +664,11 @@ bool Zone::CheckAlarms( const Image *delta_image ) if ( type == INCLUSIVE ) { - score <<= 1; + score /= 2; } else if ( type == EXCLUSIVE ) { - score >>= 1; + score *= 2; } Debug( 5, "Adjusted score is %d", score ); diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 75f318cb9..e38a1b9a6 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -72,7 +72,7 @@ else 'LabelFormat' => '%N - %d/%m/%y %H:%M:%S', 'LabelX' => 0, 'LabelY' => 0, - 'ImageBufferCount' => 60, + 'ImageBufferCount' => 50, 'WarmupCount' => 25, 'PreEventCount' => 25, 'PostEventCount' => 25, @@ -91,14 +91,14 @@ else 'SectionLength' => 600, 'FrameSkip' => 0, 'EventPrefix' => 'Event-', - 'MaxFPS' => "5", - 'AlarmMaxFPS' => "5", + 'MaxFPS' => "", + 'AlarmMaxFPS' => "", 'FPSReportInterval' => 1000, 'RefBlendPerc' => 7, 'DefaultView' => 'Events', 'DefaultRate' => '100', 'DefaultScale' => '100', - 'SignalCheckColour' => '#0000C0', + 'SignalCheckColour' => '#0000c0', 'WebColour' => 'red', 'Triggers' => "", ); @@ -139,7 +139,7 @@ if ( $newMonitor['AlarmMaxFPS'] == '0.00' ) if ( !empty($_REQUEST['preset']) ) { - $preset = dbFetchOne( "select Type, Device, Channel, Format, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, MaxFPS, Controllable, ControlId, ControlDevice, ControlAddress, DefaultRate, DefaultScale from MonitorPresets where Id = '".dbEscape($_REQUEST['preset'])."'" ); + $preset = dbFetchOne( "select Type, Device, Channel, Format, Protocol, Method, Host, Port, Path, Width, Height, Palette, MaxFPS, Controllable, ControlId, ControlDevice, ControlAddress, DefaultRate, DefaultScale from MonitorPresets where Id = '".dbEscape($_REQUEST['preset'])."'" ); foreach ( $preset as $name=>$value ) { if ( isset($value) ) @@ -150,7 +150,7 @@ if ( !empty($_REQUEST['preset']) ) } if ( !empty($_REQUEST['probe']) ) { - $probe = unserialize( $_REQUEST['probe'] ); + $probe = unserialize(base64_decode($_REQUEST['probe'])); foreach ( $probe as $name=>$value ) { if ( isset($value) ) diff --git a/web/skins/classic/views/monitorprobe.php b/web/skins/classic/views/monitorprobe.php index bb94b5f2f..45a2d490e 100644 --- a/web/skins/classic/views/monitorprobe.php +++ b/web/skins/classic/views/monitorprobe.php @@ -27,7 +27,7 @@ if ( !canEdit( 'Monitors' ) ) $cameras = array(); $cameras[0] = $SLANG['ChooseDetectedCamera']; -if ( ZM_V4L2 ) +if ( ZM_HAS_V4L2 ) { // Probe Local Cameras // @@ -45,7 +45,7 @@ if ( ZM_V4L2 ) $devices = array(); $preferredStandards = array( 'PAL', 'NTSC' ); - $preferredFormats = array( '422P', 'YUYV', 'BGR3' ); + $preferredFormats = array( 'BGR4', 'RGB4', 'BGR3', 'RGB3', 'YUYV', '422P', 'GREY'); foreach ( $output as $line ) { if ( !preg_match( '/^d:([^|]+).*S:([^|]*).*F:([^|]+).*I:(\d+)\|(.+)$/', $line, $deviceMatches ) ) @@ -83,6 +83,7 @@ if ( ZM_V4L2 ) 'Type' => 'Local', 'Device' => $deviceMatches[1], 'Channel' => $i, + 'Colours' => 4, 'Format' => $preferredStandard, 'Palette' => $preferredFormat, ); @@ -93,10 +94,15 @@ if ( ZM_V4L2 ) } else { - $inputMonitor['Width'] = 352; + $inputMonitor['Width'] = 384; $inputMonitor['Height'] = 288; } - $inputDesc = htmlspecialchars(serialize($inputMonitor)); + if ( $preferredFormat == 'GREY' ) + { + $inputMonitor['Colours'] = 1; + $inputMonitor['SignalCheckColour'] = '#000023'; + } + $inputDesc = base64_encode(serialize($inputMonitor)); $inputString = $deviceMatches[1].', chan '.$i.($input['free']?(" - ".$SLANG['Available']):(" (".$monitors[$input['id']]['Name'].")")); $inputs[] = $input; $cameras[$inputDesc] = $inputString; @@ -120,7 +126,7 @@ function probeAxis( $ip ) 'Host' => $ip, 'Port' => 80, 'Path' => '/axis-cgi/mjpg/video.cgi?resolution=320x240', - 'Palette' => 3, + 'Colours' => 4, 'Width' => 320, 'Height' => 240, ), @@ -154,7 +160,7 @@ function probePana( $ip ) 'Host' => $ip, 'Port' => 80, 'Path' => '/nphMotionJpeg?Resolution=320x240&Quality=Standard', - 'Palette' => 3, + 'Colours' => 4, 'Width' => 320, 'Height' => 240, ), @@ -174,7 +180,7 @@ function probeActi( $ip ) 'Host' => 'Admin:123456@'.$ip, 'Port' => 7070, 'Path' => '', - 'Palette' => 3, + 'Colours' => 4, 'Width' => 320, 'Height' => 240, ), @@ -209,7 +215,7 @@ function probeVivotek( $ip ) 'Host' => $ip, 'Port' => 554, 'Path' => '', - 'Palette' => 3, + 'Colours' => 4, 'Width' => 352, 'Height' => 240, ), From 1afe0bbf42811246c1deb29fbb76a83cd6732daf Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Mon, 23 May 2011 15:52:33 +0300 Subject: [PATCH 10/56] 1) Added back the colour SSE2 delta algorithms 2) Modified SSE algorithms to use one less register 3) Fixed AlarmedPixels motion detection --- src/zm_image.cpp | 336 +++++++++++++++++++++++++++++++++++++++++++-- src/zm_image.h | 4 + src/zm_monitor.cpp | 1 + src/zm_zone.cpp | 29 +--- 4 files changed, 331 insertions(+), 39 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index af5c0133e..16c528eee 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -181,12 +181,20 @@ void Image::Initialise() Debug(2,"Delta: Using SSSE3 delta functions"); } else if(sseversion >= 20) { /* SSE2 available */ - fptr_delta8_rgba = &std_delta8_rgba; - fptr_delta8_bgra = &std_delta8_bgra; - fptr_delta8_argb = &std_delta8_argb; - fptr_delta8_abgr = &std_delta8_abgr; + fptr_delta8_rgba = &sse2_delta8_rgba; + fptr_delta8_bgra = &sse2_delta8_bgra; + fptr_delta8_argb = &sse2_delta8_argb; + fptr_delta8_abgr = &sse2_delta8_abgr; + /* On some systems, the 4 SSE2 algorithms above might be slower than + ** the standard algorithms, especially on early Pentium 4 processors + ** In that case, comment out the 4 lines above and uncomment the 4 lines below + */ + // fptr_delta8_rgba = &std_delta8_rgba; + // fptr_delta8_bgra = &std_delta8_bgra; + // fptr_delta8_argb = &std_delta8_argb; + // fptr_delta8_abgr = &std_delta8_abgr; fptr_delta8_gray8 = &sse2_delta8_gray8; - Debug(2,"Delta: Using standard and SSE2 delta functions"); + Debug(2,"Delta: Using SSE2 delta functions"); } else { /* No SSE available */ fptr_delta8_rgba = &std_delta8_rgba; @@ -2403,7 +2411,7 @@ __attribute__ ((noinline)) void sse2_fastblend(const uint8_t* col1, const uint8_ "cmp %3, %4\n\t" "jb algo_sse2_blend\n\t" : - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (clearmask), "m" (divider) + : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (clearmask), "m" (divider) : "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "cc", "memory" ); #else @@ -2666,7 +2674,7 @@ __attribute__ ((noinline)) void sse2_delta8_gray8(const uint8_t* col1, const uin "cmp %3, %4\n\t" "jb algo_sse2_delta8_gray8\n\t" : - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i) + : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) : "%xmm1", "%xmm2", "%xmm3", "%xmm4", "cc", "memory" ); #else @@ -2674,6 +2682,308 @@ __attribute__ ((noinline)) void sse2_delta8_gray8(const uint8_t* col1, const uin #endif } +/* RGB32: RGBA SSE2 */ +__attribute__ ((noinline)) void sse2_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +#if (defined(__i386__) || defined(__x86_64__)) + unsigned long i = 0; + + /* XMM0 - clear mask - kept */ + /* XMM1,2,3 - General purpose */ + /* XMM4 - divide mask - kept */ + /* XMM5 - temp */ + /* XMM6 - temp */ + /* XMM7 - unused */ + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "mov $0xff, %%eax\n\t" + "movd %%eax, %%xmm0\n\t" + "pshufd $0x0, %%xmm0, %%xmm0\n\t" + "mov $0x80000000, %%eax\n\t" + "movd %%eax, %%xmm5\n\t" + "pshufd $0x0, %%xmm5, %%xmm5\n\t" + "algo_sse2_delta8_rgba:\n\t" + "movdqa (%0,%4,4), %%xmm1\n\t" + "movdqa (%1,%4,4), %%xmm2\n\t" + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" + "movdqa %%xmm2, %%xmm6\n\t" + "pmaxub %%xmm1, %%xmm2\n\t" + "pminub %%xmm5, %%xmm6\n\t" + "psubb %%xmm6, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm3\n\t" + "psrld $0x8, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "pslld $0x2, %%xmm2\n\t" + "paddd %%xmm1, %%xmm2\n\t" + "movdqa %%xmm3, %%xmm1\n\t" + "pand %%xmm0, %%xmm1\n\t" + "paddd %%xmm1, %%xmm1\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x10, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm3\n\t" + "movdqa %%xmm1, %%xmm2\n\t" + "pand %%xmm0, %%xmm3\n\t" + "pand %%xmm0, %%xmm2\n\t" + "psrldq $0x9, %%xmm2\n\t" + "por %%xmm2, %%xmm3\n\t" + "movdqa %%xmm1, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "psrldq $0x6, %%xmm2\n\t" + "por %%xmm2, %%xmm3\n\t" + "pand %%xmm0, %%xmm1\n\t" + "psrldq $0x3, %%xmm1\n\t" + "por %%xmm1, %%xmm3\n\t" + "movd %%xmm3, %%eax\n\t" + "movnti %%eax, (%2,%4)\n\t" + "add $0x4, %4\n\t" + "cmp %3, %4\n\t" + "jb algo_sse2_delta8_rgba\n\t" + : + : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "cc", "memory" + ); +#else + Panic("SSE function called on a non x86\\x86-64 platform"); +#endif +} + +/* RGB32: BGRA SSE2 */ +__attribute__ ((noinline)) void sse2_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +#if (defined(__i386__) || defined(__x86_64__)) + unsigned long i = 0; + + /* XMM0 - clear mask - kept */ + /* XMM1,2,3 - General purpose */ + /* XMM4 - divide mask - kept */ + /* XMM5 - temp */ + /* XMM6 - temp */ + /* XMM7 - unused */ + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "mov $0xff, %%eax\n\t" + "movd %%eax, %%xmm0\n\t" + "pshufd $0x0, %%xmm0, %%xmm0\n\t" + "mov $0x80000000, %%eax\n\t" + "movd %%eax, %%xmm5\n\t" + "pshufd $0x0, %%xmm5, %%xmm5\n\t" + "algo_sse2_delta8_bgra:\n\t" + "movdqa (%0,%4,4), %%xmm1\n\t" + "movdqa (%1,%4,4), %%xmm2\n\t" + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" + "movdqa %%xmm2, %%xmm6\n\t" + "pmaxub %%xmm1, %%xmm2\n\t" + "pminub %%xmm5, %%xmm6\n\t" + "psubb %%xmm6, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm3\n\t" + "psrld $0x8, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "pslld $0x2, %%xmm2\n\t" + "paddd %%xmm1, %%xmm2\n\t" + "movdqa %%xmm3, %%xmm1\n\t" + "pand %%xmm0, %%xmm1\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x10, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "paddd %%xmm2, %%xmm2\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm3\n\t" + "movdqa %%xmm1, %%xmm2\n\t" + "pand %%xmm0, %%xmm3\n\t" + "pand %%xmm0, %%xmm2\n\t" + "psrldq $0x9, %%xmm2\n\t" + "por %%xmm2, %%xmm3\n\t" + "movdqa %%xmm1, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "psrldq $0x6, %%xmm2\n\t" + "por %%xmm2, %%xmm3\n\t" + "pand %%xmm0, %%xmm1\n\t" + "psrldq $0x3, %%xmm1\n\t" + "por %%xmm1, %%xmm3\n\t" + "movd %%xmm3, %%eax\n\t" + "movnti %%eax, (%2,%4)\n\t" + "add $0x4, %4\n\t" + "cmp %3, %4\n\t" + "jb algo_sse2_delta8_bgra\n\t" + : + : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "cc", "memory" + ); +#else + Panic("SSE function called on a non x86\\x86-64 platform"); +#endif +} + +/* RGB32: ARGB SSE2 */ +__attribute__ ((noinline)) void sse2_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +#if (defined(__i386__) || defined(__x86_64__)) + unsigned long i = 0; + + /* XMM0 - clear mask - kept */ + /* XMM1,2,3 - General purpose */ + /* XMM4 - divide mask - kept */ + /* XMM5 - temp */ + /* XMM6 - temp */ + /* XMM7 - unused */ + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "mov $0xff, %%eax\n\t" + "movd %%eax, %%xmm0\n\t" + "pshufd $0x0, %%xmm0, %%xmm0\n\t" + "mov $0x80000000, %%eax\n\t" + "movd %%eax, %%xmm5\n\t" + "pshufd $0x0, %%xmm5, %%xmm5\n\t" + "algo_sse2_delta8_argb:\n\t" + "movdqa (%0,%4,4), %%xmm1\n\t" + "movdqa (%1,%4,4), %%xmm2\n\t" + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" + "movdqa %%xmm2, %%xmm6\n\t" + "pmaxub %%xmm1, %%xmm2\n\t" + "pminub %%xmm5, %%xmm6\n\t" + "psubb %%xmm6, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm3\n\t" + "psrld $0x10, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "pslld $0x2, %%xmm2\n\t" + "paddd %%xmm1, %%xmm2\n\t" + "movdqa %%xmm3, %%xmm1\n\t" + "psrld $0x8, %%xmm1\n\t" + "pand %%xmm0, %%xmm1\n\t" + "paddd %%xmm1, %%xmm1\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x18, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm3\n\t" + "movdqa %%xmm1, %%xmm2\n\t" + "pand %%xmm0, %%xmm3\n\t" + "pand %%xmm0, %%xmm2\n\t" + "psrldq $0x9, %%xmm2\n\t" + "por %%xmm2, %%xmm3\n\t" + "movdqa %%xmm1, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "psrldq $0x6, %%xmm2\n\t" + "por %%xmm2, %%xmm3\n\t" + "pand %%xmm0, %%xmm1\n\t" + "psrldq $0x3, %%xmm1\n\t" + "por %%xmm1, %%xmm3\n\t" + "movd %%xmm3, %%eax\n\t" + "movnti %%eax, (%2,%4)\n\t" + "add $0x4, %4\n\t" + "cmp %3, %4\n\t" + "jb algo_sse2_delta8_argb\n\t" + : + : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "cc", "memory" + ); +#else + Panic("SSE function called on a non x86\\x86-64 platform"); +#endif +} + +/* RGB32: ABGR SSE2 */ +__attribute__ ((noinline)) void sse2_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +#if (defined(__i386__) || defined(__x86_64__)) + unsigned long i = 0; + + /* XMM0 - clear mask - kept */ + /* XMM1,2,3 - General purpose */ + /* XMM4 - divide mask - kept */ + /* XMM5 - temp */ + /* XMM6 - temp */ + /* XMM7 - unused */ + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "mov $0xff, %%eax\n\t" + "movd %%eax, %%xmm0\n\t" + "pshufd $0x0, %%xmm0, %%xmm0\n\t" + "mov $0x80000000, %%eax\n\t" + "movd %%eax, %%xmm5\n\t" + "pshufd $0x0, %%xmm5, %%xmm5\n\t" + "algo_sse2_delta8_abgr:\n\t" + "movdqa (%0,%4,4), %%xmm1\n\t" + "movdqa (%1,%4,4), %%xmm2\n\t" + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" + "movdqa %%xmm2, %%xmm6\n\t" + "pmaxub %%xmm1, %%xmm2\n\t" + "pminub %%xmm5, %%xmm6\n\t" + "psubb %%xmm6, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm3\n\t" + "psrld $0x10, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "pslld $0x2, %%xmm2\n\t" + "paddd %%xmm1, %%xmm2\n\t" + "movdqa %%xmm3, %%xmm1\n\t" + "psrld $0x8, %%xmm1\n\t" + "pand %%xmm0, %%xmm1\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm3, %%xmm2\n\t" + "psrld $0x18, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "paddd %%xmm2, %%xmm2\n\t" + "paddd %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm3\n\t" + "movdqa %%xmm1, %%xmm2\n\t" + "pand %%xmm0, %%xmm3\n\t" + "pand %%xmm0, %%xmm2\n\t" + "psrldq $0x9, %%xmm2\n\t" + "por %%xmm2, %%xmm3\n\t" + "movdqa %%xmm1, %%xmm2\n\t" + "pand %%xmm0, %%xmm2\n\t" + "psrldq $0x6, %%xmm2\n\t" + "por %%xmm2, %%xmm3\n\t" + "pand %%xmm0, %%xmm1\n\t" + "psrldq $0x3, %%xmm1\n\t" + "por %%xmm1, %%xmm3\n\t" + "movd %%xmm3, %%eax\n\t" + "movnti %%eax, (%2,%4)\n\t" + "add $0x4, %4\n\t" + "cmp %3, %4\n\t" + "jb algo_sse2_delta8_abgr\n\t" + : + : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "cc", "memory" + ); +#else + Panic("SSE function called on a non x86\\x86-64 platform"); +#endif +} + /* RGB32: RGBA SSSE3 */ __attribute__ ((noinline)) void ssse3_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if (defined(__i386__) || defined(__x86_64__)) @@ -2724,7 +3034,7 @@ __attribute__ ((noinline)) void ssse3_delta8_rgba(const uint8_t* col1, const uin "cmp %3, %4\n\t" "jb algo_ssse3_delta8_rgba\n\t" : - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) + : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (*movemask) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -2782,7 +3092,7 @@ __attribute__ ((noinline)) void ssse3_delta8_bgra(const uint8_t* col1, const uin "cmp %3, %4\n\t" "jb algo_ssse3_delta8_bgra\n\t" : - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) + : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (*movemask) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -2841,7 +3151,7 @@ __attribute__ ((noinline)) void ssse3_delta8_argb(const uint8_t* col1, const uin "cmp %3, %4\n\t" "jb algo_ssse3_delta8_argb\n\t" : - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) + : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (*movemask) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -2900,7 +3210,7 @@ __attribute__ ((noinline)) void ssse3_delta8_abgr(const uint8_t* col1, const uin "cmp %3, %4\n\t" "jb algo_ssse3_delta8_abgr\n\t" : - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) + : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (*movemask) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -3072,7 +3382,7 @@ __attribute__ ((noinline)) void ssse3_convert_rgba_gray8(const uint8_t* col1, ui "cmp %2, %3\n\t" "jb algo_ssse3_convert_rgba_gray8\n\t" : - : "r" (col1), "r" (result), "r" (count), "r" (i), "m" (*movemask) + : "r" (col1), "r" (result), "m" (count), "r" (i), "m" (*movemask) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -3113,7 +3423,7 @@ __attribute__ ((noinline)) void ssse3_convert_yuyv_gray8(const uint8_t* col1, ui "cmp %2, %3\n\t" "jb algo_ssse3_convert_yuyv_gray8\n\t" : - : "r" (col1), "r" (result), "r" (count), "r" (i), "m" (*movemask1), "m" (*movemask2) + : "r" (col1), "r" (result), "m" (count), "r" (i), "m" (*movemask1), "m" (*movemask2) : "%xmm3", "%xmm4", "cc", "memory" ); #else diff --git a/src/zm_image.h b/src/zm_image.h index c26db5e5d..10173c03f 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -258,6 +258,10 @@ void std_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); void sse2_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void sse2_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void sse2_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void sse2_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); +void sse2_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); void ssse3_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); void ssse3_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); void ssse3_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index ce70d7fa3..4b143c279 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -2937,6 +2937,7 @@ bool Monitor::DumpSettings( char *output, bool verbose ) } #endif // ZM_HAS_V4L sprintf( output+strlen(output), "Colours : %d\n", camera->Colours() ); + sprintf( output+strlen(output), "Subpixel Order : %d\n", camera->SubpixelOrder() ); sprintf( output+strlen(output), "Event Prefix : %s\n", event_prefix ); sprintf( output+strlen(output), "Label Format : %s\n", label_format ); sprintf( output+strlen(output), "Label Coord : %d,%d\n", label_coord.X(), label_coord.Y() ); diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index a2e799720..95541b116 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -171,28 +171,15 @@ bool Zone::CheckAlarms( const Image *delta_image ) hi_x = ranges[py].hi_x; Debug( 7, "Checking line %d from %d -> %d", y, lo_x, hi_x ); - pdiff = diff_buff + (lo_x * y); + pdiff = diff_buff + (diff_width * y); ppoly = pg_image->Buffer( ranges[py].off_x, py ); - // Left margin - if ( y < hi_y ) - { - int next_lo_x = ranges[py+1].lo_x; - if ( next_lo_x < lo_x ) - { - int lo_x_diff = lo_x-next_lo_x; - memset( pdiff-lo_x_diff, BLACK, lo_x_diff ); - } - else if ( lo_x > 0 ) - *(pdiff-1) = BLACK; - } - else if ( lo_x > 0 ) - *(pdiff-1) = BLACK; + pdiff += lo_x; for ( int x = lo_x; x <= hi_x; x++, pdiff++, ppoly++ ) { if ( *ppoly && (*pdiff > min_pixel_threshold) && (!max_pixel_threshold || (*pdiff < max_pixel_threshold)) ) { alarm_pixels++; - pixel_diff_count += abs(*pdiff); + pixel_diff_count += *pdiff; *pdiff = WHITE; } else @@ -200,16 +187,6 @@ bool Zone::CheckAlarms( const Image *delta_image ) *pdiff = BLACK; } } - // Right margin - if ( y < hi_y ) - { - int next_hi_x = ranges[py+1].hi_x; - if ( next_hi_x > hi_x ) - { - //printf( "%d: Setting %d-%d = %d\n", y, hi_x, next_hi_x, next_hi_x-hi_x ); - memset( pdiff, BLACK, next_hi_x-hi_x ); - } - } } if ( pixel_diff_count && alarm_pixels ) pixel_diff = pixel_diff_count/alarm_pixels; From eeaed7ccd3fb53fa20a801d9ccd010d6d39680c0 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 7 Jun 2011 23:14:01 +0300 Subject: [PATCH 11/56] Some small changes 1) Fixed wrong size calculation in Image::AssignDirect. 2) Improved libjpeg subpixel order selection. 3) Finished adding support in the simple Overlay function. 4) Completed Flip and Rotate 32bit RGB support. 5) Allow ZM to compile on 32bit with omit frame pointer disabled by defining _DEBUG To use one less register in the SSE algorithms. 6) Removed the counter variable in some loops to reduce loop overhead. 7) Modified crop query error handling. 8) Most of the shared data now declared as volatile. 9) Small improvements to the AlarmedPixels motion detection. 10) Changed the default blend percent from 7% to 12%. 11) Fixed an earlier bug created by me: motion detection checking the wrong pixels. --- db/zm_update-1.24.2.sql | 8 - src/zm_ffmpeg_camera.cpp | 22 +- src/zm_image.cpp | 570 +++++++++++++++++++++------- src/zm_image.h | 2 + src/zm_local_camera.cpp | 104 +++-- src/zm_monitor.cpp | 10 +- src/zm_monitor.h | 4 +- src/zm_remote_camera_rtsp.cpp | 73 +++- src/zm_zone.cpp | 45 +-- web/skins/classic/views/monitor.php | 2 +- 10 files changed, 575 insertions(+), 265 deletions(-) diff --git a/db/zm_update-1.24.2.sql b/db/zm_update-1.24.2.sql index 3026bc53a..0d93185e6 100644 --- a/db/zm_update-1.24.2.sql +++ b/db/zm_update-1.24.2.sql @@ -2,14 +2,6 @@ -- This updates a 1.24.2 database to the next version -- ---Add Colours colum. This is a harmless change for ZM 1.24.2 or ZM 1.24.3 without the patch, but is required to use the patch -ALTER TABLE `Monitors` ADD `Colours` TINYINT UNSIGNED NOT NULL DEFAULT '1' AFTER `Height`; - --- Replace now unused ZM_Y_IMAGE_DELTAS option with ZM_CPU_EXTENSIONS. -UPDATE `zm`.`Config` SET `Name` = 'ZM_CPU_EXTENSIONS', -`Prompt` = 'Use advanced CPU extensions to increase performance', -`Help` = 'When advanced processor extensions such as SSE2 or SSSE3 are available, ZoneMinder can use them, which should increase performance and reduce system load. Enabling this option on processors that do not support the advanced processors extensions used by ZoneMinder is harmless and will have no effect.' WHERE `Config`.`Id` = '27'; - -- -- Add in remote ZoneMinder preset. -- diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index a217c32f6..8a820e0b6 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -157,18 +157,14 @@ int FfmpegCamera::PrimeCapture() } #if HAVE_LIBSWSCALE + if(!sws_isSupportedInput(mCodecContext->pix_fmt)) { + Fatal("swscale does not support the codec format"); + } + if(!sws_isSupportedOutput(imagePixFormat)) { Fatal("swscale does not support the target format"); } - if(config.cpu_extensions && sseversion >= 20) { - mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL ); - } else { - mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL ); - } - - if(mConvertContext == NULL) - Fatal( "Unable to create conversion context for %s", mPath.c_str() ); #else // HAVE_LIBSWSCALE Fatal( "You must compile ffmpeg with the --enable-swscale option to use ffmpeg cameras" ); #endif // HAVE_LIBSWSCALE @@ -218,6 +214,16 @@ int FfmpegCamera::Capture( Image &image ) avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height); #if HAVE_LIBSWSCALE + if(mConvertContext == NULL) { + if(config.cpu_extensions && sseversion >= 20) { + mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL ); + } else { + mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL ); + } + if(mConvertContext == NULL) + Fatal( "Unable to create conversion context for %s", mPath.c_str() ); + } + if ( sws_scale( mConvertContext, mRawFrame->data, mRawFrame->linesize, 0, mCodecContext->height, mFrame->data, mFrame->linesize ) < 0 ) Fatal( "Unable to convert raw format %u to target format %u at frame %d", mCodecContext->pix_fmt, imagePixFormat, frameCount ); #else // HAVE_LIBSWSCALE diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 16c528eee..bc51aade0 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -39,19 +39,19 @@ jpeg_decompress_struct *Image::jpg_dcinfo = 0; struct zm_error_mgr Image::jpg_err; /* Pointer to blend function. */ -blend_fptr_t fptr_blend; +static blend_fptr_t fptr_blend; /* Pointer to delta8 functions */ -delta_fptr_t fptr_delta8_rgb; -delta_fptr_t fptr_delta8_bgr; -delta_fptr_t fptr_delta8_rgba; -delta_fptr_t fptr_delta8_bgra; -delta_fptr_t fptr_delta8_argb; -delta_fptr_t fptr_delta8_abgr; -delta_fptr_t fptr_delta8_gray8; +static delta_fptr_t fptr_delta8_rgb; +static delta_fptr_t fptr_delta8_bgr; +static delta_fptr_t fptr_delta8_rgba; +static delta_fptr_t fptr_delta8_bgra; +static delta_fptr_t fptr_delta8_argb; +static delta_fptr_t fptr_delta8_abgr; +static delta_fptr_t fptr_delta8_gray8; -/* Pointer to big memory copy function */ -imgbufcpy_fptr_t fptr_imgbufcpy; +/* Pointer to image buffer memory copy function */ +static imgbufcpy_fptr_t fptr_imgbufcpy; Image::Image() { @@ -97,12 +97,11 @@ Image::Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uin pixels = width*height; colours = p_colours; subpixelorder = p_subpixelorder; - size = width*height*colours; + size = (width*height)*colours; buffer = 0; holdbuffer = 0; if ( p_buffer ) { - /* Don't free the supplied buffer, but don't hold it either */ allocation = size; buffertype = ZM_BUFTYPE_DONTFREE; buffer = p_buffer; @@ -185,8 +184,9 @@ void Image::Initialise() fptr_delta8_bgra = &sse2_delta8_bgra; fptr_delta8_argb = &sse2_delta8_argb; fptr_delta8_abgr = &sse2_delta8_abgr; - /* On some systems, the 4 SSE2 algorithms above might be slower than - ** the standard algorithms, especially on early Pentium 4 processors + /* + ** On some systems, the 4 SSE2 algorithms above might be a little slower than + ** the standard algorithms, especially on early Pentium 4 processors. ** In that case, comment out the 4 lines above and uncomment the 4 lines below */ // fptr_delta8_rgba = &std_delta8_rgba; @@ -196,7 +196,7 @@ void Image::Initialise() fptr_delta8_gray8 = &sse2_delta8_gray8; Debug(2,"Delta: Using SSE2 delta functions"); } else { - /* No SSE available */ + /* No suitable SSE version available */ fptr_delta8_rgba = &std_delta8_rgba; fptr_delta8_bgra = &std_delta8_bgra; fptr_delta8_argb = &std_delta8_argb; @@ -269,7 +269,7 @@ void Image::Initialise() uint8_t* Image::WriteBuffer(const int p_width, const int p_height, const int p_colours, const int p_subpixelorder) { unsigned int newsize; - if(p_colours != 1 && p_colours != 3 && p_colours != 4) { + if(p_colours != ZM_COLOUR_GRAY8 && p_colours != ZM_COLOUR_RGB24 && p_colours != ZM_COLOUR_RGB32) { Error("WriteBuffer called with unexpected colours: %d",p_colours); return NULL; } @@ -280,7 +280,7 @@ uint8_t* Image::WriteBuffer(const int p_width, const int p_height, const int p_c } if(p_width != width || p_height != height || p_colours != colours || p_subpixelorder != subpixelorder) { - newsize = p_width * p_height * p_colours; + newsize = (p_width * p_height) * p_colours; if(buffer == NULL) { AllocImgBuffer(newsize); @@ -316,7 +316,7 @@ void Image::AssignDirect( const int p_width, const int p_height, const int p_col return; } - if(buffer_size < (p_width*p_height*p_colours)) { + if(buffer_size < ((p_width*p_height)*p_colours)) { Error("Attempt to directly assign buffer from an undersized buffer of size: %u",buffer_size); return; } @@ -326,13 +326,13 @@ void Image::AssignDirect( const int p_width, const int p_height, const int p_col return; } - if(p_colours != 1 && p_colours != 3 && p_colours != 4) { + if(p_colours != ZM_COLOUR_GRAY8 && p_colours != ZM_COLOUR_RGB24 && p_colours != ZM_COLOUR_RGB32) { Error("Attempt to directly assign buffer with unexpected colours per pixel: %d",p_colours); return; } if(holdbuffer && buffer) { - if((p_height * p_height * p_colours) > allocation) { + if(((p_height*p_width)*p_colours) > allocation) { Error("Held buffer is undersized for assigned buffer"); return; } else { @@ -369,7 +369,7 @@ void Image::AssignDirect( const int p_width, const int p_height, const int p_col } void Image::Assign(const int p_width, const int p_height, const int p_colours, const int p_subpixelorder, const uint8_t* new_buffer, const size_t buffer_size) { - unsigned int new_size = p_width * p_height * p_colours; + unsigned int new_size = (p_width * p_height) * p_colours; if(new_buffer == NULL) { Error("Attempt to assign buffer from a NULL pointer"); @@ -386,7 +386,7 @@ void Image::Assign(const int p_width, const int p_height, const int p_colours, c return; } - if(p_colours != 1 && p_colours != 3 && p_colours != 4) { + if(p_colours != ZM_COLOUR_GRAY8 && p_colours != ZM_COLOUR_RGB24 && p_colours != ZM_COLOUR_RGB32) { Error("Attempt to assign buffer with unexpected colours per pixel: %d",p_colours); return; } @@ -419,14 +419,14 @@ void Image::Assign(const int p_width, const int p_height, const int p_colours, c } void Image::Assign( const Image &image ) { - unsigned int new_size = image.width * image.height * image.colours; + unsigned int new_size = (image.width * image.height) * image.colours; if(image.buffer == NULL) { Error("Attempt to assign image with an empty buffer"); return; } - if(image.colours != 1 && image.colours != 3 && image.colours != 4) { + if(image.colours != ZM_COLOUR_GRAY8 && image.colours != ZM_COLOUR_RGB24 && image.colours != ZM_COLOUR_RGB32) { Error("Attempt to assign image with unexpected colours per pixel: %d",image.colours); return; } @@ -457,9 +457,10 @@ void Image::Assign( const Image &image ) { (*fptr_imgbufcpy)(buffer, image.buffer, size); } +/* RGB24 only */ Image *Image::HighlightEdges( Rgb colour, const Box *limits ) { - if ( colours != 1 ) + if ( colours != ZM_COLOUR_GRAY8 ) { Panic( "Attempt to highlight image edges when colours = %d", colours ); } @@ -636,12 +637,16 @@ bool Image::ReadJpeg( const char *filename, int p_colours, int p_subpixelorder) subpixelorder = ZM_SUBPIX_ORDER_BGR; #else Warning("libjpeg-turbo is required for reading a JPEG directly into a BGR24 buffer, reading into a RGB24 buffer instead."); - cinfo->out_color_space = JCS_EXT_RGB; + cinfo->out_color_space = JCS_RGB; subpixelorder = ZM_SUBPIX_ORDER_RGB; #endif } else { /* Assume RGB */ - cinfo->out_color_space = JCS_RGB; +#ifdef JCS_EXTENSIONS + cinfo->out_color_space = JCS_EXT_RGB; +#else + cinfo->out_color_space = JCS_RGB; +#endif subpixelorder = ZM_SUBPIX_ORDER_RGB; } break; @@ -683,7 +688,7 @@ bool Image::ReadJpeg( const char *filename, int p_colours, int p_subpixelorder) bool Image::WriteJpeg( const char *filename, int quality_override ) const { - if ( config.colour_jpeg_files && colours == 1 ) + if ( config.colour_jpeg_files && colours == ZM_COLOUR_GRAY8 ) { Image temp_image( *this ); temp_image.Colourise( ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB ); @@ -758,7 +763,11 @@ bool Image::WriteJpeg( const char *filename, int quality_override ) const #endif } else { /* Assume RGB */ +#ifdef JCS_EXTENSIONS + cinfo->in_color_space = JCS_EXT_RGB; +#else cinfo->in_color_space = JCS_RGB; +#endif } break; } @@ -867,12 +876,16 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, int p_colours subpixelorder = ZM_SUBPIX_ORDER_BGR; #else Warning("libjpeg-turbo is required for reading a JPEG directly into a BGR24 buffer, reading into a RGB24 buffer instead."); - cinfo->out_color_space = JCS_EXT_RGB; + cinfo->out_color_space = JCS_RGB; subpixelorder = ZM_SUBPIX_ORDER_RGB; #endif } else { /* Assume RGB */ - cinfo->out_color_space = JCS_RGB; +#ifdef JCS_EXTENSIONS + cinfo->out_color_space = JCS_EXT_RGB; +#else + cinfo->out_color_space = JCS_RGB; +#endif subpixelorder = ZM_SUBPIX_ORDER_RGB; } break; @@ -912,7 +925,7 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, int p_colours bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_override ) const { - if ( config.colour_jpeg_files && colours == 1 ) + if ( config.colour_jpeg_files && colours == ZM_COLOUR_GRAY8 ) { Image temp_image( *this ); temp_image.Colourise(ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB ); @@ -979,7 +992,11 @@ bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_over #endif } else { /* Assume RGB */ +#ifdef JCS_EXTENSIONS + cinfo->in_color_space = JCS_EXT_RGB; +#else cinfo->in_color_space = JCS_RGB; +#endif } break; } @@ -1087,9 +1104,9 @@ void Image::Overlay( const Image &image ) unsigned char *pdest = buffer; unsigned char *psrc = image.buffer; - if ( colours == 1 ) + if ( colours == ZM_COLOUR_GRAY8 ) { - if ( image.colours == 1 ) + if ( image.colours == ZM_COLOUR_GRAY8 ) { while( pdest < (buffer+size) ) { @@ -1103,24 +1120,52 @@ void Image::Overlay( const Image &image ) } else { - Colourise(ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB ); - pdest = buffer; - while( pdest < (buffer+size) ) - { - if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) - { - RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); - GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); - BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); + Colourise(image.colours, image.subpixelorder); + + if(colours == ZM_COLOUR_RGB32) { + Rgb* prdest = (Rgb*)buffer; + const Rgb* prsrc = (Rgb*)image.buffer; + const Rgb* const max_ptr = (Rgb*)(buffer+size); + if(subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ + while (prdest < max_ptr) { + if ( RED_PTR_RGBA(prsrc) || GREEN_PTR_RGBA(prsrc) || BLUE_PTR_RGBA(prsrc) ) + { + *prdest = *prsrc; + } + prdest++; + prsrc++; + } + } else { + /* ABGR\ARGB subpixel order - Alpha byte is first */ + while (prdest < max_ptr) { + if ( RED_PTR_ABGR(prsrc) || GREEN_PTR_ABGR(prsrc) || BLUE_PTR_ABGR(prsrc) ) + { + *prdest = *prsrc; + } + prdest++; + prsrc++; + } + } + } else { + /* Assume RGB24\BGR24 */ + while( pdest < (buffer+size) ) + { + if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) + { + RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); + GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); + BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); + } + psrc += 3; + pdest += 3; } - psrc += 3; - pdest += 3; } } } else { - if ( image.colours == 1 ) + if ( image.colours == ZM_COLOUR_GRAY8 ) { while( pdest < (buffer+size) ) { @@ -1128,11 +1173,14 @@ void Image::Overlay( const Image &image ) { RED_PTR_RGBA(pdest) = GREEN_PTR_RGBA(pdest) = BLUE_PTR_RGBA(pdest) = *psrc++; } - pdest += 3; + pdest += colours; } } else { + + + while( pdest < (buffer+size) ) { if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) @@ -1141,8 +1189,8 @@ void Image::Overlay( const Image &image ) GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); } - psrc += 3; - pdest += 3; + psrc += colours; + pdest += colours; } } } @@ -1468,7 +1516,7 @@ void Image::Annotate( const char *p_text, const Coord &coord, const Rgb fg_colou if ( hi_line_y > height ) hi_line_y = height; - if ( colours == 1 ) + if ( colours == ZM_COLOUR_GRAY8 ) { unsigned char *ptr = &buffer[(lo_line_y*width)+lo_line_x]; for ( int y = lo_line_y, r = 0; y < hi_line_y && r < CHAR_HEIGHT; y++, r++, ptr += width ) @@ -1492,7 +1540,7 @@ void Image::Annotate( const char *p_text, const Coord &coord, const Rgb fg_colou } } } - else if ( colours == 3 ) + else if ( colours == ZM_COLOUR_RGB24 ) { int wc = width * colours; @@ -1524,7 +1572,7 @@ void Image::Annotate( const char *p_text, const Coord &coord, const Rgb fg_colou } } } - else if ( colours == 4) + else if ( colours == ZM_COLOUR_RGB32 ) { int wc = width * colours; @@ -1583,6 +1631,7 @@ void Image::Timestamp( const char *label, const time_t when, const Coord &coord } } +/* RGB32 compatible: complete */ void Image::Colourise(const int p_reqcolours, const int p_reqsubpixelorder) { Debug(9, "Colourise: Req colours: %u Req subpixel order: %u Current colours: %u Current subpixel order: %u",p_reqcolours,p_reqsubpixelorder,colours,subpixelorder); @@ -1643,45 +1692,49 @@ void Image::Colourise(const int p_reqcolours, const int p_reqsubpixelorder) } - +/* RGB32 compatible: complete */ void Image::DeColourise() { - colours = 1; + colours = ZM_COLOUR_GRAY8; + subpixelorder = ZM_SUBPIX_ORDER_NONE; size = width * height; - uint8_t *pdest = buffer; - unsigned int r,g,b; - - if ( colours == 3 ) + if ( colours == ZM_COLOUR_RGB32 ) { - const uint8_t *psrc = buffer; - while( pdest < (buffer+size) ) - { - //*pdest++ = (uint8_t)sqrt((RED(psrc) + GREEN(psrc) + BLUE(psrc))/3); - - /* Use fast algorithm for almost identical ITU-R BT.709 weighting */ - if(subpixelorder == ZM_SUBPIX_ORDER_BGR) { - /* BGR subpixel order */ - r = RED_PTR_BGRA(psrc); - g = GREEN_PTR_BGRA(psrc); - b = BLUE_PTR_BGRA(psrc); - *pdest++ = (r + r + b + g + g + g + g + g)>>3; - } else { - /* RGB subpixel order */ - r = RED_PTR_RGBA(psrc); - g = GREEN_PTR_RGBA(psrc); - b = BLUE_PTR_RGBA(psrc); - *pdest++ = (r + r + b + g + g + g + g + g)>>3; - } - psrc += 3; + switch(subpixelorder) { + case ZM_SUBPIX_ORDER_BGRA: + std_convert_bgra_gray8(buffer,buffer,pixels); + break; + case ZM_SUBPIX_ORDER_ARGB: + std_convert_argb_gray8(buffer,buffer,pixels); + break; + case ZM_SUBPIX_ORDER_ABGR: + std_convert_abgr_gray8(buffer,buffer,pixels); + break; + case ZM_SUBPIX_ORDER_RGBA: + default: + std_convert_rgba_gray8(buffer,buffer,pixels); + break; } + } else { + /* Assume RGB24 */ + switch(subpixelorder) { + case ZM_SUBPIX_ORDER_BGR: + std_convert_bgr_gray8(buffer,buffer,pixels); + break; + case ZM_SUBPIX_ORDER_RGB: + default: + std_convert_rgb_gray8(buffer,buffer,pixels); + break; + } + } } /* RGB32 compatible: complete */ void Image::Fill( Rgb colour, const Box *limits ) { - if ( !(colours == 1 || colours == 3 || colours == 4 ) ) + if ( !(colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB24 || colours == ZM_COLOUR_RGB32 ) ) { Panic( "Attempt to fill image with unexpected colours %d", colours ); } @@ -1693,7 +1746,7 @@ void Image::Fill( Rgb colour, const Box *limits ) int lo_y = limits?limits->Lo().Y():0; int hi_x = limits?limits->Hi().X():width-1; int hi_y = limits?limits->Hi().Y():height-1; - if ( colours == 1 ) + if ( colours == ZM_COLOUR_GRAY8 ) { for ( int y = lo_y; y <= hi_y; y++ ) { @@ -1704,7 +1757,7 @@ void Image::Fill( Rgb colour, const Box *limits ) } } } - else if ( colours == 3 ) + else if ( colours == ZM_COLOUR_RGB24 ) { for ( int y = lo_y; y <= hi_y; y++ ) { @@ -1717,12 +1770,11 @@ void Image::Fill( Rgb colour, const Box *limits ) } } } - else if ( colours == 4 ) /* RGB32 [R,G,B,A] */ + else if ( colours == ZM_COLOUR_RGB32 ) /* RGB32 */ { for ( unsigned int y = lo_y; y <= hi_y; y++ ) { Rgb *p = (Rgb*)&buffer[((y*width)+lo_x)<<2]; - // unsigned int count = (hi_x+1) - lo_x; for ( unsigned int x = lo_x; x <= hi_x; x++, p++) { @@ -1740,7 +1792,7 @@ void Image::Fill( Rgb colour, int density, const Box *limits ) if(density <= 1) return Fill(colour,limits); - if ( !(colours == 1 || colours == 3 || colours == 4 ) ) + if ( !(colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB24 || colours == ZM_COLOUR_RGB32 ) ) { Panic( "Attempt to fill image with unexpected colours %d", colours ); } @@ -1752,7 +1804,7 @@ void Image::Fill( Rgb colour, int density, const Box *limits ) int lo_y = limits?limits->Lo().Y():0; int hi_x = limits?limits->Hi().X():width-1; int hi_y = limits?limits->Hi().Y():height-1; - if ( colours == 1 ) + if ( colours == ZM_COLOUR_GRAY8 ) { for ( int y = lo_y; y <= hi_y; y++ ) { @@ -1764,7 +1816,7 @@ void Image::Fill( Rgb colour, int density, const Box *limits ) } } } - else if ( colours == 3 ) + else if ( colours == ZM_COLOUR_RGB24 ) { for ( int y = lo_y; y <= hi_y; y++ ) { @@ -1779,7 +1831,7 @@ void Image::Fill( Rgb colour, int density, const Box *limits ) } } } - else if ( colours == 4 ) /* RGB32 [R,G,B,A] */ + else if ( colours == ZM_COLOUR_RGB32 ) /* RGB32 */ { for ( int y = lo_y; y <= hi_y; y++ ) { @@ -1799,7 +1851,7 @@ void Image::Fill( Rgb colour, int density, const Box *limits ) /* RGB32 compatible: complete */ void Image::Outline( Rgb colour, const Polygon &polygon ) { - if ( !(colours == 1 || colours == 3 || colours == 4 ) ) + if ( !(colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB24 || colours == ZM_COLOUR_RGB32 ) ) { Panic( "Attempt to outline image with unexpected colours %d", colours ); } @@ -1835,7 +1887,7 @@ void Image::Outline( Rgb colour, const Polygon &polygon ) double x; int y, yinc = (y1= 0; i-- ) + for ( int i = new_width-1; i >= 0; i-- ) { d_ptr = rotate_buffer+i; - for ( int j = height-1; j >= 0; j-- ) + for ( int j = new_height-1; j >= 0; j-- ) { *d_ptr = *s_ptr++; d_ptr += line_bytes; } } } - else + else if ( colours == ZM_COLOUR_RGB32 ) + { + Rgb* s_rptr = (Rgb*)s_ptr; + Rgb* d_rptr; + for ( int i = new_width-1; i >= 0; i-- ) + { + d_rptr = (Rgb*)(rotate_buffer+(i<<2)); + for ( int j = new_height-1; j >= 0; j-- ) + { + *d_rptr = *s_rptr++; + d_rptr += new_width; + } + } + } + else /* Assume RGB24 */ { unsigned char *d_ptr; - for ( int i = width-1; i >= 0; i-- ) + for ( int i = new_width-1; i >= 0; i-- ) { d_ptr = rotate_buffer+(3*i); - for ( int j = height-1; j >= 0; j-- ) + for ( int j = new_height-1; j >= 0; j-- ) { *d_ptr = *s_ptr++; *(d_ptr+1) = *s_ptr++; @@ -2116,7 +2185,7 @@ void Image::Rotate( int angle ) unsigned char *s_ptr = buffer+size; unsigned char *d_ptr = rotate_buffer; - if ( colours == 1 ) + if ( colours == ZM_COLOUR_GRAY8 ) { while( s_ptr > buffer ) { @@ -2124,7 +2193,17 @@ void Image::Rotate( int angle ) *d_ptr++ = *s_ptr; } } - else + else if ( colours == ZM_COLOUR_RGB32 ) + { + Rgb* s_rptr = (Rgb*)s_ptr; + Rgb* d_rptr = (Rgb*)d_ptr; + while( s_rptr > (Rgb*)buffer ) + { + s_rptr--; + *d_rptr++ = *s_rptr; + } + } + else /* Assume RGB24 */ { while( s_ptr > buffer ) { @@ -2138,20 +2217,19 @@ void Image::Rotate( int angle ) } case 270 : { - int temp = width; - width = height; - height = temp; + new_height = width; + new_width = height; - int line_bytes = width*colours; + int line_bytes = new_width*colours; unsigned char *s_ptr = buffer+size; - if ( colours == 1 ) + if ( colours == ZM_COLOUR_GRAY8 ) { unsigned char *d_ptr; - for ( int i = width-1; i >= 0; i-- ) + for ( int i = new_width-1; i >= 0; i-- ) { d_ptr = rotate_buffer+i; - for ( int j = height-1; j >= 0; j-- ) + for ( int j = new_height-1; j >= 0; j-- ) { s_ptr--; *d_ptr = *s_ptr; @@ -2159,13 +2237,28 @@ void Image::Rotate( int angle ) } } } - else + else if ( colours == ZM_COLOUR_RGB32 ) + { + Rgb* s_rptr = (Rgb*)s_ptr; + Rgb* d_rptr; + for ( int i = new_width-1; i >= 0; i-- ) + { + d_rptr = (Rgb*)(rotate_buffer+(i<<2)); + for ( int j = new_height-1; j >= 0; j-- ) + { + s_rptr--; + *d_rptr = *s_rptr; + d_rptr += new_width; + } + } + } + else /* Assume RGB24 */ { unsigned char *d_ptr; - for ( int i = width-1; i >= 0; i-- ) + for ( int i = new_width-1; i >= 0; i-- ) { d_ptr = rotate_buffer+(3*i); - for ( int j = height-1; j >= 0; j-- ) + for ( int j = new_height-1; j >= 0; j-- ) { *(d_ptr+2) = *(--s_ptr); *(d_ptr+1) = *(--s_ptr); @@ -2178,13 +2271,13 @@ void Image::Rotate( int angle ) } } - AssignDirect( width, height, colours, subpixelorder, rotate_buffer, size, ZM_BUFTYPE_ZM); + AssignDirect( new_width, new_height, colours, subpixelorder, rotate_buffer, size, ZM_BUFTYPE_ZM); } +/* RGB32 compatible: complete */ void Image::Flip( bool leftright ) { - uint8_t* flip_buffer = AllocBuffer(size); int line_bytes = width*colours; @@ -2196,7 +2289,7 @@ void Image::Flip( bool leftright ) unsigned char *d_ptr = flip_buffer; unsigned char *max_d_ptr = flip_buffer + size; - if ( colours == 1 ) + if ( colours == ZM_COLOUR_GRAY8 ) { while( d_ptr < max_d_ptr ) { @@ -2208,7 +2301,22 @@ void Image::Flip( bool leftright ) s_ptr += line_bytes2; } } - else + else if ( colours == ZM_COLOUR_RGB32 ) + { + Rgb* s_rptr = (Rgb*)s_ptr; + Rgb* d_rptr = (Rgb*)flip_buffer; + Rgb* max_d_rptr = (Rgb*)max_d_ptr; + while( d_rptr < max_d_rptr ) + { + for ( int j = 0; j < width; j++ ) + { + s_rptr--; + *d_rptr++ = *s_rptr; + } + s_rptr += width * 2; + } + } + else /* Assume RGB24 */ { while( d_ptr < max_d_ptr ) { @@ -2221,7 +2329,7 @@ void Image::Flip( bool leftright ) } s_ptr += line_bytes2; } - } + } } else { @@ -2411,7 +2519,11 @@ __attribute__ ((noinline)) void sse2_fastblend(const uint8_t* col1, const uint8_ "cmp %3, %4\n\t" "jb algo_sse2_blend\n\t" : +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (clearmask), "m" (divider) +#else + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (clearmask), "m" (divider) +#endif : "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "cc", "memory" ); #else @@ -2422,6 +2534,7 @@ __attribute__ ((noinline)) void sse2_fastblend(const uint8_t* col1, const uint8_ __attribute__ ((noinline)) void std_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { static int divider = 0; static double current_blendpercent = 0.0; + const uint8_t* const max_ptr = result + count; if(current_blendpercent != blendpercent) { /* Attempt to match the blending percent to one of the possible values */ @@ -2448,7 +2561,7 @@ __attribute__ ((noinline)) void std_fastblend(const uint8_t* col1, const uint8_t } - for(register unsigned long i=0; i < count; i += 16, col1 += 16, col2 += 16, result += 16) { + while(result < max_ptr) { result[0] = ((col2[0] - col1[0])>>divider) + col1[0]; result[1] = ((col2[1] - col1[1])>>divider) + col1[1]; result[2] = ((col2[2] - col1[2])>>divider) + col1[2]; @@ -2465,26 +2578,32 @@ __attribute__ ((noinline)) void std_fastblend(const uint8_t* col1, const uint8_t result[13] = ((col2[13] - col1[13])>>divider) + col1[13]; result[14] = ((col2[14] - col1[14])>>divider) + col1[14]; result[15] = ((col2[15] - col1[15])>>divider) + col1[15]; + + col1 += 16; + col2 += 16; + result += 16; } } __attribute__ ((noinline)) void std_blend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { double divide = blendpercent / 100.0; double opacity = 1.0 - divide; - for(register unsigned long i=0; i < count; i++) { - result[i] = (col1[i] * opacity) + (col2[i] * divide); + const uint8_t* const max_ptr = result + count; + + while(result < max_ptr) { + *result++ = (*col1++ * opacity) + (*col2++ * divide); + } } - - - /************************************************* DELTA FUNCTIONS *************************************************/ /* Grayscale */ __attribute__ ((noinline)) void std_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 16 bytes (16 grayscale pixels) at a time */ - for(unsigned int i=0;i>3; + + col1 += 12; + col2 += 12; + result += 4; } } @@ -2532,7 +2661,9 @@ __attribute__ ((noinline)) void std_delta8_rgb(const uint8_t* col1, const uint8_ __attribute__ ((noinline)) void std_delta8_bgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 12 bytes (4 rgb24 pixels) at a time */ int r,g,b; - for(unsigned int i=0; i>3; + + col1 += 12; + col2 += 12; + result += 4; } } @@ -2556,7 +2691,9 @@ __attribute__ ((noinline)) void std_delta8_bgr(const uint8_t* col1, const uint8_ __attribute__ ((noinline)) void std_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */ int r,g,b; - for(unsigned int i=0; i>3; + + col1 += 16; + col2 += 16; + result += 4; } } @@ -2580,7 +2721,9 @@ __attribute__ ((noinline)) void std_delta8_rgba(const uint8_t* col1, const uint8 __attribute__ ((noinline)) void std_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */ int r,g,b; - for(unsigned int i=0; i>3; + + col1 += 16; + col2 += 16; + result += 4; } } @@ -2604,7 +2751,9 @@ __attribute__ ((noinline)) void std_delta8_bgra(const uint8_t* col1, const uint8 __attribute__ ((noinline)) void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */ int r,g,b; - for(unsigned int i=0; i>3; + + col1 += 16; + col2 += 16; + result += 4; } } @@ -2628,7 +2781,9 @@ __attribute__ ((noinline)) void std_delta8_argb(const uint8_t* col1, const uint8 __attribute__ ((noinline)) void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */ int r,g,b; - for(unsigned int i=0; i>3; + + col1 += 16; + col2 += 16; + result += 4; } } @@ -2674,7 +2833,11 @@ __attribute__ ((noinline)) void sse2_delta8_gray8(const uint8_t* col1, const uin "cmp %3, %4\n\t" "jb algo_sse2_delta8_gray8\n\t" : +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) +#else + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i) +#endif : "%xmm1", "%xmm2", "%xmm3", "%xmm4", "cc", "memory" ); #else @@ -2749,7 +2912,11 @@ __attribute__ ((noinline)) void sse2_delta8_rgba(const uint8_t* col1, const uint "cmp %3, %4\n\t" "jb algo_sse2_delta8_rgba\n\t" : +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) +#else + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i) +#endif : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "cc", "memory" ); #else @@ -2824,7 +2991,11 @@ __attribute__ ((noinline)) void sse2_delta8_bgra(const uint8_t* col1, const uint "cmp %3, %4\n\t" "jb algo_sse2_delta8_bgra\n\t" : +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) +#else + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i) +#endif : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "cc", "memory" ); #else @@ -2900,7 +3071,11 @@ __attribute__ ((noinline)) void sse2_delta8_argb(const uint8_t* col1, const uint "cmp %3, %4\n\t" "jb algo_sse2_delta8_argb\n\t" : +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) +#else + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i) +#endif : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "cc", "memory" ); #else @@ -2976,7 +3151,11 @@ __attribute__ ((noinline)) void sse2_delta8_abgr(const uint8_t* col1, const uint "cmp %3, %4\n\t" "jb algo_sse2_delta8_abgr\n\t" : +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) +#else + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i) +#endif : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "cc", "memory" ); #else @@ -3034,7 +3213,11 @@ __attribute__ ((noinline)) void ssse3_delta8_rgba(const uint8_t* col1, const uin "cmp %3, %4\n\t" "jb algo_ssse3_delta8_rgba\n\t" : +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (*movemask) +#else + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) +#endif : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -3092,7 +3275,11 @@ __attribute__ ((noinline)) void ssse3_delta8_bgra(const uint8_t* col1, const uin "cmp %3, %4\n\t" "jb algo_ssse3_delta8_bgra\n\t" : +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (*movemask) +#else + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) +#endif : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -3151,7 +3338,11 @@ __attribute__ ((noinline)) void ssse3_delta8_argb(const uint8_t* col1, const uin "cmp %3, %4\n\t" "jb algo_ssse3_delta8_argb\n\t" : +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (*movemask) +#else + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) +#endif : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -3210,7 +3401,11 @@ __attribute__ ((noinline)) void ssse3_delta8_abgr(const uint8_t* col1, const uin "cmp %3, %4\n\t" "jb algo_ssse3_delta8_abgr\n\t" : +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (*movemask) +#else + : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) +#endif : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -3221,10 +3416,68 @@ __attribute__ ((noinline)) void ssse3_delta8_abgr(const uint8_t* col1, const uin /************************************************* CONVERT FUNCTIONS *************************************************/ +/* RGB24 to grayscale */ +__attribute__ ((noinline)) void std_convert_rgb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { + unsigned int r,g,b; + const uint8_t* const max_ptr = result + count; + + while(result < max_ptr) { + r = col1[0]; + g = col1[1]; + b = col1[2]; + result[0] = (r + r + b + g + g + g + g + g)>>3; + r = col1[3]; + g = col1[4]; + b = col1[5]; + result[1] = (r + r + b + g + g + g + g + g)>>3; + r = col1[6]; + g = col1[7]; + b = col1[8]; + result[2] = (r + r + b + g + g + g + g + g)>>3; + r = col1[9]; + g = col1[10]; + b = col1[11]; + result[3] = (r + r + b + g + g + g + g + g)>>3; + + col1 += 12; + result += 4; + } +} + +/* BGR24 to grayscale */ +__attribute__ ((noinline)) void std_convert_bgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { + unsigned int r,g,b; + const uint8_t* const max_ptr = result + count; + + while(result < max_ptr) { + b = col1[0]; + g = col1[1]; + r = col1[2]; + result[0] = (r + r + b + g + g + g + g + g)>>3; + b = col1[3]; + g = col1[4]; + r = col1[5]; + result[1] = (r + r + b + g + g + g + g + g)>>3; + b = col1[6]; + g = col1[7]; + r = col1[8]; + result[2] = (r + r + b + g + g + g + g + g)>>3; + b = col1[9]; + g = col1[10]; + r = col1[11]; + result[3] = (r + r + b + g + g + g + g + g)>>3; + + col1 += 12; + result += 4; + } +} + /* RGBA to grayscale */ __attribute__ ((noinline)) void std_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; - for(unsigned int i=0; i>3; + + col1 += 16; + result += 4; } } /* BGRA to grayscale */ __attribute__ ((noinline)) void std_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; - for(unsigned int i=0; i>3; + + col1 += 16; + result += 4; } } /* ARGB to grayscale */ __attribute__ ((noinline)) void std_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; - for(unsigned int i=0; i>3; + + col1 += 16; + result += 4; } } /* ABGR to grayscale */ __attribute__ ((noinline)) void std_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; - for(unsigned int i=0; i>3; + + col1 += 16; + result += 4; } } @@ -3317,7 +3588,9 @@ __attribute__ ((noinline)) void std_convert_abgr_gray8(const uint8_t* col1, uint __attribute__ ((noinline)) void std_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { const uint16_t* yuvbuf = (const uint16_t*)col1; - for(register unsigned long i=0; i < count; i += 16, yuvbuf += 16, result += 16) { + const uint8_t* const max_ptr = result + count; + + while(result < max_ptr) { result[0] = (uint8_t)yuvbuf[0]; result[1] = (uint8_t)yuvbuf[1]; result[2] = (uint8_t)yuvbuf[2]; @@ -3334,7 +3607,10 @@ __attribute__ ((noinline)) void std_convert_yuyv_gray8(const uint8_t* col1, uint result[13] = (uint8_t)yuvbuf[13]; result[14] = (uint8_t)yuvbuf[14]; result[15] = (uint8_t)yuvbuf[15]; - } + + yuvbuf += 16; + result += 16; + } } /* RGBA to grayscale SSSE3 */ @@ -3382,7 +3658,11 @@ __attribute__ ((noinline)) void ssse3_convert_rgba_gray8(const uint8_t* col1, ui "cmp %2, %3\n\t" "jb algo_ssse3_convert_rgba_gray8\n\t" : +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ : "r" (col1), "r" (result), "m" (count), "r" (i), "m" (*movemask) +#else + : "r" (col1), "r" (result), "r" (count), "r" (i), "m" (*movemask) +#endif : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -3423,7 +3703,11 @@ __attribute__ ((noinline)) void ssse3_convert_yuyv_gray8(const uint8_t* col1, ui "cmp %2, %3\n\t" "jb algo_ssse3_convert_yuyv_gray8\n\t" : +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ : "r" (col1), "r" (result), "m" (count), "r" (i), "m" (*movemask1), "m" (*movemask2) +#else + : "r" (col1), "r" (result), "r" (count), "r" (i), "m" (*movemask1), "m" (*movemask2) +#endif : "%xmm3", "%xmm4", "cc", "memory" ); #else diff --git a/src/zm_image.h b/src/zm_image.h index 10173c03f..0da931a95 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -268,6 +268,8 @@ void ssse3_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result void ssse3_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count); /* Convert functions */ +void std_convert_rgb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count); +void std_convert_bgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count); void std_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count); void std_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long count); void std_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count); diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 53ba9ce1f..78559ae55 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -418,10 +418,10 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, Debug(2,"Using ZM for image conversion"); if(palette == V4L2_PIX_FMT_RGB32 && colours == ZM_COLOUR_GRAY8) { conversion_fptr = &std_convert_argb_gray8; - subpixelorder = ZM_SUBPIX_ORDER_ARGB; + subpixelorder = ZM_SUBPIX_ORDER_NONE; } else if(palette == V4L2_PIX_FMT_BGR32 && colours == ZM_COLOUR_GRAY8) { conversion_fptr = &std_convert_bgra_gray8; - subpixelorder = ZM_SUBPIX_ORDER_BGRA; + subpixelorder = ZM_SUBPIX_ORDER_NONE; } else if(palette == V4L2_PIX_FMT_YUYV && colours == ZM_COLOUR_GRAY8) { /* Fast YUYV->Grayscale conversion by extracting the Y channel */ if(config.cpu_extensions && sseversion >= 35) { @@ -529,10 +529,10 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, if(palette == VIDEO_PALETTE_RGB32 && colours == ZM_COLOUR_GRAY8) { if(BigEndian) { conversion_fptr = &std_convert_argb_gray8; - subpixelorder = ZM_SUBPIX_ORDER_ARGB; + subpixelorder = ZM_SUBPIX_ORDER_NONE; } else { conversion_fptr = &std_convert_bgra_gray8; - subpixelorder = ZM_SUBPIX_ORDER_BGRA; + subpixelorder = ZM_SUBPIX_ORDER_NONE; } } else if((palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422) && colours == ZM_COLOUR_GRAY8) { /* Fast YUYV->Grayscale conversion by extracting the Y channel */ @@ -1185,55 +1185,53 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers if ( !verbose ) output[strlen(output)-1] = '|'; - struct v4l2_cropcap cropcap; - memset( &cropcap, 0, sizeof(cropcap) ); - cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if ( vidioctl( vid_fd, VIDIOC_CROPCAP, &cropcap ) < 0 ) - { - Error( "Failed to query crop capabilities: %s", strerror(errno) ); - if ( verbose ) - sprintf( output, "Error, failed to query crop capabilities %s: %s\n", queryDevice, strerror(errno) ); - else - sprintf( output, "error%d\n", errno ); - return( false ); - } - if ( verbose ) - { - sprintf( output+strlen(output), "Crop Capabilities\n" ); - sprintf( output+strlen(output), " Bounds: %d x %d\n", cropcap.bounds.width, cropcap.bounds.height ); - sprintf( output+strlen(output), " Default: %d x %d\n", cropcap.defrect.width, cropcap.defrect.height ); - } - else - { - sprintf( output+strlen(output), "B:%dx%d|", cropcap.bounds.width, cropcap.bounds.height ); - } - - struct v4l2_crop crop; - memset( &crop, 0, sizeof(crop) ); - crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if ( vidioctl( vid_fd, VIDIOC_G_CROP, &crop ) < 0 ) - { - if ( errno != EINVAL ) - { - Error( "Failed to query crop: %s", strerror(errno) ); - if ( verbose ) - sprintf( output, "Error, failed to query crop %s: %s\n", queryDevice, strerror(errno) ); - else - sprintf( output, "error%d\n", errno ); - - /* Crop detection failure is not fatal and cropping is not used anyway, so no reason not to continue */ - /* return( false ); */ - } - else if ( verbose ) - { - Info( "Does not support VIDIOC_G_CROP"); - } - } - else - { - if ( verbose ) - sprintf( output+strlen(output), " Current: %d x %d\n", crop.c.width, crop.c.height ); - } + struct v4l2_cropcap cropcap; + memset( &cropcap, 0, sizeof(cropcap) ); + cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if ( vidioctl( vid_fd, VIDIOC_CROPCAP, &cropcap ) < 0 ) + { + if(errno != EINVAL) { + /* Failed querying crop capability, write error to the log and continue as if crop is not supported */ + Error( "Failed to query crop capabilities: %s", strerror(errno) ); + } + + if(verbose) { + sprintf( output+strlen(output), "Cropping is not supported"); + } else { + /* Send fake crop bounds to not confuse things parsing this, such as monitor probe */ + sprintf( output+strlen(output), "B:%dx%d|",0,0); + } + } else { + struct v4l2_crop crop; + memset( &crop, 0, sizeof(crop) ); + crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + if ( vidioctl( vid_fd, VIDIOC_G_CROP, &crop ) < 0 ) + { + if ( errno != EINVAL ) + { + /* Failed querying crop sizes, write error to the log and continue as if crop is not supported */ + Error( "Failed to query crop: %s", strerror(errno) ); + } + + if ( verbose ) { + sprintf( output+strlen(output), "Cropping is not supported"); + } else { + /* Send fake crop bounds to not confuse things parsing this, such as monitor probe */ + sprintf( output+strlen(output), "B:%dx%d|",0,0); + } + } else { + /* Cropping supported */ + if ( verbose ) { + sprintf( output+strlen(output), "Crop Capabilities\n" ); + sprintf( output+strlen(output), " Bounds: %d x %d\n", cropcap.bounds.width, cropcap.bounds.height ); + sprintf( output+strlen(output), " Default: %d x %d\n", cropcap.defrect.width, cropcap.defrect.height ); + sprintf( output+strlen(output), " Current: %d x %d\n", crop.c.width, crop.c.height ); + } else { + sprintf( output+strlen(output), "B:%dx%d|", cropcap.bounds.width, cropcap.bounds.height ); + } + } + } /* Crop code */ struct v4l2_input input; int inputIndex = 0; diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 4b143c279..7dc565b19 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -394,7 +394,6 @@ Monitor::Monitor( struct timeval *shared_timestamps = (struct timeval *)((char *)trigger_data + sizeof(TriggerData)); unsigned char *shared_images = (unsigned char *)((char *)shared_timestamps + (image_buffer_count*sizeof(struct timeval))); - /* This shouldn't be needed if the shared memory start address is multiple of 16, but just in case */ if(((unsigned long)shared_images % 16) != 0) { /* Align images buffer to nearest 16 byte boundary */ Debug(3,"Aligning shared memory images to the next 16 byte boundary"); @@ -405,7 +404,6 @@ Monitor::Monitor( { memset( mem_ptr, 0, mem_size ); shared_data->size = sizeof(SharedData); - shared_data->valid = true; shared_data->active = enabled; shared_data->signal = false; shared_data->state = IDLE; @@ -426,6 +424,7 @@ Monitor::Monitor( trigger_data->trigger_cause[0] = 0; trigger_data->trigger_text[0] = 0; trigger_data->trigger_showtext[0] = 0; + shared_data->valid = true; } else if ( purpose == ANALYSIS ) { @@ -507,7 +506,7 @@ Monitor::Monitor( Fatal( "Can't change to parent directory: %s", strerror(errno) ); } - while( shared_data->last_write_index == image_buffer_count ) + while( shared_data->last_write_index == image_buffer_count && shared_data->last_write_time == 0) { Warning( "Waiting for capture daemon" ); sleep( 1 ); @@ -941,7 +940,10 @@ void Monitor::DumpZoneImage( const char *zone_string ) Image *snap_image = snap->image; Image zone_image( *snap_image ); - zone_image.Colourise(ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB ); + if(zone_image.Colours() == ZM_COLOUR_GRAY8) { + zone_image.Colourise(ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB ); + } + for( int i = 0; i < n_zones; i++ ) { if ( exclude_id && (!extra_colour || extra_zone.getNumCoords()) && zones[i]->Id() == exclude_id ) diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 7b65265f2..a0674abd3 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -165,8 +165,8 @@ protected: int mem_size; unsigned char *mem_ptr; - SharedData *shared_data; - TriggerData *trigger_data; + volatile SharedData *shared_data; + volatile TriggerData *trigger_data; int last_state; int last_event; diff --git a/src/zm_remote_camera_rtsp.cpp b/src/zm_remote_camera_rtsp.cpp index 3b873e84e..ec4ce99cf 100644 --- a/src/zm_remote_camera_rtsp.cpp +++ b/src/zm_remote_camera_rtsp.cpp @@ -201,18 +201,14 @@ int RemoteCameraRtsp::PrimeCapture() } #if HAVE_LIBSWSCALE + if(!sws_isSupportedInput(mCodecContext->pix_fmt)) { + Fatal("swscale does not support the codec format"); + } + if(!sws_isSupportedOutput(imagePixFormat)) { Fatal("swscale does not support the target format"); } - if(config.cpu_extensions && sseversion >= 20) { - mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL ); - } else { - mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL ); - } - - if(mConvertContext == NULL) - Fatal( "Unable to create conversion context"); #else // HAVE_LIBSWSCALE Fatal( "You must compile ffmpeg with the --enable-swscale option to use RTSP cameras" ); #endif // HAVE_LIBSWSCALE @@ -237,6 +233,7 @@ int RemoteCameraRtsp::Capture( Image &image ) { AVPacket packet; uint8_t* directbuffer; + int frameComplete = false; /* Request a writeable buffer of the target image */ directbuffer = image.WriteBuffer(width, height, colours, subpixelorder); @@ -261,8 +258,8 @@ int RemoteCameraRtsp::Capture( Image &image ) return( -1 ); av_init_packet( &packet ); - int frameComplete = false; +<<<<<<< HEAD while ( !frameComplete ) { packet.data = buffer.head(); @@ -282,22 +279,60 @@ int RemoteCameraRtsp::Capture( Image &image ) if ( frameComplete ) { Debug( 3, "Got frame %d", frameCount ); +======= + while ( !frameComplete && buffer.size() > 0 ) + { + packet.data = buffer.head(); + packet.size = buffer.size(); + int len = avcodec_decode_video2( mCodecContext, mRawFrame, &frameComplete, &packet ); + if ( len < 0 ) + { + Error( "Error while decoding frame %d", frameCount ); + Hexdump( ZM_DBG_ERR, buffer.head(), buffer.size()>256?256:buffer.size() ); + buffer.clear(); + continue; + } + Debug( 2, "Frame: %d - %d/%d", frameCount, len, buffer.size() ); + //if ( buffer.size() < 400 ) + //Hexdump( 0, buffer.head(), buffer.size() ); + + buffer -= len; + + } + if ( frameComplete ) { + + Debug( 3, "Got frame %d", frameCount ); +>>>>>>> Some small changes - avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height); + avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height); #if HAVE_LIBSWSCALE - if ( sws_scale( mConvertContext, mRawFrame->data, mRawFrame->linesize, 0, mCodecContext->height, mFrame->data, mFrame->linesize ) < 0 ) - Fatal( "Unable to convert raw format %u to target format %u at frame %d", mCodecContext->pix_fmt, imagePixFormat, frameCount ); + if(mConvertContext == NULL) { + if(config.cpu_extensions && sseversion >= 20) { + mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC | SWS_CPU_CAPS_SSE2, NULL, NULL, NULL ); + } else { + mConvertContext = sws_getContext( mCodecContext->width, mCodecContext->height, mCodecContext->pix_fmt, width, height, imagePixFormat, SWS_BICUBIC, NULL, NULL, NULL ); + } + if(mConvertContext == NULL) + Fatal( "Unable to create conversion context"); + } + + if ( sws_scale( mConvertContext, mRawFrame->data, mRawFrame->linesize, 0, mCodecContext->height, mFrame->data, mFrame->linesize ) < 0 ) + Fatal( "Unable to convert raw format %u to target format %u at frame %d", mCodecContext->pix_fmt, imagePixFormat, frameCount ); #else // HAVE_LIBSWSCALE - Fatal( "You must compile ffmpeg with the --enable-swscale option to use RTSP cameras" ); + Fatal( "You must compile ffmpeg with the --enable-swscale option to use RTSP cameras" ); #endif // HAVE_LIBSWSCALE - frameCount++; - } - buffer -= len; - } - av_free_packet( &packet ); - } + frameCount++; + + } /* frame complete */ + + av_free_packet( &packet ); + } /* getFrame() */ + + if(frameComplete) + return (0); + } return (0) ; } diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index 95541b116..c66e6c517 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -153,30 +153,22 @@ bool Zone::CheckAlarms( const Image *delta_image ) Debug( 5, "Checking for alarmed pixels" ); uint8_t *pdiff; const uint8_t *ppoly; - // Create an upper margin - if ( lo_y > 0 ) - { - lo_x = ranges[0].lo_x; - if ( lo_x > 0 ) - lo_x--; - hi_x = ranges[0].hi_x; - if ( hi_x < (diff_width-1) ) - hi_x++; - pdiff = diff_buff + ( lo_x * (lo_y-1) ); - memset( pdiff, BLACK, (hi_x-lo_x)+1 ); - } + uint8_t calc_max_pixel_threshold = 255; /* To be able to remove one check from the loop below */ + if(max_pixel_threshold) + calc_max_pixel_threshold = max_pixel_threshold; + for ( int y = lo_y, py = 0; y <= hi_y; y++, py++ ) { lo_x = ranges[py].lo_x; hi_x = ranges[py].hi_x; Debug( 7, "Checking line %d from %d -> %d", y, lo_x, hi_x ); - pdiff = diff_buff + (diff_width * y); + pdiff = diff_buff + ((diff_width * y) + lo_x); ppoly = pg_image->Buffer( ranges[py].off_x, py ); - pdiff += lo_x; + for ( int x = lo_x; x <= hi_x; x++, pdiff++, ppoly++ ) { - if ( *ppoly && (*pdiff > min_pixel_threshold) && (!max_pixel_threshold || (*pdiff < max_pixel_threshold)) ) + if ( *ppoly && (*pdiff > min_pixel_threshold) && (*pdiff <= calc_max_pixel_threshold) ) { alarm_pixels++; pixel_diff_count += *pdiff; @@ -228,16 +220,15 @@ bool Zone::CheckAlarms( const Image *delta_image ) if ( bx > 1 || by > 1 ) { // Now remove any pixels smaller than our filter size - unsigned char *pdiff; unsigned char *cpdiff; int ldx, hdx, ldy, hdy; bool block; for ( int y = lo_y, py = 0; y <= hi_y; y++, py++ ) { - int lo_x = ranges[py].lo_x; - int hi_x = ranges[py].hi_x; + lo_x = ranges[py].lo_x; + hi_x = ranges[py].hi_x; - pdiff = diff_buff + (lo_x * y); + pdiff = diff_buff + ((diff_width * y) + lo_x); for ( int x = lo_x; x <= hi_x; x++, pdiff++ ) { @@ -258,7 +249,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) { for ( int dx2 = 0; block && dx2 < bx; dx2++ ) { - cpdiff = diff_buff + ( (x+dx+dx2) * (y+dy+dy2) ); + cpdiff = diff_buff + (((y+dy+dy2)*diff_width) + (x+dx+dx2)); if ( !*cpdiff ) { block = false; @@ -315,7 +306,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) typedef struct { unsigned char tag; int count; int lo_x; int hi_x; int lo_y; int hi_y; } BlobStats; BlobStats blob_stats[256]; memset( blob_stats, 0, sizeof(BlobStats)*256 ); - unsigned char *pdiff, *spdiff; + uint8_t *spdiff; int last_x, last_y; BlobStats *bsx, *bsy; BlobStats *bsm, *bss; @@ -324,7 +315,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) int lo_x = ranges[py].lo_x; int hi_x = ranges[py].hi_x; - pdiff = diff_buff + ( lo_x * y ); + pdiff = diff_buff + ((diff_width * y) + lo_x); for ( int x = lo_x; x <= hi_x; x++, pdiff++ ) { if ( *pdiff == WHITE ) @@ -370,7 +361,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) Debug( 9, "Changing %d(%d), %d->%d", sy, psy, lo_sx, hi_sx ); Debug( 9, "Range %d(%d), %d->%d", sy, psy, ranges[psy].lo_x, ranges[psy].hi_x ); - spdiff = diff_buff + ( lo_sx * sy ); + spdiff = diff_buff + ((diff_width * sy) + lo_sx); for ( int sx = lo_sx; sx <= hi_sx; sx++, spdiff++ ) { Debug( 9, "Pixel at %d,%d (%p) is %d", sx, sy, spdiff, *spdiff ); @@ -453,7 +444,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) { for ( int sy = bs->lo_y; sy <= bs->hi_y; sy++ ) { - unsigned char *spdiff = diff_buff + ( bs->lo_x * sy ); + spdiff = diff_buff + ((diff_width * sy) + bs->lo_x); for ( int sx = bs->lo_x; sx <= bs->hi_x; sx++, spdiff++ ) { if ( *spdiff == bs->tag ) @@ -530,7 +521,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) { for ( int sy = bs->lo_y; sy <= bs->hi_y; sy++ ) { - unsigned char *spdiff = diff_buff + ( bs->lo_x * sy ); + spdiff = diff_buff + ((diff_width * sy) + bs->lo_x); for ( int sx = bs->lo_x; sx <= bs->hi_x; sx++, spdiff++ ) { if ( *spdiff == bs->tag ) @@ -603,7 +594,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) for ( int sy = bs->lo_y; sy <= bs->hi_y; sy++ ) { - unsigned char *spdiff = diff_buff + ( bs->lo_x * sy ); + spdiff = diff_buff + ((diff_width * sy) + bs->lo_x); for ( int sx = bs->lo_x; sx <= bs->hi_x; sx++, spdiff++ ) { if ( *spdiff == bs->tag ) @@ -676,7 +667,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) // First mask out anything we don't want for ( int y = lo_y, py = 0; y <= hi_y; y++, py++ ) { - pdiff = diff_buff + ( lo_x * y ); + pdiff = diff_buff + ((diff_width * y) + lo_x); int lo_x2 = ranges[py].lo_x; int hi_x2 = ranges[py].hi_x; diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index e38a1b9a6..23629e352 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -94,7 +94,7 @@ else 'MaxFPS' => "", 'AlarmMaxFPS' => "", 'FPSReportInterval' => 1000, - 'RefBlendPerc' => 7, + 'RefBlendPerc' => 12, 'DefaultView' => 'Events', 'DefaultRate' => '100', 'DefaultScale' => '100', From 2fd6e99ec53b79e4db6932dfb4a9dc7f82dfcd47 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sat, 11 Jun 2011 11:50:53 +0300 Subject: [PATCH 12/56] 1) Rebased to 1.24.4 2) Reverted to stock zmdc.pl.in and zmwatch.pl.in because the bugs are fixed 3) Updated configure and Makefile files --- configure | 11047 ---------------------------------------- scripts/zmdc.pl.in | 3 - scripts/zmwatch.pl.in | 8 +- src/Makefile.in | 2 +- 4 files changed, 4 insertions(+), 11056 deletions(-) delete mode 100755 configure diff --git a/configure b/configure deleted file mode 100755 index e5fa01dea..000000000 --- a/configure +++ /dev/null @@ -1,11047 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for zm 1.25.0. -# -# Report bugs to . -# -# -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org and -$0: http://www.zoneminder.com/forums/ - Please check FAQ -$0: first about your system, including any error possibly -$0: output before this message. Then install a modern -$0: shell, or manually run the script under such a shell if -$0: you do have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. -as_fn_error () -{ - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 - fi - $as_echo "$as_me: error: $1" >&2 - as_fn_exit $as_status -} # as_fn_error - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -test -n "$DJDIR" || exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= - -# Identity of this package. -PACKAGE_NAME='zm' -PACKAGE_TARNAME='ZoneMinder' -PACKAGE_VERSION='1.25.0' -PACKAGE_STRING='zm 1.25.0' -PACKAGE_BUGREPORT='http://www.zoneminder.com/forums/ - Please check FAQ first' -PACKAGE_URL='http://www.zoneminder.com/downloads.html' - -ac_unique_file="src/zm.h" -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -ac_header_list= -ac_subst_vars='am__EXEEXT_FALSE -am__EXEEXT_TRUE -LTLIBOBJS -EXTRA_PERL_LIB -PERL_MM_PARMS -ZM_CONFIG -SYSCONFDIR -ZM_PID -LIBDIR -BINDIR -PERL -ZM_PCRE -ZM_HAS_V4L -ZM_HAS_V4L2 -ZM_HAS_V4L1 -ALLOCA -PATH_NETPBM -OPT_NETPBM -PATH_FFMPEG -OPT_FFMPEG -POW_LIB -LIBOBJS -EGREP -GREP -CXXCPP -RANLIB -LN_S -am__fastdepCC_FALSE -am__fastdepCC_TRUE -CCDEPMODE -ac_ct_CC -CFLAGS -CC -am__fastdepCXX_FALSE -am__fastdepCXX_TRUE -CXXDEPMODE -AMDEPBACKSLASH -AMDEP_FALSE -AMDEP_TRUE -am__quote -am__include -DEPDIR -OBJEXT -EXEEXT -ac_ct_CXX -CPPFLAGS -LDFLAGS -CXXFLAGS -CXX -ENABLE_MMAP -WEB_HOST -WEB_GROUP -WEB_USER -CGI_PREFIX -WEB_PREFIX -EXTRA_LIBS -FFMPEG_CFLAGS -FFMPEG_LIBS -FFMPEG_PREFIX -MYSQL_CFLAGS -MYSQL_LIBS -MYSQL_PREFIX -LIB_ARCH -ZM_LOGDIR -ZM_TMPDIR -ZM_RUNDIR -ZM_MYSQL_ENGINE -ZM_SSL_LIB -ZM_DB_PASS -ZM_DB_USER -ZM_DB_NAME -ZM_DB_HOST -TIME_BUILD -PATH_BUILD -am__untar -am__tar -AMTAR -am__leading_dot -SET_MAKE -AWK -mkdir_p -MKDIR_P -INSTALL_STRIP_PROGRAM -STRIP -install_sh -MAKEINFO -AUTOHEADER -AUTOMAKE -AUTOCONF -ACLOCAL -VERSION -PACKAGE -CYGPATH_W -am__isrc -INSTALL_DATA -INSTALL_SCRIPT -INSTALL_PROGRAM -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_URL -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -with_libarch -with_mysql -with_ffmpeg -with_extralibs -with_webdir -with_cgidir -with_webuser -with_webgroup -with_webhost -enable_debug -enable_crashtrace -enable_mmap -enable_dependency_tracking -' - ac_precious_vars='build_alias -host_alias -target_alias -ZM_DB_HOST -ZM_DB_NAME -ZM_DB_USER -ZM_DB_PASS -ZM_SSL_LIB -ZM_MYSQL_ENGINE -ZM_RUNDIR -ZM_TMPDIR -ZM_LOGDIR -CXX -CXXFLAGS -LDFLAGS -LIBS -CPPFLAGS -CCC -CC -CFLAGS -CXXCPP' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) as_fn_error "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information." - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error "pwd does not report name of working directory" - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -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 zm 1.25.0 to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/ZoneMinder] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF - -Program names: - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM run sed PROGRAM on installed program names -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of zm 1.25.0:";; - esac - cat <<\_ACEOF - -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-debug= enable or disable debug, default enabled - --enable-crashtrace= enable or disabled crash tracing, default enabled - --enable-mmap= enable or disabled mapped memory versus shared memory, default mapped - --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors - -Optional Packages: - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-libarch= architecture library path to use, default lib - --with-mysql= prefix of MySQL installation, default /usr - --with-ffmpeg= prefix of ffmpeg root directory for libavcodec etc, default /usr - --with-extralibs="" string containing extra libraries to pass to link, default empty - --with-webdir= prefix of web directory - --with-cgidir= prefix of cgi directory - --with-webuser= name of web user, default apache - --with-webgroup= name of web group, default apache - --with-webhost= name of web hostname, default zm.local - -Some influential environment variables: - ZM_DB_HOST Hostname where ZoneMinder database located, default localhost - ZM_DB_NAME Name of ZoneMinder database, default zm - ZM_DB_USER Name of ZoneMinder database user, default zmuser - ZM_DB_PASS Password of ZoneMinder database user, default zmpass - ZM_SSL_LIB Library to use for ssl functions, default gnutls - ZM_MYSQL_ENGINE - MySQL engine to use with database, default MyISAM - ZM_RUNDIR Location of transient process files, default /var/run/zm - ZM_TMPDIR Location of temporary files, default /tmp/zm - ZM_LOGDIR Location of generated log files, default /var/log/zm - CXX C++ compiler command - CXXFLAGS C++ compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CC C compiler command - CFLAGS C compiler flags - CXXCPP C++ preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to . -zm home page: . -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -zm configure 1.25.0 -generated by GNU Autoconf 2.65 - -Copyright (C) 2009 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_cxx_try_compile LINENO -# ---------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_compile - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_cxx_check_type LINENO TYPE VAR INCLUDES -# --------------------------------------------- -# Tests whether TYPE exists after having included INCLUDES, setting cache -# variable VAR accordingly. -ac_fn_cxx_check_type () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof ($2)) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof (($2))) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - -else - eval "$3=yes" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_cxx_check_type - -# ac_fn_cxx_try_cpp LINENO -# ------------------------ -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } >/dev/null && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_cpp - -# ac_fn_cxx_try_run LINENO -# ------------------------ -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_cxx_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_run - -# ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES -# --------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_cxx_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_cxx_check_header_compile - -# ac_fn_cxx_check_member LINENO AGGR MEMBER VAR INCLUDES -# ------------------------------------------------------ -# Tries to find if the field MEMBER exists in type AGGR, after including -# INCLUDES, setting cache variable VAR accordingly. -ac_fn_cxx_check_member () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 -$as_echo_n "checking for $2.$3... " >&6; } -if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main () -{ -static $2 ac_aggr; -if (ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - eval "$4=yes" -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main () -{ -static $2 ac_aggr; -if (sizeof ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - eval "$4=yes" -else - eval "$4=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$4 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_cxx_check_member - -# ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES -# --------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_cxx_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} -( cat <<\_ASBOX -## ------------------------------------------------------------------------- ## -## Report this to http://www.zoneminder.com/forums/ - Please check FAQ first ## -## ------------------------------------------------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_cxx_check_header_mongrel - -# ac_fn_cxx_try_link LINENO -# ------------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_link - -# ac_fn_cxx_check_func LINENO FUNC VAR -# ------------------------------------ -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_cxx_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_cxx_check_func - -# ac_fn_cxx_check_decl LINENO SYMBOL VAR -# -------------------------------------- -# Tests whether SYMBOL is declared, setting cache variable VAR accordingly. -ac_fn_cxx_check_decl () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5 -$as_echo_n "checking whether $2 is declared... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -#ifndef $2 - (void) $2; -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_cxx_check_decl -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 zm $as_me 1.25.0, which was -generated by GNU Autoconf 2.65. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" - done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append ac_configure_args1 " '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - cat <<\_ASBOX -## ---------------- ## -## Cache variables. ## -## ---------------- ## -_ASBOX - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - cat <<\_ASBOX -## ----------------- ## -## Output variables. ## -## ----------------- ## -_ASBOX - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## -## File substitutions. ## -## ------------------- ## -_ASBOX - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## -## confdefs.h. ## -## ----------- ## -_ASBOX - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -$as_echo "/* confdefs.h */" > confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -as_fn_append ac_header_list " stdlib.h" -as_fn_append ac_header_list " unistd.h" -as_fn_append ac_header_list " sys/param.h" -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -am__api_version='1.11' - -ac_aux_dir= -for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/$ac_t -c" - break 2 - fi - done -done -if test -z "$ac_aux_dir"; then - as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 -fi - -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -# Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -$as_echo_n "checking for a BSD-compatible install... " >&6; } -if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in #(( - ./ | .// | /[cC]/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - rm -rf conftest.one conftest.two conftest.dir - echo one > conftest.one - echo two > conftest.two - mkdir conftest.dir - if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && - test -s conftest.one && test -s conftest.two && - test -s conftest.dir/conftest.one && - test -s conftest.dir/conftest.two - then - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - fi - done - done - ;; -esac - - done -IFS=$as_save_IFS - -rm -rf conftest.one conftest.two conftest.dir - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -$as_echo "$INSTALL" >&6; } - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 -$as_echo_n "checking whether build environment is sane... " >&6; } -# Just in case -sleep 1 -echo timestamp > conftest.file -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[\\\"\#\$\&\'\`$am_lf]*) - as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; -esac -case $srcdir in - *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; -esac - -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error "ls -t appears to fail. Make sure there is not a broken -alias in your environment" "$LINENO" 5 - fi - - test "$2" = conftest.file - ) -then - # Ok. - : -else - as_fn_error "newly created file is older than distributed files! -Check your system clock" "$LINENO" 5 -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -test "$program_prefix" != NONE && - program_transform_name="s&^&$program_prefix&;$program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s&\$&$program_suffix&;$program_transform_name" -# Double any \ or $. -# By default was `s,x,x', remove it if useless. -ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' -program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` - -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` - -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 -$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} -fi - -if test x"${install_sh}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac -fi - -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -if test "$cross_compiling" != no; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. -set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$STRIP"; then - ac_cv_prog_STRIP="$STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -STRIP=$ac_cv_prog_STRIP -if test -n "$STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_STRIP"; then - ac_ct_STRIP=$STRIP - # Extract the first word of "strip", so it can be a program name with args. -set dummy strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_STRIP"; then - ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP -if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_STRIP" = x; then - STRIP=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - STRIP=$ac_ct_STRIP - fi -else - STRIP="$ac_cv_prog_STRIP" -fi - -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 -$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } -if test -z "$MKDIR_P"; then - if test "${ac_cv_path_mkdir+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in mkdir gmkdir; do - for ac_exec_ext in '' $ac_executable_extensions; do - { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue - case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( - 'mkdir (GNU coreutils) '* | \ - 'mkdir (coreutils) '* | \ - 'mkdir (fileutils) '4.1*) - ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext - break 3;; - esac - done - done - done -IFS=$as_save_IFS - -fi - - test -d ./--version && rmdir ./--version - if test "${ac_cv_path_mkdir+set}" = set; then - MKDIR_P="$ac_cv_path_mkdir -p" - else - # As a last resort, use the slow shell script. Don't cache a - # value for MKDIR_P within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - MKDIR_P="$ac_install_sh -d" - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 -$as_echo "$MKDIR_P" >&6; } - -mkdir_p="$MKDIR_P" -case $mkdir_p in - [\\/$]* | ?:[\\/]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac - -for ac_prog in gawk mawk nawk awk -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AWK="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 -$as_echo "$AWK" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AWK" && break -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - -rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. -else - am__leading_dot=_ -fi -rmdir .tst 2>/dev/null - -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - am__isrc=' -I$(srcdir)' - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi - - -# Define the identity of the package. - PACKAGE='ZoneMinder' - VERSION='1.25.0' - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - -# Some tools Automake needs. - -ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} - - -AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} - - -AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} - - -AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} - - -MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} - -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -# Always define AMTAR for backward compatibility. - -AMTAR=${AMTAR-"${am_missing_run}tar"} - -am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' - - - - - - -ac_config_headers="$ac_config_headers config.h" - - -PATH_BUILD=`pwd` - -TIME_BUILD=`date +'%s'` - - - - - - - - - - - - -if test "$ZM_DB_HOST" == ""; then - ZM_DB_HOST=localhost - -fi -if test "$ZM_DB_NAME" == ""; then - ZM_DB_NAME=zm - -fi -if test "$ZM_DB_USER" == ""; then - ZM_DB_USER=zmuser - -fi -if test "$ZM_DB_PASS" == ""; then - ZM_DB_PASS=zmpass - -fi -if test "$ZM_SSL_LIB" == ""; then - ZM_SSL_LIB=gnutls - -fi -if test "$ZM_MYSQL_ENGINE" == ""; then - ZM_MYSQL_ENGINE=MyISAM - -fi -if test "$ZM_RUNDIR" == ""; then - ZM_RUNDIR=/var/run/zm - -fi -if test "$ZM_TMPDIR" == ""; then - ZM_TMPDIR=/tmp/zm - -fi -if test "$ZM_LOGDIR" == ""; then - ZM_LOGDIR=/var/log/zm - -fi - -LIB_ARCH=lib - -# Check whether --with-libarch was given. -if test "${with_libarch+set}" = set; then : - withval=$with_libarch; LIB_ARCH=$with_libarch -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-libarch option. - This tells configure where to find architecture specific libraries. - The default of 'lib' is usually ok but 64 bit machines may require lib64. - e.g. --with-libarch=lib or --with-libarch=lib64" >&5 -$as_echo "$as_me: WARNING: You can call configure with the --with-libarch option. - This tells configure where to find architecture specific libraries. - The default of 'lib' is usually ok but 64 bit machines may require lib64. - e.g. --with-libarch=lib or --with-libarch=lib64" >&2;} - -fi - - - -MYSQL_PREFIX=/usr - -# Check whether --with-mysql was given. -if test "${with_mysql+set}" = set; then : - withval=$with_mysql; MYSQL_PREFIX=$with_mysql -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-mysql option. - This tells configure where to find the MySql C library and headers if configure cannot - locate them automatically. - e.g. --with-mysql=/usr/local or --with-mysql=/usr" >&5 -$as_echo "$as_me: WARNING: You can call configure with the --with-mysql option. - This tells configure where to find the MySql C library and headers if configure cannot - locate them automatically. - e.g. --with-mysql=/usr/local or --with-mysql=/usr" >&2;} - -fi - - -MYSQL_LIBS="-L${MYSQL_PREFIX}/${LIB_ARCH}/mysql" -MYSQL_CFLAGS="-I${MYSQL_PREFIX}/include" - - - -LDFLAGS="${MYSQL_LIBS} $LDFLAGS" - -FFMPEG_PREFIX=/usr - -# Check whether --with-ffmpeg was given. -if test "${with_ffmpeg+set}" = set; then : - withval=$with_ffmpeg; FFMPEG_PREFIX=$with_ffmpeg -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-ffmpeg option. - This tells configure where to find the ffmpeg root directory within which are the libavcodec - and libavformat files that can be used to build true MPEG streaming into ZoneMinder. Ensure that - your copy of ffmpeg has installed libraries as well as binaries (use 'make installlib'). If you - are using a local install of ffmpeg you may have to remove or rename a previous real installation - as the headers and libraries from that will probably be picked up before your local copy. - e.g. --with-ffmpeg=/usr/local" >&5 -$as_echo "$as_me: WARNING: You can call configure with the --with-ffmpeg option. - This tells configure where to find the ffmpeg root directory within which are the libavcodec - and libavformat files that can be used to build true MPEG streaming into ZoneMinder. Ensure that - your copy of ffmpeg has installed libraries as well as binaries (use 'make installlib'). If you - are using a local install of ffmpeg you may have to remove or rename a previous real installation - as the headers and libraries from that will probably be picked up before your local copy. - e.g. --with-ffmpeg=/usr/local" >&2;} - -fi - - -FFMPEG_LIBS="-L${FFMPEG_PREFIX}/${LIB_ARCH}" -FFMPEG_CFLAGS="-I${FFMPEG_PREFIX}/include" - - - -LDFLAGS="${FFMPEG_LIBS} $LDFLAGS" -CFLAGS="${FFMPEG_CFLAGS} $CFLAGS" -CPPFLAGS="${FFMPEG_CFLAGS} $CPPFLAGS" - -EXTRA_LIBS= - -# Check whether --with-extralibs was given. -if test "${with_extralibs+set}" = set; then : - withval=$with_extralibs; EXTRA_LIBS=$with_extralibs -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-extralibs option. - Ordinarily you will need to use this option only when your copy of ffmpeg has been built - with support for additional formats and you would use this option to detail which additional - libraries ffmpeg was built with so that it is able to link successfully with ZoneMinder. - You will need to wrap this option in quotes if it contains any spaces. - e.g. --with-extralibs=\"-lmp3lame\"" >&5 -$as_echo "$as_me: WARNING: You can call configure with the --with-extralibs option. - Ordinarily you will need to use this option only when your copy of ffmpeg has been built - with support for additional formats and you would use this option to detail which additional - libraries ffmpeg was built with so that it is able to link successfully with ZoneMinder. - You will need to wrap this option in quotes if it contains any spaces. - e.g. --with-extralibs=\"-lmp3lame\"" >&2;} - -fi - - - -LDFLAGS="$LDFLAGS ${EXTRA_LIBS}" - - -# Check whether --with-webdir was given. -if test "${with_webdir+set}" = set; then : - withval=$with_webdir; WEB_PREFIX=$with_webdir -else - as_fn_error "You must call configure with the --with-webdir option. - This tells configure where to install PHP and web files and scripts. - e.g. --with-webdir=/var/www/html or --with-webdir=/www/vhtdocs/" "$LINENO" 5 - -fi - - - - -# Check whether --with-cgidir was given. -if test "${with_cgidir+set}" = set; then : - withval=$with_cgidir; CGI_PREFIX=$with_cgidir -else - as_fn_error "You must call configure with the --with-cgidir option. - This tells configure where to install cgi files and scripts. - e.g. --with-cgidir=/var/www/cgi-bin or --with-webdir=/www/vhtdocs//cgi-bin" "$LINENO" 5 - -fi - - - -WEB_USER=apache - -# Check whether --with-webuser was given. -if test "${with_webuser+set}" = set; then : - withval=$with_webuser; WEB_USER=$with_webuser -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-webuser option. - This tells configure what the user name of the web user is if it is not the default of 'apache'. - e.g. --with-webuser=apache or --with-webuser=web" >&5 -$as_echo "$as_me: WARNING: You can call configure with the --with-webuser option. - This tells configure what the user name of the web user is if it is not the default of 'apache'. - e.g. --with-webuser=apache or --with-webuser=web" >&2;} - -fi - - - -WEB_GROUP=apache - -# Check whether --with-webgroup was given. -if test "${with_webgroup+set}" = set; then : - withval=$with_webgroup; WEB_GROUP=$with_webgroup -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-webgroup option. - This tells configure what the group name of the web group is if it is not the default of 'apache'. - e.g. --with-webgroup=apache or --with-webgroup=web" >&5 -$as_echo "$as_me: WARNING: You can call configure with the --with-webgroup option. - This tells configure what the group name of the web group is if it is not the default of 'apache'. - e.g. --with-webgroup=apache or --with-webgroup=web" >&2;} - -fi - - - -WEB_HOST=zm.local - -# Check whether --with-webhost was given. -if test "${with_webhost+set}" = set; then : - withval=$with_webhost; WEB_HOST=$with_webhost -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-webhost option. - This tells configure what the host name is for name based virtual hosting. This is only used to populate the sample web/zmHttpd.conf file. - e.g. --with-webhost=zm.localdomain" >&5 -$as_echo "$as_me: WARNING: You can call configure with the --with-webhost option. - This tells configure what the host name is for name based virtual hosting. This is only used to populate the sample web/zmHttpd.conf file. - e.g. --with-webhost=zm.localdomain" >&2;} - -fi - - - -ENABLE_DEBUG=yes -# Check whether --enable-debug was given. -if test "${enable_debug+set}" = set; then : - enableval=$enable_debug; ENABLE_DEBUG=$enable_debug -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --enable-debug= or --disable-debug option. - This tells configure whether to compile ZoneMinder with debug included. Although debug is included - by default it is not output unless explicitly switched on elsewhere. These checks may induce a - small penalty on performance and if you are after squeezing the maximum possible performance out - of ZoneMinder you may use this switch to prevent debug from being compiled in. - e.g. --enable-debug=yes or --disable-debug" >&5 -$as_echo "$as_me: WARNING: You can call configure with the --enable-debug= or --disable-debug option. - This tells configure whether to compile ZoneMinder with debug included. Although debug is included - by default it is not output unless explicitly switched on elsewhere. These checks may induce a - small penalty on performance and if you are after squeezing the maximum possible performance out - of ZoneMinder you may use this switch to prevent debug from being compiled in. - e.g. --enable-debug=yes or --disable-debug" >&2;} - -fi - -if test "$ENABLE_DEBUG" != "yes"; then - -$as_echo "#define ZM_DBG_OFF 1" >>confdefs.h - -fi - -ENABLE_CRASHTRACE=yes -# Check whether --enable-crashtrace was given. -if test "${enable_crashtrace+set}" = set; then : - enableval=$enable_crashtrace; ENABLE_CRASHTRACE=$enable_crashtrace -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --enable-crashtrace= or --disable-crashtrace option. - This tells configure whether to compile ZoneMinder with crash tracing included. This allows a - dump of the stack trace when a ZoneMinder binary crashes or is killed by an unexpected signal. - Although this should work on most systems it does rely on un(or loosely) documented features and - so should be regarded as experimental. If you experience problems compiling zm_signal.cpp or - ZoneMinder binaries fail to shut down correctly then you should probably disable this feature. - e.g. --enable-crashtrace=yes or --disable-crashtrace" >&5 -$as_echo "$as_me: WARNING: You can call configure with the --enable-crashtrace= or --disable-crashtrace option. - This tells configure whether to compile ZoneMinder with crash tracing included. This allows a - dump of the stack trace when a ZoneMinder binary crashes or is killed by an unexpected signal. - Although this should work on most systems it does rely on un(or loosely) documented features and - so should be regarded as experimental. If you experience problems compiling zm_signal.cpp or - ZoneMinder binaries fail to shut down correctly then you should probably disable this feature. - e.g. --enable-crashtrace=yes or --disable-crashtrace" >&2;} - -fi - -if test "$ENABLE_CRASHTRACE" != "yes"; then - -$as_echo "#define ZM_NO_CRASHTRACE 1" >>confdefs.h - -fi - -ENABLE_MMAP=yes -# Check whether --enable-mmap was given. -if test "${enable_mmap+set}" = set; then : - enableval=$enable_mmap; ENABLE_MMAP=$enable_mmap -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --enable-mmap= or --disable-mmap option. - This tells configure whether to compile ZoneMinder with mmap support rather than IPC shared - memory. This is a feature that uses memory mapped into files which all processes can share. - Memory mapping requires less configuration and is more flexible than shared memory but may - slow down your system unless the mapped files are configured to reside on a fast or RAM based - filesystem which will normally be the case by default. - e.g. --enable-mmap=yes or --disable-mmap" >&5 -$as_echo "$as_me: WARNING: You can call configure with the --enable-mmap= or --disable-mmap option. - This tells configure whether to compile ZoneMinder with mmap support rather than IPC shared - memory. This is a feature that uses memory mapped into files which all processes can share. - Memory mapping requires less configuration and is more flexible than shared memory but may - slow down your system unless the mapped files are configured to reside on a fast or RAM based - filesystem which will normally be the case by default. - e.g. --enable-mmap=yes or --disable-mmap" >&2;} - -fi - -if test "$ENABLE_MMAP" == "yes"; then - -$as_echo "#define ZM_MEM_MAPPED 1" >>confdefs.h - -else - -$as_echo "#define ZM_MEM_MAPPED 0" >>confdefs.h - -fi - - -# Compiler -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - -# Checks for programs. -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -z "$CXX"; then - if test -n "$CCC"; then - CXX=$CCC - else - if test -n "$ac_tool_prefix"; then - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CXX+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 -$as_echo "$CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CXX" && break - done -fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 -$as_echo "$ac_ct_CXX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CXX" && break -done - - if test "x$ac_ct_CXX" = x; then - CXX="g++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi -fi - - fi -fi -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 -$as_echo_n "checking whether the C++ compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "C++ compiler cannot create executables -See \`config.log' for more details." "$LINENO" 5; }; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 -$as_echo_n "checking for C++ compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run C++ compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of object files: cannot compile -See \`config.log' for more details." "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 -$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 -$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GXX=yes -else - GXX= -fi -ac_test_CXXFLAGS=${CXXFLAGS+set} -ac_save_CXXFLAGS=$CXXFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 -$as_echo_n "checking whether $CXX accepts -g... " >&6; } -if test "${ac_cv_prog_cxx_g+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_save_cxx_werror_flag=$ac_cxx_werror_flag - ac_cxx_werror_flag=yes - ac_cv_prog_cxx_g=no - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -else - CXXFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - -else - ac_cxx_werror_flag=$ac_save_cxx_werror_flag - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_prog_cxx_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cxx_werror_flag=$ac_save_cxx_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 -$as_echo "$ac_cv_prog_cxx_g" >&6; } -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -DEPDIR="${am__leading_dot}deps" - -ac_config_commands="$ac_config_commands depfiles" - - -am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 -$as_echo_n "checking for style of include used by $am_make... " >&6; } -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from `make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 -$as_echo "$_am_result" >&6; } -rm -f confinc confmf - -# Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then : - enableval=$enable_dependency_tracking; -fi - -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi - if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' -else - AMDEP_TRUE='#' - AMDEP_FALSE= -fi - - - -depcc="$CXX" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CXX_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvisualcpp | msvcmsys) - # This compiler won't grok `-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CXX_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CXX_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } -CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then - am__fastdepCXX_TRUE= - am__fastdepCXX_FALSE='#' -else - am__fastdepCXX_TRUE='#' - am__fastdepCXX_FALSE= -fi - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "no acceptable C compiler found in \$PATH -See \`config.log' for more details." "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - -depcc="$CC" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvisualcpp | msvcmsys) - # This compiler won't grok `-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CC_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CC_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } -CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then - am__fastdepCC_TRUE= - am__fastdepCC_FALSE='#' -else - am__fastdepCC_TRUE='#' - am__fastdepCC_FALSE= -fi - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 -$as_echo_n "checking whether ln -s works... " >&6; } -LN_S=$as_ln_s -if test "$LN_S" = "ln -s"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 -$as_echo "no, using $LN_S" >&6; } -fi - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_RANLIB+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -$as_echo "$RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -$as_echo "$ac_ct_RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_RANLIB" = x; then - RANLIB=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - RANLIB=$ac_ct_RANLIB - fi -else - RANLIB="$ac_cv_prog_RANLIB" -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - - -# Checks for typedefs, structures, and compiler characteristics. - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 -$as_echo_n "checking how to run the C++ preprocessor... " >&6; } -if test -z "$CXXCPP"; then - if test "${ac_cv_prog_CXXCPP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CXXCPP needs to be expanded - for CXXCPP in "$CXX -E" "/lib/cpp" - do - ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CXXCPP=$CXXCPP - -fi - CXXCPP=$ac_cv_prog_CXXCPP -else - ac_cv_prog_CXXCPP=$CXXCPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 -$as_echo "$CXXCPP" >&6; } -ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details." "$LINENO" 5; } -fi - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_cxx_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 -$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } -if test "${ac_cv_header_stdbool_h+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifndef bool - "error: bool is not defined" -#endif -#ifndef false - "error: false is not defined" -#endif -#if false - "error: false is not 0" -#endif -#ifndef true - "error: true is not defined" -#endif -#if true != 1 - "error: true is not 1" -#endif -#ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" -#endif - - struct s { _Bool s: 1; _Bool t; } s; - - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - bool e = &s; - char f[(_Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (_Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; - /* The following fails for - HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ - _Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; -# if defined __xlc__ || defined __GNUC__ - /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 - reported by James Lemley on 2005-10-05; see - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - This test is not quite right, since xlc is allowed to - reject this program, as the initializer for xlcbug is - not one of the forms that C requires support for. - However, doing the test right would require a runtime - test, and that would make cross-compilation harder. - Let us hope that IBM fixes the xlc bug, and also adds - support for this kind of constant expression. In the - meantime, this test will reject xlc, which is OK, since - our stdbool.h substitute should suffice. We also test - this with GCC, where it should work, to detect more - quickly whether someone messes up the test in the - future. */ - char digs[] = "0123456789"; - int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); -# endif - /* Catch a bug in an HP-UX C compiler. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - */ - _Bool q = true; - _Bool *pq = &q; - -int -main () -{ - - *pq |= q; - *pq |= ! q; - /* Refer to every declared value, to avoid compiler optimizations. */ - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l - + !m + !n + !o + !p + !q + !pq); - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_header_stdbool_h=yes -else - ac_cv_header_stdbool_h=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 -$as_echo "$ac_cv_header_stdbool_h" >&6; } -ac_fn_cxx_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" -if test "x$ac_cv_type__Bool" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE__BOOL 1 -_ACEOF - - -fi - -if test $ac_cv_header_stdbool_h = yes; then - -$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 -$as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if test "${ac_cv_c_const+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -/* FIXME: Include the comments suggested by Paul. */ -#ifndef __cplusplus - /* Ultrix mips cc rejects this. */ - typedef int charset[2]; - const charset cs; - /* SunOS 4.1.1 cc rejects this. */ - char const *const *pcpcc; - char **ppc; - /* NEC SVR4.0.2 mips cc rejects this. */ - struct point {int x, y;}; - static struct point const zero = {0,0}; - /* AIX XL C 1.02.0.0 rejects this. - It does not let you subtract one const X* pointer from another in - an arm of an if-expression whose if-part is not a constant - expression */ - const char *g = "string"; - pcpcc = &g + (g ? g-g : 0); - /* HPUX 7.0 cc rejects these. */ - ++pcpcc; - ppc = (char**) pcpcc; - pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; - char const *s = 0 ? (char *) 0 : (char const *) 0; - - *t++ = 0; - if (s) return 0; - } - { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ - int x[] = {25, 17}; - const int *foo = &x[0]; - ++foo; - } - { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ - typedef const int *iptr; - iptr p = 0; - ++p; - } - { /* AIX XL C 1.02.0.0 rejects this saying - "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; - } - { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ - const int foo = 10; - if (!foo) return 0; - } - return !cs[0] && !zero.x; -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_c_const=yes -else - ac_cv_c_const=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 -$as_echo "$ac_cv_c_const" >&6; } -if test $ac_cv_c_const = no; then - -$as_echo "#define const /**/" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 -$as_echo_n "checking for uid_t in sys/types.h... " >&6; } -if test "${ac_cv_type_uid_t+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "uid_t" >/dev/null 2>&1; then : - ac_cv_type_uid_t=yes -else - ac_cv_type_uid_t=no -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 -$as_echo "$ac_cv_type_uid_t" >&6; } -if test $ac_cv_type_uid_t = no; then - -$as_echo "#define uid_t int" >>confdefs.h - - -$as_echo "#define gid_t int" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 -$as_echo_n "checking for inline... " >&6; } -if test "${ac_cv_c_inline+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_c_inline=no -for ac_kw in inline __inline__ __inline; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifndef __cplusplus -typedef int foo_t; -static $ac_kw foo_t static_foo () {return 0; } -$ac_kw foo_t foo () {return 0; } -#endif - -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_c_inline=$ac_kw -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_inline" != no && break -done - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 -$as_echo "$ac_cv_c_inline" >&6; } - -case $ac_cv_c_inline in - inline | yes) ;; - *) - case $ac_cv_c_inline in - no) ac_val=;; - *) ac_val=$ac_cv_c_inline;; - esac - cat >>confdefs.h <<_ACEOF -#ifndef __cplusplus -#define inline $ac_val -#endif -_ACEOF - ;; -esac - -ac_fn_cxx_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" -if test "x$ac_cv_type_mode_t" = x""yes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define mode_t int -_ACEOF - -fi - -ac_fn_cxx_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = x""yes; then : - -else - -cat >>confdefs.h <<_ACEOF -#define size_t unsigned int -_ACEOF - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 -$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } -if test "${ac_cv_header_time+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include - -int -main () -{ -if ((struct tm *) 0) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_header_time=yes -else - ac_cv_header_time=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 -$as_echo "$ac_cv_header_time" >&6; } -if test $ac_cv_header_time = yes; then - -$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 -$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } -if test "${ac_cv_struct_tm+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include - -int -main () -{ -struct tm tm; - int *p = &tm.tm_sec; - return !p; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_struct_tm=time.h -else - ac_cv_struct_tm=sys/time.h -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 -$as_echo "$ac_cv_struct_tm" >&6; } -if test $ac_cv_struct_tm = sys/time.h; then - -$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 -$as_echo_n "checking return type of signal handlers... " >&6; } -if test "${ac_cv_type_signal+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include - -int -main () -{ -return *(signal (0, 0)) (0) == 1; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_type_signal=int -else - ac_cv_type_signal=void -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 -$as_echo "$ac_cv_type_signal" >&6; } - -cat >>confdefs.h <<_ACEOF -#define RETSIGTYPE $ac_cv_type_signal -_ACEOF - - - -ac_fn_cxx_check_type "$LINENO" "siginfo_t" "ac_cv_type_siginfo_t" "#include -" -if test "x$ac_cv_type_siginfo_t" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_SIGINFO_T 1 -_ACEOF - - -fi - -ac_fn_cxx_check_type "$LINENO" "struct sigcontext" "ac_cv_type_struct_sigcontext" "#include -" -if test "x$ac_cv_type_struct_sigcontext" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_SIGCONTEXT 1 -_ACEOF - - -fi - -ac_fn_cxx_check_member "$LINENO" "struct sigcontext" "eip" "ac_cv_member_struct_sigcontext_eip" "#include -" -if test "x$ac_cv_member_struct_sigcontext_eip" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_SIGCONTEXT_EIP 1 -_ACEOF - - -fi - -ac_fn_cxx_check_type "$LINENO" "ucontext_t" "ac_cv_type_ucontext_t" "#include -" -if test "x$ac_cv_type_ucontext_t" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_UCONTEXT_T 1 -_ACEOF - - -fi - - -# Checks for library functions. -if test $ac_cv_c_compiler_gnu = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 -$as_echo_n "checking whether $CC needs -traditional... " >&6; } -if test "${ac_cv_prog_gcc_traditional+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_pattern="Autoconf.*'x'" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -Autoconf TIOCGETP -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "$ac_pattern" >/dev/null 2>&1; then : - ac_cv_prog_gcc_traditional=yes -else - ac_cv_prog_gcc_traditional=no -fi -rm -f conftest* - - - if test $ac_cv_prog_gcc_traditional = no; then - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -Autoconf TCGETA -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "$ac_pattern" >/dev/null 2>&1; then : - ac_cv_prog_gcc_traditional=yes -fi -rm -f conftest* - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5 -$as_echo "$ac_cv_prog_gcc_traditional" >&6; } - if test $ac_cv_prog_gcc_traditional = yes; then - CC="$CC -traditional" - fi -fi - -for ac_header in stdlib.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" -if test "x$ac_cv_header_stdlib_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STDLIB_H 1 -_ACEOF - -fi - -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 -$as_echo_n "checking for GNU libc compatible malloc... " >&6; } -if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_malloc_0_nonnull=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include -#else -char *malloc (); -#endif - -int -main () -{ -return ! malloc (0); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_run "$LINENO"; then : - ac_cv_func_malloc_0_nonnull=yes -else - ac_cv_func_malloc_0_nonnull=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 -$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } -if test $ac_cv_func_malloc_0_nonnull = yes; then : - -$as_echo "#define HAVE_MALLOC 1" >>confdefs.h - -else - $as_echo "#define HAVE_MALLOC 0" >>confdefs.h - - case " $LIBOBJS " in - *" malloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS malloc.$ac_objext" - ;; -esac - - -$as_echo "#define malloc rpl_malloc" >>confdefs.h - -fi - - - - - - for ac_header in $ac_header_list -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - - - - - -for ac_func in getpagesize -do : - ac_fn_cxx_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize" -if test "x$ac_cv_func_getpagesize" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GETPAGESIZE 1 -_ACEOF - -fi -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5 -$as_echo_n "checking for working mmap... " >&6; } -if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_mmap_fixed_mapped=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -/* malloc might have been renamed as rpl_malloc. */ -#undef malloc - -/* Thanks to Mike Haertel and Jim Avera for this test. - Here is a matrix of mmap possibilities: - mmap private not fixed - mmap private fixed at somewhere currently unmapped - mmap private fixed at somewhere already mapped - mmap shared not fixed - mmap shared fixed at somewhere currently unmapped - mmap shared fixed at somewhere already mapped - For private mappings, we should verify that changes cannot be read() - back from the file, nor mmap's back from the file at a different - address. (There have been systems where private was not correctly - implemented like the infamous i386 svr4.0, and systems where the - VM page cache was not coherent with the file system buffer cache - like early versions of FreeBSD and possibly contemporary NetBSD.) - For shared mappings, we should conversely verify that changes get - propagated back to all the places they're supposed to be. - - Grep wants private fixed already mapped. - The main things grep needs to know about mmap are: - * does it exist and is it safe to write into the mmap'd area - * how to use it (BSD variants) */ - -#include -#include - -#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H -char *malloc (); -#endif - -/* This mess was copied from the GNU getpagesize.h. */ -#ifndef HAVE_GETPAGESIZE -# ifdef _SC_PAGESIZE -# define getpagesize() sysconf(_SC_PAGESIZE) -# else /* no _SC_PAGESIZE */ -# ifdef HAVE_SYS_PARAM_H -# include -# ifdef EXEC_PAGESIZE -# define getpagesize() EXEC_PAGESIZE -# else /* no EXEC_PAGESIZE */ -# ifdef NBPG -# define getpagesize() NBPG * CLSIZE -# ifndef CLSIZE -# define CLSIZE 1 -# endif /* no CLSIZE */ -# else /* no NBPG */ -# ifdef NBPC -# define getpagesize() NBPC -# else /* no NBPC */ -# ifdef PAGESIZE -# define getpagesize() PAGESIZE -# endif /* PAGESIZE */ -# endif /* no NBPC */ -# endif /* no NBPG */ -# endif /* no EXEC_PAGESIZE */ -# else /* no HAVE_SYS_PARAM_H */ -# define getpagesize() 8192 /* punt totally */ -# endif /* no HAVE_SYS_PARAM_H */ -# endif /* no _SC_PAGESIZE */ - -#endif /* no HAVE_GETPAGESIZE */ - -int -main () -{ - char *data, *data2, *data3; - const char *cdata2; - int i, pagesize; - int fd, fd2; - - pagesize = getpagesize (); - - /* First, make a file with some known garbage in it. */ - data = (char *) malloc (pagesize); - if (!data) - return 1; - for (i = 0; i < pagesize; ++i) - *(data + i) = rand (); - umask (0); - fd = creat ("conftest.mmap", 0600); - if (fd < 0) - return 2; - if (write (fd, data, pagesize) != pagesize) - return 3; - close (fd); - - /* Next, check that the tail of a page is zero-filled. File must have - non-zero length, otherwise we risk SIGBUS for entire page. */ - fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600); - if (fd2 < 0) - return 4; - cdata2 = ""; - if (write (fd2, cdata2, 1) != 1) - return 5; - data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L); - if (data2 == MAP_FAILED) - return 6; - for (i = 0; i < pagesize; ++i) - if (*(data2 + i)) - return 7; - close (fd2); - if (munmap (data2, pagesize)) - return 8; - - /* Next, try to mmap the file at a fixed address which already has - something else allocated at it. If we can, also make sure that - we see the same garbage. */ - fd = open ("conftest.mmap", O_RDWR); - if (fd < 0) - return 9; - if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FIXED, fd, 0L)) - return 10; - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data2 + i)) - return 11; - - /* Finally, make sure that changes to the mapped area do not - percolate back to the file as seen by read(). (This is a bug on - some variants of i386 svr4.0.) */ - for (i = 0; i < pagesize; ++i) - *(data2 + i) = *(data2 + i) + 1; - data3 = (char *) malloc (pagesize); - if (!data3) - return 12; - if (read (fd, data3, pagesize) != pagesize) - return 13; - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data3 + i)) - return 14; - close (fd); - return 0; -} -_ACEOF -if ac_fn_cxx_try_run "$LINENO"; then : - ac_cv_func_mmap_fixed_mapped=yes -else - ac_cv_func_mmap_fixed_mapped=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_fixed_mapped" >&5 -$as_echo "$ac_cv_func_mmap_fixed_mapped" >&6; } -if test $ac_cv_func_mmap_fixed_mapped = yes; then - -$as_echo "#define HAVE_MMAP 1" >>confdefs.h - -fi -rm -f conftest.mmap conftest.txt - -for ac_header in sys/select.h sys/socket.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for select" >&5 -$as_echo_n "checking types of arguments for select... " >&6; } -if test "${ac_cv_func_select_args+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - for ac_arg234 in 'fd_set *' 'int *' 'void *'; do - for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do - for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -#ifdef HAVE_SYS_SELECT_H -# include -#endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif - -int -main () -{ -extern int select ($ac_arg1, - $ac_arg234, $ac_arg234, $ac_arg234, - $ac_arg5); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done - done -done -# Provide a safe default value. -: ${ac_cv_func_select_args='int,int *,struct timeval *'} - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_select_args" >&5 -$as_echo "$ac_cv_func_select_args" >&6; } -ac_save_IFS=$IFS; IFS=',' -set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` -IFS=$ac_save_IFS -shift - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG1 $1 -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG234 ($2) -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define SELECT_TYPE_ARG5 ($3) -_ACEOF - -rm -f conftest* - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat correctly handles trailing slash" >&5 -$as_echo_n "checking whether lstat correctly handles trailing slash... " >&6; } -if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - rm -f conftest.sym conftest.file -echo >conftest.file -if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then - if test "$cross_compiling" = yes; then : - ac_cv_func_lstat_dereferences_slashed_symlink=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -struct stat sbuf; - /* Linux will dereference the symlink and fail, as required by POSIX. - That is better in the sense that it means we will not - have to compile and use the lstat wrapper. */ - return lstat ("conftest.sym/", &sbuf) == 0; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_run "$LINENO"; then : - ac_cv_func_lstat_dereferences_slashed_symlink=yes -else - ac_cv_func_lstat_dereferences_slashed_symlink=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -else - # If the `ln -s' command failed, then we probably don't even - # have an lstat function. - ac_cv_func_lstat_dereferences_slashed_symlink=no -fi -rm -f conftest.sym conftest.file - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 -$as_echo "$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } - -test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && - -cat >>confdefs.h <<_ACEOF -#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 -_ACEOF - - -if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then - case " $LIBOBJS " in - *" lstat.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS lstat.$ac_objext" - ;; -esac - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat accepts an empty string" >&5 -$as_echo_n "checking whether stat accepts an empty string... " >&6; } -if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_stat_empty_string_bug=yes -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -struct stat sbuf; - return stat ("", &sbuf) == 0; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_run "$LINENO"; then : - ac_cv_func_stat_empty_string_bug=no -else - ac_cv_func_stat_empty_string_bug=yes -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_stat_empty_string_bug" >&5 -$as_echo "$ac_cv_func_stat_empty_string_bug" >&6; } -if test $ac_cv_func_stat_empty_string_bug = yes; then - case " $LIBOBJS " in - *" stat.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS stat.$ac_objext" - ;; -esac - - -cat >>confdefs.h <<_ACEOF -#define HAVE_STAT_EMPTY_STRING_BUG 1 -_ACEOF - -fi - -for ac_func in strftime -do : - ac_fn_cxx_check_func "$LINENO" "strftime" "ac_cv_func_strftime" -if test "x$ac_cv_func_strftime" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STRFTIME 1 -_ACEOF - -else - # strftime is in -lintl on SCO UNIX. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strftime in -lintl" >&5 -$as_echo_n "checking for strftime in -lintl... " >&6; } -if test "${ac_cv_lib_intl_strftime+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lintl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char strftime (); -int -main () -{ -return strftime (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_intl_strftime=yes -else - ac_cv_lib_intl_strftime=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_strftime" >&5 -$as_echo "$ac_cv_lib_intl_strftime" >&6; } -if test "x$ac_cv_lib_intl_strftime" = x""yes; then : - $as_echo "#define HAVE_STRFTIME 1" >>confdefs.h - -LIBS="-lintl $LIBS" -fi - -fi -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strtod" >&5 -$as_echo_n "checking for working strtod... " >&6; } -if test "${ac_cv_func_strtod+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_strtod=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -$ac_includes_default -#ifndef strtod -double strtod (); -#endif -int -main() -{ - { - /* Some versions of Linux strtod mis-parse strings with leading '+'. */ - char *string = " +69"; - char *term; - double value; - value = strtod (string, &term); - if (value != 69 || term != (string + 4)) - return 1; - } - - { - /* Under Solaris 2.4, strtod returns the wrong value for the - terminating character under some conditions. */ - char *string = "NaN"; - char *term; - strtod (string, &term); - if (term != string && *(term - 1) == 0) - return 1; - } - return 0; -} - -_ACEOF -if ac_fn_cxx_try_run "$LINENO"; then : - ac_cv_func_strtod=yes -else - ac_cv_func_strtod=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strtod" >&5 -$as_echo "$ac_cv_func_strtod" >&6; } -if test $ac_cv_func_strtod = no; then - case " $LIBOBJS " in - *" strtod.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strtod.$ac_objext" - ;; -esac - -ac_fn_cxx_check_func "$LINENO" "pow" "ac_cv_func_pow" -if test "x$ac_cv_func_pow" = x""yes; then : - -fi - -if test $ac_cv_func_pow = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 -$as_echo_n "checking for pow in -lm... " >&6; } -if test "${ac_cv_lib_m_pow+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lm $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char pow (); -int -main () -{ -return pow (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_m_pow=yes -else - ac_cv_lib_m_pow=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 -$as_echo "$ac_cv_lib_m_pow" >&6; } -if test "x$ac_cv_lib_m_pow" = x""yes; then : - POW_LIB=-lm -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find library containing definition of pow" >&5 -$as_echo "$as_me: WARNING: cannot find library containing definition of pow" >&2;} -fi - -fi - -fi - -for ac_func in vprintf -do : - ac_fn_cxx_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" -if test "x$ac_cv_func_vprintf" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_VPRINTF 1 -_ACEOF - -ac_fn_cxx_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" -if test "x$ac_cv_func__doprnt" = x""yes; then : - -$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h - -fi - -fi -done - - -for ac_func in gethostbyname gethostname gettimeofday memmove memset mkdir munmap putenv select socket sqrt strcasecmp strchr strcspn strerror strncasecmp strrchr strsignal strspn strstr strtol strtoull -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - -for ac_func in syscall sleep usleep ioctl ioctlsocket sigaction -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - -# Other programs -# Extract the first word of "ffmpeg", so it can be a program name with args. -set dummy ffmpeg; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OPT_FFMPEG+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OPT_FFMPEG"; then - ac_cv_prog_OPT_FFMPEG="$OPT_FFMPEG" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OPT_FFMPEG="yes" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_prog_OPT_FFMPEG" && ac_cv_prog_OPT_FFMPEG="no" -fi -fi -OPT_FFMPEG=$ac_cv_prog_OPT_FFMPEG -if test -n "$OPT_FFMPEG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPT_FFMPEG" >&5 -$as_echo "$OPT_FFMPEG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -# Extract the first word of "ffmpeg", so it can be a program name with args. -set dummy ffmpeg; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PATH_FFMPEG+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case $PATH_FFMPEG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PATH_FFMPEG="$PATH_FFMPEG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_PATH_FFMPEG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -PATH_FFMPEG=$ac_cv_path_PATH_FFMPEG -if test -n "$PATH_FFMPEG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PATH_FFMPEG" >&5 -$as_echo "$PATH_FFMPEG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -# Extract the first word of "pnmscale", so it can be a program name with args. -set dummy pnmscale; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OPT_NETPBM+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OPT_NETPBM"; then - ac_cv_prog_OPT_NETPBM="$OPT_NETPBM" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OPT_NETPBM="yes" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_prog_OPT_NETPBM" && ac_cv_prog_OPT_NETPBM="no" -fi -fi -OPT_NETPBM=$ac_cv_prog_OPT_NETPBM -if test -n "$OPT_NETPBM"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPT_NETPBM" >&5 -$as_echo "$OPT_NETPBM" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -# Extract the first word of "pnmscale", so it can be a program name with args. -set dummy pnmscale; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PATH_NETPBM+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case $PATH_NETPBM in - [\\/]* | ?:[\\/]*) - ac_cv_path_PATH_NETPBM="$PATH_NETPBM" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_PATH_NETPBM="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -PATH_NETPBM=$ac_cv_path_PATH_NETPBM -if test -n "$PATH_NETPBM"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PATH_NETPBM" >&5 -$as_echo "$PATH_NETPBM" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -if test "$OPT_NETPBM" == "yes"; then -PATH_NETPBM=`dirname $PATH_NETPBM` -fi - -# Checks for libraries. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql_init in -lmysqlclient" >&5 -$as_echo_n "checking for mysql_init in -lmysqlclient... " >&6; } -if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lmysqlclient $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char mysql_init (); -int -main () -{ -return mysql_init (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_mysqlclient_mysql_init=yes -else - ac_cv_lib_mysqlclient_mysql_init=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mysqlclient_mysql_init" >&5 -$as_echo "$ac_cv_lib_mysqlclient_mysql_init" >&6; } -if test "x$ac_cv_lib_mysqlclient_mysql_init" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBMYSQLCLIENT 1 -_ACEOF - - LIBS="-lmysqlclient $LIBS" - -else - as_fn_error "zm requires libmysqlclient.a" "$LINENO" 5 -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_start_compress in -ljpeg" >&5 -$as_echo_n "checking for jpeg_start_compress in -ljpeg... " >&6; } -if test "${ac_cv_lib_jpeg_jpeg_start_compress+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ljpeg $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char jpeg_start_compress (); -int -main () -{ -return jpeg_start_compress (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_jpeg_jpeg_start_compress=yes -else - ac_cv_lib_jpeg_jpeg_start_compress=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_start_compress" >&5 -$as_echo "$ac_cv_lib_jpeg_jpeg_start_compress" >&6; } -if test "x$ac_cv_lib_jpeg_jpeg_start_compress" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBJPEG 1 -_ACEOF - - LIBS="-ljpeg $LIBS" - -else - as_fn_error "zm requires libjpeg.a" "$LINENO" 5 -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 -$as_echo_n "checking for pthread_create in -lpthread... " >&6; } -if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpthread $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char pthread_create (); -int -main () -{ -return pthread_create (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_pthread_pthread_create=yes -else - ac_cv_lib_pthread_pthread_create=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 -$as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } -if test "x$ac_cv_lib_pthread_pthread_create" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBPTHREAD 1 -_ACEOF - - LIBS="-lpthread $LIBS" - -else - as_fn_error "zm requires libpthread.a" "$LINENO" 5 -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlsym in -ldl" >&5 -$as_echo_n "checking for dlsym in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlsym+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ldl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dlsym (); -int -main () -{ -return dlsym (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_dl_dlsym=yes -else - ac_cv_lib_dl_dlsym=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlsym" >&5 -$as_echo "$ac_cv_lib_dl_dlsym" >&6; } -if test "x$ac_cv_lib_dl_dlsym" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBDL 1 -_ACEOF - - LIBS="-ldl $LIBS" - -else - as_fn_error "zm requires libdl.a" "$LINENO" 5 -fi - -if test "$ZM_SSL_LIB" == "openssl"; then -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5 in -lcrypto" >&5 -$as_echo_n "checking for MD5 in -lcrypto... " >&6; } -if test "${ac_cv_lib_crypto_MD5+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lcrypto $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char MD5 (); -int -main () -{ -return MD5 (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_crypto_MD5=yes -else - ac_cv_lib_crypto_MD5=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_MD5" >&5 -$as_echo "$ac_cv_lib_crypto_MD5" >&6; } -if test "x$ac_cv_lib_crypto_MD5" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBCRYPTO 1 -_ACEOF - - LIBS="-lcrypto $LIBS" - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcrypto.a is required for authenticated streaming - use ZM_SSL_LIB option to select gnutls instead" >&5 -$as_echo "$as_me: WARNING: libcrypto.a is required for authenticated streaming - use ZM_SSL_LIB option to select gnutls instead" >&2;} -fi - -else -for ac_header in gcrypt.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "gcrypt.h" "ac_cv_header_gcrypt_h" "$ac_includes_default" -if test "x$ac_cv_header_gcrypt_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GCRYPT_H 1 -_ACEOF - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: zm requires libgcrypt headers to be installed for gnutls" >&5 -$as_echo "$as_me: WARNING: zm requires libgcrypt headers to be installed for gnutls" >&2;} -fi - -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcry_check_version in -lgcrypt" >&5 -$as_echo_n "checking for gcry_check_version in -lgcrypt... " >&6; } -if test "${ac_cv_lib_gcrypt_gcry_check_version+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lgcrypt $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gcry_check_version (); -int -main () -{ -return gcry_check_version (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_gcrypt_gcry_check_version=yes -else - ac_cv_lib_gcrypt_gcry_check_version=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gcrypt_gcry_check_version" >&5 -$as_echo "$ac_cv_lib_gcrypt_gcry_check_version" >&6; } -if test "x$ac_cv_lib_gcrypt_gcry_check_version" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBGCRYPT 1 -_ACEOF - - LIBS="-lgcrypt $LIBS" - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libgcrypt.a is required for authenticated streaming - use ZM_SSL_LIB option to select openssl instead" >&5 -$as_echo "$as_me: WARNING: libgcrypt.a is required for authenticated streaming - use ZM_SSL_LIB option to select openssl instead" >&2;} -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5 in -lgnutls-openssl" >&5 -$as_echo_n "checking for MD5 in -lgnutls-openssl... " >&6; } -if test "${ac_cv_lib_gnutls_openssl_MD5+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lgnutls-openssl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char MD5 (); -int -main () -{ -return MD5 (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_gnutls_openssl_MD5=yes -else - ac_cv_lib_gnutls_openssl_MD5=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gnutls_openssl_MD5" >&5 -$as_echo "$ac_cv_lib_gnutls_openssl_MD5" >&6; } -if test "x$ac_cv_lib_gnutls_openssl_MD5" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBGNUTLS_OPENSSL 1 -_ACEOF - - LIBS="-lgnutls-openssl $LIBS" - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: gnutls-openssl.a is required for authenticated streaming - use ZM_SSL_LIB option to select openssl instead" >&5 -$as_echo "$as_me: WARNING: gnutls-openssl.a is required for authenticated streaming - use ZM_SSL_LIB option to select openssl instead" >&2;} -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre_compile in -lpcre" >&5 -$as_echo_n "checking for pcre_compile in -lpcre... " >&6; } -if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpcre $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char pcre_compile (); -int -main () -{ -return pcre_compile (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_pcre_pcre_compile=yes -else - ac_cv_lib_pcre_pcre_compile=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcre_pcre_compile" >&5 -$as_echo "$ac_cv_lib_pcre_pcre_compile" >&6; } -if test "x$ac_cv_lib_pcre_pcre_compile" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBPCRE 1 -_ACEOF - - LIBS="-lpcre $LIBS" - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libpcre.a may be required for remote/network camera support" >&5 -$as_echo "$as_me: WARNING: libpcre.a may be required for remote/network camera support" >&2;} -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlibVersion in -lz" >&5 -$as_echo_n "checking for zlibVersion in -lz... " >&6; } -if test "${ac_cv_lib_z_zlibVersion+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char zlibVersion (); -int -main () -{ -return zlibVersion (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_z_zlibVersion=yes -else - ac_cv_lib_z_zlibVersion=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_zlibVersion" >&5 -$as_echo "$ac_cv_lib_z_zlibVersion" >&6; } -if test "x$ac_cv_lib_z_zlibVersion" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBZ 1 -_ACEOF - - LIBS="-lz $LIBS" - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x264_predict_16x16_init in -lx264" >&5 -$as_echo_n "checking for x264_predict_16x16_init in -lx264... " >&6; } -if test "${ac_cv_lib_x264_x264_predict_16x16_init+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lx264 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char x264_predict_16x16_init (); -int -main () -{ -return x264_predict_16x16_init (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_x264_x264_predict_16x16_init=yes -else - ac_cv_lib_x264_x264_predict_16x16_init=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_x264_x264_predict_16x16_init" >&5 -$as_echo "$ac_cv_lib_x264_x264_predict_16x16_init" >&6; } -if test "x$ac_cv_lib_x264_x264_predict_16x16_init" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBX264 1 -_ACEOF - - LIBS="-lx264 $LIBS" - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_malloc in -lavutil" >&5 -$as_echo_n "checking for av_malloc in -lavutil... " >&6; } -if test "${ac_cv_lib_avutil_av_malloc+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lavutil $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char av_malloc (); -int -main () -{ -return av_malloc (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_avutil_av_malloc=yes -else - ac_cv_lib_avutil_av_malloc=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avutil_av_malloc" >&5 -$as_echo "$ac_cv_lib_avutil_av_malloc" >&6; } -if test "x$ac_cv_lib_avutil_av_malloc" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBAVUTIL 1 -_ACEOF - - LIBS="-lavutil $LIBS" - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libavutil.a may be required for MPEG streaming" >&5 -$as_echo "$as_me: WARNING: libavutil.a may be required for MPEG streaming" >&2;} -fi - -# Don't bother to warn about this one -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_image_copy in -lavcore" >&5 -$as_echo_n "checking for av_image_copy in -lavcore... " >&6; } -if test "${ac_cv_lib_avcore_av_image_copy+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lavcore $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char av_image_copy (); -int -main () -{ -return av_image_copy (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_avcore_av_image_copy=yes -else - ac_cv_lib_avcore_av_image_copy=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avcore_av_image_copy" >&5 -$as_echo "$ac_cv_lib_avcore_av_image_copy" >&6; } -if test "x$ac_cv_lib_avcore_av_image_copy" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBAVCORE 1 -_ACEOF - - LIBS="-lavcore $LIBS" - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for avcodec_init in -lavcodec" >&5 -$as_echo_n "checking for avcodec_init in -lavcodec... " >&6; } -if test "${ac_cv_lib_avcodec_avcodec_init+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lavcodec $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char avcodec_init (); -int -main () -{ -return avcodec_init (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_avcodec_avcodec_init=yes -else - ac_cv_lib_avcodec_avcodec_init=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avcodec_avcodec_init" >&5 -$as_echo "$ac_cv_lib_avcodec_avcodec_init" >&6; } -if test "x$ac_cv_lib_avcodec_avcodec_init" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBAVCODEC 1 -_ACEOF - - LIBS="-lavcodec $LIBS" - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libavcodec.a is required for MPEG streaming" >&5 -$as_echo "$as_me: WARNING: libavcodec.a is required for MPEG streaming" >&2;} -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_new_stream in -lavformat" >&5 -$as_echo_n "checking for av_new_stream in -lavformat... " >&6; } -if test "${ac_cv_lib_avformat_av_new_stream+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lavformat $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char av_new_stream (); -int -main () -{ -return av_new_stream (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_avformat_av_new_stream=yes -else - ac_cv_lib_avformat_av_new_stream=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avformat_av_new_stream" >&5 -$as_echo "$ac_cv_lib_avformat_av_new_stream" >&6; } -if test "x$ac_cv_lib_avformat_av_new_stream" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBAVFORMAT 1 -_ACEOF - - LIBS="-lavformat $LIBS" - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libavformat.a is required for MPEG streaming" >&5 -$as_echo "$as_me: WARNING: libavformat.a is required for MPEG streaming" >&2;} -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for avdevice_register_all in -lavdevice" >&5 -$as_echo_n "checking for avdevice_register_all in -lavdevice... " >&6; } -if test "${ac_cv_lib_avdevice_avdevice_register_all+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lavdevice $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char avdevice_register_all (); -int -main () -{ -return avdevice_register_all (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_avdevice_avdevice_register_all=yes -else - ac_cv_lib_avdevice_avdevice_register_all=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avdevice_avdevice_register_all" >&5 -$as_echo "$ac_cv_lib_avdevice_avdevice_register_all" >&6; } -if test "x$ac_cv_lib_avdevice_avdevice_register_all" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBAVDEVICE 1 -_ACEOF - - LIBS="-lavdevice $LIBS" - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libavdevice.a may be required for MPEG streaming" >&5 -$as_echo "$as_me: WARNING: libavdevice.a may be required for MPEG streaming" >&2;} -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sws_scale in -lswscale" >&5 -$as_echo_n "checking for sws_scale in -lswscale... " >&6; } -if test "${ac_cv_lib_swscale_sws_scale+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lswscale -lswscale $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char sws_scale (); -int -main () -{ -return sws_scale (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_swscale_sws_scale=yes -else - ac_cv_lib_swscale_sws_scale=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_swscale_sws_scale" >&5 -$as_echo "$ac_cv_lib_swscale_sws_scale" >&6; } -if test "x$ac_cv_lib_swscale_sws_scale" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBSWSCALE 1 -_ACEOF - - LIBS="-lswscale $LIBS" - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -lbz2" >&5 -$as_echo_n "checking for BZ2_bzCompress in -lbz2... " >&6; } -if test "${ac_cv_lib_bz2_BZ2_bzCompress+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lbz2 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char BZ2_bzCompress (); -int -main () -{ -return BZ2_bzCompress (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_bz2_BZ2_bzCompress=yes -else - ac_cv_lib_bz2_BZ2_bzCompress=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzCompress" >&5 -$as_echo "$ac_cv_lib_bz2_BZ2_bzCompress" >&6; } -if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBBZ2 1 -_ACEOF - - LIBS="-lbz2 $LIBS" - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: zm requires libbz2.a for recent versions of ffmpeg" >&5 -$as_echo "$as_me: WARNING: zm requires libbz2.a for recent versions of ffmpeg" >&2;} -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compress in -lz" >&5 -$as_echo_n "checking for compress in -lz... " >&6; } -if test "${ac_cv_lib_z_compress+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char compress (); -int -main () -{ -return compress (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_z_compress=yes -else - ac_cv_lib_z_compress=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5 -$as_echo "$ac_cv_lib_z_compress" >&6; } -if test "x$ac_cv_lib_z_compress" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBZ 1 -_ACEOF - - LIBS="-lz $LIBS" - -fi - - -# Checks for header files. -# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 -$as_echo_n "checking for working alloca.h... " >&6; } -if test "${ac_cv_working_alloca_h+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -char *p = (char *) alloca (2 * sizeof (int)); - if (p) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_working_alloca_h=yes -else - ac_cv_working_alloca_h=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 -$as_echo "$ac_cv_working_alloca_h" >&6; } -if test $ac_cv_working_alloca_h = yes; then - -$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 -$as_echo_n "checking for alloca... " >&6; } -if test "${ac_cv_func_alloca_works+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __GNUC__ -# define alloca __builtin_alloca -#else -# ifdef _MSC_VER -# include -# define alloca _alloca -# else -# ifdef HAVE_ALLOCA_H -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -# endif -# endif -# endif -# endif -#endif - -int -main () -{ -char *p = (char *) alloca (1); - if (p) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_func_alloca_works=yes -else - ac_cv_func_alloca_works=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 -$as_echo "$ac_cv_func_alloca_works" >&6; } - -if test $ac_cv_func_alloca_works = yes; then - -$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h - -else - # The SVR3 libPW and SVR4 libucb both contain incompatible functions -# that cause trouble. Some versions do not even contain alloca or -# contain a buggy version. If you still want to use their alloca, -# use ar to extract alloca.o from them instead of compiling alloca.c. - -ALLOCA=\${LIBOBJDIR}alloca.$ac_objext - -$as_echo "#define C_ALLOCA 1" >>confdefs.h - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 -$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } -if test "${ac_cv_os_cray+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined CRAY && ! defined CRAY2 -webecray -#else -wenotbecray -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "webecray" >/dev/null 2>&1; then : - ac_cv_os_cray=yes -else - ac_cv_os_cray=no -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 -$as_echo "$ac_cv_os_cray" >&6; } -if test $ac_cv_os_cray = yes; then - for ac_func in _getb67 GETB67 getb67; do - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define CRAY_STACKSEG_END $ac_func -_ACEOF - - break -fi - - done -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 -$as_echo_n "checking stack direction for C alloca... " >&6; } -if test "${ac_cv_c_stack_direction+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_c_stack_direction=0 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -find_stack_direction () -{ - static char *addr = 0; - auto char dummy; - if (addr == 0) - { - addr = &dummy; - return find_stack_direction (); - } - else - return (&dummy > addr) ? 1 : -1; -} - -int -main () -{ - return find_stack_direction () < 0; -} -_ACEOF -if ac_fn_cxx_try_run "$LINENO"; then : - ac_cv_c_stack_direction=1 -else - ac_cv_c_stack_direction=-1 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 -$as_echo "$ac_cv_c_stack_direction" >&6; } -cat >>confdefs.h <<_ACEOF -#define STACK_DIRECTION $ac_cv_c_stack_direction -_ACEOF - - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_cxx_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -for ac_header in fcntl.h limits.h memory.h stddef.h stdlib.h string.h strings.h sys/param.h sys/time.h syslog.h unistd.h values.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -for ac_header in netdb.h netinet/in.h arpa/inet.h sys/ioctl.h sys/socket.h sys/un.h glob.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - -for ac_header in execinfo.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "execinfo.h" "ac_cv_header_execinfo_h" "$ac_includes_default" -if test "x$ac_cv_header_execinfo_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_EXECINFO_H 1 -_ACEOF - -fi - -done - -for ac_header in syscall.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "syscall.h" "ac_cv_header_syscall_h" "$ac_includes_default" -if test "x$ac_cv_header_syscall_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SYSCALL_H 1 -_ACEOF - -fi - -done - -for ac_header in pthread.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" -if test "x$ac_cv_header_pthread_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PTHREAD_H 1 -_ACEOF - -fi - -done - -for ac_header in linux/videodev.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "linux/videodev.h" "ac_cv_header_linux_videodev_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_videodev_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LINUX_VIDEODEV_H 1 -_ACEOF - ZM_HAS_V4L1=1 - -else - ZM_HAS_V4L1=0 - -fi - -done - -for ac_header in linux/videodev2.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "linux/videodev2.h" "ac_cv_header_linux_videodev2_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_videodev2_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LINUX_VIDEODEV2_H 1 -_ACEOF - ZM_HAS_V4L2=1 - -else - ZM_HAS_V4L2=0 - -fi - -done - -if test "$ZM_HAS_V4L1" == "1" || test "$ZM_HAS_V4L2" == "1"; then -ZM_HAS_V4L=1 - -else -ZM_HAS_V4L=0 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: zm requires Video4Linux or Video4Linux2 to be installed for analog or USB camera support" >&5 -$as_echo "$as_me: WARNING: zm requires Video4Linux or Video4Linux2 to be installed for analog or USB camera support" >&2;} -fi -for ac_header in jpeglib.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "jpeglib.h" "ac_cv_header_jpeglib_h" "$ac_includes_default" -if test "x$ac_cv_header_jpeglib_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_JPEGLIB_H 1 -_ACEOF - -else - as_fn_error "zm requires libjpeg headers to be installed" "$LINENO" 5 -fi - -done - -for ac_header in mysql/mysql.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "mysql/mysql.h" "ac_cv_header_mysql_mysql_h" "$ac_includes_default" -if test "x$ac_cv_header_mysql_mysql_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_MYSQL_MYSQL_H 1 -_ACEOF - -else - as_fn_error "zm requires MySQL headers - check that MySQL development packages are installed" "$LINENO" 5 -fi - -done - -for ac_header in libavutil/avutil.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "libavutil/avutil.h" "ac_cv_header_libavutil_avutil_h" "$ac_includes_default" -if test "x$ac_cv_header_libavutil_avutil_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBAVUTIL_AVUTIL_H 1 -_ACEOF - -fi - -done - -for ac_header in libavcodec/avcodec.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "libavcodec/avcodec.h" "ac_cv_header_libavcodec_avcodec_h" "$ac_includes_default" -if test "x$ac_cv_header_libavcodec_avcodec_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBAVCODEC_AVCODEC_H 1 -_ACEOF - -fi - -done - -for ac_header in libavformat/avformat.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "libavformat/avformat.h" "ac_cv_header_libavformat_avformat_h" "$ac_includes_default" -if test "x$ac_cv_header_libavformat_avformat_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBAVFORMAT_AVFORMAT_H 1 -_ACEOF - -fi - -done - -for ac_header in libswscale/swscale.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "libswscale/swscale.h" "ac_cv_header_libswscale_swscale_h" "$ac_includes_default" -if test "x$ac_cv_header_libswscale_swscale_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBSWSCALE_SWSCALE_H 1 -_ACEOF - -fi - -done - -for ac_header in pcre/pcre.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "pcre/pcre.h" "ac_cv_header_pcre_pcre_h" "$ac_includes_default" -if test "x$ac_cv_header_pcre_pcre_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PCRE_PCRE_H 1 -_ACEOF - ZM_PCRE="1" - -fi - -done - -for ac_header in pcre.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "pcre.h" "ac_cv_header_pcre_h" "$ac_includes_default" -if test "x$ac_cv_header_pcre_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_PCRE_H 1 -_ACEOF - ZM_PCRE="1" - -fi - -done - -if test "$ENABLE_MMAP" == "yes"; then -for ac_header in sys/mman.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_mman_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SYS_MMAN_H 1 -_ACEOF - -fi - -done - -for ac_header in fcntl.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "fcntl.h" "ac_cv_header_fcntl_h" "$ac_includes_default" -if test "x$ac_cv_header_fcntl_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_FCNTL_H 1 -_ACEOF - -fi - -done - -else -for ac_header in sys/ipc.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "sys/ipc.h" "ac_cv_header_sys_ipc_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_ipc_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SYS_IPC_H 1 -_ACEOF - -fi - -done - -for ac_header in sys/shm.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "sys/shm.h" "ac_cv_header_sys_shm_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_shm_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_SYS_SHM_H 1 -_ACEOF - -fi - -done - -fi -for ac_header in zlib.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" -if test "x$ac_cv_header_zlib_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_ZLIB_H 1 -_ACEOF - -fi - -done - - -ac_fn_cxx_check_decl "$LINENO" "round" "ac_cv_have_decl_round" "#include -" -if test "x$ac_cv_have_decl_round" = x""yes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_ROUND $ac_have_decl -_ACEOF - -if test "$ZM_SSL_LIB" == "openssl"; then -ac_fn_cxx_check_decl "$LINENO" "MD5" "ac_cv_have_decl_MD5" "#include -#include -" -if test "x$ac_cv_have_decl_MD5" = x""yes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_MD5 $ac_have_decl -_ACEOF -if test $ac_have_decl = 1; then : - -else - as_fn_error "zm requires openssl/md5.h - use ZM_SSL_LIB option to select gnutls instead" "$LINENO" 5 -fi - -else -ac_fn_cxx_check_decl "$LINENO" "MD5" "ac_cv_have_decl_MD5" "#include -#include -" -if test "x$ac_cv_have_decl_MD5" = x""yes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_MD5 $ac_have_decl -_ACEOF -if test $ac_have_decl = 1; then : - -else - as_fn_error "zm requires gnutls/openssl.h - use ZM_SSL_LIB option to select openssl instead" "$LINENO" 5 -fi - -fi -ac_fn_cxx_check_decl "$LINENO" "backtrace" "ac_cv_have_decl_backtrace" "#include -" -if test "x$ac_cv_have_decl_backtrace" = x""yes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_BACKTRACE $ac_have_decl -_ACEOF - - - - -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -# Check if version of Perl is sufficient -ac_perl_version="5.6.0" - -if test "x$PERL" != "x"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl version greater than or equal to $ac_perl_version" >&5 -$as_echo_n "checking for perl version greater than or equal to $ac_perl_version... " >&6; } - # NB: It would be nice to log the error if there is one, but we cannot rely - # on autoconf internals - $PERL -e "use $ac_perl_version;" > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi - - -# Compulsory perl modules -ac_perl_modules="Sys::Syslog" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - as_fn_error "zm requires SYS:Syslog" "$LINENO" 5 - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="DBI" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - as_fn_error "zm requires DBI" "$LINENO" 5 - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="DBD::mysql" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - as_fn_error "zm requires DBD::mysql" "$LINENO" 5 - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="Getopt::Long" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - as_fn_error "zm requires Getopt::Long" "$LINENO" 5 - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="Time::HiRes" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - as_fn_error "zm requires Time::HiRes" "$LINENO" 5 - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="Date::Manip" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - as_fn_error "zm requires Date::Manip" "$LINENO" 5 - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="LWP::UserAgent" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - as_fn_error "zm requires LWP::UserAgent" "$LINENO" 5 - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="ExtUtils::MakeMaker" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - as_fn_error "zm requires ExtUtils::MakeMaker" "$LINENO" 5 - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -if test "$ENABLE_MMAP" == "yes"; then -ac_perl_modules="Sys::Mmap" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - as_fn_error "zm requires Sys::Mmap for mapped memory - set --enable-mmap=no to use IPC shared memory instead" "$LINENO" 5 - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -fi - -# Optional perl modules -ac_perl_modules="Module::Load" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Module::Load is required for PTZ camera control" >&5 -$as_echo "$as_me: WARNING: Module::Load is required for PTZ camera control" >&2;} - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="Device::SerialPort" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Device::SerialPort is required for RS232/RS485 PTZ camera control" >&5 -$as_echo "$as_me: WARNING: Device::SerialPort is required for RS232/RS485 PTZ camera control" >&2;} - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="Net::FTP" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Net::FTP is required for automatic event uploading using ftp" >&5 -$as_echo "$as_me: WARNING: Net::FTP is required for automatic event uploading using ftp" >&2;} - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="Net::SFTP::Foreign" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Net::SFTP::Foreign is required for automatic event uploading using sftp" >&5 -$as_echo "$as_me: WARNING: Net::SFTP::Foreign is required for automatic event uploading using sftp" >&2;} - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="Expect" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Expect is required for automatic event uploading using sftp" >&5 -$as_echo "$as_me: WARNING: Expect is required for automatic event uploading using sftp" >&2;} - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="Archive::Tar" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Archive::Tar may be required for automatic event uploading" >&5 -$as_echo "$as_me: WARNING: Archive::Tar may be required for automatic event uploading" >&2;} - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="Archive::Zip" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Archive::Zip may be required for automatic event uploading" >&5 -$as_echo "$as_me: WARNING: Archive::Zip may be required for automatic event uploading" >&2;} - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="Net::SMTP" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Net::SMTP may be required for automatic event email notification" >&5 -$as_echo "$as_me: WARNING: Net::SMTP may be required for automatic event email notification" >&2;} - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="MIME::Lite" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MIME::Lite may be required for automatic event email notification" >&5 -$as_echo "$as_me: WARNING: MIME::Lite may be required for automatic event email notification" >&2;} - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="MIME::Entity" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MIME::Entity may be required for automatic event email notification" >&5 -$as_echo "$as_me: WARNING: MIME::Entity may be required for automatic event email notification" >&2;} - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi -ac_perl_modules="X10::ActiveHome" -# Make sure we have perl -if test -z "$PERL"; then -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$PERL"; then - ac_cv_prog_PERL="$PERL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_PERL="perl" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -PERL=$ac_cv_prog_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi - -if test "x$PERL" != x; then - ac_perl_modules_failed=0 - for ac_perl_module in $ac_perl_modules; do - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 -$as_echo_n "checking for perl module $ac_perl_module... " >&6; } - - # Would be nice to log result here, but can't rely on autoconf internals - $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 - if test $? -ne 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; }; - ac_perl_modules_failed=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; }; - fi - done - - # Run optional shell commands - if test "$ac_perl_modules_failed" = 0; then - : - - else - : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: X10::ActiveHome is required for X.10 support" >&5 -$as_echo "$as_me: WARNING: X10::ActiveHome is required for X.10 support" >&2;} - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 -$as_echo "$as_me: WARNING: could not find perl" >&2;} -fi - - - prefix_NONE= - exec_prefix_NONE= - test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix - test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix - eval ac_define_dir="\"$bindir\"" - eval ac_define_dir="\"$ac_define_dir\"" - BINDIR="$ac_define_dir" - - -cat >>confdefs.h <<_ACEOF -#define BINDIR "$ac_define_dir" -_ACEOF - - test "$prefix_NONE" && prefix=NONE - test "$exec_prefix_NONE" && exec_prefix=NONE - - - prefix_NONE= - exec_prefix_NONE= - test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix - test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix - eval ac_define_dir="\"$libdir\"" - eval ac_define_dir="\"$ac_define_dir\"" - LIBDIR="$ac_define_dir" - - -cat >>confdefs.h <<_ACEOF -#define LIBDIR "$ac_define_dir" -_ACEOF - - test "$prefix_NONE" && prefix=NONE - test "$exec_prefix_NONE" && exec_prefix=NONE - -ZM_PID="$ZM_RUNDIR/zm.pid" - - - prefix_NONE= - exec_prefix_NONE= - test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix - test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix - eval ac_define_dir="\"$sysconfdir\"" - eval ac_define_dir="\"$ac_define_dir\"" - SYSCONFDIR="$ac_define_dir" - - -cat >>confdefs.h <<_ACEOF -#define SYSCONFDIR "$ac_define_dir" -_ACEOF - - test "$prefix_NONE" && prefix=NONE - test "$exec_prefix_NONE" && exec_prefix=NONE - -ZM_CONFIG="$SYSCONFDIR/zm.conf" - - -# Slight hack for non-standard perl install paths -if test "$prefix" != "NONE"; then - PERL_SITE_PREFIX=`perl -V:siteprefix | sed -e "s/.*='\(.*\)';/\1/"` - PERL_SITE_LIB=`perl -V:installsitelib | sed -e "s/.*='\(.*\)';/\1/"` - PERL_LIB_PATH=`echo $PERL_SITE_LIB | sed -e "s|^$PERL_SITE_PREFIX||"` - EXTRA_PERL_LIB="use lib '$prefix$PERL_LIB_PATH'; # Include custom perl install path" - PERL_MM_PARMS="PREFIX=$prefix" -else - EXTRA_PERL_LIB="# Include from system perl paths only" - PERL_MM_PARMS= -fi - - - -ac_config_files="$ac_config_files Makefile zm.conf zmconfgen.pl db/Makefile db/zm_create.sql misc/Makefile misc/apache.conf misc/logrotate.conf misc/syslog.conf scripts/Makefile scripts/zm scripts/zmaudit.pl scripts/zmcontrol.pl scripts/zmdc.pl scripts/zmfilter.pl scripts/zmpkg.pl scripts/zmtrack.pl scripts/zmtrigger.pl scripts/zmupdate.pl scripts/zmvideo.pl scripts/zmwatch.pl scripts/zmx10.pl scripts/zmdbbackup scripts/zmdbrestore scripts/zmeventdump scripts/zmlogrotate.conf scripts/ZoneMinder/lib/ZoneMinder/Base.pm scripts/ZoneMinder/lib/ZoneMinder/Config.pm scripts/ZoneMinder/lib/ZoneMinder/Memory.pm scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm src/Makefile src/zm_config.h web/Makefile web/ajax/Makefile web/css/Makefile web/graphics/Makefile web/includes/Makefile web/includes/config.php web/js/Makefile web/lang/Makefile web/skins/Makefile web/skins/classic/Makefile web/skins/classic/ajax/Makefile web/skins/classic/css/Makefile web/skins/classic/graphics/Makefile web/skins/classic/includes/Makefile web/skins/classic/js/Makefile web/skins/classic/lang/Makefile web/skins/classic/views/Makefile web/skins/classic/views/css/Makefile web/skins/classic/views/js/Makefile web/skins/mobile/Makefile web/skins/mobile/ajax/Makefile web/skins/mobile/css/Makefile web/skins/mobile/graphics/Makefile web/skins/mobile/includes/Makefile web/skins/mobile/lang/Makefile web/skins/mobile/views/Makefile web/skins/mobile/views/css/Makefile web/tools/Makefile web/tools/mootools/Makefile web/views/Makefile web/skins/xml/Makefile web/skins/xml/views/Makefile web/skins/xml/includes/Makefile" - - -# Create the definitions for compilation and defaults for the database -ac_config_commands="$ac_config_commands src/zm_config_defines.h" - -# Manually generate the perl Makefile maker -ac_config_commands="$ac_config_commands scripts/ZoneMinder/Makefile" - - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - if test -n "$EXEEXT"; then - am__EXEEXT_TRUE= - am__EXEEXT_FALSE='#' -else - am__EXEEXT_TRUE='#' - am__EXEEXT_FALSE= -fi - -if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - as_fn_error "conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then - as_fn_error "conditional \"am__fastdepCXX\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error "conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi - -: ${CONFIG_STATUS=./config.status} -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. -as_fn_error () -{ - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 - fi - $as_echo "$as_me: error: $1" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by zm $as_me 1.25.0, which was -generated by GNU Autoconf 2.65. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - -case $ac_config_headers in *" -"*) set x $ac_config_headers; shift; ac_config_headers=$*;; -esac - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_headers="$ac_config_headers" -config_commands="$ac_config_commands" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Configuration commands: -$config_commands - -Report bugs to . -zm home page: ." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -zm config.status 1.25.0 -configured by $0, generated by GNU Autoconf 2.65, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2009 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -INSTALL='$INSTALL' -MKDIR_P='$MKDIR_P' -AWK='$AWK' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append CONFIG_HEADERS " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header - as_fn_error "ambiguous option: \`$1' -Try \`$0 --help' for more information.";; - --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# -# INIT-COMMANDS -# -AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" -PERL_MM_PARMS=$PERL_MM_PARMS - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; - "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "zm.conf") CONFIG_FILES="$CONFIG_FILES zm.conf" ;; - "zmconfgen.pl") CONFIG_FILES="$CONFIG_FILES zmconfgen.pl" ;; - "db/Makefile") CONFIG_FILES="$CONFIG_FILES db/Makefile" ;; - "db/zm_create.sql") CONFIG_FILES="$CONFIG_FILES db/zm_create.sql" ;; - "misc/Makefile") CONFIG_FILES="$CONFIG_FILES misc/Makefile" ;; - "misc/apache.conf") CONFIG_FILES="$CONFIG_FILES misc/apache.conf" ;; - "misc/logrotate.conf") CONFIG_FILES="$CONFIG_FILES misc/logrotate.conf" ;; - "misc/syslog.conf") CONFIG_FILES="$CONFIG_FILES misc/syslog.conf" ;; - "scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;; - "scripts/zm") CONFIG_FILES="$CONFIG_FILES scripts/zm" ;; - "scripts/zmaudit.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmaudit.pl" ;; - "scripts/zmcontrol.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmcontrol.pl" ;; - "scripts/zmdc.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmdc.pl" ;; - "scripts/zmfilter.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmfilter.pl" ;; - "scripts/zmpkg.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmpkg.pl" ;; - "scripts/zmtrack.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmtrack.pl" ;; - "scripts/zmtrigger.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmtrigger.pl" ;; - "scripts/zmupdate.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmupdate.pl" ;; - "scripts/zmvideo.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmvideo.pl" ;; - "scripts/zmwatch.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmwatch.pl" ;; - "scripts/zmx10.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmx10.pl" ;; - "scripts/zmdbbackup") CONFIG_FILES="$CONFIG_FILES scripts/zmdbbackup" ;; - "scripts/zmdbrestore") CONFIG_FILES="$CONFIG_FILES scripts/zmdbrestore" ;; - "scripts/zmeventdump") CONFIG_FILES="$CONFIG_FILES scripts/zmeventdump" ;; - "scripts/zmlogrotate.conf") CONFIG_FILES="$CONFIG_FILES scripts/zmlogrotate.conf" ;; - "scripts/ZoneMinder/lib/ZoneMinder/Base.pm") CONFIG_FILES="$CONFIG_FILES scripts/ZoneMinder/lib/ZoneMinder/Base.pm" ;; - "scripts/ZoneMinder/lib/ZoneMinder/Config.pm") CONFIG_FILES="$CONFIG_FILES scripts/ZoneMinder/lib/ZoneMinder/Config.pm" ;; - "scripts/ZoneMinder/lib/ZoneMinder/Memory.pm") CONFIG_FILES="$CONFIG_FILES scripts/ZoneMinder/lib/ZoneMinder/Memory.pm" ;; - "scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm") CONFIG_FILES="$CONFIG_FILES scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm" ;; - "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; - "src/zm_config.h") CONFIG_FILES="$CONFIG_FILES src/zm_config.h" ;; - "web/Makefile") CONFIG_FILES="$CONFIG_FILES web/Makefile" ;; - "web/ajax/Makefile") CONFIG_FILES="$CONFIG_FILES web/ajax/Makefile" ;; - "web/css/Makefile") CONFIG_FILES="$CONFIG_FILES web/css/Makefile" ;; - "web/graphics/Makefile") CONFIG_FILES="$CONFIG_FILES web/graphics/Makefile" ;; - "web/includes/Makefile") CONFIG_FILES="$CONFIG_FILES web/includes/Makefile" ;; - "web/includes/config.php") CONFIG_FILES="$CONFIG_FILES web/includes/config.php" ;; - "web/js/Makefile") CONFIG_FILES="$CONFIG_FILES web/js/Makefile" ;; - "web/lang/Makefile") CONFIG_FILES="$CONFIG_FILES web/lang/Makefile" ;; - "web/skins/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/Makefile" ;; - "web/skins/classic/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/Makefile" ;; - "web/skins/classic/ajax/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/ajax/Makefile" ;; - "web/skins/classic/css/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/css/Makefile" ;; - "web/skins/classic/graphics/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/graphics/Makefile" ;; - "web/skins/classic/includes/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/includes/Makefile" ;; - "web/skins/classic/js/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/js/Makefile" ;; - "web/skins/classic/lang/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/lang/Makefile" ;; - "web/skins/classic/views/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/views/Makefile" ;; - "web/skins/classic/views/css/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/views/css/Makefile" ;; - "web/skins/classic/views/js/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/views/js/Makefile" ;; - "web/skins/mobile/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/Makefile" ;; - "web/skins/mobile/ajax/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/ajax/Makefile" ;; - "web/skins/mobile/css/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/css/Makefile" ;; - "web/skins/mobile/graphics/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/graphics/Makefile" ;; - "web/skins/mobile/includes/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/includes/Makefile" ;; - "web/skins/mobile/lang/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/lang/Makefile" ;; - "web/skins/mobile/views/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/views/Makefile" ;; - "web/skins/mobile/views/css/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/views/css/Makefile" ;; - "web/tools/Makefile") CONFIG_FILES="$CONFIG_FILES web/tools/Makefile" ;; - "web/tools/mootools/Makefile") CONFIG_FILES="$CONFIG_FILES web/tools/mootools/Makefile" ;; - "web/views/Makefile") CONFIG_FILES="$CONFIG_FILES web/views/Makefile" ;; - "web/skins/xml/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/xml/Makefile" ;; - "web/skins/xml/views/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/xml/views/Makefile" ;; - "web/skins/xml/includes/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/xml/includes/Makefile" ;; - "src/zm_config_defines.h") CONFIG_COMMANDS="$CONFIG_COMMANDS src/zm_config_defines.h" ;; - "scripts/ZoneMinder/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS scripts/ZoneMinder/Makefile" ;; - - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= - trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ -s/:*$// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - -# Set up the scripts for CONFIG_HEADERS section. -# No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. -if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || -BEGIN { -_ACEOF - -# Transform confdefs.h into an awk script `defines.awk', embedded as -# here-document in config.status, that substitutes the proper values into -# config.h.in to produce config.h. - -# Create a delimiter string that does not exist in confdefs.h, to ease -# handling of long lines. -ac_delim='%!_!# ' -for ac_last_try in false false :; do - ac_t=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_t"; then - break - elif $ac_last_try; then - as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -# For the awk script, D is an array of macro values keyed by name, -# likewise P contains macro parameters if any. Preserve backslash -# newline sequences. - -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -sed -n ' -s/.\{148\}/&'"$ac_delim"'/g -t rset -:rset -s/^[ ]*#[ ]*define[ ][ ]*/ / -t def -d -:def -s/\\$// -t bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3"/p -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p -d -:bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3\\\\\\n"\\/p -t cont -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p -t cont -d -:cont -n -s/.\{148\}/&'"$ac_delim"'/g -t clear -:clear -s/\\$// -t bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/"/p -d -:bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p -b cont -' >$CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - for (key in D) D_is_set[key] = 1 - FS = "" -} -/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { - line = \$ 0 - split(line, arg, " ") - if (arg[1] == "#") { - defundef = arg[2] - mac1 = arg[3] - } else { - defundef = substr(arg[1], 2) - mac1 = arg[2] - } - split(mac1, mac2, "(") #) - macro = mac2[1] - prefix = substr(line, 1, index(line, defundef) - 1) - if (D_is_set[macro]) { - # Preserve the white space surrounding the "#". - print prefix "define", macro P[macro] D[macro] - next - } else { - # Replace #undef with comments. This is necessary, for example, - # in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - if (defundef == "undef") { - print "/*", prefix defundef, macro, "*/" - next - } - } -} -{ print } -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error "could not setup config headers machinery" "$LINENO" 5 -fi # test -n "$CONFIG_HEADERS" - - -eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - - case $INSTALL in - [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; - esac - ac_MKDIR_P=$MKDIR_P - case $MKDIR_P in - [\\/$]* | ?:[\\/]* ) ;; - */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; - esac -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -s&@INSTALL@&$ac_INSTALL&;t t -s&@MKDIR_P@&$ac_MKDIR_P&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} - - rm -f "$tmp/stdin" - case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; - esac \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 - ;; - :H) - # - # CONFIG_HEADER - # - if test x"$ac_file" != x-; then - { - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -$as_echo "$as_me: $ac_file is unchanged" >&6;} - else - rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 - fi - else - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error "could not create -" "$LINENO" 5 - fi -# Compute "$ac_file"'s index in $config_headers. -_am_arg="$ac_file" -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $_am_arg | $_am_arg:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || -$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$_am_arg" : 'X\(//\)[^/]' \| \ - X"$_am_arg" : 'X\(//\)$' \| \ - X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$_am_arg" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'`/stamp-h$_am_stamp_count - ;; - - :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 -$as_echo "$as_me: executing $ac_file commands" >&6;} - ;; - esac - - - case $ac_file$ac_mode in - "depfiles":C) test x"$AMDEP_TRUE" != x"" || { - # Autoconf 2.62 quotes --file arguments for eval, but not when files - # are listed without --file. Let's play safe and only enable the eval - # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac - shift - for mf - do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`$as_dirname -- "$mf" || -$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$mf" : 'X\(//\)[^/]' \| \ - X"$mf" : 'X\(//\)$' \| \ - X"$mf" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$mf" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`$as_dirname -- "$file" || -$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$file" : 'X\(//\)[^/]' \| \ - X"$file" : 'X\(//\)$' \| \ - X"$file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir=$dirpart/$fdir; as_fn_mkdir_p - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done - done -} - ;; - "src/zm_config_defines.h":C) perl ./zmconfgen.pl ;; - "scripts/ZoneMinder/Makefile":C) (cd scripts/ZoneMinder; echo "perl Makefile.PL $PERL_MM_PARMS"; perl Makefile.PL $PERL_MM_PARMS) ;; - - esac -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit $? -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - diff --git a/scripts/zmdc.pl.in b/scripts/zmdc.pl.in index 86b23ea31..47e50cc39 100644 --- a/scripts/zmdc.pl.in +++ b/scripts/zmdc.pl.in @@ -128,9 +128,6 @@ foreach my $arg ( @ARGV ) } } -# Create the directory first if it doesn't exist -mkdir(ZM_PATH_SOCKS); - socket( CLIENT, PF_UNIX, SOCK_STREAM, 0 ) or Fatal( "Can't open socket: $!" ); my $saddr = sockaddr_un( SOCK_FILE ); diff --git a/scripts/zmwatch.pl.in b/scripts/zmwatch.pl.in index 8df23d226..4d50f0496 100644 --- a/scripts/zmwatch.pl.in +++ b/scripts/zmwatch.pl.in @@ -87,7 +87,6 @@ while( 1 ) { # Check we have got an image recently my $image_time = zmGetLastWriteTime( $monitor ); - zmMemInvalidate( $monitor ); next if ( !defined($image_time) ); # Can't read from shared data next if ( !$image_time ); # We can't get the last capture time so can't be sure it's died. @@ -96,9 +95,9 @@ while( 1 ) Debug( "Monitor $monitor->{Id} last captured $image_delay seconds ago, max is $max_image_delay\n" ); if ( $image_delay > $max_image_delay ) { - Info( "Restarting capture daemon for ".$monitor->{Name}.", time since last capture $image_delay seconds ($now-$image_time)\n" ); - $restart = 1; - } + Info( "Restarting capture daemon for ".$monitor->{Name}.", time since last capture $image_delay seconds ($now-$image_time)\n" ); + $restart = 1; + } } else { @@ -125,7 +124,6 @@ while( 1 ) { # Check we have got an image recently my $image_time = zmGetLastReadTime( $monitor ); - zmMemInvalidate( $monitor ); next if ( !defined($image_time) ); # Can't read from shared data next if ( !$image_time ); # We can't get the last capture time so can't be sure it's died. diff --git a/src/Makefile.in b/src/Makefile.in index b8a76ebdb..5d68f6c42 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -242,7 +242,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = gnu -AM_CPPFLAGS = @MYSQL_CFLAGS@ @FFMPEG_CFLAGS@ -Wall -Wno-sign-compare -fno-inline +AM_CPPFLAGS = @MYSQL_CFLAGS@ @FFMPEG_CFLAGS@ -Wall -Wno-sign-compare -finline-functions #AM_CXXFLAGS = -frepo CLEANFILES = *.rpo From eab09844de151ac544a5d2d0b376a4736ab371fb Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sat, 11 Jun 2011 19:46:55 +0300 Subject: [PATCH 13/56] 1) Some more work on the overlay function. 2) Got rid of some compiler warning messages. --- src/zm_image.cpp | 53 ++++++++++++++++++++++++++++++++++------------ src/zm_monitor.cpp | 6 +++--- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index bc51aade0..dba69b9be 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -317,7 +317,7 @@ void Image::AssignDirect( const int p_width, const int p_height, const int p_col } if(buffer_size < ((p_width*p_height)*p_colours)) { - Error("Attempt to directly assign buffer from an undersized buffer of size: %u",buffer_size); + Error("Attempt to directly assign buffer from an undersized buffer of size: %zu",buffer_size); return; } @@ -377,7 +377,7 @@ void Image::Assign(const int p_width, const int p_height, const int p_colours, c } if(buffer_size < new_size) { - Error("Attempt to assign buffer from an undersized buffer of size: %u",buffer_size); + Error("Attempt to assign buffer from an undersized buffer of size: %zu",buffer_size); return; } @@ -1094,6 +1094,7 @@ bool Image::Crop( const Box &limits ) } +/* At the moment only supports 8bit overlay for 24bit and 32bit images. */ void Image::Overlay( const Image &image ) { if ( !(width == image.width && height == image.height) ) @@ -1122,11 +1123,11 @@ void Image::Overlay( const Image &image ) { Colourise(image.colours, image.subpixelorder); - if(colours == ZM_COLOUR_RGB32) { + if(image.colours == ZM_COLOUR_RGB32) { Rgb* prdest = (Rgb*)buffer; const Rgb* prsrc = (Rgb*)image.buffer; const Rgb* const max_ptr = (Rgb*)(buffer+size); - if(subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + if(image.subpixelorder == ZM_SUBPIX_ORDER_RGBA || image.subpixelorder == ZM_SUBPIX_ORDER_BGRA) { /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ while (prdest < max_ptr) { if ( RED_PTR_RGBA(prsrc) || GREEN_PTR_RGBA(prsrc) || BLUE_PTR_RGBA(prsrc) ) @@ -1167,20 +1168,46 @@ void Image::Overlay( const Image &image ) { if ( image.colours == ZM_COLOUR_GRAY8 ) { - while( pdest < (buffer+size) ) - { - if ( *psrc ) - { - RED_PTR_RGBA(pdest) = GREEN_PTR_RGBA(pdest) = BLUE_PTR_RGBA(pdest) = *psrc++; + if(colours == ZM_COLOUR_RGB32) { + Rgb* prdest = (Rgb*)buffer; + const Rgb* const max_ptr = (Rgb*)(buffer+size); + if(subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ + while (prdest < max_ptr) { + if ( *psrc ) + { + RED_PTR_RGBA(prdest) = GREEN_PTR_RGBA(prdest) = BLUE_PTR_RGBA(prdest) = *psrc++; + } + prdest++; + } + } else { + /* ABGR\ARGB subpixel order - Alpha byte is first */ + while (prdest < max_ptr) { + if ( *psrc ) + { + RED_PTR_ABGR(prdest) = GREEN_PTR_ABGR(prdest) = BLUE_PTR_ABGR(prdest) = *psrc++; + } + prdest++; + } + } + } else { + /* Assume RGB24\BGR24 */ + while( pdest < (buffer+size) ) + { + if ( *psrc ) + { + RED_PTR_RGBA(pdest) = GREEN_PTR_RGBA(pdest) = BLUE_PTR_RGBA(pdest) = *psrc++; + } + pdest += 3; } - pdest += colours; } } else { - - - + + /* At the moment this function only supports 8bit overlay for 24bit and 32bit images. + ** The code below is old and was not updated yet to support the new formats. this code assumes RGB24 + */ while( pdest < (buffer+size) ) { if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 7dc565b19..98cff987d 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1958,7 +1958,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c int width = atoi(dbrow[col]); col++; int height = atoi(dbrow[col]); col++; int colours = atoi(dbrow[col]); col++; - int palette = atoi(dbrow[col]); col++; + /* int palette = atoi(dbrow[col]); */ col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; int contrast = atoi(dbrow[col]); col++; @@ -2117,7 +2117,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu int width = atoi(dbrow[col]); col++; int height = atoi(dbrow[col]); col++; int colours = atoi(dbrow[col]); col++; - int palette = atoi(dbrow[col]); col++; + /* int palette = atoi(dbrow[col]); */ col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; int contrast = atoi(dbrow[col]); col++; @@ -2246,7 +2246,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose int width = atoi(dbrow[col]); col++; int height = atoi(dbrow[col]); col++; int colours = atoi(dbrow[col]); col++; - int palette = atoi(dbrow[col]); col++; + /* int palette = atoi(dbrow[col]); */ col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; int contrast = atoi(dbrow[col]); col++; From 11029d57b653ea895121f7aafad49ec8b95133d0 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 14 Jun 2011 20:38:18 +0300 Subject: [PATCH 14/56] Small code fixes --- src/zm_event.cpp | 2899 ++++++++++++++++++++------------------- src/zm_image.cpp | 2 +- src/zm_image.h | 20 +- src/zm_local_camera.cpp | 2 +- 4 files changed, 1463 insertions(+), 1460 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index bab35225a..ab619192e 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -1,1449 +1,1450 @@ -// -// ZoneMinder Event Class Implementation, $Date$, $Revision$ -// Copyright (C) 2001-2008 Philip Coombes -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "zm.h" -#include "zm_db.h" -#include "zm_time.h" -#include "zm_mpeg.h" -#include "zm_signal.h" -#include "zm_event.h" -#include "zm_monitor.h" - -#include "zmf.h" - -//#define USE_PREPARED_SQL 1 - -bool Event::initialised = false; -char Event::capture_file_format[PATH_MAX]; -char Event::analyse_file_format[PATH_MAX]; -char Event::general_file_format[PATH_MAX]; - -int Event::pre_alarm_count = 0; -Event::PreAlarmData Event::pre_alarm_data[MAX_PRE_ALARM_FRAMES] = { { 0 } }; - -Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string &p_cause, const StringSetMap &p_noteSetMap ) : - monitor( p_monitor ), - start_time( p_start_time ), - cause( p_cause ), - noteSetMap( p_noteSetMap ) -{ - if ( !initialised ) - Initialise(); - - std::string notes; - createNotes( notes ); - - bool untimedEvent = false; - if ( !start_time.tv_sec ) - { - untimedEvent = true; - gettimeofday( &start_time, 0 ); - } - - static char sql[ZM_SQL_MED_BUFSIZ]; - - struct tm *stime = localtime( &start_time.tv_sec ); - snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s' )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str() ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't insert event: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - id = mysql_insert_id( &dbconn ); - if ( untimedEvent ) - { - Warning( "Event %d has zero time, setting to current", id ); - } - end_time.tv_sec = 0; - frames = 0; - alarm_frames = 0; - tot_score = 0; - max_score = 0; - - if ( config.use_deep_storage ) - { - char *path_ptr = path; - path_ptr += snprintf( path_ptr, sizeof(path), "%s/%d", config.dir_events, monitor->Id() ); - - int dt_parts[6]; - dt_parts[0] = stime->tm_year-100; - dt_parts[1] = stime->tm_mon+1; - dt_parts[2] = stime->tm_mday; - dt_parts[3] = stime->tm_hour; - dt_parts[4] = stime->tm_min; - dt_parts[5] = stime->tm_sec; - - char date_path[PATH_MAX] = ""; - char time_path[PATH_MAX] = ""; - char *time_path_ptr = time_path; - for ( int i = 0; i < sizeof(dt_parts)/sizeof(*dt_parts); i++ ) - { - path_ptr += snprintf( path_ptr, sizeof(path)-(path_ptr-path), "/%02d", dt_parts[i] ); - - struct stat statbuf; - errno = 0; - stat( path, &statbuf ); - if ( errno == ENOENT || errno == ENOTDIR ) - { - if ( mkdir( path, 0755 ) ) - { - Fatal( "Can't mkdir %s: %s", path, strerror(errno)); - } - } - if ( i == 2 ) - strncpy( date_path, path, sizeof(date_path) ); - else if ( i >= 3 ) - time_path_ptr += snprintf( time_path_ptr, sizeof(time_path)-(time_path_ptr-time_path), "%s%02d", i>3?"/":"", dt_parts[i] ); - } - char id_file[PATH_MAX]; - // Create event id symlink - snprintf( id_file, sizeof(id_file), "%s/.%d", date_path, id ); - if ( symlink( time_path, id_file ) < 0 ) - Fatal( "Can't symlink %s -> %s: %s", id_file, path, strerror(errno)); - // Create empty id tag file - snprintf( id_file, sizeof(id_file), "%s/.%d", path, id ); - if ( FILE *id_fp = fopen( id_file, "w" ) ) - fclose( id_fp ); - else - Fatal( "Can't fopen %s: %s", id_file, strerror(errno)); - } - else - { - snprintf( path, sizeof(path), "%s/%d/%d", config.dir_events, monitor->Id(), id ); - - struct stat statbuf; - errno = 0; - stat( path, &statbuf ); - if ( errno == ENOENT || errno == ENOTDIR ) - { - if ( mkdir( path, 0755 ) ) - { - Error( "Can't mkdir %s: %s", path, strerror(errno)); - } - } - char id_file[PATH_MAX]; - // Create empty id tag file - snprintf( id_file, sizeof(id_file), "%s/.%d", path, id ); - if ( FILE *id_fp = fopen( id_file, "w" ) ) - fclose( id_fp ); - else - Fatal( "Can't fopen %s: %s", id_file, strerror(errno)); - } - last_db_frame = 0; -} - -Event::~Event() -{ - if ( frames > last_db_frame ) - { - struct DeltaTimeval delta_time; - DELTA_TIMEVAL( delta_time, end_time, start_time, DT_PREC_2 ); - - Debug( 1, "Adding closing frame %d to DB", frames ); - static char sql[ZM_SQL_SML_BUFSIZ]; - snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ( %d, %d, from_unixtime( %ld ), %s%ld.%02ld )", id, frames, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't insert frame: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - } - - static char sql[ZM_SQL_MED_BUFSIZ]; - - struct DeltaTimeval delta_time; - DELTA_TIMEVAL( delta_time, end_time, start_time, DT_PREC_2 ); - - snprintf( sql, sizeof(sql), "update Events set Name='%s%d', EndTime = from_unixtime( %ld ), Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", monitor->EventPrefix(), id, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't update event: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } -} - -void Event::createNotes( std::string ¬es ) -{ - notes.clear(); - for ( StringSetMap::const_iterator mapIter = noteSetMap.begin(); mapIter != noteSetMap.end(); mapIter++ ) - { - notes += mapIter->first; - notes += ": "; - const StringSet &stringSet = mapIter->second; - for ( StringSet::const_iterator setIter = stringSet.begin(); setIter != stringSet.end(); setIter++ ) - { - if ( setIter != stringSet.begin() ) - notes += ", "; - notes += *setIter; - } - } -} - -int Event::sd = -1; - -bool Event::OpenFrameSocket( int monitor_id ) -{ - if ( sd > 0 ) - { - close( sd ); - } - - sd = socket( AF_UNIX, SOCK_STREAM, 0); - if ( sd < 0 ) - { - Error( "Can't create socket: %s", strerror(errno) ); - return( false ); - } - - int socket_buffer_size = config.frame_socket_size; - if ( socket_buffer_size > 0 ) - { - if ( setsockopt( sd, SOL_SOCKET, SO_SNDBUF, &socket_buffer_size, sizeof(socket_buffer_size) ) < 0 ) - { - Error( "Can't get socket buffer size to %d, error = %s", socket_buffer_size, strerror(errno) ); - close( sd ); - sd = -1; - return( false ); - } - } - - int flags; - if ( (flags = fcntl( sd, F_GETFL )) < 0 ) - { - Error( "Can't get socket flags, error = %s", strerror(errno) ); - close( sd ); - sd = -1; - return( false ); - } - flags |= O_NONBLOCK; - if ( fcntl( sd, F_SETFL, flags ) < 0 ) - { - Error( "Can't set socket flags, error = %s", strerror(errno) ); - close( sd ); - sd = -1; - return( false ); - } - - char sock_path[PATH_MAX] = ""; - snprintf( sock_path, sizeof(sock_path), "%s/zmf-%d.sock", config.path_socks, monitor_id ); - - struct sockaddr_un addr; - - strncpy( addr.sun_path, sock_path, sizeof(addr.sun_path) ); - addr.sun_family = AF_UNIX; - - if ( connect( sd, (struct sockaddr *)&addr, strlen(addr.sun_path)+sizeof(addr.sun_family)) < 0 ) - { - Warning( "Can't connect to frame server: %s", strerror(errno) ); - close( sd ); - sd = -1; - return( false ); - } - - Debug( 1, "Opened connection to frame server" ); - return( true ); -} - -bool Event::ValidateFrameSocket( int monitor_id ) -{ - if ( sd < 0 ) - { - return( OpenFrameSocket( monitor_id ) ); - } - return( true ); -} - -bool Event::SendFrameImage( const Image *image, bool alarm_frame ) -{ - if ( !ValidateFrameSocket( monitor->Id() ) ) - { - return( false ); - } - - static int jpg_buffer_size = 0; - static unsigned char jpg_buffer[ZM_MAX_IMAGE_SIZE]; - - image->EncodeJpeg( jpg_buffer, &jpg_buffer_size, (alarm_frame&&(config.jpeg_alarm_file_quality>config.jpeg_file_quality))?config.jpeg_alarm_file_quality:config.jpeg_file_quality ); - - static FrameHeader frame_header; - - frame_header.event_id = id; - if ( config.use_deep_storage ) - frame_header.event_time = start_time.tv_sec; - frame_header.frame_id = frames; - frame_header.alarm_frame = alarm_frame; - frame_header.image_length = jpg_buffer_size; - - struct iovec iovecs[2]; - iovecs[0].iov_base = &frame_header; - iovecs[0].iov_len = sizeof(frame_header); - iovecs[1].iov_base = jpg_buffer; - iovecs[1].iov_len = jpg_buffer_size; - - ssize_t writev_size = sizeof(frame_header)+jpg_buffer_size; - ssize_t writev_result = writev( sd, iovecs, sizeof(iovecs)/sizeof(*iovecs)); - if ( writev_result != writev_size ) - { - if ( writev_result < 0 ) - { - if ( errno == EAGAIN ) - { - Warning( "Blocking write detected" ); - } - else - { - Error( "Can't write frame: %s", strerror(errno) ); - close( sd ); - sd = -1; - } - } - else - { - Error( "Incomplete frame write: %zd of %zd bytes written", writev_result, writev_size ); - close( sd ); - sd = -1; - } - return( false ); - } - Debug( 1, "Wrote frame image, %d bytes", jpg_buffer_size ); - - return( true ); -} - -bool Event::WriteFrameImage( Image *image, struct timeval timestamp, const char *event_file, bool alarm_frame ) -{ - if ( config.timestamp_on_capture ) - { - if ( !config.opt_frame_server || !SendFrameImage( image, alarm_frame) ) - { - if ( alarm_frame && (config.jpeg_alarm_file_quality > config.jpeg_file_quality) ) - image->WriteJpeg( event_file, config.jpeg_alarm_file_quality ); - else - image->WriteJpeg( event_file ); - } - } - else - { - Image ts_image( *image ); - monitor->TimestampImage( &ts_image, ×tamp ); - if ( !config.opt_frame_server || !SendFrameImage( &ts_image, alarm_frame) ) - { - if ( alarm_frame && (config.jpeg_alarm_file_quality > config.jpeg_file_quality) ) - ts_image.WriteJpeg( event_file, config.jpeg_alarm_file_quality ); - else - ts_image.WriteJpeg( event_file ); - } - } - return( true ); -} - -void Event::updateNotes( const StringSetMap &newNoteSetMap ) -{ - bool update = false; - - //Info( "Checking notes, %d <> %d", noteSetMap.size(), newNoteSetMap.size() ); - if ( newNoteSetMap.size() > 0 ) - { - if ( noteSetMap.size() == 0 ) - { - noteSetMap = newNoteSetMap; - update = true; - } - else - { - for ( StringSetMap::const_iterator newNoteSetMapIter = newNoteSetMap.begin(); newNoteSetMapIter != newNoteSetMap.end(); newNoteSetMapIter++ ) - { - const std::string &newNoteGroup = newNoteSetMapIter->first; - const StringSet &newNoteSet = newNoteSetMapIter->second; - //Info( "Got %d new strings", newNoteSet.size() ); - if ( newNoteSet.size() > 0 ) - { - StringSetMap::iterator noteSetMapIter = noteSetMap.find( newNoteGroup ); - if ( noteSetMapIter == noteSetMap.end() ) - { - //Info( "Can't find note group %s, copying %d strings", newNoteGroup.c_str(), newNoteSet.size() ); - noteSetMap.insert( StringSetMap::value_type( newNoteGroup, newNoteSet ) ); - update = true; - } - else - { - StringSet ¬eSet = noteSetMapIter->second; - //Info( "Found note group %s, got %d strings", newNoteGroup.c_str(), newNoteSet.size() ); - for ( StringSet::const_iterator newNoteSetIter = newNoteSet.begin(); newNoteSetIter != newNoteSet.end(); newNoteSetIter++ ) - { - const std::string &newNote = *newNoteSetIter; - StringSet::iterator noteSetIter = noteSet.find( newNote ); - if ( noteSetIter == noteSet.end() ) - { - noteSet.insert( newNote ); - update = true; - } - } - } - } - } - } - } - - if ( update ) - { - std::string notes; - createNotes( notes ); - - Debug( 2, "Updating notes for event %d, '%s'", id, notes.c_str() ); - static char sql[ZM_SQL_MED_BUFSIZ]; -#if USE_PREPARED_SQL - static MYSQL_STMT *stmt = 0; - - char notesStr[ZM_SQL_MED_BUFSIZ] = ""; - unsigned long notesLen = 0; - - if ( !stmt ) - { - const char *sql = "update Events set Notes = ? where Id = ?"; - - stmt = mysql_stmt_init( &dbconn ); - if ( mysql_stmt_prepare( stmt, sql, strlen(sql) ) ) - { - Fatal( "Unable to prepare sql '%s': %s", sql, mysql_stmt_error(stmt) ); - } - - /* Get the parameter count from the statement */ - if ( mysql_stmt_param_count( stmt ) != 2 ) - { - Fatal( "Unexpected parameter count %ld in sql '%s'", mysql_stmt_param_count( stmt ), sql ); - } - - MYSQL_BIND bind[2]; - memset(bind, 0, sizeof(bind)); - - /* STRING PARAM */ - bind[0].buffer_type = MYSQL_TYPE_STRING; - bind[0].buffer = (char *)notesStr; - bind[0].buffer_length = sizeof(notesStr); - bind[0].is_null = 0; - bind[0].length = ¬esLen; - - bind[1].buffer_type= MYSQL_TYPE_LONG; - bind[1].buffer= (char *)&id; - bind[1].is_null= 0; - bind[1].length= 0; - - /* Bind the buffers */ - if ( mysql_stmt_bind_param( stmt, bind ) ) - { - Fatal( "Unable to bind sql '%s': %s", sql, mysql_stmt_error(stmt) ); - } - } - - strncpy( notesStr, notes.c_str(), sizeof(notesStr) ); - notesLen = notes.length(); - - if ( mysql_stmt_execute( stmt ) ) - { - Fatal( "Unable to execute sql '%s': %s", sql, mysql_stmt_error(stmt) ); - } -#else - static char escapedNotes[ZM_SQL_MED_BUFSIZ]; - - mysql_real_escape_string( &dbconn, escapedNotes, notes.c_str(), notes.length() ); - - snprintf( sql, sizeof(sql), "update Events set Notes = '%s' where Id = %d", escapedNotes, id ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't insert event: %s", mysql_error( &dbconn ) ); - } -#endif - } -} - -void Event::AddFrames( int n_frames, Image **images, struct timeval **timestamps ) -{ - static char sql[ZM_SQL_LGE_BUFSIZ]; - strncpy( sql, "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ", sizeof(sql) ); - int frameCount = 0; - for ( int i = 0; i < n_frames; i++ ) - { - if ( !timestamps[i]->tv_sec ) - { - Debug( 1, "Not adding pre-capture frame %d, zero timestamp", i ); - continue; - } - - frames++; - - static char event_file[PATH_MAX]; - snprintf( event_file, sizeof(event_file), capture_file_format, path, frames ); - - Debug( 1, "Writing pre-capture frame %d", frames ); - WriteFrameImage( images[i], *(timestamps[i]), event_file ); - - struct DeltaTimeval delta_time; - DELTA_TIMEVAL( delta_time, *(timestamps[i]), start_time, DT_PREC_2 ); - - int sql_len = strlen(sql); - snprintf( sql+sql_len, sizeof(sql)-sql_len, "( %d, %d, from_unixtime(%ld), %s%ld.%02ld ), ", id, frames, timestamps[i]->tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec ); - - frameCount++; - } - - if ( frameCount ) - { - Debug( 1, "Adding %d/%d frames to DB", frameCount, n_frames ); - *(sql+strlen(sql)-2) = '\0'; - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't insert frames: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - last_db_frame = frames; - } - else - { - Debug( 1, "No valid pre-capture frames to add" ); - } -} - -void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *alarm_image ) -{ - if ( !timestamp.tv_sec ) - { - Debug( 1, "Not adding new frame, zero timestamp" ); - return; - } - - frames++; - - static char event_file[PATH_MAX]; - snprintf( event_file, sizeof(event_file), capture_file_format, path, frames ); - - Debug( 1, "Writing capture frame %d", frames ); - WriteFrameImage( image, timestamp, event_file ); - - struct DeltaTimeval delta_time; - DELTA_TIMEVAL( delta_time, timestamp, start_time, DT_PREC_2 ); - - bool db_frame = (score>=0) || ((frames%config.bulk_frame_interval)==0) || !frames; - - if ( db_frame ) - { - const char *frame_type = score>0?"Alarm":(score<0?"Bulk":"Normal"); - - Debug( 1, "Adding frame %d to DB", frames ); - static char sql[ZM_SQL_MED_BUFSIZ]; - snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %d, %d, '%s', from_unixtime( %ld ), %s%ld.%02ld, %d )", id, frames, frame_type, timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't insert frame: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - last_db_frame = frames; - - // We are writing a bulk frame - if ( score < 0 ) - { - snprintf( sql, sizeof(sql), "update Events set Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't update event: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - } - } - - end_time = timestamp; - - if ( score > 0 ) - { - alarm_frames++; - - tot_score += score; - if ( score > max_score ) - max_score = score; - - if ( alarm_image ) - { - snprintf( event_file, sizeof(event_file), analyse_file_format, path, frames ); - - Debug( 1, "Writing analysis frame %d", frames ); - WriteFrameImage( alarm_image, timestamp, event_file, true ); - } - } - - if ( config.record_diag_images ) - { - char diag_glob[PATH_MAX] = ""; - - snprintf( diag_glob, sizeof(diag_glob), "%s/%d/diag-*.jpg", config.dir_events, monitor->Id() ); - glob_t pglob; - int glob_status = glob( diag_glob, 0, 0, &pglob ); - if ( glob_status != 0 ) - { - if ( glob_status < 0 ) - { - Error( "Can't glob '%s': %s", diag_glob, strerror(errno) ); - } - else - { - Debug( 1, "Can't glob '%s': %d", diag_glob, glob_status ); - } - } - else - { - char new_diag_path[PATH_MAX] = ""; - for ( int i = 0; i < pglob.gl_pathc; i++ ) - { - char *diag_path = pglob.gl_pathv[i]; - - char *diag_file = strstr( diag_path, "diag-" ); - - if ( diag_file ) - { - snprintf( new_diag_path, sizeof(new_diag_path), general_file_format, path, frames, diag_file ); - - if ( rename( diag_path, new_diag_path ) < 0 ) - { - Error( "Can't rename '%s' to '%s': %s", diag_path, new_diag_path, strerror(errno) ); - } - } - } - } - globfree( &pglob ); - } -} - -bool EventStream::loadInitialEventData( int monitor_id, time_t event_time ) -{ - static char sql[ZM_SQL_SML_BUFSIZ]; - - snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %d and unix_timestamp( EndTime ) > %ld order by Id asc limit 1", monitor_id, event_time ); - - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - MYSQL_ROW dbrow = mysql_fetch_row( result ); - - if ( mysql_errno( &dbconn ) ) - { - Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - int init_event_id = atoi( dbrow[0] ); - - mysql_free_result( result ); - - loadEventData( init_event_id ); - - if ( event_time ) - { - curr_stream_time = event_time; - curr_frame_id = 1; - if ( event_time >= event_data->start_time ) - { - for ( int i = 0; i < event_data->frame_count; i++ ) - { - //Info( "eft %d > et %d", event_data->frames[i].timestamp, event_time ); - if ( event_data->frames[i].timestamp >= event_time ) - { - curr_frame_id = i+1; - Debug( 3, "Set cst:%.2f", curr_stream_time ); - Debug( 3, "Set cfid:%d", curr_frame_id ); - break; - } - } - Debug( 3, "Skipping %ld frames", event_data->frame_count ); - } - } - return( true ); -} - -bool EventStream::loadInitialEventData( int init_event_id, int init_frame_id ) -{ - loadEventData( init_event_id ); - - if ( init_frame_id ) - { - curr_stream_time = event_data->frames[init_frame_id-1].timestamp; - curr_frame_id = init_frame_id; - } - else - { - curr_stream_time = event_data->start_time; - } - - return( true ); -} - -bool EventStream::loadEventData( int event_id ) -{ - static char sql[ZM_SQL_MED_BUFSIZ]; - - snprintf( sql, sizeof(sql), "select M.Id, M.Name, E.Frames, unix_timestamp( StartTime ) as StartTimestamp, max(F.Delta)-min(F.Delta) as Duration from Events as E inner join Monitors as M on E.MonitorId = M.Id inner join Frames as F on E.Id = F.EventId where E.Id = %d group by E.Id", event_id ); - - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - if ( !mysql_num_rows( result ) ) - { - Fatal( "Unable to load event %d, not found in DB", event_id ); - } - - MYSQL_ROW dbrow = mysql_fetch_row( result ); - - if ( mysql_errno( &dbconn ) ) - { - Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - delete event_data; - event_data = new EventData; - event_data->event_id = event_id; - event_data->monitor_id = atoi( dbrow[0] ); - event_data->start_time = atoi(dbrow[3]); - if ( config.use_deep_storage ) - { - struct tm *event_time = localtime( &event_data->start_time ); - if ( config.dir_events[0] == '/' ) - snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", config.dir_events, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec ); - else - snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", staticConfig.PATH_WEB.c_str(), config.dir_events, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec ); - } - else - { - if ( config.dir_events[0] == '/' ) - snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%ld", config.dir_events, event_data->monitor_id, event_data->event_id ); - else - snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%ld", staticConfig.PATH_WEB.c_str(), config.dir_events, event_data->monitor_id, event_data->event_id ); - } - event_data->frame_count = atoi(dbrow[2]); - event_data->duration = atof(dbrow[4]); - - updateFrameRate( (double)event_data->frame_count/event_data->duration ); - - mysql_free_result( result ); - - snprintf( sql, sizeof(sql), "select FrameId, unix_timestamp( `TimeStamp` ), Delta from Frames where EventId = %d order by FrameId asc", event_id ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - event_data->n_frames = mysql_num_rows( result ); - - event_data->frames = new FrameData[event_data->frame_count]; - int id, last_id = 0; - time_t timestamp, last_timestamp = event_data->start_time; - double delta, last_delta = 0.0; - while ( ( dbrow = mysql_fetch_row( result ) ) ) - { - id = atoi(dbrow[0]); - timestamp = atoi(dbrow[1]); - delta = atof(dbrow[2]); - int id_diff = id - last_id; - double frame_delta = (delta-last_delta)/id_diff; - if ( id_diff > 1 ) - { - for ( int i = last_id+1; i < id; i++ ) - { - event_data->frames[i-1].timestamp = (time_t)(last_timestamp + ((i-last_id)*frame_delta)); - event_data->frames[i-1].offset = (time_t)(event_data->frames[i-1].timestamp-event_data->start_time); - event_data->frames[i-1].delta = frame_delta; - event_data->frames[i-1].in_db = false; - } - } - event_data->frames[id-1].timestamp = timestamp; - event_data->frames[id-1].offset = (time_t)(event_data->frames[id-1].timestamp-event_data->start_time); - event_data->frames[id-1].delta = id>1?frame_delta:0.0; - event_data->frames[id-1].in_db = true; - last_id = id; - last_delta = delta; - last_timestamp = timestamp; - } - if ( mysql_errno( &dbconn ) ) - { - Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - //for ( int i = 0; i < 250; i++ ) - //{ - //Info( "%d -> %d @ %f (%d)", i+1, event_data->frames[i].timestamp, event_data->frames[i].delta, event_data->frames[i].in_db ); - //} - - mysql_free_result( result ); - - if ( forceEventChange || mode == MODE_ALL_GAPLESS ) - { - if ( replay_rate > 0 ) - curr_stream_time = event_data->frames[0].timestamp; - else - curr_stream_time = event_data->frames[event_data->frame_count-1].timestamp; - } - Debug( 2, "Event:%ld, Frames:%ld, Duration: %.2f", event_data->event_id, event_data->frame_count, event_data->duration ); - - return( true ); -} - -void EventStream::processCommand( const CmdMsg *msg ) -{ - Debug( 2, "Got message, type %d, msg %d", msg->msg_type, msg->msg_data[0] ) - // Check for incoming command - switch( (MsgCommand)msg->msg_data[0] ) - { - case CMD_PAUSE : - { - Debug( 1, "Got PAUSE command" ); - - // Set paused flag - paused = true; - replay_rate = ZM_RATE_BASE; - last_frame_sent = TV_2_FLOAT( now ); - break; - } - case CMD_PLAY : - { - Debug( 1, "Got PLAY command" ); - if ( paused ) - { - // Clear paused flag - paused = false; - } - replay_rate = ZM_RATE_BASE; - break; - } - case CMD_VARPLAY : - { - Debug( 1, "Got VARPLAY command" ); - if ( paused ) - { - // Clear paused flag - paused = false; - } - replay_rate = ntohs(((unsigned char)msg->msg_data[2]<<8)|(unsigned char)msg->msg_data[1])-32768; - break; - } - case CMD_STOP : - { - Debug( 1, "Got STOP command" ); - - // Clear paused flag - paused = false; - break; - } - case CMD_FASTFWD : - { - Debug( 1, "Got FAST FWD command" ); - if ( paused ) - { - // Clear paused flag - paused = false; - } - // Set play rate - switch ( replay_rate ) - { - case 2 * ZM_RATE_BASE : - replay_rate = 5 * ZM_RATE_BASE; - break; - case 5 * ZM_RATE_BASE : - replay_rate = 10 * ZM_RATE_BASE; - break; - case 10 * ZM_RATE_BASE : - replay_rate = 25 * ZM_RATE_BASE; - break; - case 25 * ZM_RATE_BASE : - case 50 * ZM_RATE_BASE : - replay_rate = 50 * ZM_RATE_BASE; - break; - default : - replay_rate = 2 * ZM_RATE_BASE; - break; - } - break; - } - case CMD_SLOWFWD : - { - Debug( 1, "Got SLOW FWD command" ); - // Set paused flag - paused = true; - // Set play rate - replay_rate = ZM_RATE_BASE; - // Set step - step = 1; - break; - } - case CMD_SLOWREV : - { - Debug( 1, "Got SLOW REV command" ); - // Set paused flag - paused = true; - // Set play rate - replay_rate = ZM_RATE_BASE; - // Set step - step = -1; - break; - } - case CMD_FASTREV : - { - Debug( 1, "Got FAST REV command" ); - if ( paused ) - { - // Clear paused flag - paused = false; - } - // Set play rate - switch ( replay_rate ) - { - case -2 * ZM_RATE_BASE : - replay_rate = -5 * ZM_RATE_BASE; - break; - case -5 * ZM_RATE_BASE : - replay_rate = -10 * ZM_RATE_BASE; - break; - case -10 * ZM_RATE_BASE : - replay_rate = -25 * ZM_RATE_BASE; - break; - case -25 * ZM_RATE_BASE : - case -50 * ZM_RATE_BASE : - replay_rate = -50 * ZM_RATE_BASE; - break; - default : - replay_rate = -2 * ZM_RATE_BASE; - break; - } - break; - } - case CMD_ZOOMIN : - { - x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2]; - y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4]; - Debug( 1, "Got ZOOM IN command, to %d,%d", x, y ); - switch ( zoom ) - { - case 100: - zoom = 150; - break; - case 150: - zoom = 200; - break; - case 200: - zoom = 300; - break; - case 300: - zoom = 400; - break; - case 400: - default : - zoom = 500; - break; - } - break; - } - case CMD_ZOOMOUT : - { - Debug( 1, "Got ZOOM OUT command" ); - switch ( zoom ) - { - case 500: - zoom = 400; - break; - case 400: - zoom = 300; - break; - case 300: - zoom = 200; - break; - case 200: - zoom = 150; - break; - case 150: - default : - zoom = 100; - break; - } - break; - } - case CMD_PAN : - { - x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2]; - y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4]; - Debug( 1, "Got PAN command, to %d,%d", x, y ); - break; - } - case CMD_SCALE : - { - scale = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2]; - Debug( 1, "Got SCALE command, to %d", scale ); - break; - } - case CMD_PREV : - { - Debug( 1, "Got PREV command" ); - if ( replay_rate >= 0 ) - curr_frame_id = 0; - else - curr_frame_id = event_data->frame_count-1; - paused = false; - forceEventChange = true; - break; - } - case CMD_NEXT : - { - Debug( 1, "Got NEXT command" ); - if ( replay_rate >= 0 ) - curr_frame_id = event_data->frame_count-1; - else - curr_frame_id = 0; - paused = false; - forceEventChange = true; - break; - } - case CMD_SEEK : - { - int offset = ((unsigned char)msg->msg_data[1]<<24)|((unsigned char)msg->msg_data[2]<<16)|((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4]; - curr_frame_id = (int)(event_data->frame_count*offset/event_data->duration); - Debug( 1, "Got SEEK command, to %d (new cfid: %d)", offset, curr_frame_id ); - break; - } - case CMD_QUERY : - { - Debug( 1, "Got QUERY command, sending STATUS" ); - break; - } - default : - { - // Do nothing, for now - } - } - struct { - int event; - int progress; - int rate; - int zoom; - bool paused; - } status_data; - - status_data.event = event_data->event_id; - status_data.progress = (int)event_data->frames[curr_frame_id-1].offset; - status_data.rate = replay_rate; - status_data.zoom = zoom; - status_data.paused = paused; - Debug( 2, "E:%d, P:%d, p:%d R:%d, Z:%d", - status_data.event, - status_data.paused, - status_data.progress, - status_data.rate, - status_data.zoom - ); - - DataMsg status_msg; - status_msg.msg_type = MSG_DATA_EVENT; - memcpy( &status_msg.msg_data, &status_data, sizeof(status_msg.msg_data) ); - if ( sendto( sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr) ) < 0 ) - { - //if ( errno != EAGAIN ) - { - Error( "Can't sendto on sd %d: %s", sd, strerror(errno) ); - exit( -1 ); - } - } - - updateFrameRate( (double)event_data->frame_count/event_data->duration ); -} - -void EventStream::checkEventLoaded() -{ - bool reload_event = false; - static char sql[ZM_SQL_SML_BUFSIZ]; - - if ( curr_frame_id <= 0 ) - { - snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %ld and Id < %ld order by Id desc limit 1", event_data->monitor_id, event_data->event_id ); - reload_event = true; - } - else if ( curr_frame_id > event_data->frame_count ) - { - snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %ld and Id > %ld order by Id asc limit 1", event_data->monitor_id, event_data->event_id ); - reload_event = true; - } - - if ( reload_event ) - { - if ( forceEventChange || mode != MODE_SINGLE ) - { - //Info( "SQL:%s", sql ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - MYSQL_ROW dbrow = mysql_fetch_row( result ); - - if ( mysql_errno( &dbconn ) ) - { - Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - if ( dbrow ) - { - int event_id = atoi(dbrow[0]); - Debug( 1, "Loading new event %d", event_id ); - - loadEventData( event_id ); - - Debug( 2, "Current frame id = %d", curr_frame_id ); - if ( curr_frame_id <= 0 ) - curr_frame_id = event_data->frame_count; - else - curr_frame_id = 1; - Debug( 2, "New frame id = %d", curr_frame_id ); - } - else - { - if ( curr_frame_id <= 0 ) - curr_frame_id = 1; - else - curr_frame_id = event_data->frame_count; - paused = true; - } - mysql_free_result( result ); - forceEventChange = false; - } - else - { - if ( curr_frame_id <= 0 ) - curr_frame_id = 1; - else - curr_frame_id = event_data->frame_count; - paused = true; - } - } -} - -bool EventStream::sendFrame( int delta_us ) -{ - Debug( 2, "Sending frame %d", curr_frame_id ); - - static char filepath[PATH_MAX]; - static struct stat filestat; - FILE *fdj = NULL; - - snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id ); - -#if HAVE_LIBAVCODEC - if ( type == STREAM_MPEG ) - { - Image image( filepath ); - - Image *send_image = prepareImage( &image ); - - if ( !vid_stream ) - { - vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, send_image->Colours(), send_image->Width(), send_image->Height() ); - fprintf( stdout, "Content-type: %s\r\n\r\n", vid_stream->MimeType() ); - vid_stream->OpenStream(); - } - /* double pts = */ vid_stream->EncodeFrame( send_image->Buffer(), send_image->Size(), config.mpeg_timed_frames, delta_us*1000 ); - } - else -#endif // HAVE_LIBAVCODEC - { - static unsigned char temp_img_buffer[ZM_MAX_IMAGE_SIZE]; - - int img_buffer_size = 0; - uint8_t *img_buffer = temp_img_buffer; - - bool send_raw = ((scale>=ZM_SCALE_BASE)&&(zoom==ZM_SCALE_BASE)); - - fprintf( stdout, "--ZoneMinderFrame\r\n" ); - - if ( type != STREAM_JPEG ) - send_raw = false; - - if ( send_raw ) - { - fdj = fopen( filepath, "rb" ); - if ( !fdj ) - { - Error( "Can't open %s: %s", filepath, strerror(errno) ); - return( false ); - } -#if HAVE_SENDFILE - if( fstat(fileno(fdj),&filestat) < 0 ) { - Error( "Failed getting information about file %s: %s", filepath, strerror(errno) ); - return( false ); - } -#else - img_buffer_size = fread( img_buffer, 1, sizeof(temp_img_buffer), fdj ); -#endif - } - else - { - Image image( filepath ); - - Image *send_image = prepareImage( &image ); - - switch( type ) - { - case STREAM_JPEG : - send_image->EncodeJpeg( img_buffer, &img_buffer_size ); - break; - case STREAM_RAW : - img_buffer = (uint8_t*)(send_image->Buffer()); - img_buffer_size = send_image->Size(); - break; - case STREAM_ZIP : - unsigned long zip_buffer_size; - send_image->Zip( img_buffer, &zip_buffer_size ); - img_buffer_size = zip_buffer_size; - break; - default: - Fatal( "Unexpected frame type %d", type ); - break; - } - } - - switch( type ) - { - case STREAM_JPEG : - fprintf( stdout, "Content-Type: image/jpeg\r\n" ); - break; - case STREAM_RAW : - fprintf( stdout, "Content-Type: image/x-rgb\r\n" ); - break; - case STREAM_ZIP : - fprintf( stdout, "Content-Type: image/x-rgbz\r\n" ); - break; - default : - Fatal( "Unexpected frame type %d", type ); - break; - } - - - if(send_raw) { -#if HAVE_SENDFILE - fprintf( stdout, "Content-Length: %d\r\n\r\n", (int)filestat.st_size ); - if(sendfile(fileno(stdout), fileno(fdj), 0, (int)filestat.st_size) != (int)filestat.st_size) { - Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno)); - return( false ); - } -#else - if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) { - Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno)); - return( false ); - } -#endif - fclose(fdj); /* Close the file handle */ - } else { - fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size ); - if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) - { - Error( "Unable to send stream frame: %s", strerror(errno) ); - return( false ); - } - } - - fprintf( stdout, "\r\n\r\n" ); - fflush( stdout ); - } - last_frame_sent = TV_2_FLOAT( now ); - return( true ); -} - -void EventStream::runStream() -{ - Event::Initialise(); - - openComms(); - - checkInitialised(); - - updateFrameRate( (double)event_data->frame_count/event_data->duration ); - - if ( type == STREAM_JPEG ) - fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" ); - - if ( !event_data ) - { - sendTextFrame( "No event data found" ); - exit( 0 ); - } - - unsigned int delta_us = 0; - while( !zm_terminate ) - { - gettimeofday( &now, NULL ); - - checkCommandQueue(); - - if ( step != 0 ) - curr_frame_id += step; - - checkEventLoaded(); - - // Get current frame data - FrameData *frame_data = &event_data->frames[curr_frame_id-1]; - - //Info( "cst:%.2f", curr_stream_time ); - //Info( "cfid:%d", curr_frame_id ); - //Info( "fdt:%d", frame_data->timestamp ); - if ( !paused ) - { - bool in_event = true; - double time_to_event = 0; - if ( replay_rate > 0 ) - { - time_to_event = event_data->frames[0].timestamp - curr_stream_time; - if ( time_to_event > 0 ) - in_event = false; - } - else if ( replay_rate < 0 ) - { - time_to_event = curr_stream_time - event_data->frames[event_data->frame_count-1].timestamp; - if ( time_to_event > 0 ) - in_event = false; - } - if ( !in_event ) - { - double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent; - if ( actual_delta_time > 1 ) - { - static char frame_text[64]; - snprintf( frame_text, sizeof(frame_text), "Time to next event = %d seconds", (int)time_to_event ); - if ( !sendTextFrame( frame_text ) ) - zm_terminate = true; - } - //else - //{ - usleep( STREAM_PAUSE_WAIT ); - //curr_stream_time += (replay_rate>0?1:-1) * ((1.0L * replay_rate * STREAM_PAUSE_WAIT)/(ZM_RATE_BASE * 1000000)); - curr_stream_time += (1.0L * replay_rate * STREAM_PAUSE_WAIT)/(ZM_RATE_BASE * 1000000); - //} - continue; - } - } - - // Figure out if we should send this frame - bool send_frame = false; - if ( !paused ) - { - // If we are streaming and this frame is due to be sent - if ( ((curr_frame_id-1)%frame_mod) == 0 ) - { - delta_us = (unsigned int)(frame_data->delta * 1000000); - if ( effective_fps < base_fps ) - delta_us = (unsigned int)((delta_us * base_fps)/effective_fps); - send_frame = true; - } - } - else if ( step != 0 ) - { - // We are paused and are just stepping forward or backward one frame - step = 0; - send_frame = true; - } - else - { - // We are paused, and doing nothing - double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent; - if ( actual_delta_time > MAX_STREAM_DELAY ) - { - // Send keepalive - Debug( 2, "Sending keepalive frame" ); - send_frame = true; - } - } - - if ( send_frame ) - if ( !sendFrame( delta_us ) ) - zm_terminate = true; - - curr_stream_time = frame_data->timestamp; - - if ( !paused ) - { - curr_frame_id += replay_rate>0?1:-1; - if ( send_frame && type != STREAM_MPEG ) - { - Debug( 3, "dUs: %d", delta_us ); - usleep( delta_us ); - } - } - else - { - usleep( STREAM_PAUSE_WAIT ); - } - } -#if HAVE_LIBAVCODEC - if ( type == STREAM_MPEG ) - delete vid_stream; -#endif // HAVE_LIBAVCODEC - - closeComms(); -} - +// +// ZoneMinder Event Class Implementation, $Date: 2010-11-11 12:22:35 +0000 (Thu, 11 Nov 2010) $, $Revision: 3189 $ +// Copyright (C) 2001-2008 Philip Coombes +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "zm.h" +#include "zm_db.h" +#include "zm_time.h" +#include "zm_mpeg.h" +#include "zm_signal.h" +#include "zm_event.h" +#include "zm_monitor.h" + +#include "zmf.h" + +#if HAVE_SYS_SENDFILE_H +#include +#endif + +//#define USE_PREPARED_SQL 1 + +bool Event::initialised = false; +char Event::capture_file_format[PATH_MAX]; +char Event::analyse_file_format[PATH_MAX]; +char Event::general_file_format[PATH_MAX]; + +int Event::pre_alarm_count = 0; +Event::PreAlarmData Event::pre_alarm_data[MAX_PRE_ALARM_FRAMES] = { { 0 } }; + +Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string &p_cause, const StringSetMap &p_noteSetMap ) : + monitor( p_monitor ), + start_time( p_start_time ), + cause( p_cause ), + noteSetMap( p_noteSetMap ) +{ + if ( !initialised ) + Initialise(); + + std::string notes; + createNotes( notes ); + + bool untimedEvent = false; + if ( !start_time.tv_sec ) + { + untimedEvent = true; + gettimeofday( &start_time, 0 ); + } + + static char sql[ZM_SQL_MED_BUFSIZ]; + + struct tm *stime = localtime( &start_time.tv_sec ); + snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s' )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str() ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't insert event: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + id = mysql_insert_id( &dbconn ); + if ( untimedEvent ) + { + Warning( "Event %d has zero time, setting to current", id ); + } + end_time.tv_sec = 0; + frames = 0; + alarm_frames = 0; + tot_score = 0; + max_score = 0; + + if ( config.use_deep_storage ) + { + char *path_ptr = path; + path_ptr += snprintf( path_ptr, sizeof(path), "%s/%d", config.dir_events, monitor->Id() ); + + int dt_parts[6]; + dt_parts[0] = stime->tm_year-100; + dt_parts[1] = stime->tm_mon+1; + dt_parts[2] = stime->tm_mday; + dt_parts[3] = stime->tm_hour; + dt_parts[4] = stime->tm_min; + dt_parts[5] = stime->tm_sec; + + char date_path[PATH_MAX] = ""; + char time_path[PATH_MAX] = ""; + char *time_path_ptr = time_path; + for ( int i = 0; i < sizeof(dt_parts)/sizeof(*dt_parts); i++ ) + { + path_ptr += snprintf( path_ptr, sizeof(path)-(path_ptr-path), "/%02d", dt_parts[i] ); + + struct stat statbuf; + errno = 0; + stat( path, &statbuf ); + if ( errno == ENOENT || errno == ENOTDIR ) + { + if ( mkdir( path, 0755 ) ) + { + Fatal( "Can't mkdir %s: %s", path, strerror(errno)); + } + } + if ( i == 2 ) + strncpy( date_path, path, sizeof(date_path) ); + else if ( i >= 3 ) + time_path_ptr += snprintf( time_path_ptr, sizeof(time_path)-(time_path_ptr-time_path), "%s%02d", i>3?"/":"", dt_parts[i] ); + } + char id_file[PATH_MAX]; + // Create event id symlink + snprintf( id_file, sizeof(id_file), "%s/.%d", date_path, id ); + if ( symlink( time_path, id_file ) < 0 ) + Fatal( "Can't symlink %s -> %s: %s", id_file, path, strerror(errno)); + // Create empty id tag file + snprintf( id_file, sizeof(id_file), "%s/.%d", path, id ); + if ( FILE *id_fp = fopen( id_file, "w" ) ) + fclose( id_fp ); + else + Fatal( "Can't fopen %s: %s", id_file, strerror(errno)); + } + else + { + snprintf( path, sizeof(path), "%s/%d/%d", config.dir_events, monitor->Id(), id ); + + struct stat statbuf; + errno = 0; + stat( path, &statbuf ); + if ( errno == ENOENT || errno == ENOTDIR ) + { + if ( mkdir( path, 0755 ) ) + { + Error( "Can't mkdir %s: %s", path, strerror(errno)); + } + } + char id_file[PATH_MAX]; + // Create empty id tag file + snprintf( id_file, sizeof(id_file), "%s/.%d", path, id ); + if ( FILE *id_fp = fopen( id_file, "w" ) ) + fclose( id_fp ); + else + Fatal( "Can't fopen %s: %s", id_file, strerror(errno)); + } + last_db_frame = 0; +} + +Event::~Event() +{ + if ( frames > last_db_frame ) + { + struct DeltaTimeval delta_time; + DELTA_TIMEVAL( delta_time, end_time, start_time, DT_PREC_2 ); + + Debug( 1, "Adding closing frame %d to DB", frames ); + static char sql[ZM_SQL_SML_BUFSIZ]; + snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ( %d, %d, from_unixtime( %ld ), %s%ld.%02ld )", id, frames, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't insert frame: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + } + + static char sql[ZM_SQL_MED_BUFSIZ]; + + struct DeltaTimeval delta_time; + DELTA_TIMEVAL( delta_time, end_time, start_time, DT_PREC_2 ); + + snprintf( sql, sizeof(sql), "update Events set Name='%s%d', EndTime = from_unixtime( %ld ), Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", monitor->EventPrefix(), id, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't update event: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } +} + +void Event::createNotes( std::string ¬es ) +{ + notes.clear(); + for ( StringSetMap::const_iterator mapIter = noteSetMap.begin(); mapIter != noteSetMap.end(); mapIter++ ) + { + notes += mapIter->first; + notes += ": "; + const StringSet &stringSet = mapIter->second; + for ( StringSet::const_iterator setIter = stringSet.begin(); setIter != stringSet.end(); setIter++ ) + { + if ( setIter != stringSet.begin() ) + notes += ", "; + notes += *setIter; + } + } +} + +int Event::sd = -1; + +bool Event::OpenFrameSocket( int monitor_id ) +{ + if ( sd > 0 ) + { + close( sd ); + } + + sd = socket( AF_UNIX, SOCK_STREAM, 0); + if ( sd < 0 ) + { + Error( "Can't create socket: %s", strerror(errno) ); + return( false ); + } + + int socket_buffer_size = config.frame_socket_size; + if ( socket_buffer_size > 0 ) + { + if ( setsockopt( sd, SOL_SOCKET, SO_SNDBUF, &socket_buffer_size, sizeof(socket_buffer_size) ) < 0 ) + { + Error( "Can't get socket buffer size to %d, error = %s", socket_buffer_size, strerror(errno) ); + close( sd ); + sd = -1; + return( false ); + } + } + + int flags; + if ( (flags = fcntl( sd, F_GETFL )) < 0 ) + { + Error( "Can't get socket flags, error = %s", strerror(errno) ); + close( sd ); + sd = -1; + return( false ); + } + flags |= O_NONBLOCK; + if ( fcntl( sd, F_SETFL, flags ) < 0 ) + { + Error( "Can't set socket flags, error = %s", strerror(errno) ); + close( sd ); + sd = -1; + return( false ); + } + + char sock_path[PATH_MAX] = ""; + snprintf( sock_path, sizeof(sock_path), "%s/zmf-%d.sock", config.path_socks, monitor_id ); + + struct sockaddr_un addr; + + strncpy( addr.sun_path, sock_path, sizeof(addr.sun_path) ); + addr.sun_family = AF_UNIX; + + if ( connect( sd, (struct sockaddr *)&addr, strlen(addr.sun_path)+sizeof(addr.sun_family)) < 0 ) + { + Warning( "Can't connect to frame server: %s", strerror(errno) ); + close( sd ); + sd = -1; + return( false ); + } + + Debug( 1, "Opened connection to frame server" ); + return( true ); +} + +bool Event::ValidateFrameSocket( int monitor_id ) +{ + if ( sd < 0 ) + { + return( OpenFrameSocket( monitor_id ) ); + } + return( true ); +} + +bool Event::SendFrameImage( const Image *image, bool alarm_frame ) +{ + if ( !ValidateFrameSocket( monitor->Id() ) ) + { + return( false ); + } + + static int jpg_buffer_size = 0; + static unsigned char jpg_buffer[ZM_MAX_IMAGE_SIZE]; + + image->EncodeJpeg( jpg_buffer, &jpg_buffer_size, (alarm_frame&&(config.jpeg_alarm_file_quality>config.jpeg_file_quality))?config.jpeg_alarm_file_quality:config.jpeg_file_quality ); + + static FrameHeader frame_header; + + frame_header.event_id = id; + if ( config.use_deep_storage ) + frame_header.event_time = start_time.tv_sec; + frame_header.frame_id = frames; + frame_header.alarm_frame = alarm_frame; + frame_header.image_length = jpg_buffer_size; + + struct iovec iovecs[2]; + iovecs[0].iov_base = &frame_header; + iovecs[0].iov_len = sizeof(frame_header); + iovecs[1].iov_base = jpg_buffer; + iovecs[1].iov_len = jpg_buffer_size; + + ssize_t writev_size = sizeof(frame_header)+jpg_buffer_size; + ssize_t writev_result = writev( sd, iovecs, sizeof(iovecs)/sizeof(*iovecs)); + if ( writev_result != writev_size ) + { + if ( writev_result < 0 ) + { + if ( errno == EAGAIN ) + { + Warning( "Blocking write detected" ); + } + else + { + Error( "Can't write frame: %s", strerror(errno) ); + close( sd ); + sd = -1; + } + } + else + { + Error( "Incomplete frame write: %zd of %zd bytes written", writev_result, writev_size ); + close( sd ); + sd = -1; + } + return( false ); + } + Debug( 1, "Wrote frame image, %d bytes", jpg_buffer_size ); + + return( true ); +} + +bool Event::WriteFrameImage( Image *image, struct timeval timestamp, const char *event_file, bool alarm_frame ) +{ + if ( config.timestamp_on_capture ) + { + if ( !config.opt_frame_server || !SendFrameImage( image, alarm_frame) ) + { + if ( alarm_frame && (config.jpeg_alarm_file_quality > config.jpeg_file_quality) ) + image->WriteJpeg( event_file, config.jpeg_alarm_file_quality ); + else + image->WriteJpeg( event_file ); + } + } + else + { + Image ts_image( *image ); + monitor->TimestampImage( &ts_image, ×tamp ); + if ( !config.opt_frame_server || !SendFrameImage( &ts_image, alarm_frame) ) + { + if ( alarm_frame && (config.jpeg_alarm_file_quality > config.jpeg_file_quality) ) + ts_image.WriteJpeg( event_file, config.jpeg_alarm_file_quality ); + else + ts_image.WriteJpeg( event_file ); + } + } + return( true ); +} + +void Event::updateNotes( const StringSetMap &newNoteSetMap ) +{ + bool update = false; + + //Info( "Checking notes, %d <> %d", noteSetMap.size(), newNoteSetMap.size() ); + if ( newNoteSetMap.size() > 0 ) + { + if ( noteSetMap.size() == 0 ) + { + noteSetMap = newNoteSetMap; + update = true; + } + else + { + for ( StringSetMap::const_iterator newNoteSetMapIter = newNoteSetMap.begin(); newNoteSetMapIter != newNoteSetMap.end(); newNoteSetMapIter++ ) + { + const std::string &newNoteGroup = newNoteSetMapIter->first; + const StringSet &newNoteSet = newNoteSetMapIter->second; + //Info( "Got %d new strings", newNoteSet.size() ); + if ( newNoteSet.size() > 0 ) + { + StringSetMap::iterator noteSetMapIter = noteSetMap.find( newNoteGroup ); + if ( noteSetMapIter == noteSetMap.end() ) + { + //Info( "Can't find note group %s, copying %d strings", newNoteGroup.c_str(), newNoteSet.size() ); + noteSetMap.insert( StringSetMap::value_type( newNoteGroup, newNoteSet ) ); + update = true; + } + else + { + StringSet ¬eSet = noteSetMapIter->second; + //Info( "Found note group %s, got %d strings", newNoteGroup.c_str(), newNoteSet.size() ); + for ( StringSet::const_iterator newNoteSetIter = newNoteSet.begin(); newNoteSetIter != newNoteSet.end(); newNoteSetIter++ ) + { + const std::string &newNote = *newNoteSetIter; + StringSet::iterator noteSetIter = noteSet.find( newNote ); + if ( noteSetIter == noteSet.end() ) + { + noteSet.insert( newNote ); + update = true; + } + } + } + } + } + } + } + + if ( update ) + { + std::string notes; + createNotes( notes ); + + Debug( 2, "Updating notes for event %d, '%s'", id, notes.c_str() ); + static char sql[ZM_SQL_MED_BUFSIZ]; +#if USE_PREPARED_SQL + static MYSQL_STMT *stmt = 0; + + char notesStr[ZM_SQL_MED_BUFSIZ] = ""; + unsigned long notesLen = 0; + + if ( !stmt ) + { + const char *sql = "update Events set Notes = ? where Id = ?"; + + stmt = mysql_stmt_init( &dbconn ); + if ( mysql_stmt_prepare( stmt, sql, strlen(sql) ) ) + { + Fatal( "Unable to prepare sql '%s': %s", sql, mysql_stmt_error(stmt) ); + } + + /* Get the parameter count from the statement */ + if ( mysql_stmt_param_count( stmt ) != 2 ) + { + Fatal( "Unexpected parameter count %ld in sql '%s'", mysql_stmt_param_count( stmt ), sql ); + } + + MYSQL_BIND bind[2]; + memset(bind, 0, sizeof(bind)); + + /* STRING PARAM */ + bind[0].buffer_type = MYSQL_TYPE_STRING; + bind[0].buffer = (char *)notesStr; + bind[0].buffer_length = sizeof(notesStr); + bind[0].is_null = 0; + bind[0].length = ¬esLen; + + bind[1].buffer_type= MYSQL_TYPE_LONG; + bind[1].buffer= (char *)&id; + bind[1].is_null= 0; + bind[1].length= 0; + + /* Bind the buffers */ + if ( mysql_stmt_bind_param( stmt, bind ) ) + { + Fatal( "Unable to bind sql '%s': %s", sql, mysql_stmt_error(stmt) ); + } + } + + strncpy( notesStr, notes.c_str(), sizeof(notesStr) ); + notesLen = notes.length(); + + if ( mysql_stmt_execute( stmt ) ) + { + Fatal( "Unable to execute sql '%s': %s", sql, mysql_stmt_error(stmt) ); + } +#else + static char escapedNotes[ZM_SQL_MED_BUFSIZ]; + + mysql_real_escape_string( &dbconn, escapedNotes, notes.c_str(), notes.length() ); + + snprintf( sql, sizeof(sql), "update Events set Notes = '%s' where Id = %d", escapedNotes, id ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't insert event: %s", mysql_error( &dbconn ) ); + } +#endif + } +} + +void Event::AddFrames( int n_frames, Image **images, struct timeval **timestamps ) +{ + static char sql[ZM_SQL_LGE_BUFSIZ]; + strncpy( sql, "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ", sizeof(sql) ); + int frameCount = 0; + for ( int i = 0; i < n_frames; i++ ) + { + if ( !timestamps[i]->tv_sec ) + { + Debug( 1, "Not adding pre-capture frame %d, zero timestamp", i ); + continue; + } + + frames++; + + static char event_file[PATH_MAX]; + snprintf( event_file, sizeof(event_file), capture_file_format, path, frames ); + + Debug( 1, "Writing pre-capture frame %d", frames ); + WriteFrameImage( images[i], *(timestamps[i]), event_file ); + + struct DeltaTimeval delta_time; + DELTA_TIMEVAL( delta_time, *(timestamps[i]), start_time, DT_PREC_2 ); + + int sql_len = strlen(sql); + snprintf( sql+sql_len, sizeof(sql)-sql_len, "( %d, %d, from_unixtime(%ld), %s%ld.%02ld ), ", id, frames, timestamps[i]->tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec ); + + frameCount++; + } + + if ( frameCount ) + { + Debug( 1, "Adding %d/%d frames to DB", frameCount, n_frames ); + *(sql+strlen(sql)-2) = '\0'; + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't insert frames: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + last_db_frame = frames; + } + else + { + Debug( 1, "No valid pre-capture frames to add" ); + } +} + +void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *alarm_image ) +{ + if ( !timestamp.tv_sec ) + { + Debug( 1, "Not adding new frame, zero timestamp" ); + return; + } + + frames++; + + static char event_file[PATH_MAX]; + snprintf( event_file, sizeof(event_file), capture_file_format, path, frames ); + + Debug( 1, "Writing capture frame %d", frames ); + WriteFrameImage( image, timestamp, event_file ); + + struct DeltaTimeval delta_time; + DELTA_TIMEVAL( delta_time, timestamp, start_time, DT_PREC_2 ); + + bool db_frame = (score>=0) || ((frames%config.bulk_frame_interval)==0) || !frames; + + if ( db_frame ) + { + const char *frame_type = score>0?"Alarm":(score<0?"Bulk":"Normal"); + + Debug( 1, "Adding frame %d to DB", frames ); + static char sql[ZM_SQL_MED_BUFSIZ]; + snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %d, %d, '%s', from_unixtime( %ld ), %s%ld.%02ld, %d )", id, frames, frame_type, timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't insert frame: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + last_db_frame = frames; + + // We are writing a bulk frame + if ( score < 0 ) + { + snprintf( sql, sizeof(sql), "update Events set Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't update event: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + } + } + + end_time = timestamp; + + if ( score > 0 ) + { + alarm_frames++; + + tot_score += score; + if ( score > max_score ) + max_score = score; + + if ( alarm_image ) + { + snprintf( event_file, sizeof(event_file), analyse_file_format, path, frames ); + + Debug( 1, "Writing analysis frame %d", frames ); + WriteFrameImage( alarm_image, timestamp, event_file, true ); + } + } + + if ( config.record_diag_images ) + { + char diag_glob[PATH_MAX] = ""; + + snprintf( diag_glob, sizeof(diag_glob), "%s/%d/diag-*.jpg", config.dir_events, monitor->Id() ); + glob_t pglob; + int glob_status = glob( diag_glob, 0, 0, &pglob ); + if ( glob_status != 0 ) + { + if ( glob_status < 0 ) + { + Error( "Can't glob '%s': %s", diag_glob, strerror(errno) ); + } + else + { + Debug( 1, "Can't glob '%s': %d", diag_glob, glob_status ); + } + } + else + { + char new_diag_path[PATH_MAX] = ""; + for ( int i = 0; i < pglob.gl_pathc; i++ ) + { + char *diag_path = pglob.gl_pathv[i]; + + char *diag_file = strstr( diag_path, "diag-" ); + + if ( diag_file ) + { + snprintf( new_diag_path, sizeof(new_diag_path), general_file_format, path, frames, diag_file ); + + if ( rename( diag_path, new_diag_path ) < 0 ) + { + Error( "Can't rename '%s' to '%s': %s", diag_path, new_diag_path, strerror(errno) ); + } + } + } + } + globfree( &pglob ); + } +} + +bool EventStream::loadInitialEventData( int monitor_id, time_t event_time ) +{ + static char sql[ZM_SQL_SML_BUFSIZ]; + + snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %d and unix_timestamp( EndTime ) > %ld order by Id asc limit 1", monitor_id, event_time ); + + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't run query: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + MYSQL_RES *result = mysql_store_result( &dbconn ); + if ( !result ) + { + Error( "Can't use query result: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + MYSQL_ROW dbrow = mysql_fetch_row( result ); + + if ( mysql_errno( &dbconn ) ) + { + Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + int init_event_id = atoi( dbrow[0] ); + + mysql_free_result( result ); + + loadEventData( init_event_id ); + + if ( event_time ) + { + curr_stream_time = event_time; + curr_frame_id = 1; + if ( event_time >= event_data->start_time ) + { + for ( int i = 0; i < event_data->frame_count; i++ ) + { + //Info( "eft %d > et %d", event_data->frames[i].timestamp, event_time ); + if ( event_data->frames[i].timestamp >= event_time ) + { + curr_frame_id = i+1; + Debug( 3, "Set cst:%.2f", curr_stream_time ); + Debug( 3, "Set cfid:%d", curr_frame_id ); + break; + } + } + Debug( 3, "Skipping %ld frames", event_data->frame_count ); + } + } + return( true ); +} + +bool EventStream::loadInitialEventData( int init_event_id, int init_frame_id ) +{ + loadEventData( init_event_id ); + + if ( init_frame_id ) + { + curr_stream_time = event_data->frames[init_frame_id-1].timestamp; + curr_frame_id = init_frame_id; + } + else + { + curr_stream_time = event_data->start_time; + } + + return( true ); +} + +bool EventStream::loadEventData( int event_id ) +{ + static char sql[ZM_SQL_MED_BUFSIZ]; + + snprintf( sql, sizeof(sql), "select M.Id, M.Name, E.Frames, unix_timestamp( StartTime ) as StartTimestamp, max(F.Delta)-min(F.Delta) as Duration from Events as E inner join Monitors as M on E.MonitorId = M.Id inner join Frames as F on E.Id = F.EventId where E.Id = %d group by E.Id", event_id ); + + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't run query: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + MYSQL_RES *result = mysql_store_result( &dbconn ); + if ( !result ) + { + Error( "Can't use query result: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + if ( !mysql_num_rows( result ) ) + { + Fatal( "Unable to load event %d, not found in DB", event_id ); + } + + MYSQL_ROW dbrow = mysql_fetch_row( result ); + + if ( mysql_errno( &dbconn ) ) + { + Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + delete event_data; + event_data = new EventData; + event_data->event_id = event_id; + event_data->monitor_id = atoi( dbrow[0] ); + event_data->start_time = atoi(dbrow[3]); + if ( config.use_deep_storage ) + { + struct tm *event_time = localtime( &event_data->start_time ); + if ( config.dir_events[0] == '/' ) + snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", config.dir_events, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec ); + else + snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", staticConfig.PATH_WEB.c_str(), config.dir_events, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec ); + } + else + { + if ( config.dir_events[0] == '/' ) + snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%ld", config.dir_events, event_data->monitor_id, event_data->event_id ); + else + snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%ld", staticConfig.PATH_WEB.c_str(), config.dir_events, event_data->monitor_id, event_data->event_id ); + } + event_data->frame_count = atoi(dbrow[2]); + event_data->duration = atof(dbrow[4]); + + updateFrameRate( (double)event_data->frame_count/event_data->duration ); + + mysql_free_result( result ); + + snprintf( sql, sizeof(sql), "select FrameId, unix_timestamp( `TimeStamp` ), Delta from Frames where EventId = %d order by FrameId asc", event_id ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't run query: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + result = mysql_store_result( &dbconn ); + if ( !result ) + { + Error( "Can't use query result: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + event_data->n_frames = mysql_num_rows( result ); + + event_data->frames = new FrameData[event_data->frame_count]; + int id, last_id = 0; + time_t timestamp, last_timestamp = event_data->start_time; + double delta, last_delta = 0.0; + while ( ( dbrow = mysql_fetch_row( result ) ) ) + { + id = atoi(dbrow[0]); + timestamp = atoi(dbrow[1]); + delta = atof(dbrow[2]); + int id_diff = id - last_id; + double frame_delta = (delta-last_delta)/id_diff; + if ( id_diff > 1 ) + { + for ( int i = last_id+1; i < id; i++ ) + { + event_data->frames[i-1].timestamp = (time_t)(last_timestamp + ((i-last_id)*frame_delta)); + event_data->frames[i-1].offset = (time_t)(event_data->frames[i-1].timestamp-event_data->start_time); + event_data->frames[i-1].delta = frame_delta; + event_data->frames[i-1].in_db = false; + } + } + event_data->frames[id-1].timestamp = timestamp; + event_data->frames[id-1].offset = (time_t)(event_data->frames[id-1].timestamp-event_data->start_time); + event_data->frames[id-1].delta = id>1?frame_delta:0.0; + event_data->frames[id-1].in_db = true; + last_id = id; + last_delta = delta; + last_timestamp = timestamp; + } + if ( mysql_errno( &dbconn ) ) + { + Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + //for ( int i = 0; i < 250; i++ ) + //{ + //Info( "%d -> %d @ %f (%d)", i+1, event_data->frames[i].timestamp, event_data->frames[i].delta, event_data->frames[i].in_db ); + //} + + mysql_free_result( result ); + + if ( forceEventChange || mode == MODE_ALL_GAPLESS ) + { + if ( replay_rate > 0 ) + curr_stream_time = event_data->frames[0].timestamp; + else + curr_stream_time = event_data->frames[event_data->frame_count-1].timestamp; + } + Debug( 2, "Event:%ld, Frames:%ld, Duration: %.2f", event_data->event_id, event_data->frame_count, event_data->duration ); + + return( true ); +} + +void EventStream::processCommand( const CmdMsg *msg ) +{ + Debug( 2, "Got message, type %d, msg %d", msg->msg_type, msg->msg_data[0] ) + // Check for incoming command + switch( (MsgCommand)msg->msg_data[0] ) + { + case CMD_PAUSE : + { + Debug( 1, "Got PAUSE command" ); + + // Set paused flag + paused = true; + replay_rate = ZM_RATE_BASE; + last_frame_sent = TV_2_FLOAT( now ); + break; + } + case CMD_PLAY : + { + Debug( 1, "Got PLAY command" ); + if ( paused ) + { + // Clear paused flag + paused = false; + } + replay_rate = ZM_RATE_BASE; + break; + } + case CMD_VARPLAY : + { + Debug( 1, "Got VARPLAY command" ); + if ( paused ) + { + // Clear paused flag + paused = false; + } + replay_rate = ntohs(((unsigned char)msg->msg_data[2]<<8)|(unsigned char)msg->msg_data[1])-32768; + break; + } + case CMD_STOP : + { + Debug( 1, "Got STOP command" ); + + // Clear paused flag + paused = false; + break; + } + case CMD_FASTFWD : + { + Debug( 1, "Got FAST FWD command" ); + if ( paused ) + { + // Clear paused flag + paused = false; + } + // Set play rate + switch ( replay_rate ) + { + case 2 * ZM_RATE_BASE : + replay_rate = 5 * ZM_RATE_BASE; + break; + case 5 * ZM_RATE_BASE : + replay_rate = 10 * ZM_RATE_BASE; + break; + case 10 * ZM_RATE_BASE : + replay_rate = 25 * ZM_RATE_BASE; + break; + case 25 * ZM_RATE_BASE : + case 50 * ZM_RATE_BASE : + replay_rate = 50 * ZM_RATE_BASE; + break; + default : + replay_rate = 2 * ZM_RATE_BASE; + break; + } + break; + } + case CMD_SLOWFWD : + { + Debug( 1, "Got SLOW FWD command" ); + // Set paused flag + paused = true; + // Set play rate + replay_rate = ZM_RATE_BASE; + // Set step + step = 1; + break; + } + case CMD_SLOWREV : + { + Debug( 1, "Got SLOW REV command" ); + // Set paused flag + paused = true; + // Set play rate + replay_rate = ZM_RATE_BASE; + // Set step + step = -1; + break; + } + case CMD_FASTREV : + { + Debug( 1, "Got FAST REV command" ); + if ( paused ) + { + // Clear paused flag + paused = false; + } + // Set play rate + switch ( replay_rate ) + { + case -2 * ZM_RATE_BASE : + replay_rate = -5 * ZM_RATE_BASE; + break; + case -5 * ZM_RATE_BASE : + replay_rate = -10 * ZM_RATE_BASE; + break; + case -10 * ZM_RATE_BASE : + replay_rate = -25 * ZM_RATE_BASE; + break; + case -25 * ZM_RATE_BASE : + case -50 * ZM_RATE_BASE : + replay_rate = -50 * ZM_RATE_BASE; + break; + default : + replay_rate = -2 * ZM_RATE_BASE; + break; + } + break; + } + case CMD_ZOOMIN : + { + x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2]; + y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4]; + Debug( 1, "Got ZOOM IN command, to %d,%d", x, y ); + switch ( zoom ) + { + case 100: + zoom = 150; + break; + case 150: + zoom = 200; + break; + case 200: + zoom = 300; + break; + case 300: + zoom = 400; + break; + case 400: + default : + zoom = 500; + break; + } + break; + } + case CMD_ZOOMOUT : + { + Debug( 1, "Got ZOOM OUT command" ); + switch ( zoom ) + { + case 500: + zoom = 400; + break; + case 400: + zoom = 300; + break; + case 300: + zoom = 200; + break; + case 200: + zoom = 150; + break; + case 150: + default : + zoom = 100; + break; + } + break; + } + case CMD_PAN : + { + x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2]; + y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4]; + Debug( 1, "Got PAN command, to %d,%d", x, y ); + break; + } + case CMD_SCALE : + { + scale = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2]; + Debug( 1, "Got SCALE command, to %d", scale ); + break; + } + case CMD_PREV : + { + Debug( 1, "Got PREV command" ); + if ( replay_rate >= 0 ) + curr_frame_id = 0; + else + curr_frame_id = event_data->frame_count-1; + paused = false; + forceEventChange = true; + break; + } + case CMD_NEXT : + { + Debug( 1, "Got NEXT command" ); + if ( replay_rate >= 0 ) + curr_frame_id = event_data->frame_count-1; + else + curr_frame_id = 0; + paused = false; + forceEventChange = true; + break; + } + case CMD_SEEK : + { + int offset = ((unsigned char)msg->msg_data[1]<<24)|((unsigned char)msg->msg_data[2]<<16)|((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4]; + curr_frame_id = (int)(event_data->frame_count*offset/event_data->duration); + Debug( 1, "Got SEEK command, to %d (new cfid: %d)", offset, curr_frame_id ); + break; + } + case CMD_QUERY : + { + Debug( 1, "Got QUERY command, sending STATUS" ); + break; + } + default : + { + // Do nothing, for now + } + } + struct { + int event; + int progress; + int rate; + int zoom; + bool paused; + } status_data; + + status_data.event = event_data->event_id; + status_data.progress = (int)event_data->frames[curr_frame_id-1].offset; + status_data.rate = replay_rate; + status_data.zoom = zoom; + status_data.paused = paused; + Debug( 2, "E:%d, P:%d, p:%d R:%d, Z:%d", + status_data.event, + status_data.paused, + status_data.progress, + status_data.rate, + status_data.zoom + ); + + DataMsg status_msg; + status_msg.msg_type = MSG_DATA_EVENT; + memcpy( &status_msg.msg_data, &status_data, sizeof(status_msg.msg_data) ); + if ( sendto( sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr) ) < 0 ) + { + //if ( errno != EAGAIN ) + { + Error( "Can't sendto on sd %d: %s", sd, strerror(errno) ); + exit( -1 ); + } + } + + updateFrameRate( (double)event_data->frame_count/event_data->duration ); +} + +void EventStream::checkEventLoaded() +{ + bool reload_event = false; + static char sql[ZM_SQL_SML_BUFSIZ]; + + if ( curr_frame_id <= 0 ) + { + snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %ld and Id < %ld order by Id desc limit 1", event_data->monitor_id, event_data->event_id ); + reload_event = true; + } + else if ( curr_frame_id > event_data->frame_count ) + { + snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %ld and Id > %ld order by Id asc limit 1", event_data->monitor_id, event_data->event_id ); + reload_event = true; + } + + if ( reload_event ) + { + if ( forceEventChange || mode != MODE_SINGLE ) + { + //Info( "SQL:%s", sql ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't run query: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + MYSQL_RES *result = mysql_store_result( &dbconn ); + if ( !result ) + { + Error( "Can't use query result: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + MYSQL_ROW dbrow = mysql_fetch_row( result ); + + if ( mysql_errno( &dbconn ) ) + { + Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + if ( dbrow ) + { + int event_id = atoi(dbrow[0]); + Debug( 1, "Loading new event %d", event_id ); + + loadEventData( event_id ); + + Debug( 2, "Current frame id = %d", curr_frame_id ); + if ( curr_frame_id <= 0 ) + curr_frame_id = event_data->frame_count; + else + curr_frame_id = 1; + Debug( 2, "New frame id = %d", curr_frame_id ); + } + else + { + if ( curr_frame_id <= 0 ) + curr_frame_id = 1; + else + curr_frame_id = event_data->frame_count; + paused = true; + } + mysql_free_result( result ); + forceEventChange = false; + } + else + { + if ( curr_frame_id <= 0 ) + curr_frame_id = 1; + else + curr_frame_id = event_data->frame_count; + paused = true; + } + } +} + +bool EventStream::sendFrame( int delta_us ) +{ + Debug( 2, "Sending frame %d", curr_frame_id ); + + static char filepath[PATH_MAX]; + static struct stat filestat; + FILE *fdj = NULL; + + snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id ); + +#if HAVE_LIBAVCODEC + if ( type == STREAM_MPEG ) + { + Image image( filepath ); + + Image *send_image = prepareImage( &image ); + + if ( !vid_stream ) + { + vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, send_image->Colours(), send_image->Width(), send_image->Height() ); + fprintf( stdout, "Content-type: %s\r\n\r\n", vid_stream->MimeType() ); + vid_stream->OpenStream(); + } + /* double pts = */ vid_stream->EncodeFrame( send_image->Buffer(), send_image->Size(), config.mpeg_timed_frames, delta_us*1000 ); + } + else +#endif // HAVE_LIBAVCODEC + { + static unsigned char temp_img_buffer[ZM_MAX_IMAGE_SIZE]; + + int img_buffer_size = 0; + uint8_t *img_buffer = temp_img_buffer; + + bool send_raw = ((scale>=ZM_SCALE_BASE)&&(zoom==ZM_SCALE_BASE)); + + fprintf( stdout, "--ZoneMinderFrame\r\n" ); + + if ( type != STREAM_JPEG ) + send_raw = false; + + if ( send_raw ) + { + fdj = fopen( filepath, "rb" ); + if ( !fdj ) + { + Error( "Can't open %s: %s", filepath, strerror(errno) ); + return( false ); + } +#if HAVE_SENDFILE + if( fstat(fileno(fdj),&filestat) < 0 ) { + Error( "Failed getting information about file %s: %s", filepath, strerror(errno) ); + return( false ); + } +#else + img_buffer_size = fread( img_buffer, 1, sizeof(temp_img_buffer), fdj ); +#endif + } + else + { + Image image( filepath ); + + Image *send_image = prepareImage( &image ); + + switch( type ) + { + case STREAM_JPEG : + send_image->EncodeJpeg( img_buffer, &img_buffer_size ); + break; + case STREAM_RAW : + img_buffer = (uint8_t*)(send_image->Buffer()); + img_buffer_size = send_image->Size(); + break; + case STREAM_ZIP : + unsigned long zip_buffer_size; + send_image->Zip( img_buffer, &zip_buffer_size ); + img_buffer_size = zip_buffer_size; + break; + default: + Fatal( "Unexpected frame type %d", type ); + break; + } + } + + switch( type ) + { + case STREAM_JPEG : + fprintf( stdout, "Content-Type: image/jpeg\r\n" ); + break; + case STREAM_RAW : + fprintf( stdout, "Content-Type: image/x-rgb\r\n" ); + break; + case STREAM_ZIP : + fprintf( stdout, "Content-Type: image/x-rgbz\r\n" ); + break; + default : + Fatal( "Unexpected frame type %d", type ); + break; + } + + + if(send_raw) { +#if HAVE_SENDFILE + fprintf( stdout, "Content-Length: %d\r\n\r\n", (int)filestat.st_size ); + if(sendfile(fileno(stdout), fileno(fdj), 0, (int)filestat.st_size) != (int)filestat.st_size) { + Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno)); + return( false ); + } +#else + if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) { + Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno)); + return( false ); + } +#endif + fclose(fdj); /* Close the file handle */ + } else { + fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size ); + if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) + { + Error( "Unable to send stream frame: %s", strerror(errno) ); + return( false ); + } + } + + fprintf( stdout, "\r\n\r\n" ); + fflush( stdout ); + } + last_frame_sent = TV_2_FLOAT( now ); + return( true ); +} + +void EventStream::runStream() +{ + Event::Initialise(); + + openComms(); + + checkInitialised(); + + updateFrameRate( (double)event_data->frame_count/event_data->duration ); + + if ( type == STREAM_JPEG ) + fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" ); + + if ( !event_data ) + { + sendTextFrame( "No event data found" ); + exit( 0 ); + } + + unsigned int delta_us = 0; + while( !zm_terminate ) + { + gettimeofday( &now, NULL ); + + checkCommandQueue(); + + if ( step != 0 ) + curr_frame_id += step; + + checkEventLoaded(); + + // Get current frame data + FrameData *frame_data = &event_data->frames[curr_frame_id-1]; + + //Info( "cst:%.2f", curr_stream_time ); + //Info( "cfid:%d", curr_frame_id ); + //Info( "fdt:%d", frame_data->timestamp ); + if ( !paused ) + { + bool in_event = true; + double time_to_event = 0; + if ( replay_rate > 0 ) + { + time_to_event = event_data->frames[0].timestamp - curr_stream_time; + if ( time_to_event > 0 ) + in_event = false; + } + else if ( replay_rate < 0 ) + { + time_to_event = curr_stream_time - event_data->frames[event_data->frame_count-1].timestamp; + if ( time_to_event > 0 ) + in_event = false; + } + if ( !in_event ) + { + double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent; + if ( actual_delta_time > 1 ) + { + static char frame_text[64]; + snprintf( frame_text, sizeof(frame_text), "Time to next event = %d seconds", (int)time_to_event ); + if ( !sendTextFrame( frame_text ) ) + zm_terminate = true; + } + //else + //{ + usleep( STREAM_PAUSE_WAIT ); + //curr_stream_time += (replay_rate>0?1:-1) * ((1.0L * replay_rate * STREAM_PAUSE_WAIT)/(ZM_RATE_BASE * 1000000)); + curr_stream_time += (1.0L * replay_rate * STREAM_PAUSE_WAIT)/(ZM_RATE_BASE * 1000000); + //} + continue; + } + } + + // Figure out if we should send this frame + bool send_frame = false; + if ( !paused ) + { + // If we are streaming and this frame is due to be sent + if ( ((curr_frame_id-1)%frame_mod) == 0 ) + { + delta_us = (unsigned int)(frame_data->delta * 1000000); + if ( effective_fps < base_fps ) + delta_us = (unsigned int)((delta_us * base_fps)/effective_fps); + send_frame = true; + } + } + else if ( step != 0 ) + { + // We are paused and are just stepping forward or backward one frame + step = 0; + send_frame = true; + } + else + { + // We are paused, and doing nothing + double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent; + if ( actual_delta_time > MAX_STREAM_DELAY ) + { + // Send keepalive + Debug( 2, "Sending keepalive frame" ); + send_frame = true; + } + } + + if ( send_frame ) + if ( !sendFrame( delta_us ) ) + zm_terminate = true; + + curr_stream_time = frame_data->timestamp; + + if ( !paused ) + { + curr_frame_id += replay_rate>0?1:-1; + if ( send_frame && type != STREAM_MPEG ) + { + Debug( 3, "dUs: %d", delta_us ); + usleep( delta_us ); + } + } + else + { + usleep( STREAM_PAUSE_WAIT ); + } + } +#if HAVE_LIBAVCODEC + if ( type == STREAM_MPEG ) + delete vid_stream; +#endif // HAVE_LIBAVCODEC + + closeComms(); +} \ No newline at end of file diff --git a/src/zm_image.cpp b/src/zm_image.cpp index dba69b9be..2002f3a0c 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -51,7 +51,7 @@ static delta_fptr_t fptr_delta8_abgr; static delta_fptr_t fptr_delta8_gray8; /* Pointer to image buffer memory copy function */ -static imgbufcpy_fptr_t fptr_imgbufcpy; +imgbufcpy_fptr_t fptr_imgbufcpy; Image::Image() { diff --git a/src/zm_image.h b/src/zm_image.h index 0da931a95..ae553deee 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -44,6 +44,13 @@ extern "C" #define ZM_BUFTYPE_AVMALLOC 3 #define ZM_BUFTYPE_ZM 4 +typedef void (*blend_fptr_t)(const uint8_t*, const uint8_t*, uint8_t*, unsigned long, double); +typedef void (*delta_fptr_t)(const uint8_t*, const uint8_t*, uint8_t*, unsigned long); +typedef void (*convert_fptr_t)(const uint8_t*, uint8_t*, unsigned long); +typedef void* (*imgbufcpy_fptr_t)(void*, const void*, size_t); + + +extern imgbufcpy_fptr_t fptr_imgbufcpy; /* Should be called from Image class functions */ inline static uint8_t* AllocBuffer(size_t p_bufsize) { @@ -68,6 +75,7 @@ inline static void DumpBuffer(uint8_t* buffer, int buffertype) { } } + // // This is image class, and represents a frame captured from a // camera in raw form. @@ -181,13 +189,13 @@ public: { if ( image.size != size ) { - Panic( "Attempt to copy different size image buffers, expected %d, got %d", size, image.size ); + Panic( "Attempt to copy different size image buffers, expected %d, got %d", size, image.size ); } - sse2_aligned_memcpy( buffer, image.buffer, size ); + (*fptr_imgbufcpy)(buffer, image.buffer, size); } inline Image &operator=( const unsigned char *new_buffer ) { - sse2_aligned_memcpy( buffer, new_buffer, size ); + (*fptr_imgbufcpy)(buffer, new_buffer, size); return( *this ); } @@ -238,12 +246,6 @@ public: #endif // ZM_IMAGE_H - -typedef void (*blend_fptr_t)(const uint8_t*, const uint8_t*, uint8_t*, unsigned long, double); -typedef void (*delta_fptr_t)(const uint8_t*, const uint8_t*, uint8_t*, unsigned long); -typedef void (*convert_fptr_t)(const uint8_t*, uint8_t*, unsigned long); -typedef void* (*imgbufcpy_fptr_t)(void*, const void*, size_t); - /* Blend functions */ void sse2_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent); void std_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent); diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 78559ae55..41c91f530 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -1901,8 +1901,8 @@ int LocalCamera::Capture( Image &image ) Debug( 3, "Captured %d for channel %d", capture_frame, channel ); buffer = v4l1_data.bufptr+v4l1_data.frames.offsets[capture_frame]; -#endif // ZM_HAS_V4L1 } +#endif // ZM_HAS_V4L1 } /* prime capture */ if(conversion_type != 0) { From 8ac3dda54b68b27d33020f734e4ba15a21ff71a0 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 15 Jun 2011 19:04:29 +0300 Subject: [PATCH 15/56] 1) Removal of the ZM_LOCAL_BGR_INVERT option. 2) Allow FPS reporting interval to be zero again. 3) Added translation for the new texts. 4) Corrected the blend function declaration. --- .../lib/ZoneMinder/ConfigData.pm.in | 10 +- src/zm_config_defines.h | 667 ------------------ src/zm_image.cpp | 4 +- src/zm_image.h | 2 +- web/lang/big5_big5.php | 2 + web/lang/cn_zh.php | 2 + web/lang/cs_cz.php | 2 + web/lang/de_de.php | 2 + web/lang/dk_dk.php | 2 + web/lang/en_gb.php | 2 + web/lang/en_us.php | 1 + web/lang/es_ar.php | 2 + web/lang/es_es.php | 1 + web/lang/et_ee.php | 2 + web/lang/fr_fr.php | 2 + web/lang/he_il.php | 2 + web/lang/hu_hu.php | 2 + web/lang/it_it.php | 2 + web/lang/ja_jp.php | 2 + web/lang/nl_nl.php | 2 + web/lang/pl_pl.php | 2 + web/lang/pt_br.php | 2 + web/lang/ro_ro.php | 2 + web/lang/ru_ru.php | 2 + web/lang/se_se.php | 2 + web/skins/classic/views/js/monitor.js.php | 2 +- web/skins/classic/views/monitor.php | 2 +- 27 files changed, 46 insertions(+), 681 deletions(-) delete mode 100644 src/zm_config_defines.h diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index 677ce8353..2e05dc113 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -307,14 +307,6 @@ our @options = type => $types{boolean}, category => "config", }, - { - name => "ZM_LOCAL_BGR_INVERT", - default => "yes", - description => "Invert BGR colours to RGB", - help => "Some cameras or video cards capture images in BGR (Blue-Green-Red) order even when the palette says RGB. If you see strange colours casts on your images then it may be worth trying this option to see if that corrects the issue. Note this option will apply only to local cameras and not those over a network.", - type => $types{boolean}, - category => "config", - }, { name => "ZM_CPU_EXTENSIONS", default => "yes", @@ -327,7 +319,7 @@ our @options = name => "ZM_FAST_IMAGE_BLENDS", default => "yes", description => "Use a fast algorithm to blend the reference image", - help => "In most modes of operation ZoneMinder needs to blend the captured image with the stored reference image to update it for the next image. The reference blend percentage specified for the monitor controls how much the new image affects the reference image. There are two methods that are available for this. If this option is set then a basic calculation is applied which though fast and fairly accurate can (due to rounding) mean that the actual range of pixel values in the reference image may be reduced from that in the captured image, e.g. a pixel may only be able to achieve a maximum of 250 for example while the captured image is consistently at 255. If you also have a small minimum pixel difference threshold this can cause multiple bogus alarms. The alternative is to switch this option off which stores an additional set of temporary values which eliminate any significant rounding errors. This is more accurate though is somewhat slower and should not really be necessary unless you find problems with the default method.", + help => "To detect alarms ZoneMinder needs to blend the captured image with the stored reference image to update it for comparison with the next image. The reference blend percentage specified for the monitor controls how much the new image affects the reference image. There are two methods that are available for this. If this option is set then fast calculation which does not use any multiplication or division is used. This calculation is extremely fast, however it limits the possible blend percentages to 50%, 25%, 12.5%, 6.25%, 3.25% and 1.5%. Any other blend percentage will be rounded to the nearest possible one. The alternative is to switch this option off and use standard blending instead, which is slower.", type => $types{boolean}, category => "config", }, diff --git a/src/zm_config_defines.h b/src/zm_config_defines.h deleted file mode 100644 index 3e57de1d9..000000000 --- a/src/zm_config_defines.h +++ /dev/null @@ -1,667 +0,0 @@ -// The file is autogenerated by zmconfgen.pl -// Do not edit this file as any changes will be overwritten - -#define ZM_LANG_DEFAULT 0 -#define ZM_OPT_USE_AUTH 1 -#define ZM_AUTH_TYPE 2 -#define ZM_AUTH_RELAY 3 -#define ZM_AUTH_HASH_SECRET 4 -#define ZM_AUTH_HASH_IPS 5 -#define ZM_AUTH_HASH_LOGINS 6 -#define ZM_DIR_EVENTS 7 -#define ZM_USE_DEEP_STORAGE 8 -#define ZM_DIR_IMAGES 9 -#define ZM_DIR_SOUNDS 10 -#define ZM_PATH_ZMS 11 -#define ZM_COLOUR_JPEG_FILES 12 -#define ZM_ADD_JPEG_COMMENTS 13 -#define ZM_JPEG_FILE_QUALITY 14 -#define ZM_JPEG_ALARM_FILE_QUALITY 15 -#define ZM_JPEG_IMAGE_QUALITY 16 -#define ZM_JPEG_STREAM_QUALITY 17 -#define ZM_MPEG_TIMED_FRAMES 18 -#define ZM_MPEG_LIVE_FORMAT 19 -#define ZM_MPEG_REPLAY_FORMAT 20 -#define ZM_RAND_STREAM 21 -#define ZM_OPT_CAMBOZOLA 22 -#define ZM_PATH_CAMBOZOLA 23 -#define ZM_RELOAD_CAMBOZOLA 24 -#define ZM_TIMESTAMP_ON_CAPTURE 25 -#define ZM_LOCAL_BGR_INVERT 26 -#define ZM_CPU_EXTENSIONS 27 -#define ZM_FAST_IMAGE_BLENDS 28 -#define ZM_OPT_ADAPTIVE_SKIP 29 -#define ZM_BLEND_ALARMED_IMAGES 30 -#define ZM_MAX_SUSPEND_TIME 31 -#define ZM_OPT_REMOTE_CAMERAS 32 -#define ZM_NETCAM_REGEXPS 33 -#define ZM_HTTP_VERSION 34 -#define ZM_HTTP_UA 35 -#define ZM_HTTP_TIMEOUT 36 -#define ZM_MIN_RTP_PORT 37 -#define ZM_MAX_RTP_PORT 38 -#define ZM_OPT_FFMPEG 39 -#define ZM_PATH_FFMPEG 40 -#define ZM_FFMPEG_INPUT_OPTIONS 41 -#define ZM_FFMPEG_OUTPUT_OPTIONS 42 -#define ZM_FFMPEG_FORMATS 43 -#define ZM_LOG_LEVEL_SYSLOG 44 -#define ZM_LOG_LEVEL_FILE 45 -#define ZM_LOG_LEVEL_WEBLOG 46 -#define ZM_LOG_LEVEL_DATABASE 47 -#define ZM_LOG_DATABASE_LIMIT 48 -#define ZM_LOG_DEBUG 49 -#define ZM_LOG_DEBUG_TARGET 50 -#define ZM_LOG_DEBUG_LEVEL 51 -#define ZM_LOG_DEBUG_FILE 52 -#define ZM_LOG_CHECK_PERIOD 53 -#define ZM_LOG_ALERT_WAR_COUNT 54 -#define ZM_LOG_ALERT_ERR_COUNT 55 -#define ZM_LOG_ALERT_FAT_COUNT 56 -#define ZM_LOG_ALARM_WAR_COUNT 57 -#define ZM_LOG_ALARM_ERR_COUNT 58 -#define ZM_LOG_ALARM_FAT_COUNT 59 -#define ZM_RECORD_EVENT_STATS 60 -#define ZM_RECORD_DIAG_IMAGES 61 -#define ZM_DUMP_CORES 62 -#define ZM_PATH_MAP 63 -#define ZM_PATH_SOCKS 64 -#define ZM_PATH_LOGS 65 -#define ZM_PATH_SWAP 66 -#define ZM_WEB_TITLE_PREFIX 67 -#define ZM_WEB_RESIZE_CONSOLE 68 -#define ZM_WEB_POPUP_ON_ALARM 69 -#define ZM_OPT_X10 70 -#define ZM_X10_DEVICE 71 -#define ZM_X10_HOUSE_CODE 72 -#define ZM_X10_DB_RELOAD_INTERVAL 73 -#define ZM_WEB_SOUND_ON_ALARM 74 -#define ZM_WEB_ALARM_SOUND 75 -#define ZM_WEB_COMPACT_MONTAGE 76 -#define ZM_OPT_FAST_DELETE 77 -#define ZM_STRICT_VIDEO_CONFIG 78 -#define ZM_V4L2_CAPTURE_FIELDS 79 -#define ZM_SIGNAL_CHECK_POINTS 80 -#define ZM_V4L_MULTI_BUFFER 81 -#define ZM_CAPTURES_PER_FRAME 82 -#define ZM_FILTER_RELOAD_DELAY 83 -#define ZM_FILTER_EXECUTE_INTERVAL 84 -#define ZM_OPT_UPLOAD 85 -#define ZM_UPLOAD_ARCH_FORMAT 86 -#define ZM_UPLOAD_ARCH_COMPRESS 87 -#define ZM_UPLOAD_ARCH_ANALYSE 88 -#define ZM_UPLOAD_PROTOCOL 89 -#define ZM_UPLOAD_FTP_HOST 90 -#define ZM_UPLOAD_HOST 91 -#define ZM_UPLOAD_PORT 92 -#define ZM_UPLOAD_FTP_USER 93 -#define ZM_UPLOAD_USER 94 -#define ZM_UPLOAD_FTP_PASS 95 -#define ZM_UPLOAD_PASS 96 -#define ZM_UPLOAD_FTP_LOC_DIR 97 -#define ZM_UPLOAD_LOC_DIR 98 -#define ZM_UPLOAD_FTP_REM_DIR 99 -#define ZM_UPLOAD_REM_DIR 100 -#define ZM_UPLOAD_FTP_TIMEOUT 101 -#define ZM_UPLOAD_TIMEOUT 102 -#define ZM_UPLOAD_FTP_PASSIVE 103 -#define ZM_UPLOAD_FTP_DEBUG 104 -#define ZM_UPLOAD_DEBUG 105 -#define ZM_OPT_EMAIL 106 -#define ZM_EMAIL_ADDRESS 107 -#define ZM_EMAIL_TEXT 108 -#define ZM_EMAIL_SUBJECT 109 -#define ZM_EMAIL_BODY 110 -#define ZM_OPT_MESSAGE 111 -#define ZM_MESSAGE_ADDRESS 112 -#define ZM_MESSAGE_TEXT 113 -#define ZM_MESSAGE_SUBJECT 114 -#define ZM_MESSAGE_BODY 115 -#define ZM_NEW_MAIL_MODULES 116 -#define ZM_EMAIL_HOST 117 -#define ZM_FROM_EMAIL 118 -#define ZM_URL 119 -#define ZM_MAX_RESTART_DELAY 120 -#define ZM_WATCH_CHECK_INTERVAL 121 -#define ZM_WATCH_MAX_DELAY 122 -#define ZM_RUN_AUDIT 123 -#define ZM_AUDIT_CHECK_INTERVAL 124 -#define ZM_FORCED_ALARM_SCORE 125 -#define ZM_BULK_FRAME_INTERVAL 126 -#define ZM_EVENT_CLOSE_MODE 127 -#define ZM_FORCE_CLOSE_EVENTS 128 -#define ZM_CREATE_ANALYSIS_IMAGES 129 -#define ZM_WEIGHTED_ALARM_CENTRES 130 -#define ZM_EVENT_IMAGE_DIGITS 131 -#define ZM_DEFAULT_ASPECT_RATIO 132 -#define ZM_USER_SELF_EDIT 133 -#define ZM_OPT_FRAME_SERVER 134 -#define ZM_FRAME_SOCKET_SIZE 135 -#define ZM_OPT_CONTROL 136 -#define ZM_OPT_TRIGGERS 137 -#define ZM_CHECK_FOR_UPDATES 138 -#define ZM_UPDATE_CHECK_PROXY 139 -#define ZM_SHM_KEY 140 -#define ZM_WEB_REFRESH_METHOD 141 -#define ZM_WEB_EVENT_SORT_FIELD 142 -#define ZM_WEB_EVENT_SORT_ORDER 143 -#define ZM_WEB_EVENTS_PER_PAGE 144 -#define ZM_WEB_LIST_THUMBS 145 -#define ZM_WEB_LIST_THUMB_WIDTH 146 -#define ZM_WEB_LIST_THUMB_HEIGHT 147 -#define ZM_WEB_USE_OBJECT_TAGS 148 -#define ZM_WEB_H_REFRESH_MAIN 149 -#define ZM_WEB_H_REFRESH_CYCLE 150 -#define ZM_WEB_H_REFRESH_IMAGE 151 -#define ZM_WEB_H_REFRESH_STATUS 152 -#define ZM_WEB_H_REFRESH_EVENTS 153 -#define ZM_WEB_H_CAN_STREAM 154 -#define ZM_WEB_H_STREAM_METHOD 155 -#define ZM_WEB_H_DEFAULT_SCALE 156 -#define ZM_WEB_H_DEFAULT_RATE 157 -#define ZM_WEB_H_VIDEO_BITRATE 158 -#define ZM_WEB_H_VIDEO_MAXFPS 159 -#define ZM_WEB_H_SCALE_THUMBS 160 -#define ZM_WEB_H_EVENTS_VIEW 161 -#define ZM_WEB_H_SHOW_PROGRESS 162 -#define ZM_WEB_H_AJAX_TIMEOUT 163 -#define ZM_WEB_M_REFRESH_MAIN 164 -#define ZM_WEB_M_REFRESH_CYCLE 165 -#define ZM_WEB_M_REFRESH_IMAGE 166 -#define ZM_WEB_M_REFRESH_STATUS 167 -#define ZM_WEB_M_REFRESH_EVENTS 168 -#define ZM_WEB_M_CAN_STREAM 169 -#define ZM_WEB_M_STREAM_METHOD 170 -#define ZM_WEB_M_DEFAULT_SCALE 171 -#define ZM_WEB_M_DEFAULT_RATE 172 -#define ZM_WEB_M_VIDEO_BITRATE 173 -#define ZM_WEB_M_VIDEO_MAXFPS 174 -#define ZM_WEB_M_SCALE_THUMBS 175 -#define ZM_WEB_M_EVENTS_VIEW 176 -#define ZM_WEB_M_SHOW_PROGRESS 177 -#define ZM_WEB_M_AJAX_TIMEOUT 178 -#define ZM_WEB_L_REFRESH_MAIN 179 -#define ZM_WEB_L_REFRESH_CYCLE 180 -#define ZM_WEB_L_REFRESH_IMAGE 181 -#define ZM_WEB_L_REFRESH_STATUS 182 -#define ZM_WEB_L_REFRESH_EVENTS 183 -#define ZM_WEB_L_CAN_STREAM 184 -#define ZM_WEB_L_STREAM_METHOD 185 -#define ZM_WEB_L_DEFAULT_SCALE 186 -#define ZM_WEB_L_DEFAULT_RATE 187 -#define ZM_WEB_L_VIDEO_BITRATE 188 -#define ZM_WEB_L_VIDEO_MAXFPS 189 -#define ZM_WEB_L_SCALE_THUMBS 190 -#define ZM_WEB_L_EVENTS_VIEW 191 -#define ZM_WEB_L_SHOW_PROGRESS 192 -#define ZM_WEB_L_AJAX_TIMEOUT 193 -#define ZM_WEB_P_CAN_STREAM 194 -#define ZM_WEB_P_STREAM_METHOD 195 -#define ZM_WEB_P_DEFAULT_SCALE 196 -#define ZM_WEB_P_DEFAULT_RATE 197 -#define ZM_WEB_P_VIDEO_BITRATE 198 -#define ZM_WEB_P_VIDEO_MAXFPS 199 -#define ZM_WEB_P_SCALE_THUMBS 200 -#define ZM_WEB_P_AJAX_TIMEOUT 201 -#define ZM_DYN_LAST_VERSION 202 -#define ZM_DYN_CURR_VERSION 203 -#define ZM_DYN_DB_VERSION 204 -#define ZM_DYN_LAST_CHECK 205 -#define ZM_DYN_NEXT_REMINDER 206 -#define ZM_DYN_DONATE_REMINDER_TIME 207 -#define ZM_DYN_SHOW_DONATE_REMINDER 208 -#define ZM_EYEZM_DEBUG 209 -#define ZM_EYEZM_LOG_TO_FILE 210 -#define ZM_EYEZM_LOG_FILE 211 -#define ZM_EYEZM_EVENT_VCODEC 212 -#define ZM_EYEZM_FEED_VCODEC 213 -#define ZM_EYEZM_H264_DEFAULT_BR 214 -#define ZM_EYEZM_H264_DEFAULT_EVBR 215 -#define ZM_EYEZM_H264_TIMEOUT 216 -#define ZM_EYEZM_SEG_DURATION 217 - - -#define ZM_MAX_CFG_ID 217 - -#define ZM_CFG_DECLARE_LIST \ - const char *lang_default;\ - bool opt_use_auth;\ - const char *auth_type;\ - const char *auth_relay;\ - const char *auth_hash_secret;\ - bool auth_hash_ips;\ - bool auth_hash_logins;\ - const char *dir_events;\ - bool use_deep_storage;\ - const char *dir_images;\ - const char *dir_sounds;\ - const char *path_zms;\ - bool colour_jpeg_files;\ - bool add_jpeg_comments;\ - int jpeg_file_quality;\ - int jpeg_alarm_file_quality;\ - int jpeg_image_quality;\ - int jpeg_stream_quality;\ - bool mpeg_timed_frames;\ - const char *mpeg_live_format;\ - const char *mpeg_replay_format;\ - bool rand_stream;\ - bool opt_cambozola;\ - const char *path_cambozola;\ - int reload_cambozola;\ - bool timestamp_on_capture;\ - bool local_bgr_invert;\ - bool cpu_extensions;\ - bool fast_image_blends;\ - bool opt_adaptive_skip;\ - bool blend_alarmed_images;\ - int max_suspend_time;\ - bool opt_remote_cameras;\ - bool netcam_regexps;\ - const char *http_version;\ - const char *http_ua;\ - int http_timeout;\ - int min_rtp_port;\ - int max_rtp_port;\ - bool opt_ffmpeg;\ - const char *path_ffmpeg;\ - const char *ffmpeg_input_options;\ - const char *ffmpeg_output_options;\ - const char *ffmpeg_formats;\ - int log_level_syslog;\ - int log_level_file;\ - int log_level_weblog;\ - int log_level_database;\ - const char *log_database_limit;\ - bool log_debug;\ - const char *log_debug_target;\ - int log_debug_level;\ - const char *log_debug_file;\ - int log_check_period;\ - int log_alert_war_count;\ - int log_alert_err_count;\ - int log_alert_fat_count;\ - int log_alarm_war_count;\ - int log_alarm_err_count;\ - int log_alarm_fat_count;\ - bool record_event_stats;\ - bool record_diag_images;\ - bool dump_cores;\ - const char *path_map;\ - const char *path_socks;\ - const char *path_logs;\ - const char *path_swap;\ - const char *web_title_prefix;\ - bool web_resize_console;\ - bool web_popup_on_alarm;\ - bool opt_x10;\ - const char *x10_device;\ - const char *x10_house_code;\ - int x10_db_reload_interval;\ - bool web_sound_on_alarm;\ - const char *web_alarm_sound;\ - bool web_compact_montage;\ - bool opt_fast_delete;\ - bool strict_video_config;\ - int v4l2_capture_fields;\ - int signal_check_points;\ - bool v4l_multi_buffer;\ - int captures_per_frame;\ - int filter_reload_delay;\ - int filter_execute_interval;\ - bool opt_upload;\ - const char *upload_arch_format;\ - bool upload_arch_compress;\ - bool upload_arch_analyse;\ - const char *upload_protocol;\ - const char *upload_ftp_host;\ - const char *upload_host;\ - int upload_port;\ - const char *upload_ftp_user;\ - const char *upload_user;\ - const char *upload_ftp_pass;\ - const char *upload_pass;\ - const char *upload_ftp_loc_dir;\ - const char *upload_loc_dir;\ - const char *upload_ftp_rem_dir;\ - const char *upload_rem_dir;\ - int upload_ftp_timeout;\ - int upload_timeout;\ - bool upload_ftp_passive;\ - bool upload_ftp_debug;\ - bool upload_debug;\ - bool opt_email;\ - const char *email_address;\ - const char *email_text;\ - const char *email_subject;\ - const char *email_body;\ - bool opt_message;\ - const char *message_address;\ - const char *message_text;\ - const char *message_subject;\ - const char *message_body;\ - bool new_mail_modules;\ - const char *email_host;\ - const char *from_email;\ - const char *url;\ - int max_restart_delay;\ - int watch_check_interval;\ - double watch_max_delay;\ - bool run_audit;\ - int audit_check_interval;\ - int forced_alarm_score;\ - int bulk_frame_interval;\ - const char *event_close_mode;\ - bool force_close_events;\ - bool create_analysis_images;\ - bool weighted_alarm_centres;\ - int event_image_digits;\ - const char *default_aspect_ratio;\ - bool user_self_edit;\ - bool opt_frame_server;\ - int frame_socket_size;\ - bool opt_control;\ - bool opt_triggers;\ - bool check_for_updates;\ - const char *update_check_proxy;\ - int shm_key;\ - const char *web_refresh_method;\ - const char *web_event_sort_field;\ - const char *web_event_sort_order;\ - int web_events_per_page;\ - bool web_list_thumbs;\ - int web_list_thumb_width;\ - int web_list_thumb_height;\ - bool web_use_object_tags;\ - int web_h_refresh_main;\ - int web_h_refresh_cycle;\ - int web_h_refresh_image;\ - int web_h_refresh_status;\ - int web_h_refresh_events;\ - const char *web_h_can_stream;\ - const char *web_h_stream_method;\ - int web_h_default_scale;\ - int web_h_default_rate;\ - int web_h_video_bitrate;\ - int web_h_video_maxfps;\ - bool web_h_scale_thumbs;\ - const char *web_h_events_view;\ - bool web_h_show_progress;\ - int web_h_ajax_timeout;\ - int web_m_refresh_main;\ - int web_m_refresh_cycle;\ - int web_m_refresh_image;\ - int web_m_refresh_status;\ - int web_m_refresh_events;\ - const char *web_m_can_stream;\ - const char *web_m_stream_method;\ - int web_m_default_scale;\ - int web_m_default_rate;\ - int web_m_video_bitrate;\ - int web_m_video_maxfps;\ - bool web_m_scale_thumbs;\ - const char *web_m_events_view;\ - bool web_m_show_progress;\ - int web_m_ajax_timeout;\ - int web_l_refresh_main;\ - int web_l_refresh_cycle;\ - int web_l_refresh_image;\ - int web_l_refresh_status;\ - int web_l_refresh_events;\ - const char *web_l_can_stream;\ - const char *web_l_stream_method;\ - int web_l_default_scale;\ - int web_l_default_rate;\ - int web_l_video_bitrate;\ - int web_l_video_maxfps;\ - bool web_l_scale_thumbs;\ - const char *web_l_events_view;\ - bool web_l_show_progress;\ - int web_l_ajax_timeout;\ - const char *web_p_can_stream;\ - const char *web_p_stream_method;\ - int web_p_default_scale;\ - int web_p_default_rate;\ - int web_p_video_bitrate;\ - int web_p_video_maxfps;\ - bool web_p_scale_thumbs;\ - int web_p_ajax_timeout;\ - const char *dyn_last_version;\ - const char *dyn_curr_version;\ - const char *dyn_db_version;\ - int dyn_last_check;\ - const char *dyn_next_reminder;\ - int dyn_donate_reminder_time;\ - bool dyn_show_donate_reminder;\ - bool eyezm_debug;\ - bool eyezm_log_to_file;\ - const char *eyezm_log_file;\ - const char *eyezm_event_vcodec;\ - const char *eyezm_feed_vcodec;\ - const char *eyezm_h264_default_br;\ - const char *eyezm_h264_default_evbr;\ - const char *eyezm_h264_timeout;\ - const char *eyezm_seg_duration;\ - - -#define ZM_CFG_ASSIGN_LIST \ - lang_default = (const char *)config.Item( ZM_LANG_DEFAULT );\ - opt_use_auth = (bool)config.Item( ZM_OPT_USE_AUTH );\ - auth_type = (const char *)config.Item( ZM_AUTH_TYPE );\ - auth_relay = (const char *)config.Item( ZM_AUTH_RELAY );\ - auth_hash_secret = (const char *)config.Item( ZM_AUTH_HASH_SECRET );\ - auth_hash_ips = (bool)config.Item( ZM_AUTH_HASH_IPS );\ - auth_hash_logins = (bool)config.Item( ZM_AUTH_HASH_LOGINS );\ - dir_events = (const char *)config.Item( ZM_DIR_EVENTS );\ - use_deep_storage = (bool)config.Item( ZM_USE_DEEP_STORAGE );\ - dir_images = (const char *)config.Item( ZM_DIR_IMAGES );\ - dir_sounds = (const char *)config.Item( ZM_DIR_SOUNDS );\ - path_zms = (const char *)config.Item( ZM_PATH_ZMS );\ - colour_jpeg_files = (bool)config.Item( ZM_COLOUR_JPEG_FILES );\ - add_jpeg_comments = (bool)config.Item( ZM_ADD_JPEG_COMMENTS );\ - jpeg_file_quality = (int)config.Item( ZM_JPEG_FILE_QUALITY );\ - jpeg_alarm_file_quality = (int)config.Item( ZM_JPEG_ALARM_FILE_QUALITY );\ - jpeg_image_quality = (int)config.Item( ZM_JPEG_IMAGE_QUALITY );\ - jpeg_stream_quality = (int)config.Item( ZM_JPEG_STREAM_QUALITY );\ - mpeg_timed_frames = (bool)config.Item( ZM_MPEG_TIMED_FRAMES );\ - mpeg_live_format = (const char *)config.Item( ZM_MPEG_LIVE_FORMAT );\ - mpeg_replay_format = (const char *)config.Item( ZM_MPEG_REPLAY_FORMAT );\ - rand_stream = (bool)config.Item( ZM_RAND_STREAM );\ - opt_cambozola = (bool)config.Item( ZM_OPT_CAMBOZOLA );\ - path_cambozola = (const char *)config.Item( ZM_PATH_CAMBOZOLA );\ - reload_cambozola = (int)config.Item( ZM_RELOAD_CAMBOZOLA );\ - timestamp_on_capture = (bool)config.Item( ZM_TIMESTAMP_ON_CAPTURE );\ - local_bgr_invert = (bool)config.Item( ZM_LOCAL_BGR_INVERT );\ - cpu_extensions = (bool)config.Item( ZM_CPU_EXTENSIONS );\ - fast_image_blends = (bool)config.Item( ZM_FAST_IMAGE_BLENDS );\ - opt_adaptive_skip = (bool)config.Item( ZM_OPT_ADAPTIVE_SKIP );\ - blend_alarmed_images = (bool)config.Item( ZM_BLEND_ALARMED_IMAGES );\ - max_suspend_time = (int)config.Item( ZM_MAX_SUSPEND_TIME );\ - opt_remote_cameras = (bool)config.Item( ZM_OPT_REMOTE_CAMERAS );\ - netcam_regexps = (bool)config.Item( ZM_NETCAM_REGEXPS );\ - http_version = (const char *)config.Item( ZM_HTTP_VERSION );\ - http_ua = (const char *)config.Item( ZM_HTTP_UA );\ - http_timeout = (int)config.Item( ZM_HTTP_TIMEOUT );\ - min_rtp_port = (int)config.Item( ZM_MIN_RTP_PORT );\ - max_rtp_port = (int)config.Item( ZM_MAX_RTP_PORT );\ - opt_ffmpeg = (bool)config.Item( ZM_OPT_FFMPEG );\ - path_ffmpeg = (const char *)config.Item( ZM_PATH_FFMPEG );\ - ffmpeg_input_options = (const char *)config.Item( ZM_FFMPEG_INPUT_OPTIONS );\ - ffmpeg_output_options = (const char *)config.Item( ZM_FFMPEG_OUTPUT_OPTIONS );\ - ffmpeg_formats = (const char *)config.Item( ZM_FFMPEG_FORMATS );\ - log_level_syslog = (int)config.Item( ZM_LOG_LEVEL_SYSLOG );\ - log_level_file = (int)config.Item( ZM_LOG_LEVEL_FILE );\ - log_level_weblog = (int)config.Item( ZM_LOG_LEVEL_WEBLOG );\ - log_level_database = (int)config.Item( ZM_LOG_LEVEL_DATABASE );\ - log_database_limit = (const char *)config.Item( ZM_LOG_DATABASE_LIMIT );\ - log_debug = (bool)config.Item( ZM_LOG_DEBUG );\ - log_debug_target = (const char *)config.Item( ZM_LOG_DEBUG_TARGET );\ - log_debug_level = (int)config.Item( ZM_LOG_DEBUG_LEVEL );\ - log_debug_file = (const char *)config.Item( ZM_LOG_DEBUG_FILE );\ - log_check_period = (int)config.Item( ZM_LOG_CHECK_PERIOD );\ - log_alert_war_count = (int)config.Item( ZM_LOG_ALERT_WAR_COUNT );\ - log_alert_err_count = (int)config.Item( ZM_LOG_ALERT_ERR_COUNT );\ - log_alert_fat_count = (int)config.Item( ZM_LOG_ALERT_FAT_COUNT );\ - log_alarm_war_count = (int)config.Item( ZM_LOG_ALARM_WAR_COUNT );\ - log_alarm_err_count = (int)config.Item( ZM_LOG_ALARM_ERR_COUNT );\ - log_alarm_fat_count = (int)config.Item( ZM_LOG_ALARM_FAT_COUNT );\ - record_event_stats = (bool)config.Item( ZM_RECORD_EVENT_STATS );\ - record_diag_images = (bool)config.Item( ZM_RECORD_DIAG_IMAGES );\ - dump_cores = (bool)config.Item( ZM_DUMP_CORES );\ - path_map = (const char *)config.Item( ZM_PATH_MAP );\ - path_socks = (const char *)config.Item( ZM_PATH_SOCKS );\ - path_logs = (const char *)config.Item( ZM_PATH_LOGS );\ - path_swap = (const char *)config.Item( ZM_PATH_SWAP );\ - web_title_prefix = (const char *)config.Item( ZM_WEB_TITLE_PREFIX );\ - web_resize_console = (bool)config.Item( ZM_WEB_RESIZE_CONSOLE );\ - web_popup_on_alarm = (bool)config.Item( ZM_WEB_POPUP_ON_ALARM );\ - opt_x10 = (bool)config.Item( ZM_OPT_X10 );\ - x10_device = (const char *)config.Item( ZM_X10_DEVICE );\ - x10_house_code = (const char *)config.Item( ZM_X10_HOUSE_CODE );\ - x10_db_reload_interval = (int)config.Item( ZM_X10_DB_RELOAD_INTERVAL );\ - web_sound_on_alarm = (bool)config.Item( ZM_WEB_SOUND_ON_ALARM );\ - web_alarm_sound = (const char *)config.Item( ZM_WEB_ALARM_SOUND );\ - web_compact_montage = (bool)config.Item( ZM_WEB_COMPACT_MONTAGE );\ - opt_fast_delete = (bool)config.Item( ZM_OPT_FAST_DELETE );\ - strict_video_config = (bool)config.Item( ZM_STRICT_VIDEO_CONFIG );\ - v4l2_capture_fields = (int)config.Item( ZM_V4L2_CAPTURE_FIELDS );\ - signal_check_points = (int)config.Item( ZM_SIGNAL_CHECK_POINTS );\ - v4l_multi_buffer = (bool)config.Item( ZM_V4L_MULTI_BUFFER );\ - captures_per_frame = (int)config.Item( ZM_CAPTURES_PER_FRAME );\ - filter_reload_delay = (int)config.Item( ZM_FILTER_RELOAD_DELAY );\ - filter_execute_interval = (int)config.Item( ZM_FILTER_EXECUTE_INTERVAL );\ - opt_upload = (bool)config.Item( ZM_OPT_UPLOAD );\ - upload_arch_format = (const char *)config.Item( ZM_UPLOAD_ARCH_FORMAT );\ - upload_arch_compress = (bool)config.Item( ZM_UPLOAD_ARCH_COMPRESS );\ - upload_arch_analyse = (bool)config.Item( ZM_UPLOAD_ARCH_ANALYSE );\ - upload_protocol = (const char *)config.Item( ZM_UPLOAD_PROTOCOL );\ - upload_ftp_host = (const char *)config.Item( ZM_UPLOAD_FTP_HOST );\ - upload_host = (const char *)config.Item( ZM_UPLOAD_HOST );\ - upload_port = (int)config.Item( ZM_UPLOAD_PORT );\ - upload_ftp_user = (const char *)config.Item( ZM_UPLOAD_FTP_USER );\ - upload_user = (const char *)config.Item( ZM_UPLOAD_USER );\ - upload_ftp_pass = (const char *)config.Item( ZM_UPLOAD_FTP_PASS );\ - upload_pass = (const char *)config.Item( ZM_UPLOAD_PASS );\ - upload_ftp_loc_dir = (const char *)config.Item( ZM_UPLOAD_FTP_LOC_DIR );\ - upload_loc_dir = (const char *)config.Item( ZM_UPLOAD_LOC_DIR );\ - upload_ftp_rem_dir = (const char *)config.Item( ZM_UPLOAD_FTP_REM_DIR );\ - upload_rem_dir = (const char *)config.Item( ZM_UPLOAD_REM_DIR );\ - upload_ftp_timeout = (int)config.Item( ZM_UPLOAD_FTP_TIMEOUT );\ - upload_timeout = (int)config.Item( ZM_UPLOAD_TIMEOUT );\ - upload_ftp_passive = (bool)config.Item( ZM_UPLOAD_FTP_PASSIVE );\ - upload_ftp_debug = (bool)config.Item( ZM_UPLOAD_FTP_DEBUG );\ - upload_debug = (bool)config.Item( ZM_UPLOAD_DEBUG );\ - opt_email = (bool)config.Item( ZM_OPT_EMAIL );\ - email_address = (const char *)config.Item( ZM_EMAIL_ADDRESS );\ - email_text = (const char *)config.Item( ZM_EMAIL_TEXT );\ - email_subject = (const char *)config.Item( ZM_EMAIL_SUBJECT );\ - email_body = (const char *)config.Item( ZM_EMAIL_BODY );\ - opt_message = (bool)config.Item( ZM_OPT_MESSAGE );\ - message_address = (const char *)config.Item( ZM_MESSAGE_ADDRESS );\ - message_text = (const char *)config.Item( ZM_MESSAGE_TEXT );\ - message_subject = (const char *)config.Item( ZM_MESSAGE_SUBJECT );\ - message_body = (const char *)config.Item( ZM_MESSAGE_BODY );\ - new_mail_modules = (bool)config.Item( ZM_NEW_MAIL_MODULES );\ - email_host = (const char *)config.Item( ZM_EMAIL_HOST );\ - from_email = (const char *)config.Item( ZM_FROM_EMAIL );\ - url = (const char *)config.Item( ZM_URL );\ - max_restart_delay = (int)config.Item( ZM_MAX_RESTART_DELAY );\ - watch_check_interval = (int)config.Item( ZM_WATCH_CHECK_INTERVAL );\ - watch_max_delay = (double) config.Item( ZM_WATCH_MAX_DELAY );\ - run_audit = (bool)config.Item( ZM_RUN_AUDIT );\ - audit_check_interval = (int)config.Item( ZM_AUDIT_CHECK_INTERVAL );\ - forced_alarm_score = (int)config.Item( ZM_FORCED_ALARM_SCORE );\ - bulk_frame_interval = (int)config.Item( ZM_BULK_FRAME_INTERVAL );\ - event_close_mode = (const char *)config.Item( ZM_EVENT_CLOSE_MODE );\ - force_close_events = (bool)config.Item( ZM_FORCE_CLOSE_EVENTS );\ - create_analysis_images = (bool)config.Item( ZM_CREATE_ANALYSIS_IMAGES );\ - weighted_alarm_centres = (bool)config.Item( ZM_WEIGHTED_ALARM_CENTRES );\ - event_image_digits = (int)config.Item( ZM_EVENT_IMAGE_DIGITS );\ - default_aspect_ratio = (const char *)config.Item( ZM_DEFAULT_ASPECT_RATIO );\ - user_self_edit = (bool)config.Item( ZM_USER_SELF_EDIT );\ - opt_frame_server = (bool)config.Item( ZM_OPT_FRAME_SERVER );\ - frame_socket_size = (int)config.Item( ZM_FRAME_SOCKET_SIZE );\ - opt_control = (bool)config.Item( ZM_OPT_CONTROL );\ - opt_triggers = (bool)config.Item( ZM_OPT_TRIGGERS );\ - check_for_updates = (bool)config.Item( ZM_CHECK_FOR_UPDATES );\ - update_check_proxy = (const char *)config.Item( ZM_UPDATE_CHECK_PROXY );\ - shm_key = (int)config.Item( ZM_SHM_KEY );\ - web_refresh_method = (const char *)config.Item( ZM_WEB_REFRESH_METHOD );\ - web_event_sort_field = (const char *)config.Item( ZM_WEB_EVENT_SORT_FIELD );\ - web_event_sort_order = (const char *)config.Item( ZM_WEB_EVENT_SORT_ORDER );\ - web_events_per_page = (int)config.Item( ZM_WEB_EVENTS_PER_PAGE );\ - web_list_thumbs = (bool)config.Item( ZM_WEB_LIST_THUMBS );\ - web_list_thumb_width = (int)config.Item( ZM_WEB_LIST_THUMB_WIDTH );\ - web_list_thumb_height = (int)config.Item( ZM_WEB_LIST_THUMB_HEIGHT );\ - web_use_object_tags = (bool)config.Item( ZM_WEB_USE_OBJECT_TAGS );\ - web_h_refresh_main = (int)config.Item( ZM_WEB_H_REFRESH_MAIN );\ - web_h_refresh_cycle = (int)config.Item( ZM_WEB_H_REFRESH_CYCLE );\ - web_h_refresh_image = (int)config.Item( ZM_WEB_H_REFRESH_IMAGE );\ - web_h_refresh_status = (int)config.Item( ZM_WEB_H_REFRESH_STATUS );\ - web_h_refresh_events = (int)config.Item( ZM_WEB_H_REFRESH_EVENTS );\ - web_h_can_stream = (const char *)config.Item( ZM_WEB_H_CAN_STREAM );\ - web_h_stream_method = (const char *)config.Item( ZM_WEB_H_STREAM_METHOD );\ - web_h_default_scale = (int)config.Item( ZM_WEB_H_DEFAULT_SCALE );\ - web_h_default_rate = (int)config.Item( ZM_WEB_H_DEFAULT_RATE );\ - web_h_video_bitrate = (int)config.Item( ZM_WEB_H_VIDEO_BITRATE );\ - web_h_video_maxfps = (int)config.Item( ZM_WEB_H_VIDEO_MAXFPS );\ - web_h_scale_thumbs = (bool)config.Item( ZM_WEB_H_SCALE_THUMBS );\ - web_h_events_view = (const char *)config.Item( ZM_WEB_H_EVENTS_VIEW );\ - web_h_show_progress = (bool)config.Item( ZM_WEB_H_SHOW_PROGRESS );\ - web_h_ajax_timeout = (int)config.Item( ZM_WEB_H_AJAX_TIMEOUT );\ - web_m_refresh_main = (int)config.Item( ZM_WEB_M_REFRESH_MAIN );\ - web_m_refresh_cycle = (int)config.Item( ZM_WEB_M_REFRESH_CYCLE );\ - web_m_refresh_image = (int)config.Item( ZM_WEB_M_REFRESH_IMAGE );\ - web_m_refresh_status = (int)config.Item( ZM_WEB_M_REFRESH_STATUS );\ - web_m_refresh_events = (int)config.Item( ZM_WEB_M_REFRESH_EVENTS );\ - web_m_can_stream = (const char *)config.Item( ZM_WEB_M_CAN_STREAM );\ - web_m_stream_method = (const char *)config.Item( ZM_WEB_M_STREAM_METHOD );\ - web_m_default_scale = (int)config.Item( ZM_WEB_M_DEFAULT_SCALE );\ - web_m_default_rate = (int)config.Item( ZM_WEB_M_DEFAULT_RATE );\ - web_m_video_bitrate = (int)config.Item( ZM_WEB_M_VIDEO_BITRATE );\ - web_m_video_maxfps = (int)config.Item( ZM_WEB_M_VIDEO_MAXFPS );\ - web_m_scale_thumbs = (bool)config.Item( ZM_WEB_M_SCALE_THUMBS );\ - web_m_events_view = (const char *)config.Item( ZM_WEB_M_EVENTS_VIEW );\ - web_m_show_progress = (bool)config.Item( ZM_WEB_M_SHOW_PROGRESS );\ - web_m_ajax_timeout = (int)config.Item( ZM_WEB_M_AJAX_TIMEOUT );\ - web_l_refresh_main = (int)config.Item( ZM_WEB_L_REFRESH_MAIN );\ - web_l_refresh_cycle = (int)config.Item( ZM_WEB_L_REFRESH_CYCLE );\ - web_l_refresh_image = (int)config.Item( ZM_WEB_L_REFRESH_IMAGE );\ - web_l_refresh_status = (int)config.Item( ZM_WEB_L_REFRESH_STATUS );\ - web_l_refresh_events = (int)config.Item( ZM_WEB_L_REFRESH_EVENTS );\ - web_l_can_stream = (const char *)config.Item( ZM_WEB_L_CAN_STREAM );\ - web_l_stream_method = (const char *)config.Item( ZM_WEB_L_STREAM_METHOD );\ - web_l_default_scale = (int)config.Item( ZM_WEB_L_DEFAULT_SCALE );\ - web_l_default_rate = (int)config.Item( ZM_WEB_L_DEFAULT_RATE );\ - web_l_video_bitrate = (int)config.Item( ZM_WEB_L_VIDEO_BITRATE );\ - web_l_video_maxfps = (int)config.Item( ZM_WEB_L_VIDEO_MAXFPS );\ - web_l_scale_thumbs = (bool)config.Item( ZM_WEB_L_SCALE_THUMBS );\ - web_l_events_view = (const char *)config.Item( ZM_WEB_L_EVENTS_VIEW );\ - web_l_show_progress = (bool)config.Item( ZM_WEB_L_SHOW_PROGRESS );\ - web_l_ajax_timeout = (int)config.Item( ZM_WEB_L_AJAX_TIMEOUT );\ - web_p_can_stream = (const char *)config.Item( ZM_WEB_P_CAN_STREAM );\ - web_p_stream_method = (const char *)config.Item( ZM_WEB_P_STREAM_METHOD );\ - web_p_default_scale = (int)config.Item( ZM_WEB_P_DEFAULT_SCALE );\ - web_p_default_rate = (int)config.Item( ZM_WEB_P_DEFAULT_RATE );\ - web_p_video_bitrate = (int)config.Item( ZM_WEB_P_VIDEO_BITRATE );\ - web_p_video_maxfps = (int)config.Item( ZM_WEB_P_VIDEO_MAXFPS );\ - web_p_scale_thumbs = (bool)config.Item( ZM_WEB_P_SCALE_THUMBS );\ - web_p_ajax_timeout = (int)config.Item( ZM_WEB_P_AJAX_TIMEOUT );\ - dyn_last_version = (const char *)config.Item( ZM_DYN_LAST_VERSION );\ - dyn_curr_version = (const char *)config.Item( ZM_DYN_CURR_VERSION );\ - dyn_db_version = (const char *)config.Item( ZM_DYN_DB_VERSION );\ - dyn_last_check = (int)config.Item( ZM_DYN_LAST_CHECK );\ - dyn_next_reminder = (const char *)config.Item( ZM_DYN_NEXT_REMINDER );\ - dyn_donate_reminder_time = (int)config.Item( ZM_DYN_DONATE_REMINDER_TIME );\ - dyn_show_donate_reminder = (bool)config.Item( ZM_DYN_SHOW_DONATE_REMINDER );\ - eyezm_debug = (bool)config.Item( ZM_EYEZM_DEBUG );\ - eyezm_log_to_file = (bool)config.Item( ZM_EYEZM_LOG_TO_FILE );\ - eyezm_log_file = (const char *)config.Item( ZM_EYEZM_LOG_FILE );\ - eyezm_event_vcodec = (const char *)config.Item( ZM_EYEZM_EVENT_VCODEC );\ - eyezm_feed_vcodec = (const char *)config.Item( ZM_EYEZM_FEED_VCODEC );\ - eyezm_h264_default_br = (const char *)config.Item( ZM_EYEZM_H264_DEFAULT_BR );\ - eyezm_h264_default_evbr = (const char *)config.Item( ZM_EYEZM_H264_DEFAULT_EVBR );\ - eyezm_h264_timeout = (const char *)config.Item( ZM_EYEZM_H264_TIMEOUT );\ - eyezm_seg_duration = (const char *)config.Item( ZM_EYEZM_SEG_DURATION );\ - - diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 2002f3a0c..c79eaa442 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -1288,11 +1288,11 @@ void Image::Overlay( const Image &image, int x, int y ) } -void Image::Blend( const Image &image, int transparency ) const +void Image::Blend( const Image &image, int transparency ) { if ( !(width == image.width && height == image.height && colours == image.colours && subpixelorder == image.subpixelorder) ) { - Panic( "Attempt to blend different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, image.width, image.height, image.colours, image.subpixelorder ); + Panic( "Attempt to blend different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, image.width, image.height, image.colours, image.subpixelorder ); } /* Do the blending */ diff --git a/src/zm_image.h b/src/zm_image.h index ae553deee..52f8d7ddc 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -217,7 +217,7 @@ public: void Overlay( const Image &image ); void Overlay( const Image &image, int x, int y ); - void Blend( const Image &image, int transparency=10 ) const; + void Blend( const Image &image, int transparency=12 ); static Image *Merge( int n_images, Image *images[] ); static Image *Merge( int n_images, Image *images[], double weight ); static Image *Highlight( int n_images, Image *images[], const Rgb threshold=RGB_BLACK, const Rgb ref_colour=RGB_RED ); diff --git a/web/lang/big5_big5.php b/web/lang/big5_big5.php index d09a0ccfd..7f9e18da7 100644 --- a/web/lang/big5_big5.php +++ b/web/lang/big5_big5.php @@ -76,6 +76,7 @@ setlocale( LC_TIME, 'Big5' ); //Date and time formatting 4.3.0 and after // Simple String Replacements $SLANG = array( '24BitColour' => '24 ä½�元色彩', + '32BitColour' => '32 ä½�元色彩', // Added - 2011-06-15 '8BitGrey' => '8 ä½�å…ƒç�°éšŽ', 'Action' => 'Action', 'Actual' => 'Actual', @@ -130,6 +131,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to an integer of zero or more', diff --git a/web/lang/cn_zh.php b/web/lang/cn_zh.php index c4b36bbe2..7850fec01 100644 --- a/web/lang/cn_zh.php +++ b/web/lang/cn_zh.php @@ -72,6 +72,7 @@ // Simple String Replacements $SLANG = array( '24BitColour' => '24 ä½�彩色', + '32BitColour' => '32 ä½�彩色', // Added - 2011-06-15 '8BitGrey' => '8 ä½�ç�°åº¦', 'Action' => '活动动作', 'Actual' => '实际', @@ -126,6 +127,7 @@ $SLANG = array( 'BadAlarmFrameCount' => '报警帧数必须设为大于1的整数', 'BadAlarmMaxFPS' => '报警最大帧率必须是正整数或正浮点数', 'BadChannel' => '通é�“必须设为大于零的整数', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => '必须为器件设置有效值', 'BadFPSReportInterval' => 'FPS帧数报告间隔缓冲数必须是0以上整数', 'BadFormat' => 'æ ¼å¼�必须设为大于零的整数', diff --git a/web/lang/cs_cz.php b/web/lang/cs_cz.php index 570ea69ce..c04694cd7 100644 --- a/web/lang/cs_cz.php +++ b/web/lang/cs_cz.php @@ -72,6 +72,7 @@ // Simple String Replacements $SLANG = array( '24BitColour' => '24 bit barevná', + '32BitColour' => '32 bit barevná', // Added - 2011-06-15 '8BitGrey' => '8 bit ¹edá ¹kála', 'Action' => 'Akce', 'Actual' => 'Skuteèná', @@ -126,6 +127,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to an integer of zero or more', diff --git a/web/lang/de_de.php b/web/lang/de_de.php index 47a9648ae..1e179cf0e 100644 --- a/web/lang/de_de.php +++ b/web/lang/de_de.php @@ -72,6 +72,7 @@ // Simple String Replacements $SLANG = array( '24BitColour' => '24-Bit-Farbe', + '32BitColour' => '32-Bit-Farbe', // Added - 2011-06-15 '8BitGrey' => '8-Bit-Grau', 'Action' => 'Aktion', 'Actual' => 'Original', @@ -126,6 +127,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Die Bildanzahl muss ganzzahlig 1 oder größer sein', 'BadAlarmMaxFPS' => 'Alarm-Maximum-FPS muss eine positive Ganzzahl oder eine Gleitkommazahl sein', 'BadChannel' => 'Der Kanal muss ganzzahlig 0 oder größer sein', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Das Gerät muss eine gültige Systemresource sein', 'BadFPSReportInterval' => 'Der FPS-Intervall-Puffer-Zähler muss ganzzahlig 0 oder größer sein', 'BadFormat' => 'Das Format muss ganzzahlig 0 oder größer sein', diff --git a/web/lang/dk_dk.php b/web/lang/dk_dk.php index 36f2521b2..6a8387123 100644 --- a/web/lang/dk_dk.php +++ b/web/lang/dk_dk.php @@ -73,6 +73,7 @@ header( "Content-Type: text/html; charset=windows-1252" ); // Simple String Replacements $SLANG = array( '24BitColour' => '24 bit farve', + '32BitColour' => '32 bit farve', // Added - 2011-06-15 '8BitGrey' => '8 bit greyscale', 'Action' => 'Action', 'Actual' => 'Aktuel', @@ -127,6 +128,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to an integer of zero or more', diff --git a/web/lang/en_gb.php b/web/lang/en_gb.php index 23778193b..3f703dd24 100644 --- a/web/lang/en_gb.php +++ b/web/lang/en_gb.php @@ -81,6 +81,7 @@ $SLANG = array( 'More' => 'More', 'Clear' => 'Clear', '24BitColour' => '24 bit colour', + '32BitColour' => '32 bit colour', '8BitGrey' => '8 bit greyscale', 'Action' => 'Action', 'Actual' => 'Actual', @@ -148,6 +149,7 @@ $SLANG = array( 'BadMaxFPS' => 'Maximum FPS must be a positive integer or floating point value', 'BadNameChars' => 'Names may only contain alphanumeric characters plus hyphen and underscore', 'BadPalette' => 'Palette must be set to a valid value', + 'BadColours' => 'Target colour must be set to a valid value', 'BadPath' => 'Path must be set to a valid value', 'BadPort' => 'Port must be set to a valid number', 'BadPostEventCount' => 'Post event image count must be an integer of zero or more', diff --git a/web/lang/en_us.php b/web/lang/en_us.php index 46cec04d5..262e47cec 100644 --- a/web/lang/en_us.php +++ b/web/lang/en_us.php @@ -71,6 +71,7 @@ require_once( 'lang/en_gb.php' ); // Simple String Replacements $SLANG['24BitColour'] = '24 bit color'; +$SLANG['32BitColour'] = '32 bit color'; $SLANG['8BitGrey'] = '8 bit grayscale'; $SLANG['Colour'] = 'Color'; $SLANG['Grey'] = 'Gray'; diff --git a/web/lang/es_ar.php b/web/lang/es_ar.php index c5759000f..452f7d1ef 100644 --- a/web/lang/es_ar.php +++ b/web/lang/es_ar.php @@ -23,6 +23,7 @@ // Simple String Replacements $SLANG = array( '24BitColour' => 'Color 24 bits', + '32BitColour' => 'Color 32 bits', // Added - 2011-06-15 '8BitGrey' => 'Grises 8 bits', 'Action' => 'Action', 'Actual' => 'Actual', @@ -77,6 +78,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to an integer of zero or more', diff --git a/web/lang/es_es.php b/web/lang/es_es.php index bdefce271..0e5d96753 100644 --- a/web/lang/es_es.php +++ b/web/lang/es_es.php @@ -72,6 +72,7 @@ header ('Content-type: text/html; charset=utf-8'); // Simple String Replacements $SLANG = array( '24BitColour' => 'Color 24 bits', + '32BitColour' => 'Color 32 bits', '8BitGrey' => 'Grises 8 bits', 'Action' => 'Acción', 'Actual' => 'Actual', diff --git a/web/lang/et_ee.php b/web/lang/et_ee.php index 68786cb3e..a6d23903e 100644 --- a/web/lang/et_ee.php +++ b/web/lang/et_ee.php @@ -68,6 +68,7 @@ header( "Content-Type: text/html; charset=UTF-8" ); // Simple String Replacements $SLANG = array( '24BitColour' => '24 bit colour', + '32BitColour' => '32 bit colour', // Added - 2011-06-15 '8BitGrey' => '8 bit greyscale', 'Action' => 'Action', 'Actual' => 'Actual', @@ -122,6 +123,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to a valid value', diff --git a/web/lang/fr_fr.php b/web/lang/fr_fr.php index b6ad10972..97dfe5e6e 100644 --- a/web/lang/fr_fr.php +++ b/web/lang/fr_fr.php @@ -72,6 +72,7 @@ // Simple String Replacements $SLANG = array( '24BitColour' => 'Couleur 24 bit', + '32BitColour' => 'Couleur 32 bit', // Added - 2011-06-15 '8BitGrey' => 'Gris 8 bit', 'Action' => 'Action', 'Actual' => 'Réel', @@ -126,6 +127,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to an integer of zero or more', diff --git a/web/lang/he_il.php b/web/lang/he_il.php index 6ff41efdb..fbff24de0 100755 --- a/web/lang/he_il.php +++ b/web/lang/he_il.php @@ -72,6 +72,7 @@ setlocale( LC_ALL, 'he_IL' ); //All locale settings 4.3.0 and after // Simple String Replacements $SLANG = array( '24BitColour' => 'öáò 24 áéè', + '32BitColour' => 'öáò 32 áéè', // Added - 2011-06-15 '8BitGrey' => 'âååðé àôåø 8 áéè', 'Action' => 'ôòåìä', 'Actual' => 'î÷åøé', @@ -126,6 +127,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to an integer of zero or more', diff --git a/web/lang/hu_hu.php b/web/lang/hu_hu.php index 1e6145ed1..2a27a9c9a 100644 --- a/web/lang/hu_hu.php +++ b/web/lang/hu_hu.php @@ -81,6 +81,7 @@ setlocale( LC_ALL, 'hu_HU' ); // Simple String Replacements $SLANG = array( '24BitColour' => '24 bites szín', + '32BitColour' => '32 bites szín', // Added - 2011-06-15 '8BitGrey' => '8 bit szürkeárnyalat', 'Action' => 'Mûvelet', 'Actual' => 'Valós', @@ -135,6 +136,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Riadó képek száma 1 vagy nagyobb egész szám legyen', 'BadAlarmMaxFPS' => 'A riadó maximális FPS száma pozitív szám legyen', 'BadChannel' => 'A csatorna száma 0 vagy nagyobb egész szám legyen', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Az eszköz érték valós legyen', 'BadFPSReportInterval' => 'FPS információs idõköz puffer számlálója 0 vagy nagyobb egész legyen', 'BadFormat' => 'A típus 0 vagy nagyobb egész szám legyen', diff --git a/web/lang/it_it.php b/web/lang/it_it.php index 9002efc74..3cda3c37a 100644 --- a/web/lang/it_it.php +++ b/web/lang/it_it.php @@ -77,6 +77,7 @@ // Simple String Replacements $SLANG = array( '24BitColour' => 'colori a 24 bit', + '32BitColour' => 'colori a 32 bit', // Added - 2011-06-15 '8BitGrey' => '8 bit scala di grigio', 'Action' => 'Azione', 'Actual' => 'Attuale', @@ -131,6 +132,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Il numero di frame di un allarme deve essere un numero intero superiore a uno', 'BadAlarmMaxFPS' => 'Il numero massimo di FPS dell\'allarme deve essere un numero intero positivo o un valore in virgola mobile', 'BadChannel' => 'Il canale deve essere settato con un numero intero uguale o maggiore di zero', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Il dispositivo deve essere impostato con un valore valido', 'BadFPSReportInterval' => 'L\'intervallo di FPS per i report deve essere un numero intero superiore a 0', 'BadFormat' => 'Il formato deve essere impostato con un numero intero come 0 o maggiore', diff --git a/web/lang/ja_jp.php b/web/lang/ja_jp.php index 4986934b2..0d083449f 100644 --- a/web/lang/ja_jp.php +++ b/web/lang/ja_jp.php @@ -72,6 +72,7 @@ // Simple String Replacements $SLANG = array( '24BitColour' => '24ËޯĶװ', + '32BitColour' => '32ËޯĶװ', // Added - 2011-06-15 '8BitGrey' => '8ËޯĔZ’W‰æ‘œ', 'Action' => 'Action', 'Actual' => '�¶’†Œp', @@ -126,6 +127,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to an integer of zero or more', diff --git a/web/lang/nl_nl.php b/web/lang/nl_nl.php index c8a994f9f..0526455a1 100644 --- a/web/lang/nl_nl.php +++ b/web/lang/nl_nl.php @@ -72,6 +72,7 @@ // Simple String Replacements $SLANG = array( '24BitColour' => '24 bit kleuren', + '32BitColour' => '32 bit kleuren', // Added - 2011-06-15 '8BitGrey' => '8 bit grijstinten', 'Action' => 'Action', 'Actual' => 'Aktueel', @@ -126,6 +127,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to an integer of zero or more', diff --git a/web/lang/pl_pl.php b/web/lang/pl_pl.php index a8cf3195f..288d0fef2 100644 --- a/web/lang/pl_pl.php +++ b/web/lang/pl_pl.php @@ -72,6 +72,7 @@ setlocale( LC_ALL, 'pl_PL' ); // All locale settings 4.3.0 and after // Simple String Replacements $SLANG = array( '24BitColour' => 'Kolor (24 bity)', + '32BitColour' => 'Kolor (32 bity)', // Added - 2011-06-15 '8BitGrey' => 'Cz/b (8 bitów)', 'Action' => 'Action', 'Actual' => 'Aktualny', @@ -126,6 +127,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to an integer of zero or more', diff --git a/web/lang/pt_br.php b/web/lang/pt_br.php index 627e49a84..62586b33b 100644 --- a/web/lang/pt_br.php +++ b/web/lang/pt_br.php @@ -12,6 +12,7 @@ // Simple String Replacements $SLANG = array( '24BitColour' => 'cor 24 bits', + '32BitColour' => 'cor 32 bits', // Added - 2011-06-15 '8BitGrey' => 'cinza 8 bits', 'Action' => 'Action', 'Actual' => 'Atual', @@ -66,6 +67,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to an integer of zero or more', diff --git a/web/lang/ro_ro.php b/web/lang/ro_ro.php index 2d1f70128..563d95aca 100755 --- a/web/lang/ro_ro.php +++ b/web/lang/ro_ro.php @@ -43,6 +43,7 @@ setlocale( LC_ALL, 'ro_RO' ); // Simple String Replacements $SLANG = array( '24BitColour' => 'Color ân 24 biţi', + '32BitColour' => 'Color ân 32 biţi', // Added - 2011-06-15 '8BitGrey' => 'Scală gri ân 8 biţi', 'Action' => 'Action', 'Actual' => 'Real', @@ -97,6 +98,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to an integer of zero or more', diff --git a/web/lang/ru_ru.php b/web/lang/ru_ru.php index 0e34cfef5..1f7e55f52 100644 --- a/web/lang/ru_ru.php +++ b/web/lang/ru_ru.php @@ -72,6 +72,7 @@ header( "Content-Type: text/html; charset=koi8-r" ); // Simple String Replacements $SLANG = array( '24BitColour' => '24 ÂÉÔÎÙÊ Ã×ÅÔ', + '32BitColour' => '32 ÂÉÔÎÙÊ Ã×ÅÔ', // Added - 2011-06-15 '8BitGrey' => '256 ÏÔÔÅÎËÏ× ÓÅÒÏÇÏ', 'Action' => 'Action', 'Actual' => 'äÅÊÓÔ×ÉÔÅÌØÎÙÊ', @@ -126,6 +127,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more', 'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value', 'BadChannel' => 'Channel must be set to an integer of zero or more', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Device must be set to a valid value', 'BadFPSReportInterval' => 'FPS report interval buffer count must be an integer of 0 or more', 'BadFormat' => 'Format must be set to an integer of zero or more', diff --git a/web/lang/se_se.php b/web/lang/se_se.php index 696d34d75..f3a65c75a 100644 --- a/web/lang/se_se.php +++ b/web/lang/se_se.php @@ -73,6 +73,7 @@ // Simple String Replacements $SLANG = array( '24BitColour' => '24 bitars färg', + '32BitColour' => '32 bitars färg', // Added - 2011-06-15 '8BitGrey' => '8 bit gråskala', 'Action' => 'Action', 'Actual' => 'Verklig', @@ -127,6 +128,7 @@ $SLANG = array( 'BadAlarmFrameCount' => 'Ramantalet för larm måste vara ett heltal, minsta värdet är 1', 'BadAlarmMaxFPS' => 'Larm för bilder/s måste vara ett positivt heltal eller ett flyttal', 'BadChannel' => 'Kanalen måste vara ett heltal, noll eller högre', + 'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15 'BadDevice' => 'Enheten måste sättas till ett giltigt värde', 'BadFPSReportInterval' => 'Buffern för ramintervallrapporten måste vara ett heltal på minst 0 eller högre', 'BadFormat' => 'Formatet måste vara ett heltal, noll eller högre', diff --git a/web/skins/classic/views/js/monitor.js.php b/web/skins/classic/views/js/monitor.js.php index 1574c1cf4..11c6dd815 100644 --- a/web/skins/classic/views/js/monitor.js.php +++ b/web/skins/classic/views/js/monitor.js.php @@ -117,7 +117,7 @@ function validateForm( form ) errors[errors.length] = ""; if ( !form.elements['newMonitor[SectionLength]'].value || !(parseInt(form.elements['newMonitor[SectionLength]'].value) >= 30 ) ) errors[errors.length] = ""; - if ( !form.elements['newMonitor[FPSReportInterval]'].value || !(parseInt(form.elements['newMonitor[FPSReportInterval]'].value) >= 100 ) ) + if ( !form.elements['newMonitor[FPSReportInterval]'].value || !(parseInt(form.elements['newMonitor[FPSReportInterval]'].value) >= 0 ) ) errors[errors.length] = ""; if ( !form.elements['newMonitor[FrameSkip]'].value || !(parseInt(form.elements['newMonitor[FrameSkip]'].value) >= 0 ) ) errors[errors.length] = ""; diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 23629e352..cb875f25b 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -352,7 +352,7 @@ if ( ZM_HAS_V4L2 ) $Colours = array( $SLANG['8BitGrey'] => 1, $SLANG['24BitColour'] => 3, - "32 bit colour" => 4 + $SLANG['32BitColour'] => 4 ); $orientations = array( From 63122ab9bc84bd8c5c06863f5459716cea0f490a Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 15 Jun 2011 19:13:04 +0300 Subject: [PATCH 16/56] Undo translations in es_es.php because its not available in the ZM 1.24.4 package. --- web/lang/es_es.php | 1 - 1 file changed, 1 deletion(-) diff --git a/web/lang/es_es.php b/web/lang/es_es.php index 0e5d96753..bdefce271 100644 --- a/web/lang/es_es.php +++ b/web/lang/es_es.php @@ -72,7 +72,6 @@ header ('Content-type: text/html; charset=utf-8'); // Simple String Replacements $SLANG = array( '24BitColour' => 'Color 24 bits', - '32BitColour' => 'Color 32 bits', '8BitGrey' => 'Grises 8 bits', 'Action' => 'Acción', 'Actual' => 'Actual', From de2df49d6443a544091cff6b7b18aa0b16290d46 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 22 Jun 2011 18:38:35 +0300 Subject: [PATCH 17/56] 1) Added support for the new formats to the mpeg code. 2) Fixed unwanted extra call to set video format for local cameras. 3) Small changes to the perl shared memory types. --- .../ZoneMinder/lib/ZoneMinder/Memory.pm.in | 108 ++++++++++++------ src/zm_event.cpp | 4 +- src/zm_local_camera.cpp | 28 +++-- src/zm_mem_utils.h | 12 +- src/zm_monitor.cpp | 2 +- src/zm_mpeg.cpp | 51 +++++++-- src/zm_mpeg.h | 4 +- src/zm_stream.cpp | 2 +- 8 files changed, 144 insertions(+), 67 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in index a6f7395ff..9e75269c8 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in @@ -146,16 +146,16 @@ our $mem_data = "contrast" => { "type"=>"int32", "seq"=>$mem_seq++ }, "alarm_x" => { "type"=>"int32", "seq"=>$mem_seq++ }, "alarm_y" => { "type"=>"int32", "seq"=>$mem_seq++ }, - "valid" => { "type"=>"uchar", "seq"=>$mem_seq++ }, - "active" => { "type"=>"uchar", "seq"=>$mem_seq++ }, - "signal" => { "type"=>"uchar", "seq"=>$mem_seq++ }, - "bpadding" => { "type"=>"uchar", "seq"=>$mem_seq++ }, + "valid" => { "type"=>"uint8", "seq"=>$mem_seq++ }, + "active" => { "type"=>"uint8", "seq"=>$mem_seq++ }, + "signal" => { "type"=>"uint8", "seq"=>$mem_seq++ }, + "bpadding" => { "type"=>"uint8", "seq"=>$mem_seq++ }, "epadding1" => { "type"=>"uint32", "seq"=>$mem_seq++ }, "epadding2" => { "type"=>"uint32", "seq"=>$mem_seq++ }, "epadding3" => { "type"=>"uint32", "seq"=>$mem_seq++ }, "last_write_time" => { "type"=>"time_t64", "seq"=>$mem_seq++ }, "last_read_time" => { "type"=>"time_t64", "seq"=>$mem_seq++ }, - "control_state" => { "type"=>"uchar[256]", "seq"=>$mem_seq++ }, + "control_state" => { "type"=>"uint8[256]", "seq"=>$mem_seq++ }, } }, "trigger_data" => { "type"=>"TriggerData", "seq"=>$mem_seq++, "contents"=> { @@ -163,9 +163,9 @@ our $mem_data = "trigger_state" => { "type"=>"uint32", "seq"=>$mem_seq++ }, "trigger_score" => { "type"=>"uint32", "seq"=>$mem_seq++ }, "padding" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "trigger_cause" => { "type"=>"char[32]", "seq"=>$mem_seq++ }, - "trigger_text" => { "type"=>"char[256]", "seq"=>$mem_seq++ }, - "trigger_showtext" => { "type"=>"char[256]", "seq"=>$mem_seq++ }, + "trigger_cause" => { "type"=>"int8[32]", "seq"=>$mem_seq++ }, + "trigger_text" => { "type"=>"int8[256]", "seq"=>$mem_seq++ }, + "trigger_showtext" => { "type"=>"int8[256]", "seq"=>$mem_seq++ }, } }, "end" => { "seq"=>$mem_seq++, "size"=> 0 } @@ -205,15 +205,15 @@ sub zmMemInit { $member_data->{size} = $member_data->{align} = 4; } - elsif ( $member_data->{type} eq "short" ) + elsif ($member_data->{type} eq "int16" || $member_data->{type} eq "uint16") { $member_data->{size} = $member_data->{align} = 2; } - elsif ( $member_data->{type} eq "char" || $member_data->{type} eq "uchar" || $member_data->{type} eq "bool1" ) + elsif ( $member_data->{type} eq "int8" || $member_data->{type} eq "uint8" || $member_data->{type} eq "bool1" ) { $member_data->{size} = $member_data->{align} = 1; } - elsif ( $member_data->{type} =~ /^u?char\[(\d+)\]$/ ) + elsif ( $member_data->{type} =~ /^u?int8\[(\d+)\]$/ ) { $member_data->{size} = $1; $member_data->{align} = 1; @@ -313,36 +313,53 @@ sub zmMemRead( $$;$ ) return( undef ); } my $value; - if ( $type eq "long" || $type eq "ulong" || $type eq "size_t") + if ( $type eq "long" ) { ( $value ) = unpack( "l!", $data ); } - elsif ( $type eq "int64" || $type eq "uint64" || $type eq "time_t64" ) + elsif ( $type eq "ulong" || $type eq "size_t" ) { - # The "q" type is only available on 64bit platforms. + ( $value ) = unpack( "L!", $data ); + } + elsif ( $type eq "int64" || $type eq "time_t64" ) + { + # The "q" type is only available on 64bit platforms, so use native. ( $value ) = unpack( "l!", $data ); } - elsif ( $type eq "int32" || $type eq "uint32" || $type eq "bool4" ) + elsif ( $type eq "uint64" ) + { + # The "q" type is only available on 64bit platforms, so use native. + ( $value ) = unpack( "L!", $data ); + } + elsif ( $type eq "int32" ) { ( $value ) = unpack( "l", $data ); } - elsif ( $type eq "short" ) + elsif ( $type eq "uint32" || $type eq "bool4" ) + { + ( $value ) = unpack( "L", $data ); + } + elsif ( $type eq "int16" ) { ( $value ) = unpack( "s", $data ); } - elsif ( $type eq "char" || $type eq "bool1" ) + elsif ( $type eq "uint16" ) + { + ( $value ) = unpack( "S", $data ); + } + elsif ( $type eq "int8" ) { ( $value ) = unpack( "c", $data ); } - elsif ( $type eq "uchar" ) + elsif ( $type eq "uint8" || $type eq "bool1" ) { ( $value ) = unpack( "C", $data ); } - elsif ( $type =~ /^char\[\d+\]$/ ) + elsif ( $type =~ /^int8\[\d+\]$/ ) { ( $value ) = unpack( "Z".$size, $data ); } - elsif ( $type =~ /^uchar\[\d+\]$/ ) + elsif ( $type =~ /^uint8\[\d+\]$/ ) { ( $value ) = unpack( "C".$size, $data ); } @@ -396,39 +413,56 @@ sub zmMemWrite( $$;$ ) my $size = $mem_data->{$section}->{contents}->{$element}->{size}; my $data; - if ( $type eq "long" || $type eq "ulong" || $type eq "size_t") + if ( $type eq "long" ) { - $data = pack( "l!", $value ); + $data = pack( "l!", $data ); } - elsif ( $type eq "int64" || $type eq "uint64" || $type eq "time_t64" ) + elsif ( $type eq "ulong" || $type eq "size_t" ) { - # The "q" type is only available on 64bit platforms. - $data = pack( "l!", $value ); + $data = pack( "L!", $data ); } - elsif ( $type eq "int32" || $type eq "uint32" || $type eq "bool4" ) + elsif ( $type eq "int64" || $type eq "time_t64" ) { - $data = pack( "l", $value ); + # The "q" type is only available on 64bit platforms, so use native. + $data = pack( "l!", $data ); } - elsif ( $type eq "short" ) + elsif ( $type eq "uint64" ) { - $data = pack( "s", $value ); + # The "q" type is only available on 64bit platforms, so use native. + $data = pack( "L!", $data ); } - elsif ( $type eq "char" || $type eq "bool1" ) + elsif ( $type eq "int32" ) { - $data = pack( "c", $value ); + $data = pack( "l", $data ); } - elsif ( $type eq "uchar" ) + elsif ( $type eq "uint32" || $type eq "bool4" ) { - $data = pack( "C", $value ); + $data = pack( "L", $data ); } - elsif ( $type =~ /^char\[\d+\]$/ ) + elsif ( $type eq "int16" ) { - $data = pack( "Z".$size, $value ); + $data = pack( "s", $data ); } - elsif ( $type =~ /^uchar\[\d+\]$/ ) + elsif ( $type eq "uint16" ) { - $data = pack( "C".$size, $value ); + $data = pack( "S", $data ); } + elsif ( $type eq "int8" ) + { + $data = pack( "c", $data ); + } + elsif ( $type eq "uint8" || $type eq "bool1" ) + { + $data = pack( "C", $data ); + } + elsif ( $type =~ /^int8\[\d+\]$/ ) + { + $data = pack( "Z".$size, $data ); + } + elsif ( $type =~ /^uint8\[\d+\]$/ ) + { + $data = pack( "C".$size, $data ); + } else { Fatal( "Unexpected type '".$type."' found for '".$field."'" ); diff --git a/src/zm_event.cpp b/src/zm_event.cpp index ab619192e..b84458e02 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -1206,7 +1206,7 @@ bool EventStream::sendFrame( int delta_us ) if ( !vid_stream ) { - vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, send_image->Colours(), send_image->Width(), send_image->Height() ); + vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, send_image->Colours(), send_image->SubpixelOrder(), send_image->Width(), send_image->Height() ); fprintf( stdout, "Content-type: %s\r\n\r\n", vid_stream->MimeType() ); vid_stream->OpenStream(); } @@ -1447,4 +1447,4 @@ void EventStream::runStream() #endif // HAVE_LIBAVCODEC closeComms(); -} \ No newline at end of file +} diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 41c91f530..d9c3da060 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -676,17 +676,23 @@ void LocalCamera::Initialise() v4l2_data.fmt.fmt.pix.height = height; v4l2_data.fmt.fmt.pix.pixelformat = palette; - if ( config.v4l2_capture_fields ) - { - v4l2_data.fmt.fmt.pix.field = (v4l2_field)config.v4l2_capture_fields; - if ( vidioctl( vid_fd, VIDIOC_S_FMT, &v4l2_data.fmt ) < 0 ) - { - Warning( "Failed to set V4L2 field to %d, falling back to auto", config.v4l2_capture_fields ); - v4l2_data.fmt.fmt.pix.field = V4L2_FIELD_ANY; - } - } - if ( vidioctl( vid_fd, VIDIOC_S_FMT, &v4l2_data.fmt ) < 0 ) - Fatal( "Failed to set video format: %s", strerror(errno) ); + if ( config.v4l2_capture_fields ) + { + v4l2_data.fmt.fmt.pix.field = (v4l2_field)config.v4l2_capture_fields; + + if ( vidioctl( vid_fd, VIDIOC_S_FMT, &v4l2_data.fmt ) < 0 ) + { + Warning( "Failed to set V4L2 field to %d, falling back to auto", config.v4l2_capture_fields ); + v4l2_data.fmt.fmt.pix.field = V4L2_FIELD_ANY; + if ( vidioctl( vid_fd, VIDIOC_S_FMT, &v4l2_data.fmt ) < 0 ) { + Fatal( "Failed to set video format: %s", strerror(errno) ); + } + } + } else { + if ( vidioctl( vid_fd, VIDIOC_S_FMT, &v4l2_data.fmt ) < 0 ) { + Fatal( "Failed to set video format: %s", strerror(errno) ); + } + } /* Note VIDIOC_S_FMT may change width and height. */ Debug( 4, " v4l2_data.fmt.type = %08x", v4l2_data.fmt.type ); diff --git a/src/zm_mem_utils.h b/src/zm_mem_utils.h index 0f9d9acac..04e313330 100644 --- a/src/zm_mem_utils.h +++ b/src/zm_mem_utils.h @@ -39,12 +39,12 @@ inline void* zm_mallocaligned(unsigned int reqalignment, size_t reqsize) { alloc = retptr + sizeof(void*); - if(((long)alloc % reqalignment) != 0) - alloc = alloc + (reqalignment - ((long)alloc % reqalignment)); - - /* Store a pointer before to the start of the block, just before returned aligned memory */ - *(void**)(alloc - sizeof(void*)) = retptr; - + if(((long)alloc % reqalignment) != 0) + alloc = alloc + (reqalignment - ((long)alloc % reqalignment)); + + /* Store a pointer before to the start of the block, just before returned aligned memory */ + *(void**)(alloc - sizeof(void*)) = retptr; + return alloc; #endif } diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 98cff987d..68566ee95 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -3379,7 +3379,7 @@ bool MonitorStream::sendFrame( Image *image, struct timeval *timestamp ) { if ( !vid_stream ) { - vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, send_image->Colours(), send_image->Width(), send_image->Height() ); + vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, send_image->Colours(), send_image->SubpixelOrder(), send_image->Width(), send_image->Height() ); fprintf( stdout, "Content-type: %s\r\n\r\n", vid_stream->MimeType() ); vid_stream->OpenStream(); } diff --git a/src/zm_mpeg.cpp b/src/zm_mpeg.cpp index ff5ba944d..f5de2a483 100644 --- a/src/zm_mpeg.cpp +++ b/src/zm_mpeg.cpp @@ -21,6 +21,7 @@ #include #include "zm.h" +#include "zm_rgb.h" #include "zm_mpeg.h" #if HAVE_LIBAVCODEC @@ -68,9 +69,45 @@ void VideoStream::SetupFormat( const char *p_filename, const char *p_format ) snprintf( ofc->filename, sizeof(ofc->filename), "%s", filename ); } -void VideoStream::SetupCodec( int colours, int width, int height, int bitrate, double frame_rate ) +void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int height, int bitrate, double frame_rate ) { - pf = (colours==1?PIX_FMT_GRAY8:PIX_FMT_RGB24); + /* ffmpeg format matching */ + switch(colours) { + case ZM_COLOUR_RGB24: + { + if(subpixelorder == ZM_SUBPIX_ORDER_BGR) { + /* BGR subpixel order */ + pf = PIX_FMT_BGR24; + } else { + /* Assume RGB subpixel order */ + pf = PIX_FMT_RGB24; + } + break; + } + case ZM_COLOUR_RGB32: + { + if(subpixelorder == ZM_SUBPIX_ORDER_ARGB) { + /* ARGB subpixel order */ + pf = PIX_FMT_ARGB; + } else if(subpixelorder == ZM_SUBPIX_ORDER_ABGR) { + /* ABGR subpixel order */ + pf = PIX_FMT_ABGR; + } else if(subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + /* BGRA subpixel order */ + pf = PIX_FMT_BGRA; + } else { + /* Assume RGBA subpixel order */ + pf = PIX_FMT_RGBA; + } + break; + } + case ZM_COLOUR_GRAY8: + pf = PIX_FMT_GRAY8; + break; + default: + Panic("Unexpected colours: %d",colours); + break; + } /* add the video streams using the default format codecs and initialize the codecs */ @@ -188,7 +225,7 @@ void VideoStream::OpenStream() Panic( "Could not allocate opicture" ); } int size = avpicture_get_size( c->pix_fmt, c->width, c->height); - uint8_t *opicture_buf = (uint8_t *)malloc(size); + uint8_t *opicture_buf = (uint8_t *)av_malloc(size); if ( !opicture_buf ) { av_free(opicture); @@ -196,7 +233,7 @@ void VideoStream::OpenStream() } avpicture_fill( (AVPicture *)opicture, opicture_buf, c->pix_fmt, c->width, c->height ); - /* if the output format is not RGB24, then a temporary RGB24 + /* if the output format is not identical to the input format, then a temporary picture is needed too. It is then converted to the required output format */ tmp_opicture = NULL; @@ -208,7 +245,7 @@ void VideoStream::OpenStream() Panic( "Could not allocate temporary opicture" ); } int size = avpicture_get_size( pf, c->width, c->height); - uint8_t *tmp_opicture_buf = (uint8_t *)malloc(size); + uint8_t *tmp_opicture_buf = (uint8_t *)av_malloc(size); if (!tmp_opicture_buf) { av_free( tmp_opicture ); @@ -244,7 +281,7 @@ void VideoStream::OpenStream() av_write_header(ofc); } -VideoStream::VideoStream( const char *filename, const char *format, int bitrate, double frame_rate, int colours, int width, int height ) +VideoStream::VideoStream( const char *filename, const char *format, int bitrate, double frame_rate, int colours, int subpixelorder, int width, int height ) { if ( !initialised ) { @@ -252,7 +289,7 @@ VideoStream::VideoStream( const char *filename, const char *format, int bitrate, } SetupFormat( filename, format ); - SetupCodec( colours, width, height, bitrate, frame_rate ); + SetupCodec( colours, subpixelorder, width, height, bitrate, frame_rate ); SetParameters(); } diff --git a/src/zm_mpeg.h b/src/zm_mpeg.h index 4ac88e5ec..c7cb4d26f 100644 --- a/src/zm_mpeg.h +++ b/src/zm_mpeg.h @@ -54,11 +54,11 @@ protected: static void Initialise(); void SetupFormat( const char *p_filename, const char *format ); - void SetupCodec( int colours, int width, int height, int bitrate, double frame_rate ); + void SetupCodec( int colours, int subpixelorder, int width, int height, int bitrate, double frame_rate ); void SetParameters(); public: - VideoStream( const char *filename, const char *format, int bitrate, double frame_rate, int colours, int width, int height ); + VideoStream( const char *filename, const char *format, int bitrate, double frame_rate, int colours, int subpixelorder, int width, int height ); ~VideoStream(); const char *MimeType() const; void OpenStream(); diff --git a/src/zm_stream.cpp b/src/zm_stream.cpp index dc1412b96..41414f495 100644 --- a/src/zm_stream.cpp +++ b/src/zm_stream.cpp @@ -245,7 +245,7 @@ bool StreamBase::sendTextFrame( const char *frame_text ) { if ( !vid_stream ) { - vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, image.Colours(), image.Width(), image.Height() ); + vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, image.Colours(), image.SubpixelOrder(), image.Width(), image.Height() ); fprintf( stdout, "Content-type: %s\r\n\r\n", vid_stream->MimeType() ); vid_stream->OpenStream(); } From bc255d1b06cf15b80ec63a2dc3e7c46cb6458c0a Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Mon, 27 Jun 2011 21:46:55 +0300 Subject: [PATCH 18/56] 1) Replaced the blend and delta algorithms with newer versions that use 1 less register and 1 less instruction per iteration. 2) Fixed small bug in rgb_convert --- src/zm_image.cpp | 338 ++++++++++++++++------------------------------- src/zm_rgb.h | 3 +- 2 files changed, 118 insertions(+), 223 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index c79eaa442..d1112859f 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -2495,7 +2495,6 @@ __attribute__ ((noinline)) void sse2_fastblend(const uint8_t* col1, const uint8_ static uint32_t divider = 0; static uint32_t clearmask = 0; static double current_blendpercent = 0.0; - unsigned long i = 0; if(current_blendpercent != blendpercent) { /* Attempt to match the blending percent to one of the possible values */ @@ -2528,29 +2527,27 @@ __attribute__ ((noinline)) void sse2_fastblend(const uint8_t* col1, const uint8_ } __asm__ __volatile__( - "movd %5, %%xmm3\n\t" - "movd %6, %%xmm4\n\t" + "movd %4, %%xmm3\n\t" + "movd %5, %%xmm4\n\t" "pshufd $0x0, %%xmm3, %%xmm3\n\t" - "algo_sse2_blend:\n\t" - "movdqa (%0,%4),%%xmm0\n\t" - "movdqa (%1,%4),%%xmm1\n\t" - "movdqa %%xmm0,%%xmm2\n\t" + "sub $0x10, %0\n\t" + "sub $0x10, %1\n\t" + "sub $0x10, %2\n\t" + "sse2_fastblend_iter:\n\t" + "movdqa (%0,%3),%%xmm0\n\t" + "movdqa %%xmm0,%%xmm2\n\t" + "movdqa (%1,%3),%%xmm1\n\t" "psrlq %%xmm4,%%xmm0\n\t" "psrlq %%xmm4,%%xmm1\n\t" "pand %%xmm3,%%xmm1\n\t" "pand %%xmm3,%%xmm0\n\t" "psubb %%xmm0,%%xmm1\n\t" "paddb %%xmm2,%%xmm1\n\t" - "movntdq %%xmm1,(%2,%4)\n\t" - "add $0x10,%4\n\t" - "cmp %3, %4\n\t" - "jb algo_sse2_blend\n\t" + "movntdq %%xmm1,(%2,%3)\n\t" + "sub $0x10, %3\n\t" + "jnz sse2_fastblend_iter\n\t" : -#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ - : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (clearmask), "m" (divider) -#else - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (clearmask), "m" (divider) -#endif + : "r" (col1), "r" (col2), "r" (result), "r" (count), "m" (clearmask), "m" (divider) : "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "cc", "memory" ); #else @@ -2837,34 +2834,24 @@ __attribute__ ((noinline)) void std_delta8_abgr(const uint8_t* col1, const uint8 /* Grayscale SSE2 */ __attribute__ ((noinline)) void sse2_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if (defined(__i386__) || defined(__x86_64__)) - unsigned long i = 0; - /* Works on 16 grayscale pixels per iteration, similar to the non-SSE version above */ - /* XMM0 - unused */ - /* XMM1,2,3,4 - General purpose */ - /* XMM5 - unused */ - /* XMM6 - unused */ - /* XMM7 - unused */ - __asm__ __volatile__ ( - "algo_sse2_delta8_gray8:\n\t" - "movdqa (%0,%4), %%xmm1\n\t" - "movdqa (%1,%4), %%xmm2\n\t" + "sub $0x10, %0\n\t" + "sub $0x10, %1\n\t" + "sub $0x10, %2\n\t" + "sse2_delta8_gray8_iter:\n\t" + "movdqa (%0,%3), %%xmm1\n\t" + "movdqa (%1,%3), %%xmm2\n\t" "movdqa %%xmm1, %%xmm3\n\t" "movdqa %%xmm2, %%xmm4\n\t" "pmaxub %%xmm1, %%xmm2\n\t" "pminub %%xmm3, %%xmm4\n\t" - "psubb %%xmm4, %%xmm2\n\t" - "movntdq %%xmm2, (%2,%4)\n\t" - "add $0x10, %4\n\t" - "cmp %3, %4\n\t" - "jb algo_sse2_delta8_gray8\n\t" + "psubb %%xmm4, %%xmm2\n\t" + "movntdq %%xmm2, (%2,%3)\n\t" + "sub $0x10, %3\n\t" + "jnz sse2_delta8_gray8_iter\n\t" : -#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ - : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) -#else - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i) -#endif + : "r" (col1), "r" (col2), "r" (result), "r" (count) : "%xmm1", "%xmm2", "%xmm3", "%xmm4", "cc", "memory" ); #else @@ -2875,14 +2862,6 @@ __attribute__ ((noinline)) void sse2_delta8_gray8(const uint8_t* col1, const uin /* RGB32: RGBA SSE2 */ __attribute__ ((noinline)) void sse2_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if (defined(__i386__) || defined(__x86_64__)) - unsigned long i = 0; - - /* XMM0 - clear mask - kept */ - /* XMM1,2,3 - General purpose */ - /* XMM4 - divide mask - kept */ - /* XMM5 - temp */ - /* XMM6 - temp */ - /* XMM7 - unused */ __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -2894,9 +2873,12 @@ __attribute__ ((noinline)) void sse2_delta8_rgba(const uint8_t* col1, const uint "mov $0x80000000, %%eax\n\t" "movd %%eax, %%xmm5\n\t" "pshufd $0x0, %%xmm5, %%xmm5\n\t" - "algo_sse2_delta8_rgba:\n\t" - "movdqa (%0,%4,4), %%xmm1\n\t" - "movdqa (%1,%4,4), %%xmm2\n\t" + "sub $0x10, %0\n\t" + "sub $0x10, %1\n\t" + "sub $0x4, %2\n\t" + "sse2_delta8_rgba_iter:\n\t" + "movdqa (%0,%3,4), %%xmm1\n\t" + "movdqa (%1,%3,4), %%xmm2\n\t" "psrlq $0x3, %%xmm1\n\t" "psrlq $0x3, %%xmm2\n\t" "pand %%xmm4, %%xmm1\n\t" @@ -2934,16 +2916,11 @@ __attribute__ ((noinline)) void sse2_delta8_rgba(const uint8_t* col1, const uint "psrldq $0x3, %%xmm1\n\t" "por %%xmm1, %%xmm3\n\t" "movd %%xmm3, %%eax\n\t" - "movnti %%eax, (%2,%4)\n\t" - "add $0x4, %4\n\t" - "cmp %3, %4\n\t" - "jb algo_sse2_delta8_rgba\n\t" + "movnti %%eax, (%2,%3)\n\t" + "sub $0x4, %3\n\t" + "jnz sse2_delta8_rgba_iter\n\t" : -#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ - : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) -#else - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i) -#endif + : "r" (col1), "r" (col2), "r" (result), "r" (count) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "cc", "memory" ); #else @@ -2954,14 +2931,6 @@ __attribute__ ((noinline)) void sse2_delta8_rgba(const uint8_t* col1, const uint /* RGB32: BGRA SSE2 */ __attribute__ ((noinline)) void sse2_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if (defined(__i386__) || defined(__x86_64__)) - unsigned long i = 0; - - /* XMM0 - clear mask - kept */ - /* XMM1,2,3 - General purpose */ - /* XMM4 - divide mask - kept */ - /* XMM5 - temp */ - /* XMM6 - temp */ - /* XMM7 - unused */ __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -2973,9 +2942,12 @@ __attribute__ ((noinline)) void sse2_delta8_bgra(const uint8_t* col1, const uint "mov $0x80000000, %%eax\n\t" "movd %%eax, %%xmm5\n\t" "pshufd $0x0, %%xmm5, %%xmm5\n\t" - "algo_sse2_delta8_bgra:\n\t" - "movdqa (%0,%4,4), %%xmm1\n\t" - "movdqa (%1,%4,4), %%xmm2\n\t" + "sub $0x10, %0\n\t" + "sub $0x10, %1\n\t" + "sub $0x4, %2\n\t" + "sse2_delta8_bgra_iter:\n\t" + "movdqa (%0,%3,4), %%xmm1\n\t" + "movdqa (%1,%3,4), %%xmm2\n\t" "psrlq $0x3, %%xmm1\n\t" "psrlq $0x3, %%xmm2\n\t" "pand %%xmm4, %%xmm1\n\t" @@ -3013,16 +2985,11 @@ __attribute__ ((noinline)) void sse2_delta8_bgra(const uint8_t* col1, const uint "psrldq $0x3, %%xmm1\n\t" "por %%xmm1, %%xmm3\n\t" "movd %%xmm3, %%eax\n\t" - "movnti %%eax, (%2,%4)\n\t" - "add $0x4, %4\n\t" - "cmp %3, %4\n\t" - "jb algo_sse2_delta8_bgra\n\t" + "movnti %%eax, (%2,%3)\n\t" + "sub $0x4, %3\n\t" + "jnz sse2_delta8_bgra_iter\n\t" : -#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ - : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) -#else - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i) -#endif + : "r" (col1), "r" (col2), "r" (result), "r" (count) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "cc", "memory" ); #else @@ -3033,14 +3000,6 @@ __attribute__ ((noinline)) void sse2_delta8_bgra(const uint8_t* col1, const uint /* RGB32: ARGB SSE2 */ __attribute__ ((noinline)) void sse2_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if (defined(__i386__) || defined(__x86_64__)) - unsigned long i = 0; - - /* XMM0 - clear mask - kept */ - /* XMM1,2,3 - General purpose */ - /* XMM4 - divide mask - kept */ - /* XMM5 - temp */ - /* XMM6 - temp */ - /* XMM7 - unused */ __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3052,9 +3011,12 @@ __attribute__ ((noinline)) void sse2_delta8_argb(const uint8_t* col1, const uint "mov $0x80000000, %%eax\n\t" "movd %%eax, %%xmm5\n\t" "pshufd $0x0, %%xmm5, %%xmm5\n\t" - "algo_sse2_delta8_argb:\n\t" - "movdqa (%0,%4,4), %%xmm1\n\t" - "movdqa (%1,%4,4), %%xmm2\n\t" + "sub $0x10, %0\n\t" + "sub $0x10, %1\n\t" + "sub $0x4, %2\n\t" + "sse2_delta8_argb_iter:\n\t" + "movdqa (%0,%3,4), %%xmm1\n\t" + "movdqa (%1,%3,4), %%xmm2\n\t" "psrlq $0x3, %%xmm1\n\t" "psrlq $0x3, %%xmm2\n\t" "pand %%xmm4, %%xmm1\n\t" @@ -3093,16 +3055,11 @@ __attribute__ ((noinline)) void sse2_delta8_argb(const uint8_t* col1, const uint "psrldq $0x3, %%xmm1\n\t" "por %%xmm1, %%xmm3\n\t" "movd %%xmm3, %%eax\n\t" - "movnti %%eax, (%2,%4)\n\t" - "add $0x4, %4\n\t" - "cmp %3, %4\n\t" - "jb algo_sse2_delta8_argb\n\t" + "movnti %%eax, (%2,%3)\n\t" + "sub $0x4, %3\n\t" + "jnz sse2_delta8_argb_iter\n\t" : -#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ - : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) -#else - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i) -#endif + : "r" (col1), "r" (col2), "r" (result), "r" (count) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "cc", "memory" ); #else @@ -3113,14 +3070,6 @@ __attribute__ ((noinline)) void sse2_delta8_argb(const uint8_t* col1, const uint /* RGB32: ABGR SSE2 */ __attribute__ ((noinline)) void sse2_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if (defined(__i386__) || defined(__x86_64__)) - unsigned long i = 0; - - /* XMM0 - clear mask - kept */ - /* XMM1,2,3 - General purpose */ - /* XMM4 - divide mask - kept */ - /* XMM5 - temp */ - /* XMM6 - temp */ - /* XMM7 - unused */ __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3132,9 +3081,12 @@ __attribute__ ((noinline)) void sse2_delta8_abgr(const uint8_t* col1, const uint "mov $0x80000000, %%eax\n\t" "movd %%eax, %%xmm5\n\t" "pshufd $0x0, %%xmm5, %%xmm5\n\t" - "algo_sse2_delta8_abgr:\n\t" - "movdqa (%0,%4,4), %%xmm1\n\t" - "movdqa (%1,%4,4), %%xmm2\n\t" + "sub $0x10, %0\n\t" + "sub $0x10, %1\n\t" + "sub $0x4, %2\n\t" + "sse2_delta8_abgr_iter:\n\t" + "movdqa (%0,%3,4), %%xmm1\n\t" + "movdqa (%1,%3,4), %%xmm2\n\t" "psrlq $0x3, %%xmm1\n\t" "psrlq $0x3, %%xmm2\n\t" "pand %%xmm4, %%xmm1\n\t" @@ -3173,16 +3125,11 @@ __attribute__ ((noinline)) void sse2_delta8_abgr(const uint8_t* col1, const uint "psrldq $0x3, %%xmm1\n\t" "por %%xmm1, %%xmm3\n\t" "movd %%xmm3, %%eax\n\t" - "movnti %%eax, (%2,%4)\n\t" - "add $0x4, %4\n\t" - "cmp %3, %4\n\t" - "jb algo_sse2_delta8_abgr\n\t" + "movnti %%eax, (%2,%3)\n\t" + "sub $0x4, %3\n\t" + "jnz sse2_delta8_abgr_iter\n\t" : -#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ - : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i) -#else - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i) -#endif + : "r" (col1), "r" (col2), "r" (result), "r" (count) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "cc", "memory" ); #else @@ -3193,14 +3140,6 @@ __attribute__ ((noinline)) void sse2_delta8_abgr(const uint8_t* col1, const uint /* RGB32: RGBA SSSE3 */ __attribute__ ((noinline)) void ssse3_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if (defined(__i386__) || defined(__x86_64__)) - unsigned long i = 0; - - /* XMM0 - clear mask - kept */ - /* XMM1,2,3 - General purpose */ - /* XMM4 - divide mask - kept */ - /* XMM5 - shuffle mask - kept */ - /* XMM6 - unused */ - /* XMM7 - unused */ __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3209,10 +3148,13 @@ __attribute__ ((noinline)) void ssse3_delta8_rgba(const uint8_t* col1, const uin "mov $0xff, %%eax\n\t" "movd %%eax, %%xmm0\n\t" "pshufd $0x0, %%xmm0, %%xmm0\n\t" - "movdqa %5, %%xmm5\n\t" - "algo_ssse3_delta8_rgba:\n\t" - "movdqa (%0,%4,4), %%xmm1\n\t" - "movdqa (%1,%4,4), %%xmm2\n\t" + "movdqa %4, %%xmm5\n\t" + "sub $0x10, %0\n\t" + "sub $0x10, %1\n\t" + "sub $0x4, %2\n\t" + "ssse3_delta8_rgba_iter:\n\t" + "movdqa (%0,%3,4), %%xmm1\n\t" + "movdqa (%1,%3,4), %%xmm2\n\t" "psrlq $0x3, %%xmm1\n\t" "psrlq $0x3, %%xmm2\n\t" "pand %%xmm4, %%xmm1\n\t" @@ -3235,16 +3177,11 @@ __attribute__ ((noinline)) void ssse3_delta8_rgba(const uint8_t* col1, const uin "paddd %%xmm2, %%xmm1\n\t" "pshufb %%xmm5, %%xmm1\n\t" "movd %%xmm1, %%eax\n\t" - "movnti %%eax, (%2,%4)\n\t" - "add $0x4, %4\n\t" - "cmp %3, %4\n\t" - "jb algo_ssse3_delta8_rgba\n\t" + "movnti %%eax, (%2,%3)\n\t" + "sub $0x4, %3\n\t" + "jnz ssse3_delta8_rgba_iter\n\t" : -#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ - : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (*movemask) -#else - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) -#endif + : "r" (col1), "r" (col2), "r" (result), "r" (count), "m" (*movemask) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -3255,14 +3192,6 @@ __attribute__ ((noinline)) void ssse3_delta8_rgba(const uint8_t* col1, const uin /* RGB32: BGRA SSSE3 */ __attribute__ ((noinline)) void ssse3_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if (defined(__i386__) || defined(__x86_64__)) - unsigned long i = 0; - - /* XMM0 - clear mask - kept */ - /* XMM1,2,3 - General purpose */ - /* XMM4 - divide mask - kept */ - /* XMM5 - shuffle mask - kept */ - /* XMM6 - unused */ - /* XMM7 - unused */ __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3271,10 +3200,13 @@ __attribute__ ((noinline)) void ssse3_delta8_bgra(const uint8_t* col1, const uin "mov $0xff, %%eax\n\t" "movd %%eax, %%xmm0\n\t" "pshufd $0x0, %%xmm0, %%xmm0\n\t" - "movdqa %5, %%xmm5\n\t" - "algo_ssse3_delta8_bgra:\n\t" - "movdqa (%0,%4,4), %%xmm1\n\t" - "movdqa (%1,%4,4), %%xmm2\n\t" + "movdqa %4, %%xmm5\n\t" + "sub $0x10, %0\n\t" + "sub $0x10, %1\n\t" + "sub $0x4, %2\n\t" + "ssse3_delta8_bgra_iter:\n\t" + "movdqa (%0,%3,4), %%xmm1\n\t" + "movdqa (%1,%3,4), %%xmm2\n\t" "psrlq $0x3, %%xmm1\n\t" "psrlq $0x3, %%xmm2\n\t" "pand %%xmm4, %%xmm1\n\t" @@ -3297,16 +3229,11 @@ __attribute__ ((noinline)) void ssse3_delta8_bgra(const uint8_t* col1, const uin "paddd %%xmm2, %%xmm1\n\t" "pshufb %%xmm5, %%xmm1\n\t" "movd %%xmm1, %%eax\n\t" - "movnti %%eax, (%2,%4)\n\t" - "add $0x4, %4\n\t" - "cmp %3, %4\n\t" - "jb algo_ssse3_delta8_bgra\n\t" + "movnti %%eax, (%2,%3)\n\t" + "sub $0x4, %3\n\t" + "jnz ssse3_delta8_bgra_iter\n\t" : -#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ - : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (*movemask) -#else - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) -#endif + : "r" (col1), "r" (col2), "r" (result), "r" (count), "m" (*movemask) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -3317,14 +3244,6 @@ __attribute__ ((noinline)) void ssse3_delta8_bgra(const uint8_t* col1, const uin /* RGB32: ARGB SSSE3 */ __attribute__ ((noinline)) void ssse3_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if (defined(__i386__) || defined(__x86_64__)) - unsigned long i = 0; - - /* XMM0 - clear mask - kept */ - /* XMM1,2,3 - General purpose */ - /* XMM4 - divide mask - kept */ - /* XMM5 - shuffle mask - kept */ - /* XMM6 - unused */ - /* XMM7 - unused */ __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3333,10 +3252,13 @@ __attribute__ ((noinline)) void ssse3_delta8_argb(const uint8_t* col1, const uin "mov $0xff, %%eax\n\t" "movd %%eax, %%xmm0\n\t" "pshufd $0x0, %%xmm0, %%xmm0\n\t" - "movdqa %5, %%xmm5\n\t" - "algo_ssse3_delta8_argb:\n\t" - "movdqa (%0,%4,4), %%xmm1\n\t" - "movdqa (%1,%4,4), %%xmm2\n\t" + "movdqa %4, %%xmm5\n\t" + "sub $0x10, %0\n\t" + "sub $0x10, %1\n\t" + "sub $0x4, %2\n\t" + "ssse3_delta8_argb_iter:\n\t" + "movdqa (%0,%3,4), %%xmm1\n\t" + "movdqa (%1,%3,4), %%xmm2\n\t" "psrlq $0x3, %%xmm1\n\t" "psrlq $0x3, %%xmm2\n\t" "pand %%xmm4, %%xmm1\n\t" @@ -3360,16 +3282,11 @@ __attribute__ ((noinline)) void ssse3_delta8_argb(const uint8_t* col1, const uin "paddd %%xmm2, %%xmm1\n\t" "pshufb %%xmm5, %%xmm1\n\t" "movd %%xmm1, %%eax\n\t" - "movnti %%eax, (%2,%4)\n\t" - "add $0x4, %4\n\t" - "cmp %3, %4\n\t" - "jb algo_ssse3_delta8_argb\n\t" + "movnti %%eax, (%2,%3)\n\t" + "sub $0x4, %3\n\t" + "jnz ssse3_delta8_argb_iter\n\t" : -#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ - : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (*movemask) -#else - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) -#endif + : "r" (col1), "r" (col2), "r" (result), "r" (count), "m" (*movemask) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -3380,14 +3297,6 @@ __attribute__ ((noinline)) void ssse3_delta8_argb(const uint8_t* col1, const uin /* RGB32: ABGR SSSE3 */ __attribute__ ((noinline)) void ssse3_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if (defined(__i386__) || defined(__x86_64__)) - unsigned long i = 0; - - /* XMM0 - clear mask - kept */ - /* XMM1,2,3 - General purpose */ - /* XMM4 - divide mask - kept */ - /* XMM5 - shuffle mask - kept */ - /* XMM6 - unused */ - /* XMM7 - unused */ __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3396,10 +3305,13 @@ __attribute__ ((noinline)) void ssse3_delta8_abgr(const uint8_t* col1, const uin "mov $0xff, %%eax\n\t" "movd %%eax, %%xmm0\n\t" "pshufd $0x0, %%xmm0, %%xmm0\n\t" - "movdqa %5, %%xmm5\n\t" - "algo_ssse3_delta8_abgr:\n\t" - "movdqa (%0,%4,4), %%xmm1\n\t" - "movdqa (%1,%4,4), %%xmm2\n\t" + "movdqa %4, %%xmm5\n\t" + "sub $0x10, %0\n\t" + "sub $0x10, %1\n\t" + "sub $0x4, %2\n\t" + "ssse3_delta8_abgr_iter:\n\t" + "movdqa (%0,%3,4), %%xmm1\n\t" + "movdqa (%1,%3,4), %%xmm2\n\t" "psrlq $0x3, %%xmm1\n\t" "psrlq $0x3, %%xmm2\n\t" "pand %%xmm4, %%xmm1\n\t" @@ -3423,16 +3335,11 @@ __attribute__ ((noinline)) void ssse3_delta8_abgr(const uint8_t* col1, const uin "paddd %%xmm2, %%xmm1\n\t" "pshufb %%xmm5, %%xmm1\n\t" "movd %%xmm1, %%eax\n\t" - "movnti %%eax, (%2,%4)\n\t" - "add $0x4, %4\n\t" - "cmp %3, %4\n\t" - "jb algo_ssse3_delta8_abgr\n\t" + "movnti %%eax, (%2,%3)\n\t" + "sub $0x4, %3\n\t" + "jnz ssse3_delta8_abgr_iter\n\t" : -#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ - : "r" (col1), "r" (col2), "r" (result), "m" (count), "r" (i), "m" (*movemask) -#else - : "r" (col1), "r" (col2), "r" (result), "r" (count), "r" (i), "m" (*movemask) -#endif + : "r" (col1), "r" (col2), "r" (result), "r" (count), "m" (*movemask) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else @@ -3643,14 +3550,6 @@ __attribute__ ((noinline)) void std_convert_yuyv_gray8(const uint8_t* col1, uint /* RGBA to grayscale SSSE3 */ __attribute__ ((noinline)) void ssse3_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { #if (defined(__i386__) || defined(__x86_64__)) - unsigned long i = 0; - - /* XMM0 - clear mask - kept */ - /* XMM1,2,3 - General purpose */ - /* XMM4 - divide mask - kept */ - /* XMM5 - shuffle mask - kept */ - /* XMM6 - unused */ - /* XMM7 - unused */ __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3659,9 +3558,11 @@ __attribute__ ((noinline)) void ssse3_convert_rgba_gray8(const uint8_t* col1, ui "mov $0xff, %%eax\n\t" "movd %%eax, %%xmm0\n\t" "pshufd $0x0, %%xmm0, %%xmm0\n\t" - "movdqa %4, %%xmm5\n\t" - "algo_ssse3_convert_rgba_gray8:\n\t" - "movdqa (%0,%3,4), %%xmm3\n\t" + "movdqa %3, %%xmm5\n\t" + "sub $0x10, %0\n\t" + "sub $0x4, %1\n\t" + "ssse3_convert_rgba_gray8_iter:\n\t" + "movdqa (%0,%2,4), %%xmm3\n\t" "psrlq $0x3, %%xmm3\n\t" "pand %%xmm4, %%xmm3\n\t" "movdqa %%xmm3, %%xmm2\n\t" @@ -3680,16 +3581,11 @@ __attribute__ ((noinline)) void ssse3_convert_rgba_gray8(const uint8_t* col1, ui "paddd %%xmm2, %%xmm1\n\t" "pshufb %%xmm5, %%xmm1\n\t" "movd %%xmm1, %%eax\n\t" - "movnti %%eax, (%1,%3)\n\t" - "add $0x4, %3\n\t" - "cmp %2, %3\n\t" - "jb algo_ssse3_convert_rgba_gray8\n\t" + "movnti %%eax, (%1,%2)\n\t" + "sub $0x4, %2\n\t" + "jnz ssse3_delta8_abgr_iter\n\t" : -#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ - : "r" (col1), "r" (result), "m" (count), "r" (i), "m" (*movemask) -#else - : "r" (col1), "r" (result), "r" (count), "r" (i), "m" (*movemask) -#endif + : "r" (col1), "r" (result), "r" (count), "m" (*movemask) : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "cc", "memory" ); #else diff --git a/src/zm_rgb.h b/src/zm_rgb.h index 5694eff19..bfef10501 100644 --- a/src/zm_rgb.h +++ b/src/zm_rgb.h @@ -144,9 +144,8 @@ inline Rgb rgb_convert(Rgb p_col, int p_subpixorder) { break; /* Grayscale */ case ZM_SUBPIX_ORDER_NONE: - { result = p_col & 0xff; - } + break; default: return p_col; break; From 442b9e5ba2518fcf6c334062b48c821a3297a4d7 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 30 Jun 2011 18:14:45 +0300 Subject: [PATCH 19/56] 1) Reloaded zm_event.cpp to hopefully fix its issues once and for all. 2) Added backup code in case sendfile() fails. 3) Fixed a bug that allowed to link a monitor to itself, which can cause alarm lasting forever once triggered. --- src/zm_event.cpp | 2903 ++++++++++++++++++++++---------------------- src/zm_monitor.cpp | 2 +- 2 files changed, 1455 insertions(+), 1450 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index b84458e02..76e36577c 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -1,1450 +1,1455 @@ -// -// ZoneMinder Event Class Implementation, $Date: 2010-11-11 12:22:35 +0000 (Thu, 11 Nov 2010) $, $Revision: 3189 $ -// Copyright (C) 2001-2008 Philip Coombes -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "zm.h" -#include "zm_db.h" -#include "zm_time.h" -#include "zm_mpeg.h" -#include "zm_signal.h" -#include "zm_event.h" -#include "zm_monitor.h" - -#include "zmf.h" - -#if HAVE_SYS_SENDFILE_H -#include -#endif - -//#define USE_PREPARED_SQL 1 - -bool Event::initialised = false; -char Event::capture_file_format[PATH_MAX]; -char Event::analyse_file_format[PATH_MAX]; -char Event::general_file_format[PATH_MAX]; - -int Event::pre_alarm_count = 0; -Event::PreAlarmData Event::pre_alarm_data[MAX_PRE_ALARM_FRAMES] = { { 0 } }; - -Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string &p_cause, const StringSetMap &p_noteSetMap ) : - monitor( p_monitor ), - start_time( p_start_time ), - cause( p_cause ), - noteSetMap( p_noteSetMap ) -{ - if ( !initialised ) - Initialise(); - - std::string notes; - createNotes( notes ); - - bool untimedEvent = false; - if ( !start_time.tv_sec ) - { - untimedEvent = true; - gettimeofday( &start_time, 0 ); - } - - static char sql[ZM_SQL_MED_BUFSIZ]; - - struct tm *stime = localtime( &start_time.tv_sec ); - snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s' )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str() ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't insert event: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - id = mysql_insert_id( &dbconn ); - if ( untimedEvent ) - { - Warning( "Event %d has zero time, setting to current", id ); - } - end_time.tv_sec = 0; - frames = 0; - alarm_frames = 0; - tot_score = 0; - max_score = 0; - - if ( config.use_deep_storage ) - { - char *path_ptr = path; - path_ptr += snprintf( path_ptr, sizeof(path), "%s/%d", config.dir_events, monitor->Id() ); - - int dt_parts[6]; - dt_parts[0] = stime->tm_year-100; - dt_parts[1] = stime->tm_mon+1; - dt_parts[2] = stime->tm_mday; - dt_parts[3] = stime->tm_hour; - dt_parts[4] = stime->tm_min; - dt_parts[5] = stime->tm_sec; - - char date_path[PATH_MAX] = ""; - char time_path[PATH_MAX] = ""; - char *time_path_ptr = time_path; - for ( int i = 0; i < sizeof(dt_parts)/sizeof(*dt_parts); i++ ) - { - path_ptr += snprintf( path_ptr, sizeof(path)-(path_ptr-path), "/%02d", dt_parts[i] ); - - struct stat statbuf; - errno = 0; - stat( path, &statbuf ); - if ( errno == ENOENT || errno == ENOTDIR ) - { - if ( mkdir( path, 0755 ) ) - { - Fatal( "Can't mkdir %s: %s", path, strerror(errno)); - } - } - if ( i == 2 ) - strncpy( date_path, path, sizeof(date_path) ); - else if ( i >= 3 ) - time_path_ptr += snprintf( time_path_ptr, sizeof(time_path)-(time_path_ptr-time_path), "%s%02d", i>3?"/":"", dt_parts[i] ); - } - char id_file[PATH_MAX]; - // Create event id symlink - snprintf( id_file, sizeof(id_file), "%s/.%d", date_path, id ); - if ( symlink( time_path, id_file ) < 0 ) - Fatal( "Can't symlink %s -> %s: %s", id_file, path, strerror(errno)); - // Create empty id tag file - snprintf( id_file, sizeof(id_file), "%s/.%d", path, id ); - if ( FILE *id_fp = fopen( id_file, "w" ) ) - fclose( id_fp ); - else - Fatal( "Can't fopen %s: %s", id_file, strerror(errno)); - } - else - { - snprintf( path, sizeof(path), "%s/%d/%d", config.dir_events, monitor->Id(), id ); - - struct stat statbuf; - errno = 0; - stat( path, &statbuf ); - if ( errno == ENOENT || errno == ENOTDIR ) - { - if ( mkdir( path, 0755 ) ) - { - Error( "Can't mkdir %s: %s", path, strerror(errno)); - } - } - char id_file[PATH_MAX]; - // Create empty id tag file - snprintf( id_file, sizeof(id_file), "%s/.%d", path, id ); - if ( FILE *id_fp = fopen( id_file, "w" ) ) - fclose( id_fp ); - else - Fatal( "Can't fopen %s: %s", id_file, strerror(errno)); - } - last_db_frame = 0; -} - -Event::~Event() -{ - if ( frames > last_db_frame ) - { - struct DeltaTimeval delta_time; - DELTA_TIMEVAL( delta_time, end_time, start_time, DT_PREC_2 ); - - Debug( 1, "Adding closing frame %d to DB", frames ); - static char sql[ZM_SQL_SML_BUFSIZ]; - snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ( %d, %d, from_unixtime( %ld ), %s%ld.%02ld )", id, frames, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't insert frame: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - } - - static char sql[ZM_SQL_MED_BUFSIZ]; - - struct DeltaTimeval delta_time; - DELTA_TIMEVAL( delta_time, end_time, start_time, DT_PREC_2 ); - - snprintf( sql, sizeof(sql), "update Events set Name='%s%d', EndTime = from_unixtime( %ld ), Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", monitor->EventPrefix(), id, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't update event: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } -} - -void Event::createNotes( std::string ¬es ) -{ - notes.clear(); - for ( StringSetMap::const_iterator mapIter = noteSetMap.begin(); mapIter != noteSetMap.end(); mapIter++ ) - { - notes += mapIter->first; - notes += ": "; - const StringSet &stringSet = mapIter->second; - for ( StringSet::const_iterator setIter = stringSet.begin(); setIter != stringSet.end(); setIter++ ) - { - if ( setIter != stringSet.begin() ) - notes += ", "; - notes += *setIter; - } - } -} - -int Event::sd = -1; - -bool Event::OpenFrameSocket( int monitor_id ) -{ - if ( sd > 0 ) - { - close( sd ); - } - - sd = socket( AF_UNIX, SOCK_STREAM, 0); - if ( sd < 0 ) - { - Error( "Can't create socket: %s", strerror(errno) ); - return( false ); - } - - int socket_buffer_size = config.frame_socket_size; - if ( socket_buffer_size > 0 ) - { - if ( setsockopt( sd, SOL_SOCKET, SO_SNDBUF, &socket_buffer_size, sizeof(socket_buffer_size) ) < 0 ) - { - Error( "Can't get socket buffer size to %d, error = %s", socket_buffer_size, strerror(errno) ); - close( sd ); - sd = -1; - return( false ); - } - } - - int flags; - if ( (flags = fcntl( sd, F_GETFL )) < 0 ) - { - Error( "Can't get socket flags, error = %s", strerror(errno) ); - close( sd ); - sd = -1; - return( false ); - } - flags |= O_NONBLOCK; - if ( fcntl( sd, F_SETFL, flags ) < 0 ) - { - Error( "Can't set socket flags, error = %s", strerror(errno) ); - close( sd ); - sd = -1; - return( false ); - } - - char sock_path[PATH_MAX] = ""; - snprintf( sock_path, sizeof(sock_path), "%s/zmf-%d.sock", config.path_socks, monitor_id ); - - struct sockaddr_un addr; - - strncpy( addr.sun_path, sock_path, sizeof(addr.sun_path) ); - addr.sun_family = AF_UNIX; - - if ( connect( sd, (struct sockaddr *)&addr, strlen(addr.sun_path)+sizeof(addr.sun_family)) < 0 ) - { - Warning( "Can't connect to frame server: %s", strerror(errno) ); - close( sd ); - sd = -1; - return( false ); - } - - Debug( 1, "Opened connection to frame server" ); - return( true ); -} - -bool Event::ValidateFrameSocket( int monitor_id ) -{ - if ( sd < 0 ) - { - return( OpenFrameSocket( monitor_id ) ); - } - return( true ); -} - -bool Event::SendFrameImage( const Image *image, bool alarm_frame ) -{ - if ( !ValidateFrameSocket( monitor->Id() ) ) - { - return( false ); - } - - static int jpg_buffer_size = 0; - static unsigned char jpg_buffer[ZM_MAX_IMAGE_SIZE]; - - image->EncodeJpeg( jpg_buffer, &jpg_buffer_size, (alarm_frame&&(config.jpeg_alarm_file_quality>config.jpeg_file_quality))?config.jpeg_alarm_file_quality:config.jpeg_file_quality ); - - static FrameHeader frame_header; - - frame_header.event_id = id; - if ( config.use_deep_storage ) - frame_header.event_time = start_time.tv_sec; - frame_header.frame_id = frames; - frame_header.alarm_frame = alarm_frame; - frame_header.image_length = jpg_buffer_size; - - struct iovec iovecs[2]; - iovecs[0].iov_base = &frame_header; - iovecs[0].iov_len = sizeof(frame_header); - iovecs[1].iov_base = jpg_buffer; - iovecs[1].iov_len = jpg_buffer_size; - - ssize_t writev_size = sizeof(frame_header)+jpg_buffer_size; - ssize_t writev_result = writev( sd, iovecs, sizeof(iovecs)/sizeof(*iovecs)); - if ( writev_result != writev_size ) - { - if ( writev_result < 0 ) - { - if ( errno == EAGAIN ) - { - Warning( "Blocking write detected" ); - } - else - { - Error( "Can't write frame: %s", strerror(errno) ); - close( sd ); - sd = -1; - } - } - else - { - Error( "Incomplete frame write: %zd of %zd bytes written", writev_result, writev_size ); - close( sd ); - sd = -1; - } - return( false ); - } - Debug( 1, "Wrote frame image, %d bytes", jpg_buffer_size ); - - return( true ); -} - -bool Event::WriteFrameImage( Image *image, struct timeval timestamp, const char *event_file, bool alarm_frame ) -{ - if ( config.timestamp_on_capture ) - { - if ( !config.opt_frame_server || !SendFrameImage( image, alarm_frame) ) - { - if ( alarm_frame && (config.jpeg_alarm_file_quality > config.jpeg_file_quality) ) - image->WriteJpeg( event_file, config.jpeg_alarm_file_quality ); - else - image->WriteJpeg( event_file ); - } - } - else - { - Image ts_image( *image ); - monitor->TimestampImage( &ts_image, ×tamp ); - if ( !config.opt_frame_server || !SendFrameImage( &ts_image, alarm_frame) ) - { - if ( alarm_frame && (config.jpeg_alarm_file_quality > config.jpeg_file_quality) ) - ts_image.WriteJpeg( event_file, config.jpeg_alarm_file_quality ); - else - ts_image.WriteJpeg( event_file ); - } - } - return( true ); -} - -void Event::updateNotes( const StringSetMap &newNoteSetMap ) -{ - bool update = false; - - //Info( "Checking notes, %d <> %d", noteSetMap.size(), newNoteSetMap.size() ); - if ( newNoteSetMap.size() > 0 ) - { - if ( noteSetMap.size() == 0 ) - { - noteSetMap = newNoteSetMap; - update = true; - } - else - { - for ( StringSetMap::const_iterator newNoteSetMapIter = newNoteSetMap.begin(); newNoteSetMapIter != newNoteSetMap.end(); newNoteSetMapIter++ ) - { - const std::string &newNoteGroup = newNoteSetMapIter->first; - const StringSet &newNoteSet = newNoteSetMapIter->second; - //Info( "Got %d new strings", newNoteSet.size() ); - if ( newNoteSet.size() > 0 ) - { - StringSetMap::iterator noteSetMapIter = noteSetMap.find( newNoteGroup ); - if ( noteSetMapIter == noteSetMap.end() ) - { - //Info( "Can't find note group %s, copying %d strings", newNoteGroup.c_str(), newNoteSet.size() ); - noteSetMap.insert( StringSetMap::value_type( newNoteGroup, newNoteSet ) ); - update = true; - } - else - { - StringSet ¬eSet = noteSetMapIter->second; - //Info( "Found note group %s, got %d strings", newNoteGroup.c_str(), newNoteSet.size() ); - for ( StringSet::const_iterator newNoteSetIter = newNoteSet.begin(); newNoteSetIter != newNoteSet.end(); newNoteSetIter++ ) - { - const std::string &newNote = *newNoteSetIter; - StringSet::iterator noteSetIter = noteSet.find( newNote ); - if ( noteSetIter == noteSet.end() ) - { - noteSet.insert( newNote ); - update = true; - } - } - } - } - } - } - } - - if ( update ) - { - std::string notes; - createNotes( notes ); - - Debug( 2, "Updating notes for event %d, '%s'", id, notes.c_str() ); - static char sql[ZM_SQL_MED_BUFSIZ]; -#if USE_PREPARED_SQL - static MYSQL_STMT *stmt = 0; - - char notesStr[ZM_SQL_MED_BUFSIZ] = ""; - unsigned long notesLen = 0; - - if ( !stmt ) - { - const char *sql = "update Events set Notes = ? where Id = ?"; - - stmt = mysql_stmt_init( &dbconn ); - if ( mysql_stmt_prepare( stmt, sql, strlen(sql) ) ) - { - Fatal( "Unable to prepare sql '%s': %s", sql, mysql_stmt_error(stmt) ); - } - - /* Get the parameter count from the statement */ - if ( mysql_stmt_param_count( stmt ) != 2 ) - { - Fatal( "Unexpected parameter count %ld in sql '%s'", mysql_stmt_param_count( stmt ), sql ); - } - - MYSQL_BIND bind[2]; - memset(bind, 0, sizeof(bind)); - - /* STRING PARAM */ - bind[0].buffer_type = MYSQL_TYPE_STRING; - bind[0].buffer = (char *)notesStr; - bind[0].buffer_length = sizeof(notesStr); - bind[0].is_null = 0; - bind[0].length = ¬esLen; - - bind[1].buffer_type= MYSQL_TYPE_LONG; - bind[1].buffer= (char *)&id; - bind[1].is_null= 0; - bind[1].length= 0; - - /* Bind the buffers */ - if ( mysql_stmt_bind_param( stmt, bind ) ) - { - Fatal( "Unable to bind sql '%s': %s", sql, mysql_stmt_error(stmt) ); - } - } - - strncpy( notesStr, notes.c_str(), sizeof(notesStr) ); - notesLen = notes.length(); - - if ( mysql_stmt_execute( stmt ) ) - { - Fatal( "Unable to execute sql '%s': %s", sql, mysql_stmt_error(stmt) ); - } -#else - static char escapedNotes[ZM_SQL_MED_BUFSIZ]; - - mysql_real_escape_string( &dbconn, escapedNotes, notes.c_str(), notes.length() ); - - snprintf( sql, sizeof(sql), "update Events set Notes = '%s' where Id = %d", escapedNotes, id ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't insert event: %s", mysql_error( &dbconn ) ); - } -#endif - } -} - -void Event::AddFrames( int n_frames, Image **images, struct timeval **timestamps ) -{ - static char sql[ZM_SQL_LGE_BUFSIZ]; - strncpy( sql, "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ", sizeof(sql) ); - int frameCount = 0; - for ( int i = 0; i < n_frames; i++ ) - { - if ( !timestamps[i]->tv_sec ) - { - Debug( 1, "Not adding pre-capture frame %d, zero timestamp", i ); - continue; - } - - frames++; - - static char event_file[PATH_MAX]; - snprintf( event_file, sizeof(event_file), capture_file_format, path, frames ); - - Debug( 1, "Writing pre-capture frame %d", frames ); - WriteFrameImage( images[i], *(timestamps[i]), event_file ); - - struct DeltaTimeval delta_time; - DELTA_TIMEVAL( delta_time, *(timestamps[i]), start_time, DT_PREC_2 ); - - int sql_len = strlen(sql); - snprintf( sql+sql_len, sizeof(sql)-sql_len, "( %d, %d, from_unixtime(%ld), %s%ld.%02ld ), ", id, frames, timestamps[i]->tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec ); - - frameCount++; - } - - if ( frameCount ) - { - Debug( 1, "Adding %d/%d frames to DB", frameCount, n_frames ); - *(sql+strlen(sql)-2) = '\0'; - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't insert frames: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - last_db_frame = frames; - } - else - { - Debug( 1, "No valid pre-capture frames to add" ); - } -} - -void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *alarm_image ) -{ - if ( !timestamp.tv_sec ) - { - Debug( 1, "Not adding new frame, zero timestamp" ); - return; - } - - frames++; - - static char event_file[PATH_MAX]; - snprintf( event_file, sizeof(event_file), capture_file_format, path, frames ); - - Debug( 1, "Writing capture frame %d", frames ); - WriteFrameImage( image, timestamp, event_file ); - - struct DeltaTimeval delta_time; - DELTA_TIMEVAL( delta_time, timestamp, start_time, DT_PREC_2 ); - - bool db_frame = (score>=0) || ((frames%config.bulk_frame_interval)==0) || !frames; - - if ( db_frame ) - { - const char *frame_type = score>0?"Alarm":(score<0?"Bulk":"Normal"); - - Debug( 1, "Adding frame %d to DB", frames ); - static char sql[ZM_SQL_MED_BUFSIZ]; - snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %d, %d, '%s', from_unixtime( %ld ), %s%ld.%02ld, %d )", id, frames, frame_type, timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't insert frame: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - last_db_frame = frames; - - // We are writing a bulk frame - if ( score < 0 ) - { - snprintf( sql, sizeof(sql), "update Events set Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't update event: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - } - } - - end_time = timestamp; - - if ( score > 0 ) - { - alarm_frames++; - - tot_score += score; - if ( score > max_score ) - max_score = score; - - if ( alarm_image ) - { - snprintf( event_file, sizeof(event_file), analyse_file_format, path, frames ); - - Debug( 1, "Writing analysis frame %d", frames ); - WriteFrameImage( alarm_image, timestamp, event_file, true ); - } - } - - if ( config.record_diag_images ) - { - char diag_glob[PATH_MAX] = ""; - - snprintf( diag_glob, sizeof(diag_glob), "%s/%d/diag-*.jpg", config.dir_events, monitor->Id() ); - glob_t pglob; - int glob_status = glob( diag_glob, 0, 0, &pglob ); - if ( glob_status != 0 ) - { - if ( glob_status < 0 ) - { - Error( "Can't glob '%s': %s", diag_glob, strerror(errno) ); - } - else - { - Debug( 1, "Can't glob '%s': %d", diag_glob, glob_status ); - } - } - else - { - char new_diag_path[PATH_MAX] = ""; - for ( int i = 0; i < pglob.gl_pathc; i++ ) - { - char *diag_path = pglob.gl_pathv[i]; - - char *diag_file = strstr( diag_path, "diag-" ); - - if ( diag_file ) - { - snprintf( new_diag_path, sizeof(new_diag_path), general_file_format, path, frames, diag_file ); - - if ( rename( diag_path, new_diag_path ) < 0 ) - { - Error( "Can't rename '%s' to '%s': %s", diag_path, new_diag_path, strerror(errno) ); - } - } - } - } - globfree( &pglob ); - } -} - -bool EventStream::loadInitialEventData( int monitor_id, time_t event_time ) -{ - static char sql[ZM_SQL_SML_BUFSIZ]; - - snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %d and unix_timestamp( EndTime ) > %ld order by Id asc limit 1", monitor_id, event_time ); - - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - MYSQL_ROW dbrow = mysql_fetch_row( result ); - - if ( mysql_errno( &dbconn ) ) - { - Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - int init_event_id = atoi( dbrow[0] ); - - mysql_free_result( result ); - - loadEventData( init_event_id ); - - if ( event_time ) - { - curr_stream_time = event_time; - curr_frame_id = 1; - if ( event_time >= event_data->start_time ) - { - for ( int i = 0; i < event_data->frame_count; i++ ) - { - //Info( "eft %d > et %d", event_data->frames[i].timestamp, event_time ); - if ( event_data->frames[i].timestamp >= event_time ) - { - curr_frame_id = i+1; - Debug( 3, "Set cst:%.2f", curr_stream_time ); - Debug( 3, "Set cfid:%d", curr_frame_id ); - break; - } - } - Debug( 3, "Skipping %ld frames", event_data->frame_count ); - } - } - return( true ); -} - -bool EventStream::loadInitialEventData( int init_event_id, int init_frame_id ) -{ - loadEventData( init_event_id ); - - if ( init_frame_id ) - { - curr_stream_time = event_data->frames[init_frame_id-1].timestamp; - curr_frame_id = init_frame_id; - } - else - { - curr_stream_time = event_data->start_time; - } - - return( true ); -} - -bool EventStream::loadEventData( int event_id ) -{ - static char sql[ZM_SQL_MED_BUFSIZ]; - - snprintf( sql, sizeof(sql), "select M.Id, M.Name, E.Frames, unix_timestamp( StartTime ) as StartTimestamp, max(F.Delta)-min(F.Delta) as Duration from Events as E inner join Monitors as M on E.MonitorId = M.Id inner join Frames as F on E.Id = F.EventId where E.Id = %d group by E.Id", event_id ); - - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - if ( !mysql_num_rows( result ) ) - { - Fatal( "Unable to load event %d, not found in DB", event_id ); - } - - MYSQL_ROW dbrow = mysql_fetch_row( result ); - - if ( mysql_errno( &dbconn ) ) - { - Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - delete event_data; - event_data = new EventData; - event_data->event_id = event_id; - event_data->monitor_id = atoi( dbrow[0] ); - event_data->start_time = atoi(dbrow[3]); - if ( config.use_deep_storage ) - { - struct tm *event_time = localtime( &event_data->start_time ); - if ( config.dir_events[0] == '/' ) - snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", config.dir_events, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec ); - else - snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", staticConfig.PATH_WEB.c_str(), config.dir_events, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec ); - } - else - { - if ( config.dir_events[0] == '/' ) - snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%ld", config.dir_events, event_data->monitor_id, event_data->event_id ); - else - snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%ld", staticConfig.PATH_WEB.c_str(), config.dir_events, event_data->monitor_id, event_data->event_id ); - } - event_data->frame_count = atoi(dbrow[2]); - event_data->duration = atof(dbrow[4]); - - updateFrameRate( (double)event_data->frame_count/event_data->duration ); - - mysql_free_result( result ); - - snprintf( sql, sizeof(sql), "select FrameId, unix_timestamp( `TimeStamp` ), Delta from Frames where EventId = %d order by FrameId asc", event_id ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - event_data->n_frames = mysql_num_rows( result ); - - event_data->frames = new FrameData[event_data->frame_count]; - int id, last_id = 0; - time_t timestamp, last_timestamp = event_data->start_time; - double delta, last_delta = 0.0; - while ( ( dbrow = mysql_fetch_row( result ) ) ) - { - id = atoi(dbrow[0]); - timestamp = atoi(dbrow[1]); - delta = atof(dbrow[2]); - int id_diff = id - last_id; - double frame_delta = (delta-last_delta)/id_diff; - if ( id_diff > 1 ) - { - for ( int i = last_id+1; i < id; i++ ) - { - event_data->frames[i-1].timestamp = (time_t)(last_timestamp + ((i-last_id)*frame_delta)); - event_data->frames[i-1].offset = (time_t)(event_data->frames[i-1].timestamp-event_data->start_time); - event_data->frames[i-1].delta = frame_delta; - event_data->frames[i-1].in_db = false; - } - } - event_data->frames[id-1].timestamp = timestamp; - event_data->frames[id-1].offset = (time_t)(event_data->frames[id-1].timestamp-event_data->start_time); - event_data->frames[id-1].delta = id>1?frame_delta:0.0; - event_data->frames[id-1].in_db = true; - last_id = id; - last_delta = delta; - last_timestamp = timestamp; - } - if ( mysql_errno( &dbconn ) ) - { - Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - //for ( int i = 0; i < 250; i++ ) - //{ - //Info( "%d -> %d @ %f (%d)", i+1, event_data->frames[i].timestamp, event_data->frames[i].delta, event_data->frames[i].in_db ); - //} - - mysql_free_result( result ); - - if ( forceEventChange || mode == MODE_ALL_GAPLESS ) - { - if ( replay_rate > 0 ) - curr_stream_time = event_data->frames[0].timestamp; - else - curr_stream_time = event_data->frames[event_data->frame_count-1].timestamp; - } - Debug( 2, "Event:%ld, Frames:%ld, Duration: %.2f", event_data->event_id, event_data->frame_count, event_data->duration ); - - return( true ); -} - -void EventStream::processCommand( const CmdMsg *msg ) -{ - Debug( 2, "Got message, type %d, msg %d", msg->msg_type, msg->msg_data[0] ) - // Check for incoming command - switch( (MsgCommand)msg->msg_data[0] ) - { - case CMD_PAUSE : - { - Debug( 1, "Got PAUSE command" ); - - // Set paused flag - paused = true; - replay_rate = ZM_RATE_BASE; - last_frame_sent = TV_2_FLOAT( now ); - break; - } - case CMD_PLAY : - { - Debug( 1, "Got PLAY command" ); - if ( paused ) - { - // Clear paused flag - paused = false; - } - replay_rate = ZM_RATE_BASE; - break; - } - case CMD_VARPLAY : - { - Debug( 1, "Got VARPLAY command" ); - if ( paused ) - { - // Clear paused flag - paused = false; - } - replay_rate = ntohs(((unsigned char)msg->msg_data[2]<<8)|(unsigned char)msg->msg_data[1])-32768; - break; - } - case CMD_STOP : - { - Debug( 1, "Got STOP command" ); - - // Clear paused flag - paused = false; - break; - } - case CMD_FASTFWD : - { - Debug( 1, "Got FAST FWD command" ); - if ( paused ) - { - // Clear paused flag - paused = false; - } - // Set play rate - switch ( replay_rate ) - { - case 2 * ZM_RATE_BASE : - replay_rate = 5 * ZM_RATE_BASE; - break; - case 5 * ZM_RATE_BASE : - replay_rate = 10 * ZM_RATE_BASE; - break; - case 10 * ZM_RATE_BASE : - replay_rate = 25 * ZM_RATE_BASE; - break; - case 25 * ZM_RATE_BASE : - case 50 * ZM_RATE_BASE : - replay_rate = 50 * ZM_RATE_BASE; - break; - default : - replay_rate = 2 * ZM_RATE_BASE; - break; - } - break; - } - case CMD_SLOWFWD : - { - Debug( 1, "Got SLOW FWD command" ); - // Set paused flag - paused = true; - // Set play rate - replay_rate = ZM_RATE_BASE; - // Set step - step = 1; - break; - } - case CMD_SLOWREV : - { - Debug( 1, "Got SLOW REV command" ); - // Set paused flag - paused = true; - // Set play rate - replay_rate = ZM_RATE_BASE; - // Set step - step = -1; - break; - } - case CMD_FASTREV : - { - Debug( 1, "Got FAST REV command" ); - if ( paused ) - { - // Clear paused flag - paused = false; - } - // Set play rate - switch ( replay_rate ) - { - case -2 * ZM_RATE_BASE : - replay_rate = -5 * ZM_RATE_BASE; - break; - case -5 * ZM_RATE_BASE : - replay_rate = -10 * ZM_RATE_BASE; - break; - case -10 * ZM_RATE_BASE : - replay_rate = -25 * ZM_RATE_BASE; - break; - case -25 * ZM_RATE_BASE : - case -50 * ZM_RATE_BASE : - replay_rate = -50 * ZM_RATE_BASE; - break; - default : - replay_rate = -2 * ZM_RATE_BASE; - break; - } - break; - } - case CMD_ZOOMIN : - { - x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2]; - y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4]; - Debug( 1, "Got ZOOM IN command, to %d,%d", x, y ); - switch ( zoom ) - { - case 100: - zoom = 150; - break; - case 150: - zoom = 200; - break; - case 200: - zoom = 300; - break; - case 300: - zoom = 400; - break; - case 400: - default : - zoom = 500; - break; - } - break; - } - case CMD_ZOOMOUT : - { - Debug( 1, "Got ZOOM OUT command" ); - switch ( zoom ) - { - case 500: - zoom = 400; - break; - case 400: - zoom = 300; - break; - case 300: - zoom = 200; - break; - case 200: - zoom = 150; - break; - case 150: - default : - zoom = 100; - break; - } - break; - } - case CMD_PAN : - { - x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2]; - y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4]; - Debug( 1, "Got PAN command, to %d,%d", x, y ); - break; - } - case CMD_SCALE : - { - scale = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2]; - Debug( 1, "Got SCALE command, to %d", scale ); - break; - } - case CMD_PREV : - { - Debug( 1, "Got PREV command" ); - if ( replay_rate >= 0 ) - curr_frame_id = 0; - else - curr_frame_id = event_data->frame_count-1; - paused = false; - forceEventChange = true; - break; - } - case CMD_NEXT : - { - Debug( 1, "Got NEXT command" ); - if ( replay_rate >= 0 ) - curr_frame_id = event_data->frame_count-1; - else - curr_frame_id = 0; - paused = false; - forceEventChange = true; - break; - } - case CMD_SEEK : - { - int offset = ((unsigned char)msg->msg_data[1]<<24)|((unsigned char)msg->msg_data[2]<<16)|((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4]; - curr_frame_id = (int)(event_data->frame_count*offset/event_data->duration); - Debug( 1, "Got SEEK command, to %d (new cfid: %d)", offset, curr_frame_id ); - break; - } - case CMD_QUERY : - { - Debug( 1, "Got QUERY command, sending STATUS" ); - break; - } - default : - { - // Do nothing, for now - } - } - struct { - int event; - int progress; - int rate; - int zoom; - bool paused; - } status_data; - - status_data.event = event_data->event_id; - status_data.progress = (int)event_data->frames[curr_frame_id-1].offset; - status_data.rate = replay_rate; - status_data.zoom = zoom; - status_data.paused = paused; - Debug( 2, "E:%d, P:%d, p:%d R:%d, Z:%d", - status_data.event, - status_data.paused, - status_data.progress, - status_data.rate, - status_data.zoom - ); - - DataMsg status_msg; - status_msg.msg_type = MSG_DATA_EVENT; - memcpy( &status_msg.msg_data, &status_data, sizeof(status_msg.msg_data) ); - if ( sendto( sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr) ) < 0 ) - { - //if ( errno != EAGAIN ) - { - Error( "Can't sendto on sd %d: %s", sd, strerror(errno) ); - exit( -1 ); - } - } - - updateFrameRate( (double)event_data->frame_count/event_data->duration ); -} - -void EventStream::checkEventLoaded() -{ - bool reload_event = false; - static char sql[ZM_SQL_SML_BUFSIZ]; - - if ( curr_frame_id <= 0 ) - { - snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %ld and Id < %ld order by Id desc limit 1", event_data->monitor_id, event_data->event_id ); - reload_event = true; - } - else if ( curr_frame_id > event_data->frame_count ) - { - snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %ld and Id > %ld order by Id asc limit 1", event_data->monitor_id, event_data->event_id ); - reload_event = true; - } - - if ( reload_event ) - { - if ( forceEventChange || mode != MODE_SINGLE ) - { - //Info( "SQL:%s", sql ); - if ( mysql_query( &dbconn, sql ) ) - { - Error( "Can't run query: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - MYSQL_RES *result = mysql_store_result( &dbconn ); - if ( !result ) - { - Error( "Can't use query result: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - MYSQL_ROW dbrow = mysql_fetch_row( result ); - - if ( mysql_errno( &dbconn ) ) - { - Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); - exit( mysql_errno( &dbconn ) ); - } - - if ( dbrow ) - { - int event_id = atoi(dbrow[0]); - Debug( 1, "Loading new event %d", event_id ); - - loadEventData( event_id ); - - Debug( 2, "Current frame id = %d", curr_frame_id ); - if ( curr_frame_id <= 0 ) - curr_frame_id = event_data->frame_count; - else - curr_frame_id = 1; - Debug( 2, "New frame id = %d", curr_frame_id ); - } - else - { - if ( curr_frame_id <= 0 ) - curr_frame_id = 1; - else - curr_frame_id = event_data->frame_count; - paused = true; - } - mysql_free_result( result ); - forceEventChange = false; - } - else - { - if ( curr_frame_id <= 0 ) - curr_frame_id = 1; - else - curr_frame_id = event_data->frame_count; - paused = true; - } - } -} - -bool EventStream::sendFrame( int delta_us ) -{ - Debug( 2, "Sending frame %d", curr_frame_id ); - - static char filepath[PATH_MAX]; - static struct stat filestat; - FILE *fdj = NULL; - - snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id ); - -#if HAVE_LIBAVCODEC - if ( type == STREAM_MPEG ) - { - Image image( filepath ); - - Image *send_image = prepareImage( &image ); - - if ( !vid_stream ) - { - vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, send_image->Colours(), send_image->SubpixelOrder(), send_image->Width(), send_image->Height() ); - fprintf( stdout, "Content-type: %s\r\n\r\n", vid_stream->MimeType() ); - vid_stream->OpenStream(); - } - /* double pts = */ vid_stream->EncodeFrame( send_image->Buffer(), send_image->Size(), config.mpeg_timed_frames, delta_us*1000 ); - } - else -#endif // HAVE_LIBAVCODEC - { - static unsigned char temp_img_buffer[ZM_MAX_IMAGE_SIZE]; - - int img_buffer_size = 0; - uint8_t *img_buffer = temp_img_buffer; - - bool send_raw = ((scale>=ZM_SCALE_BASE)&&(zoom==ZM_SCALE_BASE)); - - fprintf( stdout, "--ZoneMinderFrame\r\n" ); - - if ( type != STREAM_JPEG ) - send_raw = false; - - if ( send_raw ) - { - fdj = fopen( filepath, "rb" ); - if ( !fdj ) - { - Error( "Can't open %s: %s", filepath, strerror(errno) ); - return( false ); - } -#if HAVE_SENDFILE - if( fstat(fileno(fdj),&filestat) < 0 ) { - Error( "Failed getting information about file %s: %s", filepath, strerror(errno) ); - return( false ); - } -#else - img_buffer_size = fread( img_buffer, 1, sizeof(temp_img_buffer), fdj ); -#endif - } - else - { - Image image( filepath ); - - Image *send_image = prepareImage( &image ); - - switch( type ) - { - case STREAM_JPEG : - send_image->EncodeJpeg( img_buffer, &img_buffer_size ); - break; - case STREAM_RAW : - img_buffer = (uint8_t*)(send_image->Buffer()); - img_buffer_size = send_image->Size(); - break; - case STREAM_ZIP : - unsigned long zip_buffer_size; - send_image->Zip( img_buffer, &zip_buffer_size ); - img_buffer_size = zip_buffer_size; - break; - default: - Fatal( "Unexpected frame type %d", type ); - break; - } - } - - switch( type ) - { - case STREAM_JPEG : - fprintf( stdout, "Content-Type: image/jpeg\r\n" ); - break; - case STREAM_RAW : - fprintf( stdout, "Content-Type: image/x-rgb\r\n" ); - break; - case STREAM_ZIP : - fprintf( stdout, "Content-Type: image/x-rgbz\r\n" ); - break; - default : - Fatal( "Unexpected frame type %d", type ); - break; - } - - - if(send_raw) { -#if HAVE_SENDFILE - fprintf( stdout, "Content-Length: %d\r\n\r\n", (int)filestat.st_size ); - if(sendfile(fileno(stdout), fileno(fdj), 0, (int)filestat.st_size) != (int)filestat.st_size) { - Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno)); - return( false ); - } -#else - if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) { - Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno)); - return( false ); - } -#endif - fclose(fdj); /* Close the file handle */ - } else { - fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size ); - if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) - { - Error( "Unable to send stream frame: %s", strerror(errno) ); - return( false ); - } - } - - fprintf( stdout, "\r\n\r\n" ); - fflush( stdout ); - } - last_frame_sent = TV_2_FLOAT( now ); - return( true ); -} - -void EventStream::runStream() -{ - Event::Initialise(); - - openComms(); - - checkInitialised(); - - updateFrameRate( (double)event_data->frame_count/event_data->duration ); - - if ( type == STREAM_JPEG ) - fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" ); - - if ( !event_data ) - { - sendTextFrame( "No event data found" ); - exit( 0 ); - } - - unsigned int delta_us = 0; - while( !zm_terminate ) - { - gettimeofday( &now, NULL ); - - checkCommandQueue(); - - if ( step != 0 ) - curr_frame_id += step; - - checkEventLoaded(); - - // Get current frame data - FrameData *frame_data = &event_data->frames[curr_frame_id-1]; - - //Info( "cst:%.2f", curr_stream_time ); - //Info( "cfid:%d", curr_frame_id ); - //Info( "fdt:%d", frame_data->timestamp ); - if ( !paused ) - { - bool in_event = true; - double time_to_event = 0; - if ( replay_rate > 0 ) - { - time_to_event = event_data->frames[0].timestamp - curr_stream_time; - if ( time_to_event > 0 ) - in_event = false; - } - else if ( replay_rate < 0 ) - { - time_to_event = curr_stream_time - event_data->frames[event_data->frame_count-1].timestamp; - if ( time_to_event > 0 ) - in_event = false; - } - if ( !in_event ) - { - double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent; - if ( actual_delta_time > 1 ) - { - static char frame_text[64]; - snprintf( frame_text, sizeof(frame_text), "Time to next event = %d seconds", (int)time_to_event ); - if ( !sendTextFrame( frame_text ) ) - zm_terminate = true; - } - //else - //{ - usleep( STREAM_PAUSE_WAIT ); - //curr_stream_time += (replay_rate>0?1:-1) * ((1.0L * replay_rate * STREAM_PAUSE_WAIT)/(ZM_RATE_BASE * 1000000)); - curr_stream_time += (1.0L * replay_rate * STREAM_PAUSE_WAIT)/(ZM_RATE_BASE * 1000000); - //} - continue; - } - } - - // Figure out if we should send this frame - bool send_frame = false; - if ( !paused ) - { - // If we are streaming and this frame is due to be sent - if ( ((curr_frame_id-1)%frame_mod) == 0 ) - { - delta_us = (unsigned int)(frame_data->delta * 1000000); - if ( effective_fps < base_fps ) - delta_us = (unsigned int)((delta_us * base_fps)/effective_fps); - send_frame = true; - } - } - else if ( step != 0 ) - { - // We are paused and are just stepping forward or backward one frame - step = 0; - send_frame = true; - } - else - { - // We are paused, and doing nothing - double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent; - if ( actual_delta_time > MAX_STREAM_DELAY ) - { - // Send keepalive - Debug( 2, "Sending keepalive frame" ); - send_frame = true; - } - } - - if ( send_frame ) - if ( !sendFrame( delta_us ) ) - zm_terminate = true; - - curr_stream_time = frame_data->timestamp; - - if ( !paused ) - { - curr_frame_id += replay_rate>0?1:-1; - if ( send_frame && type != STREAM_MPEG ) - { - Debug( 3, "dUs: %d", delta_us ); - usleep( delta_us ); - } - } - else - { - usleep( STREAM_PAUSE_WAIT ); - } - } -#if HAVE_LIBAVCODEC - if ( type == STREAM_MPEG ) - delete vid_stream; -#endif // HAVE_LIBAVCODEC - - closeComms(); +// +// ZoneMinder Event Class Implementation, $Date$, $Revision$ +// Copyright (C) 2001-2008 Philip Coombes +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "zm.h" +#include "zm_db.h" +#include "zm_time.h" +#include "zm_mpeg.h" +#include "zm_signal.h" +#include "zm_event.h" +#include "zm_monitor.h" + +#include "zmf.h" + +#if HAVE_SYS_SENDFILE_H +#include +#endif + +//#define USE_PREPARED_SQL 1 + +bool Event::initialised = false; +char Event::capture_file_format[PATH_MAX]; +char Event::analyse_file_format[PATH_MAX]; +char Event::general_file_format[PATH_MAX]; + +int Event::pre_alarm_count = 0; +Event::PreAlarmData Event::pre_alarm_data[MAX_PRE_ALARM_FRAMES] = { { 0 } }; + +Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string &p_cause, const StringSetMap &p_noteSetMap ) : + monitor( p_monitor ), + start_time( p_start_time ), + cause( p_cause ), + noteSetMap( p_noteSetMap ) +{ + if ( !initialised ) + Initialise(); + + std::string notes; + createNotes( notes ); + + bool untimedEvent = false; + if ( !start_time.tv_sec ) + { + untimedEvent = true; + gettimeofday( &start_time, 0 ); + } + + static char sql[ZM_SQL_MED_BUFSIZ]; + + struct tm *stime = localtime( &start_time.tv_sec ); + snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s' )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str() ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't insert event: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + id = mysql_insert_id( &dbconn ); + if ( untimedEvent ) + { + Warning( "Event %d has zero time, setting to current", id ); + } + end_time.tv_sec = 0; + frames = 0; + alarm_frames = 0; + tot_score = 0; + max_score = 0; + + if ( config.use_deep_storage ) + { + char *path_ptr = path; + path_ptr += snprintf( path_ptr, sizeof(path), "%s/%d", config.dir_events, monitor->Id() ); + + int dt_parts[6]; + dt_parts[0] = stime->tm_year-100; + dt_parts[1] = stime->tm_mon+1; + dt_parts[2] = stime->tm_mday; + dt_parts[3] = stime->tm_hour; + dt_parts[4] = stime->tm_min; + dt_parts[5] = stime->tm_sec; + + char date_path[PATH_MAX] = ""; + char time_path[PATH_MAX] = ""; + char *time_path_ptr = time_path; + for ( int i = 0; i < sizeof(dt_parts)/sizeof(*dt_parts); i++ ) + { + path_ptr += snprintf( path_ptr, sizeof(path)-(path_ptr-path), "/%02d", dt_parts[i] ); + + struct stat statbuf; + errno = 0; + stat( path, &statbuf ); + if ( errno == ENOENT || errno == ENOTDIR ) + { + if ( mkdir( path, 0755 ) ) + { + Fatal( "Can't mkdir %s: %s", path, strerror(errno)); + } + } + if ( i == 2 ) + strncpy( date_path, path, sizeof(date_path) ); + else if ( i >= 3 ) + time_path_ptr += snprintf( time_path_ptr, sizeof(time_path)-(time_path_ptr-time_path), "%s%02d", i>3?"/":"", dt_parts[i] ); + } + char id_file[PATH_MAX]; + // Create event id symlink + snprintf( id_file, sizeof(id_file), "%s/.%d", date_path, id ); + if ( symlink( time_path, id_file ) < 0 ) + Fatal( "Can't symlink %s -> %s: %s", id_file, path, strerror(errno)); + // Create empty id tag file + snprintf( id_file, sizeof(id_file), "%s/.%d", path, id ); + if ( FILE *id_fp = fopen( id_file, "w" ) ) + fclose( id_fp ); + else + Fatal( "Can't fopen %s: %s", id_file, strerror(errno)); + } + else + { + snprintf( path, sizeof(path), "%s/%d/%d", config.dir_events, monitor->Id(), id ); + + struct stat statbuf; + errno = 0; + stat( path, &statbuf ); + if ( errno == ENOENT || errno == ENOTDIR ) + { + if ( mkdir( path, 0755 ) ) + { + Error( "Can't mkdir %s: %s", path, strerror(errno)); + } + } + char id_file[PATH_MAX]; + // Create empty id tag file + snprintf( id_file, sizeof(id_file), "%s/.%d", path, id ); + if ( FILE *id_fp = fopen( id_file, "w" ) ) + fclose( id_fp ); + else + Fatal( "Can't fopen %s: %s", id_file, strerror(errno)); + } + last_db_frame = 0; +} + +Event::~Event() +{ + if ( frames > last_db_frame ) + { + struct DeltaTimeval delta_time; + DELTA_TIMEVAL( delta_time, end_time, start_time, DT_PREC_2 ); + + Debug( 1, "Adding closing frame %d to DB", frames ); + static char sql[ZM_SQL_SML_BUFSIZ]; + snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ( %d, %d, from_unixtime( %ld ), %s%ld.%02ld )", id, frames, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't insert frame: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + } + + static char sql[ZM_SQL_MED_BUFSIZ]; + + struct DeltaTimeval delta_time; + DELTA_TIMEVAL( delta_time, end_time, start_time, DT_PREC_2 ); + + snprintf( sql, sizeof(sql), "update Events set Name='%s%d', EndTime = from_unixtime( %ld ), Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", monitor->EventPrefix(), id, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't update event: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } +} + +void Event::createNotes( std::string ¬es ) +{ + notes.clear(); + for ( StringSetMap::const_iterator mapIter = noteSetMap.begin(); mapIter != noteSetMap.end(); mapIter++ ) + { + notes += mapIter->first; + notes += ": "; + const StringSet &stringSet = mapIter->second; + for ( StringSet::const_iterator setIter = stringSet.begin(); setIter != stringSet.end(); setIter++ ) + { + if ( setIter != stringSet.begin() ) + notes += ", "; + notes += *setIter; + } + } +} + +int Event::sd = -1; + +bool Event::OpenFrameSocket( int monitor_id ) +{ + if ( sd > 0 ) + { + close( sd ); + } + + sd = socket( AF_UNIX, SOCK_STREAM, 0); + if ( sd < 0 ) + { + Error( "Can't create socket: %s", strerror(errno) ); + return( false ); + } + + int socket_buffer_size = config.frame_socket_size; + if ( socket_buffer_size > 0 ) + { + if ( setsockopt( sd, SOL_SOCKET, SO_SNDBUF, &socket_buffer_size, sizeof(socket_buffer_size) ) < 0 ) + { + Error( "Can't get socket buffer size to %d, error = %s", socket_buffer_size, strerror(errno) ); + close( sd ); + sd = -1; + return( false ); + } + } + + int flags; + if ( (flags = fcntl( sd, F_GETFL )) < 0 ) + { + Error( "Can't get socket flags, error = %s", strerror(errno) ); + close( sd ); + sd = -1; + return( false ); + } + flags |= O_NONBLOCK; + if ( fcntl( sd, F_SETFL, flags ) < 0 ) + { + Error( "Can't set socket flags, error = %s", strerror(errno) ); + close( sd ); + sd = -1; + return( false ); + } + + char sock_path[PATH_MAX] = ""; + snprintf( sock_path, sizeof(sock_path), "%s/zmf-%d.sock", config.path_socks, monitor_id ); + + struct sockaddr_un addr; + + strncpy( addr.sun_path, sock_path, sizeof(addr.sun_path) ); + addr.sun_family = AF_UNIX; + + if ( connect( sd, (struct sockaddr *)&addr, strlen(addr.sun_path)+sizeof(addr.sun_family)) < 0 ) + { + Warning( "Can't connect to frame server: %s", strerror(errno) ); + close( sd ); + sd = -1; + return( false ); + } + + Debug( 1, "Opened connection to frame server" ); + return( true ); +} + +bool Event::ValidateFrameSocket( int monitor_id ) +{ + if ( sd < 0 ) + { + return( OpenFrameSocket( monitor_id ) ); + } + return( true ); +} + +bool Event::SendFrameImage( const Image *image, bool alarm_frame ) +{ + if ( !ValidateFrameSocket( monitor->Id() ) ) + { + return( false ); + } + + static int jpg_buffer_size = 0; + static unsigned char jpg_buffer[ZM_MAX_IMAGE_SIZE]; + + image->EncodeJpeg( jpg_buffer, &jpg_buffer_size, (alarm_frame&&(config.jpeg_alarm_file_quality>config.jpeg_file_quality))?config.jpeg_alarm_file_quality:config.jpeg_file_quality ); + + static FrameHeader frame_header; + + frame_header.event_id = id; + if ( config.use_deep_storage ) + frame_header.event_time = start_time.tv_sec; + frame_header.frame_id = frames; + frame_header.alarm_frame = alarm_frame; + frame_header.image_length = jpg_buffer_size; + + struct iovec iovecs[2]; + iovecs[0].iov_base = &frame_header; + iovecs[0].iov_len = sizeof(frame_header); + iovecs[1].iov_base = jpg_buffer; + iovecs[1].iov_len = jpg_buffer_size; + + ssize_t writev_size = sizeof(frame_header)+jpg_buffer_size; + ssize_t writev_result = writev( sd, iovecs, sizeof(iovecs)/sizeof(*iovecs)); + if ( writev_result != writev_size ) + { + if ( writev_result < 0 ) + { + if ( errno == EAGAIN ) + { + Warning( "Blocking write detected" ); + } + else + { + Error( "Can't write frame: %s", strerror(errno) ); + close( sd ); + sd = -1; + } + } + else + { + Error( "Incomplete frame write: %zd of %zd bytes written", writev_result, writev_size ); + close( sd ); + sd = -1; + } + return( false ); + } + Debug( 1, "Wrote frame image, %d bytes", jpg_buffer_size ); + + return( true ); +} + +bool Event::WriteFrameImage( Image *image, struct timeval timestamp, const char *event_file, bool alarm_frame ) +{ + if ( config.timestamp_on_capture ) + { + if ( !config.opt_frame_server || !SendFrameImage( image, alarm_frame) ) + { + if ( alarm_frame && (config.jpeg_alarm_file_quality > config.jpeg_file_quality) ) + image->WriteJpeg( event_file, config.jpeg_alarm_file_quality ); + else + image->WriteJpeg( event_file ); + } + } + else + { + Image ts_image( *image ); + monitor->TimestampImage( &ts_image, ×tamp ); + if ( !config.opt_frame_server || !SendFrameImage( &ts_image, alarm_frame) ) + { + if ( alarm_frame && (config.jpeg_alarm_file_quality > config.jpeg_file_quality) ) + ts_image.WriteJpeg( event_file, config.jpeg_alarm_file_quality ); + else + ts_image.WriteJpeg( event_file ); + } + } + return( true ); +} + +void Event::updateNotes( const StringSetMap &newNoteSetMap ) +{ + bool update = false; + + //Info( "Checking notes, %d <> %d", noteSetMap.size(), newNoteSetMap.size() ); + if ( newNoteSetMap.size() > 0 ) + { + if ( noteSetMap.size() == 0 ) + { + noteSetMap = newNoteSetMap; + update = true; + } + else + { + for ( StringSetMap::const_iterator newNoteSetMapIter = newNoteSetMap.begin(); newNoteSetMapIter != newNoteSetMap.end(); newNoteSetMapIter++ ) + { + const std::string &newNoteGroup = newNoteSetMapIter->first; + const StringSet &newNoteSet = newNoteSetMapIter->second; + //Info( "Got %d new strings", newNoteSet.size() ); + if ( newNoteSet.size() > 0 ) + { + StringSetMap::iterator noteSetMapIter = noteSetMap.find( newNoteGroup ); + if ( noteSetMapIter == noteSetMap.end() ) + { + //Info( "Can't find note group %s, copying %d strings", newNoteGroup.c_str(), newNoteSet.size() ); + noteSetMap.insert( StringSetMap::value_type( newNoteGroup, newNoteSet ) ); + update = true; + } + else + { + StringSet ¬eSet = noteSetMapIter->second; + //Info( "Found note group %s, got %d strings", newNoteGroup.c_str(), newNoteSet.size() ); + for ( StringSet::const_iterator newNoteSetIter = newNoteSet.begin(); newNoteSetIter != newNoteSet.end(); newNoteSetIter++ ) + { + const std::string &newNote = *newNoteSetIter; + StringSet::iterator noteSetIter = noteSet.find( newNote ); + if ( noteSetIter == noteSet.end() ) + { + noteSet.insert( newNote ); + update = true; + } + } + } + } + } + } + } + + if ( update ) + { + std::string notes; + createNotes( notes ); + + Debug( 2, "Updating notes for event %d, '%s'", id, notes.c_str() ); + static char sql[ZM_SQL_MED_BUFSIZ]; +#if USE_PREPARED_SQL + static MYSQL_STMT *stmt = 0; + + char notesStr[ZM_SQL_MED_BUFSIZ] = ""; + unsigned long notesLen = 0; + + if ( !stmt ) + { + const char *sql = "update Events set Notes = ? where Id = ?"; + + stmt = mysql_stmt_init( &dbconn ); + if ( mysql_stmt_prepare( stmt, sql, strlen(sql) ) ) + { + Fatal( "Unable to prepare sql '%s': %s", sql, mysql_stmt_error(stmt) ); + } + + /* Get the parameter count from the statement */ + if ( mysql_stmt_param_count( stmt ) != 2 ) + { + Fatal( "Unexpected parameter count %ld in sql '%s'", mysql_stmt_param_count( stmt ), sql ); + } + + MYSQL_BIND bind[2]; + memset(bind, 0, sizeof(bind)); + + /* STRING PARAM */ + bind[0].buffer_type = MYSQL_TYPE_STRING; + bind[0].buffer = (char *)notesStr; + bind[0].buffer_length = sizeof(notesStr); + bind[0].is_null = 0; + bind[0].length = ¬esLen; + + bind[1].buffer_type= MYSQL_TYPE_LONG; + bind[1].buffer= (char *)&id; + bind[1].is_null= 0; + bind[1].length= 0; + + /* Bind the buffers */ + if ( mysql_stmt_bind_param( stmt, bind ) ) + { + Fatal( "Unable to bind sql '%s': %s", sql, mysql_stmt_error(stmt) ); + } + } + + strncpy( notesStr, notes.c_str(), sizeof(notesStr) ); + notesLen = notes.length(); + + if ( mysql_stmt_execute( stmt ) ) + { + Fatal( "Unable to execute sql '%s': %s", sql, mysql_stmt_error(stmt) ); + } +#else + static char escapedNotes[ZM_SQL_MED_BUFSIZ]; + + mysql_real_escape_string( &dbconn, escapedNotes, notes.c_str(), notes.length() ); + + snprintf( sql, sizeof(sql), "update Events set Notes = '%s' where Id = %d", escapedNotes, id ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't insert event: %s", mysql_error( &dbconn ) ); + } +#endif + } +} + +void Event::AddFrames( int n_frames, Image **images, struct timeval **timestamps ) +{ + static char sql[ZM_SQL_LGE_BUFSIZ]; + strncpy( sql, "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ", sizeof(sql) ); + int frameCount = 0; + for ( int i = 0; i < n_frames; i++ ) + { + if ( !timestamps[i]->tv_sec ) + { + Debug( 1, "Not adding pre-capture frame %d, zero timestamp", i ); + continue; + } + + frames++; + + static char event_file[PATH_MAX]; + snprintf( event_file, sizeof(event_file), capture_file_format, path, frames ); + + Debug( 1, "Writing pre-capture frame %d", frames ); + WriteFrameImage( images[i], *(timestamps[i]), event_file ); + + struct DeltaTimeval delta_time; + DELTA_TIMEVAL( delta_time, *(timestamps[i]), start_time, DT_PREC_2 ); + + int sql_len = strlen(sql); + snprintf( sql+sql_len, sizeof(sql)-sql_len, "( %d, %d, from_unixtime(%ld), %s%ld.%02ld ), ", id, frames, timestamps[i]->tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec ); + + frameCount++; + } + + if ( frameCount ) + { + Debug( 1, "Adding %d/%d frames to DB", frameCount, n_frames ); + *(sql+strlen(sql)-2) = '\0'; + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't insert frames: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + last_db_frame = frames; + } + else + { + Debug( 1, "No valid pre-capture frames to add" ); + } +} + +void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *alarm_image ) +{ + if ( !timestamp.tv_sec ) + { + Debug( 1, "Not adding new frame, zero timestamp" ); + return; + } + + frames++; + + static char event_file[PATH_MAX]; + snprintf( event_file, sizeof(event_file), capture_file_format, path, frames ); + + Debug( 1, "Writing capture frame %d", frames ); + WriteFrameImage( image, timestamp, event_file ); + + struct DeltaTimeval delta_time; + DELTA_TIMEVAL( delta_time, timestamp, start_time, DT_PREC_2 ); + + bool db_frame = (score>=0) || ((frames%config.bulk_frame_interval)==0) || !frames; + + if ( db_frame ) + { + const char *frame_type = score>0?"Alarm":(score<0?"Bulk":"Normal"); + + Debug( 1, "Adding frame %d to DB", frames ); + static char sql[ZM_SQL_MED_BUFSIZ]; + snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %d, %d, '%s', from_unixtime( %ld ), %s%ld.%02ld, %d )", id, frames, frame_type, timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't insert frame: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + last_db_frame = frames; + + // We are writing a bulk frame + if ( score < 0 ) + { + snprintf( sql, sizeof(sql), "update Events set Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d", delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, id ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't update event: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + } + } + + end_time = timestamp; + + if ( score > 0 ) + { + alarm_frames++; + + tot_score += score; + if ( score > max_score ) + max_score = score; + + if ( alarm_image ) + { + snprintf( event_file, sizeof(event_file), analyse_file_format, path, frames ); + + Debug( 1, "Writing analysis frame %d", frames ); + WriteFrameImage( alarm_image, timestamp, event_file, true ); + } + } + + if ( config.record_diag_images ) + { + char diag_glob[PATH_MAX] = ""; + + snprintf( diag_glob, sizeof(diag_glob), "%s/%d/diag-*.jpg", config.dir_events, monitor->Id() ); + glob_t pglob; + int glob_status = glob( diag_glob, 0, 0, &pglob ); + if ( glob_status != 0 ) + { + if ( glob_status < 0 ) + { + Error( "Can't glob '%s': %s", diag_glob, strerror(errno) ); + } + else + { + Debug( 1, "Can't glob '%s': %d", diag_glob, glob_status ); + } + } + else + { + char new_diag_path[PATH_MAX] = ""; + for ( int i = 0; i < pglob.gl_pathc; i++ ) + { + char *diag_path = pglob.gl_pathv[i]; + + char *diag_file = strstr( diag_path, "diag-" ); + + if ( diag_file ) + { + snprintf( new_diag_path, sizeof(new_diag_path), general_file_format, path, frames, diag_file ); + + if ( rename( diag_path, new_diag_path ) < 0 ) + { + Error( "Can't rename '%s' to '%s': %s", diag_path, new_diag_path, strerror(errno) ); + } + } + } + } + globfree( &pglob ); + } +} + +bool EventStream::loadInitialEventData( int monitor_id, time_t event_time ) +{ + static char sql[ZM_SQL_SML_BUFSIZ]; + + snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %d and unix_timestamp( EndTime ) > %ld order by Id asc limit 1", monitor_id, event_time ); + + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't run query: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + MYSQL_RES *result = mysql_store_result( &dbconn ); + if ( !result ) + { + Error( "Can't use query result: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + MYSQL_ROW dbrow = mysql_fetch_row( result ); + + if ( mysql_errno( &dbconn ) ) + { + Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + int init_event_id = atoi( dbrow[0] ); + + mysql_free_result( result ); + + loadEventData( init_event_id ); + + if ( event_time ) + { + curr_stream_time = event_time; + curr_frame_id = 1; + if ( event_time >= event_data->start_time ) + { + for ( int i = 0; i < event_data->frame_count; i++ ) + { + //Info( "eft %d > et %d", event_data->frames[i].timestamp, event_time ); + if ( event_data->frames[i].timestamp >= event_time ) + { + curr_frame_id = i+1; + Debug( 3, "Set cst:%.2f", curr_stream_time ); + Debug( 3, "Set cfid:%d", curr_frame_id ); + break; + } + } + Debug( 3, "Skipping %ld frames", event_data->frame_count ); + } + } + return( true ); +} + +bool EventStream::loadInitialEventData( int init_event_id, int init_frame_id ) +{ + loadEventData( init_event_id ); + + if ( init_frame_id ) + { + curr_stream_time = event_data->frames[init_frame_id-1].timestamp; + curr_frame_id = init_frame_id; + } + else + { + curr_stream_time = event_data->start_time; + } + + return( true ); +} + +bool EventStream::loadEventData( int event_id ) +{ + static char sql[ZM_SQL_MED_BUFSIZ]; + + snprintf( sql, sizeof(sql), "select M.Id, M.Name, E.Frames, unix_timestamp( StartTime ) as StartTimestamp, max(F.Delta)-min(F.Delta) as Duration from Events as E inner join Monitors as M on E.MonitorId = M.Id inner join Frames as F on E.Id = F.EventId where E.Id = %d group by E.Id", event_id ); + + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't run query: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + MYSQL_RES *result = mysql_store_result( &dbconn ); + if ( !result ) + { + Error( "Can't use query result: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + if ( !mysql_num_rows( result ) ) + { + Fatal( "Unable to load event %d, not found in DB", event_id ); + } + + MYSQL_ROW dbrow = mysql_fetch_row( result ); + + if ( mysql_errno( &dbconn ) ) + { + Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + delete event_data; + event_data = new EventData; + event_data->event_id = event_id; + event_data->monitor_id = atoi( dbrow[0] ); + event_data->start_time = atoi(dbrow[3]); + if ( config.use_deep_storage ) + { + struct tm *event_time = localtime( &event_data->start_time ); + if ( config.dir_events[0] == '/' ) + snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", config.dir_events, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec ); + else + snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", staticConfig.PATH_WEB.c_str(), config.dir_events, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec ); + } + else + { + if ( config.dir_events[0] == '/' ) + snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%ld", config.dir_events, event_data->monitor_id, event_data->event_id ); + else + snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%ld", staticConfig.PATH_WEB.c_str(), config.dir_events, event_data->monitor_id, event_data->event_id ); + } + event_data->frame_count = atoi(dbrow[2]); + event_data->duration = atof(dbrow[4]); + + updateFrameRate( (double)event_data->frame_count/event_data->duration ); + + mysql_free_result( result ); + + snprintf( sql, sizeof(sql), "select FrameId, unix_timestamp( `TimeStamp` ), Delta from Frames where EventId = %d order by FrameId asc", event_id ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't run query: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + result = mysql_store_result( &dbconn ); + if ( !result ) + { + Error( "Can't use query result: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + event_data->n_frames = mysql_num_rows( result ); + + event_data->frames = new FrameData[event_data->frame_count]; + int id, last_id = 0; + time_t timestamp, last_timestamp = event_data->start_time; + double delta, last_delta = 0.0; + while ( ( dbrow = mysql_fetch_row( result ) ) ) + { + id = atoi(dbrow[0]); + timestamp = atoi(dbrow[1]); + delta = atof(dbrow[2]); + int id_diff = id - last_id; + double frame_delta = (delta-last_delta)/id_diff; + if ( id_diff > 1 ) + { + for ( int i = last_id+1; i < id; i++ ) + { + event_data->frames[i-1].timestamp = (time_t)(last_timestamp + ((i-last_id)*frame_delta)); + event_data->frames[i-1].offset = (time_t)(event_data->frames[i-1].timestamp-event_data->start_time); + event_data->frames[i-1].delta = frame_delta; + event_data->frames[i-1].in_db = false; + } + } + event_data->frames[id-1].timestamp = timestamp; + event_data->frames[id-1].offset = (time_t)(event_data->frames[id-1].timestamp-event_data->start_time); + event_data->frames[id-1].delta = id>1?frame_delta:0.0; + event_data->frames[id-1].in_db = true; + last_id = id; + last_delta = delta; + last_timestamp = timestamp; + } + if ( mysql_errno( &dbconn ) ) + { + Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + //for ( int i = 0; i < 250; i++ ) + //{ + //Info( "%d -> %d @ %f (%d)", i+1, event_data->frames[i].timestamp, event_data->frames[i].delta, event_data->frames[i].in_db ); + //} + + mysql_free_result( result ); + + if ( forceEventChange || mode == MODE_ALL_GAPLESS ) + { + if ( replay_rate > 0 ) + curr_stream_time = event_data->frames[0].timestamp; + else + curr_stream_time = event_data->frames[event_data->frame_count-1].timestamp; + } + Debug( 2, "Event:%ld, Frames:%ld, Duration: %.2f", event_data->event_id, event_data->frame_count, event_data->duration ); + + return( true ); +} + +void EventStream::processCommand( const CmdMsg *msg ) +{ + Debug( 2, "Got message, type %d, msg %d", msg->msg_type, msg->msg_data[0] ) + // Check for incoming command + switch( (MsgCommand)msg->msg_data[0] ) + { + case CMD_PAUSE : + { + Debug( 1, "Got PAUSE command" ); + + // Set paused flag + paused = true; + replay_rate = ZM_RATE_BASE; + last_frame_sent = TV_2_FLOAT( now ); + break; + } + case CMD_PLAY : + { + Debug( 1, "Got PLAY command" ); + if ( paused ) + { + // Clear paused flag + paused = false; + } + replay_rate = ZM_RATE_BASE; + break; + } + case CMD_VARPLAY : + { + Debug( 1, "Got VARPLAY command" ); + if ( paused ) + { + // Clear paused flag + paused = false; + } + replay_rate = ntohs(((unsigned char)msg->msg_data[2]<<8)|(unsigned char)msg->msg_data[1])-32768; + break; + } + case CMD_STOP : + { + Debug( 1, "Got STOP command" ); + + // Clear paused flag + paused = false; + break; + } + case CMD_FASTFWD : + { + Debug( 1, "Got FAST FWD command" ); + if ( paused ) + { + // Clear paused flag + paused = false; + } + // Set play rate + switch ( replay_rate ) + { + case 2 * ZM_RATE_BASE : + replay_rate = 5 * ZM_RATE_BASE; + break; + case 5 * ZM_RATE_BASE : + replay_rate = 10 * ZM_RATE_BASE; + break; + case 10 * ZM_RATE_BASE : + replay_rate = 25 * ZM_RATE_BASE; + break; + case 25 * ZM_RATE_BASE : + case 50 * ZM_RATE_BASE : + replay_rate = 50 * ZM_RATE_BASE; + break; + default : + replay_rate = 2 * ZM_RATE_BASE; + break; + } + break; + } + case CMD_SLOWFWD : + { + Debug( 1, "Got SLOW FWD command" ); + // Set paused flag + paused = true; + // Set play rate + replay_rate = ZM_RATE_BASE; + // Set step + step = 1; + break; + } + case CMD_SLOWREV : + { + Debug( 1, "Got SLOW REV command" ); + // Set paused flag + paused = true; + // Set play rate + replay_rate = ZM_RATE_BASE; + // Set step + step = -1; + break; + } + case CMD_FASTREV : + { + Debug( 1, "Got FAST REV command" ); + if ( paused ) + { + // Clear paused flag + paused = false; + } + // Set play rate + switch ( replay_rate ) + { + case -2 * ZM_RATE_BASE : + replay_rate = -5 * ZM_RATE_BASE; + break; + case -5 * ZM_RATE_BASE : + replay_rate = -10 * ZM_RATE_BASE; + break; + case -10 * ZM_RATE_BASE : + replay_rate = -25 * ZM_RATE_BASE; + break; + case -25 * ZM_RATE_BASE : + case -50 * ZM_RATE_BASE : + replay_rate = -50 * ZM_RATE_BASE; + break; + default : + replay_rate = -2 * ZM_RATE_BASE; + break; + } + break; + } + case CMD_ZOOMIN : + { + x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2]; + y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4]; + Debug( 1, "Got ZOOM IN command, to %d,%d", x, y ); + switch ( zoom ) + { + case 100: + zoom = 150; + break; + case 150: + zoom = 200; + break; + case 200: + zoom = 300; + break; + case 300: + zoom = 400; + break; + case 400: + default : + zoom = 500; + break; + } + break; + } + case CMD_ZOOMOUT : + { + Debug( 1, "Got ZOOM OUT command" ); + switch ( zoom ) + { + case 500: + zoom = 400; + break; + case 400: + zoom = 300; + break; + case 300: + zoom = 200; + break; + case 200: + zoom = 150; + break; + case 150: + default : + zoom = 100; + break; + } + break; + } + case CMD_PAN : + { + x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2]; + y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4]; + Debug( 1, "Got PAN command, to %d,%d", x, y ); + break; + } + case CMD_SCALE : + { + scale = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2]; + Debug( 1, "Got SCALE command, to %d", scale ); + break; + } + case CMD_PREV : + { + Debug( 1, "Got PREV command" ); + if ( replay_rate >= 0 ) + curr_frame_id = 0; + else + curr_frame_id = event_data->frame_count-1; + paused = false; + forceEventChange = true; + break; + } + case CMD_NEXT : + { + Debug( 1, "Got NEXT command" ); + if ( replay_rate >= 0 ) + curr_frame_id = event_data->frame_count-1; + else + curr_frame_id = 0; + paused = false; + forceEventChange = true; + break; + } + case CMD_SEEK : + { + int offset = ((unsigned char)msg->msg_data[1]<<24)|((unsigned char)msg->msg_data[2]<<16)|((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4]; + curr_frame_id = (int)(event_data->frame_count*offset/event_data->duration); + Debug( 1, "Got SEEK command, to %d (new cfid: %d)", offset, curr_frame_id ); + break; + } + case CMD_QUERY : + { + Debug( 1, "Got QUERY command, sending STATUS" ); + break; + } + default : + { + // Do nothing, for now + } + } + struct { + int event; + int progress; + int rate; + int zoom; + bool paused; + } status_data; + + status_data.event = event_data->event_id; + status_data.progress = (int)event_data->frames[curr_frame_id-1].offset; + status_data.rate = replay_rate; + status_data.zoom = zoom; + status_data.paused = paused; + Debug( 2, "E:%d, P:%d, p:%d R:%d, Z:%d", + status_data.event, + status_data.paused, + status_data.progress, + status_data.rate, + status_data.zoom + ); + + DataMsg status_msg; + status_msg.msg_type = MSG_DATA_EVENT; + memcpy( &status_msg.msg_data, &status_data, sizeof(status_msg.msg_data) ); + if ( sendto( sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr) ) < 0 ) + { + //if ( errno != EAGAIN ) + { + Error( "Can't sendto on sd %d: %s", sd, strerror(errno) ); + exit( -1 ); + } + } + + updateFrameRate( (double)event_data->frame_count/event_data->duration ); +} + +void EventStream::checkEventLoaded() +{ + bool reload_event = false; + static char sql[ZM_SQL_SML_BUFSIZ]; + + if ( curr_frame_id <= 0 ) + { + snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %ld and Id < %ld order by Id desc limit 1", event_data->monitor_id, event_data->event_id ); + reload_event = true; + } + else if ( curr_frame_id > event_data->frame_count ) + { + snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %ld and Id > %ld order by Id asc limit 1", event_data->monitor_id, event_data->event_id ); + reload_event = true; + } + + if ( reload_event ) + { + if ( forceEventChange || mode != MODE_SINGLE ) + { + //Info( "SQL:%s", sql ); + if ( mysql_query( &dbconn, sql ) ) + { + Error( "Can't run query: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + MYSQL_RES *result = mysql_store_result( &dbconn ); + if ( !result ) + { + Error( "Can't use query result: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + MYSQL_ROW dbrow = mysql_fetch_row( result ); + + if ( mysql_errno( &dbconn ) ) + { + Error( "Can't fetch row: %s", mysql_error( &dbconn ) ); + exit( mysql_errno( &dbconn ) ); + } + + if ( dbrow ) + { + int event_id = atoi(dbrow[0]); + Debug( 1, "Loading new event %d", event_id ); + + loadEventData( event_id ); + + Debug( 2, "Current frame id = %d", curr_frame_id ); + if ( curr_frame_id <= 0 ) + curr_frame_id = event_data->frame_count; + else + curr_frame_id = 1; + Debug( 2, "New frame id = %d", curr_frame_id ); + } + else + { + if ( curr_frame_id <= 0 ) + curr_frame_id = 1; + else + curr_frame_id = event_data->frame_count; + paused = true; + } + mysql_free_result( result ); + forceEventChange = false; + } + else + { + if ( curr_frame_id <= 0 ) + curr_frame_id = 1; + else + curr_frame_id = event_data->frame_count; + paused = true; + } + } +} + +bool EventStream::sendFrame( int delta_us ) +{ + Debug( 2, "Sending frame %d", curr_frame_id ); + + static char filepath[PATH_MAX]; + static struct stat filestat; + FILE *fdj = NULL; + + snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id ); + +#if HAVE_LIBAVCODEC + if ( type == STREAM_MPEG ) + { + Image image( filepath ); + + Image *send_image = prepareImage( &image ); + + if ( !vid_stream ) + { + vid_stream = new VideoStream( "pipe:", format, bitrate, effective_fps, send_image->Colours(), send_image->SubpixelOrder(), send_image->Width(), send_image->Height() ); + fprintf( stdout, "Content-type: %s\r\n\r\n", vid_stream->MimeType() ); + vid_stream->OpenStream(); + } + /* double pts = */ vid_stream->EncodeFrame( send_image->Buffer(), send_image->Size(), config.mpeg_timed_frames, delta_us*1000 ); + } + else +#endif // HAVE_LIBAVCODEC + { + static unsigned char temp_img_buffer[ZM_MAX_IMAGE_SIZE]; + + int img_buffer_size = 0; + uint8_t *img_buffer = temp_img_buffer; + + bool send_raw = ((scale>=ZM_SCALE_BASE)&&(zoom==ZM_SCALE_BASE)); + + fprintf( stdout, "--ZoneMinderFrame\r\n" ); + + if ( type != STREAM_JPEG ) + send_raw = false; + + if ( send_raw ) + { + fdj = fopen( filepath, "rb" ); + if ( !fdj ) + { + Error( "Can't open %s: %s", filepath, strerror(errno) ); + return( false ); + } +#if HAVE_SENDFILE + if( fstat(fileno(fdj),&filestat) < 0 ) { + Error( "Failed getting information about file %s: %s", filepath, strerror(errno) ); + return( false ); + } +#else + img_buffer_size = fread( img_buffer, 1, sizeof(temp_img_buffer), fdj ); +#endif + } + else + { + Image image( filepath ); + + Image *send_image = prepareImage( &image ); + + switch( type ) + { + case STREAM_JPEG : + send_image->EncodeJpeg( img_buffer, &img_buffer_size ); + break; + case STREAM_RAW : + img_buffer = (uint8_t*)(send_image->Buffer()); + img_buffer_size = send_image->Size(); + break; + case STREAM_ZIP : + unsigned long zip_buffer_size; + send_image->Zip( img_buffer, &zip_buffer_size ); + img_buffer_size = zip_buffer_size; + break; + default: + Fatal( "Unexpected frame type %d", type ); + break; + } + } + + switch( type ) + { + case STREAM_JPEG : + fprintf( stdout, "Content-Type: image/jpeg\r\n" ); + break; + case STREAM_RAW : + fprintf( stdout, "Content-Type: image/x-rgb\r\n" ); + break; + case STREAM_ZIP : + fprintf( stdout, "Content-Type: image/x-rgbz\r\n" ); + break; + default : + Fatal( "Unexpected frame type %d", type ); + break; + } + + + if(send_raw) { +#if HAVE_SENDFILE + fprintf( stdout, "Content-Length: %d\r\n\r\n", (int)filestat.st_size ); + if(sendfile(fileno(stdout), fileno(fdj), 0, (int)filestat.st_size) != (int)filestat.st_size) { + /* sendfile() failed, use standard way instead */ + img_buffer_size = fread( img_buffer, 1, sizeof(temp_img_buffer), fdj ); + if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) { + Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno)); + return( false ); + } + } +#else + fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size ); + if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) { + Error("Unable to send raw frame %u: %s",curr_frame_id,strerror(errno)); + return( false ); + } +#endif + fclose(fdj); /* Close the file handle */ + } else { + fprintf( stdout, "Content-Length: %d\r\n\r\n", img_buffer_size ); + if ( fwrite( img_buffer, img_buffer_size, 1, stdout ) != 1 ) + { + Error( "Unable to send stream frame: %s", strerror(errno) ); + return( false ); + } + } + + fprintf( stdout, "\r\n\r\n" ); + fflush( stdout ); + } + last_frame_sent = TV_2_FLOAT( now ); + return( true ); +} + +void EventStream::runStream() +{ + Event::Initialise(); + + openComms(); + + checkInitialised(); + + updateFrameRate( (double)event_data->frame_count/event_data->duration ); + + if ( type == STREAM_JPEG ) + fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" ); + + if ( !event_data ) + { + sendTextFrame( "No event data found" ); + exit( 0 ); + } + + unsigned int delta_us = 0; + while( !zm_terminate ) + { + gettimeofday( &now, NULL ); + + checkCommandQueue(); + + if ( step != 0 ) + curr_frame_id += step; + + checkEventLoaded(); + + // Get current frame data + FrameData *frame_data = &event_data->frames[curr_frame_id-1]; + + //Info( "cst:%.2f", curr_stream_time ); + //Info( "cfid:%d", curr_frame_id ); + //Info( "fdt:%d", frame_data->timestamp ); + if ( !paused ) + { + bool in_event = true; + double time_to_event = 0; + if ( replay_rate > 0 ) + { + time_to_event = event_data->frames[0].timestamp - curr_stream_time; + if ( time_to_event > 0 ) + in_event = false; + } + else if ( replay_rate < 0 ) + { + time_to_event = curr_stream_time - event_data->frames[event_data->frame_count-1].timestamp; + if ( time_to_event > 0 ) + in_event = false; + } + if ( !in_event ) + { + double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent; + if ( actual_delta_time > 1 ) + { + static char frame_text[64]; + snprintf( frame_text, sizeof(frame_text), "Time to next event = %d seconds", (int)time_to_event ); + if ( !sendTextFrame( frame_text ) ) + zm_terminate = true; + } + //else + //{ + usleep( STREAM_PAUSE_WAIT ); + //curr_stream_time += (replay_rate>0?1:-1) * ((1.0L * replay_rate * STREAM_PAUSE_WAIT)/(ZM_RATE_BASE * 1000000)); + curr_stream_time += (1.0L * replay_rate * STREAM_PAUSE_WAIT)/(ZM_RATE_BASE * 1000000); + //} + continue; + } + } + + // Figure out if we should send this frame + bool send_frame = false; + if ( !paused ) + { + // If we are streaming and this frame is due to be sent + if ( ((curr_frame_id-1)%frame_mod) == 0 ) + { + delta_us = (unsigned int)(frame_data->delta * 1000000); + if ( effective_fps < base_fps ) + delta_us = (unsigned int)((delta_us * base_fps)/effective_fps); + send_frame = true; + } + } + else if ( step != 0 ) + { + // We are paused and are just stepping forward or backward one frame + step = 0; + send_frame = true; + } + else + { + // We are paused, and doing nothing + double actual_delta_time = TV_2_FLOAT( now ) - last_frame_sent; + if ( actual_delta_time > MAX_STREAM_DELAY ) + { + // Send keepalive + Debug( 2, "Sending keepalive frame" ); + send_frame = true; + } + } + + if ( send_frame ) + if ( !sendFrame( delta_us ) ) + zm_terminate = true; + + curr_stream_time = frame_data->timestamp; + + if ( !paused ) + { + curr_frame_id += replay_rate>0?1:-1; + if ( send_frame && type != STREAM_MPEG ) + { + Debug( 3, "dUs: %d", delta_us ); + usleep( delta_us ); + } + } + else + { + usleep( STREAM_PAUSE_WAIT ); + } + } +#if HAVE_LIBAVCODEC + if ( type == STREAM_MPEG ) + delete vid_stream; +#endif // HAVE_LIBAVCODEC + + closeComms(); } diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 68566ee95..5761a4d6e 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1707,7 +1707,7 @@ void Monitor::ReloadLinkedMonitors( const char *p_linked_monitors ) { *dest_ptr = '\0'; int link_id = atoi(link_id_str); - if ( link_id > 0 ) + if ( link_id > 0 && link_id != id) { Debug( 3, "Found linked monitor id %d", link_id ); int j; From 46aa1bb1d8661317c2eb7aec7c552467fca6f225 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 30 Jun 2011 21:05:55 +0300 Subject: [PATCH 20/56] Fixed bug in linked monitor loading code which should fix the crash of a monitor linked to a disabled monitor. --- src/zm_monitor.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 5761a4d6e..5bbff9dd4 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1732,9 +1732,9 @@ void Monitor::ReloadLinkedMonitors( const char *p_linked_monitors ) if ( n_link_ids > 0 ) { Debug( 1, "Linking to %d monitors", n_link_ids ); - n_linked_monitors = n_link_ids; - linked_monitors = new MonitorLink *[n_linked_monitors]; - for ( int i = 0; i < n_linked_monitors; i++ ) + linked_monitors = new MonitorLink *[n_link_ids]; + int count = 0; + for ( int i = 0; i < n_link_ids; i++ ) { Debug( 1, "Checking linked monitor %d", link_ids[i] ); @@ -1757,14 +1757,15 @@ void Monitor::ReloadLinkedMonitors( const char *p_linked_monitors ) { MYSQL_ROW dbrow = mysql_fetch_row( result ); Debug( 1, "Linking to monitor %d", link_ids[i] ); - linked_monitors[i] = new MonitorLink( link_ids[i], dbrow[1] ); + linked_monitors[count++] = new MonitorLink( link_ids[i], dbrow[1] ); } else { - Debug( 1, "Can't link to monitor %d, invalid id, function or not enabled", link_ids[i] ); + Warning( "Can't link to monitor %d, invalid id, function or not enabled", link_ids[i] ); } mysql_free_result( result ); } + n_linked_monitors = count; } } } From bdf06875506a84a591cede3d8734c27f4abae5f1 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Fri, 1 Jul 2011 18:01:24 +0300 Subject: [PATCH 21/56] 1) Added support for JPEG and MJPEG capture palettes - needs to be tested 2) Allow the blend percent to be zero, to disable blending --- src/zm_image.cpp | 6 ++-- src/zm_local_camera.cpp | 38 +++++++++++++++++++++-- web/skins/classic/views/js/monitor.js.php | 2 +- web/skins/classic/views/monitor.php | 18 ++++++----- web/skins/classic/views/monitorprobe.php | 2 +- 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index d1112859f..ae511d881 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -1295,8 +1295,10 @@ void Image::Blend( const Image &image, int transparency ) Panic( "Attempt to blend different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, image.width, image.height, image.colours, image.subpixelorder ); } - /* Do the blending */ - (*fptr_blend)(buffer, image.buffer, buffer, size, transparency); + if(transparency > 0) { + /* Do the blending */ + (*fptr_blend)(buffer, image.buffer, buffer, size, transparency); + } } Image *Image::Merge( int n_images, Image *images[] ) diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index d9c3da060..25bc98cf5 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -101,6 +101,7 @@ static PixelFormat getFfPixFormatFromV4lPalette( int v4l_version, int palette ) pixFormat = PIX_FMT_YUV420P; break; case V4L2_PIX_FMT_JPEG : + case V4L2_PIX_FMT_MJPEG : pixFormat = PIX_FMT_YUVJ444P; break; // These don't seem to have ffmpeg equivalents @@ -125,7 +126,6 @@ static PixelFormat getFfPixFormatFromV4lPalette( int v4l_version, int palette ) //case V4L2_PIX_FMT_SBGGR8 : //case V4L2_PIX_FMT_SGBRG8 : //case V4L2_PIX_FMT_SBGGR16 : - case V4L2_PIX_FMT_MJPEG : case V4L2_PIX_FMT_DV : case V4L2_PIX_FMT_MPEG : case V4L2_PIX_FMT_WNVA : @@ -410,10 +410,15 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, conversion_type = 2; #endif /* Our YUYV->Grayscale conversion is a lot faster than swscale's */ - if(conversion_type == 1 && colours == ZM_COLOUR_GRAY8 && palette == V4L2_PIX_FMT_YUYV) { + if(colours == ZM_COLOUR_GRAY8 && palette == V4L2_PIX_FMT_YUYV) { conversion_type = 2; } + /* JPEG */ + if(palette == V4L2_PIX_FMT_JPEG || palette == V4L2_PIX_FMT_MJPEG) { + conversion_type = 3; + } + if(conversion_type == 2) { Debug(2,"Using ZM for image conversion"); if(palette == V4L2_PIX_FMT_RGB32 && colours == ZM_COLOUR_GRAY8) { @@ -520,7 +525,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, conversion_type = 2; #endif /* Our YUYV->Grayscale conversion is a lot faster than swscale's */ - if(conversion_type == 1 && colours == ZM_COLOUR_GRAY8 && (palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422)) { + if(colours == ZM_COLOUR_GRAY8 && (palette == VIDEO_PALETTE_YUYV || palette == VIDEO_PALETTE_YUV422)) { conversion_type = 2; } @@ -714,6 +719,26 @@ void LocalCamera::Initialise() if (v4l2_data.fmt.fmt.pix.sizeimage < min) v4l2_data.fmt.fmt.pix.sizeimage = min; + v4l2_jpegcompression jpeg_comp; + if(palette == V4L2_PIX_FMT_JPEG || palette == V4L2_PIX_FMT_MJPEG) { + if( vidioctl( vid_fd, VIDIOC_G_JPEGCOMP, &jpeg_comp ) < 0 ) { + Warning("Failed to get JPEG compression options"); + + } else { + /* Set JPEG flags and quality */ + jpeg_comp.jpeg_markers |= V4L2_JPEG_MARKER_DHT | V4L2_JPEG_MARKER_DQT | V4L2_JPEG_MARKER_DRI; + jpeg_comp.quality = 85; + + /* Update the JPEG options */ + if( vidioctl( vid_fd, VIDIOC_S_JPEGCOMP, &jpeg_comp ) < 0 ) { + Warning("Failed to set JPEG compression options"); + } else { + Debug(4, "JPEG quality: %d",jpeg_comp.quality); + Debug(4, "JPEG markers: %#x",jpeg_comp.jpeg_markers); + } + } + } + Debug( 3, "Setting up request buffers" ); memset( &v4l2_data.reqbufs, 0, sizeof(v4l2_data.reqbufs) ); @@ -1826,6 +1851,7 @@ int LocalCamera::Capture( Image &image ) static uint8_t* buffer = NULL; static uint8_t* directbuffer = NULL; static int capture_frame = -1; + int buffer_bytesused = 0; int captures_per_frame = 1; if ( channel_count > 1 ) @@ -1873,6 +1899,7 @@ int LocalCamera::Capture( Image &image ) Debug( 3, "Captured frame %d/%d from channel %d", capture_frame, v4l2_data.bufptr->sequence, channel ); buffer = (unsigned char *)v4l2_data.buffers[v4l2_data.bufptr->index].start; + buffer_bytesused = v4l2_data.bufptr->bytesused; if(v4l2_data.fmt.fmt.pix.width != width && v4l2_data.fmt.fmt.pix.height != height) { Fatal("Captured image dimensions differ: V4L2: %dx%d monitor: %dx%d",v4l2_data.fmt.fmt.pix.width,v4l2_data.fmt.fmt.pix.height,width,height); @@ -1935,6 +1962,11 @@ int LocalCamera::Capture( Image &image ) /* Call the image conversion function and convert directly into the shared memory */ (*conversion_fptr)(buffer, directbuffer, pixels); } + else if(conversion_type == 3) { + + /* JPEG decoding */ + image.DecodeJpeg(buffer, buffer_bytesused, colours, subpixelorder); + } } else { Debug( 3, "No format conversion performed. Assigning the image" ); diff --git a/web/skins/classic/views/js/monitor.js.php b/web/skins/classic/views/js/monitor.js.php index 11c6dd815..f0d5801a3 100644 --- a/web/skins/classic/views/js/monitor.js.php +++ b/web/skins/classic/views/js/monitor.js.php @@ -66,7 +66,7 @@ function validateForm( form ) errors[errors.length] = ""; if ( form.elements['newMonitor[AlarmMaxFPS]'].value && !(parseFloat(form.elements['newMonitor[AlarmMaxFPS]'].value) > 0 ) ) errors[errors.length] = ""; - if ( !form.elements['newMonitor[RefBlendPerc]'].value || !(parseInt(form.elements['newMonitor[RefBlendPerc]'].value) > 0 ) ) + if ( !form.elements['newMonitor[RefBlendPerc]'].value || (parseInt(form.elements['newMonitor[RefBlendPerc]'].value) > 100 ) || (parseInt(form.elements['newMonitor[RefBlendPerc]'].value) < 0 ) ) errors[errors.length] = ""; if ( form.elements['newMonitor[Type]'].value == 'Local' ) { diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index cb875f25b..06e106a41 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -234,10 +234,10 @@ if ( ZM_HAS_V4L1 ) $SLANG['Grey'] => 1, "BGR32" => 5, "BGR24" => 4, + "*YUYV" => 8, "*RGB565" => 3, "*RGB555" => 6, "*YUV422" => 7, - "*YUYV" => 8, "*YUV422P" => 13, "*YUV420P" => 15 ); @@ -291,6 +291,14 @@ if ( ZM_HAS_V4L2 ) "RGB32" => fourcc('R','G','B','4'), /* 32 RGB-8-8-8-8 */ "BGR24" => fourcc('B','G','R','3'), /* 24 BGR-8-8-8 */ "RGB24" => fourcc('R','G','B','3'), /* 24 RGB-8-8-8 */ + "*YUYV" => fourcc('Y','U','Y','V'), /* 16 YUV 4:2:2 */ + + /* compressed formats */ + "*JPEG" => fourcc('J','P','E','G'), /* JFIF JPEG */ + "*MJPEG" => fourcc('M','J','P','G'), /* Motion-JPEG */ + //"DV" => fourcc('d','v','s','d'), /* 1394 */ + //"MPEG" => fourcc('M','P','E','G'), /* MPEG-1/2/4 */ + //"RGB332" => fourcc('R','G','B','1'), /* 8 RGB-3-3-2 */ "*RGB444" => fourcc('R','4','4','4'), /* 16 xxxxrrrr ggggbbbb */ "*RGB555" => fourcc('R','G','B','O'), /* 16 RGB-5-5-5 */ @@ -301,7 +309,7 @@ if ( ZM_HAS_V4L2 ) //"PAL8" => fourcc('P','A','L','8'), /* 8 8-bit palette */ //"YVU410" => fourcc('Y','V','U','9'), /* 9 YVU 4:1:0 */ //"YVU420" => fourcc('Y','V','1','2'), /* 12 YVU 4:2:0 */ - "*YUYV" => fourcc('Y','U','Y','V'), /* 16 YUV 4:2:2 */ + //"UYVY" => fourcc('U','Y','V','Y'), /* 16 YUV 4:2:2 */ "*YUV422P" => fourcc('4','2','2','P'), /* 16 YVU422 planar */ "*YUV411P" => fourcc('4','1','1','P'), /* 16 YVU411 planar */ @@ -327,12 +335,6 @@ if ( ZM_HAS_V4L2 ) //"SGBRG8" => fourcc('G','B','R','G'), /* 8 GBGB.. RGRG.. */ //"SBGGR16" => fourcc('B','Y','R','2'), /* 16 BGBG.. GRGR.. */ - /* compressed formats */ - "*JPEG" => fourcc('J','P','E','G'), /* JFIF JPEG */ - "*MJPEG" => fourcc('M','J','P','G'), /* Motion-JPEG */ - //"DV" => fourcc('d','v','s','d'), /* 1394 */ - //"MPEG" => fourcc('M','P','E','G'), /* MPEG-1/2/4 */ - /* Vendor-specific formats */ //"WNVA" => fourcc('W','N','V','A'), /* Winnov hw compress */ //"SN9C10X" => fourcc('S','9','1','0'), /* SN9C10x compression */ diff --git a/web/skins/classic/views/monitorprobe.php b/web/skins/classic/views/monitorprobe.php index 45a2d490e..88783dfd9 100644 --- a/web/skins/classic/views/monitorprobe.php +++ b/web/skins/classic/views/monitorprobe.php @@ -45,7 +45,7 @@ if ( ZM_HAS_V4L2 ) $devices = array(); $preferredStandards = array( 'PAL', 'NTSC' ); - $preferredFormats = array( 'BGR4', 'RGB4', 'BGR3', 'RGB3', 'YUYV', '422P', 'GREY'); + $preferredFormats = array( 'BGR4', 'RGB4', 'BGR3', 'RGB3', 'YUYV', 'JPEG', 'MJPG', '422P', 'GREY'); foreach ( $output as $line ) { if ( !preg_match( '/^d:([^|]+).*S:([^|]*).*F:([^|]+).*I:(\d+)\|(.+)$/', $line, $deviceMatches ) ) From 066fe89718d854b549143e0c5762913ec8b0d215 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sat, 2 Jul 2011 15:32:16 +0300 Subject: [PATCH 22/56] Added automatic capture palette selection. --- src/zm_config.h.in | 2 +- src/zm_local_camera.cpp | 101 ++++++++++++++++++++++- src/zm_local_camera.h | 54 ++++++------ web/skins/classic/views/monitor.php | 9 +- web/skins/classic/views/monitorprobe.php | 2 +- 5 files changed, 127 insertions(+), 41 deletions(-) diff --git a/src/zm_config.h.in b/src/zm_config.h.in index a048b6e3d..01098c90f 100644 --- a/src/zm_config.h.in +++ b/src/zm_config.h.in @@ -38,7 +38,7 @@ #define ZM_MAX_IMAGE_WIDTH 2048 // The largest image we imagine ever handling #define ZM_MAX_IMAGE_HEIGHT 1536 // The largest image we imagine ever handling -#define ZM_MAX_IMAGE_COLOURS 3 // The largest image we imagine ever handling +#define ZM_MAX_IMAGE_COLOURS 4 // The largest image we imagine ever handling #define ZM_MAX_IMAGE_DIM (ZM_MAX_IMAGE_WIDTH*ZM_MAX_IMAGE_HEIGHT) #define ZM_MAX_IMAGE_SIZE (ZM_MAX_IMAGE_DIM*ZM_MAX_IMAGE_COLOURS) diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 25bc98cf5..5f869ff03 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -251,6 +251,15 @@ static PixelFormat getFfPixFormatFromV4lPalette( int v4l_version, int palette ) } #endif // HAVE_LIBSWSCALE +#if ZM_HAS_V4L2 +static char palette_desc[32]; +/* Automatic format selection prefered formats */ +static const uint32_t prefered_rgb32_formats[] = {V4L2_PIX_FMT_BGR32, V4L2_PIX_FMT_RGB32, V4L2_PIX_FMT_BGR24, V4L2_PIX_FMT_RGB24, V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_UYVY, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_MJPEG, V4L2_PIX_FMT_YUV422P, V4L2_PIX_FMT_YUV420}; +static const uint32_t prefered_rgb24_formats[] = {V4L2_PIX_FMT_BGR24, V4L2_PIX_FMT_RGB24, V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_UYVY, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_MJPEG, V4L2_PIX_FMT_YUV422P, V4L2_PIX_FMT_YUV420}; +static const uint32_t prefered_gray8_formats[] = {V4L2_PIX_FMT_GREY, V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_UYVY, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_MJPEG, V4L2_PIX_FMT_YUV422P, V4L2_PIX_FMT_YUV420}; +#endif + + int LocalCamera::camera_count = 0; int LocalCamera::channel_count = 0; int LocalCamera::channels[VIDEO_MAX_FRAME]; @@ -336,6 +345,19 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, BigEndian = 0; } +#if ZM_HAS_V4L2 + if( v4l_version == 2 && palette == 0 ) { + /* Use automatic format selection */ + Debug(2,"Using automatic format selection"); + palette = AutoSelectFormat(colours); + if(palette == 0) { + Error("Automatic format selection failed. Falling back to YUYV"); + palette = V4L2_PIX_FMT_YUYV; + } else { + Debug(2,"Selected capture palette: %s (%c%c%c%c)",palette_desc,palette&0xff, (palette>>8)&0xff, (palette>>16)&0xff, (palette>>24)&0xff ); + } + } +#endif #if HAVE_LIBSWSCALE if( capture ) { @@ -343,8 +365,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, capturePixFormat = getFfPixFormatFromV4lPalette( v4l_version, palette ); imagePixFormat = PIX_FMT_NONE; } -#endif // HAVE_LIBSWSCALE - +#endif // HAVE_LIBSWSCALE /* V4L2 format matching */ #if ZM_HAS_V4L2 @@ -1054,6 +1075,82 @@ void LocalCamera::Terminate() } +uint32_t LocalCamera::AutoSelectFormat(int p_colours) { + /* Automatic format selection */ + uint32_t selected_palette = 0; +#if ZM_HAS_V4L2 + char fmt_desc[64][32]; + uint32_t fmt_fcc[64]; + v4l2_fmtdesc fmtinfo; + unsigned int nIndex = 0; + int nRet = 0; + int enum_fd; + + /* Open the device */ + if ((enum_fd = open( device.c_str(), O_RDWR, 0 )) < 0) { + Error( "Failed to open video device %s: %s", device.c_str(), strerror(errno) ); + return selected_palette; + } + + /* Enumerate available formats */ + memset(&fmtinfo, 0, sizeof(fmtinfo)); + fmtinfo.index = nIndex; + fmtinfo.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + while(vidioctl( enum_fd, VIDIOC_ENUM_FMT, &fmtinfo ) >= 0) { + /* Got a format. Copy it to the array */ + strcpy(fmt_desc[nIndex], (const char*)(fmtinfo.description)); + fmt_fcc[nIndex] = fmtinfo.pixelformat; + + Debug(6, "Got format: %s (%c%c%c%c) at index %d",fmt_desc[nIndex],fmt_fcc[nIndex]&0xff, (fmt_fcc[nIndex]>>8)&0xff, (fmt_fcc[nIndex]>>16)&0xff, (fmt_fcc[nIndex]>>24)&0xff ,nIndex); + + /* Proceed to the next index */ + memset(&fmtinfo, 0, sizeof(fmtinfo)); + fmtinfo.index = ++nIndex; + fmtinfo.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + } + + /* Select format */ + int nIndexUsed = -1; + int n_preferedformats = 0; + const uint32_t* preferedformats; + if(p_colours == ZM_COLOUR_RGB32) { + /* 32bit */ + preferedformats = prefered_rgb32_formats; + n_preferedformats = sizeof(prefered_rgb32_formats) / sizeof(uint32_t); + } else if(p_colours == ZM_COLOUR_GRAY8) { + /* Grayscale */ + preferedformats = prefered_gray8_formats; + n_preferedformats = sizeof(prefered_gray8_formats) / sizeof(uint32_t); + } else { + /* Assume 24bit */ + preferedformats = prefered_rgb24_formats; + n_preferedformats = sizeof(prefered_rgb24_formats) / sizeof(uint32_t); + } + for( unsigned int i=0; i < n_preferedformats && nIndexUsed < 0; i++ ) { + for( unsigned int j=0; j < nIndex; j++ ) { + if( preferedformats[i] == fmt_fcc[j] ) { + /* Found a format! */ + nIndexUsed = j; + break; + } + } + } + + /* Have we found a match? */ + if(nIndexUsed >= 0) { + /* Found a match */ + selected_palette = fmt_fcc[nIndexUsed]; + strcpy(palette_desc,fmt_desc[nIndexUsed]); + } + + /* Close the device */ + close(enum_fd); + +#endif /* ZM_HAS_V4L2 */ + return selected_palette; +} + + #define capString(test,prefix,yesString,noString,capability) \ (test) ? (prefix yesString " " capability "\n") : (prefix noString " " capability "\n") diff --git a/src/zm_local_camera.h b/src/zm_local_camera.h index 6de50b417..dab651d80 100644 --- a/src/zm_local_camera.h +++ b/src/zm_local_camera.h @@ -64,38 +64,40 @@ protected: #if ZM_HAS_V4L1 struct V4L1Data { - int active_frame; - video_mbuf frames; - video_mmap *buffers; - unsigned char *bufptr; + int active_frame; + video_mbuf frames; + video_mmap *buffers; + unsigned char *bufptr; }; #endif // ZM_HAS_V4L1 protected: - std::string device; - int channel; - int standard; - int palette; - - bool device_prime; - bool channel_prime; - int channel_index; + std::string device; + int channel; + int standard; + int palette; + bool device_prime; + bool channel_prime; + int channel_index; + + unsigned int conversion_type; /* 0 = no conversion needed, 1 = use libswscale, 2 = zm internal conversion, 3 = jpeg decoding */ + convert_fptr_t conversion_fptr; /* Pointer to conversion function used */ + + uint32_t AutoSelectFormat(int p_colours); protected: - static int camera_count; - static int channel_count; - static int channels[VIDEO_MAX_FRAME]; - static int standards[VIDEO_MAX_FRAME]; - - static int vid_fd; - - static int v4l_version; + static int camera_count; + static int channel_count; + static int channels[VIDEO_MAX_FRAME]; + static int standards[VIDEO_MAX_FRAME]; + static int vid_fd; + static int v4l_version; #if ZM_HAS_V4L2 - static V4L2Data v4l2_data; + static V4L2Data v4l2_data; #endif // ZM_HAS_V4L2 #if ZM_HAS_V4L1 - static V4L1Data v4l1_data; + static V4L1Data v4l1_data; #endif // ZM_HAS_V4L1 #if HAVE_LIBSWSCALE @@ -108,14 +110,6 @@ protected: static LocalCamera *last_camera; - /* 0 = no conversion needed, 1 = use libswscale, 2 = zm internal conversion */ - unsigned int conversion_type; - /* Pointer to conversion function used */ - convert_fptr_t conversion_fptr; - - - - public: LocalCamera( int p_id, const std::string &device, int p_channel, int p_format, const std::string &p_method, int p_width, int p_height, int p_colours, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ); ~LocalCamera(); diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 06e106a41..96f978ee4 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -65,7 +65,7 @@ else 'Path' => "", 'Port' => "80", 'Colours' => 4, - 'Palette' => fourcc('B','G','R','4'), + 'Palette' => 0, 'Width' => "320", 'Height' => "240", 'Orientation' => "0", @@ -165,8 +165,6 @@ if ( !empty($_REQUEST['probe']) ) $newMonitor['Format'] = 0x000000ff; elseif ( $newMonitor['Format'] == 'NTSC' ) $newMonitor['Format'] = 0x0000b000; - else - $newMonitor['Format'] = ''; } } @@ -213,7 +211,6 @@ unset($httpMethods['jpegTags']); if ( ZM_HAS_V4L1 ) { $v4l1DeviceFormats = array( - $SLANG['Undefined'] => '', "PAL" => 0, "NTSC" => 1, "SECAM" => 2, @@ -230,7 +227,6 @@ if ( ZM_HAS_V4L1 ) $v4l1DeviceChannels["$i"] = $i; $v4l1LocalPalettes = array( - $SLANG['Undefined'] => '', $SLANG['Grey'] => 1, "BGR32" => 5, "BGR24" => 4, @@ -246,7 +242,6 @@ if ( ZM_HAS_V4L1 ) if ( ZM_HAS_V4L2 ) { $v4l2DeviceFormats = array( - $SLANG['Undefined'] => '', "PAL" => 0x000000ff, "NTSC" => 0x0000b000, "PAL B" => 0x00000001, @@ -283,7 +278,7 @@ if ( ZM_HAS_V4L2 ) $v4l2DeviceChannels["$i"] = $i; $v4l2LocalPalettes = array( - $SLANG['Undefined'] => '', + "Auto" => 0, /* Automatic palette selection */ /* Pixel format FOURCC depth Description */ $SLANG['Grey'] => fourcc('G','R','E','Y'), /* 8 Greyscale */ diff --git a/web/skins/classic/views/monitorprobe.php b/web/skins/classic/views/monitorprobe.php index 88783dfd9..eaa4a5cf8 100644 --- a/web/skins/classic/views/monitorprobe.php +++ b/web/skins/classic/views/monitorprobe.php @@ -45,7 +45,7 @@ if ( ZM_HAS_V4L2 ) $devices = array(); $preferredStandards = array( 'PAL', 'NTSC' ); - $preferredFormats = array( 'BGR4', 'RGB4', 'BGR3', 'RGB3', 'YUYV', 'JPEG', 'MJPG', '422P', 'GREY'); + $preferredFormats = array( 'BGR4', 'RGB4', 'BGR3', 'RGB3', 'YUYV', 'UYVY', 'JPEG', 'MJPG', '422P', 'YU12', 'GREY'); foreach ( $output as $line ) { if ( !preg_match( '/^d:([^|]+).*S:([^|]*).*F:([^|]+).*I:(\d+)\|(.+)$/', $line, $deviceMatches ) ) From 7e0206bbcc4b89cf1dff3f6b90e04ede36aeda01 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sat, 2 Jul 2011 15:38:34 +0300 Subject: [PATCH 23/56] Disable zm_event.cpp deleting the diagnostic images every second --- src/zm_event.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 76e36577c..88ce48415 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -600,7 +600,8 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image * WriteFrameImage( alarm_image, timestamp, event_file, true ); } } - + + /* This makes viewing the diagnostic images impossible because it keeps deleting them if ( config.record_diag_images ) { char diag_glob[PATH_MAX] = ""; @@ -641,6 +642,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image * } globfree( &pglob ); } + */ } bool EventStream::loadInitialEventData( int monitor_id, time_t event_time ) From ca57ae643898f4aaac9da11f8d7bfcdcec96bc5d Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 5 Jul 2011 18:23:02 +0300 Subject: [PATCH 24/56] 1) Fixed and refinished the JPEG and MJPEG capture palettes support. 2) Added the SSE2 alarmedpixels code, although its unused at the moment. 3) Small changes in libjpeg interaction. 4) Small other changes. --- src/zm_image.cpp | 34 +++- src/zm_jpeg.cpp | 71 +++++++ src/zm_jpeg.h | 2 + src/zm_local_camera.cpp | 33 ++-- src/zm_utils.cpp | 8 +- src/zm_zone.cpp | 424 ++++++++++++++++++++++++++++++++-------- src/zm_zone.h | 6 +- 7 files changed, 470 insertions(+), 108 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index ae511d881..121dcf1ca 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -580,7 +580,12 @@ bool Image::ReadJpeg( const char *filename, int p_colours, int p_subpixelorder) jpeg_stdio_src( cinfo, infile ); jpeg_read_header( cinfo, TRUE ); - + + /* Check if the image has huffman tables defined. If not, add the standard ones */ + if(cinfo->dc_huff_tbl_ptrs[0] == NULL || cinfo->ac_huff_tbl_ptrs[0] == NULL) { + zm_add_std_huff_tables(cinfo); + } + if ( cinfo->image_width != width || cinfo->image_height != height) { width = cinfo->image_width; @@ -642,11 +647,14 @@ bool Image::ReadJpeg( const char *filename, int p_colours, int p_subpixelorder) #endif } else { /* Assume RGB */ +/* #ifdef JCS_EXTENSIONS cinfo->out_color_space = JCS_EXT_RGB; #else cinfo->out_color_space = JCS_RGB; #endif +*/ + cinfo->out_color_space = JCS_RGB; subpixelorder = ZM_SUBPIX_ORDER_RGB; } break; @@ -763,11 +771,14 @@ bool Image::WriteJpeg( const char *filename, int quality_override ) const #endif } else { /* Assume RGB */ +/* #ifdef JCS_EXTENSIONS - cinfo->in_color_space = JCS_EXT_RGB; + cinfo->out_color_space = JCS_EXT_RGB; #else + cinfo->out_color_space = JCS_RGB; +#endif +*/ cinfo->in_color_space = JCS_RGB; -#endif } break; } @@ -820,6 +831,11 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, int p_colours zm_jpeg_mem_src( cinfo, inbuffer, inbuffer_size ); jpeg_read_header( cinfo, TRUE ); + + /* Check if the image has huffman tables defined. If not, add the standard ones */ + if(cinfo->dc_huff_tbl_ptrs[0] == NULL || cinfo->ac_huff_tbl_ptrs[0] == NULL) { + zm_add_std_huff_tables(cinfo); + } if ( cinfo->image_width != width || cinfo->image_height != height) { @@ -881,11 +897,14 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, int p_colours #endif } else { /* Assume RGB */ +/* #ifdef JCS_EXTENSIONS cinfo->out_color_space = JCS_EXT_RGB; #else cinfo->out_color_space = JCS_RGB; -#endif +#endif +*/ + cinfo->out_color_space = JCS_RGB; subpixelorder = ZM_SUBPIX_ORDER_RGB; } break; @@ -992,11 +1011,14 @@ bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_over #endif } else { /* Assume RGB */ +/* #ifdef JCS_EXTENSIONS - cinfo->in_color_space = JCS_EXT_RGB; + cinfo->out_color_space = JCS_EXT_RGB; #else + cinfo->out_color_space = JCS_RGB; +#endif +*/ cinfo->in_color_space = JCS_RGB; -#endif } break; } diff --git a/src/zm_jpeg.cpp b/src/zm_jpeg.cpp index ed745f973..7158e0d8a 100644 --- a/src/zm_jpeg.cpp +++ b/src/zm_jpeg.cpp @@ -392,4 +392,75 @@ void zm_jpeg_mem_src( j_decompress_ptr cinfo, const JOCTET *inbuffer, int inbuff src->pub.next_input_byte = NULL; /* until buffer loaded */ } +void zm_add_std_huff_tables( j_decompress_ptr cinfo ) { +/* JPEG standard Huffman tables (cf. JPEG standard section K.3) */ +/* IMPORTANT: these are only valid for 8-bit data precision! */ + static const JHUFF_TBL dclumin = { + { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }, + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, + 0 + }; + static const JHUFF_TBL dcchrome = { + { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }, + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, + 0 + }; + static const JHUFF_TBL aclumin = { + { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }, + { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, + 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, + 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, + 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, + 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, + 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, + 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, + 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, + 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, + 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, + 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, + 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }, + 0 + }; + static const JHUFF_TBL acchrome = { + { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }, + { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, + 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, + 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, + 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, + 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, + 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, + 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, + 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, + 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, + 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, + 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, + 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, + 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, + 0xf9, 0xfa }, + 0 + }; + + cinfo->dc_huff_tbl_ptrs[0] = &dclumin; + cinfo->dc_huff_tbl_ptrs[1] = &dcchrome; + cinfo->ac_huff_tbl_ptrs[0] = &aclumin; + cinfo->ac_huff_tbl_ptrs[1] = &acchrome; + +} + } diff --git a/src/zm_jpeg.h b/src/zm_jpeg.h index 85df4c491..188b75af0 100644 --- a/src/zm_jpeg.h +++ b/src/zm_jpeg.h @@ -44,4 +44,6 @@ void zm_jpeg_emit_message( j_common_ptr cinfo, int msg_level ); // Prototypes for memory compress/decompression object */ void zm_jpeg_mem_src(j_decompress_ptr cinfo, const JOCTET *inbuffer, int inbuffer_size ); void zm_jpeg_mem_dest(j_compress_ptr cinfo, JOCTET *outbuffer, int *outbuffer_size ); + +void zm_add_std_huff_tables( j_decompress_ptr cinfo ); } diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 5f869ff03..e91df4962 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -399,7 +399,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, /* Unable to find a solution for the selected palette and target colourspace. Conversion required. Notify the user of performance penalty */ } else { if( capture ) - Warning("Unable to find a match for the selected palette and target colourspace. Conversion required, performance penalty expected"); + Warning("No match for the selected palette and colourspace. Conversion required, performance penalty expected"); #if HAVE_LIBSWSCALE /* Try using swscale for the conversion */ conversion_type = 1; @@ -437,6 +437,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, /* JPEG */ if(palette == V4L2_PIX_FMT_JPEG || palette == V4L2_PIX_FMT_MJPEG) { + Debug(2,"Using JPEG image decoding"); conversion_type = 3; } @@ -514,7 +515,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, /* Unable to find a solution for the selected palette and target colourspace. Conversion required. Notify the user of performance penalty */ } else { if( capture ) - Warning("Unable to find a match for the selected palette and target colourspace. Conversion required, performance penalty expected"); + Warning("No match for the selected palette and colourspace. Conversion required, performance penalty expected"); #if HAVE_LIBSWSCALE /* Try using swscale for the conversion */ conversion_type = 1; @@ -743,19 +744,27 @@ void LocalCamera::Initialise() v4l2_jpegcompression jpeg_comp; if(palette == V4L2_PIX_FMT_JPEG || palette == V4L2_PIX_FMT_MJPEG) { if( vidioctl( vid_fd, VIDIOC_G_JPEGCOMP, &jpeg_comp ) < 0 ) { - Warning("Failed to get JPEG compression options"); + Warning("Failed to get JPEG compression options: %s", strerror(errno) ); } else { - /* Set JPEG flags and quality */ - jpeg_comp.jpeg_markers |= V4L2_JPEG_MARKER_DHT | V4L2_JPEG_MARKER_DQT | V4L2_JPEG_MARKER_DRI; + /* Set flags and quality. MJPEG should not have the huffman tables defined */ + if(palette == V4L2_PIX_FMT_MJPEG) { + jpeg_comp.jpeg_markers |= V4L2_JPEG_MARKER_DQT | V4L2_JPEG_MARKER_DRI; + } else { + jpeg_comp.jpeg_markers |= V4L2_JPEG_MARKER_DQT | V4L2_JPEG_MARKER_DRI | V4L2_JPEG_MARKER_DHT; + } jpeg_comp.quality = 85; /* Update the JPEG options */ if( vidioctl( vid_fd, VIDIOC_S_JPEGCOMP, &jpeg_comp ) < 0 ) { - Warning("Failed to set JPEG compression options"); + Warning("Failed to set JPEG compression options: %s", strerror(errno) ); } else { - Debug(4, "JPEG quality: %d",jpeg_comp.quality); - Debug(4, "JPEG markers: %#x",jpeg_comp.jpeg_markers); + if(vidioctl( vid_fd, VIDIOC_G_JPEGCOMP, &jpeg_comp ) < 0) { + Debug(3,"Failed to get updated JPEG compression options: %s", strerror(errno) ); + } else { + Debug(4, "JPEG quality: %d",jpeg_comp.quality); + Debug(4, "JPEG markers: %#x",jpeg_comp.jpeg_markers); + } } } } @@ -1088,7 +1097,7 @@ uint32_t LocalCamera::AutoSelectFormat(int p_colours) { /* Open the device */ if ((enum_fd = open( device.c_str(), O_RDWR, 0 )) < 0) { - Error( "Failed to open video device %s: %s", device.c_str(), strerror(errno) ); + Error( "Automatic format selection failed to open video device %s: %s", device.c_str(), strerror(errno) ); return selected_palette; } @@ -2047,20 +2056,22 @@ int LocalCamera::Capture( Image &image ) } #if HAVE_LIBSWSCALE if(conversion_type == 1) { + + Debug( 9, "Calling sws_scale to perform the conversion" ); /* Use swscale to convert the image directly into the shared memory */ - avpicture_fill( (AVPicture *)tmpPicture, directbuffer, imagePixFormat, width, height ); - sws_scale( imgConversionContext, capturePictures[capture_frame]->data, capturePictures[capture_frame]->linesize, 0, height, tmpPicture->data, tmpPicture->linesize ); } #endif if(conversion_type == 2) { + Debug( 9, "Calling the conversion function" ); /* Call the image conversion function and convert directly into the shared memory */ (*conversion_fptr)(buffer, directbuffer, pixels); } else if(conversion_type == 3) { + Debug( 9, "Decoding the JPEG image" ); /* JPEG decoding */ image.DecodeJpeg(buffer, buffer_bytesused, colours, subpixelorder); } diff --git a/src/zm_utils.cpp b/src/zm_utils.cpp index 4853b4cc0..3cd081692 100644 --- a/src/zm_utils.cpp +++ b/src/zm_utils.cpp @@ -199,7 +199,7 @@ __attribute__((noinline)) void* sse2_aligned_memcpy(void* dest, const void* src, const uint8_t* lastsrc = (uint8_t*)src + (bytes - remainder); __asm__ __volatile__( - "sse2copy_begin:\n\t" + "sse2_copy_iter:\n\t" "movdqa (%0),%%xmm0\n\t" "movdqa 0x10(%0),%%xmm1\n\t" "movdqa 0x20(%0),%%xmm2\n\t" @@ -219,12 +219,12 @@ __attribute__((noinline)) void* sse2_aligned_memcpy(void* dest, const void* src, "add $0x80, %0\n\t" "add $0x80, %1\n\t" "cmp %2, %0\n\t" - "jb sse2copy_begin\n\t" + "jb sse2_copy_iter\n\t" "test %3, %3\n\t" - "jz sse2copy_finish\n\t" + "jz sse2_copy_finish\n\t" "cld\n\t" "rep movsb\n\t" - "sse2copy_finish:\n\t" + "sse2_copy_finish:\n\t" : : "S" (src), "D" (dest), "r" (lastsrc), "c" (remainder) : "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "cc", "memory" diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index c66e6c517..c67932919 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -60,38 +60,45 @@ void Zone::Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_ image = 0; score = 0; - overload_count = 0; + overload_count = 0; pg_image = new Image( monitor->Width(), monitor->Height(), 1, ZM_SUBPIX_ORDER_NONE); + pg_image->Clear(); pg_image->Fill( 0xff, polygon ); pg_image->Outline( 0xff, polygon ); - pg_image->Crop( polygon.LoX(), polygon.LoY(), polygon.HiX(), polygon.HiY() ); - ranges = new Range[polygon.Height()]; - int y = polygon.LoY(); - for ( int py = 0; py < polygon.Height(); py++, y++ ) + ranges = new Range[monitor->Height()]; + for ( int y = polygon.LoY(); y <= polygon.HiY(); y++) { - int x = polygon.LoX(); - ranges[py].lo_x = -1; - ranges[py].hi_x = -1; - ranges[py].off_x = 0; - const uint8_t *ppoly = pg_image->Buffer( 0, py ); - for ( int px = 0; px < polygon.Width(); px++, x++, ppoly++ ) + ranges[y].lo_x = -1; + ranges[y].hi_x = -1; + ranges[y].off_x = 0; + const uint8_t *ppoly = pg_image->Buffer( polygon.LoX(), y ); + for ( int x = polygon.LoX(); x <= polygon.HiX(); x++, ppoly++ ) { if ( *ppoly ) { - if ( ranges[py].lo_x == -1 ) + if ( ranges[y].lo_x == -1 ) { - ranges[py].lo_x = x; - ranges[py].off_x = px; + ranges[y].lo_x = x; } - if ( ranges[py].hi_x < x ) + if ( ranges[y].hi_x < x ) { - ranges[py].hi_x = x; + ranges[y].hi_x = x; } } } } + + if ( config.record_diag_images ) + { + static char diag_path[PATH_MAX] = ""; + if ( !diag_path[0] ) + { + snprintf( diag_path, sizeof(diag_path), "%s/%s/diag-%d-poly.jpg", config.dir_events, monitor->Name(), id); + } + pg_image->WriteJpeg( diag_path ); + } } Zone::~Zone() @@ -119,21 +126,23 @@ bool Zone::CheckAlarms( const Image *delta_image ) ResetStats(); - if ( overload_count ) - { - Info( "In overload mode, %d frames of %d remaining", overload_count, overload_frames ); - Debug( 4, "In overload mode, %d frames of %d remaining", overload_count, overload_frames ); - overload_count--; - return( false ); - } + if ( overload_count ) + { + Info( "In overload mode, %d frames of %d remaining", overload_count, overload_frames ); + Debug( 4, "In overload mode, %d frames of %d remaining", overload_count, overload_frames ); + overload_count--; + return( false ); + } delete image; // Get the difference image Image *diff_image = image = new Image( *delta_image ); int diff_width = diff_image->Width(); uint8_t* diff_buff = (uint8_t*)diff_image->Buffer(); + uint8_t* pdiff; + const uint8_t* ppoly; - unsigned long pixel_diff_count = 0; + unsigned int pixel_diff_count = 0; int alarm_lo_x = 0; int alarm_hi_x = 0; @@ -142,47 +151,27 @@ bool Zone::CheckAlarms( const Image *delta_image ) int alarm_mid_x = -1; int alarm_mid_y = -1; - - int lo_y = polygon.LoY(); - int hi_y = polygon.HiY(); - int lo_x; - int hi_x; + + unsigned int lo_y = polygon.LoY(); + unsigned int lo_x = polygon.LoX(); + unsigned int hi_x = polygon.HiX()+1; + unsigned int hi_y = polygon.HiY()+1; Debug( 4, "Checking alarms for zone %d/%s in lines %d -> %d", id, label, lo_y, hi_y ); - - Debug( 5, "Checking for alarmed pixels" ); - uint8_t *pdiff; - const uint8_t *ppoly; - uint8_t calc_max_pixel_threshold = 255; /* To be able to remove one check from the loop below */ - if(max_pixel_threshold) - calc_max_pixel_threshold = max_pixel_threshold; - for ( int y = lo_y, py = 0; y <= hi_y; y++, py++ ) - { - lo_x = ranges[py].lo_x; - hi_x = ranges[py].hi_x; - - Debug( 7, "Checking line %d from %d -> %d", y, lo_x, hi_x ); - pdiff = diff_buff + ((diff_width * y) + lo_x); - ppoly = pg_image->Buffer( ranges[py].off_x, py ); - - for ( int x = lo_x; x <= hi_x; x++, pdiff++, ppoly++ ) - { - if ( *ppoly && (*pdiff > min_pixel_threshold) && (*pdiff <= calc_max_pixel_threshold) ) - { - alarm_pixels++; - pixel_diff_count += *pdiff; - *pdiff = WHITE; - } - else - { - *pdiff = BLACK; - } - } - } + + Debug( 5, "Checking for alarmed pixels" ); + /* if(config.cpu_extensions && sseversion >= 20) { + sse2_alarmedpixels(diff_image, pg_image, &alarm_pixels, &pixel_diff_count); + } else { + std_alarmedpixels(diff_image, pg_image, &alarm_pixels, &pixel_diff_count); + } */ + std_alarmedpixels(diff_image, pg_image, &alarm_pixels, &pixel_diff_count); + if ( pixel_diff_count && alarm_pixels ) pixel_diff = pixel_diff_count/alarm_pixels; Debug( 5, "Got %d alarmed pixels, need %d -> %d, avg pixel diff %d", alarm_pixels, min_alarm_pixels, max_alarm_pixels, pixel_diff ); + if ( config.record_diag_images ) { static char diag_path[PATH_MAX] = ""; @@ -193,22 +182,26 @@ bool Zone::CheckAlarms( const Image *delta_image ) diff_image->WriteJpeg( diag_path ); } - if ( !alarm_pixels ) - { - return( false ); - } - if ( min_alarm_pixels && (alarm_pixels < min_alarm_pixels) ) - { - return( false ); - } - if ( max_alarm_pixels && (alarm_pixels > max_alarm_pixels) ) - { - overload_count = overload_frames; - return( false ); - } + if( alarm_pixels ) { + if( min_alarm_pixels && (alarm_pixels < min_alarm_pixels) ) { + /* Not enough pixels alarmed */ + return (false); + } else if( max_alarm_pixels && (alarm_pixels > max_alarm_pixels) ) { + /* Too many pixels alarmed */ + overload_count = overload_frames; + return (false); + } + } else { + /* No alarmed pixels */ + return (false); + } + + score = (100*alarm_pixels)/polygon.Area(); + if(score < 1) + score = 1; /* Fix for score of 0 when frame meets thresholds but alarmed area is not big enough */ Debug( 5, "Current score is %d", score ); - + if ( check_method >= FILTERED_PIXELS ) { int bx = filter_box.X(); @@ -223,12 +216,12 @@ bool Zone::CheckAlarms( const Image *delta_image ) unsigned char *cpdiff; int ldx, hdx, ldy, hdy; bool block; - for ( int y = lo_y, py = 0; y <= hi_y; y++, py++ ) + for ( int y = lo_y; y <= hi_y; y++ ) { - lo_x = ranges[py].lo_x; - hi_x = ranges[py].hi_x; + lo_x = ranges[y].lo_x; + hi_x = ranges[y].hi_x; - pdiff = diff_buff + ((diff_width * y) + lo_x); + pdiff = (uint8_t*)diff_image->Buffer( lo_x, y ); for ( int x = lo_x; x <= hi_x; x++, pdiff++ ) { @@ -310,12 +303,12 @@ bool Zone::CheckAlarms( const Image *delta_image ) int last_x, last_y; BlobStats *bsx, *bsy; BlobStats *bsm, *bss; - for ( int y = lo_y, py = 0; y <= hi_y; y++, py++ ) + for ( int y = lo_y; y <= hi_y; y++ ) { - int lo_x = ranges[py].lo_x; - int hi_x = ranges[py].hi_x; + int lo_x = ranges[y].lo_x; + int hi_x = ranges[y].hi_x; - pdiff = diff_buff + ((diff_width * y) + lo_x); + pdiff = (uint8_t*)diff_image->Buffer( lo_x, y ); for ( int x = lo_x; x <= hi_x; x++, pdiff++ ) { if ( *pdiff == WHITE ) @@ -632,11 +625,14 @@ bool Zone::CheckAlarms( const Image *delta_image ) if ( type == INCLUSIVE ) { + // score >>= 1; score /= 2; } else if ( type == EXCLUSIVE ) { + // score <<= 1; score *= 2; + } Debug( 5, "Adjusted score is %d", score ); @@ -665,12 +661,12 @@ bool Zone::CheckAlarms( const Image *delta_image ) int lo_y = polygon.LoY(); int hi_y = polygon.HiY(); // First mask out anything we don't want - for ( int y = lo_y, py = 0; y <= hi_y; y++, py++ ) + for ( int y = lo_y; y <= hi_y; y++ ) { pdiff = diff_buff + ((diff_width * y) + lo_x); - int lo_x2 = ranges[py].lo_x; - int hi_x2 = ranges[py].hi_x; + int lo_x2 = ranges[y].lo_x; + int hi_x2 = ranges[y].hi_x; int lo_gap = lo_x2-lo_x; if ( lo_gap > 0 ) @@ -686,7 +682,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) } } - ppoly = pg_image->Buffer( lo_gap, py ); + ppoly = pg_image->Buffer( lo_gap, y ); for ( int x = lo_x2; x <= hi_x2; x++, pdiff++, ppoly++ ) { if ( !*ppoly ) @@ -963,3 +959,261 @@ bool Zone::DumpSettings( char *output, bool /*verbose*/ ) return( true ); } +void Zone::std_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsigned int* pixel_count, unsigned int* pixel_sum) { + uint32_t pixelsalarmed = 0; + uint32_t pixelsdifference = 0; + uint8_t *pdiff; + const uint8_t *ppoly; + uint8_t calc_max_pixel_threshold = 255; + unsigned int lo_y; + unsigned int hi_y; + unsigned int lo_x; + unsigned int hi_x; + + if(max_pixel_threshold) + calc_max_pixel_threshold = max_pixel_threshold; + + lo_y = polygon.LoY(); + hi_y = polygon.HiY(); + for ( int y = lo_y; y <= hi_y; y++ ) + { + lo_x = ranges[y].lo_x; + hi_x = ranges[y].hi_x; + + Debug( 7, "Checking line %d from %d -> %d", y, lo_x, hi_x ); + pdiff = (uint8_t*)pdiff_image->Buffer( lo_x, y ); + ppoly = ppoly_image->Buffer( lo_x, y ); + + for ( int x = lo_x; x <= hi_x; x++, pdiff++, ppoly++ ) + { + if ( *ppoly && (*pdiff > min_pixel_threshold) && (*pdiff <= calc_max_pixel_threshold) ) + { + pixelsalarmed++; + pixelsdifference += *pdiff; + *pdiff = WHITE; + } + else + { + *pdiff = BLACK; + } + } + } + + /* Store the results */ + *pixel_count = pixelsalarmed; + *pixel_sum = pixelsdifference; +} + +void Zone::sse2_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsigned int* pixel_count, unsigned int* pixel_sum) { +#if (defined(__i386__) || defined(__x86_64__)) + __attribute__((aligned(16))) static uint8_t calc_maxpthreshold[16] = {127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127}; + __attribute__((aligned(16))) static uint8_t calc_minpthreshold[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + static uint8_t current_minpthreshold = 0; + static uint8_t current_maxpthreshold = 255; + unsigned int minpthreshold = min_pixel_threshold; + unsigned int maxpthreshold = max_pixel_threshold; + uint32_t pixelsalarmed = 0; + uint32_t pixelsdifference = 0; + unsigned int lo_y = polygon.LoY(); + unsigned int hi_y = polygon.HiY()+1; + unsigned int lo_x = polygon.LoX(); + unsigned int hi_x = polygon.HiX()+1; + + if(maxpthreshold == 0) + maxpthreshold = 255; + + if(minpthreshold != current_minpthreshold) { + for(unsigned int i=0;i>1; + current_minpthreshold = minpthreshold; + } + + if(maxpthreshold != current_maxpthreshold) { + for(unsigned int i=0;i>1; + current_maxpthreshold = maxpthreshold; + } + + /* + * We have to work on 16 byte aligned addresses. + * Assume width is multiples of 16 and align the lo_x and hi_x to be on a 16 byte boundary + */ + if((lo_x % 16) != 0) { + lo_x = lo_x - (lo_x % 16); + } + if((hi_x % 16) != 0) { + hi_x = hi_x + (16 - (hi_x % 16)); + if( hi_x > pdiff_image->Width() ) + /* Clamp hi_x to width */ + hi_x = pdiff_image->Width(); + } + if( hi_y > pdiff_image->Height() ) { + /* Clamp hi y to height */ + hi_y = pdiff_image->Height(); + } + + unsigned int x = lo_x; + unsigned int y = lo_y; + unsigned long xgap = hi_x - lo_x; + unsigned long width = pdiff_image->Width(); + uint8_t* pdiff = (uint8_t*)pdiff_image->Buffer(lo_x, lo_y); + const uint8_t* ppoly = ppoly_image->Buffer(lo_x, lo_y); + + /* Some sanity checks */ + if((width % 16) != 0) { + Fatal("Image width is not multiples of 16!"); + } + if((xgap % 16) != 0) { + /* Shouldn't happen but just in case */ + Fatal("Difference between calculated hi_x and lo_x is not multiples of 16"); + } + if(lo_x == hi_x) { + Error("lo_x and hi_x are identical, nothing to scan. Scanning the whole line instead"); + lo_x = 0; + hi_x = width; + } + + + /* XMM0,1,2,3 - General purpose */ + /* XMM4 - alarmed pixels count */ + /* XMM5 - difference accumulator */ + /* XMM6 - min pixel threshold mask */ + /* XMM7 - max pixel threshold mask */ + /* XMM8 - divide mask */ + /* XMM9 - 0x01 mask */ + /* + Register map: + %0 - pixelsalarmed + %1 - pixelsdifference + %2 - pdiff + %3 - ppoly + %4 - X + %5 - Y + %6 - min pixel mask + %7 - max pixel mask + %8 - lo_y + %9 - lo_x + %10 - hi_x + %11 - hi_y + %12 - width + %13 - xgap + */ + + /* Initial setup + * set X to lo_x + * set Y to lo_y + * set pdiff to pdiff start + (width * lo_y) + lo_x + * set ppoly to ppoly start + (width * lo_y) + lo_x + * set xgap to hi_x - lo_x + */ + + __asm__ __volatile__ ( + "pxor %%xmm4, %%xmm4\n\t" // Zero out the alarmed pixels count + "pxor %%xmm5, %%xmm5\n\t" // Zero out the difference accumulator + "movdqa %6, %%xmm6\n\t" // Load the min pixel threshold (divided by 2) + "movdqa %7, %%xmm7\n\t" // Load the max pixel threshold (divided by 2) +#if defined(__x86_64__) + "mov $0x7F7F7F7F, %%eax\n\t" /* Divide mask */ + "movd %%eax, %%xmm8\n\t" + "pshufd $0x0, %%xmm8, %%xmm8\n\t" + "mov $0x01010101, %%eax\n\t" /* 0x1 mask */ + "movd %%eax, %%xmm9\n\t" + "pshufd $0x0, %%xmm9, %%xmm9\n\t" +#endif + /* Iteration start */ + "sse2_ap_iter:\n\t" + "movdqa (%2), %%xmm0\n\t" // Load the pdiff + "movdqa (%3), %%xmm1\n\t" // Load the ppoly + + "pand %%xmm0, %%xmm1\n\t" // Filter out pixels not inside polygon. Result stored on XMM1 + "movdqa %%xmm1, %%xmm2\n\t" // Move the result into XMM2 + "psrlq $0x1, %%xmm2\n\t" // Divide the result by 2 (part 1) +#if defined(__x86_64__) + "pand %%xmm8, %%xmm2\n\t" // Divide the result by 2 (part 2) +#else + "mov $0x7F7F7F7F, %%eax\n\t" + "movd %%eax, %%xmm0\n\t" + "pshufd $0x0, %%xmm0, %%xmm0\n\t" + "pand %%xmm0, %%xmm2\n\t" // Divide the result by 2 (part 2) +#endif + + /* Filter out pixels bigger than max threshold and update XMM0 */ + "movdqa %%xmm7, %%xmm0\n\t" // Copy max threshold to XMM0 + "pcmpgtb %%xmm2, %%xmm0\n\t" // Filter out pixels bigger than max threshold, result stored on XMM0 + "pand %%xmm2, %%xmm0\n\t" // XMM0 = Dividied pixels that are in poly and meet maximum threshold + + /* Filter out pixels smaller than min threshold */ + "pcmpgtb %%xmm6, %%xmm0\n\t" // Filter out pixels smaller than min threshold, result stored on XMM0 + + /* Write white or black depending if pixel is alarmed or not */ + "movntdq %%xmm0, (%2)\n\t" // Set the pixel to white or black depending on the result + + /* Update the alarmed pixels count */ +#if defined(__x86_64__) + "movdqa %%xmm9, %%xmm3\n\t" // Move 0x01 mask to XMM3 +#else + "mov $0x01010101, %%eax\n\t" + "movd %%eax, %%xmm3\n\t" + "pshufd $0x0, %%xmm3, %%xmm3\n\t" +#endif + "pxor %%xmm2, %%xmm2\n\t" // Set XMM2 to zeros + + "pand %%xmm0, %%xmm3\n\t" // Set alarmed pixels to 1 in XMM3 + "psadbw %%xmm2, %%xmm3\n\t" // DEST[0-15] and DEST[64-79] contain the results + "paddd %%xmm3, %%xmm4\n\t" // Update the alarmed pixels count + + /* Update XMM0 to contain pixels in poly that meet min and max thresholds */ + "pand %%xmm1, %%xmm0\n\t" // XMM0 = Pixels in poly that meet min and max thresholds + + /* Update the difference accumulator */ + "psadbw %%xmm0, %%xmm2\n\t" // DEST[0-15] and DEST[64-79] contain the results + "paddd %%xmm2, %%xmm5\n\t" // Update the difference accumulator + + /* Move to the next pixels in the row */ + "add $0x10, %2\n\t" // Add 16 to pdiff + "add $0x10, %3\n\t" // Add 16 to ppoly + "add $0x10, %4\n\t" // Add 16 to X + "cmp %10, %4\n\t" // Check if we reached max X + "jb sse2_ap_iter\n\t" // Go for another iteration + + "sub %13, %2\n\t" // Reset pdiff to low X + "sub %13, %3\n\t" // Reset ppoly to low X + "sub %13, %4\n\t" // Reset X to low x + + "add $0x1, %5\n\t" // Increment Y to advance to the next line + "add %12, %2\n\t" // Move pdiff to the next row + "add %12, %3\n\t" // Move ppoly to the next row + + "cmp %11, %5\n\t" // Check if we reached max Y + "jb sse2_ap_iter\n\t" // Go for another iteration + + /* Calculate the alarmed pixels */ + "pshufd $0x56, %%xmm4, %%xmm0\n\t" + "paddd %%xmm4, %%xmm0\n\t" + "movd %%xmm0, %0\n\t" + + /* Calculate the pixels difference */ + "pshufd $0x56, %%xmm5, %%xmm1\n\t" + "paddd %%xmm5, %%xmm1\n\t" + "movd %%xmm1, %1\n\t" + + : "=m" (pixelsalarmed), "=m" (pixelsdifference) +#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ + : "r" (pdiff), "r" (ppoly), "r" (x), "r" (y), "m" (*calc_minpthreshold), "m" (*calc_maxpthreshold), "m" (lo_y), "m" (lo_x), "m" (hi_x), "m" (hi_y), "m" (width), "m" (xgap) +#else + : "r" (pdiff), "r" (ppoly), "r" (x), "r" (y), "m" (*calc_minpthreshold), "m" (*calc_maxpthreshold), "m" (lo_y), "m" (lo_x), "r" (hi_x), "m" (hi_y), "m" (width), "m" (xgap) +#endif +#if defined(__x86_64__) + : "%rax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "%xmm9", "cc", "memory" +#else + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "cc", "memory" +#endif + ); + + /* Store the results */ + *pixel_count = pixelsalarmed; + *pixel_sum = pixelsdifference; +#else + Panic("SSE function called on a non x86\\x86-64 platform"); +#endif +} diff --git a/src/zm_zone.h b/src/zm_zone.h index 98e020c59..ae247ada4 100644 --- a/src/zm_zone.h +++ b/src/zm_zone.h @@ -77,7 +77,7 @@ protected: // Outputs/Statistics bool alarmed; int pixel_diff; - int alarm_pixels; + unsigned int alarm_pixels; int alarm_filter_pixels; int alarm_blob_pixels; int alarm_blobs; @@ -94,7 +94,9 @@ protected: protected: void Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_type, const Polygon &p_polygon, const Rgb p_alarm_rgb, CheckMethod p_check_method, int p_min_pixel_threshold, int p_max_pixel_threshold, int p_min_alarm_pixels, int p_max_alarm_pixels, const Coord &p_filter_box, int p_min_filter_pixels, int p_max_filter_pixels, int p_min_blob_pixels, int p_max_blob_pixels, int p_min_blobs, int p_max_blobs, int p_overload_frames ); - + void std_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsigned int* pixel_count, unsigned int* pixel_sum); + void sse2_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsigned int* pixel_count, unsigned int* pixel_sum); + public: Zone( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_type, const Polygon &p_polygon, const Rgb p_alarm_rgb, CheckMethod p_check_method, int p_min_pixel_threshold=15, int p_max_pixel_threshold=0, int p_min_alarm_pixels=50, int p_max_alarm_pixels=75000, const Coord &p_filter_box=Coord( 3, 3 ), int p_min_filter_pixels=50, int p_max_filter_pixels=50000, int p_min_blob_pixels=10, int p_max_blob_pixels=0, int p_min_blobs=0, int p_max_blobs=0, int p_overload_frames=0 ) { From 349e18b543c20d500aea1d678a73144752abeeb0 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 6 Jul 2011 18:39:16 +0300 Subject: [PATCH 25/56] Few text corrections. --- src/zm_image.cpp | 14 ++++++++------ src/zm_jpeg.cpp | 6 +++--- src/zm_jpeg.h | 2 +- src/zm_local_camera.cpp | 12 ++++++------ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 121dcf1ca..a2c397bb3 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -581,9 +581,10 @@ bool Image::ReadJpeg( const char *filename, int p_colours, int p_subpixelorder) jpeg_read_header( cinfo, TRUE ); - /* Check if the image has huffman tables defined. If not, add the standard ones */ - if(cinfo->dc_huff_tbl_ptrs[0] == NULL || cinfo->ac_huff_tbl_ptrs[0] == NULL) { - zm_add_std_huff_tables(cinfo); + /* Check if the image has at least one huffman table defined. If not, use the standard ones */ + /* This is required for the MJPEG capture palette of USB devices */ + if(cinfo->dc_huff_tbl_ptrs[0] == NULL) { + zm_use_std_huff_tables(cinfo); } if ( cinfo->image_width != width || cinfo->image_height != height) @@ -832,9 +833,10 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, int p_colours jpeg_read_header( cinfo, TRUE ); - /* Check if the image has huffman tables defined. If not, add the standard ones */ - if(cinfo->dc_huff_tbl_ptrs[0] == NULL || cinfo->ac_huff_tbl_ptrs[0] == NULL) { - zm_add_std_huff_tables(cinfo); + /* Check if the image has at least one huffman table defined. If not, use the standard ones */ + /* This is required for the MJPEG capture palette of USB devices */ + if(cinfo->dc_huff_tbl_ptrs[0] == NULL) { + zm_use_std_huff_tables(cinfo); } if ( cinfo->image_width != width || cinfo->image_height != height) diff --git a/src/zm_jpeg.cpp b/src/zm_jpeg.cpp index 7158e0d8a..7bb8a73e2 100644 --- a/src/zm_jpeg.cpp +++ b/src/zm_jpeg.cpp @@ -392,9 +392,9 @@ void zm_jpeg_mem_src( j_decompress_ptr cinfo, const JOCTET *inbuffer, int inbuff src->pub.next_input_byte = NULL; /* until buffer loaded */ } -void zm_add_std_huff_tables( j_decompress_ptr cinfo ) { -/* JPEG standard Huffman tables (cf. JPEG standard section K.3) */ -/* IMPORTANT: these are only valid for 8-bit data precision! */ +void zm_use_std_huff_tables( j_decompress_ptr cinfo ) { + /* JPEG standard Huffman tables (cf. JPEG standard section K.3) */ + /* IMPORTANT: these are only valid for 8-bit data precision! */ static const JHUFF_TBL dclumin = { { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, diff --git a/src/zm_jpeg.h b/src/zm_jpeg.h index 188b75af0..94290869a 100644 --- a/src/zm_jpeg.h +++ b/src/zm_jpeg.h @@ -45,5 +45,5 @@ void zm_jpeg_emit_message( j_common_ptr cinfo, int msg_level ); void zm_jpeg_mem_src(j_decompress_ptr cinfo, const JOCTET *inbuffer, int inbuffer_size ); void zm_jpeg_mem_dest(j_compress_ptr cinfo, JOCTET *outbuffer, int *outbuffer_size ); -void zm_add_std_huff_tables( j_decompress_ptr cinfo ); +void zm_use_std_huff_tables( j_decompress_ptr cinfo ); } diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index e91df4962..eab16873f 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -1333,7 +1333,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers } if(verbose) { - sprintf( output+strlen(output), "Cropping is not supported"); + sprintf( output+strlen(output), " Cropping is not supported\n"); } else { /* Send fake crop bounds to not confuse things parsing this, such as monitor probe */ sprintf( output+strlen(output), "B:%dx%d|",0,0); @@ -1352,7 +1352,7 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers } if ( verbose ) { - sprintf( output+strlen(output), "Cropping is not supported"); + sprintf( output+strlen(output), " Cropping is not supported\n"); } else { /* Send fake crop bounds to not confuse things parsing this, such as monitor probe */ sprintf( output+strlen(output), "B:%dx%d|",0,0); @@ -1360,10 +1360,10 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers } else { /* Cropping supported */ if ( verbose ) { - sprintf( output+strlen(output), "Crop Capabilities\n" ); - sprintf( output+strlen(output), " Bounds: %d x %d\n", cropcap.bounds.width, cropcap.bounds.height ); - sprintf( output+strlen(output), " Default: %d x %d\n", cropcap.defrect.width, cropcap.defrect.height ); - sprintf( output+strlen(output), " Current: %d x %d\n", crop.c.width, crop.c.height ); + sprintf( output+strlen(output), " Crop Capabilities\n" ); + sprintf( output+strlen(output), " Bounds: %d x %d\n", cropcap.bounds.width, cropcap.bounds.height ); + sprintf( output+strlen(output), " Default: %d x %d\n", cropcap.defrect.width, cropcap.defrect.height ); + sprintf( output+strlen(output), " Current: %d x %d\n", crop.c.width, crop.c.height ); } else { sprintf( output+strlen(output), "B:%dx%d|", cropcap.bounds.width, cropcap.bounds.height ); } From 66f5d7c2f1d3d723ee8df76cc5f2bd05415cb836 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 14 Jul 2011 16:45:58 +0300 Subject: [PATCH 26/56] Added #defines to control the inclusion of the SSE code. --- src/zm_image.cpp | 24 ++++++++++++------------ src/zm_utils.cpp | 2 +- src/zm_zone.cpp | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index a2c397bb3..dc6596068 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -2517,7 +2517,7 @@ void Image::Scale( unsigned int factor ) __attribute__ ((noinline)) void sse2_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) static uint32_t divider = 0; static uint32_t clearmask = 0; static double current_blendpercent = 0.0; @@ -2859,7 +2859,7 @@ __attribute__ ((noinline)) void std_delta8_abgr(const uint8_t* col1, const uint8 /* Grayscale SSE2 */ __attribute__ ((noinline)) void sse2_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( "sub $0x10, %0\n\t" @@ -2887,7 +2887,7 @@ __attribute__ ((noinline)) void sse2_delta8_gray8(const uint8_t* col1, const uin /* RGB32: RGBA SSE2 */ __attribute__ ((noinline)) void sse2_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -2956,7 +2956,7 @@ __attribute__ ((noinline)) void sse2_delta8_rgba(const uint8_t* col1, const uint /* RGB32: BGRA SSE2 */ __attribute__ ((noinline)) void sse2_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3025,7 +3025,7 @@ __attribute__ ((noinline)) void sse2_delta8_bgra(const uint8_t* col1, const uint /* RGB32: ARGB SSE2 */ __attribute__ ((noinline)) void sse2_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3095,7 +3095,7 @@ __attribute__ ((noinline)) void sse2_delta8_argb(const uint8_t* col1, const uint /* RGB32: ABGR SSE2 */ __attribute__ ((noinline)) void sse2_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3165,7 +3165,7 @@ __attribute__ ((noinline)) void sse2_delta8_abgr(const uint8_t* col1, const uint /* RGB32: RGBA SSSE3 */ __attribute__ ((noinline)) void ssse3_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3217,7 +3217,7 @@ __attribute__ ((noinline)) void ssse3_delta8_rgba(const uint8_t* col1, const uin /* RGB32: BGRA SSSE3 */ __attribute__ ((noinline)) void ssse3_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3269,7 +3269,7 @@ __attribute__ ((noinline)) void ssse3_delta8_bgra(const uint8_t* col1, const uin /* RGB32: ARGB SSSE3 */ __attribute__ ((noinline)) void ssse3_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3322,7 +3322,7 @@ __attribute__ ((noinline)) void ssse3_delta8_argb(const uint8_t* col1, const uin /* RGB32: ABGR SSSE3 */ __attribute__ ((noinline)) void ssse3_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3575,7 +3575,7 @@ __attribute__ ((noinline)) void std_convert_yuyv_gray8(const uint8_t* col1, uint /* RGBA to grayscale SSSE3 */ __attribute__ ((noinline)) void ssse3_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( "mov $0x1F1F1F1F, %%eax\n\t" @@ -3621,7 +3621,7 @@ __attribute__ ((noinline)) void ssse3_convert_rgba_gray8(const uint8_t* col1, ui /* Converts a YUYV image into grayscale by extracting the Y channel */ __attribute__ ((noinline)) void ssse3_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) unsigned long i = 0; __attribute__((aligned(16))) static const uint8_t movemask1[16] = {0,2,4,6,8,10,12,14,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; diff --git a/src/zm_utils.cpp b/src/zm_utils.cpp index 3cd081692..11a28538c 100644 --- a/src/zm_utils.cpp +++ b/src/zm_utils.cpp @@ -193,7 +193,7 @@ void ssedetect() { /* SSE2 aligned memory copy. Useful for big copying of aligned memory like image buffers in ZM */ /* For platforms without SSE2 we will use standard x86 asm memcpy or glibc's memcpy() */ __attribute__((noinline)) void* sse2_aligned_memcpy(void* dest, const void* src, size_t bytes) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) if(bytes > 128) { unsigned int remainder = bytes % 128; const uint8_t* lastsrc = (uint8_t*)src + (bytes - remainder); diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index c67932919..bf294aa4a 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -1005,7 +1005,7 @@ void Zone::std_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsig } void Zone::sse2_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsigned int* pixel_count, unsigned int* pixel_sum) { -#if (defined(__i386__) || defined(__x86_64__)) +#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __attribute__((aligned(16))) static uint8_t calc_maxpthreshold[16] = {127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127}; __attribute__((aligned(16))) static uint8_t calc_minpthreshold[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; static uint8_t current_minpthreshold = 0; From b4921c440354d9af0c91555fbc3f344af0f122e6 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sat, 16 Jul 2011 14:27:53 +0300 Subject: [PATCH 27/56] 1) Made 24bit the default target colorspace. 2) Changed crop info's layout. --- src/zm_local_camera.cpp | 12 +++++++----- web/skins/classic/views/monitor.php | 2 +- web/skins/classic/views/monitorprobe.php | 10 +++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index eab16873f..77107bb7a 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -1321,7 +1321,10 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers while ( formatIndex++ >= 0 ); if ( !verbose ) output[strlen(output)-1] = '|'; - + + if(verbose) + sprintf( output+strlen(output), "Crop Capabilities\n" ); + struct v4l2_cropcap cropcap; memset( &cropcap, 0, sizeof(cropcap) ); cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; @@ -1360,10 +1363,9 @@ bool LocalCamera::GetCurrentSettings( const char *device, char *output, int vers } else { /* Cropping supported */ if ( verbose ) { - sprintf( output+strlen(output), " Crop Capabilities\n" ); - sprintf( output+strlen(output), " Bounds: %d x %d\n", cropcap.bounds.width, cropcap.bounds.height ); - sprintf( output+strlen(output), " Default: %d x %d\n", cropcap.defrect.width, cropcap.defrect.height ); - sprintf( output+strlen(output), " Current: %d x %d\n", crop.c.width, crop.c.height ); + sprintf( output+strlen(output), " Bounds: %d x %d\n", cropcap.bounds.width, cropcap.bounds.height ); + sprintf( output+strlen(output), " Default: %d x %d\n", cropcap.defrect.width, cropcap.defrect.height ); + sprintf( output+strlen(output), " Current: %d x %d\n", crop.c.width, crop.c.height ); } else { sprintf( output+strlen(output), "B:%dx%d|", cropcap.bounds.width, cropcap.bounds.height ); } diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 96f978ee4..175868be4 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -64,7 +64,7 @@ else 'Host' => "", 'Path' => "", 'Port' => "80", - 'Colours' => 4, + 'Colours' => 3, 'Palette' => 0, 'Width' => "320", 'Height' => "240", diff --git a/web/skins/classic/views/monitorprobe.php b/web/skins/classic/views/monitorprobe.php index eaa4a5cf8..a282f6d71 100644 --- a/web/skins/classic/views/monitorprobe.php +++ b/web/skins/classic/views/monitorprobe.php @@ -83,7 +83,7 @@ if ( ZM_HAS_V4L2 ) 'Type' => 'Local', 'Device' => $deviceMatches[1], 'Channel' => $i, - 'Colours' => 4, + 'Colours' => 3, 'Format' => $preferredStandard, 'Palette' => $preferredFormat, ); @@ -126,7 +126,7 @@ function probeAxis( $ip ) 'Host' => $ip, 'Port' => 80, 'Path' => '/axis-cgi/mjpg/video.cgi?resolution=320x240', - 'Colours' => 4, + 'Colours' => 3, 'Width' => 320, 'Height' => 240, ), @@ -160,7 +160,7 @@ function probePana( $ip ) 'Host' => $ip, 'Port' => 80, 'Path' => '/nphMotionJpeg?Resolution=320x240&Quality=Standard', - 'Colours' => 4, + 'Colours' => 3, 'Width' => 320, 'Height' => 240, ), @@ -180,7 +180,7 @@ function probeActi( $ip ) 'Host' => 'Admin:123456@'.$ip, 'Port' => 7070, 'Path' => '', - 'Colours' => 4, + 'Colours' => 3, 'Width' => 320, 'Height' => 240, ), @@ -215,7 +215,7 @@ function probeVivotek( $ip ) 'Host' => $ip, 'Port' => 554, 'Path' => '', - 'Colours' => 4, + 'Colours' => 3, 'Width' => 352, 'Height' => 240, ), From be8ef02a7c808c64e490fa73f37ba1babaeb979f Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sat, 16 Jul 2011 14:48:44 +0300 Subject: [PATCH 28/56] Small corrections --- web/skins/classic/views/monitorprobe.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/skins/classic/views/monitorprobe.php b/web/skins/classic/views/monitorprobe.php index a282f6d71..0f26d6331 100644 --- a/web/skins/classic/views/monitorprobe.php +++ b/web/skins/classic/views/monitorprobe.php @@ -45,7 +45,7 @@ if ( ZM_HAS_V4L2 ) $devices = array(); $preferredStandards = array( 'PAL', 'NTSC' ); - $preferredFormats = array( 'BGR4', 'RGB4', 'BGR3', 'RGB3', 'YUYV', 'UYVY', 'JPEG', 'MJPG', '422P', 'YU12', 'GREY'); + $preferredFormats = array( 'BGR3', 'RGB3', 'YUYV', 'UYVY', 'JPEG', 'MJPG', '422P', 'YU12', 'GREY' ); foreach ( $output as $line ) { if ( !preg_match( '/^d:([^|]+).*S:([^|]*).*F:([^|]+).*I:(\d+)\|(.+)$/', $line, $deviceMatches ) ) @@ -126,7 +126,7 @@ function probeAxis( $ip ) 'Host' => $ip, 'Port' => 80, 'Path' => '/axis-cgi/mjpg/video.cgi?resolution=320x240', - 'Colours' => 3, + 'Palette' => 3, 'Width' => 320, 'Height' => 240, ), @@ -160,7 +160,7 @@ function probePana( $ip ) 'Host' => $ip, 'Port' => 80, 'Path' => '/nphMotionJpeg?Resolution=320x240&Quality=Standard', - 'Colours' => 3, + 'Palette' => 3, 'Width' => 320, 'Height' => 240, ), @@ -180,7 +180,7 @@ function probeActi( $ip ) 'Host' => 'Admin:123456@'.$ip, 'Port' => 7070, 'Path' => '', - 'Colours' => 3, + 'Palette' => 3, 'Width' => 320, 'Height' => 240, ), @@ -215,7 +215,7 @@ function probeVivotek( $ip ) 'Host' => $ip, 'Port' => 554, 'Path' => '', - 'Colours' => 3, + 'Palette' => 3, 'Width' => 352, 'Height' => 240, ), From b51bce05e8f13f18a65217b560d455477540ce64 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sun, 31 Jul 2011 22:03:51 +0300 Subject: [PATCH 29/56] Rebased to SVN revision 3487 --- config.h.in | 12 ++++++------ src/zm_jpeg.cpp | 8 ++++---- src/zm_remote_camera_rtsp.cpp | 24 +----------------------- 3 files changed, 11 insertions(+), 33 deletions(-) diff --git a/config.h.in b/config.h.in index c432ceaba..11a064e1e 100644 --- a/config.h.in +++ b/config.h.in @@ -180,24 +180,24 @@ /* Define to 1 if you have the header file. */ #undef HAVE_PCRE_PCRE_H -/* Define to 1 if you have the header file. */ -#undef HAVE_PTHREAD_H - /* Define to 1 if you have the `posix_memalign' function. */ #undef HAVE_POSIX_MEMALIGN +/* Define to 1 if you have the header file. */ +#undef HAVE_PTHREAD_H + /* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT -/* Define to 1 if you have the `sigaction' function. */ -#undef HAVE_SIGACTION - /* Define to 1 if you have the `sendfile' function. */ #undef HAVE_SENDFILE +/* Define to 1 if you have the `sigaction' function. */ +#undef HAVE_SIGACTION + /* Define to 1 if the system has the type `siginfo_t'. */ #undef HAVE_SIGINFO_T diff --git a/src/zm_jpeg.cpp b/src/zm_jpeg.cpp index 7bb8a73e2..58c3ca5be 100644 --- a/src/zm_jpeg.cpp +++ b/src/zm_jpeg.cpp @@ -456,10 +456,10 @@ void zm_use_std_huff_tables( j_decompress_ptr cinfo ) { 0 }; - cinfo->dc_huff_tbl_ptrs[0] = &dclumin; - cinfo->dc_huff_tbl_ptrs[1] = &dcchrome; - cinfo->ac_huff_tbl_ptrs[0] = &aclumin; - cinfo->ac_huff_tbl_ptrs[1] = &acchrome; + cinfo->dc_huff_tbl_ptrs[0] = (JHUFF_TBL*)&dclumin; + cinfo->dc_huff_tbl_ptrs[1] = (JHUFF_TBL*)&dcchrome; + cinfo->ac_huff_tbl_ptrs[0] = (JHUFF_TBL*)&aclumin; + cinfo->ac_huff_tbl_ptrs[1] = (JHUFF_TBL*)&acchrome; } diff --git a/src/zm_remote_camera_rtsp.cpp b/src/zm_remote_camera_rtsp.cpp index ec4ce99cf..bb23f3335 100644 --- a/src/zm_remote_camera_rtsp.cpp +++ b/src/zm_remote_camera_rtsp.cpp @@ -259,27 +259,6 @@ int RemoteCameraRtsp::Capture( Image &image ) av_init_packet( &packet ); -<<<<<<< HEAD - while ( !frameComplete ) - { - packet.data = buffer.head(); - packet.size = buffer.size(); - int len = avcodec_decode_video2( mCodecContext, mRawFrame, &frameComplete, &packet ); - if ( len < 0 ) - { - Error( "Error while decoding frame %d", frameCount ); - Hexdump( Logger::ERROR, buffer.head(), buffer.size()>256?256:buffer.size() ); - buffer.clear(); - continue; - } - Debug( 2, "Frame: %d - %d/%d", frameCount, len, buffer.size() ); - //if ( buffer.size() < 400 ) - //Hexdump( 0, buffer.head(), buffer.size() ); - - if ( frameComplete ) - { - Debug( 3, "Got frame %d", frameCount ); -======= while ( !frameComplete && buffer.size() > 0 ) { packet.data = buffer.head(); @@ -288,7 +267,7 @@ int RemoteCameraRtsp::Capture( Image &image ) if ( len < 0 ) { Error( "Error while decoding frame %d", frameCount ); - Hexdump( ZM_DBG_ERR, buffer.head(), buffer.size()>256?256:buffer.size() ); + Hexdump( Logger::ERROR, buffer.head(), buffer.size()>256?256:buffer.size() ); buffer.clear(); continue; } @@ -302,7 +281,6 @@ int RemoteCameraRtsp::Capture( Image &image ) if ( frameComplete ) { Debug( 3, "Got frame %d", frameCount ); ->>>>>>> Some small changes avpicture_fill( (AVPicture *)mFrame, directbuffer, imagePixFormat, width, height); From 41ad83a7d3fc311c6d5a60e4a9ebbef0f7864753 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sun, 31 Jul 2011 22:15:17 +0300 Subject: [PATCH 30/56] Added updated configure and src/zm_config_defines.h --- configure | 10900 ++++++++++++++++++++++++++++++++++++++ src/zm_config_defines.h | 637 +++ 2 files changed, 11537 insertions(+) create mode 100755 configure create mode 100644 src/zm_config_defines.h diff --git a/configure b/configure new file mode 100755 index 000000000..3791f9c70 --- /dev/null +++ b/configure @@ -0,0 +1,10900 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.65 for zm 1.25.0. +# +# Report bugs to . +# +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and +$0: http://www.zoneminder.com/forums/ (Please check FAQ +$0: first) about your system, including any error possibly +$0: output before this message. Then install a modern +$0: shell, or manually run the script under such a shell if +$0: you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with status $?, using 1 if that was 0. +as_fn_error () +{ + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='zm' +PACKAGE_TARNAME='ZoneMinder' +PACKAGE_VERSION='1.25.0' +PACKAGE_STRING='zm 1.25.0' +PACKAGE_BUGREPORT='http://www.zoneminder.com/forums/ (Please check FAQ first)' +PACKAGE_URL='http://www.zoneminder.com/downloads.html' + +ac_unique_file="src/zm.h" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_header_list= +ac_subst_vars='am__EXEEXT_FALSE +am__EXEEXT_TRUE +LTLIBOBJS +EXTRA_PERL_LIB +PERL_MM_PARMS +ZM_CONFIG +SYSCONFDIR +ZM_PID +LIBDIR +BINDIR +PERL +ZM_PCRE +ZM_HAS_V4L +ZM_HAS_V4L2 +ZM_HAS_V4L1 +ALLOCA +PATH_NETPBM +OPT_NETPBM +PATH_FFMPEG +OPT_FFMPEG +POW_LIB +LIBOBJS +EGREP +GREP +CXXCPP +RANLIB +LN_S +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +ac_ct_CC +CFLAGS +CC +am__fastdepCXX_FALSE +am__fastdepCXX_TRUE +CXXDEPMODE +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__quote +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CXX +CPPFLAGS +LDFLAGS +CXXFLAGS +CXX +ENABLE_MMAP +WEB_HOST +WEB_GROUP +WEB_USER +CGI_PREFIX +WEB_PREFIX +EXTRA_LIBS +FFMPEG_CFLAGS +FFMPEG_LIBS +FFMPEG_PREFIX +MYSQL_CFLAGS +MYSQL_LIBS +MYSQL_PREFIX +LIB_ARCH +ZM_LOGDIR +ZM_TMPDIR +ZM_RUNDIR +ZM_MYSQL_ENGINE +ZM_SSL_LIB +ZM_DB_PASS +ZM_DB_USER +ZM_DB_NAME +ZM_DB_HOST +TIME_BUILD +PATH_BUILD +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +MKDIR_P +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +with_libarch +with_mysql +with_ffmpeg +with_extralibs +with_webdir +with_cgidir +with_webuser +with_webgroup +with_webhost +enable_debug +enable_crashtrace +enable_mmap +enable_dependency_tracking +' + ac_precious_vars='build_alias +host_alias +target_alias +ZM_DB_HOST +ZM_DB_NAME +ZM_DB_USER +ZM_DB_PASS +ZM_SSL_LIB +ZM_MYSQL_ENGINE +ZM_RUNDIR +ZM_TMPDIR +ZM_LOGDIR +CXX +CXXFLAGS +LDFLAGS +LIBS +CPPFLAGS +CCC +CC +CFLAGS +CXXCPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information." + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +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 zm 1.25.0 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/ZoneMinder] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of zm 1.25.0:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-debug= enable or disable debug, default enabled + --enable-crashtrace= enable or disabled crash tracing, default enabled + --enable-mmap= enable or disabled mapped memory versus shared memory, default mapped + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-libarch= architecture library path to use, default lib + --with-mysql= prefix of MySQL installation, default /usr + --with-ffmpeg= prefix of ffmpeg root directory for libavcodec etc, default /usr + --with-extralibs="" string containing extra libraries to pass to link, default empty + --with-webdir= prefix of web directory + --with-cgidir= prefix of cgi directory + --with-webuser= name of web user, default apache + --with-webgroup= name of web group, default apache + --with-webhost= name of web hostname, default zm.local + +Some influential environment variables: + ZM_DB_HOST Hostname where ZoneMinder database located, default localhost + ZM_DB_NAME Name of ZoneMinder database, default zm + ZM_DB_USER Name of ZoneMinder database user, default zmuser + ZM_DB_PASS Password of ZoneMinder database user, default zmpass + ZM_SSL_LIB Library to use for ssl functions, default gnutls + ZM_MYSQL_ENGINE + MySQL engine to use with database, default MyISAM + ZM_RUNDIR Location of transient process files, default /var/run/zm + ZM_TMPDIR Location of temporary files, default /tmp/zm + ZM_LOGDIR Location of generated log files, default /var/log/zm + CXX C++ compiler command + CXXFLAGS C++ compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CC C compiler command + CFLAGS C compiler flags + CXXCPP C++ preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +zm home page: . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +zm configure 1.25.0 +generated by GNU Autoconf 2.65 + +Copyright (C) 2009 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_cxx_try_compile LINENO +# ---------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_compile + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_cxx_check_type LINENO TYPE VAR INCLUDES +# --------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_cxx_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_cxx_check_type + +# ac_fn_cxx_try_cpp LINENO +# ------------------------ +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } >/dev/null && { + test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_cpp + +# ac_fn_cxx_try_run LINENO +# ------------------------ +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_cxx_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_run + +# ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES +# --------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_cxx_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_cxx_check_header_compile + +# ac_fn_cxx_check_member LINENO AGGR MEMBER VAR INCLUDES +# ------------------------------------------------------ +# Tries to find if the field MEMBER exists in type AGGR, after including +# INCLUDES, setting cache variable VAR accordingly. +ac_fn_cxx_check_member () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 +$as_echo_n "checking for $2.$3... " >&6; } +if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval "$4=yes" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (sizeof ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval "$4=yes" +else + eval "$4=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$4 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_cxx_check_member + +# ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES +# --------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_cxx_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( cat <<\_ASBOX +## ------------------------------------------------------------------------- ## +## Report this to http://www.zoneminder.com/forums/ (Please check FAQ first) ## +## ------------------------------------------------------------------------- ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_cxx_check_header_mongrel + +# ac_fn_cxx_try_link LINENO +# ------------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_link + +# ac_fn_cxx_check_func LINENO FUNC VAR +# ------------------------------------ +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_cxx_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_cxx_check_func + +# ac_fn_cxx_check_decl LINENO SYMBOL VAR +# -------------------------------------- +# Tests whether SYMBOL is declared, setting cache variable VAR accordingly. +ac_fn_cxx_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5 +$as_echo_n "checking whether $2 is declared... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $2 + (void) $2; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_cxx_check_decl +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 zm $as_me 1.25.0, which was +generated by GNU Autoconf 2.65. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + ac_site_file1=$CONFIG_SITE +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +as_fn_append ac_header_list " stdlib.h" +as_fn_append ac_header_list " unistd.h" +as_fn_append ac_header_list " sys/param.h" +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +am__api_version='1.11' + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + for ac_t in install-sh install.sh shtool; do + if test -f "$ac_dir/$ac_t"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/$ac_t -c" + break 2 + fi + done +done +if test -z "$ac_aux_dir"; then + as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[\\\"\#\$\&\'\`$am_lf]*) + as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; +esac +case $srcdir in + *[\\\"\#\$\&\'\`$am_lf\ \ ]*) + as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; +esac + +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error "ls -t appears to fail. Make sure there is not a broken +alias in your environment" "$LINENO" 5 + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + as_fn_error "newly created file is older than distributed files! +Check your system clock" "$LINENO" 5 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if test "${ac_cv_path_mkdir+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + +fi + + test -d ./--version && rmdir ./--version + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + MKDIR_P="$ac_install_sh -d" + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='ZoneMinder' + VERSION='1.25.0' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + + +ac_config_headers="$ac_config_headers config.h" + + +PATH_BUILD=`pwd` + +TIME_BUILD=`date +'%s'` + + + + + + + + + + + + +if test "$ZM_DB_HOST" == ""; then + ZM_DB_HOST=localhost + +fi +if test "$ZM_DB_NAME" == ""; then + ZM_DB_NAME=zm + +fi +if test "$ZM_DB_USER" == ""; then + ZM_DB_USER=zmuser + +fi +if test "$ZM_DB_PASS" == ""; then + ZM_DB_PASS=zmpass + +fi +if test "$ZM_SSL_LIB" == ""; then + ZM_SSL_LIB=gnutls + +fi +if test "$ZM_MYSQL_ENGINE" == ""; then + ZM_MYSQL_ENGINE=MyISAM + +fi +if test "$ZM_RUNDIR" == ""; then + ZM_RUNDIR=/var/run/zm + +fi +if test "$ZM_TMPDIR" == ""; then + ZM_TMPDIR=/tmp/zm + +fi +if test "$ZM_LOGDIR" == ""; then + ZM_LOGDIR=/var/log/zm + +fi + +LIB_ARCH=lib + +# Check whether --with-libarch was given. +if test "${with_libarch+set}" = set; then : + withval=$with_libarch; LIB_ARCH=$with_libarch +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-libarch option. + This tells configure where to find architecture specific libraries. + The default of 'lib' is usually ok but 64 bit machines may require lib64. + e.g. --with-libarch=lib or --with-libarch=lib64" >&5 +$as_echo "$as_me: WARNING: You can call configure with the --with-libarch option. + This tells configure where to find architecture specific libraries. + The default of 'lib' is usually ok but 64 bit machines may require lib64. + e.g. --with-libarch=lib or --with-libarch=lib64" >&2;} + +fi + + + +MYSQL_PREFIX=/usr + +# Check whether --with-mysql was given. +if test "${with_mysql+set}" = set; then : + withval=$with_mysql; MYSQL_PREFIX=$with_mysql +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-mysql option. + This tells configure where to find the MySql C library and headers if configure cannot + locate them automatically. + e.g. --with-mysql=/usr/local or --with-mysql=/usr" >&5 +$as_echo "$as_me: WARNING: You can call configure with the --with-mysql option. + This tells configure where to find the MySql C library and headers if configure cannot + locate them automatically. + e.g. --with-mysql=/usr/local or --with-mysql=/usr" >&2;} + +fi + + +MYSQL_LIBS="-L${MYSQL_PREFIX}/${LIB_ARCH}/mysql" +MYSQL_CFLAGS="-I${MYSQL_PREFIX}/include" + + + +LDFLAGS="${MYSQL_LIBS} $LDFLAGS" + +FFMPEG_PREFIX=/usr + +# Check whether --with-ffmpeg was given. +if test "${with_ffmpeg+set}" = set; then : + withval=$with_ffmpeg; FFMPEG_PREFIX=$with_ffmpeg +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-ffmpeg option. + This tells configure where to find the ffmpeg root directory within which are the libavcodec + and libavformat files that can be used to build true MPEG streaming into ZoneMinder. Ensure that + your copy of ffmpeg has installed libraries as well as binaries (use 'make installlib'). If you + are using a local install of ffmpeg you may have to remove or rename a previous real installation + as the headers and libraries from that will probably be picked up before your local copy. + e.g. --with-ffmpeg=/usr/local" >&5 +$as_echo "$as_me: WARNING: You can call configure with the --with-ffmpeg option. + This tells configure where to find the ffmpeg root directory within which are the libavcodec + and libavformat files that can be used to build true MPEG streaming into ZoneMinder. Ensure that + your copy of ffmpeg has installed libraries as well as binaries (use 'make installlib'). If you + are using a local install of ffmpeg you may have to remove or rename a previous real installation + as the headers and libraries from that will probably be picked up before your local copy. + e.g. --with-ffmpeg=/usr/local" >&2;} + +fi + + +FFMPEG_LIBS="-L${FFMPEG_PREFIX}/${LIB_ARCH}" +FFMPEG_CFLAGS="-I${FFMPEG_PREFIX}/include" + + + +LDFLAGS="${FFMPEG_LIBS} $LDFLAGS" +CFLAGS="${FFMPEG_CFLAGS} $CFLAGS" +CPPFLAGS="${FFMPEG_CFLAGS} $CPPFLAGS" + +EXTRA_LIBS= + +# Check whether --with-extralibs was given. +if test "${with_extralibs+set}" = set; then : + withval=$with_extralibs; EXTRA_LIBS=$with_extralibs +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-extralibs option. + Ordinarily you will need to use this option only when your copy of ffmpeg has been built + with support for additional formats and you would use this option to detail which additional + libraries ffmpeg was built with so that it is able to link successfully with ZoneMinder. + You will need to wrap this option in quotes if it contains any spaces. + e.g. --with-extralibs=\"-lmp3lame\"" >&5 +$as_echo "$as_me: WARNING: You can call configure with the --with-extralibs option. + Ordinarily you will need to use this option only when your copy of ffmpeg has been built + with support for additional formats and you would use this option to detail which additional + libraries ffmpeg was built with so that it is able to link successfully with ZoneMinder. + You will need to wrap this option in quotes if it contains any spaces. + e.g. --with-extralibs=\"-lmp3lame\"" >&2;} + +fi + + + +LDFLAGS="$LDFLAGS ${EXTRA_LIBS}" + + +# Check whether --with-webdir was given. +if test "${with_webdir+set}" = set; then : + withval=$with_webdir; WEB_PREFIX=$with_webdir +else + as_fn_error "You must call configure with the --with-webdir option. + This tells configure where to install PHP and web files and scripts. + e.g. --with-webdir=/var/www/html or --with-webdir=/www/vhtdocs/" "$LINENO" 5 + +fi + + + + +# Check whether --with-cgidir was given. +if test "${with_cgidir+set}" = set; then : + withval=$with_cgidir; CGI_PREFIX=$with_cgidir +else + as_fn_error "You must call configure with the --with-cgidir option. + This tells configure where to install cgi files and scripts. + e.g. --with-cgidir=/var/www/cgi-bin or --with-webdir=/www/vhtdocs//cgi-bin" "$LINENO" 5 + +fi + + + +WEB_USER=apache + +# Check whether --with-webuser was given. +if test "${with_webuser+set}" = set; then : + withval=$with_webuser; WEB_USER=$with_webuser +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-webuser option. + This tells configure what the user name of the web user is if it is not the default of 'apache'. + e.g. --with-webuser=apache or --with-webuser=web" >&5 +$as_echo "$as_me: WARNING: You can call configure with the --with-webuser option. + This tells configure what the user name of the web user is if it is not the default of 'apache'. + e.g. --with-webuser=apache or --with-webuser=web" >&2;} + +fi + + + +WEB_GROUP=apache + +# Check whether --with-webgroup was given. +if test "${with_webgroup+set}" = set; then : + withval=$with_webgroup; WEB_GROUP=$with_webgroup +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-webgroup option. + This tells configure what the group name of the web group is if it is not the default of 'apache'. + e.g. --with-webgroup=apache or --with-webgroup=web" >&5 +$as_echo "$as_me: WARNING: You can call configure with the --with-webgroup option. + This tells configure what the group name of the web group is if it is not the default of 'apache'. + e.g. --with-webgroup=apache or --with-webgroup=web" >&2;} + +fi + + + +WEB_HOST=zm.local + +# Check whether --with-webhost was given. +if test "${with_webhost+set}" = set; then : + withval=$with_webhost; WEB_HOST=$with_webhost +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --with-webhost option. + This tells configure what the host name is for name based virtual hosting. This is only used to populate the sample web/zmHttpd.conf file. + e.g. --with-webhost=zm.localdomain" >&5 +$as_echo "$as_me: WARNING: You can call configure with the --with-webhost option. + This tells configure what the host name is for name based virtual hosting. This is only used to populate the sample web/zmHttpd.conf file. + e.g. --with-webhost=zm.localdomain" >&2;} + +fi + + + +ENABLE_DEBUG=yes +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then : + enableval=$enable_debug; ENABLE_DEBUG=$enable_debug +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --enable-debug= or --disable-debug option. + This tells configure whether to compile ZoneMinder with debug included. Although debug is included + by default it is not output unless explicitly switched on elsewhere. These checks may induce a + small penalty on performance and if you are after squeezing the maximum possible performance out + of ZoneMinder you may use this switch to prevent debug from being compiled in. + e.g. --enable-debug=yes or --disable-debug" >&5 +$as_echo "$as_me: WARNING: You can call configure with the --enable-debug= or --disable-debug option. + This tells configure whether to compile ZoneMinder with debug included. Although debug is included + by default it is not output unless explicitly switched on elsewhere. These checks may induce a + small penalty on performance and if you are after squeezing the maximum possible performance out + of ZoneMinder you may use this switch to prevent debug from being compiled in. + e.g. --enable-debug=yes or --disable-debug" >&2;} + +fi + +if test "$ENABLE_DEBUG" != "yes"; then + +$as_echo "#define ZM_DBG_OFF 1" >>confdefs.h + +fi + +ENABLE_CRASHTRACE=yes +# Check whether --enable-crashtrace was given. +if test "${enable_crashtrace+set}" = set; then : + enableval=$enable_crashtrace; ENABLE_CRASHTRACE=$enable_crashtrace +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --enable-crashtrace= or --disable-crashtrace option. + This tells configure whether to compile ZoneMinder with crash tracing included. This allows a + dump of the stack trace when a ZoneMinder binary crashes or is killed by an unexpected signal. + Although this should work on most systems it does rely on un(or loosely) documented features and + so should be regarded as experimental. If you experience problems compiling zm_signal.cpp or + ZoneMinder binaries fail to shut down correctly then you should probably disable this feature. + e.g. --enable-crashtrace=yes or --disable-crashtrace" >&5 +$as_echo "$as_me: WARNING: You can call configure with the --enable-crashtrace= or --disable-crashtrace option. + This tells configure whether to compile ZoneMinder with crash tracing included. This allows a + dump of the stack trace when a ZoneMinder binary crashes or is killed by an unexpected signal. + Although this should work on most systems it does rely on un(or loosely) documented features and + so should be regarded as experimental. If you experience problems compiling zm_signal.cpp or + ZoneMinder binaries fail to shut down correctly then you should probably disable this feature. + e.g. --enable-crashtrace=yes or --disable-crashtrace" >&2;} + +fi + +if test "$ENABLE_CRASHTRACE" != "yes"; then + +$as_echo "#define ZM_NO_CRASHTRACE 1" >>confdefs.h + +fi + +ENABLE_MMAP=yes +# Check whether --enable-mmap was given. +if test "${enable_mmap+set}" = set; then : + enableval=$enable_mmap; ENABLE_MMAP=$enable_mmap +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You can call configure with the --enable-mmap= or --disable-mmap option. + This tells configure whether to compile ZoneMinder with mmap support rather than IPC shared + memory. This is a feature that uses memory mapped into files which all processes can share. + Memory mapping requires less configuration and is more flexible than shared memory but may + slow down your system unless the mapped files are configured to reside on a fast or RAM based + filesystem which will normally be the case by default. + e.g. --enable-mmap=yes or --disable-mmap" >&5 +$as_echo "$as_me: WARNING: You can call configure with the --enable-mmap= or --disable-mmap option. + This tells configure whether to compile ZoneMinder with mmap support rather than IPC shared + memory. This is a feature that uses memory mapped into files which all processes can share. + Memory mapping requires less configuration and is more flexible than shared memory but may + slow down your system unless the mapped files are configured to reside on a fast or RAM based + filesystem which will normally be the case by default. + e.g. --enable-mmap=yes or --disable-mmap" >&2;} + +fi + +if test "$ENABLE_MMAP" == "yes"; then + +$as_echo "#define ZM_MEM_MAPPED 1" >>confdefs.h + +else + +$as_echo "#define ZM_MEM_MAPPED 0" >>confdefs.h + +fi + + +# Compiler +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +# Checks for programs. +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CXX+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 +$as_echo_n "checking whether the C++ compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ as_fn_set_status 77 +as_fn_error "C++ compiler cannot create executables +See \`config.log' for more details." "$LINENO" 5; }; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 +$as_echo_n "checking for C++ compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot run C++ compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if test "${ac_cv_objext+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot compute suffix of object files: cannot compile +See \`config.log' for more details." "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if test "${ac_cv_prog_cxx_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +else + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 +$as_echo_n "checking for style of include used by $am_make... " >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from `make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 +$as_echo "$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +depcc="$CXX" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "no acceptable C compiler found in \$PATH +See \`config.log' for more details." "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_RANLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + + +# Checks for typedefs, structures, and compiler characteristics. + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 +$as_echo_n "checking how to run the C++ preprocessor... " >&6; } +if test -z "$CXXCPP"; then + if test "${ac_cv_prog_CXXCPP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP +else + ac_cv_prog_CXXCPP=$CXXCPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 +$as_echo "$CXXCPP" >&6; } +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." "$LINENO" 5; } +fi + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if test "${ac_cv_path_GREP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if test "${ac_cv_header_stdc+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 +$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } +if test "${ac_cv_header_stdbool_h+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#ifndef bool + "error: bool is not defined" +#endif +#ifndef false + "error: false is not defined" +#endif +#if false + "error: false is not 0" +#endif +#ifndef true + "error: true is not defined" +#endif +#if true != 1 + "error: true is not 1" +#endif +#ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" +#endif + + struct s { _Bool s: 1; _Bool t; } s; + + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + bool e = &s; + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + /* The following fails for + HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; +# if defined __xlc__ || defined __GNUC__ + /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 + reported by James Lemley on 2005-10-05; see + http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html + This test is not quite right, since xlc is allowed to + reject this program, as the initializer for xlcbug is + not one of the forms that C requires support for. + However, doing the test right would require a runtime + test, and that would make cross-compilation harder. + Let us hope that IBM fixes the xlc bug, and also adds + support for this kind of constant expression. In the + meantime, this test will reject xlc, which is OK, since + our stdbool.h substitute should suffice. We also test + this with GCC, where it should work, to detect more + quickly whether someone messes up the test in the + future. */ + char digs[] = "0123456789"; + int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); +# endif + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; + +int +main () +{ + + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_header_stdbool_h=yes +else + ac_cv_header_stdbool_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 +$as_echo "$ac_cv_header_stdbool_h" >&6; } +ac_fn_cxx_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" +if test "x$ac_cv_type__Bool" = x""yes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE__BOOL 1 +_ACEOF + + +fi + +if test $ac_cv_header_stdbool_h = yes; then + +$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 +$as_echo_n "checking for an ANSI C-conforming const... " >&6; } +if test "${ac_cv_c_const+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset cs; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_c_const=yes +else + ac_cv_c_const=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 +$as_echo "$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +$as_echo "#define const /**/" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 +$as_echo_n "checking for uid_t in sys/types.h... " >&6; } +if test "${ac_cv_type_uid_t+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "uid_t" >/dev/null 2>&1; then : + ac_cv_type_uid_t=yes +else + ac_cv_type_uid_t=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 +$as_echo "$ac_cv_type_uid_t" >&6; } +if test $ac_cv_type_uid_t = no; then + +$as_echo "#define uid_t int" >>confdefs.h + + +$as_echo "#define gid_t int" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 +$as_echo_n "checking for inline... " >&6; } +if test "${ac_cv_c_inline+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_c_inline=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_inline" != no && break +done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 +$as_echo "$ac_cv_c_inline" >&6; } + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + +ac_fn_cxx_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" +if test "x$ac_cv_type_mode_t" = x""yes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define mode_t int +_ACEOF + +fi + +ac_fn_cxx_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = x""yes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 +$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } +if test "${ac_cv_header_time+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_header_time=yes +else + ac_cv_header_time=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 +$as_echo "$ac_cv_header_time" >&6; } +if test $ac_cv_header_time = yes; then + +$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 +$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } +if test "${ac_cv_struct_tm+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +struct tm tm; + int *p = &tm.tm_sec; + return !p; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_struct_tm=time.h +else + ac_cv_struct_tm=sys/time.h +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 +$as_echo "$ac_cv_struct_tm" >&6; } +if test $ac_cv_struct_tm = sys/time.h; then + +$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 +$as_echo_n "checking return type of signal handlers... " >&6; } +if test "${ac_cv_type_signal+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +return *(signal (0, 0)) (0) == 1; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_type_signal=int +else + ac_cv_type_signal=void +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 +$as_echo "$ac_cv_type_signal" >&6; } + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + + +ac_fn_cxx_check_type "$LINENO" "siginfo_t" "ac_cv_type_siginfo_t" "#include +" +if test "x$ac_cv_type_siginfo_t" = x""yes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_SIGINFO_T 1 +_ACEOF + + +fi + +ac_fn_cxx_check_type "$LINENO" "struct sigcontext" "ac_cv_type_struct_sigcontext" "#include +" +if test "x$ac_cv_type_struct_sigcontext" = x""yes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SIGCONTEXT 1 +_ACEOF + + +fi + +ac_fn_cxx_check_member "$LINENO" "struct sigcontext" "eip" "ac_cv_member_struct_sigcontext_eip" "#include +" +if test "x$ac_cv_member_struct_sigcontext_eip" = x""yes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SIGCONTEXT_EIP 1 +_ACEOF + + +fi + +ac_fn_cxx_check_type "$LINENO" "ucontext_t" "ac_cv_type_ucontext_t" "#include +" +if test "x$ac_cv_type_ucontext_t" = x""yes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_UCONTEXT_T 1 +_ACEOF + + +fi + + +# Checks for library functions. +if test $ac_cv_c_compiler_gnu = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 +$as_echo_n "checking whether $CC needs -traditional... " >&6; } +if test "${ac_cv_prog_gcc_traditional+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_pattern="Autoconf.*'x'" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +Autoconf TIOCGETP +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then : + ac_cv_prog_gcc_traditional=yes +else + ac_cv_prog_gcc_traditional=no +fi +rm -f conftest* + + + if test $ac_cv_prog_gcc_traditional = no; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +Autoconf TCGETA +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then : + ac_cv_prog_gcc_traditional=yes +fi +rm -f conftest* + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5 +$as_echo "$ac_cv_prog_gcc_traditional" >&6; } + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi + +for ac_header in stdlib.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" +if test "x$ac_cv_header_stdlib_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STDLIB_H 1 +_ACEOF + +fi + +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 +$as_echo_n "checking for GNU libc compatible malloc... " >&6; } +if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_malloc_0_nonnull=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined STDC_HEADERS || defined HAVE_STDLIB_H +# include +#else +char *malloc (); +#endif + +int +main () +{ +return ! malloc (0); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + ac_cv_func_malloc_0_nonnull=yes +else + ac_cv_func_malloc_0_nonnull=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 +$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } +if test $ac_cv_func_malloc_0_nonnull = yes; then : + +$as_echo "#define HAVE_MALLOC 1" >>confdefs.h + +else + $as_echo "#define HAVE_MALLOC 0" >>confdefs.h + + case " $LIBOBJS " in + *" malloc.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS malloc.$ac_objext" + ;; +esac + + +$as_echo "#define malloc rpl_malloc" >>confdefs.h + +fi + + + + + + for ac_header in $ac_header_list +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + + +for ac_func in getpagesize +do : + ac_fn_cxx_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize" +if test "x$ac_cv_func_getpagesize" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_GETPAGESIZE 1 +_ACEOF + +fi +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5 +$as_echo_n "checking for working mmap... " >&6; } +if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_mmap_fixed_mapped=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +/* malloc might have been renamed as rpl_malloc. */ +#undef malloc + +/* Thanks to Mike Haertel and Jim Avera for this test. + Here is a matrix of mmap possibilities: + mmap private not fixed + mmap private fixed at somewhere currently unmapped + mmap private fixed at somewhere already mapped + mmap shared not fixed + mmap shared fixed at somewhere currently unmapped + mmap shared fixed at somewhere already mapped + For private mappings, we should verify that changes cannot be read() + back from the file, nor mmap's back from the file at a different + address. (There have been systems where private was not correctly + implemented like the infamous i386 svr4.0, and systems where the + VM page cache was not coherent with the file system buffer cache + like early versions of FreeBSD and possibly contemporary NetBSD.) + For shared mappings, we should conversely verify that changes get + propagated back to all the places they're supposed to be. + + Grep wants private fixed already mapped. + The main things grep needs to know about mmap are: + * does it exist and is it safe to write into the mmap'd area + * how to use it (BSD variants) */ + +#include +#include + +#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H +char *malloc (); +#endif + +/* This mess was copied from the GNU getpagesize.h. */ +#ifndef HAVE_GETPAGESIZE +# ifdef _SC_PAGESIZE +# define getpagesize() sysconf(_SC_PAGESIZE) +# else /* no _SC_PAGESIZE */ +# ifdef HAVE_SYS_PARAM_H +# include +# ifdef EXEC_PAGESIZE +# define getpagesize() EXEC_PAGESIZE +# else /* no EXEC_PAGESIZE */ +# ifdef NBPG +# define getpagesize() NBPG * CLSIZE +# ifndef CLSIZE +# define CLSIZE 1 +# endif /* no CLSIZE */ +# else /* no NBPG */ +# ifdef NBPC +# define getpagesize() NBPC +# else /* no NBPC */ +# ifdef PAGESIZE +# define getpagesize() PAGESIZE +# endif /* PAGESIZE */ +# endif /* no NBPC */ +# endif /* no NBPG */ +# endif /* no EXEC_PAGESIZE */ +# else /* no HAVE_SYS_PARAM_H */ +# define getpagesize() 8192 /* punt totally */ +# endif /* no HAVE_SYS_PARAM_H */ +# endif /* no _SC_PAGESIZE */ + +#endif /* no HAVE_GETPAGESIZE */ + +int +main () +{ + char *data, *data2, *data3; + int i, pagesize; + int fd, fd2; + + pagesize = getpagesize (); + + /* First, make a file with some known garbage in it. */ + data = (char *) malloc (pagesize); + if (!data) + return 1; + for (i = 0; i < pagesize; ++i) + *(data + i) = rand (); + umask (0); + fd = creat ("conftest.mmap", 0600); + if (fd < 0) + return 2; + if (write (fd, data, pagesize) != pagesize) + return 3; + close (fd); + + /* Next, check that the tail of a page is zero-filled. File must have + non-zero length, otherwise we risk SIGBUS for entire page. */ + fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600); + if (fd2 < 0) + return 4; + data2 = ""; + if (write (fd2, data2, 1) != 1) + return 5; + data2 = mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L); + if (data2 == MAP_FAILED) + return 6; + for (i = 0; i < pagesize; ++i) + if (*(data2 + i)) + return 7; + close (fd2); + if (munmap (data2, pagesize)) + return 8; + + /* Next, try to mmap the file at a fixed address which already has + something else allocated at it. If we can, also make sure that + we see the same garbage. */ + fd = open ("conftest.mmap", O_RDWR); + if (fd < 0) + return 9; + if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_FIXED, fd, 0L)) + return 10; + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data2 + i)) + return 11; + + /* Finally, make sure that changes to the mapped area do not + percolate back to the file as seen by read(). (This is a bug on + some variants of i386 svr4.0.) */ + for (i = 0; i < pagesize; ++i) + *(data2 + i) = *(data2 + i) + 1; + data3 = (char *) malloc (pagesize); + if (!data3) + return 12; + if (read (fd, data3, pagesize) != pagesize) + return 13; + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data3 + i)) + return 14; + close (fd); + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + ac_cv_func_mmap_fixed_mapped=yes +else + ac_cv_func_mmap_fixed_mapped=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_fixed_mapped" >&5 +$as_echo "$ac_cv_func_mmap_fixed_mapped" >&6; } +if test $ac_cv_func_mmap_fixed_mapped = yes; then + +$as_echo "#define HAVE_MMAP 1" >>confdefs.h + +fi +rm -f conftest.mmap conftest.txt + +for ac_header in sys/select.h sys/socket.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for select" >&5 +$as_echo_n "checking types of arguments for select... " >&6; } +if test "${ac_cv_func_select_args+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + for ac_arg234 in 'fd_set *' 'int *' 'void *'; do + for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do + for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_SELECT_H +# include +#endif +#ifdef HAVE_SYS_SOCKET_H +# include +#endif + +int +main () +{ +extern int select ($ac_arg1, + $ac_arg234, $ac_arg234, $ac_arg234, + $ac_arg5); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done + done +done +# Provide a safe default value. +: ${ac_cv_func_select_args='int,int *,struct timeval *'} + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_select_args" >&5 +$as_echo "$ac_cv_func_select_args" >&6; } +ac_save_IFS=$IFS; IFS=',' +set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` +IFS=$ac_save_IFS +shift + +cat >>confdefs.h <<_ACEOF +#define SELECT_TYPE_ARG1 $1 +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define SELECT_TYPE_ARG234 ($2) +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define SELECT_TYPE_ARG5 ($3) +_ACEOF + +rm -f conftest* + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat correctly handles trailing slash" >&5 +$as_echo_n "checking whether lstat correctly handles trailing slash... " >&6; } +if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + rm -f conftest.sym conftest.file +echo >conftest.file +if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then + if test "$cross_compiling" = yes; then : + ac_cv_func_lstat_dereferences_slashed_symlink=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +struct stat sbuf; + /* Linux will dereference the symlink and fail, as required by POSIX. + That is better in the sense that it means we will not + have to compile and use the lstat wrapper. */ + return lstat ("conftest.sym/", &sbuf) == 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + ac_cv_func_lstat_dereferences_slashed_symlink=yes +else + ac_cv_func_lstat_dereferences_slashed_symlink=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +else + # If the `ln -s' command failed, then we probably don't even + # have an lstat function. + ac_cv_func_lstat_dereferences_slashed_symlink=no +fi +rm -f conftest.sym conftest.file + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 +$as_echo "$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } + +test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && + +cat >>confdefs.h <<_ACEOF +#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 +_ACEOF + + +if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then + case " $LIBOBJS " in + *" lstat.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS lstat.$ac_objext" + ;; +esac + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat accepts an empty string" >&5 +$as_echo_n "checking whether stat accepts an empty string... " >&6; } +if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_stat_empty_string_bug=yes +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +struct stat sbuf; + return stat ("", &sbuf) == 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + ac_cv_func_stat_empty_string_bug=no +else + ac_cv_func_stat_empty_string_bug=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_stat_empty_string_bug" >&5 +$as_echo "$ac_cv_func_stat_empty_string_bug" >&6; } +if test $ac_cv_func_stat_empty_string_bug = yes; then + case " $LIBOBJS " in + *" stat.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS stat.$ac_objext" + ;; +esac + + +cat >>confdefs.h <<_ACEOF +#define HAVE_STAT_EMPTY_STRING_BUG 1 +_ACEOF + +fi + +for ac_func in strftime +do : + ac_fn_cxx_check_func "$LINENO" "strftime" "ac_cv_func_strftime" +if test "x$ac_cv_func_strftime" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STRFTIME 1 +_ACEOF + +else + # strftime is in -lintl on SCO UNIX. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strftime in -lintl" >&5 +$as_echo_n "checking for strftime in -lintl... " >&6; } +if test "${ac_cv_lib_intl_strftime+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lintl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char strftime (); +int +main () +{ +return strftime (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_intl_strftime=yes +else + ac_cv_lib_intl_strftime=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_strftime" >&5 +$as_echo "$ac_cv_lib_intl_strftime" >&6; } +if test "x$ac_cv_lib_intl_strftime" = x""yes; then : + $as_echo "#define HAVE_STRFTIME 1" >>confdefs.h + +LIBS="-lintl $LIBS" +fi + +fi +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strtod" >&5 +$as_echo_n "checking for working strtod... " >&6; } +if test "${ac_cv_func_strtod+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_strtod=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +$ac_includes_default +#ifndef strtod +double strtod (); +#endif +int +main() +{ + { + /* Some versions of Linux strtod mis-parse strings with leading '+'. */ + char *string = " +69"; + char *term; + double value; + value = strtod (string, &term); + if (value != 69 || term != (string + 4)) + return 1; + } + + { + /* Under Solaris 2.4, strtod returns the wrong value for the + terminating character under some conditions. */ + char *string = "NaN"; + char *term; + strtod (string, &term); + if (term != string && *(term - 1) == 0) + return 1; + } + return 0; +} + +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + ac_cv_func_strtod=yes +else + ac_cv_func_strtod=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strtod" >&5 +$as_echo "$ac_cv_func_strtod" >&6; } +if test $ac_cv_func_strtod = no; then + case " $LIBOBJS " in + *" strtod.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtod.$ac_objext" + ;; +esac + +ac_fn_cxx_check_func "$LINENO" "pow" "ac_cv_func_pow" +if test "x$ac_cv_func_pow" = x""yes; then : + +fi + +if test $ac_cv_func_pow = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 +$as_echo_n "checking for pow in -lm... " >&6; } +if test "${ac_cv_lib_m_pow+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pow (); +int +main () +{ +return pow (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_m_pow=yes +else + ac_cv_lib_m_pow=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 +$as_echo "$ac_cv_lib_m_pow" >&6; } +if test "x$ac_cv_lib_m_pow" = x""yes; then : + POW_LIB=-lm +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find library containing definition of pow" >&5 +$as_echo "$as_me: WARNING: cannot find library containing definition of pow" >&2;} +fi + +fi + +fi + +for ac_func in vprintf +do : + ac_fn_cxx_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" +if test "x$ac_cv_func_vprintf" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_VPRINTF 1 +_ACEOF + +ac_fn_cxx_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" +if test "x$ac_cv_func__doprnt" = x""yes; then : + +$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h + +fi + +fi +done + + +for ac_func in gethostbyname gethostname gettimeofday memmove memset mkdir munmap posix_memalign putenv select sendfile socket sqrt strcasecmp strchr strcspn strerror strncasecmp strrchr strsignal strspn strstr strtol strtoull +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +for ac_func in syscall sleep usleep ioctl ioctlsocket sigaction +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +# Other programs +# Extract the first word of "ffmpeg", so it can be a program name with args. +set dummy ffmpeg; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_OPT_FFMPEG+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OPT_FFMPEG"; then + ac_cv_prog_OPT_FFMPEG="$OPT_FFMPEG" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OPT_FFMPEG="yes" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_OPT_FFMPEG" && ac_cv_prog_OPT_FFMPEG="no" +fi +fi +OPT_FFMPEG=$ac_cv_prog_OPT_FFMPEG +if test -n "$OPT_FFMPEG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPT_FFMPEG" >&5 +$as_echo "$OPT_FFMPEG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "ffmpeg", so it can be a program name with args. +set dummy ffmpeg; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_PATH_FFMPEG+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $PATH_FFMPEG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PATH_FFMPEG="$PATH_FFMPEG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_PATH_FFMPEG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +PATH_FFMPEG=$ac_cv_path_PATH_FFMPEG +if test -n "$PATH_FFMPEG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PATH_FFMPEG" >&5 +$as_echo "$PATH_FFMPEG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "pnmscale", so it can be a program name with args. +set dummy pnmscale; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_OPT_NETPBM+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OPT_NETPBM"; then + ac_cv_prog_OPT_NETPBM="$OPT_NETPBM" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OPT_NETPBM="yes" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_OPT_NETPBM" && ac_cv_prog_OPT_NETPBM="no" +fi +fi +OPT_NETPBM=$ac_cv_prog_OPT_NETPBM +if test -n "$OPT_NETPBM"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPT_NETPBM" >&5 +$as_echo "$OPT_NETPBM" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "pnmscale", so it can be a program name with args. +set dummy pnmscale; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_PATH_NETPBM+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $PATH_NETPBM in + [\\/]* | ?:[\\/]*) + ac_cv_path_PATH_NETPBM="$PATH_NETPBM" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_PATH_NETPBM="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +PATH_NETPBM=$ac_cv_path_PATH_NETPBM +if test -n "$PATH_NETPBM"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PATH_NETPBM" >&5 +$as_echo "$PATH_NETPBM" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +if test "$OPT_NETPBM" == "yes"; then +PATH_NETPBM=`dirname $PATH_NETPBM` +fi + +# Checks for libraries. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql_init in -lmysqlclient" >&5 +$as_echo_n "checking for mysql_init in -lmysqlclient... " >&6; } +if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lmysqlclient $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char mysql_init (); +int +main () +{ +return mysql_init (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_mysqlclient_mysql_init=yes +else + ac_cv_lib_mysqlclient_mysql_init=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mysqlclient_mysql_init" >&5 +$as_echo "$ac_cv_lib_mysqlclient_mysql_init" >&6; } +if test "x$ac_cv_lib_mysqlclient_mysql_init" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBMYSQLCLIENT 1 +_ACEOF + + LIBS="-lmysqlclient $LIBS" + +else + as_fn_error "zm requires libmysqlclient.a" "$LINENO" 5 +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_start_compress in -ljpeg" >&5 +$as_echo_n "checking for jpeg_start_compress in -ljpeg... " >&6; } +if test "${ac_cv_lib_jpeg_jpeg_start_compress+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ljpeg $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char jpeg_start_compress (); +int +main () +{ +return jpeg_start_compress (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_jpeg_jpeg_start_compress=yes +else + ac_cv_lib_jpeg_jpeg_start_compress=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_start_compress" >&5 +$as_echo "$ac_cv_lib_jpeg_jpeg_start_compress" >&6; } +if test "x$ac_cv_lib_jpeg_jpeg_start_compress" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBJPEG 1 +_ACEOF + + LIBS="-ljpeg $LIBS" + +else + as_fn_error "zm requires libjpeg.a" "$LINENO" 5 +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 +$as_echo_n "checking for pthread_create in -lpthread... " >&6; } +if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpthread $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_create (); +int +main () +{ +return pthread_create (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_pthread_pthread_create=yes +else + ac_cv_lib_pthread_pthread_create=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 +$as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } +if test "x$ac_cv_lib_pthread_pthread_create" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBPTHREAD 1 +_ACEOF + + LIBS="-lpthread $LIBS" + +else + as_fn_error "zm requires libpthread.a" "$LINENO" 5 +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlsym in -ldl" >&5 +$as_echo_n "checking for dlsym in -ldl... " >&6; } +if test "${ac_cv_lib_dl_dlsym+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlsym (); +int +main () +{ +return dlsym (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_dl_dlsym=yes +else + ac_cv_lib_dl_dlsym=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlsym" >&5 +$as_echo "$ac_cv_lib_dl_dlsym" >&6; } +if test "x$ac_cv_lib_dl_dlsym" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBDL 1 +_ACEOF + + LIBS="-ldl $LIBS" + +else + as_fn_error "zm requires libdl.a" "$LINENO" 5 +fi + +if test "$ZM_SSL_LIB" == "openssl"; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5 in -lcrypto" >&5 +$as_echo_n "checking for MD5 in -lcrypto... " >&6; } +if test "${ac_cv_lib_crypto_MD5+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcrypto $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char MD5 (); +int +main () +{ +return MD5 (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_crypto_MD5=yes +else + ac_cv_lib_crypto_MD5=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_MD5" >&5 +$as_echo "$ac_cv_lib_crypto_MD5" >&6; } +if test "x$ac_cv_lib_crypto_MD5" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBCRYPTO 1 +_ACEOF + + LIBS="-lcrypto $LIBS" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcrypto.a is required for authenticated streaming - use ZM_SSL_LIB option to select gnutls instead" >&5 +$as_echo "$as_me: WARNING: libcrypto.a is required for authenticated streaming - use ZM_SSL_LIB option to select gnutls instead" >&2;} +fi + +else +for ac_header in gcrypt.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "gcrypt.h" "ac_cv_header_gcrypt_h" "$ac_includes_default" +if test "x$ac_cv_header_gcrypt_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_GCRYPT_H 1 +_ACEOF + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: zm requires libgcrypt headers to be installed for gnutls" >&5 +$as_echo "$as_me: WARNING: zm requires libgcrypt headers to be installed for gnutls" >&2;} +fi + +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcry_check_version in -lgcrypt" >&5 +$as_echo_n "checking for gcry_check_version in -lgcrypt... " >&6; } +if test "${ac_cv_lib_gcrypt_gcry_check_version+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lgcrypt $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gcry_check_version (); +int +main () +{ +return gcry_check_version (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_gcrypt_gcry_check_version=yes +else + ac_cv_lib_gcrypt_gcry_check_version=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gcrypt_gcry_check_version" >&5 +$as_echo "$ac_cv_lib_gcrypt_gcry_check_version" >&6; } +if test "x$ac_cv_lib_gcrypt_gcry_check_version" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBGCRYPT 1 +_ACEOF + + LIBS="-lgcrypt $LIBS" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libgcrypt.a is required for authenticated streaming - use ZM_SSL_LIB option to select openssl instead" >&5 +$as_echo "$as_me: WARNING: libgcrypt.a is required for authenticated streaming - use ZM_SSL_LIB option to select openssl instead" >&2;} +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5 in -lgnutls-openssl" >&5 +$as_echo_n "checking for MD5 in -lgnutls-openssl... " >&6; } +if test "${ac_cv_lib_gnutls_openssl_MD5+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lgnutls-openssl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char MD5 (); +int +main () +{ +return MD5 (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_gnutls_openssl_MD5=yes +else + ac_cv_lib_gnutls_openssl_MD5=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gnutls_openssl_MD5" >&5 +$as_echo "$ac_cv_lib_gnutls_openssl_MD5" >&6; } +if test "x$ac_cv_lib_gnutls_openssl_MD5" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBGNUTLS_OPENSSL 1 +_ACEOF + + LIBS="-lgnutls-openssl $LIBS" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: gnutls-openssl.a is required for authenticated streaming - use ZM_SSL_LIB option to select openssl instead" >&5 +$as_echo "$as_me: WARNING: gnutls-openssl.a is required for authenticated streaming - use ZM_SSL_LIB option to select openssl instead" >&2;} +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre_compile in -lpcre" >&5 +$as_echo_n "checking for pcre_compile in -lpcre... " >&6; } +if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpcre $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pcre_compile (); +int +main () +{ +return pcre_compile (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_pcre_pcre_compile=yes +else + ac_cv_lib_pcre_pcre_compile=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcre_pcre_compile" >&5 +$as_echo "$ac_cv_lib_pcre_pcre_compile" >&6; } +if test "x$ac_cv_lib_pcre_pcre_compile" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBPCRE 1 +_ACEOF + + LIBS="-lpcre $LIBS" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libpcre.a may be required for remote/network camera support" >&5 +$as_echo "$as_me: WARNING: libpcre.a may be required for remote/network camera support" >&2;} +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlibVersion in -lz" >&5 +$as_echo_n "checking for zlibVersion in -lz... " >&6; } +if test "${ac_cv_lib_z_zlibVersion+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char zlibVersion (); +int +main () +{ +return zlibVersion (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_z_zlibVersion=yes +else + ac_cv_lib_z_zlibVersion=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_zlibVersion" >&5 +$as_echo "$ac_cv_lib_z_zlibVersion" >&6; } +if test "x$ac_cv_lib_z_zlibVersion" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBZ 1 +_ACEOF + + LIBS="-lz $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x264_predict_16x16_init in -lx264" >&5 +$as_echo_n "checking for x264_predict_16x16_init in -lx264... " >&6; } +if test "${ac_cv_lib_x264_x264_predict_16x16_init+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lx264 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char x264_predict_16x16_init (); +int +main () +{ +return x264_predict_16x16_init (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_x264_x264_predict_16x16_init=yes +else + ac_cv_lib_x264_x264_predict_16x16_init=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_x264_x264_predict_16x16_init" >&5 +$as_echo "$ac_cv_lib_x264_x264_predict_16x16_init" >&6; } +if test "x$ac_cv_lib_x264_x264_predict_16x16_init" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBX264 1 +_ACEOF + + LIBS="-lx264 $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_malloc in -lavutil" >&5 +$as_echo_n "checking for av_malloc in -lavutil... " >&6; } +if test "${ac_cv_lib_avutil_av_malloc+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lavutil $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char av_malloc (); +int +main () +{ +return av_malloc (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_avutil_av_malloc=yes +else + ac_cv_lib_avutil_av_malloc=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avutil_av_malloc" >&5 +$as_echo "$ac_cv_lib_avutil_av_malloc" >&6; } +if test "x$ac_cv_lib_avutil_av_malloc" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBAVUTIL 1 +_ACEOF + + LIBS="-lavutil $LIBS" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libavutil.a may be required for MPEG streaming" >&5 +$as_echo "$as_me: WARNING: libavutil.a may be required for MPEG streaming" >&2;} +fi + +# Don't bother to warn about this one +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_image_copy in -lavcore" >&5 +$as_echo_n "checking for av_image_copy in -lavcore... " >&6; } +if test "${ac_cv_lib_avcore_av_image_copy+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lavcore $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char av_image_copy (); +int +main () +{ +return av_image_copy (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_avcore_av_image_copy=yes +else + ac_cv_lib_avcore_av_image_copy=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avcore_av_image_copy" >&5 +$as_echo "$ac_cv_lib_avcore_av_image_copy" >&6; } +if test "x$ac_cv_lib_avcore_av_image_copy" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBAVCORE 1 +_ACEOF + + LIBS="-lavcore $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for avcodec_init in -lavcodec" >&5 +$as_echo_n "checking for avcodec_init in -lavcodec... " >&6; } +if test "${ac_cv_lib_avcodec_avcodec_init+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lavcodec $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char avcodec_init (); +int +main () +{ +return avcodec_init (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_avcodec_avcodec_init=yes +else + ac_cv_lib_avcodec_avcodec_init=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avcodec_avcodec_init" >&5 +$as_echo "$ac_cv_lib_avcodec_avcodec_init" >&6; } +if test "x$ac_cv_lib_avcodec_avcodec_init" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBAVCODEC 1 +_ACEOF + + LIBS="-lavcodec $LIBS" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libavcodec.a is required for MPEG streaming" >&5 +$as_echo "$as_me: WARNING: libavcodec.a is required for MPEG streaming" >&2;} +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_new_stream in -lavformat" >&5 +$as_echo_n "checking for av_new_stream in -lavformat... " >&6; } +if test "${ac_cv_lib_avformat_av_new_stream+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lavformat $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char av_new_stream (); +int +main () +{ +return av_new_stream (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_avformat_av_new_stream=yes +else + ac_cv_lib_avformat_av_new_stream=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avformat_av_new_stream" >&5 +$as_echo "$ac_cv_lib_avformat_av_new_stream" >&6; } +if test "x$ac_cv_lib_avformat_av_new_stream" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBAVFORMAT 1 +_ACEOF + + LIBS="-lavformat $LIBS" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libavformat.a is required for MPEG streaming" >&5 +$as_echo "$as_me: WARNING: libavformat.a is required for MPEG streaming" >&2;} +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for avdevice_register_all in -lavdevice" >&5 +$as_echo_n "checking for avdevice_register_all in -lavdevice... " >&6; } +if test "${ac_cv_lib_avdevice_avdevice_register_all+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lavdevice $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char avdevice_register_all (); +int +main () +{ +return avdevice_register_all (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_avdevice_avdevice_register_all=yes +else + ac_cv_lib_avdevice_avdevice_register_all=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avdevice_avdevice_register_all" >&5 +$as_echo "$ac_cv_lib_avdevice_avdevice_register_all" >&6; } +if test "x$ac_cv_lib_avdevice_avdevice_register_all" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBAVDEVICE 1 +_ACEOF + + LIBS="-lavdevice $LIBS" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libavdevice.a may be required for MPEG streaming" >&5 +$as_echo "$as_me: WARNING: libavdevice.a may be required for MPEG streaming" >&2;} +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sws_scale in -lswscale" >&5 +$as_echo_n "checking for sws_scale in -lswscale... " >&6; } +if test "${ac_cv_lib_swscale_sws_scale+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lswscale -lswscale $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sws_scale (); +int +main () +{ +return sws_scale (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_swscale_sws_scale=yes +else + ac_cv_lib_swscale_sws_scale=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_swscale_sws_scale" >&5 +$as_echo "$ac_cv_lib_swscale_sws_scale" >&6; } +if test "x$ac_cv_lib_swscale_sws_scale" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSWSCALE 1 +_ACEOF + + LIBS="-lswscale $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -lbz2" >&5 +$as_echo_n "checking for BZ2_bzCompress in -lbz2... " >&6; } +if test "${ac_cv_lib_bz2_BZ2_bzCompress+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbz2 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char BZ2_bzCompress (); +int +main () +{ +return BZ2_bzCompress (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_bz2_BZ2_bzCompress=yes +else + ac_cv_lib_bz2_BZ2_bzCompress=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzCompress" >&5 +$as_echo "$ac_cv_lib_bz2_BZ2_bzCompress" >&6; } +if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBBZ2 1 +_ACEOF + + LIBS="-lbz2 $LIBS" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: zm requires libbz2.a for recent versions of ffmpeg" >&5 +$as_echo "$as_me: WARNING: zm requires libbz2.a for recent versions of ffmpeg" >&2;} +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compress in -lz" >&5 +$as_echo_n "checking for compress in -lz... " >&6; } +if test "${ac_cv_lib_z_compress+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char compress (); +int +main () +{ +return compress (); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_lib_z_compress=yes +else + ac_cv_lib_z_compress=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5 +$as_echo "$ac_cv_lib_z_compress" >&6; } +if test "x$ac_cv_lib_z_compress" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBZ 1 +_ACEOF + + LIBS="-lz $LIBS" + +fi + + +# Checks for header files. +# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works +# for constant arguments. Useless! +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 +$as_echo_n "checking for working alloca.h... " >&6; } +if test "${ac_cv_working_alloca_h+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +char *p = (char *) alloca (2 * sizeof (int)); + if (p) return 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_working_alloca_h=yes +else + ac_cv_working_alloca_h=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 +$as_echo "$ac_cv_working_alloca_h" >&6; } +if test $ac_cv_working_alloca_h = yes; then + +$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 +$as_echo_n "checking for alloca... " >&6; } +if test "${ac_cv_func_alloca_works+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __GNUC__ +# define alloca __builtin_alloca +#else +# ifdef _MSC_VER +# include +# define alloca _alloca +# else +# ifdef HAVE_ALLOCA_H +# include +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +char *alloca (); +# endif +# endif +# endif +# endif +#endif + +int +main () +{ +char *p = (char *) alloca (1); + if (p) return 0; + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_func_alloca_works=yes +else + ac_cv_func_alloca_works=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 +$as_echo "$ac_cv_func_alloca_works" >&6; } + +if test $ac_cv_func_alloca_works = yes; then + +$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h + +else + # The SVR3 libPW and SVR4 libucb both contain incompatible functions +# that cause trouble. Some versions do not even contain alloca or +# contain a buggy version. If you still want to use their alloca, +# use ar to extract alloca.o from them instead of compiling alloca.c. + +ALLOCA=\${LIBOBJDIR}alloca.$ac_objext + +$as_echo "#define C_ALLOCA 1" >>confdefs.h + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 +$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } +if test "${ac_cv_os_cray+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined CRAY && ! defined CRAY2 +webecray +#else +wenotbecray +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "webecray" >/dev/null 2>&1; then : + ac_cv_os_cray=yes +else + ac_cv_os_cray=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 +$as_echo "$ac_cv_os_cray" >&6; } +if test $ac_cv_os_cray = yes; then + for ac_func in _getb67 GETB67 getb67; do + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : + +cat >>confdefs.h <<_ACEOF +#define CRAY_STACKSEG_END $ac_func +_ACEOF + + break +fi + + done +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 +$as_echo_n "checking stack direction for C alloca... " >&6; } +if test "${ac_cv_c_stack_direction+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_c_stack_direction=0 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +find_stack_direction () +{ + static char *addr = 0; + auto char dummy; + if (addr == 0) + { + addr = &dummy; + return find_stack_direction (); + } + else + return (&dummy > addr) ? 1 : -1; +} + +int +main () +{ + return find_stack_direction () < 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + ac_cv_c_stack_direction=1 +else + ac_cv_c_stack_direction=-1 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 +$as_echo "$ac_cv_c_stack_direction" >&6; } +cat >>confdefs.h <<_ACEOF +#define STACK_DIRECTION $ac_cv_c_stack_direction +_ACEOF + + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if test "${ac_cv_header_stdc+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +for ac_header in fcntl.h limits.h memory.h stddef.h stdlib.h string.h strings.h sys/param.h sys/time.h syslog.h unistd.h values.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +for ac_header in netdb.h netinet/in.h arpa/inet.h sys/ioctl.h sys/socket.h sys/un.h glob.h sys/sendfile.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +for ac_header in execinfo.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "execinfo.h" "ac_cv_header_execinfo_h" "$ac_includes_default" +if test "x$ac_cv_header_execinfo_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_EXECINFO_H 1 +_ACEOF + +fi + +done + +for ac_header in syscall.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "syscall.h" "ac_cv_header_syscall_h" "$ac_includes_default" +if test "x$ac_cv_header_syscall_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYSCALL_H 1 +_ACEOF + +fi + +done + +for ac_header in pthread.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" +if test "x$ac_cv_header_pthread_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_PTHREAD_H 1 +_ACEOF + +fi + +done + +for ac_header in linux/videodev.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "linux/videodev.h" "ac_cv_header_linux_videodev_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_videodev_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINUX_VIDEODEV_H 1 +_ACEOF + ZM_HAS_V4L1=1 + +else + ZM_HAS_V4L1=0 + +fi + +done + +for ac_header in linux/videodev2.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "linux/videodev2.h" "ac_cv_header_linux_videodev2_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_videodev2_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LINUX_VIDEODEV2_H 1 +_ACEOF + ZM_HAS_V4L2=1 + +else + ZM_HAS_V4L2=0 + +fi + +done + +if test "$ZM_HAS_V4L1" == "1" || test "$ZM_HAS_V4L2" == "1"; then +ZM_HAS_V4L=1 + +else +ZM_HAS_V4L=0 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: zm requires Video4Linux or Video4Linux2 to be installed for analog or USB camera support" >&5 +$as_echo "$as_me: WARNING: zm requires Video4Linux or Video4Linux2 to be installed for analog or USB camera support" >&2;} +fi +for ac_header in jpeglib.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "jpeglib.h" "ac_cv_header_jpeglib_h" "$ac_includes_default" +if test "x$ac_cv_header_jpeglib_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_JPEGLIB_H 1 +_ACEOF + +else + as_fn_error "zm requires libjpeg headers to be installed" "$LINENO" 5 +fi + +done + +for ac_header in mysql/mysql.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "mysql/mysql.h" "ac_cv_header_mysql_mysql_h" "$ac_includes_default" +if test "x$ac_cv_header_mysql_mysql_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MYSQL_MYSQL_H 1 +_ACEOF + +else + as_fn_error "zm requires MySQL headers - check that MySQL development packages are installed" "$LINENO" 5 +fi + +done + +for ac_header in libavutil/avutil.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "libavutil/avutil.h" "ac_cv_header_libavutil_avutil_h" "$ac_includes_default" +if test "x$ac_cv_header_libavutil_avutil_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBAVUTIL_AVUTIL_H 1 +_ACEOF + +fi + +done + +for ac_header in libavcodec/avcodec.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "libavcodec/avcodec.h" "ac_cv_header_libavcodec_avcodec_h" "$ac_includes_default" +if test "x$ac_cv_header_libavcodec_avcodec_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBAVCODEC_AVCODEC_H 1 +_ACEOF + +fi + +done + +for ac_header in libavformat/avformat.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "libavformat/avformat.h" "ac_cv_header_libavformat_avformat_h" "$ac_includes_default" +if test "x$ac_cv_header_libavformat_avformat_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBAVFORMAT_AVFORMAT_H 1 +_ACEOF + +fi + +done + +for ac_header in libswscale/swscale.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "libswscale/swscale.h" "ac_cv_header_libswscale_swscale_h" "$ac_includes_default" +if test "x$ac_cv_header_libswscale_swscale_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSWSCALE_SWSCALE_H 1 +_ACEOF + +fi + +done + +for ac_header in pcre/pcre.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "pcre/pcre.h" "ac_cv_header_pcre_pcre_h" "$ac_includes_default" +if test "x$ac_cv_header_pcre_pcre_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_PCRE_PCRE_H 1 +_ACEOF + ZM_PCRE="1" + +fi + +done + +for ac_header in pcre.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "pcre.h" "ac_cv_header_pcre_h" "$ac_includes_default" +if test "x$ac_cv_header_pcre_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_PCRE_H 1 +_ACEOF + ZM_PCRE="1" + +fi + +done + +if test "$ENABLE_MMAP" == "yes"; then +for ac_header in sys/mman.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_mman_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_MMAN_H 1 +_ACEOF + +fi + +done + +for ac_header in fcntl.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "fcntl.h" "ac_cv_header_fcntl_h" "$ac_includes_default" +if test "x$ac_cv_header_fcntl_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_FCNTL_H 1 +_ACEOF + +fi + +done + +else +for ac_header in sys/ipc.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "sys/ipc.h" "ac_cv_header_sys_ipc_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_ipc_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_IPC_H 1 +_ACEOF + +fi + +done + +for ac_header in sys/shm.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "sys/shm.h" "ac_cv_header_sys_shm_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_shm_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_SHM_H 1 +_ACEOF + +fi + +done + +fi +for ac_header in zlib.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" +if test "x$ac_cv_header_zlib_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_ZLIB_H 1 +_ACEOF + +fi + +done + + +ac_fn_cxx_check_decl "$LINENO" "round" "ac_cv_have_decl_round" "#include +" +if test "x$ac_cv_have_decl_round" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ROUND $ac_have_decl +_ACEOF + +if test "$ZM_SSL_LIB" == "openssl"; then +ac_fn_cxx_check_decl "$LINENO" "MD5" "ac_cv_have_decl_MD5" "#include +#include +" +if test "x$ac_cv_have_decl_MD5" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_MD5 $ac_have_decl +_ACEOF +if test $ac_have_decl = 1; then : + +else + as_fn_error "zm requires openssl/md5.h - use ZM_SSL_LIB option to select gnutls instead" "$LINENO" 5 +fi + +else +ac_fn_cxx_check_decl "$LINENO" "MD5" "ac_cv_have_decl_MD5" "#include +#include +" +if test "x$ac_cv_have_decl_MD5" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_MD5 $ac_have_decl +_ACEOF +if test $ac_have_decl = 1; then : + +else + as_fn_error "zm requires gnutls/openssl.h - use ZM_SSL_LIB option to select openssl instead" "$LINENO" 5 +fi + +fi +ac_fn_cxx_check_decl "$LINENO" "backtrace" "ac_cv_have_decl_backtrace" "#include +" +if test "x$ac_cv_have_decl_backtrace" = x""yes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_BACKTRACE $ac_have_decl +_ACEOF + + + + +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +# Check if version of Perl is sufficient +ac_perl_version="5.6.0" + +if test "x$PERL" != "x"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl version greater than or equal to $ac_perl_version" >&5 +$as_echo_n "checking for perl version greater than or equal to $ac_perl_version... " >&6; } + # NB: It would be nice to log the error if there is one, but we cannot rely + # on autoconf internals + $PERL -e "use $ac_perl_version;" > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi + + +# Compulsory perl modules +ac_perl_modules="Sys::Syslog" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + as_fn_error "zm requires SYS:Syslog" "$LINENO" 5 + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="DBI" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + as_fn_error "zm requires DBI" "$LINENO" 5 + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="DBD::mysql" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + as_fn_error "zm requires DBD::mysql" "$LINENO" 5 + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="Getopt::Long" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + as_fn_error "zm requires Getopt::Long" "$LINENO" 5 + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="Time::HiRes" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + as_fn_error "zm requires Time::HiRes" "$LINENO" 5 + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="Date::Manip" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + as_fn_error "zm requires Date::Manip" "$LINENO" 5 + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="LWP::UserAgent" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + as_fn_error "zm requires LWP::UserAgent" "$LINENO" 5 + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="ExtUtils::MakeMaker" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + as_fn_error "zm requires ExtUtils::MakeMaker" "$LINENO" 5 + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +if test "$ENABLE_MMAP" == "yes"; then +ac_perl_modules="Sys::Mmap" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + as_fn_error "zm requires Sys::Mmap for mapped memory - set --enable-mmap=no to use IPC shared memory instead" "$LINENO" 5 + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +fi + +# Optional perl modules +ac_perl_modules="Module::Load" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Module::Load is required for PTZ camera control" >&5 +$as_echo "$as_me: WARNING: Module::Load is required for PTZ camera control" >&2;} + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="Device::SerialPort" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Device::SerialPort is required for RS232/RS485 PTZ camera control" >&5 +$as_echo "$as_me: WARNING: Device::SerialPort is required for RS232/RS485 PTZ camera control" >&2;} + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="Net::FTP" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Net::FTP is required for automatic event uploading" >&5 +$as_echo "$as_me: WARNING: Net::FTP is required for automatic event uploading" >&2;} + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="Archive::Tar" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Archive::Tar may be required for automatic event uploading" >&5 +$as_echo "$as_me: WARNING: Archive::Tar may be required for automatic event uploading" >&2;} + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="Archive::Zip" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Archive::Zip may be required for automatic event uploading" >&5 +$as_echo "$as_me: WARNING: Archive::Zip may be required for automatic event uploading" >&2;} + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="Net::SMTP" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Net::SMTP may be required for automatic event email notification" >&5 +$as_echo "$as_me: WARNING: Net::SMTP may be required for automatic event email notification" >&2;} + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="MIME::Lite" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MIME::Lite may be required for automatic event email notification" >&5 +$as_echo "$as_me: WARNING: MIME::Lite may be required for automatic event email notification" >&2;} + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="MIME::Entity" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MIME::Entity may be required for automatic event email notification" >&5 +$as_echo "$as_me: WARNING: MIME::Entity may be required for automatic event email notification" >&2;} + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="X10::ActiveHome" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_PERL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: X10::ActiveHome is required for X.10 support" >&5 +$as_echo "$as_me: WARNING: X10::ActiveHome is required for X.10 support" >&2;} + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi + + + prefix_NONE= + exec_prefix_NONE= + test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix + test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix + eval ac_define_dir="\"$bindir\"" + eval ac_define_dir="\"$ac_define_dir\"" + BINDIR="$ac_define_dir" + + +cat >>confdefs.h <<_ACEOF +#define BINDIR "$ac_define_dir" +_ACEOF + + test "$prefix_NONE" && prefix=NONE + test "$exec_prefix_NONE" && exec_prefix=NONE + + + prefix_NONE= + exec_prefix_NONE= + test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix + test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix + eval ac_define_dir="\"$libdir\"" + eval ac_define_dir="\"$ac_define_dir\"" + LIBDIR="$ac_define_dir" + + +cat >>confdefs.h <<_ACEOF +#define LIBDIR "$ac_define_dir" +_ACEOF + + test "$prefix_NONE" && prefix=NONE + test "$exec_prefix_NONE" && exec_prefix=NONE + +ZM_PID="$ZM_RUNDIR/zm.pid" + + + prefix_NONE= + exec_prefix_NONE= + test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix + test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix + eval ac_define_dir="\"$sysconfdir\"" + eval ac_define_dir="\"$ac_define_dir\"" + SYSCONFDIR="$ac_define_dir" + + +cat >>confdefs.h <<_ACEOF +#define SYSCONFDIR "$ac_define_dir" +_ACEOF + + test "$prefix_NONE" && prefix=NONE + test "$exec_prefix_NONE" && exec_prefix=NONE + +ZM_CONFIG="$SYSCONFDIR/zm.conf" + + +# Slight hack for non-standard perl install paths +if test "$prefix" != "NONE"; then + PERL_SITE_PREFIX=`perl -V:siteprefix | sed -e "s/.*='\(.*\)';/\1/"` + PERL_SITE_LIB=`perl -V:installsitelib | sed -e "s/.*='\(.*\)';/\1/"` + PERL_LIB_PATH=`echo $PERL_SITE_LIB | sed -e "s|^$PERL_SITE_PREFIX||"` + EXTRA_PERL_LIB="use lib '$prefix$PERL_LIB_PATH'; # Include custom perl install path" + PERL_MM_PARMS="PREFIX=$prefix" +else + EXTRA_PERL_LIB="# Include from system perl paths only" + PERL_MM_PARMS= +fi + + + +ac_config_files="$ac_config_files Makefile zm.conf zmconfgen.pl db/Makefile db/zm_create.sql misc/Makefile misc/apache.conf misc/logrotate.conf misc/syslog.conf scripts/Makefile scripts/zm scripts/zmaudit.pl scripts/zmcontrol.pl scripts/zmdc.pl scripts/zmfilter.pl scripts/zmpkg.pl scripts/zmtrack.pl scripts/zmtrigger.pl scripts/zmupdate.pl scripts/zmvideo.pl scripts/zmwatch.pl scripts/zmx10.pl scripts/zmdbbackup scripts/zmdbrestore scripts/zmeventdump scripts/zmlogrotate.conf scripts/ZoneMinder/lib/ZoneMinder/Base.pm scripts/ZoneMinder/lib/ZoneMinder/Config.pm scripts/ZoneMinder/lib/ZoneMinder/Memory.pm scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm src/Makefile src/zm_config.h web/Makefile web/ajax/Makefile web/css/Makefile web/graphics/Makefile web/includes/Makefile web/includes/config.php web/js/Makefile web/lang/Makefile web/skins/Makefile web/skins/classic/Makefile web/skins/classic/ajax/Makefile web/skins/classic/css/Makefile web/skins/classic/graphics/Makefile web/skins/classic/includes/Makefile web/skins/classic/js/Makefile web/skins/classic/lang/Makefile web/skins/classic/views/Makefile web/skins/classic/views/css/Makefile web/skins/classic/views/js/Makefile web/skins/mobile/Makefile web/skins/mobile/ajax/Makefile web/skins/mobile/css/Makefile web/skins/mobile/graphics/Makefile web/skins/mobile/includes/Makefile web/skins/mobile/lang/Makefile web/skins/mobile/views/Makefile web/skins/mobile/views/css/Makefile web/tools/Makefile web/tools/mootools/Makefile web/views/Makefile web/skins/xml/Makefile web/skins/xml/views/Makefile web/skins/xml/includes/Makefile" + + +# Create the definitions for compilation and defaults for the database +ac_config_commands="$ac_config_commands src/zm_config_defines.h" + +# Manually generate the perl Makefile maker +ac_config_commands="$ac_config_commands scripts/ZoneMinder/Makefile" + + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + if test -n "$EXEEXT"; then + am__EXEEXT_TRUE= + am__EXEEXT_FALSE='#' +else + am__EXEEXT_TRUE='#' + am__EXEEXT_FALSE= +fi + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + as_fn_error "conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + as_fn_error "conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + as_fn_error "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi + +: ${CONFIG_STATUS=./config.status} +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with status $?, using 1 if that was 0. +as_fn_error () +{ + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by zm $as_me 1.25.0, which was +generated by GNU Autoconf 2.65. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to . +zm home page: ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +zm config.status 1.25.0 +configured by $0, generated by GNU Autoconf 2.65, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2009 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" +PERL_MM_PARMS=$PERL_MM_PARMS + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "zm.conf") CONFIG_FILES="$CONFIG_FILES zm.conf" ;; + "zmconfgen.pl") CONFIG_FILES="$CONFIG_FILES zmconfgen.pl" ;; + "db/Makefile") CONFIG_FILES="$CONFIG_FILES db/Makefile" ;; + "db/zm_create.sql") CONFIG_FILES="$CONFIG_FILES db/zm_create.sql" ;; + "misc/Makefile") CONFIG_FILES="$CONFIG_FILES misc/Makefile" ;; + "misc/apache.conf") CONFIG_FILES="$CONFIG_FILES misc/apache.conf" ;; + "misc/logrotate.conf") CONFIG_FILES="$CONFIG_FILES misc/logrotate.conf" ;; + "misc/syslog.conf") CONFIG_FILES="$CONFIG_FILES misc/syslog.conf" ;; + "scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;; + "scripts/zm") CONFIG_FILES="$CONFIG_FILES scripts/zm" ;; + "scripts/zmaudit.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmaudit.pl" ;; + "scripts/zmcontrol.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmcontrol.pl" ;; + "scripts/zmdc.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmdc.pl" ;; + "scripts/zmfilter.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmfilter.pl" ;; + "scripts/zmpkg.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmpkg.pl" ;; + "scripts/zmtrack.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmtrack.pl" ;; + "scripts/zmtrigger.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmtrigger.pl" ;; + "scripts/zmupdate.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmupdate.pl" ;; + "scripts/zmvideo.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmvideo.pl" ;; + "scripts/zmwatch.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmwatch.pl" ;; + "scripts/zmx10.pl") CONFIG_FILES="$CONFIG_FILES scripts/zmx10.pl" ;; + "scripts/zmdbbackup") CONFIG_FILES="$CONFIG_FILES scripts/zmdbbackup" ;; + "scripts/zmdbrestore") CONFIG_FILES="$CONFIG_FILES scripts/zmdbrestore" ;; + "scripts/zmeventdump") CONFIG_FILES="$CONFIG_FILES scripts/zmeventdump" ;; + "scripts/zmlogrotate.conf") CONFIG_FILES="$CONFIG_FILES scripts/zmlogrotate.conf" ;; + "scripts/ZoneMinder/lib/ZoneMinder/Base.pm") CONFIG_FILES="$CONFIG_FILES scripts/ZoneMinder/lib/ZoneMinder/Base.pm" ;; + "scripts/ZoneMinder/lib/ZoneMinder/Config.pm") CONFIG_FILES="$CONFIG_FILES scripts/ZoneMinder/lib/ZoneMinder/Config.pm" ;; + "scripts/ZoneMinder/lib/ZoneMinder/Memory.pm") CONFIG_FILES="$CONFIG_FILES scripts/ZoneMinder/lib/ZoneMinder/Memory.pm" ;; + "scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm") CONFIG_FILES="$CONFIG_FILES scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm" ;; + "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; + "src/zm_config.h") CONFIG_FILES="$CONFIG_FILES src/zm_config.h" ;; + "web/Makefile") CONFIG_FILES="$CONFIG_FILES web/Makefile" ;; + "web/ajax/Makefile") CONFIG_FILES="$CONFIG_FILES web/ajax/Makefile" ;; + "web/css/Makefile") CONFIG_FILES="$CONFIG_FILES web/css/Makefile" ;; + "web/graphics/Makefile") CONFIG_FILES="$CONFIG_FILES web/graphics/Makefile" ;; + "web/includes/Makefile") CONFIG_FILES="$CONFIG_FILES web/includes/Makefile" ;; + "web/includes/config.php") CONFIG_FILES="$CONFIG_FILES web/includes/config.php" ;; + "web/js/Makefile") CONFIG_FILES="$CONFIG_FILES web/js/Makefile" ;; + "web/lang/Makefile") CONFIG_FILES="$CONFIG_FILES web/lang/Makefile" ;; + "web/skins/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/Makefile" ;; + "web/skins/classic/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/Makefile" ;; + "web/skins/classic/ajax/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/ajax/Makefile" ;; + "web/skins/classic/css/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/css/Makefile" ;; + "web/skins/classic/graphics/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/graphics/Makefile" ;; + "web/skins/classic/includes/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/includes/Makefile" ;; + "web/skins/classic/js/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/js/Makefile" ;; + "web/skins/classic/lang/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/lang/Makefile" ;; + "web/skins/classic/views/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/views/Makefile" ;; + "web/skins/classic/views/css/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/views/css/Makefile" ;; + "web/skins/classic/views/js/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/classic/views/js/Makefile" ;; + "web/skins/mobile/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/Makefile" ;; + "web/skins/mobile/ajax/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/ajax/Makefile" ;; + "web/skins/mobile/css/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/css/Makefile" ;; + "web/skins/mobile/graphics/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/graphics/Makefile" ;; + "web/skins/mobile/includes/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/includes/Makefile" ;; + "web/skins/mobile/lang/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/lang/Makefile" ;; + "web/skins/mobile/views/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/views/Makefile" ;; + "web/skins/mobile/views/css/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/mobile/views/css/Makefile" ;; + "web/tools/Makefile") CONFIG_FILES="$CONFIG_FILES web/tools/Makefile" ;; + "web/tools/mootools/Makefile") CONFIG_FILES="$CONFIG_FILES web/tools/mootools/Makefile" ;; + "web/views/Makefile") CONFIG_FILES="$CONFIG_FILES web/views/Makefile" ;; + "web/skins/xml/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/xml/Makefile" ;; + "web/skins/xml/views/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/xml/views/Makefile" ;; + "web/skins/xml/includes/Makefile") CONFIG_FILES="$CONFIG_FILES web/skins/xml/includes/Makefile" ;; + "src/zm_config_defines.h") CONFIG_COMMANDS="$CONFIG_COMMANDS src/zm_config_defines.h" ;; + "scripts/ZoneMinder/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS scripts/ZoneMinder/Makefile" ;; + + *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ + || as_fn_error "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then + break + elif $ac_last_try; then + as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + esac \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$tmp/config.h" "$ac_file" \ + || as_fn_error "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error "could not create -" "$LINENO" 5 + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir=$dirpart/$fdir; as_fn_mkdir_p + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} + ;; + "src/zm_config_defines.h":C) perl ./zmconfgen.pl ;; + "scripts/ZoneMinder/Makefile":C) (cd scripts/ZoneMinder; echo "perl Makefile.PL $PERL_MM_PARMS"; perl Makefile.PL $PERL_MM_PARMS) ;; + + esac +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit $? +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/src/zm_config_defines.h b/src/zm_config_defines.h new file mode 100644 index 000000000..b26a1bb1e --- /dev/null +++ b/src/zm_config_defines.h @@ -0,0 +1,637 @@ +// The file is autogenerated by zmconfgen.pl +// Do not edit this file as any changes will be overwritten + +#define ZM_LANG_DEFAULT 0 +#define ZM_OPT_USE_AUTH 1 +#define ZM_AUTH_TYPE 2 +#define ZM_AUTH_RELAY 3 +#define ZM_AUTH_HASH_SECRET 4 +#define ZM_AUTH_HASH_IPS 5 +#define ZM_AUTH_HASH_LOGINS 6 +#define ZM_DIR_EVENTS 7 +#define ZM_USE_DEEP_STORAGE 8 +#define ZM_DIR_IMAGES 9 +#define ZM_DIR_SOUNDS 10 +#define ZM_PATH_ZMS 11 +#define ZM_COLOUR_JPEG_FILES 12 +#define ZM_ADD_JPEG_COMMENTS 13 +#define ZM_JPEG_FILE_QUALITY 14 +#define ZM_JPEG_ALARM_FILE_QUALITY 15 +#define ZM_JPEG_IMAGE_QUALITY 16 +#define ZM_JPEG_STREAM_QUALITY 17 +#define ZM_MPEG_TIMED_FRAMES 18 +#define ZM_MPEG_LIVE_FORMAT 19 +#define ZM_MPEG_REPLAY_FORMAT 20 +#define ZM_RAND_STREAM 21 +#define ZM_OPT_CAMBOZOLA 22 +#define ZM_PATH_CAMBOZOLA 23 +#define ZM_RELOAD_CAMBOZOLA 24 +#define ZM_TIMESTAMP_ON_CAPTURE 25 +#define ZM_CPU_EXTENSIONS 26 +#define ZM_FAST_IMAGE_BLENDS 27 +#define ZM_OPT_ADAPTIVE_SKIP 28 +#define ZM_BLEND_ALARMED_IMAGES 29 +#define ZM_MAX_SUSPEND_TIME 30 +#define ZM_OPT_REMOTE_CAMERAS 31 +#define ZM_NETCAM_REGEXPS 32 +#define ZM_HTTP_VERSION 33 +#define ZM_HTTP_UA 34 +#define ZM_HTTP_TIMEOUT 35 +#define ZM_MIN_RTP_PORT 36 +#define ZM_MAX_RTP_PORT 37 +#define ZM_OPT_FFMPEG 38 +#define ZM_PATH_FFMPEG 39 +#define ZM_FFMPEG_INPUT_OPTIONS 40 +#define ZM_FFMPEG_OUTPUT_OPTIONS 41 +#define ZM_FFMPEG_FORMATS 42 +#define ZM_LOG_LEVEL_SYSLOG 43 +#define ZM_LOG_LEVEL_FILE 44 +#define ZM_LOG_LEVEL_WEBLOG 45 +#define ZM_LOG_LEVEL_DATABASE 46 +#define ZM_LOG_DATABASE_LIMIT 47 +#define ZM_LOG_DEBUG 48 +#define ZM_LOG_DEBUG_TARGET 49 +#define ZM_LOG_DEBUG_LEVEL 50 +#define ZM_LOG_DEBUG_FILE 51 +#define ZM_LOG_CHECK_PERIOD 52 +#define ZM_LOG_ALERT_WAR_COUNT 53 +#define ZM_LOG_ALERT_ERR_COUNT 54 +#define ZM_LOG_ALERT_FAT_COUNT 55 +#define ZM_LOG_ALARM_WAR_COUNT 56 +#define ZM_LOG_ALARM_ERR_COUNT 57 +#define ZM_LOG_ALARM_FAT_COUNT 58 +#define ZM_RECORD_EVENT_STATS 59 +#define ZM_RECORD_DIAG_IMAGES 60 +#define ZM_DUMP_CORES 61 +#define ZM_PATH_MAP 62 +#define ZM_PATH_SOCKS 63 +#define ZM_PATH_LOGS 64 +#define ZM_PATH_SWAP 65 +#define ZM_WEB_TITLE_PREFIX 66 +#define ZM_WEB_RESIZE_CONSOLE 67 +#define ZM_WEB_POPUP_ON_ALARM 68 +#define ZM_OPT_X10 69 +#define ZM_X10_DEVICE 70 +#define ZM_X10_HOUSE_CODE 71 +#define ZM_X10_DB_RELOAD_INTERVAL 72 +#define ZM_WEB_SOUND_ON_ALARM 73 +#define ZM_WEB_ALARM_SOUND 74 +#define ZM_WEB_COMPACT_MONTAGE 75 +#define ZM_OPT_FAST_DELETE 76 +#define ZM_STRICT_VIDEO_CONFIG 77 +#define ZM_V4L2_CAPTURE_FIELDS 78 +#define ZM_SIGNAL_CHECK_POINTS 79 +#define ZM_V4L_MULTI_BUFFER 80 +#define ZM_CAPTURES_PER_FRAME 81 +#define ZM_FILTER_RELOAD_DELAY 82 +#define ZM_FILTER_EXECUTE_INTERVAL 83 +#define ZM_OPT_UPLOAD 84 +#define ZM_UPLOAD_ARCH_FORMAT 85 +#define ZM_UPLOAD_ARCH_COMPRESS 86 +#define ZM_UPLOAD_ARCH_ANALYSE 87 +#define ZM_UPLOAD_FTP_HOST 88 +#define ZM_UPLOAD_FTP_USER 89 +#define ZM_UPLOAD_FTP_PASS 90 +#define ZM_UPLOAD_FTP_LOC_DIR 91 +#define ZM_UPLOAD_FTP_REM_DIR 92 +#define ZM_UPLOAD_FTP_TIMEOUT 93 +#define ZM_UPLOAD_FTP_PASSIVE 94 +#define ZM_UPLOAD_FTP_DEBUG 95 +#define ZM_OPT_EMAIL 96 +#define ZM_EMAIL_ADDRESS 97 +#define ZM_EMAIL_TEXT 98 +#define ZM_EMAIL_SUBJECT 99 +#define ZM_EMAIL_BODY 100 +#define ZM_OPT_MESSAGE 101 +#define ZM_MESSAGE_ADDRESS 102 +#define ZM_MESSAGE_TEXT 103 +#define ZM_MESSAGE_SUBJECT 104 +#define ZM_MESSAGE_BODY 105 +#define ZM_NEW_MAIL_MODULES 106 +#define ZM_EMAIL_HOST 107 +#define ZM_FROM_EMAIL 108 +#define ZM_URL 109 +#define ZM_MAX_RESTART_DELAY 110 +#define ZM_WATCH_CHECK_INTERVAL 111 +#define ZM_WATCH_MAX_DELAY 112 +#define ZM_RUN_AUDIT 113 +#define ZM_AUDIT_CHECK_INTERVAL 114 +#define ZM_FORCED_ALARM_SCORE 115 +#define ZM_BULK_FRAME_INTERVAL 116 +#define ZM_EVENT_CLOSE_MODE 117 +#define ZM_FORCE_CLOSE_EVENTS 118 +#define ZM_CREATE_ANALYSIS_IMAGES 119 +#define ZM_WEIGHTED_ALARM_CENTRES 120 +#define ZM_EVENT_IMAGE_DIGITS 121 +#define ZM_DEFAULT_ASPECT_RATIO 122 +#define ZM_USER_SELF_EDIT 123 +#define ZM_OPT_FRAME_SERVER 124 +#define ZM_FRAME_SOCKET_SIZE 125 +#define ZM_OPT_CONTROL 126 +#define ZM_OPT_TRIGGERS 127 +#define ZM_CHECK_FOR_UPDATES 128 +#define ZM_UPDATE_CHECK_PROXY 129 +#define ZM_SHM_KEY 130 +#define ZM_WEB_REFRESH_METHOD 131 +#define ZM_WEB_EVENT_SORT_FIELD 132 +#define ZM_WEB_EVENT_SORT_ORDER 133 +#define ZM_WEB_EVENTS_PER_PAGE 134 +#define ZM_WEB_LIST_THUMBS 135 +#define ZM_WEB_LIST_THUMB_WIDTH 136 +#define ZM_WEB_LIST_THUMB_HEIGHT 137 +#define ZM_WEB_USE_OBJECT_TAGS 138 +#define ZM_WEB_H_REFRESH_MAIN 139 +#define ZM_WEB_H_REFRESH_CYCLE 140 +#define ZM_WEB_H_REFRESH_IMAGE 141 +#define ZM_WEB_H_REFRESH_STATUS 142 +#define ZM_WEB_H_REFRESH_EVENTS 143 +#define ZM_WEB_H_CAN_STREAM 144 +#define ZM_WEB_H_STREAM_METHOD 145 +#define ZM_WEB_H_DEFAULT_SCALE 146 +#define ZM_WEB_H_DEFAULT_RATE 147 +#define ZM_WEB_H_VIDEO_BITRATE 148 +#define ZM_WEB_H_VIDEO_MAXFPS 149 +#define ZM_WEB_H_SCALE_THUMBS 150 +#define ZM_WEB_H_EVENTS_VIEW 151 +#define ZM_WEB_H_SHOW_PROGRESS 152 +#define ZM_WEB_H_AJAX_TIMEOUT 153 +#define ZM_WEB_M_REFRESH_MAIN 154 +#define ZM_WEB_M_REFRESH_CYCLE 155 +#define ZM_WEB_M_REFRESH_IMAGE 156 +#define ZM_WEB_M_REFRESH_STATUS 157 +#define ZM_WEB_M_REFRESH_EVENTS 158 +#define ZM_WEB_M_CAN_STREAM 159 +#define ZM_WEB_M_STREAM_METHOD 160 +#define ZM_WEB_M_DEFAULT_SCALE 161 +#define ZM_WEB_M_DEFAULT_RATE 162 +#define ZM_WEB_M_VIDEO_BITRATE 163 +#define ZM_WEB_M_VIDEO_MAXFPS 164 +#define ZM_WEB_M_SCALE_THUMBS 165 +#define ZM_WEB_M_EVENTS_VIEW 166 +#define ZM_WEB_M_SHOW_PROGRESS 167 +#define ZM_WEB_M_AJAX_TIMEOUT 168 +#define ZM_WEB_L_REFRESH_MAIN 169 +#define ZM_WEB_L_REFRESH_CYCLE 170 +#define ZM_WEB_L_REFRESH_IMAGE 171 +#define ZM_WEB_L_REFRESH_STATUS 172 +#define ZM_WEB_L_REFRESH_EVENTS 173 +#define ZM_WEB_L_CAN_STREAM 174 +#define ZM_WEB_L_STREAM_METHOD 175 +#define ZM_WEB_L_DEFAULT_SCALE 176 +#define ZM_WEB_L_DEFAULT_RATE 177 +#define ZM_WEB_L_VIDEO_BITRATE 178 +#define ZM_WEB_L_VIDEO_MAXFPS 179 +#define ZM_WEB_L_SCALE_THUMBS 180 +#define ZM_WEB_L_EVENTS_VIEW 181 +#define ZM_WEB_L_SHOW_PROGRESS 182 +#define ZM_WEB_L_AJAX_TIMEOUT 183 +#define ZM_WEB_P_CAN_STREAM 184 +#define ZM_WEB_P_STREAM_METHOD 185 +#define ZM_WEB_P_DEFAULT_SCALE 186 +#define ZM_WEB_P_DEFAULT_RATE 187 +#define ZM_WEB_P_VIDEO_BITRATE 188 +#define ZM_WEB_P_VIDEO_MAXFPS 189 +#define ZM_WEB_P_SCALE_THUMBS 190 +#define ZM_WEB_P_AJAX_TIMEOUT 191 +#define ZM_DYN_LAST_VERSION 192 +#define ZM_DYN_CURR_VERSION 193 +#define ZM_DYN_DB_VERSION 194 +#define ZM_DYN_LAST_CHECK 195 +#define ZM_DYN_NEXT_REMINDER 196 +#define ZM_DYN_DONATE_REMINDER_TIME 197 +#define ZM_DYN_SHOW_DONATE_REMINDER 198 +#define ZM_EYEZM_DEBUG 199 +#define ZM_EYEZM_LOG_TO_FILE 200 +#define ZM_EYEZM_LOG_FILE 201 +#define ZM_EYEZM_EVENT_VCODEC 202 +#define ZM_EYEZM_FEED_VCODEC 203 +#define ZM_EYEZM_H264_DEFAULT_BR 204 +#define ZM_EYEZM_H264_DEFAULT_EVBR 205 +#define ZM_EYEZM_H264_TIMEOUT 206 +#define ZM_EYEZM_SEG_DURATION 207 + + +#define ZM_MAX_CFG_ID 207 + +#define ZM_CFG_DECLARE_LIST \ + const char *lang_default;\ + bool opt_use_auth;\ + const char *auth_type;\ + const char *auth_relay;\ + const char *auth_hash_secret;\ + bool auth_hash_ips;\ + bool auth_hash_logins;\ + const char *dir_events;\ + bool use_deep_storage;\ + const char *dir_images;\ + const char *dir_sounds;\ + const char *path_zms;\ + bool colour_jpeg_files;\ + bool add_jpeg_comments;\ + int jpeg_file_quality;\ + int jpeg_alarm_file_quality;\ + int jpeg_image_quality;\ + int jpeg_stream_quality;\ + bool mpeg_timed_frames;\ + const char *mpeg_live_format;\ + const char *mpeg_replay_format;\ + bool rand_stream;\ + bool opt_cambozola;\ + const char *path_cambozola;\ + int reload_cambozola;\ + bool timestamp_on_capture;\ + bool cpu_extensions;\ + bool fast_image_blends;\ + bool opt_adaptive_skip;\ + bool blend_alarmed_images;\ + int max_suspend_time;\ + bool opt_remote_cameras;\ + bool netcam_regexps;\ + const char *http_version;\ + const char *http_ua;\ + int http_timeout;\ + int min_rtp_port;\ + int max_rtp_port;\ + bool opt_ffmpeg;\ + const char *path_ffmpeg;\ + const char *ffmpeg_input_options;\ + const char *ffmpeg_output_options;\ + const char *ffmpeg_formats;\ + int log_level_syslog;\ + int log_level_file;\ + int log_level_weblog;\ + int log_level_database;\ + const char *log_database_limit;\ + bool log_debug;\ + const char *log_debug_target;\ + int log_debug_level;\ + const char *log_debug_file;\ + int log_check_period;\ + int log_alert_war_count;\ + int log_alert_err_count;\ + int log_alert_fat_count;\ + int log_alarm_war_count;\ + int log_alarm_err_count;\ + int log_alarm_fat_count;\ + bool record_event_stats;\ + bool record_diag_images;\ + bool dump_cores;\ + const char *path_map;\ + const char *path_socks;\ + const char *path_logs;\ + const char *path_swap;\ + const char *web_title_prefix;\ + bool web_resize_console;\ + bool web_popup_on_alarm;\ + bool opt_x10;\ + const char *x10_device;\ + const char *x10_house_code;\ + int x10_db_reload_interval;\ + bool web_sound_on_alarm;\ + const char *web_alarm_sound;\ + bool web_compact_montage;\ + bool opt_fast_delete;\ + bool strict_video_config;\ + int v4l2_capture_fields;\ + int signal_check_points;\ + bool v4l_multi_buffer;\ + int captures_per_frame;\ + int filter_reload_delay;\ + int filter_execute_interval;\ + bool opt_upload;\ + const char *upload_arch_format;\ + bool upload_arch_compress;\ + bool upload_arch_analyse;\ + const char *upload_ftp_host;\ + const char *upload_ftp_user;\ + const char *upload_ftp_pass;\ + const char *upload_ftp_loc_dir;\ + const char *upload_ftp_rem_dir;\ + int upload_ftp_timeout;\ + bool upload_ftp_passive;\ + bool upload_ftp_debug;\ + bool opt_email;\ + const char *email_address;\ + const char *email_text;\ + const char *email_subject;\ + const char *email_body;\ + bool opt_message;\ + const char *message_address;\ + const char *message_text;\ + const char *message_subject;\ + const char *message_body;\ + bool new_mail_modules;\ + const char *email_host;\ + const char *from_email;\ + const char *url;\ + int max_restart_delay;\ + int watch_check_interval;\ + double watch_max_delay;\ + bool run_audit;\ + int audit_check_interval;\ + int forced_alarm_score;\ + int bulk_frame_interval;\ + const char *event_close_mode;\ + bool force_close_events;\ + bool create_analysis_images;\ + bool weighted_alarm_centres;\ + int event_image_digits;\ + const char *default_aspect_ratio;\ + bool user_self_edit;\ + bool opt_frame_server;\ + int frame_socket_size;\ + bool opt_control;\ + bool opt_triggers;\ + bool check_for_updates;\ + const char *update_check_proxy;\ + int shm_key;\ + const char *web_refresh_method;\ + const char *web_event_sort_field;\ + const char *web_event_sort_order;\ + int web_events_per_page;\ + bool web_list_thumbs;\ + int web_list_thumb_width;\ + int web_list_thumb_height;\ + bool web_use_object_tags;\ + int web_h_refresh_main;\ + int web_h_refresh_cycle;\ + int web_h_refresh_image;\ + int web_h_refresh_status;\ + int web_h_refresh_events;\ + const char *web_h_can_stream;\ + const char *web_h_stream_method;\ + int web_h_default_scale;\ + int web_h_default_rate;\ + int web_h_video_bitrate;\ + int web_h_video_maxfps;\ + bool web_h_scale_thumbs;\ + const char *web_h_events_view;\ + bool web_h_show_progress;\ + int web_h_ajax_timeout;\ + int web_m_refresh_main;\ + int web_m_refresh_cycle;\ + int web_m_refresh_image;\ + int web_m_refresh_status;\ + int web_m_refresh_events;\ + const char *web_m_can_stream;\ + const char *web_m_stream_method;\ + int web_m_default_scale;\ + int web_m_default_rate;\ + int web_m_video_bitrate;\ + int web_m_video_maxfps;\ + bool web_m_scale_thumbs;\ + const char *web_m_events_view;\ + bool web_m_show_progress;\ + int web_m_ajax_timeout;\ + int web_l_refresh_main;\ + int web_l_refresh_cycle;\ + int web_l_refresh_image;\ + int web_l_refresh_status;\ + int web_l_refresh_events;\ + const char *web_l_can_stream;\ + const char *web_l_stream_method;\ + int web_l_default_scale;\ + int web_l_default_rate;\ + int web_l_video_bitrate;\ + int web_l_video_maxfps;\ + bool web_l_scale_thumbs;\ + const char *web_l_events_view;\ + bool web_l_show_progress;\ + int web_l_ajax_timeout;\ + const char *web_p_can_stream;\ + const char *web_p_stream_method;\ + int web_p_default_scale;\ + int web_p_default_rate;\ + int web_p_video_bitrate;\ + int web_p_video_maxfps;\ + bool web_p_scale_thumbs;\ + int web_p_ajax_timeout;\ + const char *dyn_last_version;\ + const char *dyn_curr_version;\ + const char *dyn_db_version;\ + int dyn_last_check;\ + const char *dyn_next_reminder;\ + int dyn_donate_reminder_time;\ + bool dyn_show_donate_reminder;\ + bool eyezm_debug;\ + bool eyezm_log_to_file;\ + const char *eyezm_log_file;\ + const char *eyezm_event_vcodec;\ + const char *eyezm_feed_vcodec;\ + const char *eyezm_h264_default_br;\ + const char *eyezm_h264_default_evbr;\ + const char *eyezm_h264_timeout;\ + const char *eyezm_seg_duration;\ + + +#define ZM_CFG_ASSIGN_LIST \ + lang_default = (const char *)config.Item( ZM_LANG_DEFAULT );\ + opt_use_auth = (bool)config.Item( ZM_OPT_USE_AUTH );\ + auth_type = (const char *)config.Item( ZM_AUTH_TYPE );\ + auth_relay = (const char *)config.Item( ZM_AUTH_RELAY );\ + auth_hash_secret = (const char *)config.Item( ZM_AUTH_HASH_SECRET );\ + auth_hash_ips = (bool)config.Item( ZM_AUTH_HASH_IPS );\ + auth_hash_logins = (bool)config.Item( ZM_AUTH_HASH_LOGINS );\ + dir_events = (const char *)config.Item( ZM_DIR_EVENTS );\ + use_deep_storage = (bool)config.Item( ZM_USE_DEEP_STORAGE );\ + dir_images = (const char *)config.Item( ZM_DIR_IMAGES );\ + dir_sounds = (const char *)config.Item( ZM_DIR_SOUNDS );\ + path_zms = (const char *)config.Item( ZM_PATH_ZMS );\ + colour_jpeg_files = (bool)config.Item( ZM_COLOUR_JPEG_FILES );\ + add_jpeg_comments = (bool)config.Item( ZM_ADD_JPEG_COMMENTS );\ + jpeg_file_quality = (int)config.Item( ZM_JPEG_FILE_QUALITY );\ + jpeg_alarm_file_quality = (int)config.Item( ZM_JPEG_ALARM_FILE_QUALITY );\ + jpeg_image_quality = (int)config.Item( ZM_JPEG_IMAGE_QUALITY );\ + jpeg_stream_quality = (int)config.Item( ZM_JPEG_STREAM_QUALITY );\ + mpeg_timed_frames = (bool)config.Item( ZM_MPEG_TIMED_FRAMES );\ + mpeg_live_format = (const char *)config.Item( ZM_MPEG_LIVE_FORMAT );\ + mpeg_replay_format = (const char *)config.Item( ZM_MPEG_REPLAY_FORMAT );\ + rand_stream = (bool)config.Item( ZM_RAND_STREAM );\ + opt_cambozola = (bool)config.Item( ZM_OPT_CAMBOZOLA );\ + path_cambozola = (const char *)config.Item( ZM_PATH_CAMBOZOLA );\ + reload_cambozola = (int)config.Item( ZM_RELOAD_CAMBOZOLA );\ + timestamp_on_capture = (bool)config.Item( ZM_TIMESTAMP_ON_CAPTURE );\ + cpu_extensions = (bool)config.Item( ZM_CPU_EXTENSIONS );\ + fast_image_blends = (bool)config.Item( ZM_FAST_IMAGE_BLENDS );\ + opt_adaptive_skip = (bool)config.Item( ZM_OPT_ADAPTIVE_SKIP );\ + blend_alarmed_images = (bool)config.Item( ZM_BLEND_ALARMED_IMAGES );\ + max_suspend_time = (int)config.Item( ZM_MAX_SUSPEND_TIME );\ + opt_remote_cameras = (bool)config.Item( ZM_OPT_REMOTE_CAMERAS );\ + netcam_regexps = (bool)config.Item( ZM_NETCAM_REGEXPS );\ + http_version = (const char *)config.Item( ZM_HTTP_VERSION );\ + http_ua = (const char *)config.Item( ZM_HTTP_UA );\ + http_timeout = (int)config.Item( ZM_HTTP_TIMEOUT );\ + min_rtp_port = (int)config.Item( ZM_MIN_RTP_PORT );\ + max_rtp_port = (int)config.Item( ZM_MAX_RTP_PORT );\ + opt_ffmpeg = (bool)config.Item( ZM_OPT_FFMPEG );\ + path_ffmpeg = (const char *)config.Item( ZM_PATH_FFMPEG );\ + ffmpeg_input_options = (const char *)config.Item( ZM_FFMPEG_INPUT_OPTIONS );\ + ffmpeg_output_options = (const char *)config.Item( ZM_FFMPEG_OUTPUT_OPTIONS );\ + ffmpeg_formats = (const char *)config.Item( ZM_FFMPEG_FORMATS );\ + log_level_syslog = (int)config.Item( ZM_LOG_LEVEL_SYSLOG );\ + log_level_file = (int)config.Item( ZM_LOG_LEVEL_FILE );\ + log_level_weblog = (int)config.Item( ZM_LOG_LEVEL_WEBLOG );\ + log_level_database = (int)config.Item( ZM_LOG_LEVEL_DATABASE );\ + log_database_limit = (const char *)config.Item( ZM_LOG_DATABASE_LIMIT );\ + log_debug = (bool)config.Item( ZM_LOG_DEBUG );\ + log_debug_target = (const char *)config.Item( ZM_LOG_DEBUG_TARGET );\ + log_debug_level = (int)config.Item( ZM_LOG_DEBUG_LEVEL );\ + log_debug_file = (const char *)config.Item( ZM_LOG_DEBUG_FILE );\ + log_check_period = (int)config.Item( ZM_LOG_CHECK_PERIOD );\ + log_alert_war_count = (int)config.Item( ZM_LOG_ALERT_WAR_COUNT );\ + log_alert_err_count = (int)config.Item( ZM_LOG_ALERT_ERR_COUNT );\ + log_alert_fat_count = (int)config.Item( ZM_LOG_ALERT_FAT_COUNT );\ + log_alarm_war_count = (int)config.Item( ZM_LOG_ALARM_WAR_COUNT );\ + log_alarm_err_count = (int)config.Item( ZM_LOG_ALARM_ERR_COUNT );\ + log_alarm_fat_count = (int)config.Item( ZM_LOG_ALARM_FAT_COUNT );\ + record_event_stats = (bool)config.Item( ZM_RECORD_EVENT_STATS );\ + record_diag_images = (bool)config.Item( ZM_RECORD_DIAG_IMAGES );\ + dump_cores = (bool)config.Item( ZM_DUMP_CORES );\ + path_map = (const char *)config.Item( ZM_PATH_MAP );\ + path_socks = (const char *)config.Item( ZM_PATH_SOCKS );\ + path_logs = (const char *)config.Item( ZM_PATH_LOGS );\ + path_swap = (const char *)config.Item( ZM_PATH_SWAP );\ + web_title_prefix = (const char *)config.Item( ZM_WEB_TITLE_PREFIX );\ + web_resize_console = (bool)config.Item( ZM_WEB_RESIZE_CONSOLE );\ + web_popup_on_alarm = (bool)config.Item( ZM_WEB_POPUP_ON_ALARM );\ + opt_x10 = (bool)config.Item( ZM_OPT_X10 );\ + x10_device = (const char *)config.Item( ZM_X10_DEVICE );\ + x10_house_code = (const char *)config.Item( ZM_X10_HOUSE_CODE );\ + x10_db_reload_interval = (int)config.Item( ZM_X10_DB_RELOAD_INTERVAL );\ + web_sound_on_alarm = (bool)config.Item( ZM_WEB_SOUND_ON_ALARM );\ + web_alarm_sound = (const char *)config.Item( ZM_WEB_ALARM_SOUND );\ + web_compact_montage = (bool)config.Item( ZM_WEB_COMPACT_MONTAGE );\ + opt_fast_delete = (bool)config.Item( ZM_OPT_FAST_DELETE );\ + strict_video_config = (bool)config.Item( ZM_STRICT_VIDEO_CONFIG );\ + v4l2_capture_fields = (int)config.Item( ZM_V4L2_CAPTURE_FIELDS );\ + signal_check_points = (int)config.Item( ZM_SIGNAL_CHECK_POINTS );\ + v4l_multi_buffer = (bool)config.Item( ZM_V4L_MULTI_BUFFER );\ + captures_per_frame = (int)config.Item( ZM_CAPTURES_PER_FRAME );\ + filter_reload_delay = (int)config.Item( ZM_FILTER_RELOAD_DELAY );\ + filter_execute_interval = (int)config.Item( ZM_FILTER_EXECUTE_INTERVAL );\ + opt_upload = (bool)config.Item( ZM_OPT_UPLOAD );\ + upload_arch_format = (const char *)config.Item( ZM_UPLOAD_ARCH_FORMAT );\ + upload_arch_compress = (bool)config.Item( ZM_UPLOAD_ARCH_COMPRESS );\ + upload_arch_analyse = (bool)config.Item( ZM_UPLOAD_ARCH_ANALYSE );\ + upload_ftp_host = (const char *)config.Item( ZM_UPLOAD_FTP_HOST );\ + upload_ftp_user = (const char *)config.Item( ZM_UPLOAD_FTP_USER );\ + upload_ftp_pass = (const char *)config.Item( ZM_UPLOAD_FTP_PASS );\ + upload_ftp_loc_dir = (const char *)config.Item( ZM_UPLOAD_FTP_LOC_DIR );\ + upload_ftp_rem_dir = (const char *)config.Item( ZM_UPLOAD_FTP_REM_DIR );\ + upload_ftp_timeout = (int)config.Item( ZM_UPLOAD_FTP_TIMEOUT );\ + upload_ftp_passive = (bool)config.Item( ZM_UPLOAD_FTP_PASSIVE );\ + upload_ftp_debug = (bool)config.Item( ZM_UPLOAD_FTP_DEBUG );\ + opt_email = (bool)config.Item( ZM_OPT_EMAIL );\ + email_address = (const char *)config.Item( ZM_EMAIL_ADDRESS );\ + email_text = (const char *)config.Item( ZM_EMAIL_TEXT );\ + email_subject = (const char *)config.Item( ZM_EMAIL_SUBJECT );\ + email_body = (const char *)config.Item( ZM_EMAIL_BODY );\ + opt_message = (bool)config.Item( ZM_OPT_MESSAGE );\ + message_address = (const char *)config.Item( ZM_MESSAGE_ADDRESS );\ + message_text = (const char *)config.Item( ZM_MESSAGE_TEXT );\ + message_subject = (const char *)config.Item( ZM_MESSAGE_SUBJECT );\ + message_body = (const char *)config.Item( ZM_MESSAGE_BODY );\ + new_mail_modules = (bool)config.Item( ZM_NEW_MAIL_MODULES );\ + email_host = (const char *)config.Item( ZM_EMAIL_HOST );\ + from_email = (const char *)config.Item( ZM_FROM_EMAIL );\ + url = (const char *)config.Item( ZM_URL );\ + max_restart_delay = (int)config.Item( ZM_MAX_RESTART_DELAY );\ + watch_check_interval = (int)config.Item( ZM_WATCH_CHECK_INTERVAL );\ + watch_max_delay = (double) config.Item( ZM_WATCH_MAX_DELAY );\ + run_audit = (bool)config.Item( ZM_RUN_AUDIT );\ + audit_check_interval = (int)config.Item( ZM_AUDIT_CHECK_INTERVAL );\ + forced_alarm_score = (int)config.Item( ZM_FORCED_ALARM_SCORE );\ + bulk_frame_interval = (int)config.Item( ZM_BULK_FRAME_INTERVAL );\ + event_close_mode = (const char *)config.Item( ZM_EVENT_CLOSE_MODE );\ + force_close_events = (bool)config.Item( ZM_FORCE_CLOSE_EVENTS );\ + create_analysis_images = (bool)config.Item( ZM_CREATE_ANALYSIS_IMAGES );\ + weighted_alarm_centres = (bool)config.Item( ZM_WEIGHTED_ALARM_CENTRES );\ + event_image_digits = (int)config.Item( ZM_EVENT_IMAGE_DIGITS );\ + default_aspect_ratio = (const char *)config.Item( ZM_DEFAULT_ASPECT_RATIO );\ + user_self_edit = (bool)config.Item( ZM_USER_SELF_EDIT );\ + opt_frame_server = (bool)config.Item( ZM_OPT_FRAME_SERVER );\ + frame_socket_size = (int)config.Item( ZM_FRAME_SOCKET_SIZE );\ + opt_control = (bool)config.Item( ZM_OPT_CONTROL );\ + opt_triggers = (bool)config.Item( ZM_OPT_TRIGGERS );\ + check_for_updates = (bool)config.Item( ZM_CHECK_FOR_UPDATES );\ + update_check_proxy = (const char *)config.Item( ZM_UPDATE_CHECK_PROXY );\ + shm_key = (int)config.Item( ZM_SHM_KEY );\ + web_refresh_method = (const char *)config.Item( ZM_WEB_REFRESH_METHOD );\ + web_event_sort_field = (const char *)config.Item( ZM_WEB_EVENT_SORT_FIELD );\ + web_event_sort_order = (const char *)config.Item( ZM_WEB_EVENT_SORT_ORDER );\ + web_events_per_page = (int)config.Item( ZM_WEB_EVENTS_PER_PAGE );\ + web_list_thumbs = (bool)config.Item( ZM_WEB_LIST_THUMBS );\ + web_list_thumb_width = (int)config.Item( ZM_WEB_LIST_THUMB_WIDTH );\ + web_list_thumb_height = (int)config.Item( ZM_WEB_LIST_THUMB_HEIGHT );\ + web_use_object_tags = (bool)config.Item( ZM_WEB_USE_OBJECT_TAGS );\ + web_h_refresh_main = (int)config.Item( ZM_WEB_H_REFRESH_MAIN );\ + web_h_refresh_cycle = (int)config.Item( ZM_WEB_H_REFRESH_CYCLE );\ + web_h_refresh_image = (int)config.Item( ZM_WEB_H_REFRESH_IMAGE );\ + web_h_refresh_status = (int)config.Item( ZM_WEB_H_REFRESH_STATUS );\ + web_h_refresh_events = (int)config.Item( ZM_WEB_H_REFRESH_EVENTS );\ + web_h_can_stream = (const char *)config.Item( ZM_WEB_H_CAN_STREAM );\ + web_h_stream_method = (const char *)config.Item( ZM_WEB_H_STREAM_METHOD );\ + web_h_default_scale = (int)config.Item( ZM_WEB_H_DEFAULT_SCALE );\ + web_h_default_rate = (int)config.Item( ZM_WEB_H_DEFAULT_RATE );\ + web_h_video_bitrate = (int)config.Item( ZM_WEB_H_VIDEO_BITRATE );\ + web_h_video_maxfps = (int)config.Item( ZM_WEB_H_VIDEO_MAXFPS );\ + web_h_scale_thumbs = (bool)config.Item( ZM_WEB_H_SCALE_THUMBS );\ + web_h_events_view = (const char *)config.Item( ZM_WEB_H_EVENTS_VIEW );\ + web_h_show_progress = (bool)config.Item( ZM_WEB_H_SHOW_PROGRESS );\ + web_h_ajax_timeout = (int)config.Item( ZM_WEB_H_AJAX_TIMEOUT );\ + web_m_refresh_main = (int)config.Item( ZM_WEB_M_REFRESH_MAIN );\ + web_m_refresh_cycle = (int)config.Item( ZM_WEB_M_REFRESH_CYCLE );\ + web_m_refresh_image = (int)config.Item( ZM_WEB_M_REFRESH_IMAGE );\ + web_m_refresh_status = (int)config.Item( ZM_WEB_M_REFRESH_STATUS );\ + web_m_refresh_events = (int)config.Item( ZM_WEB_M_REFRESH_EVENTS );\ + web_m_can_stream = (const char *)config.Item( ZM_WEB_M_CAN_STREAM );\ + web_m_stream_method = (const char *)config.Item( ZM_WEB_M_STREAM_METHOD );\ + web_m_default_scale = (int)config.Item( ZM_WEB_M_DEFAULT_SCALE );\ + web_m_default_rate = (int)config.Item( ZM_WEB_M_DEFAULT_RATE );\ + web_m_video_bitrate = (int)config.Item( ZM_WEB_M_VIDEO_BITRATE );\ + web_m_video_maxfps = (int)config.Item( ZM_WEB_M_VIDEO_MAXFPS );\ + web_m_scale_thumbs = (bool)config.Item( ZM_WEB_M_SCALE_THUMBS );\ + web_m_events_view = (const char *)config.Item( ZM_WEB_M_EVENTS_VIEW );\ + web_m_show_progress = (bool)config.Item( ZM_WEB_M_SHOW_PROGRESS );\ + web_m_ajax_timeout = (int)config.Item( ZM_WEB_M_AJAX_TIMEOUT );\ + web_l_refresh_main = (int)config.Item( ZM_WEB_L_REFRESH_MAIN );\ + web_l_refresh_cycle = (int)config.Item( ZM_WEB_L_REFRESH_CYCLE );\ + web_l_refresh_image = (int)config.Item( ZM_WEB_L_REFRESH_IMAGE );\ + web_l_refresh_status = (int)config.Item( ZM_WEB_L_REFRESH_STATUS );\ + web_l_refresh_events = (int)config.Item( ZM_WEB_L_REFRESH_EVENTS );\ + web_l_can_stream = (const char *)config.Item( ZM_WEB_L_CAN_STREAM );\ + web_l_stream_method = (const char *)config.Item( ZM_WEB_L_STREAM_METHOD );\ + web_l_default_scale = (int)config.Item( ZM_WEB_L_DEFAULT_SCALE );\ + web_l_default_rate = (int)config.Item( ZM_WEB_L_DEFAULT_RATE );\ + web_l_video_bitrate = (int)config.Item( ZM_WEB_L_VIDEO_BITRATE );\ + web_l_video_maxfps = (int)config.Item( ZM_WEB_L_VIDEO_MAXFPS );\ + web_l_scale_thumbs = (bool)config.Item( ZM_WEB_L_SCALE_THUMBS );\ + web_l_events_view = (const char *)config.Item( ZM_WEB_L_EVENTS_VIEW );\ + web_l_show_progress = (bool)config.Item( ZM_WEB_L_SHOW_PROGRESS );\ + web_l_ajax_timeout = (int)config.Item( ZM_WEB_L_AJAX_TIMEOUT );\ + web_p_can_stream = (const char *)config.Item( ZM_WEB_P_CAN_STREAM );\ + web_p_stream_method = (const char *)config.Item( ZM_WEB_P_STREAM_METHOD );\ + web_p_default_scale = (int)config.Item( ZM_WEB_P_DEFAULT_SCALE );\ + web_p_default_rate = (int)config.Item( ZM_WEB_P_DEFAULT_RATE );\ + web_p_video_bitrate = (int)config.Item( ZM_WEB_P_VIDEO_BITRATE );\ + web_p_video_maxfps = (int)config.Item( ZM_WEB_P_VIDEO_MAXFPS );\ + web_p_scale_thumbs = (bool)config.Item( ZM_WEB_P_SCALE_THUMBS );\ + web_p_ajax_timeout = (int)config.Item( ZM_WEB_P_AJAX_TIMEOUT );\ + dyn_last_version = (const char *)config.Item( ZM_DYN_LAST_VERSION );\ + dyn_curr_version = (const char *)config.Item( ZM_DYN_CURR_VERSION );\ + dyn_db_version = (const char *)config.Item( ZM_DYN_DB_VERSION );\ + dyn_last_check = (int)config.Item( ZM_DYN_LAST_CHECK );\ + dyn_next_reminder = (const char *)config.Item( ZM_DYN_NEXT_REMINDER );\ + dyn_donate_reminder_time = (int)config.Item( ZM_DYN_DONATE_REMINDER_TIME );\ + dyn_show_donate_reminder = (bool)config.Item( ZM_DYN_SHOW_DONATE_REMINDER );\ + eyezm_debug = (bool)config.Item( ZM_EYEZM_DEBUG );\ + eyezm_log_to_file = (bool)config.Item( ZM_EYEZM_LOG_TO_FILE );\ + eyezm_log_file = (const char *)config.Item( ZM_EYEZM_LOG_FILE );\ + eyezm_event_vcodec = (const char *)config.Item( ZM_EYEZM_EVENT_VCODEC );\ + eyezm_feed_vcodec = (const char *)config.Item( ZM_EYEZM_FEED_VCODEC );\ + eyezm_h264_default_br = (const char *)config.Item( ZM_EYEZM_H264_DEFAULT_BR );\ + eyezm_h264_default_evbr = (const char *)config.Item( ZM_EYEZM_H264_DEFAULT_EVBR );\ + eyezm_h264_timeout = (const char *)config.Item( ZM_EYEZM_H264_TIMEOUT );\ + eyezm_seg_duration = (const char *)config.Item( ZM_EYEZM_SEG_DURATION );\ + + From de015761c15c6d0d7aac865e1e76187e2b66be02 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sun, 31 Jul 2011 22:15:38 +0300 Subject: [PATCH 31/56] Fix different palettes warning showing up when using automatic palette selection. --- src/zm_local_camera.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 77107bb7a..f4a8b8f5d 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -296,7 +296,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, if ( capture ) { - if ( device_prime ) + if ( device_prime ) { Debug( 2, "V4L support enabled, using V4L%d api", v4l_version ); } @@ -314,21 +314,6 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, // We are the second, or subsequent, input using this channel channel_prime = false; } - - if ( last_camera ) - { - if ( (p_method == "v4l2" && v4l_version != 2) || (p_method == "v4l1" && v4l_version != 1) ) - Fatal( "Different Video For Linux version used for monitors sharing same device" ); - - if ( standard != last_camera->standard ) - Warning( "Different video standards defined for monitors sharing same device, results may be unpredictable or completely wrong" ); - - if ( palette != last_camera->palette ) - Warning( "Different video palettes defined for monitors sharing same device, results may be unpredictable or completely wrong" ); - - if ( width != last_camera->width || height != last_camera->height ) - Warning( "Different capture sizes defined for monitors sharing same device, results may be unpredictable or completely wrong" ); - } } @@ -359,6 +344,22 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, } #endif + if( capture ) { + if ( last_camera ) { + if ( (p_method == "v4l2" && v4l_version != 2) || (p_method == "v4l1" && v4l_version != 1) ) + Fatal( "Different Video For Linux version used for monitors sharing same device" ); + + if ( standard != last_camera->standard ) + Warning( "Different video standards defined for monitors sharing same device, results may be unpredictable or completely wrong" ); + + if ( palette != last_camera->palette ) + Warning( "Different video palettes defined for monitors sharing same device, results may be unpredictable or completely wrong" ); + + if ( width != last_camera->width || height != last_camera->height ) + Warning( "Different capture sizes defined for monitors sharing same device, results may be unpredictable or completely wrong" ); + } + } + #if HAVE_LIBSWSCALE if( capture ) { /* Get ffmpeg pixel format based on capture palette and endianness */ From d5fbd351b3085072aa129ce68a08170a1f0224ce Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 2 Aug 2011 16:35:10 +0300 Subject: [PATCH 32/56] Small corrections --- web/skins/classic/views/monitorprobe.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/skins/classic/views/monitorprobe.php b/web/skins/classic/views/monitorprobe.php index 0f26d6331..ed278ea8e 100644 --- a/web/skins/classic/views/monitorprobe.php +++ b/web/skins/classic/views/monitorprobe.php @@ -126,7 +126,7 @@ function probeAxis( $ip ) 'Host' => $ip, 'Port' => 80, 'Path' => '/axis-cgi/mjpg/video.cgi?resolution=320x240', - 'Palette' => 3, + 'Colours' => 3, 'Width' => 320, 'Height' => 240, ), @@ -160,7 +160,7 @@ function probePana( $ip ) 'Host' => $ip, 'Port' => 80, 'Path' => '/nphMotionJpeg?Resolution=320x240&Quality=Standard', - 'Palette' => 3, + 'Colours' => 3, 'Width' => 320, 'Height' => 240, ), @@ -180,7 +180,7 @@ function probeActi( $ip ) 'Host' => 'Admin:123456@'.$ip, 'Port' => 7070, 'Path' => '', - 'Palette' => 3, + 'Colours' => 3, 'Width' => 320, 'Height' => 240, ), @@ -215,7 +215,7 @@ function probeVivotek( $ip ) 'Host' => $ip, 'Port' => 554, 'Path' => '', - 'Palette' => 3, + 'Colours' => 3, 'Width' => 352, 'Height' => 240, ), From f266fd1f34136b23e8324088ffa56fbd34139c6a Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 9 Aug 2011 21:35:18 +0300 Subject: [PATCH 33/56] Rebased to SVN revision 3497. --- configure | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 3791f9c70..7be00169a 100755 --- a/configure +++ b/configure @@ -2,7 +2,7 @@ # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.65 for zm 1.25.0. # -# Report bugs to . +# Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -231,8 +231,8 @@ fi $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and -$0: http://www.zoneminder.com/forums/ (Please check FAQ -$0: first) about your system, including any error possibly +$0: http://www.zoneminder.com/forums/ - Please check FAQ +$0: first about your system, including any error possibly $0: output before this message. Then install a modern $0: shell, or manually run the script under such a shell if $0: you do have one." @@ -555,7 +555,7 @@ PACKAGE_NAME='zm' PACKAGE_TARNAME='ZoneMinder' PACKAGE_VERSION='1.25.0' PACKAGE_STRING='zm 1.25.0' -PACKAGE_BUGREPORT='http://www.zoneminder.com/forums/ (Please check FAQ first)' +PACKAGE_BUGREPORT='http://www.zoneminder.com/forums/ - Please check FAQ first' PACKAGE_URL='http://www.zoneminder.com/downloads.html' ac_unique_file="src/zm.h" @@ -1428,7 +1428,7 @@ Some influential environment variables: Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to . +Report bugs to . zm home page: . _ACEOF ac_status=$? @@ -1875,7 +1875,7 @@ $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" > $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------------------------------------------- ## -## Report this to http://www.zoneminder.com/forums/ (Please check FAQ first) ## +## Report this to http://www.zoneminder.com/forums/ - Please check FAQ first ## ## ------------------------------------------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -9979,7 +9979,7 @@ $config_headers Configuration commands: $config_commands -Report bugs to . +Report bugs to . zm home page: ." _ACEOF From b3a1dcf03216b2f71d434d3ade91dac7fa6d78f0 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sun, 21 Aug 2011 01:43:30 +0300 Subject: [PATCH 34/56] Fixed SSSE3 detection and changed few text strings. --- src/zm_image.cpp | 7 +++---- src/zm_utils.cpp | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index dc6596068..1d8c0fd69 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -141,14 +141,14 @@ void Image::Initialise() if(config.fast_image_blends) { if(config.cpu_extensions && sseversion >= 20) { fptr_blend = &sse2_fastblend; /* SSE2 fast blend */ - Debug(2,"Blend: using SSE2 fast blending"); + Debug(2,"Blend: Using SSE2 fast blend function"); } else { fptr_blend = &std_fastblend; /* standard fast blend */ - Debug(2,"Blend: using standard fast blending"); + Debug(2,"Blend: Using fast blend function"); } } else { fptr_blend = &std_blend; - Debug(2,"Blend: using standard blending"); + Debug(2,"Blend: Using standard blend function"); } __attribute__((aligned(16))) uint8_t blend1[16] = {142,255,159,91,88,227,0,52,37,80,152,97,104,252,90,82}; @@ -3547,7 +3547,6 @@ __attribute__ ((noinline)) void std_convert_abgr_gray8(const uint8_t* col1, uint /* Converts a YUYV image into grayscale by extracting the Y channel */ __attribute__ ((noinline)) void std_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { const uint16_t* yuvbuf = (const uint16_t*)col1; - const uint8_t* const max_ptr = result + count; while(result < max_ptr) { diff --git a/src/zm_utils.cpp b/src/zm_utils.cpp index 11a28538c..d781c320d 100644 --- a/src/zm_utils.cpp +++ b/src/zm_utils.cpp @@ -166,7 +166,7 @@ void ssedetect() { : "%eax", "%ebx" ); - if (r_ecx & 0x00000100) { + if (r_ecx & 0x00000200) { sseversion = 35; /* SSSE3 */ Debug(1,"Detected a x86\\x86-64 processor with SSSE3"); } else if (r_ecx & 0x00000001) { From 28e06e935b2d056f8d483d6ac1eedbf2031f8f19 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 7 Sep 2011 19:07:23 +0300 Subject: [PATCH 35/56] 1) Fixed blob motion detection issues. 2) Some more progress towards getting analysis images working. 3) Fixed possible log corruption because of ssedetect(). --- src/zm_image.cpp | 274 ++++++++++++++++++++++++++++------------------- src/zm_zone.cpp | 141 +++++++++++++----------- src/zma.cpp | 4 +- src/zmc.cpp | 4 +- src/zmf.cpp | 4 +- src/zms.cpp | 4 +- 6 files changed, 251 insertions(+), 180 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 1d8c0fd69..60b60a57f 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -475,7 +475,7 @@ Image *Image::HighlightEdges( Rgb colour, const Box *limits ) for ( int y = lo_y; y <= hi_y; y++ ) { uint8_t *p = &buffer[(y*width)+lo_x]; - uint8_t *phigh = high_buff + ( lo_x * y ); + uint8_t *phigh = high_buff + (((y * width) + lo_x) * 3); for ( int x = lo_x; x <= hi_x; x++, p++, phigh += 3 ) { bool edge = false; @@ -1117,134 +1117,184 @@ bool Image::Crop( const Box &limits ) return( Crop( limits.LoX(), limits.LoY(), limits.HiX(), limits.HiY() ) ); } - -/* At the moment only supports 8bit overlay for 24bit and 32bit images. */ +/* Not fully complete */ void Image::Overlay( const Image &image ) { if ( !(width == image.width && height == image.height) ) - { - Panic( "Attempt to overlay different sized images, expected %dx%d, got %dx%d", width, height, image.width, image.height ); - } - - unsigned char *pdest = buffer; - unsigned char *psrc = image.buffer; - - if ( colours == ZM_COLOUR_GRAY8 ) { - if ( image.colours == ZM_COLOUR_GRAY8 ) + Panic( "Attempt to overlay different sized images, expected %dx%d, got %dx%d", width, height, image.width, image.height ); + } + + if( colours == image.colours && subpixelorder != image.subpixelorder ) { + Warning("Attempt to overlay images of same format but with different subpixel order."); + } + + /* Grayscale ontop of grayscale */ + if ( colours == ZM_COLOUR_GRAY8 && image.colours == ZM_COLOUR_GRAY8 ) { + const uint8_t* const max_ptr = buffer+size; + const uint8_t* psrc = image.buffer; + uint8_t* pdest = buffer; + + while( pdest < max_ptr ) { - while( pdest < (buffer+size) ) + if ( *psrc ) { + *pdest = *psrc; + } + pdest++; + psrc++; + } + + /* RGB24 ontop of grayscale - convert to same format first */ + } else if ( colours == ZM_COLOUR_GRAY8 && image.colours == ZM_COLOUR_RGB24 ) { + Colourise(image.colours, image.subpixelorder); + + const uint8_t* const max_ptr = buffer+size; + const uint8_t* psrc = image.buffer; + uint8_t* pdest = buffer; + + while( pdest < max_ptr ) + { + if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) + { + RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); + GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); + BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); + } + pdest += 3; + psrc += 3; + } + + /* RGB32 ontop of grayscale - convert to same format first */ + } else if( colours == ZM_COLOUR_GRAY8 && image.colours == ZM_COLOUR_RGB32 ) { + Colourise(image.colours, image.subpixelorder); + + const Rgb* const max_ptr = (Rgb*)(buffer+size); + const Rgb* prsrc = (Rgb*)image.buffer; + Rgb* prdest = (Rgb*)buffer; + + if(subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ + while (prdest < max_ptr) { + if ( RED_PTR_RGBA(prsrc) || GREEN_PTR_RGBA(prsrc) || BLUE_PTR_RGBA(prsrc) ) + { + *prdest = *prsrc; + } + prdest++; + prsrc++; + } + } else { + /* ABGR\ARGB subpixel order - Alpha byte is first */ + while (prdest < max_ptr) { + if ( RED_PTR_ABGR(prsrc) || GREEN_PTR_ABGR(prsrc) || BLUE_PTR_ABGR(prsrc) ) + { + *prdest = *prsrc; + } + prdest++; + prsrc++; + } + } + + /* Grayscale ontop of RGB24 */ + } else if ( colours == ZM_COLOUR_RGB24 && image.colours == ZM_COLOUR_GRAY8 ) { + const uint8_t* const max_ptr = buffer+size; + const uint8_t* psrc = image.buffer; + uint8_t* pdest = buffer; + + while( pdest < max_ptr ) + { + if ( *psrc ) + { + RED_PTR_RGBA(pdest) = GREEN_PTR_RGBA(pdest) = BLUE_PTR_RGBA(pdest) = *psrc; + } + pdest += 3; + psrc++; + } + + /* RGB24 ontop of RGB24 */ + } else if ( colours == ZM_COLOUR_RGB24 && image.colours == ZM_COLOUR_RGB24 ) { + const uint8_t* const max_ptr = buffer+size; + const uint8_t* psrc = image.buffer; + uint8_t* pdest = buffer; + + while( pdest < max_ptr ) + { + if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) + { + RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); + GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); + BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); + } + pdest += 3; + psrc += 3; + } + + /* RGB32 ontop of RGB24 - TO BE DONE */ + } else if ( colours == ZM_COLOUR_RGB24 && image.colours == ZM_COLOUR_RGB32 ) { + Error("Overlay of RGB32 ontop of RGB24 is not supported."); + + /* Grayscale ontop of RGB32 */ + } else if ( colours == ZM_COLOUR_RGB32 && image.colours == ZM_COLOUR_GRAY8 ) { + const Rgb* const max_ptr = (Rgb*)(buffer+size); + Rgb* prdest = (Rgb*)buffer; + const uint8_t* psrc = image.buffer; + + if(subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + /* RGBA\BGRA subpixel order - Alpha byte is last */ + while (prdest < max_ptr) { if ( *psrc ) { - *pdest = *psrc; + RED_PTR_RGBA(prdest) = GREEN_PTR_RGBA(prdest) = BLUE_PTR_RGBA(prdest) = *psrc; } - pdest++; + prdest++; + psrc++; + } + } else { + /* ABGR\ARGB subpixel order - Alpha byte is first */ + while (prdest < max_ptr) { + if ( *psrc ) + { + RED_PTR_ABGR(prdest) = GREEN_PTR_ABGR(prdest) = BLUE_PTR_ABGR(prdest) = *psrc; + } + prdest++; psrc++; } } - else - { - Colourise(image.colours, image.subpixelorder); - - if(image.colours == ZM_COLOUR_RGB32) { - Rgb* prdest = (Rgb*)buffer; - const Rgb* prsrc = (Rgb*)image.buffer; - const Rgb* const max_ptr = (Rgb*)(buffer+size); - if(image.subpixelorder == ZM_SUBPIX_ORDER_RGBA || image.subpixelorder == ZM_SUBPIX_ORDER_BGRA) { - /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ - while (prdest < max_ptr) { - if ( RED_PTR_RGBA(prsrc) || GREEN_PTR_RGBA(prsrc) || BLUE_PTR_RGBA(prsrc) ) - { - *prdest = *prsrc; - } - prdest++; - prsrc++; - } - } else { - /* ABGR\ARGB subpixel order - Alpha byte is first */ - while (prdest < max_ptr) { - if ( RED_PTR_ABGR(prsrc) || GREEN_PTR_ABGR(prsrc) || BLUE_PTR_ABGR(prsrc) ) - { - *prdest = *prsrc; - } - prdest++; - prsrc++; - } - } - } else { - /* Assume RGB24\BGR24 */ - while( pdest < (buffer+size) ) + + /* RGB24 ontop of RGB32 - TO BE DONE */ + } else if ( colours == ZM_COLOUR_RGB32 && image.colours == ZM_COLOUR_RGB24 ) { + Error("Overlay of RGB24 ontop of RGB32 is not supported."); + + /* RGB32 ontop of RGB32 */ + } else if ( colours == ZM_COLOUR_RGB32 && image.colours == ZM_COLOUR_RGB32 ) { + const Rgb* const max_ptr = (Rgb*)(buffer+size); + Rgb* prdest = (Rgb*)buffer; + const Rgb* prsrc = (Rgb*)image.buffer; + + if(image.subpixelorder == ZM_SUBPIX_ORDER_RGBA || image.subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ + while (prdest < max_ptr) { + if ( RED_PTR_RGBA(prsrc) || GREEN_PTR_RGBA(prsrc) || BLUE_PTR_RGBA(prsrc) ) { - if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) - { - RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); - GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); - BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); - } - psrc += 3; - pdest += 3; + *prdest = *prsrc; } + prdest++; + prsrc++; + } + } else { + /* ABGR\ARGB subpixel order - Alpha byte is first */ + while (prdest < max_ptr) { + if ( RED_PTR_ABGR(prsrc) || GREEN_PTR_ABGR(prsrc) || BLUE_PTR_ABGR(prsrc) ) + { + *prdest = *prsrc; + } + prdest++; + prsrc++; } } + } - else - { - if ( image.colours == ZM_COLOUR_GRAY8 ) - { - if(colours == ZM_COLOUR_RGB32) { - Rgb* prdest = (Rgb*)buffer; - const Rgb* const max_ptr = (Rgb*)(buffer+size); - if(subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA) { - /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ - while (prdest < max_ptr) { - if ( *psrc ) - { - RED_PTR_RGBA(prdest) = GREEN_PTR_RGBA(prdest) = BLUE_PTR_RGBA(prdest) = *psrc++; - } - prdest++; - } - } else { - /* ABGR\ARGB subpixel order - Alpha byte is first */ - while (prdest < max_ptr) { - if ( *psrc ) - { - RED_PTR_ABGR(prdest) = GREEN_PTR_ABGR(prdest) = BLUE_PTR_ABGR(prdest) = *psrc++; - } - prdest++; - } - } - } else { - /* Assume RGB24\BGR24 */ - while( pdest < (buffer+size) ) - { - if ( *psrc ) - { - RED_PTR_RGBA(pdest) = GREEN_PTR_RGBA(pdest) = BLUE_PTR_RGBA(pdest) = *psrc++; - } - pdest += 3; - } - } - } - else - { - - /* At the moment this function only supports 8bit overlay for 24bit and 32bit images. - ** The code below is old and was not updated yet to support the new formats. this code assumes RGB24 - */ - while( pdest < (buffer+size) ) - { - if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) - { - RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); - GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); - BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); - } - psrc += colours; - pdest += colours; - } - } - } + } /* RGB32 compatible: complete */ diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index bf294aa4a..0bb4c1b94 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -68,13 +68,13 @@ void Zone::Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_ pg_image->Outline( 0xff, polygon ); ranges = new Range[monitor->Height()]; - for ( int y = polygon.LoY(); y <= polygon.HiY(); y++) + for ( int y = 0; y < monitor->Height(); y++) { ranges[y].lo_x = -1; ranges[y].hi_x = -1; ranges[y].off_x = 0; - const uint8_t *ppoly = pg_image->Buffer( polygon.LoX(), y ); - for ( int x = polygon.LoX(); x <= polygon.HiX(); x++, ppoly++ ) + const uint8_t *ppoly = pg_image->Buffer( 0, y ); + for ( int x = 0; x < monitor->Width(); x++, ppoly++ ) { if ( *ppoly ) { @@ -154,8 +154,8 @@ bool Zone::CheckAlarms( const Image *delta_image ) unsigned int lo_y = polygon.LoY(); unsigned int lo_x = polygon.LoX(); - unsigned int hi_x = polygon.HiX()+1; - unsigned int hi_y = polygon.HiY()+1; + unsigned int hi_x = polygon.HiX(); + unsigned int hi_y = polygon.HiY(); Debug( 4, "Checking alarms for zone %d/%s in lines %d -> %d", id, label, lo_y, hi_y ); @@ -168,10 +168,6 @@ bool Zone::CheckAlarms( const Image *delta_image ) } */ std_alarmedpixels(diff_image, pg_image, &alarm_pixels, &pixel_diff_count); - if ( pixel_diff_count && alarm_pixels ) - pixel_diff = pixel_diff_count/alarm_pixels; - Debug( 5, "Got %d alarmed pixels, need %d -> %d, avg pixel diff %d", alarm_pixels, min_alarm_pixels, max_alarm_pixels, pixel_diff ); - if ( config.record_diag_images ) { static char diag_path[PATH_MAX] = ""; @@ -181,6 +177,10 @@ bool Zone::CheckAlarms( const Image *delta_image ) } diff_image->WriteJpeg( diag_path ); } + + if ( pixel_diff_count && alarm_pixels ) + pixel_diff = pixel_diff_count/alarm_pixels; + Debug( 5, "Got %d alarmed pixels, need %d -> %d, avg pixel diff %d", alarm_pixels, min_alarm_pixels, max_alarm_pixels, pixel_diff ); if( alarm_pixels ) { if( min_alarm_pixels && (alarm_pixels < min_alarm_pixels) ) { @@ -196,7 +196,6 @@ bool Zone::CheckAlarms( const Image *delta_image ) return (false); } - score = (100*alarm_pixels)/polygon.Area(); if(score < 1) score = 1; /* Fix for score of 0 when frame meets thresholds but alarmed area is not big enough */ @@ -265,6 +264,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) { alarm_filter_pixels = alarm_pixels; } + if ( config.record_diag_images ) { static char diag_path[PATH_MAX] = ""; @@ -274,23 +274,26 @@ bool Zone::CheckAlarms( const Image *delta_image ) } diff_image->WriteJpeg( diag_path ); } + Debug( 5, "Got %d filtered pixels, need %d -> %d", alarm_filter_pixels, min_filter_pixels, max_filter_pixels ); - - if ( !alarm_filter_pixels ) - { - return( false ); - } - if ( min_filter_pixels && (alarm_filter_pixels < min_filter_pixels) ) - { - return( false ); - } - if ( max_filter_pixels && (alarm_filter_pixels > max_filter_pixels) ) - { - overload_count = overload_frames; - return( false ); - } - + + if( alarm_filter_pixels ) { + if( min_filter_pixels && (alarm_filter_pixels < min_filter_pixels) ) { + /* Not enough pixels alarmed */ + return (false); + } else if( max_filter_pixels && (alarm_filter_pixels > max_filter_pixels) ) { + /* Too many pixels alarmed */ + overload_count = overload_frames; + return (false); + } + } else { + /* No filtered pixels */ + return (false); + } + score = (100*alarm_filter_pixels)/(polygon.Area()); + if(score < 1) + score = 1; /* Fix for score of 0 when frame meets thresholds but alarmed area is not big enough */ Debug( 5, "Current score is %d", score ); if ( check_method >= BLOBS ) @@ -300,7 +303,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) BlobStats blob_stats[256]; memset( blob_stats, 0, sizeof(BlobStats)*256 ); uint8_t *spdiff; - int last_x, last_y; + uint8_t last_x, last_y; BlobStats *bsx, *bsy; BlobStats *bsm, *bss; for ( int y = lo_y; y <= hi_y; y++ ) @@ -316,8 +319,20 @@ bool Zone::CheckAlarms( const Image *delta_image ) Debug( 9, "Got white pixel at %d,%d (%p)", x, y, pdiff ); //last_x = (x>lo_x)?*(pdiff-1):0; //last_y = (y>lo_y&&x>=last_lo_x&&x<=last_hi_x)?*(pdiff-diff_width):0; - last_x = x>0?*(pdiff-1):0; - last_y = y>0?*(pdiff-diff_width):0; + + last_x = 0; + if(x > 0) { + if((x-1) >= lo_x) { + last_x = *(pdiff-1); + } + } + + last_y = 0; + if(y > 0) { + if((y-1) >= lo_y && ranges[(y-1)].lo_x <= x && ranges[(y-1)].hi_x >= x) { + last_y = *(pdiff-diff_width); + } + } if ( last_x ) { @@ -332,6 +347,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) Debug( 9, "Matching neighbours, setting to %d", last_x ); // Add to the blob from the x side (either side really) *pdiff = last_x; + alarm_blob_pixels++; bsx->count++; if ( x > bsx->hi_x ) bsx->hi_x = x; if ( y > bsx->hi_y ) bsx->hi_y = y; @@ -347,13 +363,13 @@ bool Zone::CheckAlarms( const Image *delta_image ) Debug( 9, "Slave blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bss->tag, bss->count, bss->lo_x, bss->hi_x, bss->lo_y, bss->hi_y ); // Now change all those pixels to the other setting int changed = 0; - for ( int sy = bss->lo_y, psy = bss->lo_y-lo_y; sy <= bss->hi_y; sy++, psy++ ) + for ( int sy = bss->lo_y; sy <= bss->hi_y; sy++) { - int lo_sx = bss->lo_x>=ranges[psy].lo_x?bss->lo_x:ranges[psy].lo_x; - int hi_sx = bss->hi_x<=ranges[psy].hi_x?bss->hi_x:ranges[psy].hi_x; + int lo_sx = bss->lo_x>=ranges[sy].lo_x?bss->lo_x:ranges[sy].lo_x; + int hi_sx = bss->hi_x<=ranges[sy].hi_x?bss->hi_x:ranges[sy].hi_x; - Debug( 9, "Changing %d(%d), %d->%d", sy, psy, lo_sx, hi_sx ); - Debug( 9, "Range %d(%d), %d->%d", sy, psy, ranges[psy].lo_x, ranges[psy].hi_x ); + Debug( 9, "Changing %d, %d->%d", sy, lo_sx, hi_sx ); + Debug( 9, "Range %d, %d->%d", sy, ranges[sy].lo_x, ranges[sy].hi_x ); spdiff = diff_buff + ((diff_width * sy) + lo_sx); for ( int sx = lo_sx; sx <= hi_sx; sx++, spdiff++ ) { @@ -367,6 +383,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) } } *pdiff = bsm->tag; + alarm_blob_pixels++; if ( !changed ) { Info( "Master blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bsm->tag, bsm->count, bsm->lo_x, bsm->hi_x, bsm->lo_y, bsm->hi_y ); @@ -402,6 +419,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) Debug( 9, "Setting to left neighbour %d", last_x ); // Add to the blob from the x side *pdiff = last_x; + alarm_blob_pixels++; bsx->count++; if ( x > bsx->hi_x ) bsx->hi_x = x; if ( y > bsx->hi_y ) bsx->hi_y = y; @@ -411,12 +429,14 @@ bool Zone::CheckAlarms( const Image *delta_image ) { if ( last_y ) { + Debug( 9, "Top neighbour is %d", last_y ); Debug( 9, "Setting to top neighbour %d", last_y ); - + // Add to the blob from the y side BlobStats *bsy = &blob_stats[last_y]; *pdiff = last_y; + alarm_blob_pixels++; bsy->count++; if ( x > bsy->hi_x ) bsy->hi_x = x; if ( y > bsy->hi_y ) bsy->hi_y = y; @@ -464,6 +484,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) { Debug( 9, "Creating new blob %d", i ); *pdiff = i; + alarm_blob_pixels++; bs->tag = i; bs->count++; bs->lo_x = bs->hi_x = x; @@ -496,10 +517,10 @@ bool Zone::CheckAlarms( const Image *delta_image ) } if ( !alarm_blobs ) - { - return( false ); - } - alarm_blob_pixels = alarm_filter_pixels; + { + return( false ); + } + Debug( 5, "Got %d raw blob pixels, %d raw blobs, need %d -> %d, %d -> %d", alarm_blob_pixels, alarm_blobs, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs ); // Now eliminate blobs under the threshold @@ -553,21 +574,26 @@ bool Zone::CheckAlarms( const Image *delta_image ) } diff_image->WriteJpeg( diag_path ); } - Debug( 5, "Got %d blob pixels, %d blobs, need %d -> %d, %d -> %d", alarm_blob_pixels, alarm_blobs, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs ); - - if ( !alarm_blobs ) - { - return( false ); - } - if ( min_blobs && (alarm_blobs < min_blobs) ) - { - return( false ); - } - if ( max_blobs && (alarm_blobs > max_blobs) ) - { - overload_count = overload_frames; - return( false ); - } + Debug( 5, "Got %d blob pixels, %d blobs, need %d -> %d, %d -> %d", alarm_blob_pixels, alarm_blobs, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs ); + + if( alarm_blobs ) { + if( min_blobs && (alarm_blobs < min_blobs) ) { + /* Not enough pixels alarmed */ + return (false); + } else if(max_blobs && (alarm_blobs > max_blobs) ) { + /* Too many pixels alarmed */ + overload_count = overload_frames; + return (false); + } + } else { + /* No blobs */ + return (false); + } + + score = (100*alarm_blob_pixels)/(polygon.Area()); + if(score < 1) + score = 1; /* Fix for score of 0 when frame meets thresholds but alarmed area is not big enough */ + Debug( 5, "Current score is %d", score ); alarm_lo_x = polygon.HiX()+1; alarm_hi_x = polygon.LoX()-1; @@ -613,8 +639,6 @@ bool Zone::CheckAlarms( const Image *delta_image ) if ( alarm_hi_y < bs->hi_y ) alarm_hi_y = bs->hi_y; } } - score = ((100*alarm_blob_pixels)/int(sqrt((double)alarm_blobs)))/(polygon.Area()); - Debug( 5, "Current score is %d", score ); } else { @@ -656,10 +680,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) if ( (type < PRECLUSIVE) && check_method >= BLOBS && config.create_analysis_images ) { - int lo_x = polygon.LoX(); - int hi_x = polygon.HiX(); - int lo_y = polygon.LoY(); - int hi_y = polygon.HiY(); + // First mask out anything we don't want for ( int y = lo_y; y <= hi_y; y++ ) { @@ -682,7 +703,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) } } - ppoly = pg_image->Buffer( lo_gap, y ); + ppoly = pg_image->Buffer( lo_x2, y ); for ( int x = lo_x2; x <= hi_x2; x++, pdiff++, ppoly++ ) { if ( !*ppoly ) diff --git a/src/zma.cpp b/src/zma.cpp index 7c54d0c05..3de25bf12 100644 --- a/src/zma.cpp +++ b/src/zma.cpp @@ -91,10 +91,10 @@ int main( int argc, char *argv[] ) snprintf( log_id_string, sizeof(log_id_string), "zma_m%d", id ); zmLoadConfig(); - - ssedetect(); logInit( log_id_string ); + + ssedetect(); Monitor *monitor = Monitor::Load( id, true, Monitor::ANALYSIS ); diff --git a/src/zmc.cpp b/src/zmc.cpp index 734e4606b..692c0b59e 100644 --- a/src/zmc.cpp +++ b/src/zmc.cpp @@ -149,10 +149,10 @@ int main( int argc, char *argv[] ) } zmLoadConfig(); - - ssedetect(); logInit( log_id_string ); + + ssedetect(); Monitor **monitors = 0; int n_monitors = 0; diff --git a/src/zmf.cpp b/src/zmf.cpp index 998f7a0ec..bc7a54ee0 100644 --- a/src/zmf.cpp +++ b/src/zmf.cpp @@ -159,10 +159,10 @@ int main( int argc, char *argv[] ) snprintf( log_id_string, sizeof(log_id_string), "m%d", id ); zmLoadConfig(); - - ssedetect(); logInit( "zmf" ); + + ssedetect(); Monitor *monitor = Monitor::Load( id, false, Monitor::QUERY ); diff --git a/src/zms.cpp b/src/zms.cpp index db7902303..af294cb71 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -86,10 +86,10 @@ int main( int argc, const char *argv[] ) } zmLoadConfig(); - - ssedetect(); logInit( "zms" ); + + ssedetect(); zmSetDefaultTermHandler(); zmSetDefaultDieHandler(); From e217e995625cec19500d516fbe93fce35729b742 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 14 Sep 2011 21:09:52 +0300 Subject: [PATCH 36/56] 1) Fixed wrong alarm colour in analysis images. 2) Added GCC's target attribute to remove the need for -msse2. --- src/zm_image.cpp | 68 ++++++++++++++++++++++++------------------------ src/zm_utils.cpp | 2 +- src/zm_zone.cpp | 9 ++++--- 3 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 60b60a57f..fdeba7163 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -2566,7 +2566,7 @@ void Image::Scale( unsigned int factor ) /************************************************* BLEND FUNCTIONS *************************************************/ -__attribute__ ((noinline)) void sse2_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { +__attribute__((noinline,__target__("sse2"))) void sse2_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) static uint32_t divider = 0; static uint32_t clearmask = 0; @@ -2631,7 +2631,7 @@ __attribute__ ((noinline)) void sse2_fastblend(const uint8_t* col1, const uint8_ #endif } -__attribute__ ((noinline)) void std_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { +__attribute__((noinline)) void std_fastblend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { static int divider = 0; static double current_blendpercent = 0.0; const uint8_t* const max_ptr = result + count; @@ -2685,7 +2685,7 @@ __attribute__ ((noinline)) void std_fastblend(const uint8_t* col1, const uint8_t } } -__attribute__ ((noinline)) void std_blend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { +__attribute__((noinline)) void std_blend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { double divide = blendpercent / 100.0; double opacity = 1.0 - divide; const uint8_t* const max_ptr = result + count; @@ -2699,7 +2699,7 @@ __attribute__ ((noinline)) void std_blend(const uint8_t* col1, const uint8_t* co /************************************************* DELTA FUNCTIONS *************************************************/ /* Grayscale */ -__attribute__ ((noinline)) void std_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 16 bytes (16 grayscale pixels) at a time */ const uint8_t* const max_ptr = result + count; @@ -2728,7 +2728,7 @@ __attribute__ ((noinline)) void std_delta8_gray8(const uint8_t* col1, const uint } /* RGB24: RGB */ -__attribute__ ((noinline)) void std_delta8_rgb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_delta8_rgb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 12 bytes (4 rgb24 pixels) at a time */ int r,g,b; const uint8_t* const max_ptr = result + count; @@ -2758,7 +2758,7 @@ __attribute__ ((noinline)) void std_delta8_rgb(const uint8_t* col1, const uint8_ } /* RGB24: BGR */ -__attribute__ ((noinline)) void std_delta8_bgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_delta8_bgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 12 bytes (4 rgb24 pixels) at a time */ int r,g,b; const uint8_t* const max_ptr = result + count; @@ -2788,7 +2788,7 @@ __attribute__ ((noinline)) void std_delta8_bgr(const uint8_t* col1, const uint8_ } /* RGB32: RGBA */ -__attribute__ ((noinline)) void std_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */ int r,g,b; const uint8_t* const max_ptr = result + count; @@ -2818,7 +2818,7 @@ __attribute__ ((noinline)) void std_delta8_rgba(const uint8_t* col1, const uint8 } /* RGB32: BGRA */ -__attribute__ ((noinline)) void std_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */ int r,g,b; const uint8_t* const max_ptr = result + count; @@ -2848,7 +2848,7 @@ __attribute__ ((noinline)) void std_delta8_bgra(const uint8_t* col1, const uint8 } /* RGB32: ARGB */ -__attribute__ ((noinline)) void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */ int r,g,b; const uint8_t* const max_ptr = result + count; @@ -2878,7 +2878,7 @@ __attribute__ ((noinline)) void std_delta8_argb(const uint8_t* col1, const uint8 } /* RGB32: ABGR */ -__attribute__ ((noinline)) void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { /* Loop unrolling is used to work on 16 bytes (4 rgb32 pixels) at a time */ int r,g,b; const uint8_t* const max_ptr = result + count; @@ -2908,7 +2908,7 @@ __attribute__ ((noinline)) void std_delta8_abgr(const uint8_t* col1, const uint8 } /* Grayscale SSE2 */ -__attribute__ ((noinline)) void sse2_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline,__target__("sse2"))) void sse2_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( @@ -2936,7 +2936,7 @@ __attribute__ ((noinline)) void sse2_delta8_gray8(const uint8_t* col1, const uin } /* RGB32: RGBA SSE2 */ -__attribute__ ((noinline)) void sse2_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline,__target__("sse2"))) void sse2_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( @@ -3005,7 +3005,7 @@ __attribute__ ((noinline)) void sse2_delta8_rgba(const uint8_t* col1, const uint } /* RGB32: BGRA SSE2 */ -__attribute__ ((noinline)) void sse2_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline,__target__("sse2"))) void sse2_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( @@ -3074,7 +3074,7 @@ __attribute__ ((noinline)) void sse2_delta8_bgra(const uint8_t* col1, const uint } /* RGB32: ARGB SSE2 */ -__attribute__ ((noinline)) void sse2_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline,__target__("sse2"))) void sse2_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( @@ -3144,7 +3144,7 @@ __attribute__ ((noinline)) void sse2_delta8_argb(const uint8_t* col1, const uint } /* RGB32: ABGR SSE2 */ -__attribute__ ((noinline)) void sse2_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline,__target__("sse2"))) void sse2_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( @@ -3214,7 +3214,7 @@ __attribute__ ((noinline)) void sse2_delta8_abgr(const uint8_t* col1, const uint } /* RGB32: RGBA SSSE3 */ -__attribute__ ((noinline)) void ssse3_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline,__target__("ssse3"))) void ssse3_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( @@ -3266,7 +3266,7 @@ __attribute__ ((noinline)) void ssse3_delta8_rgba(const uint8_t* col1, const uin } /* RGB32: BGRA SSSE3 */ -__attribute__ ((noinline)) void ssse3_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline,__target__("ssse3"))) void ssse3_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( @@ -3318,7 +3318,7 @@ __attribute__ ((noinline)) void ssse3_delta8_bgra(const uint8_t* col1, const uin } /* RGB32: ARGB SSSE3 */ -__attribute__ ((noinline)) void ssse3_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline,__target__("ssse3"))) void ssse3_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( @@ -3371,7 +3371,7 @@ __attribute__ ((noinline)) void ssse3_delta8_argb(const uint8_t* col1, const uin } /* RGB32: ABGR SSSE3 */ -__attribute__ ((noinline)) void ssse3_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { +__attribute__((noinline,__target__("ssse3"))) void ssse3_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( @@ -3427,7 +3427,7 @@ __attribute__ ((noinline)) void ssse3_delta8_abgr(const uint8_t* col1, const uin /************************************************* CONVERT FUNCTIONS *************************************************/ /* RGB24 to grayscale */ -__attribute__ ((noinline)) void std_convert_rgb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_convert_rgb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; const uint8_t* const max_ptr = result + count; @@ -3455,7 +3455,7 @@ __attribute__ ((noinline)) void std_convert_rgb_gray8(const uint8_t* col1, uint8 } /* BGR24 to grayscale */ -__attribute__ ((noinline)) void std_convert_bgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_convert_bgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; const uint8_t* const max_ptr = result + count; @@ -3483,7 +3483,7 @@ __attribute__ ((noinline)) void std_convert_bgr_gray8(const uint8_t* col1, uint8 } /* RGBA to grayscale */ -__attribute__ ((noinline)) void std_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; const uint8_t* const max_ptr = result + count; @@ -3511,7 +3511,7 @@ __attribute__ ((noinline)) void std_convert_rgba_gray8(const uint8_t* col1, uint } /* BGRA to grayscale */ -__attribute__ ((noinline)) void std_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_convert_bgra_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; const uint8_t* const max_ptr = result + count; @@ -3539,7 +3539,7 @@ __attribute__ ((noinline)) void std_convert_bgra_gray8(const uint8_t* col1, uint } /* ARGB to grayscale */ -__attribute__ ((noinline)) void std_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_convert_argb_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; const uint8_t* const max_ptr = result + count; @@ -3567,7 +3567,7 @@ __attribute__ ((noinline)) void std_convert_argb_gray8(const uint8_t* col1, uint } /* ABGR to grayscale */ -__attribute__ ((noinline)) void std_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_convert_abgr_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; const uint8_t* const max_ptr = result + count; @@ -3595,7 +3595,7 @@ __attribute__ ((noinline)) void std_convert_abgr_gray8(const uint8_t* col1, uint } /* Converts a YUYV image into grayscale by extracting the Y channel */ -__attribute__ ((noinline)) void std_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void std_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { const uint16_t* yuvbuf = (const uint16_t*)col1; const uint8_t* const max_ptr = result + count; @@ -3623,7 +3623,7 @@ __attribute__ ((noinline)) void std_convert_yuyv_gray8(const uint8_t* col1, uint } /* RGBA to grayscale SSSE3 */ -__attribute__ ((noinline)) void ssse3_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline,__target__("ssse3"))) void ssse3_convert_rgba_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __asm__ __volatile__ ( @@ -3669,7 +3669,7 @@ __attribute__ ((noinline)) void ssse3_convert_rgba_gray8(const uint8_t* col1, ui } /* Converts a YUYV image into grayscale by extracting the Y channel */ -__attribute__ ((noinline)) void ssse3_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline,__target__("ssse3"))) void ssse3_convert_yuyv_gray8(const uint8_t* col1, uint8_t* result, unsigned long count) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) unsigned long i = 0; @@ -3714,7 +3714,7 @@ __attribute__ ((noinline)) void ssse3_convert_yuyv_gray8(const uint8_t* col1, ui } /* YUYV to RGB24 - relocated from zm_local_camera.cpp */ -__attribute__ ((noinline)) void zm_convert_yuyv_rgb(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void zm_convert_yuyv_rgb(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; unsigned int y1,y2,u,v; for(unsigned int i=0; i < count; i += 2, col1 += 4, result += 6) { @@ -3743,7 +3743,7 @@ __attribute__ ((noinline)) void zm_convert_yuyv_rgb(const uint8_t* col1, uint8_t } /* YUYV to RGBA - modified the one above */ -__attribute__ ((noinline)) void zm_convert_yuyv_rgba(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void zm_convert_yuyv_rgba(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; unsigned int y1,y2,u,v; for(unsigned int i=0; i < count; i += 2, col1 += 4, result += 8) { @@ -3772,7 +3772,7 @@ __attribute__ ((noinline)) void zm_convert_yuyv_rgba(const uint8_t* col1, uint8_ } /* RGB555 to RGB24 - relocated from zm_local_camera.cpp */ -__attribute__ ((noinline)) void zm_convert_rgb555_rgb(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void zm_convert_rgb555_rgb(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; for(unsigned int i=0; i < count; i++, col1 += 2, result += 3) { b = ((*col1)<<3)&0xf8; @@ -3785,7 +3785,7 @@ __attribute__ ((noinline)) void zm_convert_rgb555_rgb(const uint8_t* col1, uint8 } /* RGB555 to RGBA - modified the one above */ -__attribute__ ((noinline)) void zm_convert_rgb555_rgba(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void zm_convert_rgb555_rgba(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; for(unsigned int i=0; i < count; i++, col1 += 2, result += 4) { b = ((*col1)<<3)&0xf8; @@ -3798,7 +3798,7 @@ __attribute__ ((noinline)) void zm_convert_rgb555_rgba(const uint8_t* col1, uint } /* RGB565 to RGB24 - relocated from zm_local_camera.cpp */ -__attribute__ ((noinline)) void zm_convert_rgb565_rgb(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void zm_convert_rgb565_rgb(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; for(unsigned int i=0; i < count; i++, col1 += 2, result += 3) { b = ((*col1)<<3)&0xf8; @@ -3811,7 +3811,7 @@ __attribute__ ((noinline)) void zm_convert_rgb565_rgb(const uint8_t* col1, uint8 } /* RGB565 to RGBA - modified the one above */ -__attribute__ ((noinline)) void zm_convert_rgb565_rgba(const uint8_t* col1, uint8_t* result, unsigned long count) { +__attribute__((noinline)) void zm_convert_rgb565_rgba(const uint8_t* col1, uint8_t* result, unsigned long count) { unsigned int r,g,b; for(unsigned int i=0; i < count; i++, col1 += 2, result += 4) { b = ((*col1)<<3)&0xf8; diff --git a/src/zm_utils.cpp b/src/zm_utils.cpp index d781c320d..2e884517e 100644 --- a/src/zm_utils.cpp +++ b/src/zm_utils.cpp @@ -192,7 +192,7 @@ void ssedetect() { /* SSE2 aligned memory copy. Useful for big copying of aligned memory like image buffers in ZM */ /* For platforms without SSE2 we will use standard x86 asm memcpy or glibc's memcpy() */ -__attribute__((noinline)) void* sse2_aligned_memcpy(void* dest, const void* src, size_t bytes) { +__attribute__((noinline,__target__("sse2"))) void* sse2_aligned_memcpy(void* dest, const void* src, size_t bytes) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) if(bytes > 128) { unsigned int remainder = bytes % 128; diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index 0bb4c1b94..b1cd8377f 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -904,14 +904,17 @@ int Zone::Load( Monitor *monitor, Zone **&zones ) int MinBlobs = dbrow[col]?atoi(dbrow[col]):0; col++; int MaxBlobs = dbrow[col]?atoi(dbrow[col]):0; col++; int OverloadFrames = dbrow[col]?atoi(dbrow[col]):0; col++; + + /* HTML colour code is actually BGR in memory, we want RGB */ + AlarmRGB = rgb_convert(AlarmRGB, ZM_SUBPIX_ORDER_BGR); Debug( 5, "Parsing polygon %s", Coords ); Polygon polygon; if ( !ParsePolygonString( Coords, polygon ) ) Panic( "Unable to parse polygon string '%s' for zone %d/%s for monitor %s", Coords, Id, Name, monitor->Name() ); - if ( polygon.LoX() < 0 || polygon.HiX() >= monitor->Width() || polygon.LoY() < 0 || polygon.HiY() >= monitor->Height() ) - Panic( "Zone %d/%s for monitor %s extends outside of image dimensions, %d, %d, %d, %d", Id, Name, monitor->Name(), polygon.LoX(), polygon.LoY(), polygon.HiX(), polygon.HiY() ); + if ( polygon.LoX() < 0 || polygon.HiX() >= monitor->Width() || polygon.LoY() < 0 || polygon.HiY() >= monitor->Height() ) + Panic( "Zone %d/%s for monitor %s extends outside of image dimensions, %d, %d, %d, %d", Id, Name, monitor->Name(), polygon.LoX(), polygon.LoY(), polygon.HiX(), polygon.HiY() ); if ( false && !strcmp( Units, "Percent" ) ) { @@ -1025,7 +1028,7 @@ void Zone::std_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsig *pixel_sum = pixelsdifference; } -void Zone::sse2_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsigned int* pixel_count, unsigned int* pixel_sum) { +__attribute__((noinline,__target__("sse2"))) void Zone::sse2_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsigned int* pixel_count, unsigned int* pixel_sum) { #if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) __attribute__((aligned(16))) static uint8_t calc_maxpthreshold[16] = {127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127}; __attribute__((aligned(16))) static uint8_t calc_minpthreshold[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; From af821828b8c19abbb63b9821985dcf6209009fd3 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 26 Oct 2011 13:28:07 +0200 Subject: [PATCH 37/56] Changed a few warnings --- src/zm_image.cpp | 21 +++++++++------------ src/zm_local_camera.cpp | 15 +++++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index fdeba7163..1fa928671 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -1117,7 +1117,8 @@ bool Image::Crop( const Box &limits ) return( Crop( limits.LoX(), limits.LoY(), limits.HiX(), limits.HiY() ) ); } -/* Not fully complete */ +/* Far from complete */ +/* Need to implement all possible of overlays possible */ void Image::Overlay( const Image &image ) { if ( !(width == image.width && height == image.height) ) @@ -1125,11 +1126,7 @@ void Image::Overlay( const Image &image ) Panic( "Attempt to overlay different sized images, expected %dx%d, got %dx%d", width, height, image.width, image.height ); } - if( colours == image.colours && subpixelorder != image.subpixelorder ) { - Warning("Attempt to overlay images of same format but with different subpixel order."); - } - - /* Grayscale ontop of grayscale */ + /* Grayscale ontop of grayscale - complete */ if ( colours == ZM_COLOUR_GRAY8 && image.colours == ZM_COLOUR_GRAY8 ) { const uint8_t* const max_ptr = buffer+size; const uint8_t* psrc = image.buffer; @@ -1145,7 +1142,7 @@ void Image::Overlay( const Image &image ) psrc++; } - /* RGB24 ontop of grayscale - convert to same format first */ + /* RGB24 ontop of grayscale - convert to same format first - complete */ } else if ( colours == ZM_COLOUR_GRAY8 && image.colours == ZM_COLOUR_RGB24 ) { Colourise(image.colours, image.subpixelorder); @@ -1165,7 +1162,7 @@ void Image::Overlay( const Image &image ) psrc += 3; } - /* RGB32 ontop of grayscale - convert to same format first */ + /* RGB32 ontop of grayscale - convert to same format first - complete */ } else if( colours == ZM_COLOUR_GRAY8 && image.colours == ZM_COLOUR_RGB32 ) { Colourise(image.colours, image.subpixelorder); @@ -1195,7 +1192,7 @@ void Image::Overlay( const Image &image ) } } - /* Grayscale ontop of RGB24 */ + /* Grayscale ontop of RGB24 - complete */ } else if ( colours == ZM_COLOUR_RGB24 && image.colours == ZM_COLOUR_GRAY8 ) { const uint8_t* const max_ptr = buffer+size; const uint8_t* psrc = image.buffer; @@ -1211,7 +1208,7 @@ void Image::Overlay( const Image &image ) psrc++; } - /* RGB24 ontop of RGB24 */ + /* RGB24 ontop of RGB24 - not complete. need to take care of different subpixel orders */ } else if ( colours == ZM_COLOUR_RGB24 && image.colours == ZM_COLOUR_RGB24 ) { const uint8_t* const max_ptr = buffer+size; const uint8_t* psrc = image.buffer; @@ -1233,7 +1230,7 @@ void Image::Overlay( const Image &image ) } else if ( colours == ZM_COLOUR_RGB24 && image.colours == ZM_COLOUR_RGB32 ) { Error("Overlay of RGB32 ontop of RGB24 is not supported."); - /* Grayscale ontop of RGB32 */ + /* Grayscale ontop of RGB32 - complete */ } else if ( colours == ZM_COLOUR_RGB32 && image.colours == ZM_COLOUR_GRAY8 ) { const Rgb* const max_ptr = (Rgb*)(buffer+size); Rgb* prdest = (Rgb*)buffer; @@ -1265,7 +1262,7 @@ void Image::Overlay( const Image &image ) } else if ( colours == ZM_COLOUR_RGB32 && image.colours == ZM_COLOUR_RGB24 ) { Error("Overlay of RGB24 ontop of RGB32 is not supported."); - /* RGB32 ontop of RGB32 */ + /* RGB32 ontop of RGB32 - not complete. need to take care of different subpixel orders */ } else if ( colours == ZM_COLOUR_RGB32 && image.colours == ZM_COLOUR_RGB32 ) { const Rgb* const max_ptr = (Rgb*)(buffer+size); Rgb* prdest = (Rgb*)buffer; diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index f4a8b8f5d..7b6c0a77c 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -400,7 +400,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, /* Unable to find a solution for the selected palette and target colourspace. Conversion required. Notify the user of performance penalty */ } else { if( capture ) - Warning("No match for the selected palette and colourspace. Conversion required, performance penalty expected"); + Info("No direct match for the selected palette and target colorspace. Format conversion is required, performance penalty expected"); #if HAVE_LIBSWSCALE /* Try using swscale for the conversion */ conversion_type = 1; @@ -479,7 +479,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, conversion_fptr = &zm_convert_rgb565_rgba; subpixelorder = ZM_SUBPIX_ORDER_RGBA; } else { - Fatal("Unable to find suitable conversion for selected palette and target colourspace."); + Fatal("Unable to find a suitable format conversion for the selected palette and target colorspace."); } } } @@ -516,7 +516,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, /* Unable to find a solution for the selected palette and target colourspace. Conversion required. Notify the user of performance penalty */ } else { if( capture ) - Warning("No match for the selected palette and colourspace. Conversion required, performance penalty expected"); + Info("No direct match for the selected palette and target colorspace. Format conversion is required, performance penalty expected"); #if HAVE_LIBSWSCALE /* Try using swscale for the conversion */ conversion_type = 1; @@ -591,7 +591,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, conversion_fptr = &zm_convert_rgb565_rgba; subpixelorder = ZM_SUBPIX_ORDER_RGBA; } else { - Panic("Unable to find suitable conversion for selected palette and target colourspace."); + Fatal("Unable to find a suitable format conversion for the selected palette and target colorspace."); } } } @@ -745,8 +745,11 @@ void LocalCamera::Initialise() v4l2_jpegcompression jpeg_comp; if(palette == V4L2_PIX_FMT_JPEG || palette == V4L2_PIX_FMT_MJPEG) { if( vidioctl( vid_fd, VIDIOC_G_JPEGCOMP, &jpeg_comp ) < 0 ) { - Warning("Failed to get JPEG compression options: %s", strerror(errno) ); - + if(errno == EINVAL) { + Debug(2,"JPEG compression options are not available", strerror(errno) ); + } else { + Warning("Failed to get JPEG compression options: %s", strerror(errno) ); + } } else { /* Set flags and quality. MJPEG should not have the huffman tables defined */ if(palette == V4L2_PIX_FMT_MJPEG) { From d7e9c6ad5c7391f2624ebbd883705338a69ce4f6 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 27 Oct 2011 17:22:36 +0200 Subject: [PATCH 38/56] Analysis image finally working! --- src/zm_image.cpp | 102 +++++++++++++++++++++++++++++++++++++---------- src/zm_image.h | 2 +- src/zm_zone.cpp | 8 +++- 3 files changed, 89 insertions(+), 23 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 1fa928671..195de6875 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -457,43 +457,100 @@ void Image::Assign( const Image &image ) { (*fptr_imgbufcpy)(buffer, image.buffer, size); } -/* RGB24 only */ -Image *Image::HighlightEdges( Rgb colour, const Box *limits ) +Image *Image::HighlightEdges( Rgb colour, int p_colours, int p_subpixelorder, const Box *limits ) { if ( colours != ZM_COLOUR_GRAY8 ) { Panic( "Attempt to highlight image edges when colours = %d", colours ); } - Image *high_image = new Image( width, height, ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB); - uint8_t* high_buff = high_image->WriteBuffer(width, height, ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB); + /* Convert the colour's RGBA subpixel order into the image's subpixel order */ + colour = rgb_convert(colour,p_subpixelorder); + + /* Create a new image of the target format */ + Image *high_image = new Image( width, height, p_colours, p_subpixelorder ); + uint8_t* high_buff = high_image->WriteBuffer(width, height, p_colours, p_subpixelorder); + + /* Set image to all black */ + high_image->Clear(); int lo_x = limits?limits->Lo().X():0; int lo_y = limits?limits->Lo().Y():0; int hi_x = limits?limits->Hi().X():width-1; int hi_y = limits?limits->Hi().Y():height-1; - for ( int y = lo_y; y <= hi_y; y++ ) + + if ( p_colours == ZM_COLOUR_GRAY8 ) { - uint8_t *p = &buffer[(y*width)+lo_x]; - uint8_t *phigh = high_buff + (((y * width) + lo_x) * 3); - for ( int x = lo_x; x <= hi_x; x++, p++, phigh += 3 ) + for ( int y = lo_y; y <= hi_y; y++ ) { - bool edge = false; - if ( *p ) + const uint8_t* p = buffer + (y * width) + lo_x; + uint8_t* phigh = high_buff + (y * width) + lo_x; + for ( int x = lo_x; x <= hi_x; x++, p++, phigh++ ) { - if ( !edge && x > 0 && !*(p-1) ) edge = true; - if ( !edge && x < (width-1) && !*(p+1) ) edge = true; - if ( !edge && y > 0 && !*(p-width) ) edge = true; - if ( !edge && y < (height-1) && !*(p+width) ) edge = true; - } - if ( edge ) - { - RED_PTR_RGBA(phigh) = RED_VAL_RGBA(colour); - GREEN_PTR_RGBA(phigh) = GREEN_VAL_RGBA(colour); - BLUE_PTR_RGBA(phigh) = BLUE_VAL_RGBA(colour); + bool edge = false; + if ( *p ) + { + if ( !edge && x > 0 && !*(p-1) ) edge = true; + if ( !edge && x < (width-1) && !*(p+1) ) edge = true; + if ( !edge && y > 0 && !*(p-width) ) edge = true; + if ( !edge && y < (height-1) && !*(p+width) ) edge = true; + } + if ( edge ) + { + *phigh = colour; + } } } } + else if ( p_colours == ZM_COLOUR_RGB24 ) + { + for ( int y = lo_y; y <= hi_y; y++ ) + { + const uint8_t* p = buffer + (y * width) + lo_x; + uint8_t* phigh = high_buff + (((y * width) + lo_x) * 3); + for ( int x = lo_x; x <= hi_x; x++, p++, phigh += 3 ) + { + bool edge = false; + if ( *p ) + { + if ( !edge && x > 0 && !*(p-1) ) edge = true; + if ( !edge && x < (width-1) && !*(p+1) ) edge = true; + if ( !edge && y > 0 && !*(p-width) ) edge = true; + if ( !edge && y < (height-1) && !*(p+width) ) edge = true; + } + if ( edge ) + { + RED_PTR_RGBA(phigh) = RED_VAL_RGBA(colour); + GREEN_PTR_RGBA(phigh) = GREEN_VAL_RGBA(colour); + BLUE_PTR_RGBA(phigh) = BLUE_VAL_RGBA(colour); + } + } + } + } + else if ( p_colours == ZM_COLOUR_RGB32 ) + { + for ( int y = lo_y; y <= hi_y; y++ ) + { + const uint8_t* p = buffer + (y * width) + lo_x; + Rgb* phigh = (Rgb*)(high_buff + (((y * width) + lo_x) * 4)); + for ( int x = lo_x; x <= hi_x; x++, p++, phigh++ ) + { + bool edge = false; + if ( *p ) + { + if ( !edge && x > 0 && !*(p-1) ) edge = true; + if ( !edge && x < (width-1) && !*(p+1) ) edge = true; + if ( !edge && y > 0 && !*(p-width) ) edge = true; + if ( !edge && y < (height-1) && !*(p+width) ) edge = true; + } + if ( edge ) + { + *phigh = colour; + } + } + } + } + return( high_image ); } @@ -1126,6 +1183,10 @@ void Image::Overlay( const Image &image ) Panic( "Attempt to overlay different sized images, expected %dx%d, got %dx%d", width, height, image.width, image.height ); } + if( colours == image.colours && subpixelorder != image.subpixelorder ) { + Warning("Attempt to overlay images of same format but with different subpixel order."); + } + /* Grayscale ontop of grayscale - complete */ if ( colours == ZM_COLOUR_GRAY8 && image.colours == ZM_COLOUR_GRAY8 ) { const uint8_t* const max_ptr = buffer+size; @@ -1289,7 +1350,6 @@ void Image::Overlay( const Image &image ) prsrc++; } } - } } diff --git a/src/zm_image.h b/src/zm_image.h index 52f8d7ddc..432f81023 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -226,7 +226,7 @@ public: const Coord centreCoord( const char *text ) const; void Annotate( const char *p_text, const Coord &coord, const Rgb fg_colour=RGB_WHITE, const Rgb bg_colour=RGB_BLACK ); - Image *HighlightEdges( Rgb colour, const Box *limits=0 ); + Image *HighlightEdges( Rgb colour, int p_colours, int p_subpixelorder, const Box *limits=0 ); //Image *HighlightEdges( Rgb colour, const Polygon &polygon ); void Timestamp( const char *label, const time_t when, const Coord &coord ); void Colourise(const int p_reqcolours, const int p_reqsubpixelorder); diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index b1cd8377f..95dbb4f72 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -725,7 +725,13 @@ bool Zone::CheckAlarms( const Image *delta_image ) } } } - image = diff_image->HighlightEdges( alarm_rgb, &polygon.Extent() ); + + if( monitor->Colours() == ZM_COLOUR_GRAY8 ) { + image = diff_image->HighlightEdges( alarm_rgb, ZM_COLOUR_RGB24, ZM_SUBPIX_ORDER_RGB, &polygon.Extent() ); + } else { + image = diff_image->HighlightEdges( alarm_rgb, monitor->Colours(), monitor->SubpixelOrder(), &polygon.Extent() ); + } + // Only need to delete this when 'image' becomes detached and points somewhere else delete diff_image; } From 8e9ccfe1ec1ecff75d4170109b81848141b83af4 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 27 Oct 2011 17:50:39 +0200 Subject: [PATCH 39/56] Removed the now unused SSE2 AlarmedPixels code. --- src/zm_zone.cpp | 214 ------------------------------------------------ src/zm_zone.h | 1 - 2 files changed, 215 deletions(-) diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index 95dbb4f72..9d8ce354a 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -1033,217 +1033,3 @@ void Zone::std_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsig *pixel_count = pixelsalarmed; *pixel_sum = pixelsdifference; } - -__attribute__((noinline,__target__("sse2"))) void Zone::sse2_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsigned int* pixel_count, unsigned int* pixel_sum) { -#if ((defined(__i386__) || defined(__x86_64__) || defined(ZM_KEEP_SSE)) && !defined(ZM_STRIP_SSE)) - __attribute__((aligned(16))) static uint8_t calc_maxpthreshold[16] = {127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127}; - __attribute__((aligned(16))) static uint8_t calc_minpthreshold[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - static uint8_t current_minpthreshold = 0; - static uint8_t current_maxpthreshold = 255; - unsigned int minpthreshold = min_pixel_threshold; - unsigned int maxpthreshold = max_pixel_threshold; - uint32_t pixelsalarmed = 0; - uint32_t pixelsdifference = 0; - unsigned int lo_y = polygon.LoY(); - unsigned int hi_y = polygon.HiY()+1; - unsigned int lo_x = polygon.LoX(); - unsigned int hi_x = polygon.HiX()+1; - - if(maxpthreshold == 0) - maxpthreshold = 255; - - if(minpthreshold != current_minpthreshold) { - for(unsigned int i=0;i>1; - current_minpthreshold = minpthreshold; - } - - if(maxpthreshold != current_maxpthreshold) { - for(unsigned int i=0;i>1; - current_maxpthreshold = maxpthreshold; - } - - /* - * We have to work on 16 byte aligned addresses. - * Assume width is multiples of 16 and align the lo_x and hi_x to be on a 16 byte boundary - */ - if((lo_x % 16) != 0) { - lo_x = lo_x - (lo_x % 16); - } - if((hi_x % 16) != 0) { - hi_x = hi_x + (16 - (hi_x % 16)); - if( hi_x > pdiff_image->Width() ) - /* Clamp hi_x to width */ - hi_x = pdiff_image->Width(); - } - if( hi_y > pdiff_image->Height() ) { - /* Clamp hi y to height */ - hi_y = pdiff_image->Height(); - } - - unsigned int x = lo_x; - unsigned int y = lo_y; - unsigned long xgap = hi_x - lo_x; - unsigned long width = pdiff_image->Width(); - uint8_t* pdiff = (uint8_t*)pdiff_image->Buffer(lo_x, lo_y); - const uint8_t* ppoly = ppoly_image->Buffer(lo_x, lo_y); - - /* Some sanity checks */ - if((width % 16) != 0) { - Fatal("Image width is not multiples of 16!"); - } - if((xgap % 16) != 0) { - /* Shouldn't happen but just in case */ - Fatal("Difference between calculated hi_x and lo_x is not multiples of 16"); - } - if(lo_x == hi_x) { - Error("lo_x and hi_x are identical, nothing to scan. Scanning the whole line instead"); - lo_x = 0; - hi_x = width; - } - - - /* XMM0,1,2,3 - General purpose */ - /* XMM4 - alarmed pixels count */ - /* XMM5 - difference accumulator */ - /* XMM6 - min pixel threshold mask */ - /* XMM7 - max pixel threshold mask */ - /* XMM8 - divide mask */ - /* XMM9 - 0x01 mask */ - /* - Register map: - %0 - pixelsalarmed - %1 - pixelsdifference - %2 - pdiff - %3 - ppoly - %4 - X - %5 - Y - %6 - min pixel mask - %7 - max pixel mask - %8 - lo_y - %9 - lo_x - %10 - hi_x - %11 - hi_y - %12 - width - %13 - xgap - */ - - /* Initial setup - * set X to lo_x - * set Y to lo_y - * set pdiff to pdiff start + (width * lo_y) + lo_x - * set ppoly to ppoly start + (width * lo_y) + lo_x - * set xgap to hi_x - lo_x - */ - - __asm__ __volatile__ ( - "pxor %%xmm4, %%xmm4\n\t" // Zero out the alarmed pixels count - "pxor %%xmm5, %%xmm5\n\t" // Zero out the difference accumulator - "movdqa %6, %%xmm6\n\t" // Load the min pixel threshold (divided by 2) - "movdqa %7, %%xmm7\n\t" // Load the max pixel threshold (divided by 2) -#if defined(__x86_64__) - "mov $0x7F7F7F7F, %%eax\n\t" /* Divide mask */ - "movd %%eax, %%xmm8\n\t" - "pshufd $0x0, %%xmm8, %%xmm8\n\t" - "mov $0x01010101, %%eax\n\t" /* 0x1 mask */ - "movd %%eax, %%xmm9\n\t" - "pshufd $0x0, %%xmm9, %%xmm9\n\t" -#endif - /* Iteration start */ - "sse2_ap_iter:\n\t" - "movdqa (%2), %%xmm0\n\t" // Load the pdiff - "movdqa (%3), %%xmm1\n\t" // Load the ppoly - - "pand %%xmm0, %%xmm1\n\t" // Filter out pixels not inside polygon. Result stored on XMM1 - "movdqa %%xmm1, %%xmm2\n\t" // Move the result into XMM2 - "psrlq $0x1, %%xmm2\n\t" // Divide the result by 2 (part 1) -#if defined(__x86_64__) - "pand %%xmm8, %%xmm2\n\t" // Divide the result by 2 (part 2) -#else - "mov $0x7F7F7F7F, %%eax\n\t" - "movd %%eax, %%xmm0\n\t" - "pshufd $0x0, %%xmm0, %%xmm0\n\t" - "pand %%xmm0, %%xmm2\n\t" // Divide the result by 2 (part 2) -#endif - - /* Filter out pixels bigger than max threshold and update XMM0 */ - "movdqa %%xmm7, %%xmm0\n\t" // Copy max threshold to XMM0 - "pcmpgtb %%xmm2, %%xmm0\n\t" // Filter out pixels bigger than max threshold, result stored on XMM0 - "pand %%xmm2, %%xmm0\n\t" // XMM0 = Dividied pixels that are in poly and meet maximum threshold - - /* Filter out pixels smaller than min threshold */ - "pcmpgtb %%xmm6, %%xmm0\n\t" // Filter out pixels smaller than min threshold, result stored on XMM0 - - /* Write white or black depending if pixel is alarmed or not */ - "movntdq %%xmm0, (%2)\n\t" // Set the pixel to white or black depending on the result - - /* Update the alarmed pixels count */ -#if defined(__x86_64__) - "movdqa %%xmm9, %%xmm3\n\t" // Move 0x01 mask to XMM3 -#else - "mov $0x01010101, %%eax\n\t" - "movd %%eax, %%xmm3\n\t" - "pshufd $0x0, %%xmm3, %%xmm3\n\t" -#endif - "pxor %%xmm2, %%xmm2\n\t" // Set XMM2 to zeros - - "pand %%xmm0, %%xmm3\n\t" // Set alarmed pixels to 1 in XMM3 - "psadbw %%xmm2, %%xmm3\n\t" // DEST[0-15] and DEST[64-79] contain the results - "paddd %%xmm3, %%xmm4\n\t" // Update the alarmed pixels count - - /* Update XMM0 to contain pixels in poly that meet min and max thresholds */ - "pand %%xmm1, %%xmm0\n\t" // XMM0 = Pixels in poly that meet min and max thresholds - - /* Update the difference accumulator */ - "psadbw %%xmm0, %%xmm2\n\t" // DEST[0-15] and DEST[64-79] contain the results - "paddd %%xmm2, %%xmm5\n\t" // Update the difference accumulator - - /* Move to the next pixels in the row */ - "add $0x10, %2\n\t" // Add 16 to pdiff - "add $0x10, %3\n\t" // Add 16 to ppoly - "add $0x10, %4\n\t" // Add 16 to X - "cmp %10, %4\n\t" // Check if we reached max X - "jb sse2_ap_iter\n\t" // Go for another iteration - - "sub %13, %2\n\t" // Reset pdiff to low X - "sub %13, %3\n\t" // Reset ppoly to low X - "sub %13, %4\n\t" // Reset X to low x - - "add $0x1, %5\n\t" // Increment Y to advance to the next line - "add %12, %2\n\t" // Move pdiff to the next row - "add %12, %3\n\t" // Move ppoly to the next row - - "cmp %11, %5\n\t" // Check if we reached max Y - "jb sse2_ap_iter\n\t" // Go for another iteration - - /* Calculate the alarmed pixels */ - "pshufd $0x56, %%xmm4, %%xmm0\n\t" - "paddd %%xmm4, %%xmm0\n\t" - "movd %%xmm0, %0\n\t" - - /* Calculate the pixels difference */ - "pshufd $0x56, %%xmm5, %%xmm1\n\t" - "paddd %%xmm5, %%xmm1\n\t" - "movd %%xmm1, %1\n\t" - - : "=m" (pixelsalarmed), "=m" (pixelsdifference) -#if (defined(_DEBUG) && !defined(__x86_64__)) /* Use one less register to allow compilation to success on 32bit with omit frame pointer disabled */ - : "r" (pdiff), "r" (ppoly), "r" (x), "r" (y), "m" (*calc_minpthreshold), "m" (*calc_maxpthreshold), "m" (lo_y), "m" (lo_x), "m" (hi_x), "m" (hi_y), "m" (width), "m" (xgap) -#else - : "r" (pdiff), "r" (ppoly), "r" (x), "r" (y), "m" (*calc_minpthreshold), "m" (*calc_maxpthreshold), "m" (lo_y), "m" (lo_x), "r" (hi_x), "m" (hi_y), "m" (width), "m" (xgap) -#endif -#if defined(__x86_64__) - : "%rax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "%xmm9", "cc", "memory" -#else - : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "cc", "memory" -#endif - ); - - /* Store the results */ - *pixel_count = pixelsalarmed; - *pixel_sum = pixelsdifference; -#else - Panic("SSE function called on a non x86\\x86-64 platform"); -#endif -} diff --git a/src/zm_zone.h b/src/zm_zone.h index ae247ada4..6aa45e13d 100644 --- a/src/zm_zone.h +++ b/src/zm_zone.h @@ -95,7 +95,6 @@ protected: protected: void Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_type, const Polygon &p_polygon, const Rgb p_alarm_rgb, CheckMethod p_check_method, int p_min_pixel_threshold, int p_max_pixel_threshold, int p_min_alarm_pixels, int p_max_alarm_pixels, const Coord &p_filter_box, int p_min_filter_pixels, int p_max_filter_pixels, int p_min_blob_pixels, int p_max_blob_pixels, int p_min_blobs, int p_max_blobs, int p_overload_frames ); void std_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsigned int* pixel_count, unsigned int* pixel_sum); - void sse2_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsigned int* pixel_count, unsigned int* pixel_sum); public: Zone( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_type, const Polygon &p_polygon, const Rgb p_alarm_rgb, CheckMethod p_check_method, int p_min_pixel_threshold=15, int p_max_pixel_threshold=0, int p_min_alarm_pixels=50, int p_max_alarm_pixels=75000, const Coord &p_filter_box=Coord( 3, 3 ), int p_min_filter_pixels=50, int p_max_filter_pixels=50000, int p_min_blob_pixels=10, int p_max_blob_pixels=0, int p_min_blobs=0, int p_max_blobs=0, int p_overload_frames=0 ) From fc1807f433c6764f42316d847011aa7d493f81ae Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sun, 30 Oct 2011 14:53:46 +0200 Subject: [PATCH 40/56] Fixed possible small stack corruption. --- src/zm_local_camera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 7b6c0a77c..43df705d9 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -746,7 +746,7 @@ void LocalCamera::Initialise() if(palette == V4L2_PIX_FMT_JPEG || palette == V4L2_PIX_FMT_MJPEG) { if( vidioctl( vid_fd, VIDIOC_G_JPEGCOMP, &jpeg_comp ) < 0 ) { if(errno == EINVAL) { - Debug(2,"JPEG compression options are not available", strerror(errno) ); + Debug(2, "JPEG compression options are not available"); } else { Warning("Failed to get JPEG compression options: %s", strerror(errno) ); } From 2135e58c41a9edf8cbf7a5533cccf3093d417be5 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sun, 6 Nov 2011 14:13:28 +0200 Subject: [PATCH 41/56] Fixed zma crashes caused by flaky signal and few bugs in mocord mode. --- src/zm_monitor.cpp | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 5bbff9dd4..ec89b22bc 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1234,7 +1234,6 @@ bool Monitor::Analyse() { Info( "%s: %03d - Closing event %d, signal loss", name, image_count, event->Id() ); closeEvent(); - shared_data->state = state = IDLE; last_section_mod = 0; } if ( !event ) @@ -1246,6 +1245,7 @@ bool Monitor::Analyse() Event::StringSet noteSet; noteSet.insert( signalText ); noteSetMap[SIGNAL_CAUSE] = noteSet; + shared_data->state = state = IDLE; shared_data->active = signal; ref_image = *snap_image; } @@ -1311,8 +1311,11 @@ bool Monitor::Analyse() { if ( state == IDLE || state == TAPE || event_close_mode == CLOSE_TIME ) { - if ( state == IDLE || state == TAPE ) + if ( state == TAPE ) + { + shared_data->state = state = IDLE; Info( "%s: %03d - Closing event %d, section end", name, image_count, event->Id() ) + } else Info( "%s: %03d - Closing event %d, section end forced ", name, image_count, event->Id() ); closeEvent(); @@ -1326,7 +1329,6 @@ bool Monitor::Analyse() } if ( !event ) { - shared_data->state = state = TAPE; // Create event event = new Event( this, *timestamp, "Continuous", noteSetMap ); @@ -1334,6 +1336,12 @@ bool Monitor::Analyse() Info( "%s: %03d - Opening new event %d, section start", name, image_count, event->Id() ); + /* To prevent cancelling out the prealarm or alarm state caused from signal reacquired or from a linked monitor */ + if ( state == IDLE ) + { + shared_data->state = state = TAPE; + } + //if ( config.overlap_timed_events ) if ( false ) { @@ -1535,23 +1543,6 @@ bool Monitor::Analyse() } } } - if ( function == RECORD || function == MOCORD ) - { - if ( state == IDLE || state == TAPE ) - { - int section_mod = timestamp->tv_sec%section_length; - if ( section_mod < last_section_mod ) - { - Info( "%s: %03d - Closing event %d, section end2", name, image_count, event->Id() ); - closeEvent(); - last_section_mod = 0; - } - else - { - last_section_mod = section_mod; - } - } - } } } else From 1f072b1a62ae29ac082db873f3450f93225e6f4a Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sun, 13 Nov 2011 12:22:18 +0200 Subject: [PATCH 42/56] Fixed few zma issues related to signal checking and linked monitors. --- src/zm_monitor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index ec89b22bc..1fce364ae 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1249,7 +1249,7 @@ bool Monitor::Analyse() shared_data->active = signal; ref_image = *snap_image; } - else if ( signal && Active() && function != RECORD && function != NODECT ) + else if ( signal && Active() && (function == MODECT || function == MOCORD) ) { Event::StringSet zoneSet; int motion_score = DetectMotion( *snap_image, zoneSet ); @@ -1270,7 +1270,7 @@ bool Monitor::Analyse() } shared_data->active = signal; } - if ( n_linked_monitors > 0 ) + if ( (!signal_change && signal) && n_linked_monitors > 0 ) { bool first_link = true; Event::StringSet noteSet; @@ -1278,7 +1278,7 @@ bool Monitor::Analyse() { if ( linked_monitors[i]->isConnected() ) { - if ( linked_monitors[i]->hasAlarmed() ) + if ( linked_monitors[i]->isAlarmed() ) { if ( !event ) { @@ -1336,7 +1336,7 @@ bool Monitor::Analyse() Info( "%s: %03d - Opening new event %d, section start", name, image_count, event->Id() ); - /* To prevent cancelling out the prealarm or alarm state caused from signal reacquired or from a linked monitor */ + /* To prevent cancelling out an existing alert\prealarm\alarm state */ if ( state == IDLE ) { shared_data->state = state = TAPE; @@ -1555,7 +1555,7 @@ bool Monitor::Analyse() shared_data->state = state = IDLE; last_section_mod = 0; } - if ( signal && (function == MODECT || function == MOCORD) && (config.blend_alarmed_images || state != ALARM) ) + if ( (!signal_change && signal) && (function == MODECT || function == MOCORD) && (config.blend_alarmed_images || state != ALARM) ) { ref_image.Blend( *snap_image, ref_blend_perc ); } From 115db01f8c4c6b1a01daf2da64f8de212bbc7b6d Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 9 Feb 2012 12:23:45 +0200 Subject: [PATCH 43/56] Few changes: 1) Fixed buffer overflow occurring if JPEG quality is set to 100. 2) Changed linked monitors alarm behaviour again. 3) Fixed extremely poor blend performance on some processors such as the Intel Atom. 4) Added optional profiling code for Blend() and Delta(). --- src/zm_image.cpp | 56 +++++++++++++++++++++++++++++++++++++++++----- src/zm_monitor.cpp | 4 ++-- src/zm_utils.cpp | 10 +++++++++ src/zm_utils.h | 3 +++ 4 files changed, 65 insertions(+), 8 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 195de6875..7186446ca 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -34,7 +34,7 @@ static short *g_u_table; static short *b_u_table; __attribute__((aligned(16))) static const uint8_t movemask[16] = {0,4,8,12,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; -jpeg_compress_struct *Image::jpg_ccinfo[100] = { 0 }; +jpeg_compress_struct *Image::jpg_ccinfo[101] = { 0 }; jpeg_decompress_struct *Image::jpg_dcinfo = 0; struct zm_error_mgr Image::jpg_err; @@ -1421,15 +1421,40 @@ void Image::Overlay( const Image &image, int x, int y ) void Image::Blend( const Image &image, int transparency ) { +#ifdef ZM_IMAGE_PROFILING + struct timespec start,end,diff; + unsigned long long executetime; + unsigned long milpixels; +#endif + uint8_t* new_buffer; + if ( !(width == image.width && height == image.height && colours == image.colours && subpixelorder == image.subpixelorder) ) { Panic( "Attempt to blend different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, image.width, image.height, image.colours, image.subpixelorder ); } - if(transparency > 0) { - /* Do the blending */ - (*fptr_blend)(buffer, image.buffer, buffer, size, transparency); - } + if(transparency <= 0) + return; + + new_buffer = AllocBuffer(size); + +#ifdef ZM_IMAGE_PROFILING + clock_gettime(CLOCK_THREAD_CPUTIME_ID,&start); +#endif + + /* Do the blending */ + (*fptr_blend)(buffer, image.buffer, new_buffer, size, transparency); + +#ifdef ZM_IMAGE_PROFILING + clock_gettime(CLOCK_THREAD_CPUTIME_ID,&end); + timespec_diff(&start,&end,&diff); + + executetime = (1000000000ull * diff.tv_sec) + diff.tv_nsec; + milpixels = (unsigned long)((long double)size)/((((long double)executetime)/1000)); + Debug(5, "Blend: %u colours blended in %llu nanoseconds, %lu million colours/s\n",size,executetime,milpixels); +#endif + + AssignDirect( width, height, colours, subpixelorder, new_buffer, size, ZM_BUFTYPE_ZM); } Image *Image::Merge( int n_images, Image *images[] ) @@ -1544,6 +1569,12 @@ Image *Image::Highlight( int n_images, Image *images[], const Rgb threshold, con /* New function to allow buffer re-using instead of allocationg memory for the delta image everytime */ void Image::Delta( const Image &image, Image* targetimage) const { +#ifdef ZM_IMAGE_PROFILING + struct timespec start,end,diff; + unsigned long long executetime; + unsigned long milpixels; +#endif + if ( !(width == image.width && height == image.height && colours == image.colours && subpixelorder == image.subpixelorder) ) { Panic( "Attempt to get delta of different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, image.width, image.height, image.colours, image.subpixelorder); @@ -1554,7 +1585,11 @@ void Image::Delta( const Image &image, Image* targetimage) const if(pdiff == NULL) { Panic("Failed requesting writeable buffer for storing the delta image"); } - + +#ifdef ZM_IMAGE_PROFILING + clock_gettime(CLOCK_THREAD_CPUTIME_ID,&start); +#endif + switch(colours) { case ZM_COLOUR_RGB24: { @@ -1591,6 +1626,15 @@ void Image::Delta( const Image &image, Image* targetimage) const Panic("Delta called with unexpected colours: %d",colours); break; } + +#ifdef ZM_IMAGE_PROFILING + clock_gettime(CLOCK_THREAD_CPUTIME_ID,&end); + timespec_diff(&start,&end,&diff); + + executetime = (1000000000ull * diff.tv_sec) + diff.tv_nsec; + milpixels = (unsigned long)((long double)pixels)/((((long double)executetime)/1000)); + Debug(5, "Delta: %u delta pixels generated in %llu nanoseconds, %lu million pixels/s\n",pixels,executetime,milpixels); +#endif } const Coord Image::centreCoord( const char *text ) const diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 1fce364ae..6732298fa 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -224,7 +224,7 @@ bool Monitor::MonitorLink::inAlarm() bool Monitor::MonitorLink::hasAlarmed() { - if ( shared_data->state == ALARM || shared_data->state == ALERT ) + if ( shared_data->state == ALARM ) { return( true ); } @@ -1278,7 +1278,7 @@ bool Monitor::Analyse() { if ( linked_monitors[i]->isConnected() ) { - if ( linked_monitors[i]->isAlarmed() ) + if ( linked_monitors[i]->hasAlarmed() ) { if ( !event ) { diff --git a/src/zm_utils.cpp b/src/zm_utils.cpp index 2e884517e..fabd79c96 100644 --- a/src/zm_utils.cpp +++ b/src/zm_utils.cpp @@ -241,3 +241,13 @@ __attribute__((noinline,__target__("sse2"))) void* sse2_aligned_memcpy(void* des return dest; } +void timespec_diff(struct timespec *start, struct timespec *end, struct timespec *diff) { + if (((end->tv_nsec)-(start->tv_nsec))<0) { + diff->tv_sec = end->tv_sec-start->tv_sec-1; + diff->tv_nsec = 1000000000+end->tv_nsec-start->tv_nsec; + } else { + diff->tv_sec = end->tv_sec-start->tv_sec; + diff->tv_nsec = end->tv_nsec-start->tv_nsec; + } +} + diff --git a/src/zm_utils.h b/src/zm_utils.h index 9313a0125..658c10180 100644 --- a/src/zm_utils.h +++ b/src/zm_utils.h @@ -20,6 +20,8 @@ #ifndef ZM_UTILS_H #define ZM_UTILS_H +#include +#include #include #include @@ -45,6 +47,7 @@ inline int min( int a, int b ) void ssedetect(); void* sse2_aligned_memcpy(void* dest, const void* src, size_t bytes); +void timespec_diff(struct timespec *start, struct timespec *end, struct timespec *diff); extern unsigned int sseversion; From 8d304972f18c880fd2002eb019082c8d648d298e Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 9 Feb 2012 13:10:48 +0200 Subject: [PATCH 44/56] Fix compile error caused by the previous commit. --- src/zm_image.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_image.h b/src/zm_image.h index 432f81023..c0c0660b6 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -131,7 +131,7 @@ protected: static unsigned char *y_r_table; static unsigned char *y_g_table; static unsigned char *y_b_table; - static jpeg_compress_struct *jpg_ccinfo[100]; + static jpeg_compress_struct *jpg_ccinfo[101]; static jpeg_decompress_struct *jpg_dcinfo; static struct zm_error_mgr jpg_err; From 2dfdc8129c35accb71b2f37a1e0eea0c5dd29a78 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 7 Mar 2012 14:33:09 +0200 Subject: [PATCH 45/56] Few small fixes: 1) Added a workaround against SWS_CPU_CAPS_SSE2 not being defined. 2) Fixed enableDisableAlarms javascript error. 3) swscale unsupported format errors now include the unsupported format in the error. 4) Fixed a small error affecting local cameras with rotation enabled. --- src/zm_ffmpeg.h | 5 +++++ src/zm_ffmpeg_camera.cpp | 4 ++-- src/zm_local_camera.cpp | 8 ++++---- src/zm_remote_camera_rtsp.cpp | 4 ++-- web/skins/classic/views/js/watch.js | 4 ---- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/zm_ffmpeg.h b/src/zm_ffmpeg.h index 081f0d21e..7c5301638 100644 --- a/src/zm_ffmpeg.h +++ b/src/zm_ffmpeg.h @@ -54,6 +54,11 @@ extern "C" { #else // FFMPEG_VERSION_INT #define ZM_FFMPEG_SVN 1 #endif // FFMPEG_VERSION_INT + +/* Fix for not having SWS_CPU_CAPS_SSE2 defined */ +#ifndef SWS_CPU_CAPS_SSE2 +#define SWS_CPU_CAPS_SSE2 0x02000000 +#endif #endif // HAVE_LIBAVCODEC diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 8a820e0b6..42927f6b1 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -158,11 +158,11 @@ int FfmpegCamera::PrimeCapture() #if HAVE_LIBSWSCALE if(!sws_isSupportedInput(mCodecContext->pix_fmt)) { - Fatal("swscale does not support the codec format"); + Fatal("swscale does not support the codec format: %c%c%c%c",(mCodecContext->pix_fmt)&0xff,((mCodecContext->pix_fmt>>8)&0xff),((mCodecContext->pix_fmt>>16)&0xff),((mCodecContext->pix_fmt>>24)&0xff)); } if(!sws_isSupportedOutput(imagePixFormat)) { - Fatal("swscale does not support the target format"); + Fatal("swscale does not support the target format: %c%c%c%c",(imagePixFormat)&0xff,((imagePixFormat>>8)&0xff),((imagePixFormat>>16)&0xff),((imagePixFormat>>24)&0xff)); } #else // HAVE_LIBSWSCALE diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 43df705d9..efd983822 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -339,7 +339,7 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, Error("Automatic format selection failed. Falling back to YUYV"); palette = V4L2_PIX_FMT_YUYV; } else { - Debug(2,"Selected capture palette: %s (%c%c%c%c)",palette_desc,palette&0xff, (palette>>8)&0xff, (palette>>16)&0xff, (palette>>24)&0xff ); + Info("Selected capture palette: %s (%c%c%c%c)", palette_desc, palette&0xff, (palette>>8)&0xff, (palette>>16)&0xff, (palette>>24)&0xff); } } #endif @@ -419,11 +419,11 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, } if( capture ) { if(!sws_isSupportedInput(capturePixFormat)) { - Error("swscale does not support the used capture format"); + Error("swscale does not support the used capture format: %c%c%c%c",(capturePixFormat)&0xff,((capturePixFormat>>8)&0xff),((capturePixFormat>>16)&0xff),((capturePixFormat>>24)&0xff)); conversion_type = 2; /* Try ZM format conversions */ } if(!sws_isSupportedOutput(imagePixFormat)) { - Error("swscale does not support the target format"); + Error("swscale does not support the target format: %c%c%c%c",(imagePixFormat)&0xff,((imagePixFormat>>8)&0xff),((imagePixFormat>>16)&0xff),((imagePixFormat>>24)&0xff)); conversion_type = 2; /* Try ZM format conversions */ } } @@ -2013,7 +2013,7 @@ int LocalCamera::Capture( Image &image ) buffer = (unsigned char *)v4l2_data.buffers[v4l2_data.bufptr->index].start; buffer_bytesused = v4l2_data.bufptr->bytesused; - if(v4l2_data.fmt.fmt.pix.width != width && v4l2_data.fmt.fmt.pix.height != height) { + if((v4l2_data.fmt.fmt.pix.width * v4l2_data.fmt.fmt.pix.height) != (width * height)) { Fatal("Captured image dimensions differ: V4L2: %dx%d monitor: %dx%d",v4l2_data.fmt.fmt.pix.width,v4l2_data.fmt.fmt.pix.height,width,height); } diff --git a/src/zm_remote_camera_rtsp.cpp b/src/zm_remote_camera_rtsp.cpp index bb23f3335..3ccc76973 100644 --- a/src/zm_remote_camera_rtsp.cpp +++ b/src/zm_remote_camera_rtsp.cpp @@ -202,11 +202,11 @@ int RemoteCameraRtsp::PrimeCapture() #if HAVE_LIBSWSCALE if(!sws_isSupportedInput(mCodecContext->pix_fmt)) { - Fatal("swscale does not support the codec format"); + Fatal("swscale does not support the codec format: %c%c%c%c",(mCodecContext->pix_fmt)&0xff,((mCodecContext->pix_fmt>>8)&0xff),((mCodecContext->pix_fmt>>16)&0xff),((mCodecContext->pix_fmt>>24)&0xff)); } if(!sws_isSupportedOutput(imagePixFormat)) { - Fatal("swscale does not support the target format"); + Fatal("swscale does not support the target format: %c%c%c%c",(imagePixFormat)&0xff,((imagePixFormat>>8)&0xff),((imagePixFormat>>16)&0xff),((imagePixFormat>>24)&0xff)); } #else // HAVE_LIBSWSCALE diff --git a/web/skins/classic/views/js/watch.js b/web/skins/classic/views/js/watch.js index b88fb4402..dc3f63d43 100644 --- a/web/skins/classic/views/js/watch.js +++ b/web/skins/classic/views/js/watch.js @@ -204,10 +204,6 @@ function getStreamCmdResponse( respObj, respText ) } $('enableDisableAlarms').removeClass( 'hidden' ); } - else - { - $('enableDisableAlarms').addClass( 'hidden' ); - } } else checkStreamForErrors("getStreamCmdResponse",respObj);//log them From 40a8dd9b631e0a9f3b46ae2383dcb99831e516fb Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 7 Mar 2012 15:02:27 +0200 Subject: [PATCH 46/56] Automatic capture palette selection now displays the selected capture palette in the log (only for zmc). --- src/zm_local_camera.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index efd983822..68475c362 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -339,7 +339,9 @@ LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, Error("Automatic format selection failed. Falling back to YUYV"); palette = V4L2_PIX_FMT_YUYV; } else { - Info("Selected capture palette: %s (%c%c%c%c)", palette_desc, palette&0xff, (palette>>8)&0xff, (palette>>16)&0xff, (palette>>24)&0xff); + if(capture) { + Info("Selected capture palette: %s (%c%c%c%c)", palette_desc, palette&0xff, (palette>>8)&0xff, (palette>>16)&0xff, (palette>>24)&0xff); + } } } #endif From 60a042e44b31a4848008e14379658d8e5bde78d9 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Mon, 12 Mar 2012 19:52:53 +0200 Subject: [PATCH 47/56] Fixed an error in zmMemWrite(), breaking shared memory writes from perl, which prevented zmtrigger.pl (and perhaps others) from working. --- .../ZoneMinder/lib/ZoneMinder/Memory.pm.in | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in index 9e75269c8..35fc0b0a4 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in @@ -415,53 +415,53 @@ sub zmMemWrite( $$;$ ) my $data; if ( $type eq "long" ) { - $data = pack( "l!", $data ); + $data = pack( "l!", $value ); } elsif ( $type eq "ulong" || $type eq "size_t" ) { - $data = pack( "L!", $data ); + $data = pack( "L!", $value ); } elsif ( $type eq "int64" || $type eq "time_t64" ) { # The "q" type is only available on 64bit platforms, so use native. - $data = pack( "l!", $data ); + $data = pack( "l!", $value ); } elsif ( $type eq "uint64" ) { # The "q" type is only available on 64bit platforms, so use native. - $data = pack( "L!", $data ); + $data = pack( "L!", $value ); } elsif ( $type eq "int32" ) { - $data = pack( "l", $data ); + $data = pack( "l", $value ); } elsif ( $type eq "uint32" || $type eq "bool4" ) { - $data = pack( "L", $data ); + $data = pack( "L", $value ); } elsif ( $type eq "int16" ) { - $data = pack( "s", $data ); + $data = pack( "s", $value ); } elsif ( $type eq "uint16" ) { - $data = pack( "S", $data ); + $data = pack( "S", $value ); } elsif ( $type eq "int8" ) { - $data = pack( "c", $data ); + $data = pack( "c", $value ); } elsif ( $type eq "uint8" || $type eq "bool1" ) { - $data = pack( "C", $data ); + $data = pack( "C", $value ); } elsif ( $type =~ /^int8\[\d+\]$/ ) { - $data = pack( "Z".$size, $data ); + $data = pack( "Z".$size, $value ); } elsif ( $type =~ /^uint8\[\d+\]$/ ) { - $data = pack( "C".$size, $data ); + $data = pack( "C".$size, $value ); } else { From 0932f50d80abe2de14ed2f409851a584e38f3ed1 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 22 Mar 2012 08:30:57 +0200 Subject: [PATCH 48/56] 1) Added the image size and format to the shared memory. This is useful for viewer applications relying on the shared memory. 2) Small changes to improve the response time of the DVR controls. Going through frames in a paused event is now much faster. --- scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in | 4 ++-- src/zm_event.cpp | 4 ++-- src/zm_monitor.cpp | 6 +++++- src/zm_monitor.h | 8 ++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in index 35fc0b0a4..dfc9da828 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/Memory.pm.in @@ -149,10 +149,10 @@ our $mem_data = "valid" => { "type"=>"uint8", "seq"=>$mem_seq++ }, "active" => { "type"=>"uint8", "seq"=>$mem_seq++ }, "signal" => { "type"=>"uint8", "seq"=>$mem_seq++ }, - "bpadding" => { "type"=>"uint8", "seq"=>$mem_seq++ }, + "format" => { "type"=>"uint8", "seq"=>$mem_seq++ }, + "imagesize" => { "type"=>"uint32", "seq"=>$mem_seq++ }, "epadding1" => { "type"=>"uint32", "seq"=>$mem_seq++ }, "epadding2" => { "type"=>"uint32", "seq"=>$mem_seq++ }, - "epadding3" => { "type"=>"uint32", "seq"=>$mem_seq++ }, "last_write_time" => { "type"=>"time_t64", "seq"=>$mem_seq++ }, "last_read_time" => { "type"=>"time_t64", "seq"=>$mem_seq++ }, "control_state" => { "type"=>"uint8[256]", "seq"=>$mem_seq++ }, diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 88ce48415..0fd203cdd 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -1348,7 +1348,7 @@ void EventStream::runStream() { gettimeofday( &now, NULL ); - checkCommandQueue(); + while(checkCommandQueue()); if ( step != 0 ) curr_frame_id += step; @@ -1445,7 +1445,7 @@ void EventStream::runStream() } else { - usleep( STREAM_PAUSE_WAIT ); + usleep( (unsigned long)((1000000 * ZM_RATE_BASE)/((base_fps?base_fps:1)*abs(replay_rate*2))) ); } } #if HAVE_LIBAVCODEC diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 6732298fa..798e22b1d 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -418,6 +418,8 @@ Monitor::Monitor( shared_data->contrast = -1; shared_data->alarm_x = -1; shared_data->alarm_y = -1; + shared_data->format = camera->SubpixelOrder(); + shared_data->imagesize = camera->ImageSize(); trigger_data->size = sizeof(TriggerData); trigger_data->trigger_state = TRIGGER_CANCEL; trigger_data->trigger_score = 0; @@ -3517,7 +3519,9 @@ void MonitorStream::runStream() if ( connkey ) { - got_command = checkCommandQueue(); + while(checkCommandQueue()) { + got_command = true; + } } bool frame_sent = false; diff --git a/src/zm_monitor.h b/src/zm_monitor.h index a0674abd3..acbe0933b 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -105,10 +105,10 @@ protected: uint8_t valid; /* +48 */ uint8_t active; /* +49 */ uint8_t signal; /* +50 */ - uint8_t bpadding; /* +51 */ - uint32_t epadding1; /* +52 */ - uint32_t epadding2; /* +56 */ - uint32_t epadding3; /* +60 */ + uint8_t format; /* +51 */ + uint32_t imagesize; /* +52 */ + uint32_t epadding1; /* +56 */ + uint32_t epadding2; /* +60 */ /* ** This keeps 32bit time_t and 64bit time_t identical and compatible as long as time is before 2038. ** Shared memory layout should be identical for both 32bit and 64bit and is multiples of 16. From 9dbf00ebd76054999dbcb9c356d4fb06eb6f712e Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 22 Mar 2012 08:41:17 +0200 Subject: [PATCH 49/56] A big performance improvement for SSE2 delta (32bit RGB only). Should be useful on processors without SSSE3, such as many AMD processors. --- src/zm_image.cpp | 80 ++++++++---------------------------------------- 1 file changed, 12 insertions(+), 68 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 7186446ca..b6443ef18 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -3047,9 +3047,6 @@ __attribute__((noinline,__target__("sse2"))) void sse2_delta8_rgba(const uint8_t "mov $0xff, %%eax\n\t" "movd %%eax, %%xmm0\n\t" "pshufd $0x0, %%xmm0, %%xmm0\n\t" - "mov $0x80000000, %%eax\n\t" - "movd %%eax, %%xmm5\n\t" - "pshufd $0x0, %%xmm5, %%xmm5\n\t" "sub $0x10, %0\n\t" "sub $0x10, %1\n\t" "sub $0x4, %2\n\t" @@ -3079,20 +3076,9 @@ __attribute__((noinline,__target__("sse2"))) void sse2_delta8_rgba(const uint8_t "psrld $0x10, %%xmm2\n\t" "pand %%xmm0, %%xmm2\n\t" "paddd %%xmm2, %%xmm1\n\t" - "movdqa %%xmm1, %%xmm3\n\t" - "movdqa %%xmm1, %%xmm2\n\t" - "pand %%xmm0, %%xmm3\n\t" - "pand %%xmm0, %%xmm2\n\t" - "psrldq $0x9, %%xmm2\n\t" - "por %%xmm2, %%xmm3\n\t" - "movdqa %%xmm1, %%xmm2\n\t" - "pand %%xmm0, %%xmm2\n\t" - "psrldq $0x6, %%xmm2\n\t" - "por %%xmm2, %%xmm3\n\t" - "pand %%xmm0, %%xmm1\n\t" - "psrldq $0x3, %%xmm1\n\t" - "por %%xmm1, %%xmm3\n\t" - "movd %%xmm3, %%eax\n\t" + "packssdw %%xmm1, %%xmm1\n\t" + "packuswb %%xmm1, %%xmm1\n\t" + "movd %%xmm1, %%eax\n\t" "movnti %%eax, (%2,%3)\n\t" "sub $0x4, %3\n\t" "jnz sse2_delta8_rgba_iter\n\t" @@ -3116,9 +3102,6 @@ __attribute__((noinline,__target__("sse2"))) void sse2_delta8_bgra(const uint8_t "mov $0xff, %%eax\n\t" "movd %%eax, %%xmm0\n\t" "pshufd $0x0, %%xmm0, %%xmm0\n\t" - "mov $0x80000000, %%eax\n\t" - "movd %%eax, %%xmm5\n\t" - "pshufd $0x0, %%xmm5, %%xmm5\n\t" "sub $0x10, %0\n\t" "sub $0x10, %1\n\t" "sub $0x4, %2\n\t" @@ -3148,20 +3131,9 @@ __attribute__((noinline,__target__("sse2"))) void sse2_delta8_bgra(const uint8_t "pand %%xmm0, %%xmm2\n\t" "paddd %%xmm2, %%xmm2\n\t" "paddd %%xmm2, %%xmm1\n\t" - "movdqa %%xmm1, %%xmm3\n\t" - "movdqa %%xmm1, %%xmm2\n\t" - "pand %%xmm0, %%xmm3\n\t" - "pand %%xmm0, %%xmm2\n\t" - "psrldq $0x9, %%xmm2\n\t" - "por %%xmm2, %%xmm3\n\t" - "movdqa %%xmm1, %%xmm2\n\t" - "pand %%xmm0, %%xmm2\n\t" - "psrldq $0x6, %%xmm2\n\t" - "por %%xmm2, %%xmm3\n\t" - "pand %%xmm0, %%xmm1\n\t" - "psrldq $0x3, %%xmm1\n\t" - "por %%xmm1, %%xmm3\n\t" - "movd %%xmm3, %%eax\n\t" + "packssdw %%xmm1, %%xmm1\n\t" + "packuswb %%xmm1, %%xmm1\n\t" + "movd %%xmm1, %%eax\n\t" "movnti %%eax, (%2,%3)\n\t" "sub $0x4, %3\n\t" "jnz sse2_delta8_bgra_iter\n\t" @@ -3185,9 +3157,6 @@ __attribute__((noinline,__target__("sse2"))) void sse2_delta8_argb(const uint8_t "mov $0xff, %%eax\n\t" "movd %%eax, %%xmm0\n\t" "pshufd $0x0, %%xmm0, %%xmm0\n\t" - "mov $0x80000000, %%eax\n\t" - "movd %%eax, %%xmm5\n\t" - "pshufd $0x0, %%xmm5, %%xmm5\n\t" "sub $0x10, %0\n\t" "sub $0x10, %1\n\t" "sub $0x4, %2\n\t" @@ -3218,20 +3187,9 @@ __attribute__((noinline,__target__("sse2"))) void sse2_delta8_argb(const uint8_t "psrld $0x18, %%xmm2\n\t" "pand %%xmm0, %%xmm2\n\t" "paddd %%xmm2, %%xmm1\n\t" - "movdqa %%xmm1, %%xmm3\n\t" - "movdqa %%xmm1, %%xmm2\n\t" - "pand %%xmm0, %%xmm3\n\t" - "pand %%xmm0, %%xmm2\n\t" - "psrldq $0x9, %%xmm2\n\t" - "por %%xmm2, %%xmm3\n\t" - "movdqa %%xmm1, %%xmm2\n\t" - "pand %%xmm0, %%xmm2\n\t" - "psrldq $0x6, %%xmm2\n\t" - "por %%xmm2, %%xmm3\n\t" - "pand %%xmm0, %%xmm1\n\t" - "psrldq $0x3, %%xmm1\n\t" - "por %%xmm1, %%xmm3\n\t" - "movd %%xmm3, %%eax\n\t" + "packssdw %%xmm1, %%xmm1\n\t" + "packuswb %%xmm1, %%xmm1\n\t" + "movd %%xmm1, %%eax\n\t" "movnti %%eax, (%2,%3)\n\t" "sub $0x4, %3\n\t" "jnz sse2_delta8_argb_iter\n\t" @@ -3255,9 +3213,6 @@ __attribute__((noinline,__target__("sse2"))) void sse2_delta8_abgr(const uint8_t "mov $0xff, %%eax\n\t" "movd %%eax, %%xmm0\n\t" "pshufd $0x0, %%xmm0, %%xmm0\n\t" - "mov $0x80000000, %%eax\n\t" - "movd %%eax, %%xmm5\n\t" - "pshufd $0x0, %%xmm5, %%xmm5\n\t" "sub $0x10, %0\n\t" "sub $0x10, %1\n\t" "sub $0x4, %2\n\t" @@ -3288,20 +3243,9 @@ __attribute__((noinline,__target__("sse2"))) void sse2_delta8_abgr(const uint8_t "pand %%xmm0, %%xmm2\n\t" "paddd %%xmm2, %%xmm2\n\t" "paddd %%xmm2, %%xmm1\n\t" - "movdqa %%xmm1, %%xmm3\n\t" - "movdqa %%xmm1, %%xmm2\n\t" - "pand %%xmm0, %%xmm3\n\t" - "pand %%xmm0, %%xmm2\n\t" - "psrldq $0x9, %%xmm2\n\t" - "por %%xmm2, %%xmm3\n\t" - "movdqa %%xmm1, %%xmm2\n\t" - "pand %%xmm0, %%xmm2\n\t" - "psrldq $0x6, %%xmm2\n\t" - "por %%xmm2, %%xmm3\n\t" - "pand %%xmm0, %%xmm1\n\t" - "psrldq $0x3, %%xmm1\n\t" - "por %%xmm1, %%xmm3\n\t" - "movd %%xmm3, %%eax\n\t" + "packssdw %%xmm1, %%xmm1\n\t" + "packuswb %%xmm1, %%xmm1\n\t" + "movd %%xmm1, %%eax\n\t" "movnti %%eax, (%2,%3)\n\t" "sub $0x4, %3\n\t" "jnz sse2_delta8_abgr_iter\n\t" From e413042cdb37c6a1811ea1cc5bb01e6be491986c Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sun, 1 Apr 2012 13:03:18 +0300 Subject: [PATCH 50/56] Fixed a longtime bug in my version that caused distorted analysis images in some setups. --- src/zm_zone.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index 9d8ce354a..0acf7a045 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -217,8 +217,8 @@ bool Zone::CheckAlarms( const Image *delta_image ) bool block; for ( int y = lo_y; y <= hi_y; y++ ) { - lo_x = ranges[y].lo_x; - hi_x = ranges[y].hi_x; + int lo_x = ranges[y].lo_x; + int hi_x = ranges[y].hi_x; pdiff = (uint8_t*)diff_image->Buffer( lo_x, y ); From 8f0ec42ba28312aa75d731b7d2ad5e8742cb60de Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 25 Jan 2012 16:59:56 +0200 Subject: [PATCH 51/56] First work on adding built-in deinterlacing to ZM. --- src/zm_image.cpp | 139 ++++++++++++++++++++++++++++ src/zm_image.h | 3 + src/zm_monitor.cpp | 30 ++++-- src/zm_monitor.h | 3 +- web/skins/classic/views/monitor.php | 9 ++ 5 files changed, 174 insertions(+), 10 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index b6443ef18..3b48e08eb 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -2663,6 +2663,145 @@ void Image::Scale( unsigned int factor ) } +void Image::Deinterlace_Discard() +{ + /* Simple deinterlacing. Copy the even lines into the odd lines */ + + if ( colours == ZM_COLOUR_GRAY8 ) + { + const uint8_t *psrc; + uint8_t *pdest; + for (unsigned int y = 0; y < height; y += 2) + { + psrc = buffer + (y * width); + pdest = buffer + ((y+1) * width); + for (unsigned int x = 0; x < width; x++) { + *pdest++ = *psrc++; + } + } + } + else if ( colours == ZM_COLOUR_RGB24 ) + { + const uint8_t *psrc; + uint8_t *pdest; + for (unsigned int y = 0; y < height; y += 2) + { + psrc = buffer + ((y * width) * 3); + pdest = buffer + (((y+1) * width) * 3); + for (unsigned int x = 0; x < width; x++) { + *pdest++ = *psrc++; + *pdest++ = *psrc++; + *pdest++ = *psrc++; + } + } + } + else if ( colours == ZM_COLOUR_RGB32 ) + { + const Rgb *psrc; + Rgb *pdest; + for (unsigned int y = 0; y < height; y += 2) + { + psrc = (Rgb*)(buffer + ((y * width) << 2)); + pdest = (Rgb*)(buffer + (((y+1) * width) << 2)); + for (unsigned int x = 0; x < width; x++) { + *pdest++ = *psrc++; + } + } + } else { + Error("Deinterlace called with unexpected colours: %d", colours); + } + +} + +void Image::Deinterlace_Linear() +{ + /* Simple deinterlacing. The odd lines are average of the line above and line below */ + + if ( colours == ZM_COLOUR_GRAY8 ) + { + const uint8_t *pbelow, *pabove; + uint8_t *pcurrent; + for (unsigned int y = 1; y < (height-1); y += 2) + { + pabove = buffer + ((y-1) * width); + pbelow = buffer + ((y+1) * width); + pcurrent = buffer + (y * width); + for (unsigned int x = 0; x < width; x++) { + *pcurrent++ = (*pabove++ + *pbelow++) >> 1; + } + } + /* Special case for the last line */ + pcurrent = buffer + ((height-1) * width); + pabove = buffer + ((height-2) * width); + for (unsigned int x = 0; x < width; x++) { + *pcurrent++ = *pabove++; + } + } + else if ( colours == ZM_COLOUR_RGB24 ) + { + const uint8_t *pbelow, *pabove; + uint8_t *pcurrent; + for (unsigned int y = 1; y < (height-1); y += 2) + { + pabove = buffer + (((y-1) * width) * 3); + pbelow = buffer + (((y+1) * width) * 3); + pcurrent = buffer + ((y * width) * 3); + for (unsigned int x = 0; x < width; x++) { + *pcurrent++ = (*pabove++ + *pbelow++) >> 1; + *pcurrent++ = (*pabove++ + *pbelow++) >> 1; + *pcurrent++ = (*pabove++ + *pbelow++) >> 1; + } + } + /* Special case for the last line */ + pcurrent = buffer + (((height-1) * width) * 3); + pabove = buffer + (((height-2) * width) * 3); + for (unsigned int x = 0; x < width; x++) { + *pcurrent++ = *pabove++; + *pcurrent++ = *pabove++; + *pcurrent++ = *pabove++; + } + } + else if ( colours == ZM_COLOUR_RGB32 ) + { + const Rgb *pbelow, *pabove; + Rgb *pcurrent; + for (unsigned int y = 1; y < (height-1); y += 2) + { + pabove = (Rgb*)(buffer + (((y-1) * width) << 2)); + pbelow = (Rgb*)(buffer + (((y+1) * width) << 2)); + pcurrent = (Rgb*)(buffer + ((y * width) << 2)); + for (unsigned int x = 0; x < width; x++) { + *pcurrent++ = (*pabove++ + *pbelow++) >> 1; + } + } + /* Special case for the last line */ + pcurrent = (Rgb*)(buffer + (((height-1) * width) << 2)); + pabove = (Rgb*)(buffer + (((height-2) * width) << 2)); + for (unsigned int x = 0; x < width; x++) { + *pcurrent++ = *pabove++; + } + } else { + Error("Deinterlace called with unexpected colours: %d", colours); + } + +} + +/* +void Image::Deinterlace_4field_linear_weave(const image* next_image, image* dest_image) +{ + if ( !(width == next_image.width && height == next_image.height && colours == next_image.colours && subpixelorder == next_image.subpixelorder) ) + { + Panic( "Attempt to deinterlace different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, next_image.width, next_image.height, next_image.colours, next_image.subpixelorder); + } + + uint8_t *pdest = dest_image->WriteBuffer(width, height, colours, subpixelorder); + + + + + +} +*/ /************************************************* BLEND FUNCTIONS *************************************************/ diff --git a/src/zm_image.h b/src/zm_image.h index c0c0660b6..577371171 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -242,6 +242,9 @@ public: void Rotate( int angle ); void Flip( bool leftright ); void Scale( unsigned int factor ); + void Deinterlace_Discard(); + void Deinterlace_Linear(); + }; #endif // ZM_IMAGE_H diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 798e22b1d..469ba031f 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -244,6 +244,7 @@ Monitor::Monitor( const char *p_linked_monitors, Camera *p_camera, int p_orientation, + unsigned int p_deinterlacing, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, @@ -270,6 +271,7 @@ Monitor::Monitor( width( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Height():p_camera->Width() ), height( (p_orientation==ROTATE_90||p_orientation==ROTATE_270)?p_camera->Width():p_camera->Height() ), orientation( (Orientation)p_orientation ), + deinterlacing( p_deinterlacing ), label_coord( p_label_coord ), image_buffer_count( p_image_buffer_count ), warmup_count( p_warmup_count ), @@ -1769,11 +1771,11 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose static char sql[ZM_SQL_MED_BUFSIZ]; if ( !device[0] ) { - strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Method, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' order by Device, Channel", sizeof(sql) ); + strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' order by Device, Channel", sizeof(sql) ); } else { - snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Method, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' and Device = '%s' order by Channel", device ); + snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' and Device = '%s' order by Channel", device ); } if ( mysql_query( &dbconn, sql ) ) { @@ -1811,6 +1813,7 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose int colours = atoi(dbrow[col]); col++; int palette = atoi(dbrow[col]); col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; + unsigned int deinterlacing = atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; int contrast = atoi(dbrow[col]); col++; int hue = atoi(dbrow[col]); col++; @@ -1870,6 +1873,7 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose linked_monitors, camera, orientation, + deinterlacing, event_prefix, label_format, Coord( label_x, label_y ), @@ -1911,11 +1915,11 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c static char sql[ZM_SQL_MED_BUFSIZ]; if ( !protocol ) { - strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote'", sizeof(sql) ); + strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote'", sizeof(sql) ); } else { - snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote' and Protocol = '%s' and Host = '%s' and Port = '%s' and Path = '%s'", protocol, host, port, path ); + snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote' and Protocol = '%s' and Host = '%s' and Port = '%s' and Path = '%s'", protocol, host, port, path ); } if ( mysql_query( &dbconn, sql ) ) { @@ -1954,6 +1958,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c int colours = atoi(dbrow[col]); col++; /* int palette = atoi(dbrow[col]); */ col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; + unsigned int deinterlacing = atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; int contrast = atoi(dbrow[col]); col++; int hue = atoi(dbrow[col]); col++; @@ -2034,6 +2039,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c linked_monitors, camera, orientation, + deinterlacing, event_prefix.c_str(), label_format.c_str(), Coord( label_x, label_y ), @@ -2074,11 +2080,11 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu static char sql[ZM_SQL_MED_BUFSIZ]; if ( !file[0] ) { - strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File'", sizeof(sql) ); + strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File'", sizeof(sql) ); } else { - snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File' and Path = '%s'", file ); + snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File' and Path = '%s'", file ); } if ( mysql_query( &dbconn, sql ) ) { @@ -2113,6 +2119,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu int colours = atoi(dbrow[col]); col++; /* int palette = atoi(dbrow[col]); */ col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; + unsigned int deinterlacing = atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; int contrast = atoi(dbrow[col]); col++; int hue = atoi(dbrow[col]); col++; @@ -2162,6 +2169,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu linked_monitors, camera, orientation, + deinterlacing, event_prefix, label_format, Coord( label_x, label_y ), @@ -2203,11 +2211,11 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose static char sql[ZM_SQL_MED_BUFSIZ]; if ( !file[0] ) { - strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg'", sizeof(sql) ); + strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg'", sizeof(sql) ); } else { - snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg' and Path = '%s'", file ); + snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg' and Path = '%s'", file ); } if ( mysql_query( &dbconn, sql ) ) { @@ -2242,6 +2250,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose int colours = atoi(dbrow[col]); col++; /* int palette = atoi(dbrow[col]); */ col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; + unsigned int deinterlacing = atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; int contrast = atoi(dbrow[col]); col++; int hue = atoi(dbrow[col]); col++; @@ -2291,6 +2300,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose linked_monitors, camera, orientation, + deinterlacing, event_prefix, label_format, Coord( label_x, label_y ), @@ -2330,7 +2340,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) { static char sql[ZM_SQL_MED_BUFSIZ]; - snprintf( sql, sizeof(sql), "select Id, Name, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = %d", id ); + snprintf( sql, sizeof(sql), "select Id, Name, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = %d", id ); if ( mysql_query( &dbconn, sql ) ) { Error( "Can't run query: %s", mysql_error( &dbconn ) ); @@ -2372,6 +2382,7 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) int colours = atoi(dbrow[col]); col++; int palette = atoi(dbrow[col]); col++; Orientation orientation = (Orientation)atoi(dbrow[col]); col++; + unsigned int deinterlacing = atoi(dbrow[col]); col++; int brightness = atoi(dbrow[col]); col++; int contrast = atoi(dbrow[col]); col++; int hue = atoi(dbrow[col]); col++; @@ -2522,6 +2533,7 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) linked_monitors.c_str(), camera, orientation, + deinterlacing, event_prefix.c_str(), label_format.c_str(), Coord( label_x, label_y ), diff --git a/src/zm_monitor.h b/src/zm_monitor.h index acbe0933b..3f4ff19cc 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -210,6 +210,7 @@ protected: unsigned int width; // Normally the same as the camera, but not if partly rotated unsigned int height; // Normally the same as the camera, but not if partly rotated Orientation orientation; // Whether the image has to be rotated at all + unsigned int deinterlacing; int brightness; // The statically saved brightness of the camera int contrast; // The statically saved contrast of the camera int hue; // The statically saved hue of the camera @@ -276,7 +277,7 @@ protected: MonitorLink **linked_monitors; public: - Monitor( int p_id, const char *p_name, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, Purpose p_purpose, int p_n_zones=0, Zone *p_zones[]=0 ); + Monitor( int p_id, const char *p_name, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, unsigned int p_deinterlacing, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, Purpose p_purpose, int p_n_zones=0, Zone *p_zones[]=0 ); ~Monitor(); void AddZones( int p_n_zones, Zone *p_zones[] ); diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 175868be4..904cc07f6 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -69,6 +69,7 @@ else 'Width' => "320", 'Height' => "240", 'Orientation' => "0", + 'Deinterlacing' => 0, 'LabelFormat' => '%N - %d/%m/%y %H:%M:%S', 'LabelX' => 0, 'LabelY' => 0, @@ -361,6 +362,12 @@ $orientations = array( $SLANG['FlippedVert'] => 'vert' ); +$deinterlaceopts = array( + "Disabled" => 0, + "Discard" => 1, + "Linear" => 2 +); + xhtmlHeaders(__FILE__, $SLANG['Monitor']." - ".validHtmlStr($monitor['Name']) ); ?> @@ -465,6 +472,7 @@ if ( $tab != 'source' ) + () + Date: Mon, 30 Jan 2012 08:00:22 +0200 Subject: [PATCH 52/56] Much more progress! 1) Removed the V4L2_CAPTURE_FIELDS option. 2) V4L2 Interlacing control options added to the new per-monitor deinterlacing option. 3) Fixed the 32bit version of Linear. 4) Added Blend (50%) and Blend (25%). 5) Completed the grayscale version of the Four Field Motion Adaptive deinterlacing algorithm. --- .../lib/ZoneMinder/ConfigData.pm.in | 8 - src/zm_config_defines.h | 288 ++++++++++-------- src/zm_image.cpp | 219 +++++++++++-- src/zm_image.h | 3 + src/zm_local_camera.cpp | 11 +- src/zm_local_camera.h | 4 +- src/zm_monitor.cpp | 68 ++++- src/zm_monitor.h | 1 + web/skins/classic/views/monitor.php | 38 ++- 9 files changed, 464 insertions(+), 176 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index 2e05dc113..55c0ec302 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -737,14 +737,6 @@ our @options = type => $types{boolean}, category => "config", }, - { - name => "ZM_V4L2_CAPTURE_FIELDS", - default => "0", - description => "Control interlacing and field handling in V4L2", - help => "The Video4Linux2 standard allows finer control of interlacing than the previous version. This option allows finer control over how the system handle interlacing in general for V4L2 devices. The possible values are described at http://v4l2spec.bytesex.org/spec/x6386.htm#V4L2-FIELD and the default value of 0 allows the driver to decide for itself. This will often result in interlaced images.~~The most useful other values are 2 (top, or 3 for bottom) which prevent interlacing by only capturing one field (or set of scanlines), or 7 which captures both fields but in separate images. This latter option can increase frame rates but with the possibility that alternate frames are one scanline offset from each other so may appear to move up and down slightly.~~Note that preventing interlacing when capturing large image sizes may not actually increase the information content as often the maximum size of single field, non-interlaced, images may be fairly small and the image is just enlarged in the application.", - type => $types{integer}, - category => "config", - }, { name => "ZM_SIGNAL_CHECK_POINTS", default => "10", diff --git a/src/zm_config_defines.h b/src/zm_config_defines.h index b26a1bb1e..572ee589f 100644 --- a/src/zm_config_defines.h +++ b/src/zm_config_defines.h @@ -79,139 +79,147 @@ #define ZM_WEB_COMPACT_MONTAGE 75 #define ZM_OPT_FAST_DELETE 76 #define ZM_STRICT_VIDEO_CONFIG 77 -#define ZM_V4L2_CAPTURE_FIELDS 78 -#define ZM_SIGNAL_CHECK_POINTS 79 -#define ZM_V4L_MULTI_BUFFER 80 -#define ZM_CAPTURES_PER_FRAME 81 -#define ZM_FILTER_RELOAD_DELAY 82 -#define ZM_FILTER_EXECUTE_INTERVAL 83 -#define ZM_OPT_UPLOAD 84 -#define ZM_UPLOAD_ARCH_FORMAT 85 -#define ZM_UPLOAD_ARCH_COMPRESS 86 -#define ZM_UPLOAD_ARCH_ANALYSE 87 +#define ZM_SIGNAL_CHECK_POINTS 78 +#define ZM_V4L_MULTI_BUFFER 79 +#define ZM_CAPTURES_PER_FRAME 80 +#define ZM_FILTER_RELOAD_DELAY 81 +#define ZM_FILTER_EXECUTE_INTERVAL 82 +#define ZM_OPT_UPLOAD 83 +#define ZM_UPLOAD_ARCH_FORMAT 84 +#define ZM_UPLOAD_ARCH_COMPRESS 85 +#define ZM_UPLOAD_ARCH_ANALYSE 86 +#define ZM_UPLOAD_PROTOCOL 87 #define ZM_UPLOAD_FTP_HOST 88 -#define ZM_UPLOAD_FTP_USER 89 -#define ZM_UPLOAD_FTP_PASS 90 -#define ZM_UPLOAD_FTP_LOC_DIR 91 -#define ZM_UPLOAD_FTP_REM_DIR 92 -#define ZM_UPLOAD_FTP_TIMEOUT 93 -#define ZM_UPLOAD_FTP_PASSIVE 94 -#define ZM_UPLOAD_FTP_DEBUG 95 -#define ZM_OPT_EMAIL 96 -#define ZM_EMAIL_ADDRESS 97 -#define ZM_EMAIL_TEXT 98 -#define ZM_EMAIL_SUBJECT 99 -#define ZM_EMAIL_BODY 100 -#define ZM_OPT_MESSAGE 101 -#define ZM_MESSAGE_ADDRESS 102 -#define ZM_MESSAGE_TEXT 103 -#define ZM_MESSAGE_SUBJECT 104 -#define ZM_MESSAGE_BODY 105 -#define ZM_NEW_MAIL_MODULES 106 -#define ZM_EMAIL_HOST 107 -#define ZM_FROM_EMAIL 108 -#define ZM_URL 109 -#define ZM_MAX_RESTART_DELAY 110 -#define ZM_WATCH_CHECK_INTERVAL 111 -#define ZM_WATCH_MAX_DELAY 112 -#define ZM_RUN_AUDIT 113 -#define ZM_AUDIT_CHECK_INTERVAL 114 -#define ZM_FORCED_ALARM_SCORE 115 -#define ZM_BULK_FRAME_INTERVAL 116 -#define ZM_EVENT_CLOSE_MODE 117 -#define ZM_FORCE_CLOSE_EVENTS 118 -#define ZM_CREATE_ANALYSIS_IMAGES 119 -#define ZM_WEIGHTED_ALARM_CENTRES 120 -#define ZM_EVENT_IMAGE_DIGITS 121 -#define ZM_DEFAULT_ASPECT_RATIO 122 -#define ZM_USER_SELF_EDIT 123 -#define ZM_OPT_FRAME_SERVER 124 -#define ZM_FRAME_SOCKET_SIZE 125 -#define ZM_OPT_CONTROL 126 -#define ZM_OPT_TRIGGERS 127 -#define ZM_CHECK_FOR_UPDATES 128 -#define ZM_UPDATE_CHECK_PROXY 129 -#define ZM_SHM_KEY 130 -#define ZM_WEB_REFRESH_METHOD 131 -#define ZM_WEB_EVENT_SORT_FIELD 132 -#define ZM_WEB_EVENT_SORT_ORDER 133 -#define ZM_WEB_EVENTS_PER_PAGE 134 -#define ZM_WEB_LIST_THUMBS 135 -#define ZM_WEB_LIST_THUMB_WIDTH 136 -#define ZM_WEB_LIST_THUMB_HEIGHT 137 -#define ZM_WEB_USE_OBJECT_TAGS 138 -#define ZM_WEB_H_REFRESH_MAIN 139 -#define ZM_WEB_H_REFRESH_CYCLE 140 -#define ZM_WEB_H_REFRESH_IMAGE 141 -#define ZM_WEB_H_REFRESH_STATUS 142 -#define ZM_WEB_H_REFRESH_EVENTS 143 -#define ZM_WEB_H_CAN_STREAM 144 -#define ZM_WEB_H_STREAM_METHOD 145 -#define ZM_WEB_H_DEFAULT_SCALE 146 -#define ZM_WEB_H_DEFAULT_RATE 147 -#define ZM_WEB_H_VIDEO_BITRATE 148 -#define ZM_WEB_H_VIDEO_MAXFPS 149 -#define ZM_WEB_H_SCALE_THUMBS 150 -#define ZM_WEB_H_EVENTS_VIEW 151 -#define ZM_WEB_H_SHOW_PROGRESS 152 -#define ZM_WEB_H_AJAX_TIMEOUT 153 -#define ZM_WEB_M_REFRESH_MAIN 154 -#define ZM_WEB_M_REFRESH_CYCLE 155 -#define ZM_WEB_M_REFRESH_IMAGE 156 -#define ZM_WEB_M_REFRESH_STATUS 157 -#define ZM_WEB_M_REFRESH_EVENTS 158 -#define ZM_WEB_M_CAN_STREAM 159 -#define ZM_WEB_M_STREAM_METHOD 160 -#define ZM_WEB_M_DEFAULT_SCALE 161 -#define ZM_WEB_M_DEFAULT_RATE 162 -#define ZM_WEB_M_VIDEO_BITRATE 163 -#define ZM_WEB_M_VIDEO_MAXFPS 164 -#define ZM_WEB_M_SCALE_THUMBS 165 -#define ZM_WEB_M_EVENTS_VIEW 166 -#define ZM_WEB_M_SHOW_PROGRESS 167 -#define ZM_WEB_M_AJAX_TIMEOUT 168 -#define ZM_WEB_L_REFRESH_MAIN 169 -#define ZM_WEB_L_REFRESH_CYCLE 170 -#define ZM_WEB_L_REFRESH_IMAGE 171 -#define ZM_WEB_L_REFRESH_STATUS 172 -#define ZM_WEB_L_REFRESH_EVENTS 173 -#define ZM_WEB_L_CAN_STREAM 174 -#define ZM_WEB_L_STREAM_METHOD 175 -#define ZM_WEB_L_DEFAULT_SCALE 176 -#define ZM_WEB_L_DEFAULT_RATE 177 -#define ZM_WEB_L_VIDEO_BITRATE 178 -#define ZM_WEB_L_VIDEO_MAXFPS 179 -#define ZM_WEB_L_SCALE_THUMBS 180 -#define ZM_WEB_L_EVENTS_VIEW 181 -#define ZM_WEB_L_SHOW_PROGRESS 182 -#define ZM_WEB_L_AJAX_TIMEOUT 183 -#define ZM_WEB_P_CAN_STREAM 184 -#define ZM_WEB_P_STREAM_METHOD 185 -#define ZM_WEB_P_DEFAULT_SCALE 186 -#define ZM_WEB_P_DEFAULT_RATE 187 -#define ZM_WEB_P_VIDEO_BITRATE 188 -#define ZM_WEB_P_VIDEO_MAXFPS 189 -#define ZM_WEB_P_SCALE_THUMBS 190 -#define ZM_WEB_P_AJAX_TIMEOUT 191 -#define ZM_DYN_LAST_VERSION 192 -#define ZM_DYN_CURR_VERSION 193 -#define ZM_DYN_DB_VERSION 194 -#define ZM_DYN_LAST_CHECK 195 -#define ZM_DYN_NEXT_REMINDER 196 -#define ZM_DYN_DONATE_REMINDER_TIME 197 -#define ZM_DYN_SHOW_DONATE_REMINDER 198 -#define ZM_EYEZM_DEBUG 199 -#define ZM_EYEZM_LOG_TO_FILE 200 -#define ZM_EYEZM_LOG_FILE 201 -#define ZM_EYEZM_EVENT_VCODEC 202 -#define ZM_EYEZM_FEED_VCODEC 203 -#define ZM_EYEZM_H264_DEFAULT_BR 204 -#define ZM_EYEZM_H264_DEFAULT_EVBR 205 -#define ZM_EYEZM_H264_TIMEOUT 206 -#define ZM_EYEZM_SEG_DURATION 207 +#define ZM_UPLOAD_HOST 89 +#define ZM_UPLOAD_PORT 90 +#define ZM_UPLOAD_FTP_USER 91 +#define ZM_UPLOAD_USER 92 +#define ZM_UPLOAD_FTP_PASS 93 +#define ZM_UPLOAD_PASS 94 +#define ZM_UPLOAD_FTP_LOC_DIR 95 +#define ZM_UPLOAD_LOC_DIR 96 +#define ZM_UPLOAD_FTP_REM_DIR 97 +#define ZM_UPLOAD_REM_DIR 98 +#define ZM_UPLOAD_FTP_TIMEOUT 99 +#define ZM_UPLOAD_TIMEOUT 100 +#define ZM_UPLOAD_FTP_PASSIVE 101 +#define ZM_UPLOAD_FTP_DEBUG 102 +#define ZM_UPLOAD_DEBUG 103 +#define ZM_OPT_EMAIL 104 +#define ZM_EMAIL_ADDRESS 105 +#define ZM_EMAIL_TEXT 106 +#define ZM_EMAIL_SUBJECT 107 +#define ZM_EMAIL_BODY 108 +#define ZM_OPT_MESSAGE 109 +#define ZM_MESSAGE_ADDRESS 110 +#define ZM_MESSAGE_TEXT 111 +#define ZM_MESSAGE_SUBJECT 112 +#define ZM_MESSAGE_BODY 113 +#define ZM_NEW_MAIL_MODULES 114 +#define ZM_EMAIL_HOST 115 +#define ZM_FROM_EMAIL 116 +#define ZM_URL 117 +#define ZM_MAX_RESTART_DELAY 118 +#define ZM_WATCH_CHECK_INTERVAL 119 +#define ZM_WATCH_MAX_DELAY 120 +#define ZM_RUN_AUDIT 121 +#define ZM_AUDIT_CHECK_INTERVAL 122 +#define ZM_FORCED_ALARM_SCORE 123 +#define ZM_BULK_FRAME_INTERVAL 124 +#define ZM_EVENT_CLOSE_MODE 125 +#define ZM_FORCE_CLOSE_EVENTS 126 +#define ZM_CREATE_ANALYSIS_IMAGES 127 +#define ZM_WEIGHTED_ALARM_CENTRES 128 +#define ZM_EVENT_IMAGE_DIGITS 129 +#define ZM_DEFAULT_ASPECT_RATIO 130 +#define ZM_USER_SELF_EDIT 131 +#define ZM_OPT_FRAME_SERVER 132 +#define ZM_FRAME_SOCKET_SIZE 133 +#define ZM_OPT_CONTROL 134 +#define ZM_OPT_TRIGGERS 135 +#define ZM_CHECK_FOR_UPDATES 136 +#define ZM_UPDATE_CHECK_PROXY 137 +#define ZM_SHM_KEY 138 +#define ZM_WEB_REFRESH_METHOD 139 +#define ZM_WEB_EVENT_SORT_FIELD 140 +#define ZM_WEB_EVENT_SORT_ORDER 141 +#define ZM_WEB_EVENTS_PER_PAGE 142 +#define ZM_WEB_LIST_THUMBS 143 +#define ZM_WEB_LIST_THUMB_WIDTH 144 +#define ZM_WEB_LIST_THUMB_HEIGHT 145 +#define ZM_WEB_USE_OBJECT_TAGS 146 +#define ZM_WEB_H_REFRESH_MAIN 147 +#define ZM_WEB_H_REFRESH_CYCLE 148 +#define ZM_WEB_H_REFRESH_IMAGE 149 +#define ZM_WEB_H_REFRESH_STATUS 150 +#define ZM_WEB_H_REFRESH_EVENTS 151 +#define ZM_WEB_H_CAN_STREAM 152 +#define ZM_WEB_H_STREAM_METHOD 153 +#define ZM_WEB_H_DEFAULT_SCALE 154 +#define ZM_WEB_H_DEFAULT_RATE 155 +#define ZM_WEB_H_VIDEO_BITRATE 156 +#define ZM_WEB_H_VIDEO_MAXFPS 157 +#define ZM_WEB_H_SCALE_THUMBS 158 +#define ZM_WEB_H_EVENTS_VIEW 159 +#define ZM_WEB_H_SHOW_PROGRESS 160 +#define ZM_WEB_H_AJAX_TIMEOUT 161 +#define ZM_WEB_M_REFRESH_MAIN 162 +#define ZM_WEB_M_REFRESH_CYCLE 163 +#define ZM_WEB_M_REFRESH_IMAGE 164 +#define ZM_WEB_M_REFRESH_STATUS 165 +#define ZM_WEB_M_REFRESH_EVENTS 166 +#define ZM_WEB_M_CAN_STREAM 167 +#define ZM_WEB_M_STREAM_METHOD 168 +#define ZM_WEB_M_DEFAULT_SCALE 169 +#define ZM_WEB_M_DEFAULT_RATE 170 +#define ZM_WEB_M_VIDEO_BITRATE 171 +#define ZM_WEB_M_VIDEO_MAXFPS 172 +#define ZM_WEB_M_SCALE_THUMBS 173 +#define ZM_WEB_M_EVENTS_VIEW 174 +#define ZM_WEB_M_SHOW_PROGRESS 175 +#define ZM_WEB_M_AJAX_TIMEOUT 176 +#define ZM_WEB_L_REFRESH_MAIN 177 +#define ZM_WEB_L_REFRESH_CYCLE 178 +#define ZM_WEB_L_REFRESH_IMAGE 179 +#define ZM_WEB_L_REFRESH_STATUS 180 +#define ZM_WEB_L_REFRESH_EVENTS 181 +#define ZM_WEB_L_CAN_STREAM 182 +#define ZM_WEB_L_STREAM_METHOD 183 +#define ZM_WEB_L_DEFAULT_SCALE 184 +#define ZM_WEB_L_DEFAULT_RATE 185 +#define ZM_WEB_L_VIDEO_BITRATE 186 +#define ZM_WEB_L_VIDEO_MAXFPS 187 +#define ZM_WEB_L_SCALE_THUMBS 188 +#define ZM_WEB_L_EVENTS_VIEW 189 +#define ZM_WEB_L_SHOW_PROGRESS 190 +#define ZM_WEB_L_AJAX_TIMEOUT 191 +#define ZM_WEB_P_CAN_STREAM 192 +#define ZM_WEB_P_STREAM_METHOD 193 +#define ZM_WEB_P_DEFAULT_SCALE 194 +#define ZM_WEB_P_DEFAULT_RATE 195 +#define ZM_WEB_P_VIDEO_BITRATE 196 +#define ZM_WEB_P_VIDEO_MAXFPS 197 +#define ZM_WEB_P_SCALE_THUMBS 198 +#define ZM_WEB_P_AJAX_TIMEOUT 199 +#define ZM_DYN_LAST_VERSION 200 +#define ZM_DYN_CURR_VERSION 201 +#define ZM_DYN_DB_VERSION 202 +#define ZM_DYN_LAST_CHECK 203 +#define ZM_DYN_NEXT_REMINDER 204 +#define ZM_DYN_DONATE_REMINDER_TIME 205 +#define ZM_DYN_SHOW_DONATE_REMINDER 206 +#define ZM_EYEZM_DEBUG 207 +#define ZM_EYEZM_LOG_TO_FILE 208 +#define ZM_EYEZM_LOG_FILE 209 +#define ZM_EYEZM_EVENT_VCODEC 210 +#define ZM_EYEZM_FEED_VCODEC 211 +#define ZM_EYEZM_H264_DEFAULT_BR 212 +#define ZM_EYEZM_H264_DEFAULT_EVBR 213 +#define ZM_EYEZM_H264_TIMEOUT 214 +#define ZM_EYEZM_SEG_DURATION 215 -#define ZM_MAX_CFG_ID 207 +#define ZM_MAX_CFG_ID 215 #define ZM_CFG_DECLARE_LIST \ const char *lang_default;\ @@ -292,7 +300,6 @@ bool web_compact_montage;\ bool opt_fast_delete;\ bool strict_video_config;\ - int v4l2_capture_fields;\ int signal_check_points;\ bool v4l_multi_buffer;\ int captures_per_frame;\ @@ -302,14 +309,23 @@ const char *upload_arch_format;\ bool upload_arch_compress;\ bool upload_arch_analyse;\ + const char *upload_protocol;\ const char *upload_ftp_host;\ + const char *upload_host;\ + int upload_port;\ const char *upload_ftp_user;\ + const char *upload_user;\ const char *upload_ftp_pass;\ + const char *upload_pass;\ const char *upload_ftp_loc_dir;\ + const char *upload_loc_dir;\ const char *upload_ftp_rem_dir;\ + const char *upload_rem_dir;\ int upload_ftp_timeout;\ + int upload_timeout;\ bool upload_ftp_passive;\ bool upload_ftp_debug;\ + bool upload_debug;\ bool opt_email;\ const char *email_address;\ const char *email_text;\ @@ -503,7 +519,6 @@ web_compact_montage = (bool)config.Item( ZM_WEB_COMPACT_MONTAGE );\ opt_fast_delete = (bool)config.Item( ZM_OPT_FAST_DELETE );\ strict_video_config = (bool)config.Item( ZM_STRICT_VIDEO_CONFIG );\ - v4l2_capture_fields = (int)config.Item( ZM_V4L2_CAPTURE_FIELDS );\ signal_check_points = (int)config.Item( ZM_SIGNAL_CHECK_POINTS );\ v4l_multi_buffer = (bool)config.Item( ZM_V4L_MULTI_BUFFER );\ captures_per_frame = (int)config.Item( ZM_CAPTURES_PER_FRAME );\ @@ -513,14 +528,23 @@ upload_arch_format = (const char *)config.Item( ZM_UPLOAD_ARCH_FORMAT );\ upload_arch_compress = (bool)config.Item( ZM_UPLOAD_ARCH_COMPRESS );\ upload_arch_analyse = (bool)config.Item( ZM_UPLOAD_ARCH_ANALYSE );\ + upload_protocol = (const char *)config.Item( ZM_UPLOAD_PROTOCOL );\ upload_ftp_host = (const char *)config.Item( ZM_UPLOAD_FTP_HOST );\ + upload_host = (const char *)config.Item( ZM_UPLOAD_HOST );\ + upload_port = (int)config.Item( ZM_UPLOAD_PORT );\ upload_ftp_user = (const char *)config.Item( ZM_UPLOAD_FTP_USER );\ + upload_user = (const char *)config.Item( ZM_UPLOAD_USER );\ upload_ftp_pass = (const char *)config.Item( ZM_UPLOAD_FTP_PASS );\ + upload_pass = (const char *)config.Item( ZM_UPLOAD_PASS );\ upload_ftp_loc_dir = (const char *)config.Item( ZM_UPLOAD_FTP_LOC_DIR );\ + upload_loc_dir = (const char *)config.Item( ZM_UPLOAD_LOC_DIR );\ upload_ftp_rem_dir = (const char *)config.Item( ZM_UPLOAD_FTP_REM_DIR );\ + upload_rem_dir = (const char *)config.Item( ZM_UPLOAD_REM_DIR );\ upload_ftp_timeout = (int)config.Item( ZM_UPLOAD_FTP_TIMEOUT );\ + upload_timeout = (int)config.Item( ZM_UPLOAD_TIMEOUT );\ upload_ftp_passive = (bool)config.Item( ZM_UPLOAD_FTP_PASSIVE );\ upload_ftp_debug = (bool)config.Item( ZM_UPLOAD_FTP_DEBUG );\ + upload_debug = (bool)config.Item( ZM_UPLOAD_DEBUG );\ opt_email = (bool)config.Item( ZM_OPT_EMAIL );\ email_address = (const char *)config.Item( ZM_EMAIL_ADDRESS );\ email_text = (const char *)config.Item( ZM_EMAIL_TEXT );\ diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 3b48e08eb..3df234a78 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -2717,10 +2717,11 @@ void Image::Deinterlace_Linear() { /* Simple deinterlacing. The odd lines are average of the line above and line below */ + const uint8_t *pbelow, *pabove; + uint8_t *pcurrent; + if ( colours == ZM_COLOUR_GRAY8 ) { - const uint8_t *pbelow, *pabove; - uint8_t *pcurrent; for (unsigned int y = 1; y < (height-1); y += 2) { pabove = buffer + ((y-1) * width); @@ -2739,8 +2740,6 @@ void Image::Deinterlace_Linear() } else if ( colours == ZM_COLOUR_RGB24 ) { - const uint8_t *pbelow, *pabove; - uint8_t *pcurrent; for (unsigned int y = 1; y < (height-1); y += 2) { pabove = buffer + (((y-1) * width) * 3); @@ -2763,22 +2762,26 @@ void Image::Deinterlace_Linear() } else if ( colours == ZM_COLOUR_RGB32 ) { - const Rgb *pbelow, *pabove; - Rgb *pcurrent; for (unsigned int y = 1; y < (height-1); y += 2) { - pabove = (Rgb*)(buffer + (((y-1) * width) << 2)); - pbelow = (Rgb*)(buffer + (((y+1) * width) << 2)); - pcurrent = (Rgb*)(buffer + ((y * width) << 2)); + pabove = buffer + (((y-1) * width) << 2); + pbelow = buffer + (((y+1) * width) << 2); + pcurrent = buffer + ((y * width) << 2); for (unsigned int x = 0; x < width; x++) { *pcurrent++ = (*pabove++ + *pbelow++) >> 1; + *pcurrent++ = (*pabove++ + *pbelow++) >> 1; + *pcurrent++ = (*pabove++ + *pbelow++) >> 1; + *pcurrent++ = (*pabove++ + *pbelow++) >> 1; } } /* Special case for the last line */ - pcurrent = (Rgb*)(buffer + (((height-1) * width) << 2)); - pabove = (Rgb*)(buffer + (((height-2) * width) << 2)); + pcurrent = buffer + (((height-1) * width) << 2); + pabove = buffer + (((height-2) * width) << 2); for (unsigned int x = 0; x < width; x++) { *pcurrent++ = *pabove++; + *pcurrent++ = *pabove++; + *pcurrent++ = *pabove++; + *pcurrent++ = *pabove++; } } else { Error("Deinterlace called with unexpected colours: %d", colours); @@ -2786,22 +2789,202 @@ void Image::Deinterlace_Linear() } -/* -void Image::Deinterlace_4field_linear_weave(const image* next_image, image* dest_image) +void Image::Deinterlace_Blend() { - if ( !(width == next_image.width && height == next_image.height && colours == next_image.colours && subpixelorder == next_image.subpixelorder) ) + /* Simple deinterlacing. Blend the fields together. 50% blend */ + + uint8_t *pabove, *pcurrent; + + if ( colours == ZM_COLOUR_GRAY8 ) { - Panic( "Attempt to deinterlace different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, next_image.width, next_image.height, next_image.colours, next_image.subpixelorder); + for (unsigned int y = 1; y < height; y += 2) + { + pabove = buffer + ((y-1) * width); + pcurrent = buffer + (y * width); + for (unsigned int x = 0; x < width; x++) { + *pabove = (*pabove + *pcurrent) >> 1; + *pcurrent++ = *pabove++; + } + } + } + else if ( colours == ZM_COLOUR_RGB24 ) + { + for (unsigned int y = 1; y < height; y += 2) + { + pabove = buffer + (((y-1) * width) * 3); + pcurrent = buffer + ((y * width) * 3); + for (unsigned int x = 0; x < width; x++) { + *pabove = (*pabove + *pcurrent) >> 1; + *pcurrent++ = *pabove++; + *pabove = (*pabove + *pcurrent) >> 1; + *pcurrent++ = *pabove++; + *pabove = (*pabove + *pcurrent) >> 1; + *pcurrent++ = *pabove++; + } + } + } + else if ( colours == ZM_COLOUR_RGB32 ) + { + for (unsigned int y = 1; y < height; y += 2) + { + pabove = buffer + (((y-1) * width) << 2); + pcurrent = buffer + ((y * width) << 2); + for (unsigned int x = 0; x < width; x++) { + *pabove = (*pabove + *pcurrent) >> 1; + *pcurrent++ = *pabove++; + *pabove = (*pabove + *pcurrent) >> 1; + *pcurrent++ = *pabove++; + *pabove = (*pabove + *pcurrent) >> 1; + *pcurrent++ = *pabove++; + *pabove = (*pabove + *pcurrent) >> 1; + *pcurrent++ = *pabove++; + } + } + } else { + Error("Deinterlace called with unexpected colours: %d", colours); } - uint8_t *pdest = dest_image->WriteBuffer(width, height, colours, subpixelorder); - +} + +void Image::Deinterlace_Blend_CustomRatio(int divider) +{ + /* Simple deinterlacing. Blend the fields together at a custom ratio. */ + /* 1 = 50% blending */ + /* 2 = 25% blending */ + /* 3 = 12.% blending */ + /* 4 = 6.25% blending */ + uint8_t *pabove, *pcurrent; + uint8_t subpix1, subpix2; + if ( divider < 1 || divider > 4 ) { + Error("Deinterlace called with invalid blend ratio"); + } + if ( colours == ZM_COLOUR_GRAY8 ) + { + for (unsigned int y = 1; y < height; y += 2) + { + pabove = buffer + ((y-1) * width); + pcurrent = buffer + (y * width); + for (unsigned int x = 0; x < width; x++) { + subpix1 = ((*pabove - *pcurrent)>>divider) + *pcurrent; + subpix2 = ((*pcurrent - *pabove)>>divider) + *pabove; + *pcurrent++ = subpix1; + *pabove++ = subpix2; + } + } + } + else if ( colours == ZM_COLOUR_RGB24 ) + { + for (unsigned int y = 1; y < height; y += 2) + { + pabove = buffer + (((y-1) * width) * 3); + pcurrent = buffer + ((y * width) * 3); + for (unsigned int x = 0; x < width; x++) { + subpix1 = ((*pabove - *pcurrent)>>divider) + *pcurrent; + subpix2 = ((*pcurrent - *pabove)>>divider) + *pabove; + *pcurrent++ = subpix1; + *pabove++ = subpix2; + subpix1 = ((*pabove - *pcurrent)>>divider) + *pcurrent; + subpix2 = ((*pcurrent - *pabove)>>divider) + *pabove; + *pcurrent++ = subpix1; + *pabove++ = subpix2; + subpix1 = ((*pabove - *pcurrent)>>divider) + *pcurrent; + subpix2 = ((*pcurrent - *pabove)>>divider) + *pabove; + *pcurrent++ = subpix1; + *pabove++ = subpix2; + } + } + } + else if ( colours == ZM_COLOUR_RGB32 ) + { + for (unsigned int y = 1; y < height; y += 2) + { + pabove = buffer + (((y-1) * width) << 2); + pcurrent = buffer + ((y * width) << 2); + for (unsigned int x = 0; x < width; x++) { + subpix1 = ((*pabove - *pcurrent)>>divider) + *pcurrent; + subpix2 = ((*pcurrent - *pabove)>>divider) + *pabove; + *pcurrent++ = subpix1; + *pabove++ = subpix2; + subpix1 = ((*pabove - *pcurrent)>>divider) + *pcurrent; + subpix2 = ((*pcurrent - *pabove)>>divider) + *pabove; + *pcurrent++ = subpix1; + *pabove++ = subpix2; + subpix1 = ((*pabove - *pcurrent)>>divider) + *pcurrent; + subpix2 = ((*pcurrent - *pabove)>>divider) + *pabove; + *pcurrent++ = subpix1; + *pabove++ = subpix2; + subpix1 = ((*pabove - *pcurrent)>>divider) + *pcurrent; + subpix2 = ((*pcurrent - *pabove)>>divider) + *pabove; + *pcurrent++ = subpix1; + *pabove++ = subpix2; + } + } + } else { + Error("Deinterlace called with unexpected colours: %d", colours); + } } -*/ + + +void Image::Deinterlace_4Field(const Image* next_image, unsigned int threshold) +{ + if ( !(width == next_image->width && height == next_image->height && colours == next_image->colours && subpixelorder == next_image->subpixelorder) ) + { + Panic( "Attempt to deinterlace different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, next_image->width, next_image->height, next_image->colours, next_image->subpixelorder); + } + + uint8_t *delta_buffer = AllocBuffer(width * (height>>1)); + uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow, *pdelta; + + if ( colours == ZM_COLOUR_GRAY8 ) + { + /* Motion detection */ + for (unsigned int y = 1; y < height; y += 2) { + pcurrent = buffer + ((y * width)); + pncurrent = next_image->buffer + ((y * width)); + pabove = buffer + (((y-1) * width)); + pnabove = next_image->buffer + (((y-1) * width)); + pdelta = delta_buffer + (((y>>1) * width)); + for (unsigned int x = 0; x < width; x++) { + *pdelta = abs(*pnabove++ - *pabove++); + *pdelta |= abs(*pncurrent++ - *pcurrent++); + pdelta++; + } + } + + /* Check if pixels meet threshold */ + for (unsigned int y = 1; y < (height-1); y += 2) { + pcurrent = buffer + ((y * width)); + pabove = buffer + (((y-1) * width)); + pbelow = buffer + (((y+1) * width)); + pdelta = delta_buffer + (((y>>1) * width)); + for (unsigned int x = 0; x < width; x++) { + if(*pdelta++ >= threshold) { + pcurrent[x] = (pabove[x] + pbelow[x]) >> 1; + } + } + } + /* Special case for the last line */ + pcurrent = buffer + ((height-1) * width); + pabove = buffer + ((height-2) * width); + pdelta = delta_buffer + ((((height>>1)-1) * width)); + for (unsigned int x = 0; x < width; x++) { + if(*pdelta++ >= threshold) { + pcurrent[x] = pabove[x]; + } + } + } else { + Error("Unimplemented yet"); + } + + /* Free the delta buffer */ + DumpBuffer(delta_buffer, ZM_BUFTYPE_ZM); + +} + /************************************************* BLEND FUNCTIONS *************************************************/ diff --git a/src/zm_image.h b/src/zm_image.h index 577371171..b01fb333a 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -244,6 +244,9 @@ public: void Scale( unsigned int factor ); void Deinterlace_Discard(); void Deinterlace_Linear(); + void Deinterlace_Blend(); + void Deinterlace_Blend_CustomRatio(int divider); + void Deinterlace_4Field(const Image* next_image, unsigned int threshold); }; diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 68475c362..0fc9ddf1b 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -281,13 +281,14 @@ AVFrame **LocalCamera::capturePictures = 0; LocalCamera *LocalCamera::last_camera = NULL; -LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, int p_standard, const std::string &p_method, int p_width, int p_height, int p_colours, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ) : +LocalCamera::LocalCamera( int p_id, const std::string &p_device, int p_channel, int p_standard, const std::string &p_method, int p_width, int p_height, int p_colours, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, unsigned int p_extras) : Camera( p_id, LOCAL_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture ), device( p_device ), channel( p_channel ), standard( p_standard ), palette( p_palette ), - channel_index( 0 ) + channel_index( 0 ), + extras ( p_extras ) { // If we are the first, or only, input on this device then // do the initial opening etc @@ -706,13 +707,13 @@ void LocalCamera::Initialise() v4l2_data.fmt.fmt.pix.height = height; v4l2_data.fmt.fmt.pix.pixelformat = palette; - if ( config.v4l2_capture_fields ) + if ( (extras & 0xff) != 0 ) { - v4l2_data.fmt.fmt.pix.field = (v4l2_field)config.v4l2_capture_fields; + v4l2_data.fmt.fmt.pix.field = (v4l2_field)(extras & 0xff); if ( vidioctl( vid_fd, VIDIOC_S_FMT, &v4l2_data.fmt ) < 0 ) { - Warning( "Failed to set V4L2 field to %d, falling back to auto", config.v4l2_capture_fields ); + Warning( "Failed to set V4L2 field to %d, falling back to auto", (extras & 0xff) ); v4l2_data.fmt.fmt.pix.field = V4L2_FIELD_ANY; if ( vidioctl( vid_fd, VIDIOC_S_FMT, &v4l2_data.fmt ) < 0 ) { Fatal( "Failed to set video format: %s", strerror(errno) ); diff --git a/src/zm_local_camera.h b/src/zm_local_camera.h index dab651d80..05f06fe44 100644 --- a/src/zm_local_camera.h +++ b/src/zm_local_camera.h @@ -79,6 +79,7 @@ protected: bool device_prime; bool channel_prime; int channel_index; + unsigned int extras; unsigned int conversion_type; /* 0 = no conversion needed, 1 = use libswscale, 2 = zm internal conversion, 3 = jpeg decoding */ convert_fptr_t conversion_fptr; /* Pointer to conversion function used */ @@ -111,7 +112,7 @@ protected: static LocalCamera *last_camera; public: - LocalCamera( int p_id, const std::string &device, int p_channel, int p_format, const std::string &p_method, int p_width, int p_height, int p_colours, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture ); + LocalCamera( int p_id, const std::string &device, int p_channel, int p_format, const std::string &p_method, int p_width, int p_height, int p_colours, int p_palette, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, unsigned int p_extras = 0); ~LocalCamera(); void Initialise(); @@ -122,6 +123,7 @@ public: int Channel() const { return( channel ); } int Standard() const { return( standard ); } int Palette() const { return( palette ); } + int Extras() const { return( extras ); } int Brightness( int p_brightness=-1 ); int Hue( int p_hue=-1 ); diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 469ba031f..6ec4c53c5 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -458,6 +458,13 @@ Monitor::Monitor( image_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder(), &(shared_images[i*camera->ImageSize()]) ); image_buffer[i].image->HoldBuffer(true); /* Don't release the internal buffer or replace it with another */ } + if ( (deinterlacing & 0xff) == 4) + { + /* Four field motion adaptive deinterlacing in use */ + /* Allocate a buffer for the next image */ + next_buffer.image = new Image( width, height, camera->Colours(), camera->SubpixelOrder()); + next_buffer.timestamp = new struct timeval; + } if ( !n_zones ) { n_zones = 1; @@ -1848,6 +1855,8 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); + int extras = (deinterlacing>>24)&0xff; + Camera *camera = new LocalCamera( id, device, @@ -1862,7 +1871,8 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose contrast, hue, colour, - purpose==CAPTURE + purpose==CAPTURE, + extras ); monitors[i] = new Monitor( @@ -2416,6 +2426,8 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width); int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height); + int extras = (deinterlacing>>24)&0xff; + Camera *camera = 0; if ( type == "Local" ) { @@ -2434,7 +2446,8 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) contrast, hue, colour, - purpose==CAPTURE + purpose==CAPTURE, + extras ); #else // ZM_HAS_V4L Fatal( "You must have video4linux libraries and headers installed to use local analog or USB cameras for monitor %d", id ); @@ -2576,11 +2589,30 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose ) int Monitor::Capture() { - int index = image_count%image_buffer_count; - Image* capture_image = image_buffer[index].image; - - /* Capture directly into image buffer, avoiding the need to memcpy() */ - int captureResult = camera->Capture(*capture_image); + static int FirstCapture = 1; + int captureResult; + + int index = image_count%image_buffer_count; + Image* capture_image = image_buffer[index].image; + + if ( (deinterlacing & 0xff) == 4) { + if ( FirstCapture != 1 ) { + /* Copy the next image into the shared memory */ + capture_image->CopyBuffer(*(next_buffer.image)); + } + + /* Capture a new next image */ + captureResult = camera->Capture(*(next_buffer.image)); + + if ( FirstCapture ) { + FirstCapture = 0; + return 0; + } + + } else { + /* Capture directly into image buffer, avoiding the need to memcpy() */ + captureResult = camera->Capture(*capture_image); + } if ( captureResult != 0 ) { @@ -2588,8 +2620,11 @@ int Monitor::Capture() // Fake a signal loss image capture_image->Fill( signal_check_colour ); captureResult = 0; + } else { + captureResult = 1; } - if ( captureResult == 0 ) + + if ( captureResult == 1 ) { if ( orientation != ROTATE_0 ) { @@ -2615,6 +2650,22 @@ int Monitor::Capture() } } } + + /* Deinterlacing */ + if ( (deinterlacing & 0xff) == 1 ) { + capture_image->Deinterlace_Discard(); + } else if ( (deinterlacing & 0xff) == 2 ) { + capture_image->Deinterlace_Linear(); + } else if ( (deinterlacing & 0xff) == 3 ) { + capture_image->Deinterlace_Blend(); + } else if ( (deinterlacing & 0xff) == 4 ) { + capture_image->Deinterlace_4Field( next_buffer.image, (deinterlacing>>8)&0xff ); + } else if ( (deinterlacing & 0xff) == 5 ) { + capture_image->Deinterlace_Blend_CustomRatio( (deinterlacing>>8)&0xff ); + } + + } + if ( true ) { if ( capture_image->Size() != camera->ImageSize() ) { @@ -2622,7 +2673,6 @@ int Monitor::Capture() return( -1 ); } - if ( (index == shared_data->last_read_index) && (function > MONITOR) ) { Warning( "Buffer overrun at index %d, image %d, slow down capture, speed up analysis or increase ring buffer size", index, image_count ); diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 3f4ff19cc..cbc5d75ff 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -265,6 +265,7 @@ protected: TriggerData *trigger_data; Snapshot *image_buffer; + Snapshot next_buffer; /* Used by four field deinterlacing */ Camera *camera; diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 904cc07f6..0e0c21949 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -363,9 +363,30 @@ $orientations = array( ); $deinterlaceopts = array( - "Disabled" => 0, - "Discard" => 1, - "Linear" => 2 + "Disabled" => 0x00000000, + "Four field motion adaptive - Soft" => 0x00003204, /* 50 change */ + "Four field motion adaptive - Medium" => 0x00001E04, /* 30 change */ + "Four field motion adaptive - Hard" => 0x00000A04, /* 10 change */ + "Discard" => 0x00000001, + "Linear" => 0x00000002, + "Blend" => 0x00000003, + "Blend (25%)" => 0x00000205 +); + +$deinterlaceopts_v4l2 = array( + "Disabled" => 0x00000000, + "Four field motion adaptive - Soft" => 0x00003204, /* 50 change */ + "Four field motion adaptive - Medium" => 0x00001E04, /* 30 change */ + "Four field motion adaptive - Hard" => 0x00000A04, /* 10 change */ + "Discard" => 0x00000001, + "Linear" => 0x00000002, + "Blend" => 0x00000003, + "Blend (25%)" => 0x00000205, + "V4L2: Top field only" => 0x02000000, + "V4L2: Bottom field only" => 0x03000000, + "V4L2: Alternate fields" => 0x07000000, + "V4L2: Progressive" => 0x01000000, + "V4L2: Interlaced" => 0x04000000, ); xhtmlHeaders(__FILE__, $SLANG['Monitor']." - ".validHtmlStr($monitor['Name']) ); @@ -671,7 +692,18 @@ switch ( $tab ) () + + + + Date: Thu, 9 Feb 2012 12:33:54 +0200 Subject: [PATCH 53/56] Some more progress on the deinterlacing code. --- src/zm_image.cpp | 220 ++++++++++++++++++++++++++-- src/zm_monitor.cpp | 5 + web/skins/classic/views/monitor.php | 18 ++- 3 files changed, 225 insertions(+), 18 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 3df234a78..a16efa416 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -2943,11 +2943,11 @@ void Image::Deinterlace_4Field(const Image* next_image, unsigned int threshold) { /* Motion detection */ for (unsigned int y = 1; y < height; y += 2) { - pcurrent = buffer + ((y * width)); - pncurrent = next_image->buffer + ((y * width)); - pabove = buffer + (((y-1) * width)); - pnabove = next_image->buffer + (((y-1) * width)); - pdelta = delta_buffer + (((y>>1) * width)); + pcurrent = buffer + (y * width); + pncurrent = next_image->buffer + (y * width); + pabove = buffer + ((y-1) * width); + pnabove = next_image->buffer + ((y-1) * width); + pdelta = delta_buffer + ((y>>1) * width); for (unsigned int x = 0; x < width; x++) { *pdelta = abs(*pnabove++ - *pabove++); *pdelta |= abs(*pncurrent++ - *pcurrent++); @@ -2957,10 +2957,10 @@ void Image::Deinterlace_4Field(const Image* next_image, unsigned int threshold) /* Check if pixels meet threshold */ for (unsigned int y = 1; y < (height-1); y += 2) { - pcurrent = buffer + ((y * width)); - pabove = buffer + (((y-1) * width)); - pbelow = buffer + (((y+1) * width)); - pdelta = delta_buffer + (((y>>1) * width)); + pcurrent = buffer + (y * width); + pabove = buffer + ((y-1) * width); + pbelow = buffer + ((y+1) * width); + pdelta = delta_buffer + ((y>>1) * width); for (unsigned int x = 0; x < width; x++) { if(*pdelta++ >= threshold) { pcurrent[x] = (pabove[x] + pbelow[x]) >> 1; @@ -2970,14 +2970,212 @@ void Image::Deinterlace_4Field(const Image* next_image, unsigned int threshold) /* Special case for the last line */ pcurrent = buffer + ((height-1) * width); pabove = buffer + ((height-2) * width); - pdelta = delta_buffer + ((((height>>1)-1) * width)); + pdelta = delta_buffer + (((height>>1)-1) * width); for (unsigned int x = 0; x < width; x++) { if(*pdelta++ >= threshold) { pcurrent[x] = pabove[x]; } } + } + else if ( colours == ZM_COLOUR_RGB24 ) + { + /* Motion detection */ + if ( subpixelorder == ZM_SUBPIX_ORDER_BGR ) { + unsigned int b, g, r; + for (unsigned int y = 1; y < height; y += 2) { + pcurrent = buffer + ((y * width) * 3); + pncurrent = next_image->buffer + ((y * width) * 3); + pabove = buffer + (((y-1) * width) * 3); + pnabove = next_image->buffer + (((y-1) * width) * 3); + pdelta = delta_buffer + ((y>>1) * width); + for (unsigned int x = 0; x < width; x++) { + b = abs(*pnabove++ - *pabove++); + g = abs(*pnabove++ - *pabove++); + r = abs(*pnabove++ - *pabove++); + *pdelta = (r + r + b + g + g + g + g + g)>>3; + b = abs(*pncurrent++ - *pcurrent++); + g = abs(*pncurrent++ - *pcurrent++); + r = abs(*pncurrent++ - *pcurrent++); + *pdelta |= (r + r + b + g + g + g + g + g)>>3; + pdelta++; + } + } + } else { + unsigned int r, g, b; + for (unsigned int y = 1; y < height; y += 2) { + pcurrent = buffer + ((y * width) * 3); + pncurrent = next_image->buffer + ((y * width) * 3); + pabove = buffer + (((y-1) * width) * 3); + pnabove = next_image->buffer + (((y-1) * width) * 3); + pdelta = delta_buffer + ((y>>1) * width); + for (unsigned int x = 0; x < width; x++) { + r = abs(*pnabove++ - *pabove++); + g = abs(*pnabove++ - *pabove++); + b = abs(*pnabove++ - *pabove++); + *pdelta = (r + r + b + g + g + g + g + g)>>3; + r = abs(*pncurrent++ - *pcurrent++); + g = abs(*pncurrent++ - *pcurrent++); + b = abs(*pncurrent++ - *pcurrent++); + *pdelta |= (r + r + b + g + g + g + g + g)>>3; + pdelta++; + } + } + } + + /* Check if pixels meet threshold */ + for (unsigned int y = 1; y < (height-1); y += 2) { + pcurrent = buffer + ((y * width) * 3); + pabove = buffer + (((y-1) * width) * 3); + pbelow = buffer + (((y+1) * width) * 3); + pdelta = delta_buffer + ((y>>1) * width); + for (unsigned int x = 0; x < width; x++) { + if(*pdelta++ >= threshold) { + pcurrent[(x*3)+0] = (pabove[(x*3)+0] + pbelow[(x*3)+0]) >> 1; + pcurrent[(x*3)+1] = (pabove[(x*3)+1] + pbelow[(x*3)+1]) >> 1; + pcurrent[(x*3)+2] = (pabove[(x*3)+2] + pbelow[(x*3)+2]) >> 1; + } + } + } + /* Special case for the last line */ + pcurrent = buffer + (((height-1) * width) * 3); + pabove = buffer + (((height-2) * width) * 3); + pdelta = delta_buffer + (((height>>1)-1) * width); + for (unsigned int x = 0; x < width; x++) { + if(*pdelta++ >= threshold) { + pcurrent[(x*3)+0] = pabove[(x*3)+0]; + pcurrent[(x*3)+1] = pabove[(x*3)+1]; + pcurrent[(x*3)+2] = pabove[(x*3)+2]; + } + } + } + else if ( colours == ZM_COLOUR_RGB32 ) + { + /* Motion detection */ + if ( subpixelorder == ZM_SUBPIX_ORDER_BGRA ) { + unsigned int b, g, r; + for (unsigned int y = 1; y < height; y += 2) { + pcurrent = buffer + ((y * width) << 2); + pncurrent = next_image->buffer + ((y * width) << 2); + pabove = buffer + (((y-1) * width) << 2); + pnabove = next_image->buffer + (((y-1) * width) << 2); + pdelta = delta_buffer + ((y>>1) * width); + for (unsigned int x = 0; x < width; x++) { + b = abs(pnabove[0] - pabove[0]); + g = abs(pnabove[1] - pabove[1]); + r = abs(pnabove[2] - pabove[2]); + *pdelta = (r + r + b + g + g + g + g + g)>>3; + b = abs(pncurrent[0] - pcurrent[0]); + g = abs(pncurrent[1] - pcurrent[1]); + r = abs(pncurrent[2] - pcurrent[2]); + *pdelta |= (r + r + b + g + g + g + g + g)>>3; + pnabove += 4; + pabove += 4; + pncurrent += 4; + pcurrent += 4; + pdelta++; + } + } + } else if ( subpixelorder == ZM_SUBPIX_ORDER_ARGB ) { + /*unsigned int r, g, b; + for (unsigned int y = 1; y < height; y += 2) { + pcurrent = buffer + ((y * width) * 3); + pncurrent = next_image->buffer + ((y * width) * 3); + pabove = buffer + (((y-1) * width) * 3); + pnabove = next_image->buffer + (((y-1) * width) * 3); + pdelta = delta_buffer + ((y>>1) * width); + for (unsigned int x = 0; x < width; x++) { + r = abs(*pnabove++ - *pabove++); + g = abs(*pnabove++ - *pabove++); + b = abs(*pnabove++ - *pabove++); + *pdelta = (r + r + b + g + g + g + g + g)>>3; + r = abs(*pncurrent++ - *pcurrent++); + g = abs(*pncurrent++ - *pcurrent++); + b = abs(*pncurrent++ - *pcurrent++); + *pdelta |= (r + r + b + g + g + g + g + g)>>3; + pdelta++; + } + }*/ + Error("This type of deinterlacing is not implemented yet"); + } else if ( subpixelorder == ZM_SUBPIX_ORDER_ABGR ) { + /*unsigned int r, g, b; + for (unsigned int y = 1; y < height; y += 2) { + pcurrent = buffer + ((y * width) * 3); + pncurrent = next_image->buffer + ((y * width) * 3); + pabove = buffer + (((y-1) * width) * 3); + pnabove = next_image->buffer + (((y-1) * width) * 3); + pdelta = delta_buffer + ((y>>1) * width); + for (unsigned int x = 0; x < width; x++) { + r = abs(*pnabove++ - *pabove++); + g = abs(*pnabove++ - *pabove++); + b = abs(*pnabove - *pabove); + pnabove += 2; + pabove += 2; + *pdelta = (r + r + b + g + g + g + g + g)>>3; + r = abs(*pncurrent++ - *pcurrent++); + g = abs(*pncurrent++ - *pcurrent++); + b = abs(*pncurrent - *pcurrent); + pncurrent += 2; + pcurrent += 2; + *pdelta |= (r + r + b + g + g + g + g + g)>>3; + pdelta++; + } + }*/ + Error("This type of deinterlacing is not implemented yet"); + } else { + unsigned int r, g, b; + for (unsigned int y = 1; y < height; y += 2) { + pcurrent = buffer + ((y * width) << 2); + pncurrent = next_image->buffer + ((y * width) << 2); + pabove = buffer + (((y-1) * width) << 2); + pnabove = next_image->buffer + (((y-1) * width) << 2); + pdelta = delta_buffer + ((y>>1) * width); + for (unsigned int x = 0; x < width; x++) { + r = abs(pnabove[0] - pabove[0]); + g = abs(pnabove[1] - pabove[1]); + b = abs(pnabove[2] - pabove[2]); + *pdelta = (r + r + b + g + g + g + g + g)>>3; + r = abs(pncurrent[0] - pcurrent[0]); + g = abs(pncurrent[1] - pcurrent[1]); + b = abs(pncurrent[2] - pcurrent[2]); + *pdelta |= (r + r + b + g + g + g + g + g)>>3; + pnabove += 4; + pabove += 4; + pncurrent += 4; + pcurrent += 4; + pdelta++; + } + } + } + + /* Check if pixels meet threshold */ + for (unsigned int y = 1; y < (height-1); y += 2) { + pcurrent = buffer + ((y * width) << 2); + pabove = buffer + (((y-1) * width) << 2); + pbelow = buffer + (((y+1) * width) << 2); + pdelta = delta_buffer + ((y>>1) * width); + for (unsigned int x = 0; x < width; x++) { + if(*pdelta++ >= threshold) { + pcurrent[(x<<2)+0] = (pabove[(x<<2)+0] + pbelow[(x<<2)+0]) >> 1; + pcurrent[(x<<2)+1] = (pabove[(x<<2)+1] + pbelow[(x<<2)+1]) >> 1; + pcurrent[(x<<2)+2] = (pabove[(x<<2)+2] + pbelow[(x<<2)+2]) >> 1; + pcurrent[(x<<2)+3] = (pabove[(x<<2)+3] + pbelow[(x<<2)+3]) >> 1; + } + } + } + /* Special case for the last line */ + pcurrent = buffer + (((height-1) * width) << 2); + pabove = buffer + (((height-2) * width) << 2); + pdelta = delta_buffer + (((height>>1)-1) * width); + for (unsigned int x = 0; x < width; x++) { + if(*pdelta++ >= threshold) { + pcurrent[(x<<2)+0] = pabove[(x<<2)+0]; + pcurrent[(x<<2)+1] = pabove[(x<<2)+1]; + pcurrent[(x<<2)+2] = pabove[(x<<2)+2]; + pcurrent[(x<<2)+3] = pabove[(x<<2)+3]; + } + } } else { - Error("Unimplemented yet"); + Error("Not implemented yet"); } /* Free the delta buffer */ diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 6ec4c53c5..216b914ab 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -536,6 +536,11 @@ Monitor::~Monitor() Info( "%s: %03d - Closing event %d, shutting down", name, image_count, event->Id() ); closeEvent(); + if ( (deinterlacing & 0xff) == 4) + { + delete next_buffer.image; + delete next_buffer.timestamp; + } for ( int i = 0; i < image_buffer_count; i++ ) { delete image_buffer[i].image; diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 0e0c21949..e0e3aa295 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -364,9 +364,11 @@ $orientations = array( $deinterlaceopts = array( "Disabled" => 0x00000000, - "Four field motion adaptive - Soft" => 0x00003204, /* 50 change */ + "Four field motion adaptive - Very Soft" => 0x00003204, /* 50 change */ + "Four field motion adaptive - Soft" => 0x00002804, /* 40 change */ "Four field motion adaptive - Medium" => 0x00001E04, /* 30 change */ - "Four field motion adaptive - Hard" => 0x00000A04, /* 10 change */ + "Four field motion adaptive - Hard" => 0x00001404, /* 20 change */ + "Four field motion adaptive - Very Hard" => 0x00000A04, /* 10 change */ "Discard" => 0x00000001, "Linear" => 0x00000002, "Blend" => 0x00000003, @@ -375,16 +377,18 @@ $deinterlaceopts = array( $deinterlaceopts_v4l2 = array( "Disabled" => 0x00000000, - "Four field motion adaptive - Soft" => 0x00003204, /* 50 change */ + "Four field motion adaptive - Very Soft" => 0x00003204, /* 50 change */ + "Four field motion adaptive - Soft" => 0x00002804, /* 40 change */ "Four field motion adaptive - Medium" => 0x00001E04, /* 30 change */ - "Four field motion adaptive - Hard" => 0x00000A04, /* 10 change */ + "Four field motion adaptive - Hard" => 0x00001404, /* 20 change */ + "Four field motion adaptive - Very Hard" => 0x00000A04, /* 10 change */ "Discard" => 0x00000001, "Linear" => 0x00000002, "Blend" => 0x00000003, "Blend (25%)" => 0x00000205, - "V4L2: Top field only" => 0x02000000, - "V4L2: Bottom field only" => 0x03000000, - "V4L2: Alternate fields" => 0x07000000, + "V4L2: Capture top field only" => 0x02000000, + "V4L2: Capture bottom field only" => 0x03000000, + "V4L2: Alternate fields (Bob)" => 0x07000000, "V4L2: Progressive" => 0x01000000, "V4L2: Interlaced" => 0x04000000, ); From 0fe55a18bfdaf91cd6f332a7201b2cba7a0b5ce7 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sun, 15 Jul 2012 17:30:37 +0300 Subject: [PATCH 54/56] Something useable :) 1) Added optimized versions of four field deinterlacing, including SSSE3 ones. 2) Removed the "Very Soft" and "Very Hard" options. 3) Deinterlacing happens before any rotation to the image. --- src/zm_image.cpp | 1559 ++++++++++++++++++++++----- src/zm_image.h | 17 +- src/zm_monitor.cpp | 28 +- web/skins/classic/views/monitor.php | 16 +- 4 files changed, 1352 insertions(+), 268 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index a16efa416..8685ffdce 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -50,6 +50,13 @@ static delta_fptr_t fptr_delta8_argb; static delta_fptr_t fptr_delta8_abgr; static delta_fptr_t fptr_delta8_gray8; +/* Pointers to deinterlace_4field functions */ +static deinterlace_4field_fptr_t fptr_deinterlace_4field_rgba; +static deinterlace_4field_fptr_t fptr_deinterlace_4field_bgra; +static deinterlace_4field_fptr_t fptr_deinterlace_4field_argb; +static deinterlace_4field_fptr_t fptr_deinterlace_4field_abgr; +static deinterlace_4field_fptr_t fptr_deinterlace_4field_gray8; + /* Pointer to image buffer memory copy function */ imgbufcpy_fptr_t fptr_imgbufcpy; @@ -214,6 +221,23 @@ void Image::Initialise() Debug(2,"Delta: CPU extensions disabled, using standard delta functions"); } + /* Use SSSE3 deinterlace functions? */ + if(config.cpu_extensions && sseversion >= 35) { + fptr_deinterlace_4field_rgba = &ssse3_deinterlace_4field_rgba; + fptr_deinterlace_4field_bgra = &ssse3_deinterlace_4field_bgra; + fptr_deinterlace_4field_argb = &ssse3_deinterlace_4field_argb; + fptr_deinterlace_4field_abgr = &ssse3_deinterlace_4field_abgr; + fptr_deinterlace_4field_gray8 = &ssse3_deinterlace_4field_gray8; + Debug(2,"Deinterlace: Using SSSE3 delta functions"); + } else { + fptr_deinterlace_4field_rgba = &std_deinterlace_4field_rgba; + fptr_deinterlace_4field_bgra = &std_deinterlace_4field_bgra; + fptr_deinterlace_4field_argb = &std_deinterlace_4field_argb; + fptr_deinterlace_4field_abgr = &std_deinterlace_4field_abgr; + fptr_deinterlace_4field_gray8 = &std_deinterlace_4field_gray8; + Debug(2,"Deinterlace: Using standard delta functions"); + } + /* Use SSE2 aligned memory copy? */ if(config.cpu_extensions && sseversion >= 20) { fptr_imgbufcpy = &sse2_aligned_memcpy; @@ -2936,250 +2960,42 @@ void Image::Deinterlace_4Field(const Image* next_image, unsigned int threshold) Panic( "Attempt to deinterlace different sized images, expected %dx%dx%d %d, got %dx%dx%d %d", width, height, colours, subpixelorder, next_image->width, next_image->height, next_image->colours, next_image->subpixelorder); } - uint8_t *delta_buffer = AllocBuffer(width * (height>>1)); - uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow, *pdelta; - - if ( colours == ZM_COLOUR_GRAY8 ) - { - /* Motion detection */ - for (unsigned int y = 1; y < height; y += 2) { - pcurrent = buffer + (y * width); - pncurrent = next_image->buffer + (y * width); - pabove = buffer + ((y-1) * width); - pnabove = next_image->buffer + ((y-1) * width); - pdelta = delta_buffer + ((y>>1) * width); - for (unsigned int x = 0; x < width; x++) { - *pdelta = abs(*pnabove++ - *pabove++); - *pdelta |= abs(*pncurrent++ - *pcurrent++); - pdelta++; - } - } - - /* Check if pixels meet threshold */ - for (unsigned int y = 1; y < (height-1); y += 2) { - pcurrent = buffer + (y * width); - pabove = buffer + ((y-1) * width); - pbelow = buffer + ((y+1) * width); - pdelta = delta_buffer + ((y>>1) * width); - for (unsigned int x = 0; x < width; x++) { - if(*pdelta++ >= threshold) { - pcurrent[x] = (pabove[x] + pbelow[x]) >> 1; - } - } - } - /* Special case for the last line */ - pcurrent = buffer + ((height-1) * width); - pabove = buffer + ((height-2) * width); - pdelta = delta_buffer + (((height>>1)-1) * width); - for (unsigned int x = 0; x < width; x++) { - if(*pdelta++ >= threshold) { - pcurrent[x] = pabove[x]; - } - } - } - else if ( colours == ZM_COLOUR_RGB24 ) - { - /* Motion detection */ - if ( subpixelorder == ZM_SUBPIX_ORDER_BGR ) { - unsigned int b, g, r; - for (unsigned int y = 1; y < height; y += 2) { - pcurrent = buffer + ((y * width) * 3); - pncurrent = next_image->buffer + ((y * width) * 3); - pabove = buffer + (((y-1) * width) * 3); - pnabove = next_image->buffer + (((y-1) * width) * 3); - pdelta = delta_buffer + ((y>>1) * width); - for (unsigned int x = 0; x < width; x++) { - b = abs(*pnabove++ - *pabove++); - g = abs(*pnabove++ - *pabove++); - r = abs(*pnabove++ - *pabove++); - *pdelta = (r + r + b + g + g + g + g + g)>>3; - b = abs(*pncurrent++ - *pcurrent++); - g = abs(*pncurrent++ - *pcurrent++); - r = abs(*pncurrent++ - *pcurrent++); - *pdelta |= (r + r + b + g + g + g + g + g)>>3; - pdelta++; - } - } - } else { - unsigned int r, g, b; - for (unsigned int y = 1; y < height; y += 2) { - pcurrent = buffer + ((y * width) * 3); - pncurrent = next_image->buffer + ((y * width) * 3); - pabove = buffer + (((y-1) * width) * 3); - pnabove = next_image->buffer + (((y-1) * width) * 3); - pdelta = delta_buffer + ((y>>1) * width); - for (unsigned int x = 0; x < width; x++) { - r = abs(*pnabove++ - *pabove++); - g = abs(*pnabove++ - *pabove++); - b = abs(*pnabove++ - *pabove++); - *pdelta = (r + r + b + g + g + g + g + g)>>3; - r = abs(*pncurrent++ - *pcurrent++); - g = abs(*pncurrent++ - *pcurrent++); - b = abs(*pncurrent++ - *pcurrent++); - *pdelta |= (r + r + b + g + g + g + g + g)>>3; - pdelta++; - } - } - } - - /* Check if pixels meet threshold */ - for (unsigned int y = 1; y < (height-1); y += 2) { - pcurrent = buffer + ((y * width) * 3); - pabove = buffer + (((y-1) * width) * 3); - pbelow = buffer + (((y+1) * width) * 3); - pdelta = delta_buffer + ((y>>1) * width); - for (unsigned int x = 0; x < width; x++) { - if(*pdelta++ >= threshold) { - pcurrent[(x*3)+0] = (pabove[(x*3)+0] + pbelow[(x*3)+0]) >> 1; - pcurrent[(x*3)+1] = (pabove[(x*3)+1] + pbelow[(x*3)+1]) >> 1; - pcurrent[(x*3)+2] = (pabove[(x*3)+2] + pbelow[(x*3)+2]) >> 1; - } - } - } - /* Special case for the last line */ - pcurrent = buffer + (((height-1) * width) * 3); - pabove = buffer + (((height-2) * width) * 3); - pdelta = delta_buffer + (((height>>1)-1) * width); - for (unsigned int x = 0; x < width; x++) { - if(*pdelta++ >= threshold) { - pcurrent[(x*3)+0] = pabove[(x*3)+0]; - pcurrent[(x*3)+1] = pabove[(x*3)+1]; - pcurrent[(x*3)+2] = pabove[(x*3)+2]; - } - } + switch(colours) { + case ZM_COLOUR_RGB24: + { + if(subpixelorder == ZM_SUBPIX_ORDER_BGR) { + /* BGR subpixel order */ + std_deinterlace_4field_bgr(buffer, next_image->buffer, threshold, width, height); + } else { + /* Assume RGB subpixel order */ + std_deinterlace_4field_rgb(buffer, next_image->buffer, threshold, width, height); + } + break; + } + case ZM_COLOUR_RGB32: + { + if(subpixelorder == ZM_SUBPIX_ORDER_ARGB) { + /* ARGB subpixel order */ + (*fptr_deinterlace_4field_argb)(buffer, next_image->buffer, threshold, width, height); + } else if(subpixelorder == ZM_SUBPIX_ORDER_ABGR) { + /* ABGR subpixel order */ + (*fptr_deinterlace_4field_abgr)(buffer, next_image->buffer, threshold, width, height); + } else if(subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + /* BGRA subpixel order */ + (*fptr_deinterlace_4field_bgra)(buffer, next_image->buffer, threshold, width, height); + } else { + /* Assume RGBA subpixel order */ + (*fptr_deinterlace_4field_rgba)(buffer, next_image->buffer, threshold, width, height); + } + break; + } + case ZM_COLOUR_GRAY8: + (*fptr_deinterlace_4field_gray8)(buffer, next_image->buffer, threshold, width, height); + break; + default: + Panic("Deinterlace_4Field called with unexpected colours: %d",colours); + break; } - else if ( colours == ZM_COLOUR_RGB32 ) - { - /* Motion detection */ - if ( subpixelorder == ZM_SUBPIX_ORDER_BGRA ) { - unsigned int b, g, r; - for (unsigned int y = 1; y < height; y += 2) { - pcurrent = buffer + ((y * width) << 2); - pncurrent = next_image->buffer + ((y * width) << 2); - pabove = buffer + (((y-1) * width) << 2); - pnabove = next_image->buffer + (((y-1) * width) << 2); - pdelta = delta_buffer + ((y>>1) * width); - for (unsigned int x = 0; x < width; x++) { - b = abs(pnabove[0] - pabove[0]); - g = abs(pnabove[1] - pabove[1]); - r = abs(pnabove[2] - pabove[2]); - *pdelta = (r + r + b + g + g + g + g + g)>>3; - b = abs(pncurrent[0] - pcurrent[0]); - g = abs(pncurrent[1] - pcurrent[1]); - r = abs(pncurrent[2] - pcurrent[2]); - *pdelta |= (r + r + b + g + g + g + g + g)>>3; - pnabove += 4; - pabove += 4; - pncurrent += 4; - pcurrent += 4; - pdelta++; - } - } - } else if ( subpixelorder == ZM_SUBPIX_ORDER_ARGB ) { - /*unsigned int r, g, b; - for (unsigned int y = 1; y < height; y += 2) { - pcurrent = buffer + ((y * width) * 3); - pncurrent = next_image->buffer + ((y * width) * 3); - pabove = buffer + (((y-1) * width) * 3); - pnabove = next_image->buffer + (((y-1) * width) * 3); - pdelta = delta_buffer + ((y>>1) * width); - for (unsigned int x = 0; x < width; x++) { - r = abs(*pnabove++ - *pabove++); - g = abs(*pnabove++ - *pabove++); - b = abs(*pnabove++ - *pabove++); - *pdelta = (r + r + b + g + g + g + g + g)>>3; - r = abs(*pncurrent++ - *pcurrent++); - g = abs(*pncurrent++ - *pcurrent++); - b = abs(*pncurrent++ - *pcurrent++); - *pdelta |= (r + r + b + g + g + g + g + g)>>3; - pdelta++; - } - }*/ - Error("This type of deinterlacing is not implemented yet"); - } else if ( subpixelorder == ZM_SUBPIX_ORDER_ABGR ) { - /*unsigned int r, g, b; - for (unsigned int y = 1; y < height; y += 2) { - pcurrent = buffer + ((y * width) * 3); - pncurrent = next_image->buffer + ((y * width) * 3); - pabove = buffer + (((y-1) * width) * 3); - pnabove = next_image->buffer + (((y-1) * width) * 3); - pdelta = delta_buffer + ((y>>1) * width); - for (unsigned int x = 0; x < width; x++) { - r = abs(*pnabove++ - *pabove++); - g = abs(*pnabove++ - *pabove++); - b = abs(*pnabove - *pabove); - pnabove += 2; - pabove += 2; - *pdelta = (r + r + b + g + g + g + g + g)>>3; - r = abs(*pncurrent++ - *pcurrent++); - g = abs(*pncurrent++ - *pcurrent++); - b = abs(*pncurrent - *pcurrent); - pncurrent += 2; - pcurrent += 2; - *pdelta |= (r + r + b + g + g + g + g + g)>>3; - pdelta++; - } - }*/ - Error("This type of deinterlacing is not implemented yet"); - } else { - unsigned int r, g, b; - for (unsigned int y = 1; y < height; y += 2) { - pcurrent = buffer + ((y * width) << 2); - pncurrent = next_image->buffer + ((y * width) << 2); - pabove = buffer + (((y-1) * width) << 2); - pnabove = next_image->buffer + (((y-1) * width) << 2); - pdelta = delta_buffer + ((y>>1) * width); - for (unsigned int x = 0; x < width; x++) { - r = abs(pnabove[0] - pabove[0]); - g = abs(pnabove[1] - pabove[1]); - b = abs(pnabove[2] - pabove[2]); - *pdelta = (r + r + b + g + g + g + g + g)>>3; - r = abs(pncurrent[0] - pcurrent[0]); - g = abs(pncurrent[1] - pcurrent[1]); - b = abs(pncurrent[2] - pcurrent[2]); - *pdelta |= (r + r + b + g + g + g + g + g)>>3; - pnabove += 4; - pabove += 4; - pncurrent += 4; - pcurrent += 4; - pdelta++; - } - } - } - - /* Check if pixels meet threshold */ - for (unsigned int y = 1; y < (height-1); y += 2) { - pcurrent = buffer + ((y * width) << 2); - pabove = buffer + (((y-1) * width) << 2); - pbelow = buffer + (((y+1) * width) << 2); - pdelta = delta_buffer + ((y>>1) * width); - for (unsigned int x = 0; x < width; x++) { - if(*pdelta++ >= threshold) { - pcurrent[(x<<2)+0] = (pabove[(x<<2)+0] + pbelow[(x<<2)+0]) >> 1; - pcurrent[(x<<2)+1] = (pabove[(x<<2)+1] + pbelow[(x<<2)+1]) >> 1; - pcurrent[(x<<2)+2] = (pabove[(x<<2)+2] + pbelow[(x<<2)+2]) >> 1; - pcurrent[(x<<2)+3] = (pabove[(x<<2)+3] + pbelow[(x<<2)+3]) >> 1; - } - } - } - /* Special case for the last line */ - pcurrent = buffer + (((height-1) * width) << 2); - pabove = buffer + (((height-2) * width) << 2); - pdelta = delta_buffer + (((height>>1)-1) * width); - for (unsigned int x = 0; x < width; x++) { - if(*pdelta++ >= threshold) { - pcurrent[(x<<2)+0] = pabove[(x<<2)+0]; - pcurrent[(x<<2)+1] = pabove[(x<<2)+1]; - pcurrent[(x<<2)+2] = pabove[(x<<2)+2]; - pcurrent[(x<<2)+3] = pabove[(x<<2)+3]; - } - } - } else { - Error("Not implemented yet"); - } - - /* Free the delta buffer */ - DumpBuffer(delta_buffer, ZM_BUFTYPE_ZM); } @@ -4388,3 +4204,1260 @@ __attribute__((noinline)) void zm_convert_rgb565_rgba(const uint8_t* col1, uint8 } } +/************************************************* DEINTERLACE FUNCTIONS *************************************************/ + +/* Grayscale */ +void std_deinterlace_4field_gray8(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +{ + uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; + const uint8_t* const max_ptr = col1 + (width*(height-1)); + const uint8_t *max_ptr2; + + pcurrent = col1 + width; + pncurrent = col2 + width; + pabove = col1; + pnabove = col2; + pbelow = col1 + (width*2); + while(pcurrent < max_ptr) + { + max_ptr2 = pcurrent + width; + while(pcurrent < max_ptr2) { + if(((abs(*pnabove - *pabove) + abs(*pncurrent - *pcurrent)) >> 1) >= threshold) { + *pcurrent = (*pabove + *pbelow) >> 1; + } + pabove++; + pnabove++; + pcurrent++; + pncurrent++; + pbelow++; + } + pcurrent += width; + pncurrent += width; + pabove += width; + pnabove += width; + pbelow += width; + + } + + /* Special case for the last line */ + max_ptr2 = pcurrent + width; + while(pcurrent < max_ptr2) { + if(((abs(*pnabove - *pabove) + abs(*pncurrent - *pcurrent)) >> 1) >= threshold) { + *pcurrent = *pabove; + } + pabove++; + pnabove++; + pcurrent++; + pncurrent++; + } +} + +/* RGB */ +void std_deinterlace_4field_rgb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +{ + uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; + const unsigned int row_width = width*3; + const uint8_t* const max_ptr = col1 + (row_width * (height-1)); + const uint8_t *max_ptr2; + unsigned int b, g, r; + unsigned int delta1, delta2; + + pcurrent = col1 + (width*3); + pncurrent = col2 + (width*3); + pabove = col1; + pnabove = col2; + pbelow = col1 + ((width*2)*3); + while(pcurrent < max_ptr) + { + max_ptr2 = pcurrent + row_width; + while(pcurrent < max_ptr2) { + r = abs(pnabove[0] - pabove[0]); + g = abs(pnabove[1] - pabove[1]); + b = abs(pnabove[2] - pabove[2]); + delta1 = (r + r + b + g + g + g + g + g)>>3; + r = abs(pncurrent[0] - pcurrent[0]); + g = abs(pncurrent[1] - pcurrent[1]); + b = abs(pncurrent[2] - pcurrent[2]); + delta2 = (r + r + b + g + g + g + g + g)>>3; + if(((delta1 + delta2) >> 1) >= threshold) { + pcurrent[0] = (pabove[0] + pbelow[0]) >> 1; + pcurrent[1] = (pabove[1] + pbelow[1]) >> 1; + pcurrent[2] = (pabove[2] + pbelow[2]) >> 1; + } + pabove += 3; + pnabove += 3; + pcurrent += 3; + pncurrent += 3; + pbelow += 3; + } + pcurrent += row_width; + pncurrent += row_width; + pabove += row_width; + pnabove += row_width; + pbelow += row_width; + + } + + /* Special case for the last line */ + max_ptr2 = pcurrent + row_width; + while(pcurrent < max_ptr2) { + r = abs(pnabove[0] - pabove[0]); + g = abs(pnabove[1] - pabove[1]); + b = abs(pnabove[2] - pabove[2]); + delta1 = (r + r + b + g + g + g + g + g)>>3; + r = abs(pncurrent[0] - pcurrent[0]); + g = abs(pncurrent[1] - pcurrent[1]); + b = abs(pncurrent[2] - pcurrent[2]); + delta2 = (r + r + b + g + g + g + g + g)>>3; + if(((delta1 + delta2) >> 1) >= threshold) { + pcurrent[0] = pabove[0]; + pcurrent[1] = pabove[1]; + pcurrent[2] = pabove[2]; + } + pabove += 3; + pnabove += 3; + pcurrent += 3; + pncurrent += 3; + } +} + +/* BGR */ +void std_deinterlace_4field_bgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +{ + uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; + const unsigned int row_width = width*3; + const uint8_t* const max_ptr = col1 + (row_width * (height-1)); + const uint8_t *max_ptr2; + unsigned int b, g, r; + unsigned int delta1, delta2; + + pcurrent = col1 + (width*3); + pncurrent = col2 + (width*3); + pabove = col1; + pnabove = col2; + pbelow = col1 + ((width*2)*3); + while(pcurrent < max_ptr) + { + max_ptr2 = pcurrent + row_width; + while(pcurrent < max_ptr2) { + b = abs(pnabove[0] - pabove[0]); + g = abs(pnabove[1] - pabove[1]); + r = abs(pnabove[2] - pabove[2]); + delta1 = (r + r + b + g + g + g + g + g)>>3; + b = abs(pncurrent[0] - pcurrent[0]); + g = abs(pncurrent[1] - pcurrent[1]); + r = abs(pncurrent[2] - pcurrent[2]); + delta2 = (r + r + b + g + g + g + g + g)>>3; + if(((delta1 + delta2) >> 1) >= threshold) { + pcurrent[0] = (pabove[0] + pbelow[0]) >> 1; + pcurrent[1] = (pabove[1] + pbelow[1]) >> 1; + pcurrent[2] = (pabove[2] + pbelow[2]) >> 1; + } + pabove += 3; + pnabove += 3; + pcurrent += 3; + pncurrent += 3; + pbelow += 3; + } + pcurrent += row_width; + pncurrent += row_width; + pabove += row_width; + pnabove += row_width; + pbelow += row_width; + + } + + /* Special case for the last line */ + max_ptr2 = pcurrent + row_width; + while(pcurrent < max_ptr2) { + b = abs(pnabove[0] - pabove[0]); + g = abs(pnabove[1] - pabove[1]); + r = abs(pnabove[2] - pabove[2]); + delta1 = (r + r + b + g + g + g + g + g)>>3; + b = abs(pncurrent[0] - pcurrent[0]); + g = abs(pncurrent[1] - pcurrent[1]); + r = abs(pncurrent[2] - pcurrent[2]); + delta2 = (r + r + b + g + g + g + g + g)>>3; + if(((delta1 + delta2) >> 1) >= threshold) { + pcurrent[0] = pabove[0]; + pcurrent[1] = pabove[1]; + pcurrent[2] = pabove[2]; + } + pabove += 3; + pnabove += 3; + pcurrent += 3; + pncurrent += 3; + } +} + +/* RGBA */ +void std_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +{ + uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; + const unsigned int row_width = width*4; + const uint8_t* const max_ptr = col1 + (row_width * (height-1)); + const uint8_t *max_ptr2; + unsigned int b, g, r; + unsigned int delta1, delta2; + + pcurrent = col1 + row_width; + pncurrent = col2 + row_width; + pabove = col1; + pnabove = col2; + pbelow = col1 + (row_width*2); + while(pcurrent < max_ptr) + { + max_ptr2 = pcurrent + row_width; + while(pcurrent < max_ptr2) { + r = abs(pnabove[0] - pabove[0]); + g = abs(pnabove[1] - pabove[1]); + b = abs(pnabove[2] - pabove[2]); + delta1 = (r + r + b + g + g + g + g + g)>>3; + r = abs(pncurrent[0] - pcurrent[0]); + g = abs(pncurrent[1] - pcurrent[1]); + b = abs(pncurrent[2] - pcurrent[2]); + delta2 = (r + r + b + g + g + g + g + g)>>3; + if(((delta1 + delta2) >> 1) >= threshold) { + pcurrent[0] = (pabove[0] + pbelow[0]) >> 1; + pcurrent[1] = (pabove[1] + pbelow[1]) >> 1; + pcurrent[2] = (pabove[2] + pbelow[2]) >> 1; + } + pabove += 4; + pnabove += 4; + pcurrent += 4; + pncurrent += 4; + pbelow += 4; + } + pcurrent += row_width; + pncurrent += row_width; + pabove += row_width; + pnabove += row_width; + pbelow += row_width; + + } + + /* Special case for the last line */ + max_ptr2 = pcurrent + row_width; + while(pcurrent < max_ptr2) { + r = abs(pnabove[0] - pabove[0]); + g = abs(pnabove[1] - pabove[1]); + b = abs(pnabove[2] - pabove[2]); + delta1 = (r + r + b + g + g + g + g + g)>>3; + r = abs(pncurrent[0] - pcurrent[0]); + g = abs(pncurrent[1] - pcurrent[1]); + b = abs(pncurrent[2] - pcurrent[2]); + delta2 = (r + r + b + g + g + g + g + g)>>3; + if(((delta1 + delta2) >> 1) >= threshold) { + pcurrent[0] = pabove[0]; + pcurrent[1] = pabove[1]; + pcurrent[2] = pabove[2]; + } + pabove += 4; + pnabove += 4; + pcurrent += 4; + pncurrent += 4; + } +} + +/* BGRA */ +void std_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +{ + uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; + const unsigned int row_width = width*4; + const uint8_t* const max_ptr = col1 + (row_width * (height-1)); + const uint8_t *max_ptr2; + unsigned int b, g, r; + unsigned int delta1, delta2; + + pcurrent = col1 + row_width; + pncurrent = col2 + row_width; + pabove = col1; + pnabove = col2; + pbelow = col1 + (row_width*2); + while(pcurrent < max_ptr) + { + max_ptr2 = pcurrent + row_width; + while(pcurrent < max_ptr2) { + b = abs(pnabove[0] - pabove[0]); + g = abs(pnabove[1] - pabove[1]); + r = abs(pnabove[2] - pabove[2]); + delta1 = (r + r + b + g + g + g + g + g)>>3; + b = abs(pncurrent[0] - pcurrent[0]); + g = abs(pncurrent[1] - pcurrent[1]); + r = abs(pncurrent[2] - pcurrent[2]); + delta2 = (r + r + b + g + g + g + g + g)>>3; + if(((delta1 + delta2) >> 1) >= threshold) { + pcurrent[0] = (pabove[0] + pbelow[0]) >> 1; + pcurrent[1] = (pabove[1] + pbelow[1]) >> 1; + pcurrent[2] = (pabove[2] + pbelow[2]) >> 1; + } + pabove += 4; + pnabove += 4; + pcurrent += 4; + pncurrent += 4; + pbelow += 4; + } + pcurrent += row_width; + pncurrent += row_width; + pabove += row_width; + pnabove += row_width; + pbelow += row_width; + + } + + /* Special case for the last line */ + max_ptr2 = pcurrent + row_width; + while(pcurrent < max_ptr2) { + b = abs(pnabove[0] - pabove[0]); + g = abs(pnabove[1] - pabove[1]); + r = abs(pnabove[2] - pabove[2]); + delta1 = (r + r + b + g + g + g + g + g)>>3; + b = abs(pncurrent[0] - pcurrent[0]); + g = abs(pncurrent[1] - pcurrent[1]); + r = abs(pncurrent[2] - pcurrent[2]); + delta2 = (r + r + b + g + g + g + g + g)>>3; + if(((delta1 + delta2) >> 1) >= threshold) { + pcurrent[0] = pabove[0]; + pcurrent[1] = pabove[1]; + pcurrent[2] = pabove[2]; + } + pabove += 4; + pnabove += 4; + pcurrent += 4; + pncurrent += 4; + } +} + +/* ARGB */ +void std_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +{ + uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; + const unsigned int row_width = width*4; + const uint8_t* const max_ptr = col1 + (row_width * (height-1)); + const uint8_t *max_ptr2; + unsigned int b, g, r; + unsigned int delta1, delta2; + + pcurrent = col1 + row_width; + pncurrent = col2 + row_width; + pabove = col1; + pnabove = col2; + pbelow = col1 + (row_width*2); + while(pcurrent < max_ptr) + { + max_ptr2 = pcurrent + row_width; + while(pcurrent < max_ptr2) { + r = abs(pnabove[1] - pabove[1]); + g = abs(pnabove[2] - pabove[2]); + b = abs(pnabove[3] - pabove[3]); + delta1 = (r + r + b + g + g + g + g + g)>>3; + r = abs(pncurrent[1] - pcurrent[1]); + g = abs(pncurrent[2] - pcurrent[2]); + b = abs(pncurrent[3] - pcurrent[3]); + delta2 = (r + r + b + g + g + g + g + g)>>3; + if(((delta1 + delta2) >> 1) >= threshold) { + pcurrent[1] = (pabove[1] + pbelow[1]) >> 1; + pcurrent[2] = (pabove[2] + pbelow[2]) >> 1; + pcurrent[3] = (pabove[3] + pbelow[3]) >> 1; + } + pabove += 4; + pnabove += 4; + pcurrent += 4; + pncurrent += 4; + pbelow += 4; + } + pcurrent += row_width; + pncurrent += row_width; + pabove += row_width; + pnabove += row_width; + pbelow += row_width; + + } + + /* Special case for the last line */ + max_ptr2 = pcurrent + row_width; + while(pcurrent < max_ptr2) { + r = abs(pnabove[1] - pabove[1]); + g = abs(pnabove[2] - pabove[2]); + b = abs(pnabove[3] - pabove[3]); + delta1 = (r + r + b + g + g + g + g + g)>>3; + r = abs(pncurrent[1] - pcurrent[1]); + g = abs(pncurrent[2] - pcurrent[2]); + b = abs(pncurrent[3] - pcurrent[3]); + delta2 = (r + r + b + g + g + g + g + g)>>3; + if(((delta1 + delta2) >> 1) >= threshold) { + pcurrent[1] = pabove[1]; + pcurrent[2] = pabove[2]; + pcurrent[3] = pabove[3]; + } + pabove += 4; + pnabove += 4; + pcurrent += 4; + pncurrent += 4; + } +} + +/* ABGR */ +void std_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +{ + uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; + const unsigned int row_width = width*4; + const uint8_t* const max_ptr = col1 + (row_width * (height-1)); + const uint8_t *max_ptr2; + unsigned int b, g, r; + unsigned int delta1, delta2; + + pcurrent = col1 + row_width; + pncurrent = col2 + row_width; + pabove = col1; + pnabove = col2; + pbelow = col1 + (row_width*2); + while(pcurrent < max_ptr) + { + max_ptr2 = pcurrent + row_width; + while(pcurrent < max_ptr2) { + b = abs(pnabove[1] - pabove[1]); + g = abs(pnabove[2] - pabove[2]); + r = abs(pnabove[3] - pabove[3]); + delta1 = (r + r + b + g + g + g + g + g)>>3; + b = abs(pncurrent[1] - pcurrent[1]); + g = abs(pncurrent[2] - pcurrent[2]); + r = abs(pncurrent[3] - pcurrent[3]); + delta2 = (r + r + b + g + g + g + g + g)>>3; + if(((delta1 + delta2) >> 1) >= threshold) { + pcurrent[1] = (pabove[1] + pbelow[1]) >> 1; + pcurrent[2] = (pabove[2] + pbelow[2]) >> 1; + pcurrent[3] = (pabove[3] + pbelow[3]) >> 1; + } + pabove += 4; + pnabove += 4; + pcurrent += 4; + pncurrent += 4; + pbelow += 4; + } + pcurrent += row_width; + pncurrent += row_width; + pabove += row_width; + pnabove += row_width; + pbelow += row_width; + + } + + /* Special case for the last line */ + max_ptr2 = pcurrent + row_width; + while(pcurrent < max_ptr2) { + b = abs(pnabove[1] - pabove[1]); + g = abs(pnabove[2] - pabove[2]); + r = abs(pnabove[3] - pabove[3]); + delta1 = (r + r + b + g + g + g + g + g)>>3; + b = abs(pncurrent[1] - pcurrent[1]); + g = abs(pncurrent[2] - pcurrent[2]); + r = abs(pncurrent[3] - pcurrent[3]); + delta2 = (r + r + b + g + g + g + g + g)>>3; + if(((delta1 + delta2) >> 1) >= threshold) { + pcurrent[1] = pabove[1]; + pcurrent[2] = pabove[2]; + pcurrent[3] = pabove[3]; + } + pabove += 4; + pnabove += 4; + pcurrent += 4; + pncurrent += 4; + } +} + +/* Grayscale SSSE3 */ +__attribute__ ((noinline)) void ssse3_deinterlace_4field_gray8(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { + + union { + uint32_t int32; + uint8_t int8a[4]; + } threshold_mask; + threshold_mask.int8a[0] = threshold; + threshold_mask.int8a[1] = 0; + threshold_mask.int8a[2] = threshold; + threshold_mask.int8a[3] = 0; + + unsigned long row_width = width; + uint8_t* max_ptr = col1 + (row_width * (height-2)); + uint8_t* max_ptr2 = col1 + row_width; + + __asm__ __volatile__ ( + /* Load the threshold */ + "mov %5, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + /* Zero the temporary register */ + "pxor %%xmm0, %%xmm0\n\t" + + "algo_ssse3_deinterlace_4field_gray8:\n\t" + + /* Load pabove into xmm1 and pnabove into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" /* Keep backup of pabove in xmm5 */ + "pmaxub %%xmm2, %%xmm1\n\t" + "pminub %%xmm5, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm7\n\t" /* Backup of delta2 in xmm7 for now */ + + /* Next row */ + "add %4, %0\n\t" + "add %4, %1\n\t" + + /* Load pcurrent into xmm1 and pncurrent into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm6\n\t" /* Keep backup of pcurrent in xmm6 */ + "pmaxub %%xmm2, %%xmm1\n\t" + "pminub %%xmm6, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + + "pavgb %%xmm7, %%xmm1\n\t" // Average the two deltas together + "movdqa %%xmm1, %%xmm2\n\t" + + /* Do the comparison on words instead of bytes because we don't have unsigned comparison */ + "punpcklbw %%xmm0, %%xmm1\n\t" // Expand pixels 0-7 into words into xmm1 + "punpckhbw %%xmm0, %%xmm2\n\t" // Expand pixels 8-15 into words into xmm2 + "pcmpgtw %%xmm4, %%xmm1\n\t" // Compare average delta with threshold for pixels 0-7 + "pcmpgtw %%xmm4, %%xmm2\n\t" // Compare average delta with threshold for pixels 8-15 + "packsswb %%xmm2, %%xmm1\n\t" // Pack the comparison results into xmm1 + + "movdqa (%0,%4), %%xmm2\n\t" // Load pbelow + "pavgb %%xmm5, %%xmm2\n\t" // Average pabove and pbelow + "pand %%xmm1, %%xmm2\n\t" // Filter out pixels in avg that shouldn't be copied + "pandn %%xmm6, %%xmm1\n\t" // Filter out pixels in pcurrent that should be replaced + + "por %%xmm2, %%xmm1\n\t" // Put the new values in pcurrent + "movntdq %%xmm1, (%0)\n\t" // Write pcurrent + + "sub %4, %0\n\t" // Restore pcurrent to pabove + "sub %4, %1\n\t" // Restore pncurrent to pnabove + + /* Next pixels */ + "add $0x10, %0\n\t" // Add 16 to pcurrent + "add $0x10, %1\n\t" // Add 16 to pncurrent + + /* Check if we reached the row end */ + "cmp %2, %0\n\t" + "jb algo_ssse3_deinterlace_4field_gray8\n\t" // Go for another iteration + + /* Next row */ + "add %4, %0\n\t" // Add width to pcurrent + "add %4, %1\n\t" // Add width to pncurrent + "mov %0, %2\n\t" + "add %4, %2\n\t" // Add width to max_ptr2 + + /* Check if we reached the end */ + "cmp %3, %0\n\t" + "jb algo_ssse3_deinterlace_4field_gray8\n\t" // Go for another iteration + : + : "r" (col1), "r" (col2), "r" (max_ptr2), "r" (max_ptr), "r" (row_width), "m" (threshold_mask.int32) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "cc", "memory" + ); +} + +/* RGBA SSSE3 */ +__attribute__ ((noinline)) void ssse3_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { + __attribute__((aligned(16))) static const uint8_t movemask2[16] = {1,1,1,1,1,0,0,2,9,9,9,9,9,8,8,10}; + + const uint32_t threshold_val = threshold; + + unsigned long row_width = width*4; + uint8_t* max_ptr = col1 + (row_width * (height-2)); + uint8_t* max_ptr2 = col1 + row_width; + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "movdqa %6, %%xmm3\n\t" + "mov %5, %%eax\n\t" +#if defined(__x86_64__) + "movd %%eax, %%xmm8\n\t" + "pshufd $0x0, %%xmm8, %%xmm8\n\t" +#endif + /* Zero the temporary register */ + "pxor %%xmm0, %%xmm0\n\t" + + "algo_ssse3_deinterlace_4field_rgba:\n\t" + + /* Load pabove into xmm1 and pnabove into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" /* Keep backup of pabove in xmm5 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm7\n\t" /* Backup of delta2 in xmm7 for now */ + + /* Next row */ + "add %4, %0\n\t" + "add %4, %1\n\t" + + /* Load pcurrent into xmm1 and pncurrent into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm6\n\t" /* Keep backup of pcurrent in xmm6 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + + "pavgb %%xmm7, %%xmm1\n\t" // Average the two deltas together + +#if defined(__x86_64__) + "pcmpgtd %%xmm8, %%xmm1\n\t" // Compare average delta with the threshold +#else + "movd %%eax, %%xmm7\n\t" // Setup the threshold + "pshufd $0x0, %%xmm7, %%xmm7\n\t" + + "pcmpgtd %%xmm7, %%xmm1\n\t" // Compare average delta with the threshold +#endif + "movdqa (%0,%4), %%xmm2\n\t" // Load pbelow + "pavgb %%xmm5, %%xmm2\n\t" // Average pabove and pbelow + "pand %%xmm1, %%xmm2\n\t" // Filter out pixels in avg that shouldn't be copied + "pandn %%xmm6, %%xmm1\n\t" // Filter out pixels in pcurrent that should be replaced + + "por %%xmm2, %%xmm1\n\t" // Put the new values in pcurrent + "movntdq %%xmm1, (%0)\n\t" // Write pcurrent + + "sub %4, %0\n\t" // Restore pcurrent to pabove + "sub %4, %1\n\t" // Restore pncurrent to pnabove + + /* Next pixels */ + "add $0x10, %0\n\t" // Add 16 to pcurrent + "add $0x10, %1\n\t" // Add 16 to pncurrent + + /* Check if we reached the row end */ + "cmp %2, %0\n\t" + "jb algo_ssse3_deinterlace_4field_rgba\n\t" // Go for another iteration + + /* Next row */ + "add %4, %0\n\t" // Add width to pcurrent + "add %4, %1\n\t" // Add width to pncurrent + "mov %0, %2\n\t" + "add %4, %2\n\t" // Add width to max_ptr2 + + /* Check if we reached the end */ + "cmp %3, %0\n\t" + "jb algo_ssse3_deinterlace_4field_rgba\n\t" // Go for another iteration + + /* Special case for the last line */ + /* Load pabove into xmm1 and pnabove into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" /* Keep backup of pabove in xmm5 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm7\n\t" /* Backup of delta2 in xmm7 for now */ + + /* Next row */ + "add %4, %0\n\t" + "add %4, %1\n\t" + + /* Load pcurrent into xmm1 and pncurrent into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm6\n\t" /* Keep backup of pcurrent in xmm6 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + + "pavgb %%xmm7, %%xmm1\n\t" // Average the two deltas together + +#if defined(__x86_64__) + "pcmpgtd %%xmm8, %%xmm1\n\t" // Compare average delta with the threshold +#else + "movd %%eax, %%xmm7\n\t" // Setup the threshold + "pshufd $0x0, %%xmm7, %%xmm7\n\t" + + "pcmpgtd %%xmm7, %%xmm1\n\t" // Compare average delta with the threshold +#endif + "pand %%xmm1, %%xmm5\n\t" // Filter out pixels in pabove that shouldn't be copied + "pandn %%xmm6, %%xmm1\n\t" // Filter out pixels in pcurrent that should be replaced + + "por %%xmm5, %%xmm1\n\t" // Put the new values in pcurrent + "movntdq %%xmm1, (%0)\n\t" // Write pcurrent + : + : "r" (col1), "r" (col2), "r" (max_ptr2), "r" (max_ptr), "r" (row_width), "m" (threshold_val), "m" (*movemask2) +#if defined(__x86_64__) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "cc", "memory" +#else + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "cc", "memory" +#endif + ); +} + +/* BGRA SSSE3 */ +__attribute__ ((noinline)) void ssse3_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { + __attribute__((aligned(16))) static const uint8_t movemask2[16] = {1,1,1,1,1,2,2,0,9,9,9,9,9,10,10,8}; + + const uint32_t threshold_val = threshold; + + unsigned long row_width = width*4; + uint8_t* max_ptr = col1 + (row_width * (height-2)); + uint8_t* max_ptr2 = col1 + row_width; + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "movdqa %6, %%xmm3\n\t" + "mov %5, %%eax\n\t" +#if defined(__x86_64__) + "movd %%eax, %%xmm8\n\t" + "pshufd $0x0, %%xmm8, %%xmm8\n\t" +#endif + /* Zero the temporary register */ + "pxor %%xmm0, %%xmm0\n\t" + + "algo_ssse3_deinterlace_4field_bgra:\n\t" + + /* Load pabove into xmm1 and pnabove into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" /* Keep backup of pabove in xmm5 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm7\n\t" /* Backup of delta2 in xmm7 for now */ + + /* Next row */ + "add %4, %0\n\t" + "add %4, %1\n\t" + + /* Load pcurrent into xmm1 and pncurrent into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm6\n\t" /* Keep backup of pcurrent in xmm6 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + + "pavgb %%xmm7, %%xmm1\n\t" // Average the two deltas together + +#if defined(__x86_64__) + "pcmpgtd %%xmm8, %%xmm1\n\t" // Compare average delta with the threshold +#else + "movd %%eax, %%xmm7\n\t" // Setup the threshold + "pshufd $0x0, %%xmm7, %%xmm7\n\t" + + "pcmpgtd %%xmm7, %%xmm1\n\t" // Compare average delta with the threshold +#endif + "movdqa (%0,%4), %%xmm2\n\t" // Load pbelow + "pavgb %%xmm5, %%xmm2\n\t" // Average pabove and pbelow + "pand %%xmm1, %%xmm2\n\t" // Filter out pixels in avg that shouldn't be copied + "pandn %%xmm6, %%xmm1\n\t" // Filter out pixels in pcurrent that should be replaced + + "por %%xmm2, %%xmm1\n\t" // Put the new values in pcurrent + "movntdq %%xmm1, (%0)\n\t" // Write pcurrent + + "sub %4, %0\n\t" // Restore pcurrent to pabove + "sub %4, %1\n\t" // Restore pncurrent to pnabove + + /* Next pixels */ + "add $0x10, %0\n\t" // Add 16 to pcurrent + "add $0x10, %1\n\t" // Add 16 to pncurrent + + /* Check if we reached the row end */ + "cmp %2, %0\n\t" + "jb algo_ssse3_deinterlace_4field_bgra\n\t" // Go for another iteration + + /* Next row */ + "add %4, %0\n\t" // Add width to pcurrent + "add %4, %1\n\t" // Add width to pncurrent + "mov %0, %2\n\t" + "add %4, %2\n\t" // Add width to max_ptr2 + + /* Check if we reached the end */ + "cmp %3, %0\n\t" + "jb algo_ssse3_deinterlace_4field_bgra\n\t" // Go for another iteration + + /* Special case for the last line */ + /* Load pabove into xmm1 and pnabove into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" /* Keep backup of pabove in xmm5 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm7\n\t" /* Backup of delta2 in xmm7 for now */ + + /* Next row */ + "add %4, %0\n\t" + "add %4, %1\n\t" + + /* Load pcurrent into xmm1 and pncurrent into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm6\n\t" /* Keep backup of pcurrent in xmm6 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + + "pavgb %%xmm7, %%xmm1\n\t" // Average the two deltas together + +#if defined(__x86_64__) + "pcmpgtd %%xmm8, %%xmm1\n\t" // Compare average delta with the threshold +#else + "movd %%eax, %%xmm7\n\t" // Setup the threshold + "pshufd $0x0, %%xmm7, %%xmm7\n\t" + + "pcmpgtd %%xmm7, %%xmm1\n\t" // Compare average delta with the threshold +#endif + "pand %%xmm1, %%xmm5\n\t" // Filter out pixels in pabove that shouldn't be copied + "pandn %%xmm6, %%xmm1\n\t" // Filter out pixels in pcurrent that should be replaced + + "por %%xmm5, %%xmm1\n\t" // Put the new values in pcurrent + "movntdq %%xmm1, (%0)\n\t" // Write pcurrent + : + : "r" (col1), "r" (col2), "r" (max_ptr2), "r" (max_ptr), "r" (row_width), "m" (threshold_val), "m" (*movemask2) +#if defined(__x86_64__) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "cc", "memory" +#else + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "cc", "memory" +#endif + ); +} + +/* ARGB SSSE3 */ +__attribute__ ((noinline)) void ssse3_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { + __attribute__((aligned(16))) static const uint8_t movemask2[16] = {2,2,2,2,2,1,1,3,10,10,10,10,10,9,9,11}; + + const uint32_t threshold_val = threshold; + + unsigned long row_width = width*4; + uint8_t* max_ptr = col1 + (row_width * (height-2)); + uint8_t* max_ptr2 = col1 + row_width; + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "movdqa %6, %%xmm3\n\t" + "mov %5, %%eax\n\t" +#if defined(__x86_64__) + "movd %%eax, %%xmm8\n\t" + "pshufd $0x0, %%xmm8, %%xmm8\n\t" +#endif + /* Zero the temporary register */ + "pxor %%xmm0, %%xmm0\n\t" + + "algo_ssse3_deinterlace_4field_argb:\n\t" + + /* Load pabove into xmm1 and pnabove into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" /* Keep backup of pabove in xmm5 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm7\n\t" /* Backup of delta2 in xmm7 for now */ + + /* Next row */ + "add %4, %0\n\t" + "add %4, %1\n\t" + + /* Load pcurrent into xmm1 and pncurrent into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm6\n\t" /* Keep backup of pcurrent in xmm6 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + + "pavgb %%xmm7, %%xmm1\n\t" // Average the two deltas together + +#if defined(__x86_64__) + "pcmpgtd %%xmm8, %%xmm1\n\t" // Compare average delta with the threshold +#else + "movd %%eax, %%xmm7\n\t" // Setup the threshold + "pshufd $0x0, %%xmm7, %%xmm7\n\t" + + "pcmpgtd %%xmm7, %%xmm1\n\t" // Compare average delta with the threshold +#endif + "movdqa (%0,%4), %%xmm2\n\t" // Load pbelow + "pavgb %%xmm5, %%xmm2\n\t" // Average pabove and pbelow + "pand %%xmm1, %%xmm2\n\t" // Filter out pixels in avg that shouldn't be copied + "pandn %%xmm6, %%xmm1\n\t" // Filter out pixels in pcurrent that should be replaced + + "por %%xmm2, %%xmm1\n\t" // Put the new values in pcurrent + "movntdq %%xmm1, (%0)\n\t" // Write pcurrent + + "sub %4, %0\n\t" // Restore pcurrent to pabove + "sub %4, %1\n\t" // Restore pncurrent to pnabove + + /* Next pixels */ + "add $0x10, %0\n\t" // Add 16 to pcurrent + "add $0x10, %1\n\t" // Add 16 to pncurrent + + /* Check if we reached the row end */ + "cmp %2, %0\n\t" + "jb algo_ssse3_deinterlace_4field_argb\n\t" // Go for another iteration + + /* Next row */ + "add %4, %0\n\t" // Add width to pcurrent + "add %4, %1\n\t" // Add width to pncurrent + "mov %0, %2\n\t" + "add %4, %2\n\t" // Add width to max_ptr2 + + /* Check if we reached the end */ + "cmp %3, %0\n\t" + "jb algo_ssse3_deinterlace_4field_argb\n\t" // Go for another iteration + + /* Special case for the last line */ + /* Load pabove into xmm1 and pnabove into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" /* Keep backup of pabove in xmm5 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm7\n\t" /* Backup of delta2 in xmm7 for now */ + + /* Next row */ + "add %4, %0\n\t" + "add %4, %1\n\t" + + /* Load pcurrent into xmm1 and pncurrent into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm6\n\t" /* Keep backup of pcurrent in xmm6 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + + "pavgb %%xmm7, %%xmm1\n\t" // Average the two deltas together + +#if defined(__x86_64__) + "pcmpgtd %%xmm8, %%xmm1\n\t" // Compare average delta with the threshold +#else + "movd %%eax, %%xmm7\n\t" // Setup the threshold + "pshufd $0x0, %%xmm7, %%xmm7\n\t" + + "pcmpgtd %%xmm7, %%xmm1\n\t" // Compare average delta with the threshold +#endif + "pand %%xmm1, %%xmm5\n\t" // Filter out pixels in pabove that shouldn't be copied + "pandn %%xmm6, %%xmm1\n\t" // Filter out pixels in pcurrent that should be replaced + + "por %%xmm5, %%xmm1\n\t" // Put the new values in pcurrent + "movntdq %%xmm1, (%0)\n\t" // Write pcurrent + : + : "r" (col1), "r" (col2), "r" (max_ptr2), "r" (max_ptr), "r" (row_width), "m" (threshold_val), "m" (*movemask2) +#if defined(__x86_64__) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "cc", "memory" +#else + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "cc", "memory" +#endif + ); +} + +/* ABGR SSSE3 */ +__attribute__ ((noinline)) void ssse3_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { + __attribute__((aligned(16))) static const uint8_t movemask2[16] = {2,2,2,2,2,3,3,1,10,10,10,10,10,11,11,9}; + + const uint32_t threshold_val = threshold; + + unsigned long row_width = width*4; + uint8_t* max_ptr = col1 + (row_width * (height-2)); + uint8_t* max_ptr2 = col1 + row_width; + + __asm__ __volatile__ ( + "mov $0x1F1F1F1F, %%eax\n\t" + "movd %%eax, %%xmm4\n\t" + "pshufd $0x0, %%xmm4, %%xmm4\n\t" + "movdqa %6, %%xmm3\n\t" + "mov %5, %%eax\n\t" +#if defined(__x86_64__) + "movd %%eax, %%xmm8\n\t" + "pshufd $0x0, %%xmm8, %%xmm8\n\t" +#endif + /* Zero the temporary register */ + "pxor %%xmm0, %%xmm0\n\t" + + "algo_ssse3_deinterlace_4field_abgr:\n\t" + + /* Load pabove into xmm1 and pnabove into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" /* Keep backup of pabove in xmm5 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm7\n\t" /* Backup of delta2 in xmm7 for now */ + + /* Next row */ + "add %4, %0\n\t" + "add %4, %1\n\t" + + /* Load pcurrent into xmm1 and pncurrent into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm6\n\t" /* Keep backup of pcurrent in xmm6 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + + "pavgb %%xmm7, %%xmm1\n\t" // Average the two deltas together + +#if defined(__x86_64__) + "pcmpgtd %%xmm8, %%xmm1\n\t" // Compare average delta with the threshold +#else + "movd %%eax, %%xmm7\n\t" // Setup the threshold + "pshufd $0x0, %%xmm7, %%xmm7\n\t" + + "pcmpgtd %%xmm7, %%xmm1\n\t" // Compare average delta with the threshold +#endif + "movdqa (%0,%4), %%xmm2\n\t" // Load pbelow + "pavgb %%xmm5, %%xmm2\n\t" // Average pabove and pbelow + "pand %%xmm1, %%xmm2\n\t" // Filter out pixels in avg that shouldn't be copied + "pandn %%xmm6, %%xmm1\n\t" // Filter out pixels in pcurrent that should be replaced + + "por %%xmm2, %%xmm1\n\t" // Put the new values in pcurrent + "movntdq %%xmm1, (%0)\n\t" // Write pcurrent + + "sub %4, %0\n\t" // Restore pcurrent to pabove + "sub %4, %1\n\t" // Restore pncurrent to pnabove + + /* Next pixels */ + "add $0x10, %0\n\t" // Add 16 to pcurrent + "add $0x10, %1\n\t" // Add 16 to pncurrent + + /* Check if we reached the row end */ + "cmp %2, %0\n\t" + "jb algo_ssse3_deinterlace_4field_abgr\n\t" // Go for another iteration + + /* Next row */ + "add %4, %0\n\t" // Add width to pcurrent + "add %4, %1\n\t" // Add width to pncurrent + "mov %0, %2\n\t" + "add %4, %2\n\t" // Add width to max_ptr2 + + /* Check if we reached the end */ + "cmp %3, %0\n\t" + "jb algo_ssse3_deinterlace_4field_abgr\n\t" // Go for another iteration + + /* Special case for the last line */ + /* Load pabove into xmm1 and pnabove into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm5\n\t" /* Keep backup of pabove in xmm5 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + "movdqa %%xmm1, %%xmm7\n\t" /* Backup of delta2 in xmm7 for now */ + + /* Next row */ + "add %4, %0\n\t" + "add %4, %1\n\t" + + /* Load pcurrent into xmm1 and pncurrent into xmm2 */ + "movdqa (%0), %%xmm1\n\t" + "movdqa (%1), %%xmm2\n\t" + "movdqa %%xmm1, %%xmm6\n\t" /* Keep backup of pcurrent in xmm6 */ + "psrlq $0x3, %%xmm1\n\t" + "psrlq $0x3, %%xmm2\n\t" + "pand %%xmm4, %%xmm1\n\t" + "pand %%xmm4, %%xmm2\n\t" + "psubb %%xmm2, %%xmm1\n\t" + "pabsb %%xmm1, %%xmm2\n\t" + "movdqa %%xmm2, %%xmm1\n\t" + "punpckldq %%xmm1, %%xmm1\n\t" + "pshufb %%xmm3, %%xmm1\n\t" + "psadbw %%xmm0, %%xmm1\n\t" + "punpckhdq %%xmm2, %%xmm2\n\t" + "pshufb %%xmm3, %%xmm2\n\t" + "psadbw %%xmm0, %%xmm2\n\t" + "packuswb %%xmm2, %%xmm1\n\t" + + "pavgb %%xmm7, %%xmm1\n\t" // Average the two deltas together + +#if defined(__x86_64__) + "pcmpgtd %%xmm8, %%xmm1\n\t" // Compare average delta with the threshold +#else + "movd %%eax, %%xmm7\n\t" // Setup the threshold + "pshufd $0x0, %%xmm7, %%xmm7\n\t" + + "pcmpgtd %%xmm7, %%xmm1\n\t" // Compare average delta with the threshold +#endif + "pand %%xmm1, %%xmm5\n\t" // Filter out pixels in pabove that shouldn't be copied + "pandn %%xmm6, %%xmm1\n\t" // Filter out pixels in pcurrent that should be replaced + + "por %%xmm5, %%xmm1\n\t" // Put the new values in pcurrent + "movntdq %%xmm1, (%0)\n\t" // Write pcurrent + : + : "r" (col1), "r" (col2), "r" (max_ptr2), "r" (max_ptr), "r" (row_width), "m" (threshold_val), "m" (*movemask2) +#if defined(__x86_64__) + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "cc", "memory" +#else + : "%eax", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "cc", "memory" +#endif + ); +} + diff --git a/src/zm_image.h b/src/zm_image.h index b01fb333a..c6ffd2a54 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -47,9 +47,9 @@ extern "C" typedef void (*blend_fptr_t)(const uint8_t*, const uint8_t*, uint8_t*, unsigned long, double); typedef void (*delta_fptr_t)(const uint8_t*, const uint8_t*, uint8_t*, unsigned long); typedef void (*convert_fptr_t)(const uint8_t*, uint8_t*, unsigned long); +typedef void (*deinterlace_4field_fptr_t)(uint8_t*, uint8_t*, unsigned int, unsigned int, unsigned int); typedef void* (*imgbufcpy_fptr_t)(void*, const void*, size_t); - extern imgbufcpy_fptr_t fptr_imgbufcpy; /* Should be called from Image class functions */ @@ -242,6 +242,7 @@ public: void Rotate( int angle ); void Flip( bool leftright ); void Scale( unsigned int factor ); + void Deinterlace_Discard(); void Deinterlace_Linear(); void Deinterlace_Blend(); @@ -292,4 +293,16 @@ void zm_convert_rgb555_rgba(const uint8_t* col1, uint8_t* result, unsigned long void zm_convert_rgb565_rgb(const uint8_t* col1, uint8_t* result, unsigned long count); void zm_convert_rgb565_rgba(const uint8_t* col1, uint8_t* result, unsigned long count); - +/* Deinterlace_4Field functions */ +void std_deinterlace_4field_gray8(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height); +void std_deinterlace_4field_rgb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height); +void std_deinterlace_4field_bgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height); +void std_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height); +void std_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height); +void std_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height); +void std_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height); +void ssse3_deinterlace_4field_gray8(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height); +void ssse3_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height); +void ssse3_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height); +void ssse3_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height); +void ssse3_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height); diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 216b914ab..298ad2b3a 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -2631,6 +2631,21 @@ int Monitor::Capture() if ( captureResult == 1 ) { + + /* Deinterlacing */ + if ( (deinterlacing & 0xff) == 1 ) { + capture_image->Deinterlace_Discard(); + } else if ( (deinterlacing & 0xff) == 2 ) { + capture_image->Deinterlace_Linear(); + } else if ( (deinterlacing & 0xff) == 3 ) { + capture_image->Deinterlace_Blend(); + } else if ( (deinterlacing & 0xff) == 4 ) { + capture_image->Deinterlace_4Field( next_buffer.image, (deinterlacing>>8)&0xff ); + } else if ( (deinterlacing & 0xff) == 5 ) { + capture_image->Deinterlace_Blend_CustomRatio( (deinterlacing>>8)&0xff ); + } + + if ( orientation != ROTATE_0 ) { switch ( orientation ) @@ -2655,19 +2670,6 @@ int Monitor::Capture() } } } - - /* Deinterlacing */ - if ( (deinterlacing & 0xff) == 1 ) { - capture_image->Deinterlace_Discard(); - } else if ( (deinterlacing & 0xff) == 2 ) { - capture_image->Deinterlace_Linear(); - } else if ( (deinterlacing & 0xff) == 3 ) { - capture_image->Deinterlace_Blend(); - } else if ( (deinterlacing & 0xff) == 4 ) { - capture_image->Deinterlace_4Field( next_buffer.image, (deinterlacing>>8)&0xff ); - } else if ( (deinterlacing & 0xff) == 5 ) { - capture_image->Deinterlace_Blend_CustomRatio( (deinterlacing>>8)&0xff ); - } } if ( true ) { diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index e0e3aa295..0170a308f 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -364,11 +364,9 @@ $orientations = array( $deinterlaceopts = array( "Disabled" => 0x00000000, - "Four field motion adaptive - Very Soft" => 0x00003204, /* 50 change */ - "Four field motion adaptive - Soft" => 0x00002804, /* 40 change */ - "Four field motion adaptive - Medium" => 0x00001E04, /* 30 change */ - "Four field motion adaptive - Hard" => 0x00001404, /* 20 change */ - "Four field motion adaptive - Very Hard" => 0x00000A04, /* 10 change */ + "Four field motion adaptive - Soft" => 0x00001E04, /* 30 change */ + "Four field motion adaptive - Medium" => 0x00001404, /* 20 change */ + "Four field motion adaptive - Hard" => 0x00000A04, /* 10 change */ "Discard" => 0x00000001, "Linear" => 0x00000002, "Blend" => 0x00000003, @@ -377,11 +375,9 @@ $deinterlaceopts = array( $deinterlaceopts_v4l2 = array( "Disabled" => 0x00000000, - "Four field motion adaptive - Very Soft" => 0x00003204, /* 50 change */ - "Four field motion adaptive - Soft" => 0x00002804, /* 40 change */ - "Four field motion adaptive - Medium" => 0x00001E04, /* 30 change */ - "Four field motion adaptive - Hard" => 0x00001404, /* 20 change */ - "Four field motion adaptive - Very Hard" => 0x00000A04, /* 10 change */ + "Four field motion adaptive - Soft" => 0x00001E04, /* 30 change */ + "Four field motion adaptive - Medium" => 0x00001404, /* 20 change */ + "Four field motion adaptive - Hard" => 0x00000A04, /* 10 change */ "Discard" => 0x00000001, "Linear" => 0x00000002, "Blend" => 0x00000003, From ed2e3a8ce06c9cbd97a2e1edc1e4a432428c19a5 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 17 Jul 2012 10:36:21 +0300 Subject: [PATCH 55/56] Fixed few compiler errors (unknown registers and such) and modified zm_create.sql to include the new field. --- db/zm_create.sql.in | 1 + src/Makefile.am | 2 +- src/zm_image.cpp | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index cee85f83d..0c48e7ca3 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -332,6 +332,7 @@ CREATE TABLE `Monitors` ( `Colours` tinyint(3) unsigned NOT NULL default '1', `Palette` int(10) unsigned NOT NULL default '0', `Orientation` enum('0','90','180','270','hori','vert') NOT NULL default '0', + `Deinterlacing` int(10) unsigned NOT NULL default '0', `Brightness` mediumint(7) NOT NULL default '-1', `Contrast` mediumint(7) NOT NULL default '-1', `Hue` mediumint(7) NOT NULL default '-1', diff --git a/src/Makefile.am b/src/Makefile.am index 95dca309f..1e971c157 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = gnu -AM_CPPFLAGS = @MYSQL_CFLAGS@ @FFMPEG_CFLAGS@ -Wall -Wno-sign-compare -finline-functions +AM_CPPFLAGS = @MYSQL_CFLAGS@ @FFMPEG_CFLAGS@ -Wall -finline-functions -fomit-frame-pointer -D__STDC_CONSTANT_MACROS #AM_CXXFLAGS = -frepo CLEANFILES = *.rpo diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 8685ffdce..179baf8c8 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -4207,7 +4207,7 @@ __attribute__((noinline)) void zm_convert_rgb565_rgba(const uint8_t* col1, uint8 /************************************************* DEINTERLACE FUNCTIONS *************************************************/ /* Grayscale */ -void std_deinterlace_4field_gray8(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +__attribute__((noinline)) void std_deinterlace_4field_gray8(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const uint8_t* const max_ptr = col1 + (width*(height-1)); @@ -4253,7 +4253,7 @@ void std_deinterlace_4field_gray8(uint8_t* col1, uint8_t* col2, unsigned int thr } /* RGB */ -void std_deinterlace_4field_rgb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +__attribute__((noinline)) void std_deinterlace_4field_rgb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const unsigned int row_width = width*3; @@ -4322,7 +4322,7 @@ void std_deinterlace_4field_rgb(uint8_t* col1, uint8_t* col2, unsigned int thres } /* BGR */ -void std_deinterlace_4field_bgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +__attribute__((noinline)) void std_deinterlace_4field_bgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const unsigned int row_width = width*3; @@ -4391,7 +4391,7 @@ void std_deinterlace_4field_bgr(uint8_t* col1, uint8_t* col2, unsigned int thres } /* RGBA */ -void std_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +__attribute__((noinline)) void std_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const unsigned int row_width = width*4; @@ -4460,7 +4460,7 @@ void std_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int thre } /* BGRA */ -void std_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +__attribute__((noinline)) void std_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const unsigned int row_width = width*4; @@ -4529,7 +4529,7 @@ void std_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int thre } /* ARGB */ -void std_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +__attribute__((noinline)) void std_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const unsigned int row_width = width*4; @@ -4598,7 +4598,7 @@ void std_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int thre } /* ABGR */ -void std_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) +__attribute__((noinline)) void std_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { uint8_t *pcurrent, *pabove, *pncurrent, *pnabove, *pbelow; const unsigned int row_width = width*4; @@ -4667,7 +4667,7 @@ void std_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int thre } /* Grayscale SSSE3 */ -__attribute__ ((noinline)) void ssse3_deinterlace_4field_gray8(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { +__attribute__((noinline,__target__("ssse3"))) void ssse3_deinterlace_4field_gray8(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { union { uint32_t int32; @@ -4758,7 +4758,7 @@ __attribute__ ((noinline)) void ssse3_deinterlace_4field_gray8(uint8_t* col1, ui } /* RGBA SSSE3 */ -__attribute__ ((noinline)) void ssse3_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { +__attribute__((noinline,__target__("ssse3"))) void ssse3_deinterlace_4field_rgba(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { __attribute__((aligned(16))) static const uint8_t movemask2[16] = {1,1,1,1,1,0,0,2,9,9,9,9,9,8,8,10}; const uint32_t threshold_val = threshold; @@ -4934,7 +4934,7 @@ __attribute__ ((noinline)) void ssse3_deinterlace_4field_rgba(uint8_t* col1, uin } /* BGRA SSSE3 */ -__attribute__ ((noinline)) void ssse3_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { +__attribute__((noinline,__target__("ssse3"))) void ssse3_deinterlace_4field_bgra(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { __attribute__((aligned(16))) static const uint8_t movemask2[16] = {1,1,1,1,1,2,2,0,9,9,9,9,9,10,10,8}; const uint32_t threshold_val = threshold; @@ -5110,7 +5110,7 @@ __attribute__ ((noinline)) void ssse3_deinterlace_4field_bgra(uint8_t* col1, uin } /* ARGB SSSE3 */ -__attribute__ ((noinline)) void ssse3_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { +__attribute__((noinline,__target__("ssse3"))) void ssse3_deinterlace_4field_argb(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { __attribute__((aligned(16))) static const uint8_t movemask2[16] = {2,2,2,2,2,1,1,3,10,10,10,10,10,9,9,11}; const uint32_t threshold_val = threshold; @@ -5286,7 +5286,7 @@ __attribute__ ((noinline)) void ssse3_deinterlace_4field_argb(uint8_t* col1, uin } /* ABGR SSSE3 */ -__attribute__ ((noinline)) void ssse3_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { +__attribute__((noinline,__target__("ssse3"))) void ssse3_deinterlace_4field_abgr(uint8_t* col1, uint8_t* col2, unsigned int threshold, unsigned int width, unsigned int height) { __attribute__((aligned(16))) static const uint8_t movemask2[16] = {2,2,2,2,2,3,3,1,10,10,10,10,10,11,11,9}; const uint32_t threshold_val = threshold; From 0ef29743f23202d23984635f714abbbc209d7732 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 17 Jul 2012 12:23:13 +0300 Subject: [PATCH 56/56] Merged the deinterlacing code, although only four field is optimized so far, and is still not working perfectly. 1) Fixed compile errors that may occur when compiling with gcc 4.7 or newer. 2) Modified the check for libavcodec to work correctly with the latest versions of ffmpeg. --- aclocal.m4 | 4 +- configure | 1001 +++++++++++++++++++++++++++-------------------- configure.ac | 4 +- src/Makefile.am | 2 +- src/Makefile.in | 2 +- src/zm_logger.h | 1 + src/zm_thread.h | 1 + 7 files changed, 594 insertions(+), 421 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 61989b26c..bf5bfb06d 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -13,8 +13,8 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],, -[m4_warning([this file was generated for autoconf 2.65. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, +[m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) diff --git a/configure b/configure index 7be00169a..7e4521b66 100755 --- a/configure +++ b/configure @@ -1,13 +1,13 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for zm 1.25.0. +# Generated by GNU Autoconf 2.68 for zm 1.25.0. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -91,6 +91,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -216,11 +217,18 @@ IFS=$as_save_IFS # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. + # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; + esac + exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -320,7 +328,7 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -360,19 +368,19 @@ else fi # as_fn_arith -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -534,7 +542,7 @@ test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` @@ -831,8 +839,9 @@ do fi case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -877,7 +886,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -903,7 +912,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1107,7 +1116,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1123,7 +1132,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1153,8 +1162,8 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) as_fn_error "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information." + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" ;; *=*) @@ -1162,7 +1171,7 @@ Try \`$0 --help' for more information." # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error "invalid variable name: \`$ac_envvar'" ;; + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1172,7 +1181,7 @@ Try \`$0 --help' for more information." $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac @@ -1180,13 +1189,13 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error "missing argument to $ac_option" + as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1209,7 +1218,7 @@ do [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1223,8 +1232,8 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1239,9 +1248,9 @@ test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error "working directory cannot be determined" + as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error "pwd does not report name of working directory" + as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1280,11 +1289,11 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1324,7 +1333,7 @@ Configuration: --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files @@ -1493,9 +1502,9 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF zm configure 1.25.0 -generated by GNU Autoconf 2.65 +generated by GNU Autoconf 2.68 -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1539,7 +1548,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile @@ -1577,7 +1586,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1591,7 +1600,7 @@ ac_fn_cxx_check_type () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" @@ -1632,7 +1641,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_type @@ -1657,7 +1666,7 @@ $as_echo "$ac_try_echo"; } >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } >/dev/null && { + test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : @@ -1668,7 +1677,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp @@ -1710,7 +1719,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_run @@ -1724,7 +1733,7 @@ ac_fn_cxx_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1742,7 +1751,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile @@ -1755,7 +1764,7 @@ ac_fn_cxx_check_member () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 $as_echo_n "checking for $2.$3... " >&6; } -if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$4+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1799,7 +1808,7 @@ fi eval ac_res=\$$4 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_member @@ -1811,10 +1820,10 @@ $as_echo "$ac_res" >&6; } ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -1850,7 +1859,7 @@ if ac_fn_cxx_try_cpp "$LINENO"; then : else ac_header_preproc=no fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } @@ -1873,17 +1882,15 @@ $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} -( cat <<\_ASBOX -## ------------------------------------------------------------------------- ## +( $as_echo "## ------------------------------------------------------------------------- ## ## Report this to http://www.zoneminder.com/forums/ - Please check FAQ first ## -## ------------------------------------------------------------------------- ## -_ASBOX +## ------------------------------------------------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -1892,7 +1899,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_mongrel @@ -1937,7 +1944,7 @@ fi # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link @@ -1950,7 +1957,7 @@ ac_fn_cxx_check_func () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2005,19 +2012,22 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_func -# ac_fn_cxx_check_decl LINENO SYMBOL VAR -# -------------------------------------- -# Tests whether SYMBOL is declared, setting cache variable VAR accordingly. +# ac_fn_cxx_check_decl LINENO SYMBOL VAR INCLUDES +# ----------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. ac_fn_cxx_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5 -$as_echo_n "checking whether $2 is declared... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + as_decl_name=`echo $2|sed 's/ *(.*//'` + as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2026,8 +2036,12 @@ $4 int main () { -#ifndef $2 - (void) $2; +#ifndef $as_decl_name +#ifdef __cplusplus + (void) $as_decl_use; +#else + (void) $as_decl_name; +#endif #endif ; @@ -2044,7 +2058,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_decl cat >config.log <<_ACEOF @@ -2052,7 +2066,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by zm $as_me 1.25.0, which was -generated by GNU Autoconf 2.65. Invocation command line was +generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2162,11 +2176,9 @@ trap 'exit_status=$? { echo - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## -## ---------------- ## -_ASBOX +## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( @@ -2200,11 +2212,9 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; ) echo - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## -## ----------------- ## -_ASBOX +## ----------------- ##" echo for ac_var in $ac_subst_vars do @@ -2217,11 +2227,9 @@ _ASBOX echo if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## -## ------------------- ## -_ASBOX +## ------------------- ##" echo for ac_var in $ac_subst_files do @@ -2235,11 +2243,9 @@ _ASBOX fi if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## -## ----------- ## -_ASBOX +## ----------- ##" echo cat confdefs.h echo @@ -2294,7 +2300,12 @@ _ACEOF ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -2309,7 +2320,11 @@ do { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } fi done @@ -2388,7 +2403,7 @@ if $ac_cache_corrupted; then $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## @@ -2405,16 +2420,22 @@ am__api_version='1.11' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/$ac_t -c" - break 2 - fi - done + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi done if test -z "$ac_aux_dir"; then - as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -2443,7 +2464,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then : +if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -2530,11 +2551,11 @@ am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) - as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; + as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's @@ -2556,7 +2577,7 @@ if ( # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". - as_fn_error "ls -t appears to fail. Make sure there is not a broken + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi @@ -2566,7 +2587,7 @@ then # Ok. : else - as_fn_error "newly created file is older than distributed files! + as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 @@ -2620,7 +2641,7 @@ if test "$cross_compiling" != no; then set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then : +if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -2660,7 +2681,7 @@ if test -z "$ac_cv_prog_STRIP"; then set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -2713,7 +2734,7 @@ INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then - if test "${ac_cv_path_mkdir+set}" = set; then : + if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -2764,7 +2785,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then : +if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -2804,7 +2825,7 @@ done $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF @@ -2812,7 +2833,7 @@ SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; @@ -2846,7 +2867,7 @@ if test "`cd $srcdir && pwd`" != "`pwd`"; then am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then - as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi @@ -3027,7 +3048,7 @@ fi FFMPEG_LIBS="-L${FFMPEG_PREFIX}/${LIB_ARCH}" -FFMPEG_CFLAGS="-I${FFMPEG_PREFIX}/include" +FFMPEG_CFLAGS="-I${FFMPEG_PREFIX}/include -D__STDC_CONSTANT_MACROS" @@ -3065,7 +3086,7 @@ LDFLAGS="$LDFLAGS ${EXTRA_LIBS}" if test "${with_webdir+set}" = set; then : withval=$with_webdir; WEB_PREFIX=$with_webdir else - as_fn_error "You must call configure with the --with-webdir option. + as_fn_error $? "You must call configure with the --with-webdir option. This tells configure where to install PHP and web files and scripts. e.g. --with-webdir=/var/www/html or --with-webdir=/www/vhtdocs/" "$LINENO" 5 @@ -3078,7 +3099,7 @@ fi if test "${with_cgidir+set}" = set; then : withval=$with_cgidir; CGI_PREFIX=$with_cgidir else - as_fn_error "You must call configure with the --with-cgidir option. + as_fn_error $? "You must call configure with the --with-cgidir option. This tells configure where to install cgi files and scripts. e.g. --with-cgidir=/var/www/cgi-bin or --with-webdir=/www/vhtdocs//cgi-bin" "$LINENO" 5 @@ -3249,7 +3270,7 @@ if test -z "$CXX"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CXX+set}" = set; then : +if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then @@ -3293,7 +3314,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : +if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then @@ -3456,9 +3477,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "C++ compiler cannot create executables -See \`config.log' for more details." "$LINENO" 5; }; } +as_fn_error 77 "C++ compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -3500,8 +3520,8 @@ done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -3558,9 +3578,9 @@ $as_echo "$ac_try_echo"; } >&5 else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run C++ compiled programs. +as_fn_error $? "cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } fi fi fi @@ -3571,7 +3591,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : +if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3611,8 +3631,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of object files: cannot compile -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -3622,7 +3642,7 @@ OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : +if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3659,7 +3679,7 @@ ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } -if test "${ac_cv_prog_cxx_g+set}" = set; then : +if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag @@ -3807,7 +3827,7 @@ depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } -if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then : +if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then @@ -3940,7 +3960,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3980,7 +4000,7 @@ if test -z "$ac_cv_prog_CC"; then set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -4033,7 +4053,7 @@ if test -z "$CC"; then set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -4073,7 +4093,7 @@ if test -z "$CC"; then set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -4132,7 +4152,7 @@ if test -z "$CC"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -4176,7 +4196,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -4230,8 +4250,8 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "no acceptable C compiler found in \$PATH -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -4260,7 +4280,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : +if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -4297,7 +4317,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : +if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -4375,7 +4395,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : +if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -4474,7 +4494,7 @@ depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } -if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then : +if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then @@ -4614,7 +4634,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_RANLIB+set}" = set; then : +if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then @@ -4654,7 +4674,7 @@ if test -z "$ac_cv_prog_RANLIB"; then set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then @@ -4705,7 +4725,7 @@ fi $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF @@ -4713,7 +4733,7 @@ SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; @@ -4743,7 +4763,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then - if test "${ac_cv_prog_CXXCPP+set}" = set; then : + if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded @@ -4773,7 +4793,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -4789,11 +4809,11 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi @@ -4832,7 +4852,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -4848,18 +4868,18 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=cpp @@ -4871,7 +4891,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : +if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -4920,7 +4940,7 @@ esac done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then - as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP @@ -4934,7 +4954,7 @@ $as_echo "$ac_cv_path_GREP" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : +if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -4986,7 +5006,7 @@ esac done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then - as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP @@ -5001,7 +5021,7 @@ $as_echo "$ac_cv_path_EGREP" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5118,8 +5138,7 @@ do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -5131,7 +5150,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } -if test "${ac_cv_header_stdbool_h+set}" = set; then : +if ${ac_cv_header_stdbool_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5163,7 +5182,7 @@ else char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; - bool e = &s; + /* See body of main program for 'e'. */ char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; @@ -5174,25 +5193,6 @@ else _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; -# if defined __xlc__ || defined __GNUC__ - /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 - reported by James Lemley on 2005-10-05; see - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - This test is not quite right, since xlc is allowed to - reject this program, as the initializer for xlcbug is - not one of the forms that C requires support for. - However, doing the test right would require a runtime - test, and that would make cross-compilation harder. - Let us hope that IBM fixes the xlc bug, and also adds - support for this kind of constant expression. In the - meantime, this test will reject xlc, which is OK, since - our stdbool.h substitute should suffice. We also test - this with GCC, where it should work, to detect more - quickly whether someone messes up the test in the - future. */ - char digs[] = "0123456789"; - int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); -# endif /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html @@ -5204,6 +5204,7 @@ int main () { + bool e = &s; *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ @@ -5224,7 +5225,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } ac_fn_cxx_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" -if test "x$ac_cv_type__Bool" = x""yes; then : +if test "x$ac_cv_type__Bool" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 @@ -5241,7 +5242,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if test "${ac_cv_c_const+set}" = set; then : +if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5321,7 +5322,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 $as_echo_n "checking for uid_t in sys/types.h... " >&6; } -if test "${ac_cv_type_uid_t+set}" = set; then : +if ${ac_cv_type_uid_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5351,7 +5352,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } -if test "${ac_cv_c_inline+set}" = set; then : +if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no @@ -5392,7 +5393,7 @@ _ACEOF esac ac_fn_cxx_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" -if test "x$ac_cv_type_mode_t" = x""yes; then : +if test "x$ac_cv_type_mode_t" = xyes; then : else @@ -5403,7 +5404,7 @@ _ACEOF fi ac_fn_cxx_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = x""yes; then : +if test "x$ac_cv_type_size_t" = xyes; then : else @@ -5415,7 +5416,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } -if test "${ac_cv_header_time+set}" = set; then : +if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5450,7 +5451,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } -if test "${ac_cv_struct_tm+set}" = set; then : +if ${ac_cv_struct_tm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5485,7 +5486,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } -if test "${ac_cv_type_signal+set}" = set; then : +if ${ac_cv_type_signal+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5519,7 +5520,7 @@ _ACEOF ac_fn_cxx_check_type "$LINENO" "siginfo_t" "ac_cv_type_siginfo_t" "#include " -if test "x$ac_cv_type_siginfo_t" = x""yes; then : +if test "x$ac_cv_type_siginfo_t" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SIGINFO_T 1 @@ -5530,7 +5531,7 @@ fi ac_fn_cxx_check_type "$LINENO" "struct sigcontext" "ac_cv_type_struct_sigcontext" "#include " -if test "x$ac_cv_type_struct_sigcontext" = x""yes; then : +if test "x$ac_cv_type_struct_sigcontext" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_SIGCONTEXT 1 @@ -5541,7 +5542,7 @@ fi ac_fn_cxx_check_member "$LINENO" "struct sigcontext" "eip" "ac_cv_member_struct_sigcontext_eip" "#include " -if test "x$ac_cv_member_struct_sigcontext_eip" = x""yes; then : +if test "x$ac_cv_member_struct_sigcontext_eip" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_SIGCONTEXT_EIP 1 @@ -5552,7 +5553,7 @@ fi ac_fn_cxx_check_type "$LINENO" "ucontext_t" "ac_cv_type_ucontext_t" "#include " -if test "x$ac_cv_type_ucontext_t" = x""yes; then : +if test "x$ac_cv_type_ucontext_t" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_UCONTEXT_T 1 @@ -5566,7 +5567,7 @@ fi if test $ac_cv_c_compiler_gnu = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 $as_echo_n "checking whether $CC needs -traditional... " >&6; } -if test "${ac_cv_prog_gcc_traditional+set}" = set; then : +if ${ac_cv_prog_gcc_traditional+:} false; then : $as_echo_n "(cached) " >&6 else ac_pattern="Autoconf.*'x'" @@ -5608,7 +5609,7 @@ fi for ac_header in stdlib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" -if test "x$ac_cv_header_stdlib_h" = x""yes; then : +if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF @@ -5619,7 +5620,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 $as_echo_n "checking for GNU libc compatible malloc... " >&6; } -if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then : +if ${ac_cv_func_malloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -5680,8 +5681,7 @@ do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -5700,7 +5700,7 @@ done for ac_func in getpagesize do : ac_fn_cxx_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize" -if test "x$ac_cv_func_getpagesize" = x""yes; then : +if test "x$ac_cv_func_getpagesize" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETPAGESIZE 1 _ACEOF @@ -5710,7 +5710,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5 $as_echo_n "checking for working mmap... " >&6; } -if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then : +if ${ac_cv_func_mmap_fixed_mapped+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -5787,6 +5787,7 @@ int main () { char *data, *data2, *data3; + const char *cdata2; int i, pagesize; int fd, fd2; @@ -5811,10 +5812,10 @@ main () fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600); if (fd2 < 0) return 4; - data2 = ""; - if (write (fd2, data2, 1) != 1) + cdata2 = ""; + if (write (fd2, cdata2, 1) != 1) return 5; - data2 = mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L); + data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L); if (data2 == MAP_FAILED) return 6; for (i = 0; i < pagesize; ++i) @@ -5877,8 +5878,7 @@ for ac_header in sys/select.h sys/socket.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -5889,7 +5889,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for select" >&5 $as_echo_n "checking types of arguments for select... " >&6; } -if test "${ac_cv_func_select_args+set}" = set; then : +if ${ac_cv_func_select_args+:} false; then : $as_echo_n "(cached) " >&6 else for ac_arg234 in 'fd_set *' 'int *' 'void *'; do @@ -5923,7 +5923,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done done # Provide a safe default value. -: ${ac_cv_func_select_args='int,int *,struct timeval *'} +: "${ac_cv_func_select_args=int,int *,struct timeval *}" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_select_args" >&5 @@ -5951,7 +5951,7 @@ rm -f conftest* { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat correctly handles trailing slash" >&5 $as_echo_n "checking whether lstat correctly handles trailing slash... " >&6; } -if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then : +if ${ac_cv_func_lstat_dereferences_slashed_symlink+:} false; then : $as_echo_n "(cached) " >&6 else rm -f conftest.sym conftest.file @@ -6013,7 +6013,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat accepts an empty string" >&5 $as_echo_n "checking whether stat accepts an empty string... " >&6; } -if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then : +if ${ac_cv_func_stat_empty_string_bug+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -6060,7 +6060,7 @@ fi for ac_func in strftime do : ac_fn_cxx_check_func "$LINENO" "strftime" "ac_cv_func_strftime" -if test "x$ac_cv_func_strftime" = x""yes; then : +if test "x$ac_cv_func_strftime" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRFTIME 1 _ACEOF @@ -6069,7 +6069,7 @@ else # strftime is in -lintl on SCO UNIX. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for strftime in -lintl" >&5 $as_echo_n "checking for strftime in -lintl... " >&6; } -if test "${ac_cv_lib_intl_strftime+set}" = set; then : +if ${ac_cv_lib_intl_strftime+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6103,7 +6103,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_strftime" >&5 $as_echo "$ac_cv_lib_intl_strftime" >&6; } -if test "x$ac_cv_lib_intl_strftime" = x""yes; then : +if test "x$ac_cv_lib_intl_strftime" = xyes; then : $as_echo "#define HAVE_STRFTIME 1" >>confdefs.h LIBS="-lintl $LIBS" @@ -6114,7 +6114,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strtod" >&5 $as_echo_n "checking for working strtod... " >&6; } -if test "${ac_cv_func_strtod+set}" = set; then : +if ${ac_cv_func_strtod+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -6173,14 +6173,14 @@ if test $ac_cv_func_strtod = no; then esac ac_fn_cxx_check_func "$LINENO" "pow" "ac_cv_func_pow" -if test "x$ac_cv_func_pow" = x""yes; then : +if test "x$ac_cv_func_pow" = xyes; then : fi if test $ac_cv_func_pow = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 $as_echo_n "checking for pow in -lm... " >&6; } -if test "${ac_cv_lib_m_pow+set}" = set; then : +if ${ac_cv_lib_m_pow+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6214,7 +6214,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 $as_echo "$ac_cv_lib_m_pow" >&6; } -if test "x$ac_cv_lib_m_pow" = x""yes; then : +if test "x$ac_cv_lib_m_pow" = xyes; then : POW_LIB=-lm else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find library containing definition of pow" >&5 @@ -6228,13 +6228,13 @@ fi for ac_func in vprintf do : ac_fn_cxx_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" -if test "x$ac_cv_func_vprintf" = x""yes; then : +if test "x$ac_cv_func_vprintf" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VPRINTF 1 _ACEOF ac_fn_cxx_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" -if test "x$ac_cv_func__doprnt" = x""yes; then : +if test "x$ac_cv_func__doprnt" = xyes; then : $as_echo "#define HAVE_DOPRNT 1" >>confdefs.h @@ -6248,8 +6248,7 @@ for ac_func in gethostbyname gethostname gettimeofday memmove memset mkdir munma do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -6261,8 +6260,7 @@ for ac_func in syscall sleep usleep ioctl ioctlsocket sigaction do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -6276,7 +6274,7 @@ done set dummy ffmpeg; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OPT_FFMPEG+set}" = set; then : +if ${ac_cv_prog_OPT_FFMPEG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OPT_FFMPEG"; then @@ -6314,7 +6312,7 @@ fi set dummy ffmpeg; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PATH_FFMPEG+set}" = set; then : +if ${ac_cv_path_PATH_FFMPEG+:} false; then : $as_echo_n "(cached) " >&6 else case $PATH_FFMPEG in @@ -6354,7 +6352,7 @@ fi set dummy pnmscale; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OPT_NETPBM+set}" = set; then : +if ${ac_cv_prog_OPT_NETPBM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OPT_NETPBM"; then @@ -6392,7 +6390,7 @@ fi set dummy pnmscale; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PATH_NETPBM+set}" = set; then : +if ${ac_cv_path_PATH_NETPBM+:} false; then : $as_echo_n "(cached) " >&6 else case $PATH_NETPBM in @@ -6435,7 +6433,7 @@ fi # Checks for libraries. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql_init in -lmysqlclient" >&5 $as_echo_n "checking for mysql_init in -lmysqlclient... " >&6; } -if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then : +if ${ac_cv_lib_mysqlclient_mysql_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6469,7 +6467,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mysqlclient_mysql_init" >&5 $as_echo "$ac_cv_lib_mysqlclient_mysql_init" >&6; } -if test "x$ac_cv_lib_mysqlclient_mysql_init" = x""yes; then : +if test "x$ac_cv_lib_mysqlclient_mysql_init" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBMYSQLCLIENT 1 _ACEOF @@ -6477,12 +6475,12 @@ _ACEOF LIBS="-lmysqlclient $LIBS" else - as_fn_error "zm requires libmysqlclient.a" "$LINENO" 5 + as_fn_error $? "zm requires libmysqlclient.a" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_start_compress in -ljpeg" >&5 $as_echo_n "checking for jpeg_start_compress in -ljpeg... " >&6; } -if test "${ac_cv_lib_jpeg_jpeg_start_compress+set}" = set; then : +if ${ac_cv_lib_jpeg_jpeg_start_compress+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6516,7 +6514,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_start_compress" >&5 $as_echo "$ac_cv_lib_jpeg_jpeg_start_compress" >&6; } -if test "x$ac_cv_lib_jpeg_jpeg_start_compress" = x""yes; then : +if test "x$ac_cv_lib_jpeg_jpeg_start_compress" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBJPEG 1 _ACEOF @@ -6524,12 +6522,12 @@ _ACEOF LIBS="-ljpeg $LIBS" else - as_fn_error "zm requires libjpeg.a" "$LINENO" 5 + as_fn_error $? "zm requires libjpeg.a" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 $as_echo_n "checking for pthread_create in -lpthread... " >&6; } -if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then : +if ${ac_cv_lib_pthread_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6563,7 +6561,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 $as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } -if test "x$ac_cv_lib_pthread_pthread_create" = x""yes; then : +if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPTHREAD 1 _ACEOF @@ -6571,12 +6569,12 @@ _ACEOF LIBS="-lpthread $LIBS" else - as_fn_error "zm requires libpthread.a" "$LINENO" 5 + as_fn_error $? "zm requires libpthread.a" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlsym in -ldl" >&5 $as_echo_n "checking for dlsym in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlsym+set}" = set; then : +if ${ac_cv_lib_dl_dlsym+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6610,7 +6608,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlsym" >&5 $as_echo "$ac_cv_lib_dl_dlsym" >&6; } -if test "x$ac_cv_lib_dl_dlsym" = x""yes; then : +if test "x$ac_cv_lib_dl_dlsym" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF @@ -6618,13 +6616,13 @@ _ACEOF LIBS="-ldl $LIBS" else - as_fn_error "zm requires libdl.a" "$LINENO" 5 + as_fn_error $? "zm requires libdl.a" "$LINENO" 5 fi if test "$ZM_SSL_LIB" == "openssl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5 in -lcrypto" >&5 $as_echo_n "checking for MD5 in -lcrypto... " >&6; } -if test "${ac_cv_lib_crypto_MD5+set}" = set; then : +if ${ac_cv_lib_crypto_MD5+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6658,7 +6656,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_MD5" >&5 $as_echo "$ac_cv_lib_crypto_MD5" >&6; } -if test "x$ac_cv_lib_crypto_MD5" = x""yes; then : +if test "x$ac_cv_lib_crypto_MD5" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBCRYPTO 1 _ACEOF @@ -6674,7 +6672,7 @@ else for ac_header in gcrypt.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "gcrypt.h" "ac_cv_header_gcrypt_h" "$ac_includes_default" -if test "x$ac_cv_header_gcrypt_h" = x""yes; then : +if test "x$ac_cv_header_gcrypt_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GCRYPT_H 1 _ACEOF @@ -6688,7 +6686,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcry_check_version in -lgcrypt" >&5 $as_echo_n "checking for gcry_check_version in -lgcrypt... " >&6; } -if test "${ac_cv_lib_gcrypt_gcry_check_version+set}" = set; then : +if ${ac_cv_lib_gcrypt_gcry_check_version+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6722,7 +6720,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gcrypt_gcry_check_version" >&5 $as_echo "$ac_cv_lib_gcrypt_gcry_check_version" >&6; } -if test "x$ac_cv_lib_gcrypt_gcry_check_version" = x""yes; then : +if test "x$ac_cv_lib_gcrypt_gcry_check_version" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBGCRYPT 1 _ACEOF @@ -6736,7 +6734,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5 in -lgnutls-openssl" >&5 $as_echo_n "checking for MD5 in -lgnutls-openssl... " >&6; } -if test "${ac_cv_lib_gnutls_openssl_MD5+set}" = set; then : +if ${ac_cv_lib_gnutls_openssl_MD5+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6770,7 +6768,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gnutls_openssl_MD5" >&5 $as_echo "$ac_cv_lib_gnutls_openssl_MD5" >&6; } -if test "x$ac_cv_lib_gnutls_openssl_MD5" = x""yes; then : +if test "x$ac_cv_lib_gnutls_openssl_MD5" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBGNUTLS_OPENSSL 1 _ACEOF @@ -6785,7 +6783,7 @@ fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre_compile in -lpcre" >&5 $as_echo_n "checking for pcre_compile in -lpcre... " >&6; } -if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then : +if ${ac_cv_lib_pcre_pcre_compile+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6819,7 +6817,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcre_pcre_compile" >&5 $as_echo "$ac_cv_lib_pcre_pcre_compile" >&6; } -if test "x$ac_cv_lib_pcre_pcre_compile" = x""yes; then : +if test "x$ac_cv_lib_pcre_pcre_compile" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPCRE 1 _ACEOF @@ -6833,7 +6831,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlibVersion in -lz" >&5 $as_echo_n "checking for zlibVersion in -lz... " >&6; } -if test "${ac_cv_lib_z_zlibVersion+set}" = set; then : +if ${ac_cv_lib_z_zlibVersion+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6867,7 +6865,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_zlibVersion" >&5 $as_echo "$ac_cv_lib_z_zlibVersion" >&6; } -if test "x$ac_cv_lib_z_zlibVersion" = x""yes; then : +if test "x$ac_cv_lib_z_zlibVersion" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBZ 1 _ACEOF @@ -6878,7 +6876,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for x264_predict_16x16_init in -lx264" >&5 $as_echo_n "checking for x264_predict_16x16_init in -lx264... " >&6; } -if test "${ac_cv_lib_x264_x264_predict_16x16_init+set}" = set; then : +if ${ac_cv_lib_x264_x264_predict_16x16_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6912,7 +6910,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_x264_x264_predict_16x16_init" >&5 $as_echo "$ac_cv_lib_x264_x264_predict_16x16_init" >&6; } -if test "x$ac_cv_lib_x264_x264_predict_16x16_init" = x""yes; then : +if test "x$ac_cv_lib_x264_x264_predict_16x16_init" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBX264 1 _ACEOF @@ -6923,7 +6921,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_malloc in -lavutil" >&5 $as_echo_n "checking for av_malloc in -lavutil... " >&6; } -if test "${ac_cv_lib_avutil_av_malloc+set}" = set; then : +if ${ac_cv_lib_avutil_av_malloc+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -6957,7 +6955,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avutil_av_malloc" >&5 $as_echo "$ac_cv_lib_avutil_av_malloc" >&6; } -if test "x$ac_cv_lib_avutil_av_malloc" = x""yes; then : +if test "x$ac_cv_lib_avutil_av_malloc" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBAVUTIL 1 _ACEOF @@ -6972,7 +6970,7 @@ fi # Don't bother to warn about this one { $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_image_copy in -lavcore" >&5 $as_echo_n "checking for av_image_copy in -lavcore... " >&6; } -if test "${ac_cv_lib_avcore_av_image_copy+set}" = set; then : +if ${ac_cv_lib_avcore_av_image_copy+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -7006,7 +7004,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avcore_av_image_copy" >&5 $as_echo "$ac_cv_lib_avcore_av_image_copy" >&6; } -if test "x$ac_cv_lib_avcore_av_image_copy" = x""yes; then : +if test "x$ac_cv_lib_avcore_av_image_copy" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBAVCORE 1 _ACEOF @@ -7015,9 +7013,9 @@ _ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for avcodec_init in -lavcodec" >&5 -$as_echo_n "checking for avcodec_init in -lavcodec... " >&6; } -if test "${ac_cv_lib_avcodec_avcodec_init+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for avcodec_open in -lavcodec" >&5 +$as_echo_n "checking for avcodec_open in -lavcodec... " >&6; } +if ${ac_cv_lib_avcodec_avcodec_open+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -7031,27 +7029,27 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char avcodec_init (); +char avcodec_open (); int main () { -return avcodec_init (); +return avcodec_open (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_avcodec_avcodec_init=yes + ac_cv_lib_avcodec_avcodec_open=yes else - ac_cv_lib_avcodec_avcodec_init=no + ac_cv_lib_avcodec_avcodec_open=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avcodec_avcodec_init" >&5 -$as_echo "$ac_cv_lib_avcodec_avcodec_init" >&6; } -if test "x$ac_cv_lib_avcodec_avcodec_init" = x""yes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avcodec_avcodec_open" >&5 +$as_echo "$ac_cv_lib_avcodec_avcodec_open" >&6; } +if test "x$ac_cv_lib_avcodec_avcodec_open" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBAVCODEC 1 _ACEOF @@ -7065,7 +7063,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_new_stream in -lavformat" >&5 $as_echo_n "checking for av_new_stream in -lavformat... " >&6; } -if test "${ac_cv_lib_avformat_av_new_stream+set}" = set; then : +if ${ac_cv_lib_avformat_av_new_stream+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -7099,7 +7097,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avformat_av_new_stream" >&5 $as_echo "$ac_cv_lib_avformat_av_new_stream" >&6; } -if test "x$ac_cv_lib_avformat_av_new_stream" = x""yes; then : +if test "x$ac_cv_lib_avformat_av_new_stream" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBAVFORMAT 1 _ACEOF @@ -7113,7 +7111,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for avdevice_register_all in -lavdevice" >&5 $as_echo_n "checking for avdevice_register_all in -lavdevice... " >&6; } -if test "${ac_cv_lib_avdevice_avdevice_register_all+set}" = set; then : +if ${ac_cv_lib_avdevice_avdevice_register_all+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -7147,7 +7145,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avdevice_avdevice_register_all" >&5 $as_echo "$ac_cv_lib_avdevice_avdevice_register_all" >&6; } -if test "x$ac_cv_lib_avdevice_avdevice_register_all" = x""yes; then : +if test "x$ac_cv_lib_avdevice_avdevice_register_all" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBAVDEVICE 1 _ACEOF @@ -7161,7 +7159,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sws_scale in -lswscale" >&5 $as_echo_n "checking for sws_scale in -lswscale... " >&6; } -if test "${ac_cv_lib_swscale_sws_scale+set}" = set; then : +if ${ac_cv_lib_swscale_sws_scale+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -7195,7 +7193,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_swscale_sws_scale" >&5 $as_echo "$ac_cv_lib_swscale_sws_scale" >&6; } -if test "x$ac_cv_lib_swscale_sws_scale" = x""yes; then : +if test "x$ac_cv_lib_swscale_sws_scale" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSWSCALE 1 _ACEOF @@ -7206,7 +7204,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -lbz2" >&5 $as_echo_n "checking for BZ2_bzCompress in -lbz2... " >&6; } -if test "${ac_cv_lib_bz2_BZ2_bzCompress+set}" = set; then : +if ${ac_cv_lib_bz2_BZ2_bzCompress+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -7240,7 +7238,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzCompress" >&5 $as_echo "$ac_cv_lib_bz2_BZ2_bzCompress" >&6; } -if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = x""yes; then : +if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBBZ2 1 _ACEOF @@ -7254,7 +7252,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compress in -lz" >&5 $as_echo_n "checking for compress in -lz... " >&6; } -if test "${ac_cv_lib_z_compress+set}" = set; then : +if ${ac_cv_lib_z_compress+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -7288,7 +7286,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5 $as_echo "$ac_cv_lib_z_compress" >&6; } -if test "x$ac_cv_lib_z_compress" = x""yes; then : +if test "x$ac_cv_lib_z_compress" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBZ 1 _ACEOF @@ -7303,7 +7301,7 @@ fi # for constant arguments. Useless! { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 $as_echo_n "checking for working alloca.h... " >&6; } -if test "${ac_cv_working_alloca_h+set}" = set; then : +if ${ac_cv_working_alloca_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7336,7 +7334,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 $as_echo_n "checking for alloca... " >&6; } -if test "${ac_cv_func_alloca_works+set}" = set; then : +if ${ac_cv_func_alloca_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7355,7 +7353,7 @@ else #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); +void *alloca (size_t); # endif # endif # endif @@ -7399,7 +7397,7 @@ $as_echo "#define C_ALLOCA 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 $as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } -if test "${ac_cv_os_cray+set}" = set; then : +if ${ac_cv_os_cray+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7426,8 +7424,7 @@ if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define CRAY_STACKSEG_END $ac_func @@ -7441,7 +7438,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 $as_echo_n "checking stack direction for C alloca... " >&6; } -if test "${ac_cv_c_stack_direction+set}" = set; then : +if ${ac_cv_c_stack_direction+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -7491,7 +7488,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7605,8 +7602,7 @@ for ac_header in fcntl.h limits.h memory.h stddef.h stdlib.h string.h strings.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7619,8 +7615,7 @@ for ac_header in netdb.h netinet/in.h arpa/inet.h sys/ioctl.h sys/socket.h sys/u do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7632,7 +7627,7 @@ done for ac_header in execinfo.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "execinfo.h" "ac_cv_header_execinfo_h" "$ac_includes_default" -if test "x$ac_cv_header_execinfo_h" = x""yes; then : +if test "x$ac_cv_header_execinfo_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_EXECINFO_H 1 _ACEOF @@ -7644,7 +7639,7 @@ done for ac_header in syscall.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "syscall.h" "ac_cv_header_syscall_h" "$ac_includes_default" -if test "x$ac_cv_header_syscall_h" = x""yes; then : +if test "x$ac_cv_header_syscall_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYSCALL_H 1 _ACEOF @@ -7656,7 +7651,7 @@ done for ac_header in pthread.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" -if test "x$ac_cv_header_pthread_h" = x""yes; then : +if test "x$ac_cv_header_pthread_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTHREAD_H 1 _ACEOF @@ -7668,7 +7663,7 @@ done for ac_header in linux/videodev.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "linux/videodev.h" "ac_cv_header_linux_videodev_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_videodev_h" = x""yes; then : +if test "x$ac_cv_header_linux_videodev_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_VIDEODEV_H 1 _ACEOF @@ -7684,7 +7679,7 @@ done for ac_header in linux/videodev2.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "linux/videodev2.h" "ac_cv_header_linux_videodev2_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_videodev2_h" = x""yes; then : +if test "x$ac_cv_header_linux_videodev2_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LINUX_VIDEODEV2_H 1 _ACEOF @@ -7709,13 +7704,13 @@ fi for ac_header in jpeglib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "jpeglib.h" "ac_cv_header_jpeglib_h" "$ac_includes_default" -if test "x$ac_cv_header_jpeglib_h" = x""yes; then : +if test "x$ac_cv_header_jpeglib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_JPEGLIB_H 1 _ACEOF else - as_fn_error "zm requires libjpeg headers to be installed" "$LINENO" 5 + as_fn_error $? "zm requires libjpeg headers to be installed" "$LINENO" 5 fi done @@ -7723,13 +7718,13 @@ done for ac_header in mysql/mysql.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "mysql/mysql.h" "ac_cv_header_mysql_mysql_h" "$ac_includes_default" -if test "x$ac_cv_header_mysql_mysql_h" = x""yes; then : +if test "x$ac_cv_header_mysql_mysql_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MYSQL_MYSQL_H 1 _ACEOF else - as_fn_error "zm requires MySQL headers - check that MySQL development packages are installed" "$LINENO" 5 + as_fn_error $? "zm requires MySQL headers - check that MySQL development packages are installed" "$LINENO" 5 fi done @@ -7737,7 +7732,7 @@ done for ac_header in libavutil/avutil.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "libavutil/avutil.h" "ac_cv_header_libavutil_avutil_h" "$ac_includes_default" -if test "x$ac_cv_header_libavutil_avutil_h" = x""yes; then : +if test "x$ac_cv_header_libavutil_avutil_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBAVUTIL_AVUTIL_H 1 _ACEOF @@ -7749,7 +7744,7 @@ done for ac_header in libavcodec/avcodec.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "libavcodec/avcodec.h" "ac_cv_header_libavcodec_avcodec_h" "$ac_includes_default" -if test "x$ac_cv_header_libavcodec_avcodec_h" = x""yes; then : +if test "x$ac_cv_header_libavcodec_avcodec_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBAVCODEC_AVCODEC_H 1 _ACEOF @@ -7761,7 +7756,7 @@ done for ac_header in libavformat/avformat.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "libavformat/avformat.h" "ac_cv_header_libavformat_avformat_h" "$ac_includes_default" -if test "x$ac_cv_header_libavformat_avformat_h" = x""yes; then : +if test "x$ac_cv_header_libavformat_avformat_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBAVFORMAT_AVFORMAT_H 1 _ACEOF @@ -7773,7 +7768,7 @@ done for ac_header in libswscale/swscale.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "libswscale/swscale.h" "ac_cv_header_libswscale_swscale_h" "$ac_includes_default" -if test "x$ac_cv_header_libswscale_swscale_h" = x""yes; then : +if test "x$ac_cv_header_libswscale_swscale_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSWSCALE_SWSCALE_H 1 _ACEOF @@ -7785,7 +7780,7 @@ done for ac_header in pcre/pcre.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "pcre/pcre.h" "ac_cv_header_pcre_pcre_h" "$ac_includes_default" -if test "x$ac_cv_header_pcre_pcre_h" = x""yes; then : +if test "x$ac_cv_header_pcre_pcre_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCRE_PCRE_H 1 _ACEOF @@ -7798,7 +7793,7 @@ done for ac_header in pcre.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "pcre.h" "ac_cv_header_pcre_h" "$ac_includes_default" -if test "x$ac_cv_header_pcre_h" = x""yes; then : +if test "x$ac_cv_header_pcre_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCRE_H 1 _ACEOF @@ -7812,7 +7807,7 @@ if test "$ENABLE_MMAP" == "yes"; then for ac_header in sys/mman.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_mman_h" = x""yes; then : +if test "x$ac_cv_header_sys_mman_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_MMAN_H 1 _ACEOF @@ -7824,7 +7819,7 @@ done for ac_header in fcntl.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "fcntl.h" "ac_cv_header_fcntl_h" "$ac_includes_default" -if test "x$ac_cv_header_fcntl_h" = x""yes; then : +if test "x$ac_cv_header_fcntl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_FCNTL_H 1 _ACEOF @@ -7837,7 +7832,7 @@ else for ac_header in sys/ipc.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "sys/ipc.h" "ac_cv_header_sys_ipc_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_ipc_h" = x""yes; then : +if test "x$ac_cv_header_sys_ipc_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_IPC_H 1 _ACEOF @@ -7849,7 +7844,7 @@ done for ac_header in sys/shm.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "sys/shm.h" "ac_cv_header_sys_shm_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_shm_h" = x""yes; then : +if test "x$ac_cv_header_sys_shm_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SHM_H 1 _ACEOF @@ -7862,7 +7857,7 @@ fi for ac_header in zlib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" -if test "x$ac_cv_header_zlib_h" = x""yes; then : +if test "x$ac_cv_header_zlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ZLIB_H 1 _ACEOF @@ -7874,7 +7869,7 @@ done ac_fn_cxx_check_decl "$LINENO" "round" "ac_cv_have_decl_round" "#include " -if test "x$ac_cv_have_decl_round" = x""yes; then : +if test "x$ac_cv_have_decl_round" = xyes; then : ac_have_decl=1 else ac_have_decl=0 @@ -7888,7 +7883,7 @@ if test "$ZM_SSL_LIB" == "openssl"; then ac_fn_cxx_check_decl "$LINENO" "MD5" "ac_cv_have_decl_MD5" "#include #include " -if test "x$ac_cv_have_decl_MD5" = x""yes; then : +if test "x$ac_cv_have_decl_MD5" = xyes; then : ac_have_decl=1 else ac_have_decl=0 @@ -7900,14 +7895,14 @@ _ACEOF if test $ac_have_decl = 1; then : else - as_fn_error "zm requires openssl/md5.h - use ZM_SSL_LIB option to select gnutls instead" "$LINENO" 5 + as_fn_error $? "zm requires openssl/md5.h - use ZM_SSL_LIB option to select gnutls instead" "$LINENO" 5 fi else ac_fn_cxx_check_decl "$LINENO" "MD5" "ac_cv_have_decl_MD5" "#include #include " -if test "x$ac_cv_have_decl_MD5" = x""yes; then : +if test "x$ac_cv_have_decl_MD5" = xyes; then : ac_have_decl=1 else ac_have_decl=0 @@ -7919,13 +7914,13 @@ _ACEOF if test $ac_have_decl = 1; then : else - as_fn_error "zm requires gnutls/openssl.h - use ZM_SSL_LIB option to select openssl instead" "$LINENO" 5 + as_fn_error $? "zm requires gnutls/openssl.h - use ZM_SSL_LIB option to select openssl instead" "$LINENO" 5 fi fi ac_fn_cxx_check_decl "$LINENO" "backtrace" "ac_cv_have_decl_backtrace" "#include " -if test "x$ac_cv_have_decl_backtrace" = x""yes; then : +if test "x$ac_cv_have_decl_backtrace" = xyes; then : ac_have_decl=1 else ac_have_decl=0 @@ -7944,7 +7939,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8011,7 +8006,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8070,7 +8065,7 @@ $as_echo "ok" >&6; }; else : - as_fn_error "zm requires SYS:Syslog" "$LINENO" 5 + as_fn_error $? "zm requires SYS:Syslog" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 @@ -8083,7 +8078,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8142,7 +8137,7 @@ $as_echo "ok" >&6; }; else : - as_fn_error "zm requires DBI" "$LINENO" 5 + as_fn_error $? "zm requires DBI" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 @@ -8155,7 +8150,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8214,7 +8209,7 @@ $as_echo "ok" >&6; }; else : - as_fn_error "zm requires DBD::mysql" "$LINENO" 5 + as_fn_error $? "zm requires DBD::mysql" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 @@ -8227,7 +8222,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8286,7 +8281,7 @@ $as_echo "ok" >&6; }; else : - as_fn_error "zm requires Getopt::Long" "$LINENO" 5 + as_fn_error $? "zm requires Getopt::Long" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 @@ -8299,7 +8294,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8358,7 +8353,7 @@ $as_echo "ok" >&6; }; else : - as_fn_error "zm requires Time::HiRes" "$LINENO" 5 + as_fn_error $? "zm requires Time::HiRes" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 @@ -8371,7 +8366,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8430,7 +8425,7 @@ $as_echo "ok" >&6; }; else : - as_fn_error "zm requires Date::Manip" "$LINENO" 5 + as_fn_error $? "zm requires Date::Manip" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 @@ -8443,7 +8438,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8502,7 +8497,7 @@ $as_echo "ok" >&6; }; else : - as_fn_error "zm requires LWP::UserAgent" "$LINENO" 5 + as_fn_error $? "zm requires LWP::UserAgent" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 @@ -8515,7 +8510,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8574,7 +8569,7 @@ $as_echo "ok" >&6; }; else : - as_fn_error "zm requires ExtUtils::MakeMaker" "$LINENO" 5 + as_fn_error $? "zm requires ExtUtils::MakeMaker" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 @@ -8588,7 +8583,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8647,7 +8642,7 @@ $as_echo "ok" >&6; }; else : - as_fn_error "zm requires Sys::Mmap for mapped memory - set --enable-mmap=no to use IPC shared memory instead" "$LINENO" 5 + as_fn_error $? "zm requires Sys::Mmap for mapped memory - set --enable-mmap=no to use IPC shared memory instead" "$LINENO" 5 fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 @@ -8663,7 +8658,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8736,7 +8731,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8809,7 +8804,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8868,8 +8863,154 @@ $as_echo "ok" >&6; }; else : - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Net::FTP is required for automatic event uploading" >&5 -$as_echo "$as_me: WARNING: Net::FTP is required for automatic event uploading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Net::FTP is required for automatic event uploading using ftp" >&5 +$as_echo "$as_me: WARNING: Net::FTP is required for automatic event uploading using ftp" >&2;} + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="Net::SFTP::Foreign" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_PERL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Net::SFTP::Foreign is required for automatic event uploading using sftp" >&5 +$as_echo "$as_me: WARNING: Net::SFTP::Foreign is required for automatic event uploading using sftp" >&2;} + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 +$as_echo "$as_me: WARNING: could not find perl" >&2;} +fi +ac_perl_modules="Expect" +# Make sure we have perl +if test -z "$PERL"; then +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_PERL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PERL"; then + ac_cv_prog_PERL="$PERL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_PERL="perl" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PERL=$ac_cv_prog_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + +if test "x$PERL" != x; then + ac_perl_modules_failed=0 + for ac_perl_module in $ac_perl_modules; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl module $ac_perl_module" >&5 +$as_echo_n "checking for perl module $ac_perl_module... " >&6; } + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL "-M$ac_perl_module" -e exit > /dev/null 2>&1 + if test $? -ne 0; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; }; + ac_perl_modules_failed=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; }; + fi + done + + # Run optional shell commands + if test "$ac_perl_modules_failed" = 0; then + : + + else + : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Expect is required for automatic event uploading using sftp" >&5 +$as_echo "$as_me: WARNING: Expect is required for automatic event uploading using sftp" >&2;} fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find perl" >&5 @@ -8882,7 +9023,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -8955,7 +9096,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -9028,7 +9169,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -9101,7 +9242,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -9174,7 +9315,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -9247,7 +9388,7 @@ if test -z "$PERL"; then set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_PERL+set}" = set; then : +if ${ac_cv_prog_PERL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PERL"; then @@ -9458,10 +9599,21 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && + if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -9477,6 +9629,7 @@ DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' @@ -9500,19 +9653,19 @@ else fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - as_fn_error "conditional \"AMDEP\" was never defined. + as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then - as_fn_error "conditional \"am__fastdepCXX\" was never defined. + as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error "conditional \"am__fastdepCC\" was never defined. + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -: ${CONFIG_STATUS=./config.status} +: "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -9613,6 +9766,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -9658,19 +9812,19 @@ export LANGUAGE (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -9866,7 +10020,7 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -9920,7 +10074,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by zm $as_me 1.25.0, which was -generated by GNU Autoconf 2.65. Invocation command line was +generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -9987,10 +10141,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ zm config.status 1.25.0 -configured by $0, generated by GNU Autoconf 2.65, +configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -10008,11 +10162,16 @@ ac_need_defaults=: while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -10034,6 +10193,7 @@ do $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -10046,7 +10206,7 @@ do ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - as_fn_error "ambiguous option: \`$1' + as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; @@ -10055,7 +10215,7 @@ Try \`$0 --help' for more information.";; ac_cs_silent=: ;; # This is an error. - -*) as_fn_error "unrecognized option: \`$1' + -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" @@ -10180,7 +10340,7 @@ do "src/zm_config_defines.h") CONFIG_COMMANDS="$CONFIG_COMMANDS src/zm_config_defines.h" ;; "scripts/ZoneMinder/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS scripts/ZoneMinder/Makefile" ;; - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -10203,9 +10363,10 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= + tmp= ac_tmp= trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -10213,12 +10374,13 @@ $debug || { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" + test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -10235,12 +10397,12 @@ if test "x$ac_cr" = x; then fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' + ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF @@ -10249,18 +10411,18 @@ _ACEOF echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -10268,7 +10430,7 @@ done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -10316,7 +10478,7 @@ t delim rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -10348,21 +10510,29 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// }' fi @@ -10374,7 +10544,7 @@ fi # test -n "$CONFIG_FILES" # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || +cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -10386,11 +10556,11 @@ _ACEOF # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_t=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_t"; then + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -10475,7 +10645,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error "could not setup config headers machinery" "$LINENO" 5 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -10488,7 +10658,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -10507,7 +10677,7 @@ do for ac_f do case $ac_f in - -) ac_f="$tmp/stdin";; + -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -10516,7 +10686,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -10542,8 +10712,8 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -10679,23 +10849,24 @@ s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 +which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} +which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$tmp/stdin" + rm -f "$ac_tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -10704,21 +10875,21 @@ which seems to be undefined. Please make sure it is defined." >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error "could not create -" "$LINENO" 5 + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" @@ -10870,7 +11041,7 @@ _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -10891,7 +11062,7 @@ if test "$no_create" != yes; then exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit $? + $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 diff --git a/configure.ac b/configure.ac index 1c7c93f63..cbde26a22 100644 --- a/configure.ac +++ b/configure.ac @@ -89,7 +89,7 @@ AC_ARG_WITH(ffmpeg, ) AC_SUBST(FFMPEG_PREFIX) FFMPEG_LIBS="-L${FFMPEG_PREFIX}/${LIB_ARCH}" -FFMPEG_CFLAGS="-I${FFMPEG_PREFIX}/include" +FFMPEG_CFLAGS="-I${FFMPEG_PREFIX}/include -D__STDC_CONSTANT_MACROS" AC_SUBST(FFMPEG_LIBS) AC_SUBST(FFMPEG_CFLAGS) @@ -276,7 +276,7 @@ AC_CHECK_LIB(x264,x264_predict_16x16_init) AC_CHECK_LIB(avutil,av_malloc,,AC_MSG_WARN(libavutil.a may be required for MPEG streaming)) # Don't bother to warn about this one AC_CHECK_LIB(avcore,av_image_copy,,) -AC_CHECK_LIB(avcodec,avcodec_init,,AC_MSG_WARN(libavcodec.a is required for MPEG streaming)) +AC_CHECK_LIB(avcodec,avcodec_open,,AC_MSG_WARN(libavcodec.a is required for MPEG streaming)) AC_CHECK_LIB(avformat,av_new_stream,,AC_MSG_WARN(libavformat.a is required for MPEG streaming)) AC_CHECK_LIB(avdevice,avdevice_register_all,,AC_MSG_WARN(libavdevice.a may be required for MPEG streaming)) AC_CHECK_LIB(swscale,sws_scale,,,-lswscale) diff --git a/src/Makefile.am b/src/Makefile.am index 1e971c157..4680c45fe 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = gnu -AM_CPPFLAGS = @MYSQL_CFLAGS@ @FFMPEG_CFLAGS@ -Wall -finline-functions -fomit-frame-pointer -D__STDC_CONSTANT_MACROS +AM_CPPFLAGS = @MYSQL_CFLAGS@ -Wall -finline-functions -fomit-frame-pointer #AM_CXXFLAGS = -frepo CLEANFILES = *.rpo diff --git a/src/Makefile.in b/src/Makefile.in index 5d68f6c42..f91cec1c9 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -242,7 +242,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = gnu -AM_CPPFLAGS = @MYSQL_CFLAGS@ @FFMPEG_CFLAGS@ -Wall -Wno-sign-compare -finline-functions +AM_CPPFLAGS = @MYSQL_CFLAGS@ -Wall -finline-functions -fomit-frame-pointer #AM_CXXFLAGS = -frepo CLEANFILES = *.rpo diff --git a/src/zm_logger.h b/src/zm_logger.h index 4ac779e2b..188aed518 100644 --- a/src/zm_logger.h +++ b/src/zm_logger.h @@ -20,6 +20,7 @@ #ifndef ZM_LOGGER_H #define ZM_LOGGER_H +#include #include #include #include diff --git a/src/zm_thread.h b/src/zm_thread.h index 49fb73bcc..d1bbbcc6f 100644 --- a/src/zm_thread.h +++ b/src/zm_thread.h @@ -20,6 +20,7 @@ #ifndef ZM_THREAD_H #define ZM_THREAD_H +#include #include #include "zm_exception.h" #include "zm_utils.h"