diff --git a/es-core/src/components/VideoFFmpegComponent.cpp b/es-core/src/components/VideoFFmpegComponent.cpp index 566d1b48a..5ec94bd4b 100644 --- a/es-core/src/components/VideoFFmpegComponent.cpp +++ b/es-core/src/components/VideoFFmpegComponent.cpp @@ -54,6 +54,7 @@ VideoFFmpegComponent::VideoFFmpegComponent() , mVideoTargetQueueSize {0} , mAudioTargetQueueSize {0} , mVideoTimeBase {0.0l} + , mLinePaddingComp {0.0f} , mAccumulatedTime {0.0l} , mStartTimeAccumulation {false} , mDecodedFrame {false} @@ -212,11 +213,13 @@ void VideoFFmpegComponent::render(const glm::mat4& parentTrans) if (!mDecodedFrame) return; + const float paddingComp {mLinePaddingComp}; + // clang-format off - vertices[0] = {{0.0f, 0.0f }, {mTopLeftCrop.x - mCropOffset.x, 1.0f - mBottomRightCrop.y + mCropOffset.y}, 0xFFFFFFFF}; - vertices[1] = {{0.0f, mSize.y}, {mTopLeftCrop.x - mCropOffset.x, 1.0f - mTopLeftCrop.y + mCropOffset.y }, 0xFFFFFFFF}; - vertices[2] = {{mSize.x, 0.0f }, {(mBottomRightCrop.x * 1.0f) - mCropOffset.x, 1.0f - mBottomRightCrop.y + mCropOffset.y}, 0xFFFFFFFF}; - vertices[3] = {{mSize.x, mSize.y}, {(mBottomRightCrop.x * 1.0f) - mCropOffset.x, 1.0f - mTopLeftCrop.y + mCropOffset.y }, 0xFFFFFFFF}; + vertices[0] = {{0.0f, 0.0f }, {mTopLeftCrop.x - mCropOffset.x, 1.0f - mBottomRightCrop.y + mCropOffset.y}, 0xFFFFFFFF}; + vertices[1] = {{0.0f, mSize.y}, {mTopLeftCrop.x - mCropOffset.x, 1.0f - mTopLeftCrop.y + mCropOffset.y }, 0xFFFFFFFF}; + vertices[2] = {{mSize.x, 0.0f }, {(mBottomRightCrop.x * 1.0f) - mCropOffset.x - paddingComp, 1.0f - mBottomRightCrop.y + mCropOffset.y}, 0xFFFFFFFF}; + vertices[3] = {{mSize.x, mSize.y}, {(mBottomRightCrop.x * 1.0f) - mCropOffset.x - paddingComp, 1.0f - mTopLeftCrop.y + mCropOffset.y }, 0xFFFFFFFF}; // clang-format on vertices[0].color = mColorShift; @@ -847,6 +850,16 @@ void VideoFFmpegComponent::getProcessedFrames() const int bytesPerPixel {4}; const int width {mVideoFrameResampled->linesize[0] / bytesPerPixel}; + // For performance reasons the linesize value may padded to a larger size than the + // usable data. This seems to happen mostly (only?) on Windows. If this occurs we + // need to compensate for this when calculating the vertices in render(). + if (width != mVideoFrameResampled->width && width > 0) { + const float linePaddingComp {static_cast(width - mVideoFrameResampled->width) / + static_cast(width)}; + if (linePaddingComp != 0.0f) + mLinePaddingComp = linePaddingComp; + } + currFrame.width = width; currFrame.height = mVideoFrameResampled->height; diff --git a/es-core/src/components/VideoFFmpegComponent.h b/es-core/src/components/VideoFFmpegComponent.h index 24691dc17..af5cbcdb6 100644 --- a/es-core/src/components/VideoFFmpegComponent.h +++ b/es-core/src/components/VideoFFmpegComponent.h @@ -171,6 +171,7 @@ private: int mVideoFrameReadCount; int mVideoFrameDroppedCount; + std::atomic mLinePaddingComp; std::atomic mAccumulatedTime; std::atomic mStartTimeAccumulation; std::atomic mDecodedFrame;