diff --git a/app/codec/frame.cpp b/app/codec/frame.cpp index 0b23ce968..d428ac31a 100644 --- a/app/codec/frame.cpp +++ b/app/codec/frame.cpp @@ -22,6 +22,7 @@ #include #include +#include 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(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 diff --git a/app/codec/frame.h b/app/codec/frame.h index 0c3e1e8ed..014a261ba 100644 --- a/app/codec/frame.h +++ b/app/codec/frame.h @@ -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