frame: implemented usage of linesizes
Frame will transparently use an optimized linesize for it's allocated data.
This commit is contained in:
+10
-1
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtGlobal>
|
||||
#include <QtMath>
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
@@ -44,6 +45,14 @@ const VideoRenderingParams &Frame::video_params() const
|
||||
void Frame::set_video_params(const VideoRenderingParams ¶ms)
|
||||
{
|
||||
params_ = params;
|
||||
|
||||
// Align linesize to 16
|
||||
linesize_ = qCeil(static_cast<double>(params.width()) / 16.0) * 16;
|
||||
}
|
||||
|
||||
int Frame::linesize() const
|
||||
{
|
||||
return linesize_;
|
||||
}
|
||||
|
||||
const int &Frame::width() const
|
||||
@@ -132,7 +141,7 @@ void Frame::allocate()
|
||||
return;
|
||||
}
|
||||
|
||||
data_.resize(PixelFormat::GetBufferSize(params_.format(), params_.width(), params_.height()));
|
||||
data_.resize(PixelFormat::GetBufferSize(params_.format(), linesize_, params_.height()));
|
||||
}
|
||||
|
||||
bool Frame::is_allocated() const
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
const VideoRenderingParams& video_params() const;
|
||||
void set_video_params(const VideoRenderingParams& params);
|
||||
|
||||
int linesize() const;
|
||||
const int& width() const;
|
||||
const int& height() const;
|
||||
const PixelFormat::Format& format() const;
|
||||
@@ -122,6 +123,8 @@ private:
|
||||
|
||||
rational sample_aspect_ratio_;
|
||||
|
||||
int linesize_;
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
Reference in New Issue
Block a user