Few minor code improvements

This commit is contained in:
Kfir Itzhak 2013-12-22 15:19:55 +02:00
parent 283f71625b
commit 8ae387e376
4 changed files with 28 additions and 20 deletions

View File

@ -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<EncoderParameter_t> 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<EncoderParameter_t> encoderparamsvec;
double fps;
Image delta_image;
Image ref_image;

View File

@ -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<prevnals.size();i++) {
prevnals[i].p_payload = prevpayload.head() + payload_head;
payload_head += nals[i].i_payload;
prevnals[i].p_payload = prevpayload.head() + payload_offset;
payload_offset += nals[i].i_payload;
}
/* We need this for the next frame */
@ -426,6 +433,8 @@ int ParseEncoderParameters(const char* str, std::vector<EncoderParameter_t>* vec
return -2;
}
vec->clear();
if(str[0] == 0) {
/* Empty */
return 0;
@ -438,8 +447,6 @@ int ParseEncoderParameters(const char* str, std::vector<EncoderParameter_t>* vec
unsigned int lineno = 0;
EncoderParameter_t param;
vec->clear();
while(std::getline(ss, line) ) {
lineno++;

View File

@ -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

View File

@ -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']) );