[x265] [PATCH 1 of 3] analysis: fix output mismatch in load/save

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Thu Feb 11 08:24:12 CET 2016


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1455024354 -19800
#      Tue Feb 09 18:55:54 2016 +0530
# Node ID 07eb2d73102b7bcd1dceaba3d575e50a8ec85c14
# Parent  822782933427f19e76b34f340a3c52fb4bc95424
analysis: fix output mismatch in load/save

diff -r 822782933427 -r 07eb2d73102b source/common/framedata.h
--- a/source/common/framedata.h	Tue Feb 09 12:05:42 2016 +0530
+++ b/source/common/framedata.h	Tue Feb 09 18:55:54 2016 +0530
@@ -168,6 +168,7 @@
 struct analysis_inter_data
 {
     MV*         mv;
+    WeightParam* wt;
     int32_t*    ref;
     uint8_t*    depth;
     uint8_t*    modes;
diff -r 822782933427 -r 07eb2d73102b source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Tue Feb 09 12:05:42 2016 +0530
+++ b/source/encoder/encoder.cpp	Tue Feb 09 18:55:54 2016 +0530
@@ -1887,6 +1887,7 @@
         CHECKED_MALLOC(interData->modes, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);
         CHECKED_MALLOC_ZERO(interData->bestMergeCand, uint32_t, analysis->numCUsInFrame * CUGeom::MAX_GEOMS);
         CHECKED_MALLOC_ZERO(interData->mv, MV, analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir);
+        CHECKED_MALLOC_ZERO(interData->wt, WeightParam, 3 * numDir);
         analysis->interData = interData;
     }
     return;
@@ -1913,6 +1914,7 @@
         X265_FREE(((analysis_inter_data*)analysis->interData)->modes);
         X265_FREE(((analysis_inter_data*)analysis->interData)->bestMergeCand);
         X265_FREE(((analysis_inter_data*)analysis->interData)->mv);
+        X265_FREE(((analysis_inter_data*)analysis->interData)->wt);
         X265_FREE(analysis->interData);
     }
 }
@@ -2021,6 +2023,7 @@
         X265_FREAD(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile);      
         X265_FREAD(((analysis_inter_data *)analysis->interData)->bestMergeCand, sizeof(uint32_t), analysis->numCUsInFrame * CUGeom::MAX_GEOMS, m_analysisFile);
         X265_FREAD(((analysis_inter_data *)analysis->interData)->mv, sizeof(MV), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile);
+        X265_FREAD(((analysis_inter_data *)analysis->interData)->wt, sizeof(WeightParam), 3 * numDir, m_analysisFile);
         consumedBytes += frameRecordSize;
         if (numDir == 1)
             totalConsumedBytes = consumedBytes;
@@ -2105,6 +2108,7 @@
         analysis->frameRecordSize += depthBytes * 2;
         analysis->frameRecordSize += sizeof(uint32_t) * analysis->numCUsInFrame * CUGeom::MAX_GEOMS;
         analysis->frameRecordSize += sizeof(MV) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir;
+        analysis->frameRecordSize += sizeof(WeightParam) * 3 * numDir;
     }
     X265_FWRITE(&analysis->frameRecordSize, sizeof(uint32_t), 1, m_analysisFile);
     X265_FWRITE(&depthBytes, sizeof(uint32_t), 1, m_analysisFile);
@@ -2130,6 +2134,7 @@
         X265_FWRITE(((analysis_inter_data*)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile);
         X265_FWRITE(((analysis_inter_data*)analysis->interData)->bestMergeCand, sizeof(uint32_t), analysis->numCUsInFrame * CUGeom::MAX_GEOMS, m_analysisFile);
         X265_FWRITE(((analysis_inter_data*)analysis->interData)->mv, sizeof(MV), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile);
+        X265_FWRITE(((analysis_inter_data*)analysis->interData)->wt, sizeof(WeightParam), 3 * numDir, m_analysisFile);
     }
 #undef X265_FWRITE
 }
diff -r 822782933427 -r 07eb2d73102b source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Tue Feb 09 12:05:42 2016 +0530
+++ b/source/encoder/frameencoder.cpp	Tue Feb 09 18:55:54 2016 +0530
@@ -333,18 +333,40 @@
     // Weighted Prediction parameters estimation.
     bool bUseWeightP = slice->m_sliceType == P_SLICE && slice->m_pps->bUseWeightPred;
     bool bUseWeightB = slice->m_sliceType == B_SLICE && slice->m_pps->bUseWeightedBiPred;
+
+    WeightParam* reuseWP = NULL;
+    if (m_param->analysisMode && (bUseWeightP || bUseWeightB))
+        reuseWP = ((analysis_inter_data*)m_frame->m_analysisData.interData)->wt;
+
     if (bUseWeightP || bUseWeightB)
     {
 #if DETAILED_CU_STATS
         m_cuStats.countWeightAnalyze++;
         ScopedElapsedTime time(m_cuStats.weightAnalyzeTime);
 #endif
-        WeightAnalysis wa(*this);
-        if (m_pool && wa.tryBondPeers(*this, 1))
-            /* use an idle worker for weight analysis */
-            wa.waitForExit();
+        if (m_param->analysisMode == X265_ANALYSIS_LOAD)
+        {
+            for (int list = 0; list < slice->isInterB() + 1; list++) 
+            {
+                for (int plane = 0; plane < (m_param->internalCsp != X265_CSP_I400 ? 3 : 1); plane++)
+                {
+                    for (int ref = 1; ref < slice->m_numRefIdx[list]; ref++)
+                        SET_WEIGHT(slice->m_weightPredTable[list][ref][plane], false, 1 << reuseWP->log2WeightDenom, reuseWP->log2WeightDenom, 0);
+                    slice->m_weightPredTable[list][0][plane] = *(reuseWP++);
+                }
+            }
+        }
         else
-            weightAnalyse(*slice, *m_frame, *m_param);
+        {
+            WeightAnalysis wa(*this);
+            if (m_pool && wa.tryBondPeers(*this, 1))
+                /* use an idle worker for weight analysis */
+                wa.waitForExit();
+            else
+                weightAnalyse(*slice, *m_frame, *m_param);
+
+        }
+
     }
     else
         slice->disableWeights();
@@ -361,6 +383,12 @@
             slice->m_refReconPicList[l][ref] = slice->m_refFrameList[l][ref]->m_reconPic;
             m_mref[l][ref].init(slice->m_refReconPicList[l][ref], w, *m_param);
         }
+        if (m_param->analysisMode == X265_ANALYSIS_SAVE && (bUseWeightP || bUseWeightB))
+        {
+            for (int i = 0; i < (m_param->internalCsp != X265_CSP_I400 ? 3 : 1); i++)
+                *(reuseWP++) = slice->m_weightPredTable[l][0][i];
+        }
+
     }
 
     int numTLD;


More information about the x265-devel mailing list