From d020b36062c174f09c64c28e27d63e3f4b6ec5dd Mon Sep 17 00:00:00 2001
From: rlliao <ruling.liao@sg.panasonic.com>
Date: Fri, 7 Dec 2018 10:24:18 +0800
Subject: [PATCH] Fix ticket #130 Incorrect scaling operation in triangle list
 derivation

---
 source/Lib/CommonLib/UnitTools.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp
index a2be738ba..fee9892d7 100644
--- a/source/Lib/CommonLib/UnitTools.cpp
+++ b/source/Lib/CommonLib/UnitTools.cpp
@@ -4980,7 +4980,11 @@ void PU::getTriangleMergeCandidates( const PredictionUnit &pu, MergeCtx& triangl
       int32_t refPicPocL0 = slice.getRefPOC(REF_PIC_LIST_0, candidate[i].refIdx[0]);
       int32_t refPicPocL1 = slice.getRefPOC(REF_PIC_LIST_1, candidate[i].refIdx[1]);
       Mv aveMv = candidate[i].mv[1];
-      aveMv = aveMv.scaleMv( xGetDistScaleFactor( curPicPoc, refPicPocL0, curPicPoc, refPicPocL1 ) ); // scaling to L0
+      int32_t distscale = xGetDistScaleFactor( curPicPoc, refPicPocL0, curPicPoc, refPicPocL1 );
+      if( distscale != 4096 )
+      {
+        aveMv = aveMv.scaleMv( distscale ); // scaling to L0
+      }
       aveMv.setHor( ( aveMv.getHor() + candidate[i].mv[0].getHor() + 1 ) >> 1 );
       aveMv.setVer( ( aveMv.getVer() + candidate[i].mv[0].getVer() + 1 ) >> 1 );
           
-- 
GitLab