diff --git a/app/decoder/frame.cpp b/app/decoder/frame.cpp index 464566491..8211be699 100644 --- a/app/decoder/frame.cpp +++ b/app/decoder/frame.cpp @@ -27,46 +27,10 @@ Frame::Frame() : width_(0), - height_(0), - data_(nullptr) + height_(0) { } -Frame::Frame(const Frame &f) : - data_(nullptr) -{ - Q_UNUSED(f) -} - -Frame::Frame(Frame &&f) : - data_(f.data_) -{ - f.data_ = nullptr; -} - -Frame &Frame::operator=(const Frame &f) -{ - Q_UNUSED(f) - - data_ = nullptr; - return *this; -} - -Frame &Frame::operator=(Frame &&f) -{ - if (&f != this) { - data_ = f.data_; - f.data_ = nullptr; - } - - return *this; -} - -Frame::~Frame() -{ - destroy(); -} - const int &Frame::width() { return width_; @@ -109,23 +73,19 @@ void Frame::set_format(const int &format) uint8_t *Frame::data() { - return data_; + return data_.data(); } const uint8_t *Frame::const_data() { - return data_; + return data_.constData(); } void Frame::allocate() { - if (data_ != nullptr) { - destroy(); - } - // Assume this frame is intended to be a video frame if (width_ > 0 && height_ > 0) { - data_ = new uint8_t[PixelService::GetBufferSize(static_cast(format_), width_, height_)]; + data_.resize(PixelService::GetBufferSize(static_cast(format_), width_, height_)); } // FIXME: Audio sample allocation @@ -133,6 +93,5 @@ void Frame::allocate() void Frame::destroy() { - delete [] data_; - data_ = nullptr; + data_.clear(); } diff --git a/app/decoder/frame.h b/app/decoder/frame.h index a18dc8333..6151e4533 100644 --- a/app/decoder/frame.h +++ b/app/decoder/frame.h @@ -22,6 +22,7 @@ #define FRAME_H #include +#include #include "common/rational.h" #include "render/pixelformat.h" @@ -39,21 +40,6 @@ public: /// Normal constructor Frame(); - /// Copy constructor - Frame(const Frame& f); - - /// Move constructor - Frame(Frame&& f); - - /// Copy assignment operator - Frame& operator=(const Frame& f); - - /// Move assignment operator - Frame& operator=(Frame&& f); - - /// Destructor - ~Frame(); - /** * @brief Get frame's width in pixels */ @@ -115,7 +101,7 @@ private: int format_; - uint8_t* data_; + QVector data_; rational timestamp_;