shithub: openh264

Download patch

ref: 03db750ba9b8fe208aa4002d35ba7096e5daf5d2
parent: e4a9c7f8e41b1ffd2fefe6f91b65e4f74b316349
author: Martin Storsjö <[email protected]>
date: Sun May 4 13:35:01 EDT 2014

Limit the ME scanning range to 16 pixels from the end of the buffer

The block size is chosen randomly; if the block size is 16,
LineFullSearch_c will read a block with 16 pixels from kiMaxPos;
thus kiMaxPos cannot be larger than height-16, otherwise the calls
end up with reads out of bounds.

--- a/test/encoder/EncUT_MotionEstimate.cpp
+++ b/test/encoder/EncUT_MotionEstimate.cpp
@@ -174,7 +174,7 @@
                       pMvdCostY, pMvdCostX[ iCurMeBlockQpelPixX ],
                       m_iMaxSearchBlock, m_iWidth,
                       INTPEL_NEEDED_MARGIN,
-                      m_iHeight-INTPEL_NEEDED_MARGIN, true );
+                      m_iHeight-INTPEL_NEEDED_MARGIN-16, true );
 
     //the last selection may be affected by MVDcost, that is when smaller MvY will be better
     bFoundMatch = (sMe.sMv.iMvX==0
@@ -235,7 +235,7 @@
                       pMvdCostX, pMvdCostY[ iCurMeBlockQpelPixY ],
                       m_iMaxSearchBlock, m_iWidth,
                       INTPEL_NEEDED_MARGIN,
-                      m_iWidth-INTPEL_NEEDED_MARGIN, false );
+                      m_iWidth-INTPEL_NEEDED_MARGIN-16, false );
 
     //the last selection may be affected by MVDcost, that is when smaller MvY will be better
     bFoundMatch = (sMe.sMv.iMvY==0
@@ -303,7 +303,7 @@
                       pMvdCostY, pMvdCostX[ iCurMeBlockQpelPixX ],
                       m_iMaxSearchBlock, m_iWidth,
                       INTPEL_NEEDED_MARGIN,
-                      m_iHeight-INTPEL_NEEDED_MARGIN, true );
+                      m_iHeight-INTPEL_NEEDED_MARGIN-16, true );
 
     //the last selection may be affected by MVDcost, that is when smaller MvY will be better
     bFoundMatch = (sMe.sMv.iMvX==0
@@ -369,7 +369,7 @@
                       pMvdCostX, pMvdCostY[ iCurMeBlockQpelPixY ],
                       m_iMaxSearchBlock, m_iWidth,
                       INTPEL_NEEDED_MARGIN,
-                      m_iWidth-INTPEL_NEEDED_MARGIN, false );
+                      m_iWidth-INTPEL_NEEDED_MARGIN-16, false );
 
     //the last selection may be affected by MVDcost, that is when smaller MvY will be better
     bFoundMatch = (sMe.sMv.iMvY==0