From 2cb6cfeb7a209e8baf4cbbd3c4e47b670cff17a8 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Sat, 1 Mar 2014 17:06:54 +0800 Subject: [PATCH] effective and padded line sizes for a video frame --- src/QtAV/VideoFrame.h | 6 ++++++ src/VideoFrame.cpp | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/QtAV/VideoFrame.h b/src/QtAV/VideoFrame.h index 8b86c860..a9b94991 100644 --- a/src/QtAV/VideoFrame.h +++ b/src/QtAV/VideoFrame.h @@ -68,9 +68,15 @@ public: //int width(int plane = 0) const? int width() const; int height() const; + // plane width without padded bytes. + int effectivePlaneWidth(int plane) const; + // plane width with padded bytes for alignment. int planeWidth(int plane) const; int planeHeight(int plane) const; + // no padded bytes + int effectiveBytesPerLine(int plane) const; + //use ptr instead of ImageConverterId to avoid allocating memory // Id can be used in VideoThread void setImageConverter(ImageConverter *conv); diff --git a/src/VideoFrame.cpp b/src/VideoFrame.cpp index 4a5057fa..13a7de37 100644 --- a/src/VideoFrame.cpp +++ b/src/VideoFrame.cpp @@ -258,12 +258,16 @@ int VideoFrame::height() const return d_func()->height; } +int VideoFrame::effectivePlaneWidth(int plane) const +{ + Q_D(const VideoFrame); + return effectiveBytesPerLine(plane)/d->format.bytesPerPixel(plane); +} + int VideoFrame::planeWidth(int plane) const { Q_D(const VideoFrame); - if (plane == 0) - return d->width; - return d->format.chromaWidth(d->width); + return bytesPerLine(plane)/d->format.bytesPerPixel(plane); } int VideoFrame::planeHeight(int plane) const @@ -274,6 +278,12 @@ int VideoFrame::planeHeight(int plane) const return d->format.chromaHeight(d->height); } +int VideoFrame::effectiveBytesPerLine(int plane) const +{ + Q_D(const VideoFrame); + return d->format.bytesPerLine(width(), plane); +} + void VideoFrame::setImageConverter(ImageConverter *conv) { d_func()->conv = conv;