From eb6b9217ab917ed6dede734cddd678a0cc4389e4 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 22 Apr 2020 15:19:04 +1000 Subject: [PATCH] frame: implemented usage of linesizes Frame will transparently use an optimized linesize for it's allocated data. --- app/codec/frame.cpp | 11 ++++++++++- app/codec/frame.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) 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