changeset 12628:d2496437286a Release_3.3

Fix: segmentation fault for hist-scenecut option fixes plane size calculation for chroma planes using source resolution and not padded resolution.
author Srikanth Kurapati
date Tue, 17 Mar 2020 13:01:14 +0530
parents f94b0d32737d
children 75fa5a7636b7
files source/encoder/encoder.cpp
diffstat 1 files changed, 9 insertions(+-), 4 deletions(-) [+]
line wrap: on
line diff
--- a/source/encoder/encoder.cpp	Mon Feb 17 20:45:57 2020 +0530
+++ b/source/encoder/encoder.cpp	Tue Mar 17 13:01:14 2020 +0530
@@ -218,10 +218,7 @@ void Encoder::create()
 
     if (m_param->bHistBasedSceneCut)
     {
-        for (int i = 0; i < x265_cli_csps[m_param->internalCsp].planes; i++)
-        {
-            m_planeSizes[i] = (m_param->sourceWidth >> x265_cli_csps[p->internalCsp].width[i]) * (m_param->sourceHeight >> x265_cli_csps[m_param->internalCsp].height[i]);
-        }
+        m_planeSizes[0] = (m_param->sourceWidth >> x265_cli_csps[p->internalCsp].width[0]) * (m_param->sourceHeight >> x265_cli_csps[m_param->internalCsp].height[0]);
         uint32_t pixelbytes = m_param->internalBitDepth > 8 ? 2 : 1;
         m_edgePic = X265_MALLOC(pixel, m_planeSizes[0] * pixelbytes);
         m_edgeHistThreshold = m_param->edgeTransitionThreshold;
@@ -1605,6 +1602,14 @@ int Encoder::encode(const x265_picture* 
         if (m_param->bHistBasedSceneCut && pic_in)
         {
             x265_picture *pic = (x265_picture *) pic_in;
+
+            if (pic->poc == 0)
+            {
+                /* for entire encode compute the chroma plane sizes only once */
+                for (int i = 1; i < x265_cli_csps[m_param->internalCsp].planes; i++)
+                    m_planeSizes[i] = (pic->width >> x265_cli_csps[m_param->internalCsp].width[i]) * (pic->height >> x265_cli_csps[m_param->internalCsp].height[i]);
+            }
+
             if (computeHistograms(pic))
             {
                 double maxUVSad = 0.0, edgeSad = 0.0;