Move the decoding_enabled logic to constructor to save a few cycles
This commit is contained in:
parent
5c1135b2a7
commit
f77292e6cc
|
@ -463,6 +463,18 @@ Monitor::Monitor(
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
// Do this here to save a few cycles with all the comparisons
|
||||
decoding_enabled = !(
|
||||
( function == RECORD or function == NODECT )
|
||||
and
|
||||
( savejpegs == 0 )
|
||||
and
|
||||
( videowriter == H264PASSTHROUGH )
|
||||
and
|
||||
!decoding_enabled
|
||||
);
|
||||
Debug(1, "Decoding enabled: %d", decoding_enabled);
|
||||
|
||||
memset(mem_ptr, 0, mem_size);
|
||||
shared_data->size = sizeof(SharedData);
|
||||
shared_data->active = enabled;
|
||||
|
@ -1874,7 +1886,7 @@ void Monitor::Reload() {
|
|||
if ( !row ) {
|
||||
Error("Can't run query: %s", mysql_error(&dbconn));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ( MYSQL_ROW dbrow = row->mysql_row() ) {
|
||||
int index = 0;
|
||||
function = (Function)atoi(dbrow[index++]);
|
||||
|
|
|
@ -253,6 +253,7 @@ protected:
|
|||
CameraType type;
|
||||
Function function; // What the monitor is doing
|
||||
bool enabled; // Whether the monitor is enabled or asleep
|
||||
bool decoding_enabled; // Whether the monitor will decode h264/h265 packets
|
||||
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
|
||||
bool v4l_multi_buffer;
|
||||
|
@ -447,15 +448,7 @@ public:
|
|||
return enabled;
|
||||
}
|
||||
inline bool DecodingEnabled() const {
|
||||
return !(
|
||||
( monitor->GetFunction() == Monitor::RECORD or monitor->GetFunction() == Monitor::NODECT )
|
||||
and
|
||||
( monitor->GetOptSaveJPEGs() == 0 )
|
||||
and
|
||||
( monitor->GetOptVideoWriter() == Monitor::H264PASSTHROUGH )
|
||||
and
|
||||
!decoding_enabled
|
||||
);
|
||||
return decoding_enabled;
|
||||
}
|
||||
inline const char *EventPrefix() const { return event_prefix; }
|
||||
inline bool Ready() const {
|
||||
|
|
Loading…
Reference in New Issue