From fc18e768427d9f946e97967b7c88d9a7452c8844 Mon Sep 17 00:00:00 2001 From: jpsdr Date: Fri, 17 Jul 2020 20:16:04 +0200 Subject: [PATCH] Duplicate destination result line is better... Signed-off-by: jpsdr --- nnedi3/nnedi3.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nnedi3/nnedi3.cpp b/nnedi3/nnedi3.cpp index 14189c4..a469b45 100644 --- a/nnedi3/nnedi3.cpp +++ b/nnedi3/nnedi3.cpp @@ -1204,15 +1204,13 @@ PVideoFrame __stdcall nnedi3::GetFrame(int n, IScriptEnvironment *env) if (vi.Is420() && ((vi.height & 3)!=0)) { - ptrdiff_t src_offsetU=(src->GetHeight(PLANAR_U)-1)*src->GetPitch(PLANAR_U); - ptrdiff_t src_offsetV=(src->GetHeight(PLANAR_V)-1)*src->GetPitch(PLANAR_V); - ptrdiff_t dst_offsetU=(dst->GetHeight(PLANAR_U)-1)*dst->GetPitch(PLANAR_U); - ptrdiff_t dst_offsetV=(dst->GetHeight(PLANAR_V)-1)*dst->GetPitch(PLANAR_V); - - memcpy(dst->GetWritePtr(PLANAR_U)+dst_offsetU,src->GetReadPtr(PLANAR_U)+src_offsetU, - src->GetRowSize(PLANAR_U)); - memcpy(dst->GetWritePtr(PLANAR_V)+dst_offsetV,src->GetReadPtr(PLANAR_V)+src_offsetV, - src->GetRowSize(PLANAR_V)); + ptrdiff_t dst_offsetU=(dst->GetHeight(PLANAR_U)-2)*dst->GetPitch(PLANAR_U); + ptrdiff_t dst_offsetV=(dst->GetHeight(PLANAR_V)-2)*dst->GetPitch(PLANAR_V); + + memcpy(dst->GetWritePtr(PLANAR_U)+(dst_offsetU+dst->GetPitch(PLANAR_U)), + dst->GetWritePtr(PLANAR_U)+dst_offsetU,dst->GetRowSize(PLANAR_U)); + memcpy(dst->GetWritePtr(PLANAR_V)+(dst_offsetV+dst->GetPitch(PLANAR_V)), + dst->GetWritePtr(PLANAR_V)+dst_offsetV,dst->GetRowSize(PLANAR_V)); } return dst;