From 062ae675c81a4377c4fbf10711f79473dd5c9ed6 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Wed, 22 Jul 2020 13:12:59 -0500 Subject: [PATCH 1/7] partial cleanup of getNavBarHTML --- web/skins/classic/includes/functions.php | 132 +++++++++++++++-------- 1 file changed, 85 insertions(+), 47 deletions(-) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 3d60fde3e..5c9be938e 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -256,21 +256,21 @@ function getNavBarHTML($reload = null) { $status = $running ? ($state ? $state : translate('Running')) : translate('Stopped'); ?> - -'.validHtmlStr(ZM_WEB_CONSOLE_BANNER).''; + } +} + +function getBandwidthHTML($bandwidth_options,$user) { + + echo makePopupLink( '?view=bandwidth', 'zmBandwidth', 'bandwidth', "network_check ".$bandwidth_options[$_COOKIE['zmBandwidth']] . ' ', ($user && $user['MaxBandwidth'] != 'low' )); +} + +function getZMVersionHTML($versionClass) { + + echo makePopupLink( '?view=version', 'zmVersion', 'version', 'v'.ZM_VERSION.'', canEdit('System') ); +} function xhtmlFooter() { global $cspNonce; From 7fd038d99b8635c9f8199204c3c9bc6e310c2228 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Jul 2020 17:28:12 -0400 Subject: [PATCH 2/7] spacing and quotes --- web/includes/Event.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/web/includes/Event.php b/web/includes/Event.php index f1ba99626..89e41b2ca 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -380,54 +380,54 @@ class Event extends ZM_Object { $Event = $this; $eventPath = $Event->Path(); - if ( $frame and ! is_array($frame) ) { + if ( $frame and !is_array($frame) ) { # Must be an Id Logger::Debug("Assuming that $frame is an Id"); - $frame = array( 'FrameId'=>$frame, 'Type'=>'', 'Delta'=>0 ); + $frame = array('FrameId'=>$frame, 'Type'=>'', 'Delta'=>0); } - if ( ( ! $frame ) and file_exists($eventPath.'/snapshot.jpg') ) { + if ( ( !$frame ) and file_exists($eventPath.'/snapshot.jpg') ) { # No frame specified, so look for a snapshot to use $captImage = 'snapshot.jpg'; - Logger::Debug("Frame not specified, using snapshot"); - $frame = array('FrameId'=>'snapshot', 'Type'=>'','Delta'=>0); + Logger::Debug('Frame not specified, using snapshot'); + $frame = array('FrameId'=>'snapshot', 'Type'=>'', 'Delta'=>0); } else { - $captImage = sprintf( '%0'.ZM_EVENT_IMAGE_DIGITS.'d-analyze.jpg', $frame['FrameId'] ); + $captImage = sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d-analyze.jpg', $frame['FrameId']); if ( ! file_exists( $eventPath.'/'.$captImage ) ) { - $captImage = sprintf( '%0'.ZM_EVENT_IMAGE_DIGITS.'d-capture.jpg', $frame['FrameId'] ); - if ( ! file_exists( $eventPath.'/'.$captImage ) ) { + $captImage = sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d-capture.jpg', $frame['FrameId']); + if ( !file_exists($eventPath.'/'.$captImage) ) { # Generate the frame JPG if ( $Event->DefaultVideo() ) { $videoPath = $eventPath.'/'.$Event->DefaultVideo(); - if ( ! file_exists( $videoPath ) ) { - Error("Event claims to have a video file, but it does not seem to exist at $videoPath" ); + if ( !file_exists($videoPath) ) { + Error('Event claims to have a video file, but it does not seem to exist at '.$videoPath); return ''; } #$command ='ffmpeg -v 0 -i '.$videoPath.' -vf "select=gte(n\\,'.$frame['FrameId'].'),setpts=PTS-STARTPTS" '.$eventPath.'/'.$captImage; $command ='ffmpeg -ss '. $frame['Delta'] .' -i '.$videoPath.' -frames:v 1 '.$eventPath.'/'.$captImage; - Logger::Debug( "Running $command" ); + Logger::Debug('Running '.$command); $output = array(); $retval = 0; - exec( $command, $output, $retval ); + exec($command, $output, $retval); Logger::Debug("Retval: $retval, output: " . implode("\n", $output)); } else { - Error("Can't create frame images from video because there is no video file for event ".$Event->Id().' at ' .$Event->Path() ); + Error('Can\'t create frame images from video because there is no video file for event '.$Event->Id().' at ' .$Event->Path()); } } // end if capture file exists } // end if analyze file exists } // end if frame or snapshot $captPath = $eventPath.'/'.$captImage; - if ( ! file_exists($captPath) ) { - Error("Capture file does not exist at $captPath"); + if ( !file_exists($captPath) ) { + Error('Capture file does not exist at '.$captPath); } $analImage = sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d-analyse.jpg', $frame['FrameId']); $analPath = $eventPath.'/'.$analImage; - $alarmFrame = $frame['Type']=='Alarm'; + $alarmFrame = $frame['Type'] == 'Alarm'; $hasAnalImage = $alarmFrame && file_exists($analPath) && filesize($analPath); $isAnalImage = $hasAnalImage && !$captureOnly; @@ -443,8 +443,8 @@ class Event extends ZM_Object { $fraction = sprintf('%.3f', $scale/SCALE_BASE); $scale = (int)round($scale); - $thumbCaptPath = preg_replace( '/\.jpg$/', "-$scale.jpg", $captPath ); - $thumbAnalPath = preg_replace( '/\.jpg$/', "-$scale.jpg", $analPath ); + $thumbCaptPath = preg_replace('/\.jpg$/', "-$scale.jpg", $captPath); + $thumbAnalPath = preg_replace('/\.jpg$/', "-$scale.jpg", $analPath); if ( $isAnalImage ) { $imagePath = $analPath; @@ -457,7 +457,7 @@ class Event extends ZM_Object { $thumbFile = $thumbPath; if ( $overwrite || ! file_exists($thumbFile) || ! filesize($thumbFile) ) { // Get new dimensions - list( $imageWidth, $imageHeight ) = getimagesize($imagePath); + list($imageWidth, $imageHeight) = getimagesize($imagePath); $thumbWidth = $imageWidth * $fraction; $thumbHeight = $imageHeight * $fraction; @@ -484,7 +484,7 @@ class Event extends ZM_Object { ); return $imageData; - } + } # getImageSrc public function link_to($text=null) { if ( !$text ) From e746f0babe468584c89c0d48fe06623499514493 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Jul 2020 17:28:41 -0400 Subject: [PATCH 3/7] Use 0 instead of the word auto for scale --- web/skins/classic/views/frame.php | 17 ++++++++--------- web/skins/classic/views/js/frame.js | 6 +++--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/web/skins/classic/views/frame.php b/web/skins/classic/views/frame.php index 64f1035b3..d8a60a15d 100644 --- a/web/skins/classic/views/frame.php +++ b/web/skins/classic/views/frame.php @@ -50,19 +50,19 @@ $lastFid = $maxFid; $alarmFrame = $Frame->Type() == 'Alarm'; -if ( isset( $_REQUEST['scale'] ) ) { +if ( isset($_REQUEST['scale']) ) { $scale = validNum($_REQUEST['scale']); -} else if ( isset( $_COOKIE['zmWatchScale'.$Monitor->Id()] ) ) { +} else if ( isset($_COOKIE['zmWatchScale'.$Monitor->Id()]) ) { $scale = validNum($_COOKIE['zmWatchScale'.$Monitor->Id()]); -} else if ( isset( $_COOKIE['zmWatchScale'] ) ) { +} else if ( isset($_COOKIE['zmWatchScale']) ) { $scale = validNum($_COOKIE['zmWatchScale']); } else { $scale = max(reScale(SCALE_BASE, $Monitor->DefaultScale(), ZM_WEB_DEFAULT_SCALE), SCALE_BASE); } -$scale = $scale ?: 'auto'; +$scale = $scale ? $scale : 0; -$imageData = $Event->getImageSrc( $frame, $scale, 0 ); -if ( ! $imageData ) { +$imageData = $Event->getImageSrc($frame, $scale, 0); +if ( !$imageData ) { ZM\Error("No data found for Event $eid frame $fid"); $imageData = array(); } @@ -89,10 +89,10 @@ xhtmlHeaders(__FILE__, translate('Frame').' - '.$Event->Id().' - '.$Frame->Frame
Id().'&fid='.$Frame->FrameId(), 'zmStats', 'stats', translate('Stats') ); } ?> - +
-
+

Id().'-'.$Frame->FrameId().' ('.$Frame->Score().')' ?>

@@ -100,7 +100,6 @@ xhtmlHeaders(__FILE__, translate('Frame').' - '.$Event->Id().' - '.$Frame->Frame

- ', $Event->Id(), $Frame->FrameId(), $scale, ( $show=='anal'?'capt':'anal' ) ); } ?> diff --git a/web/skins/classic/views/js/frame.js b/web/skins/classic/views/js/frame.js index a0a30eed4..37dae96ec 100644 --- a/web/skins/classic/views/js/frame.js +++ b/web/skins/classic/views/js/frame.js @@ -11,7 +11,7 @@ function changeScale() { if ( img ) { var baseWidth = $j('#base_width').val(); var baseHeight = $j('#base_height').val(); - if ( scale == 'auto' ) { + if ( ! parseInt(scale) ) { var newSize = scaleToFit(baseWidth, baseHeight, img, $j('#controls')); newWidth = newSize.width; newHeight = newSize.height; @@ -24,7 +24,7 @@ function changeScale() { img.css('width', newWidth + 'px'); img.css('height', newHeight + 'px'); } - Cookie.write( 'zmWatchScale', scale, {duration: 10*365} ); + Cookie.write('zmWatchScale', scale, {duration: 10*365}); $j.each(controlsLinks, function(k, anchor) { //Make frames respect scale choices if ( anchor ) { anchor.prop('href', anchor.prop('href').replace(/scale=.*&/, 'scale=' + scale + '&')); @@ -32,7 +32,7 @@ function changeScale() { }); } -if ( scale == 'auto' ) { +if ( !scale ) { $j(document).ready(changeScale); } From 07165aed98f5fd35f9a00a089d6d8de5b4eadb48 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Jul 2020 17:30:28 -0400 Subject: [PATCH 4/7] mostly spacing. Also set new_size from line_size in Assign(Image&) and set linesize in the assigned image --- src/zm_image.cpp | 104 ++++++++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 38 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 21ed8c1fb..2237e2f21 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -122,7 +122,7 @@ Image::Image() { blend = fptr_blend; } -Image::Image( const char *filename ) { +Image::Image(const char *filename) { if ( !initialised ) Initialise(); width = 0; @@ -141,7 +141,7 @@ Image::Image( const char *filename ) { update_function_pointers(); } -Image::Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer, unsigned int p_padding) { +Image::Image(int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer, unsigned int p_padding) { if ( !initialised ) Initialise(); width = p_width; @@ -166,7 +166,7 @@ Image::Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uin update_function_pointers(); } -Image::Image( int p_width, int p_linesize, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer, unsigned int p_padding) { +Image::Image(int p_width, int p_linesize, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer, unsigned int p_padding) { if ( !initialised ) Initialise(); width = p_width; @@ -263,14 +263,6 @@ Image::~Image() { /* Should be called as part of program shutdown to free everything */ void Image::Deinitialise() { if ( !initialised ) return; - /* - delete[] y_table; - delete[] uv_table; - delete[] r_v_table; - delete[] g_v_table; - delete[] g_u_table; - delete[] b_u_table; - */ initialised = false; if ( readjpg_dcinfo ) { jpeg_destroy_decompress( readjpg_dcinfo ); @@ -345,7 +337,7 @@ void Image::Initialise() { (*fptr_blend)(blend1,blend2,blendres,128,12.0); /* Compare results with expected results */ - for ( int i=0; i < 128; i ++ ) { + for ( int i=0; i < 128; i++ ) { if ( abs(blendexp[i] - blendres[i]) > 3 ) { Panic("Blend function failed self-test: Results differ from the expected results. Column %u Expected %u Got %u",i,blendexp[i],blendres[i]); } @@ -445,7 +437,7 @@ void Image::Initialise() { } /* Run the delta8 RGBA function */ - (*fptr_delta8_rgba)(delta8_1,delta8_2,delta8_rgba_res,32); + (*fptr_delta8_rgba)(delta8_1,delta8_2,delta8_rgba_res, 32); /* Compare results with expected results */ for ( int i=0; i < 32; i++ ) { @@ -491,9 +483,17 @@ void Image::Initialise() { } /* Requests a writeable buffer to the image. This is safer than buffer() because this way we can guarantee that a buffer of required size exists */ -uint8_t* Image::WriteBuffer(const unsigned int p_width, const unsigned int p_height, const unsigned int p_colours, const unsigned int p_subpixelorder) { +uint8_t* Image::WriteBuffer( + const unsigned int p_width, + const unsigned int p_height, + const unsigned int p_colours, + const unsigned int p_subpixelorder) { - if ( p_colours != ZM_COLOUR_GRAY8 && p_colours != ZM_COLOUR_RGB24 && p_colours != ZM_COLOUR_RGB32 ) { + 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; } @@ -605,7 +605,13 @@ void Image::AssignDirect( } } -void Image::Assign(const unsigned int p_width, const unsigned int p_height, const unsigned int p_colours, const unsigned int p_subpixelorder, const uint8_t* new_buffer, const size_t buffer_size) { +void Image::Assign( + const unsigned int p_width, + const unsigned int p_height, + const unsigned int p_colours, + const unsigned 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 ) { @@ -652,24 +658,30 @@ void Image::Assign(const unsigned int p_width, const unsigned int p_height, cons if ( new_buffer != buffer ) (*fptr_imgbufcpy)(buffer, new_buffer, size); -Debug(1,"Assign"); } -void Image::Assign( const Image &image ) { - unsigned int new_size = (image.width * image.height) * image.colours; +void Image::Assign(const Image &image) { + unsigned int new_size = image.height * image.linesize; if ( image.buffer == NULL ) { Error("Attempt to assign image with an empty buffer"); return; } - 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); + 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; } - if ( !buffer || image.width != width || image.height != height - || image.colours != colours || image.subpixelorder != subpixelorder) { + if ( !buffer + || image.width != width || image.height != height + || image.colours != colours || image.subpixelorder != subpixelorder + || image.linesize != linesize + ) { if ( holdbuffer && buffer ) { if ( new_size > allocation ) { @@ -689,13 +701,19 @@ void Image::Assign( const Image &image ) { colours = image.colours; subpixelorder = image.subpixelorder; size = new_size; + linesize = image.linesize; } if ( image.buffer != buffer ) (*fptr_imgbufcpy)(buffer, image.buffer, size); } -Image *Image::HighlightEdges( Rgb colour, unsigned int p_colours, unsigned int p_subpixelorder, const Box *limits ) { +Image *Image::HighlightEdges( + Rgb colour, + unsigned int p_colours, + unsigned int p_subpixelorder, + const Box *limits + ) { if ( colours != ZM_COLOUR_GRAY8 ) { Panic("Attempt to highlight image edges when colours = %d", colours); } @@ -704,7 +722,7 @@ Image *Image::HighlightEdges( Rgb colour, unsigned int p_colours, unsigned int p 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 ); + 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 */ @@ -722,10 +740,13 @@ Image *Image::HighlightEdges( Rgb colour, unsigned int p_colours, unsigned int p for ( unsigned int x = lo_x; x <= hi_x; x++, p++, phigh++ ) { bool edge = false; if ( *p ) { + edge = (x > 0 && !*(p-1)) || (x < (width-1) && !*(p+1)) || (y > 0 && !*(p-width)) || (y < (height-1) && !*(p+width)); +#if 0 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; +#endif } if ( edge ) { *phigh = colour; @@ -739,10 +760,13 @@ Image *Image::HighlightEdges( Rgb colour, unsigned int p_colours, unsigned int p for ( unsigned int x = lo_x; x <= hi_x; x++, p++, phigh += 3 ) { bool edge = false; if ( *p ) { + edge = (x > 0 && !*(p-1)) || (x < (width-1) && !*(p+1)) || (y > 0 && !*(p-width)) || (y < (height-1) && !*(p+width)); +#if 0 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; +#endif } if ( edge ) { RED_PTR_RGBA(phigh) = RED_VAL_RGBA(colour); @@ -758,10 +782,13 @@ Image *Image::HighlightEdges( Rgb colour, unsigned int p_colours, unsigned int p for ( unsigned int x = lo_x; x <= hi_x; x++, p++, phigh++ ) { bool edge = false; if ( *p ) { + edge = (x > 0 && !*(p-1)) || (x < (width-1) && !*(p+1)) || (y > 0 && !*(p-width)) || (y < (height-1) && !*(p+width)); +#if 0 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; +#endif } if ( edge ) { *phigh = colour; @@ -773,9 +800,9 @@ Image *Image::HighlightEdges( Rgb colour, unsigned int p_colours, unsigned int p return high_image; } -bool Image::ReadRaw( const char *filename ) { +bool Image::ReadRaw(const char *filename) { FILE *infile; - if ( (infile = fopen( filename, "rb" )) == NULL ) { + if ( (infile = fopen(filename, "rb")) == NULL ) { Error("Can't open %s: %s", filename, strerror(errno)); return false; } @@ -1760,7 +1787,7 @@ Image *Image::Highlight( unsigned int n_images, Image *images[], const Rgb thres return result; } -/* New function to allow buffer re-using instead of allocationg memory for the delta image every time */ +/* New function to allow buffer re-using instead of allocating memory for the delta image every time */ void Image::Delta( const Image &image, Image* targetimage) const { #ifdef ZM_IMAGE_PROFILING struct timespec start,end,diff; @@ -3471,7 +3498,7 @@ __attribute__((noinline)) void fast_delta8_bgr(const uint8_t* col1, const uint8_ int r,g,b; const uint8_t* const max_ptr = result + count; - while(result < max_ptr) { + while (result < max_ptr) { b = abs(col1[0] - col2[0]); g = abs(col1[1] - col2[1]); r = abs(col1[2] - col2[2]); @@ -3500,7 +3527,7 @@ __attribute__((noinline)) void std_delta8_bgr(const uint8_t* col1, const uint8_t int r,g,b; const uint8_t* const max_ptr = result + count; - while(result < max_ptr) { + while (result < max_ptr) { b = abs(col1[0] - col2[0]); g = abs(col1[1] - col2[1]); r = abs(col1[2] - col2[2]); @@ -3518,7 +3545,7 @@ __attribute__((noinline)) void fast_delta8_rgba(const uint8_t* col1, const uint8 int r,g,b; const uint8_t* const max_ptr = result + count; - while(result < max_ptr) { + while (result < max_ptr) { r = abs(col1[0] - col2[0]); g = abs(col1[1] - col2[1]); b = abs(col1[2] - col2[2]); @@ -3547,7 +3574,7 @@ __attribute__((noinline)) void std_delta8_rgba(const uint8_t* col1, const uint8_ int r,g,b; const uint8_t* const max_ptr = result + count; - while(result < max_ptr) { + while (result < max_ptr) { r = abs(col1[0] - col2[0]); g = abs(col1[1] - col2[1]); b = abs(col1[2] - col2[2]); @@ -3565,7 +3592,7 @@ __attribute__((noinline)) void fast_delta8_bgra(const uint8_t* col1, const uint8 int r,g,b; const uint8_t* const max_ptr = result + count; - while(result < max_ptr) { + while (result < max_ptr) { b = abs(col1[0] - col2[0]); g = abs(col1[1] - col2[1]); r = abs(col1[2] - col2[2]); @@ -3593,7 +3620,7 @@ __attribute__((noinline)) void std_delta8_bgra(const uint8_t* col1, const uint8_ int r,g,b; const uint8_t* const max_ptr = result + count; - while(result < max_ptr) { + while (result < max_ptr) { b = abs(col1[0] - col2[0]); g = abs(col1[1] - col2[1]); r = abs(col1[2] - col2[2]); @@ -3611,7 +3638,7 @@ __attribute__((noinline)) void fast_delta8_argb(const uint8_t* col1, const uint8 int r,g,b; const uint8_t* const max_ptr = result + count; - while(result < max_ptr) { + while (result < max_ptr) { r = abs(col1[1] - col2[1]); g = abs(col1[2] - col2[2]); b = abs(col1[3] - col2[3]); @@ -3634,12 +3661,13 @@ __attribute__((noinline)) void fast_delta8_argb(const uint8_t* col1, const uint8 result += 4; } } + __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; - while(result < max_ptr) { + while (result < max_ptr) { r = abs(col1[1] - col2[1]); g = abs(col1[2] - col2[2]); b = abs(col1[3] - col2[3]); @@ -3657,7 +3685,7 @@ __attribute__((noinline)) void fast_delta8_abgr(const uint8_t* col1, const uint8 int r,g,b; const uint8_t* const max_ptr = result + count; - while(result < max_ptr) { + while (result < max_ptr) { b = abs(col1[1] - col2[1]); g = abs(col1[2] - col2[2]); r = abs(col1[3] - col2[3]); @@ -3684,7 +3712,7 @@ __attribute__((noinline)) void std_delta8_abgr(const uint8_t* col1, const uint8_ int r,g,b; const uint8_t* const max_ptr = result + count; - while(result < max_ptr) { + while (result < max_ptr) { b = abs(col1[1] - col2[1]); g = abs(col1[2] - col2[2]); r = abs(col1[3] - col2[3]); From f635afe00fc25f0934001c3bf3379402455133d1 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Jul 2020 17:30:39 -0400 Subject: [PATCH 5/7] spacing --- src/zm_zone.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index b22403f09..ee7a5c829 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -122,7 +122,7 @@ void Zone::Setup( } else { diag_path[0] = 0; } -} // end Zone::Setup +} // end Zone::Setup Zone::~Zone() { delete[] label; @@ -131,7 +131,7 @@ Zone::~Zone() { delete[] ranges; } -void Zone::RecordStats( const Event *event ) { +void Zone::RecordStats(const Event *event) { static char sql[ZM_SQL_MED_BUFSIZ]; db_mutex.lock(); snprintf(sql, sizeof(sql), @@ -142,7 +142,7 @@ void Zone::RecordStats( const Event *event ) { Error("Can't insert event stats: %s", mysql_error(&dbconn)); } db_mutex.unlock(); -} // end void Zone::RecordStats( const Event *event ) +} // end void Zone::RecordStats( const Event *event ) bool Zone::CheckOverloadCount() { if ( overload_count ) { @@ -151,40 +151,40 @@ bool Zone::CheckOverloadCount() { return false; } return true; -} // end bool Zone::CheckOverloadCount() +} // end bool Zone::CheckOverloadCount() void Zone::SetScore(unsigned int nScore) { score = nScore; -} // end void Zone::SetScore(unsigned int nScore) +} // end void Zone::SetScore(unsigned int nScore) void Zone::SetAlarmImage(const Image* srcImage) { delete image; image = new Image(*srcImage); -} // end void Zone::SetAlarmImage( const Image* srcImage ) +} // end void Zone::SetAlarmImage( const Image* srcImage ) int Zone::GetOverloadCount() { return overload_count; -} // end int Zone::GetOverloadCount() +} // end int Zone::GetOverloadCount() void Zone::SetOverloadCount(int nOverCount) { overload_count = nOverCount; -} // end void Zone::SetOverloadCount(int nOverCount ) +} // end void Zone::SetOverloadCount(int nOverCount ) int Zone::GetOverloadFrames() { return overload_frames; -} // end int Zone::GetOverloadFrames +} // end int Zone::GetOverloadFrames int Zone::GetExtendAlarmCount() { return extend_alarm_count; -} // end int Zone::GetExtendAlarmCount() +} // end int Zone::GetExtendAlarmCount() void Zone::SetExtendAlarmCount(int nExtendAlarmCount) { extend_alarm_count = nExtendAlarmCount; -} // end void Zone::SetExtendAlarmCount( int nExtendAlarmCount ) +} // end void Zone::SetExtendAlarmCount( int nExtendAlarmCount ) int Zone::GetExtendAlarmFrames() { return extend_alarm_frames; -} // end int Zone::GetExtendAlarmFrames() +} // end int Zone::GetExtendAlarmFrames() bool Zone::CheckExtendAlarmCount() { Info("ExtendAlarm count: %d, ExtendAlarm frames: %d", extend_alarm_count, extend_alarm_frames); @@ -194,7 +194,7 @@ bool Zone::CheckExtendAlarmCount() { return true; } return false; -} // end bool Zone::CheckExtendAlarmCount +} // end bool Zone::CheckExtendAlarmCount bool Zone::CheckAlarms(const Image *delta_image) { ResetStats(); @@ -984,10 +984,14 @@ bool Zone::DumpSettings(char *output, bool /*verbose*/) { sprintf( output+strlen(output), " Max Blob Pixels : %d\n", max_blob_pixels ); sprintf( output+strlen(output), " Min Blobs : %d\n", min_blobs ); sprintf( output+strlen(output), " Max Blobs : %d\n", max_blobs ); - return( true ); + return true; } -void Zone::std_alarmedpixels(Image* pdiff_image, const Image* ppoly_image, unsigned int* pixel_count, unsigned int* pixel_sum) { +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 calc_max_pixel_threshold = 255; From 172eaad8bd41c6978c33d8f369dcbee3fd05d0ee Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Jul 2020 22:45:11 -0400 Subject: [PATCH 6/7] fix capture jpeg saving due to use of std::string --- src/zm_event.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 0193172ac..3a88ff536 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -495,7 +495,7 @@ void Event::AddFramesInternal(int n_frames, int start_frame, Image **images, str frames++; if ( monitor->GetOptSaveJPEGs() & 1 ) { - std::string event_file = stringtf(staticConfig.capture_file_format, path, frames); + std::string event_file = stringtf(staticConfig.capture_file_format, path.c_str(), frames); Debug(1, "Writing pre-capture frame %d", frames); WriteFrameImage(images[i], *(timestamps[i]), event_file.c_str()); } @@ -606,7 +606,7 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a score = 0; if ( monitor->GetOptSaveJPEGs() & 1 ) { - std::string event_file = stringtf(staticConfig.capture_file_format, path, frames); + std::string event_file = stringtf(staticConfig.capture_file_format, path.c_str(), frames); Debug(1, "Writing capture frame %d to %s", frames, event_file.c_str()); if ( !WriteFrameImage(image, timestamp, event_file.c_str()) ) { Error("Failed to write frame image"); From e9323f96a528c5624ea315c92a093ae4e22af963 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Thu, 23 Jul 2020 10:52:12 -0500 Subject: [PATCH 7/7] additional cleanup of getNavBarHTML --- web/skins/classic/includes/functions.php | 270 ++++++++++++++--------- 1 file changed, 171 insertions(+), 99 deletions(-) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 5c9be938e..1115614e0 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -268,104 +268,31 @@ function getNavBarHTML($reload = null) {

-