From 8ae387e376df214f90998fc93d0cdc094950464b Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Sun, 22 Dec 2013 15:19:55 +0200 Subject: [PATCH] Few minor code improvements --- src/zm_monitor.h | 11 ++++++----- src/zm_video.cpp | 27 +++++++++++++++++---------- src/zm_video.h | 4 ++-- web/skins/classic/views/monitor.php | 6 +++--- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/zm_monitor.h b/src/zm_monitor.h index aff5fc91b..b1c805ae1 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -216,6 +216,12 @@ protected: 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 savejpegspref; + int videowriterpref; + std::string encoderparams; + std::vector encoderparamsvec; + 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 @@ -239,11 +245,6 @@ protected: bool track_motion; // Whether this monitor tries to track detected motion Rgb signal_check_colour; // The colour that the camera will emit when no video signal detected - int savejpegspref; - int videowriterpref; - std::string encoderparams; - std::vector encoderparamsvec; - double fps; Image delta_image; Image ref_image; diff --git a/src/zm_video.cpp b/src/zm_video.cpp index 851def599..1ea81a8a9 100644 --- a/src/zm_video.cpp +++ b/src/zm_video.cpp @@ -38,10 +38,17 @@ VideoWriter::~VideoWriter() { } -int VideoWriter::Reset() { +int VideoWriter::Reset(const char* new_path) { /* Common variables reset */ + /* If there is a new path, use it */ + if(new_path != NULL) { + path = new_path; + } + + /* Reset frame counter */ frame_count = 0; + return 0; } @@ -90,8 +97,6 @@ X264MP4Writer::~X264MP4Writer() { if(bOpen) Close(); - - //x264_picture_clean(&x264picout); } @@ -184,9 +189,9 @@ int X264MP4Writer::Close() { return 0; } -int X264MP4Writer::Reset() { +int X264MP4Writer::Reset(const char* new_path) { - VideoWriter::Reset(); + VideoWriter::Reset(new_path); /* Close the encoder and file */ if(bOpen) @@ -345,6 +350,8 @@ void X264MP4Writer::x264encodeloop(bool bFlush) { /* Handle the previous frame */ if(!bFirstFrame) { + buffer.clear(); + /* Process the NALs for the previous frame */ for(unsigned int i=0; i < prevnals.size(); i++) { Debug(9,"Processing NAL: Type %d Size %d",prevnals[i].i_type,prevnals[i].i_payload); @@ -393,10 +400,10 @@ void X264MP4Writer::x264encodeloop(bool bFlush) { /* Update the payload pointers */ /* This is done in a separate loop because the previous loop might reallocate memory when appending, making the pointers invalid */ - unsigned int payload_head = 0; + unsigned int payload_offset = 0; for(unsigned int i=0;i* vec return -2; } + vec->clear(); + if(str[0] == 0) { /* Empty */ return 0; @@ -438,8 +447,6 @@ int ParseEncoderParameters(const char* str, std::vector* vec unsigned int lineno = 0; EncoderParameter_t param; - vec->clear(); - while(std::getline(ss, line) ) { lineno++; diff --git a/src/zm_video.h b/src/zm_video.h index 0bae5fb3d..abb82df8c 100644 --- a/src/zm_video.h +++ b/src/zm_video.h @@ -80,7 +80,7 @@ public: virtual int Encode(const Image* img, const unsigned int frame_time) = 0; virtual int Open() = 0; virtual int Close() = 0; - virtual int Reset(); + virtual int Reset(const char* new_path = NULL); const char* GetContainer() const { return container.c_str(); @@ -166,7 +166,7 @@ public: int Encode(const Image* img, const unsigned int frame_time); int Open(); int Close(); - int Reset(); + int Reset(const char* new_path = NULL); }; #endif // HAVE_LIBX264 && HAVE_LIBMP4V2 && HAVE_LIBAVUTIL && HAVE_LIBSWSCALE diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 6934ccc6b..6fb2c0141 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -418,13 +418,13 @@ $savejpegopts = array( "Disabled" => 0, "Frames only" => 1, "Analysis images only (if available)" => 2, - "Frames + analysis images (if available)" => 3 + "Frames + Analysis images (if available)" => 3 ); $videowriteropts = array( "Disabled" => 0, - "X264 : MP4V2" => 1, - "H264 Passthrough : MP4V2 (not implemented)" => 2 + "X264 : MP4V2" => 1 +// "H264 Passthrough : MP4V2 (not implemented)" => 2 ); xhtmlHeaders(__FILE__, $SLANG['Monitor']." - ".validHtmlStr($monitor['Name']) );