[x265] [PATCH] fix crash in hrd when init function is called with null pointer

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Wed Jun 4 12:09:40 CEST 2014


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1401876457 -19800
#      Wed Jun 04 15:37:37 2014 +0530
# Node ID 794c6ad0c9d57d23728bec1686638e7dc0f13f9a
# Parent  1fe42453d2e3ce15de4f385284a21fadc615ead2
fix crash in hrd when init function is called with null pointer

diff -r 1fe42453d2e3 -r 794c6ad0c9d5 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Wed Jun 04 11:05:29 2014 +0530
+++ b/source/encoder/ratecontrol.cpp	Wed Jun 04 15:37:37 2014 +0530
@@ -383,12 +383,16 @@
         int vbvBufferSize = param->rc.vbvBufferSize * 1000;
         int vbvMaxBitrate = param->rc.vbvMaxBitrate * 1000;
 
-        TComHRD* hrd = sps->getVuiParameters()->getHrdParameters();
-        if (hrd->getNalHrdParametersPresentFlag())
+        if (param->bEmitHRDSEI)
         {
-            vbvBufferSize = (hrd->getCpbSizeValueMinus1(0, 0, 0) + 1) << (hrd->getCpbSizeScale() + CPB_SHIFT);
-            vbvMaxBitrate = (hrd->getBitRateValueMinus1(0, 0, 0) + 1) << (hrd->getBitRateScale() + BR_SHIFT);
+            TComHRD* hrd = sps->getVuiParameters()->getHrdParameters();
+            if (!hrd && hrd->getNalHrdParametersPresentFlag())
+            {
+                vbvBufferSize = (hrd->getCpbSizeValueMinus1(0, 0, 0) + 1) << (hrd->getCpbSizeScale() + CPB_SHIFT);
+                vbvMaxBitrate = (hrd->getBitRateValueMinus1(0, 0, 0) + 1) << (hrd->getBitRateScale() + BR_SHIFT);
+            }
         }
+
         bufferRate = vbvMaxBitrate / fps;
         vbvMaxRate = vbvMaxBitrate;
         bufferSize = vbvBufferSize;
@@ -459,9 +463,6 @@
     hrd->setDpbOutputDelayLengthMinus1(Clip3(4, 31, 32 - calcLength(maxDpbOutputDelay)) - 1);
 
     #undef MAX_DURATION
-
-    vbvBufferSize = cpbSizeUnscale;
-    vbvMaxBitrate = bitRateUnscale;
 }
 
 void RateControl::rateControlStart(TComPic* pic, Lookahead *l, RateControlEntry* rce, Encoder* enc)
@@ -718,7 +719,7 @@
             double underflow = 1.0 + (totalBits - wantedBitsWindow) / abrBuffer;
             if (underflow < 0.9 && !isFrameDone)
             {
-                init(NULL);
+                init(curSlice->getSPS());
                 shortTermCplxSum = rce->lastSatd / (CLIP_DURATION(frameDuration) / BASE_FRAME_DURATION);
                 shortTermCplxCount = 1;
                 isAbrReset = true;


More information about the x265-devel mailing list