[x265] [PATCH] analysis: allocate analysis load/save memory based on slicetype

sagar at multicorewareinc.com sagar at multicorewareinc.com
Fri Dec 18 14:23:32 CET 2015


# HG changeset patch
# User Sagar Kotecha<sagar at multicorewareinc.com>
# Date 1450440620 -19800
#      Fri Dec 18 17:40:20 2015 +0530
# Node ID 81476a951bd84dbf2a261387b32e8dd302ef97fa
# Parent  942587f1ab4484ce69a818ce9c8adc59c38fe239
analysis: allocate analysis load/save memory based on slicetype

diff -r 942587f1ab44 -r 81476a951bd8 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Wed Dec 16 09:08:00 2015 +0530
+++ b/source/encoder/encoder.cpp	Fri Dec 18 17:40:20 2015 +0530
@@ -1857,6 +1857,7 @@
 
 void Encoder::allocAnalysis(x265_analysis_data* analysis)
 {
+    X265_CHECK(analysis->sliceType, "invalid slice type\n");
     analysis->interData = analysis->intraData = NULL;
     if (analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I)
     {
@@ -1870,13 +1871,14 @@
     }
     else
     {
+        int numDir = analysis->sliceType == X265_TYPE_P ? 1 : 2;
         analysis_inter_data *interData = (analysis_inter_data*)analysis->interData;
         CHECKED_MALLOC_ZERO(interData, analysis_inter_data, 1);
-        CHECKED_MALLOC_ZERO(interData->ref, int32_t, analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2);
+        CHECKED_MALLOC_ZERO(interData->ref, int32_t, analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir);
         CHECKED_MALLOC(interData->depth, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);
         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 * 2);
+        CHECKED_MALLOC_ZERO(interData->mv, MV, analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir);
         analysis->interData = interData;
     }
     return;


More information about the x265-devel mailing list