diff --git a/src/Frame.cpp b/src/Frame.cpp index 3561875..d9aec6f 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -91,11 +91,8 @@ Frame::Frame(int _width, -Frame::Frame(Frame &src) +Frame::Frame(Frame const& src) { - // free memory if allocated before. - release(); - // Copy fields. width = src.width; height = src.height; @@ -267,7 +264,7 @@ void Frame::cloneTo(Frame& dst) -bool Frame::operator==(Frame &src) +bool Frame::operator==(Frame const& src) const { // Check yourself. if (this == &src) @@ -296,31 +293,9 @@ bool Frame::operator==(Frame &src) -bool Frame::operator!=(Frame &src) +bool Frame::operator!=(Frame const& src) const { - // Check yourself. - if (this == &src) - return false; - - // Check frame atributes. - if (width != src.width || - height != src.height || - fourcc != src.fourcc || - frameId != src.frameId || - sourceId != src.sourceId || - size != src.size) - return true; - - // Compare frame data. - if (data == src.data) - return false; - - if (size > 0 && src.size > 0) - for (int i = 0; i < size; ++i) - if (data[i] != src.data[i]) - return true; - - return false; + return !(*this == src); } @@ -478,4 +453,4 @@ bool Frame::deserialize(uint8_t* _data, int _size) memcpy(data, &_data[pos], size); return true; -} \ No newline at end of file +} diff --git a/src/Frame.h b/src/Frame.h index 84efc32..f792fd3 100644 --- a/src/Frame.h +++ b/src/Frame.h @@ -96,7 +96,7 @@ class Frame * @brief Copy class constructor. * @param src Source class object. */ - Frame(Frame& src); + Frame(Frame const& src); /** * @brief Class destructor. @@ -114,14 +114,14 @@ class Frame * @param src Source frame object. * @return TRUE if the frames are not identical or FALSE. */ - bool operator!= (Frame& src); + bool operator!= (Frame const& src) const; /** * @brief Operator "==". Operator to compare two frame objects. * @param src Source frame object. * @return TRUE if the frames are identical or FALSE. */ - bool operator== (Frame& src); + bool operator== (Frame const& src) const; /** * @brief Clone data. Method copies frame and copy just pointer to data. @@ -171,4 +171,4 @@ class Frame bool m_isAllocated{false}; }; } -} \ No newline at end of file +}