[x265-commits] [x265] slicetype: remove unused numDecided member variable

Steve Borho steve at borho.org
Fri Jan 24 20:00:32 CET 2014


details:   http://hg.videolan.org/x265/rev/f2766083c252
branches:  
changeset: 5880:f2766083c252
user:      Steve Borho <steve at borho.org>
date:      Thu Jan 23 18:55:22 2014 -0600
description:
slicetype: remove unused numDecided member variable
Subject: [x265] testbench: added the chroma_addAvg primitives.

details:   http://hg.videolan.org/x265/rev/5460e85ae178
branches:  
changeset: 5881:5460e85ae178
user:      Deepthi Nandakumar <deepthi at multicorewareinc.com>
date:      Fri Jan 24 07:43:33 2014 +0530
description:
testbench: added the chroma_addAvg primitives.
Subject: [x265] slicetype: upgrade frame cost variables to uint64_t

details:   http://hg.videolan.org/x265/rev/629d0a685dcb
branches:  stable
changeset: 5882:629d0a685dcb
user:      Steve Borho <steve at borho.org>
date:      Thu Jan 23 19:13:56 2014 -0600
description:
slicetype: upgrade frame cost variables to uint64_t
Subject: [x265] Merge with stable

details:   http://hg.videolan.org/x265/rev/099a71435329
branches:  
changeset: 5883:099a71435329
user:      Steve Borho <steve at borho.org>
date:      Thu Jan 23 20:34:48 2014 -0600
description:
Merge with stable
Subject: [x265] preset: re-disable lookahead at ultrafast preset

details:   http://hg.videolan.org/x265/rev/c2af7808ef8d
branches:  
changeset: 5884:c2af7808ef8d
user:      Steve Borho <steve at borho.org>
date:      Thu Jan 23 19:29:28 2014 -0600
description:
preset: re-disable lookahead at ultrafast preset
Subject: [x265] slicetype: repair I frame placement with lookahead disabled

details:   http://hg.videolan.org/x265/rev/f0ae3d8d2b03
branches:  
changeset: 5885:f0ae3d8d2b03
user:      Steve Borho <steve at borho.org>
date:      Thu Jan 23 19:41:38 2014 -0600
description:
slicetype: repair I frame placement with lookahead disabled

if ((true || foo) && bar) properly degrades to if (bar)
Subject: [x265] white-space and other nits

details:   http://hg.videolan.org/x265/rev/438a2258504d
branches:  
changeset: 5886:438a2258504d
user:      Steve Borho <steve at borho.org>
date:      Thu Jan 23 19:14:14 2014 -0600
description:
white-space and other nits
Subject: [x265] nit

details:   http://hg.videolan.org/x265/rev/23c65133c555
branches:  
changeset: 5887:23c65133c555
user:      Steve Borho <steve at borho.org>
date:      Thu Jan 23 20:41:05 2014 -0600
description:
nit
Subject: [x265] lowres: fix msys compile error

details:   http://hg.videolan.org/x265/rev/f45d9772cc40
branches:  stable
changeset: 5888:f45d9772cc40
user:      Deepthi Nandakumar <deepthi at multicorewareinc.com>
date:      Fri Jan 24 11:46:39 2014 +0530
description:
lowres: fix msys compile error
Subject: [x265] Merge with stable

details:   http://hg.videolan.org/x265/rev/807495b7a9fc
branches:  
changeset: 5889:807495b7a9fc
user:      Deepthi Nandakumar <deepthi at multicorewareinc.com>
date:      Fri Jan 24 11:50:23 2014 +0530
description:
Merge with stable
Subject: [x265] slicetype: change all costs to int64_t

details:   http://hg.videolan.org/x265/rev/8dd9b7ac5b61
branches:  stable
changeset: 5890:8dd9b7ac5b61
user:      Deepthi Nandakumar <deepthi at multicorewareinc.com>
date:      Fri Jan 24 12:59:44 2014 +0530
description:
slicetype: change all costs to int64_t
Subject: [x265] slicetype: fix bcost behavior with signed ints

details:   http://hg.videolan.org/x265/rev/0431eb3404e7
branches:  stable
changeset: 5891:0431eb3404e7
user:      Steve Borho <steve at borho.org>
date:      Fri Jan 24 09:51:28 2014 -0600
description:
slicetype: fix bcost behavior with signed ints
Subject: [x265] nits

details:   http://hg.videolan.org/x265/rev/c02e59ab4ee9
branches:  stable
changeset: 5892:c02e59ab4ee9
user:      Steve Borho <steve at borho.org>
date:      Fri Jan 24 09:52:54 2014 -0600
description:
nits
Subject: [x265] reference: pad width of weighted region to multiple of 16

details:   http://hg.videolan.org/x265/rev/2ab2bb459d1a
branches:  stable
changeset: 5893:2ab2bb459d1a
user:      Steve Borho <steve at borho.org>
date:      Fri Jan 24 10:08:34 2014 -0600
description:
reference: pad width of weighted region to multiple of 16
Subject: [x265] fix b-pyramid for fixed GOP

details:   http://hg.videolan.org/x265/rev/ffee1032eaed
branches:  stable
changeset: 5894:ffee1032eaed
user:      Satoshi Nakagawa <nakagawa424 at oki.com>
date:      Fri Jan 24 15:47:21 2014 +0900
description:
fix b-pyramid for fixed GOP
Subject: [x265] Merge with stable

details:   http://hg.videolan.org/x265/rev/047fd4670cbe
branches:  
changeset: 5895:047fd4670cbe
user:      Steve Borho <steve at borho.org>
date:      Fri Jan 24 11:52:12 2014 -0600
description:
Merge with stable
Subject: [x265] slicetype: prevent compiler warnings about uninitialized variables

details:   http://hg.videolan.org/x265/rev/2a2e5711f63b
branches:  stable
changeset: 5896:2a2e5711f63b
user:      Steve Borho <steve at borho.org>
date:      Fri Jan 24 12:57:46 2014 -0600
description:
slicetype: prevent compiler warnings about uninitialized variables
Subject: [x265] Merge with stable

details:   http://hg.videolan.org/x265/rev/7cd3a3195598
branches:  
changeset: 5897:7cd3a3195598
user:      Steve Borho <steve at borho.org>
date:      Fri Jan 24 12:59:47 2014 -0600
description:
Merge with stable

diffstat:

 source/common/common.cpp       |   1 +
 source/common/common.h         |   1 +
 source/common/lowres.cpp       |   8 +++---
 source/common/lowres.h         |   6 ++--
 source/encoder/ratecontrol.cpp |  12 ++++----
 source/encoder/ratecontrol.h   |  15 ++++++-----
 source/encoder/reference.cpp   |   3 +-
 source/encoder/slicetype.cpp   |  51 ++++++++++++++++++++---------------------
 source/encoder/slicetype.h     |  25 +++++++++----------
 source/test/pixelharness.cpp   |  13 ++++++++++
 10 files changed, 75 insertions(+), 60 deletions(-)

diffs (truncated from 448 to 300 lines):

diff -r 416713ab5821 -r 7cd3a3195598 source/common/common.cpp
--- a/source/common/common.cpp	Thu Jan 23 18:37:10 2014 -0600
+++ b/source/common/common.cpp	Fri Jan 24 12:59:47 2014 -0600
@@ -275,6 +275,7 @@ int x265_param_default_preset(x265_param
         if (!strcmp(preset, "ultrafast"))
         {
             param->lookaheadDepth = 10;
+            param->scenecutThreshold = 0; // disable lookahead
             param->maxCUSize = 32;
             param->searchRange = 28;
             param->bFrameAdaptive = 0;
diff -r 416713ab5821 -r 7cd3a3195598 source/common/common.h
--- a/source/common/common.h	Thu Jan 23 18:37:10 2014 -0600
+++ b/source/common/common.h	Fri Jan 24 12:59:47 2014 -0600
@@ -25,6 +25,7 @@
 #define X265_COMMON_H
 
 #include <cstdlib>
+#include <cstring>
 #include "x265.h"
 
 #define X265_MIN(a, b) ((a) < (b) ? (a) : (b))
diff -r 416713ab5821 -r 7cd3a3195598 source/common/lowres.cpp
--- a/source/common/lowres.cpp	Thu Jan 23 18:37:10 2014 -0600
+++ b/source/common/lowres.cpp	Fri Jan 24 12:59:47 2014 -0600
@@ -65,7 +65,7 @@ void Lowres::create(TComPicYuv *orig, in
     lowresPlane[2] = buffer[2] + padoffset;
     lowresPlane[3] = buffer[3] + padoffset;
 
-    intraCost = (int32_t*)X265_MALLOC(int, cuCount);
+    intraCost = (int32_t*)X265_MALLOC(int32_t, cuCount);
 
     for (int i = 0; i < bframes + 2; i++)
     {
@@ -80,8 +80,8 @@ void Lowres::create(TComPicYuv *orig, in
     {
         lowresMvs[0][i] = (MV*)X265_MALLOC(MV, cuCount);
         lowresMvs[1][i] = (MV*)X265_MALLOC(MV, cuCount);
-        lowresMvCosts[0][i] = (int32_t*)X265_MALLOC(int, cuCount);
-        lowresMvCosts[1][i] = (int32_t*)X265_MALLOC(int, cuCount);
+        lowresMvCosts[0][i] = (int32_t*)X265_MALLOC(int32_t, cuCount);
+        lowresMvCosts[1][i] = (int32_t*)X265_MALLOC(int32_t, cuCount);
     }
 }
 
@@ -127,7 +127,7 @@ void Lowres::init(TComPicYuv *orig, int 
     sliceType = type;
     frameNum = poc;
     leadingBframes = 0;
-    satdCost = -1;
+    satdCost = (int64_t)-1;
     memset(costEst, -1, sizeof(costEst));
 
     if (qpAqOffset && invQscaleFactor)
diff -r 416713ab5821 -r 7cd3a3195598 source/common/lowres.h
--- a/source/common/lowres.h	Thu Jan 23 18:37:10 2014 -0600
+++ b/source/common/lowres.h	Fri Jan 24 12:59:47 2014 -0600
@@ -112,12 +112,12 @@ struct Lowres : public ReferencePlanes
     bool   bLastMiniGopBFrame;
 
     /* lookahead output data */
-    int       costEst[X265_BFRAME_MAX + 2][X265_BFRAME_MAX + 2];
-    int       costEstAq[X265_BFRAME_MAX + 2][X265_BFRAME_MAX + 2];
+    int64_t   costEst[X265_BFRAME_MAX + 2][X265_BFRAME_MAX + 2];
+    int64_t   costEstAq[X265_BFRAME_MAX + 2][X265_BFRAME_MAX + 2];
     int32_t*  rowSatds[X265_BFRAME_MAX + 2][X265_BFRAME_MAX + 2];
     int       intraMbs[X265_BFRAME_MAX + 2];
     int32_t*  intraCost;
-    int       satdCost;
+    int64_t   satdCost;
     uint16_t(*lowresCosts[X265_BFRAME_MAX + 2][X265_BFRAME_MAX + 2]);
     int32_t*  lowresMvCosts[2][X265_BFRAME_MAX + 1];
     MV*       lowresMvs[2][X265_BFRAME_MAX + 1];
diff -r 416713ab5821 -r 7cd3a3195598 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Thu Jan 23 18:37:10 2014 -0600
+++ b/source/encoder/ratecontrol.cpp	Fri Jan 24 12:59:47 2014 -0600
@@ -534,7 +534,7 @@ double RateControl::rateEstimateQscale(R
         if (curSlice->getPOC() == 0)
             lastQScaleFor[P_SLICE] = q * fabs(cfg->param.rc.ipFactor);
 
-        rce->frameSizePlanned = predictSize(&pred[sliceType], q, lastSatd);
+        rce->frameSizePlanned = predictSize(&pred[sliceType], q, (double)lastSatd);
 
         return q;
     }
@@ -573,7 +573,7 @@ double RateControl::clipQscale(double q)
 
             // Now a hard threshold to make sure the frame fits in VBV.
             // This one is mostly for I-frames.
-            double bits = predictSize(&pred[sliceType], q, lastSatd);
+            double bits = predictSize(&pred[sliceType], q, (double)lastSatd);
 
             // For small VBVs, allow the frame to use up the entire VBV.
             double maxFillFactor;
@@ -590,7 +590,7 @@ double RateControl::clipQscale(double q)
                 bits *= qf;
                 if (bits < bufferRate / minFillFactor)
                     q *= bits * minFillFactor / bufferRate;
-                bits = predictSize(&pred[sliceType], q, lastSatd);
+                bits = predictSize(&pred[sliceType], q, (double)lastSatd);
             }
 
             q = X265_MAX(q0, q);
@@ -601,9 +601,9 @@ double RateControl::clipQscale(double q)
         if (sliceType == P_SLICE)
         {
             int nb = bframes;
-            double bits = predictSize(&pred[sliceType], q, lastSatd);
+            double bits = predictSize(&pred[sliceType], q, (double)lastSatd);
             double pbbits = bits;
-            double bbits = predictSize(&predBfromP, q * cfg->param.rc.pbFactor, lastSatd);
+            double bbits = predictSize(&predBfromP, q * cfg->param.rc.pbFactor, (double)lastSatd);
             double space;
             if (bbits > bufferRate)
                 nb = 0;
@@ -678,7 +678,7 @@ void RateControl::updateVbv(int64_t bits
     int mbCount = (int)((cfg->param.sourceHeight * cfg->param.sourceWidth) / pow((int)16, 2.0));
 
     if  (rce->lastSatd >= mbCount)
-        updatePredictor(&pred[rce->sliceType], qp2qScale(rce->qpaRc), rce->lastSatd, (double)bits);
+        updatePredictor(&pred[rce->sliceType], qp2qScale(rce->qpaRc), (double)rce->lastSatd, (double)bits);
 
     if (!isVbv)
         return;
diff -r 416713ab5821 -r 7cd3a3195598 source/encoder/ratecontrol.h
--- a/source/encoder/ratecontrol.h	Thu Jan 23 18:37:10 2014 -0600
+++ b/source/encoder/ratecontrol.h	Fri Jan 24 12:59:47 2014 -0600
@@ -46,19 +46,20 @@ class TEncCfg;
 
 struct RateControlEntry
 {
+    int64_t texBits;
+    int64_t lastSatd;
+
     int sliceType;
-    int texBits;
     int mvBits;
+    int bframes;
+    int poc;
+
+    bool bLastMiniGopBFrame;
     double blurredComplexity;
     double qpaRc;
     double qRceq;
-
-    int lastSatd;
-    bool bLastMiniGopBFrame;
     double frameSizePlanned;
     double bufferRate;
-    int bframes;
-    int poc;
 };
 
 struct Predictor
@@ -97,7 +98,7 @@ struct RateControl
     int bframeBits;
     double leadingNoBSatd;
 
-    int    lastSatd;
+    int64_t lastSatd;
     int    qpConstant[3];
     double cplxrSum;          /* sum of bits*qscale/rceq */
     double wantedBitsWindow;  /* target bitrate * window */
diff -r 416713ab5821 -r 7cd3a3195598 source/encoder/reference.cpp
--- a/source/encoder/reference.cpp	Thu Jan 23 18:37:10 2014 -0600
+++ b/source/encoder/reference.cpp	Fri Jan 24 12:59:47 2014 -0600
@@ -94,7 +94,8 @@ void MotionReference::applyWeight(int ro
     int shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
     int local_shift = shift + shiftNum;
     int local_round = local_shift ? (1 << (local_shift - 1)) : 0;
-    primitives.weight_pp(src, dst, lumaStride, dstStride, width, height, weight, local_round, local_shift, offset);
+    int padwidth = (width + 15) & ~15;  // weightp assembly needs even 16 byte widths
+    primitives.weight_pp(src, dst, lumaStride, dstStride, padwidth, height, weight, local_round, local_shift, offset);
 
     // Extending Left & Right
     primitives.extendRowBorder(dst, dstStride, width, height, marginX);
diff -r 416713ab5821 -r 7cd3a3195598 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Thu Jan 23 18:37:10 2014 -0600
+++ b/source/encoder/slicetype.cpp	Fri Jan 24 12:59:47 2014 -0600
@@ -60,7 +60,6 @@ Lookahead::Lookahead(TEncCfg *_cfg, Thre
     : est(pool)
 {
     this->cfg = _cfg;
-    numDecided = 0;
     lastKeyframe = - cfg->param.keyframeMax;
     lastNonB = NULL;
     widthInCU = ((cfg->param.sourceWidth / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
@@ -110,7 +109,7 @@ void Lookahead::flush()
 // Called by RateControl to get the estimated SATD cost for a given picture.
 // It assumes dpb->prepareEncode() has already been called for the picture and
 // all the references are established
-int Lookahead::getEstimatedPictureCost(TComPic *pic)
+int64_t Lookahead::getEstimatedPictureCost(TComPic *pic)
 {
     Lowres *frames[X265_LOOKAHEAD_MAX];
 
@@ -160,7 +159,7 @@ int Lookahead::getEstimatedPictureCost(T
         break;
 
     default:
-        return -1;
+        return 0;
     }
 
     if (pic->m_lowres.costEst[b - p0][p1 - b] < 0)
@@ -229,7 +228,7 @@ void Lookahead::slicetypeDecide()
 
         if (frm.sliceType == X265_TYPE_KEYFRAME)
             frm.sliceType = cfg->param.bOpenGOP ? X265_TYPE_I : X265_TYPE_IDR;
-        if (( /* !cfg->param.intraRefresh || */ frm.frameNum == 0) && frm.frameNum - lastKeyframe >= cfg->param.keyframeMax)
+        if (/*(!cfg->param.intraRefresh || frm.frameNum == 0) && */ frm.frameNum - lastKeyframe >= cfg->param.keyframeMax)
         {
             if (frm.sliceType == X265_TYPE_AUTO || frm.sliceType == X265_TYPE_I)
                 frm.sliceType = cfg->param.bOpenGOP && lastKeyframe >= 0 ? X265_TYPE_I : X265_TYPE_IDR;
@@ -379,8 +378,8 @@ void Lookahead::slicetypeAnalyse(Lowres 
     int num_frames, origNumFrames, keyint_limit, framecnt;
     int maxSearch = X265_MIN(cfg->param.lookaheadDepth, X265_LOOKAHEAD_MAX);
     int cuCount = NUM_CUS;
-    int cost1p0, cost2p0, cost1b1, cost2p1;
     int reset_start;
+    int64_t cost1p0, cost2p0, cost1b1, cost2p1;
 
     if (!lastNonB)
         return;
@@ -478,8 +477,8 @@ void Lookahead::slicetypeAnalyse(Lowres 
                 int j;
                 for (j = i + 2; j <= X265_MIN(i + cfg->param.bframes, num_frames - 1); j++)
                 {
-                    int pthresh = X265_MAX(INTER_THRESH - P_SENS_BIAS * (j - i - 1), INTER_THRESH / 10);
-                    int pcost = est.estimateFrameCost(frames, i + 0, j + 1, j + 1, 1);
+                    int64_t pthresh = X265_MAX(INTER_THRESH - P_SENS_BIAS * (j - i - 1), INTER_THRESH / 10);
+                    int64_t pcost = est.estimateFrameCost(frames, i + 0, j + 1, j + 1, 1);
                     if (pcost > pthresh * cuCount || frames[j + 1]->intraMbs[j - i + 1] > cuCount / 3)
                         break;
                     frames[j]->sliceType = X265_TYPE_B;
@@ -547,7 +546,7 @@ void Lookahead::slicetypeAnalyse(Lowres 
 }
 
 
-int Lookahead::scenecut(Lowres **frames, int p0, int p1, bool bRealScenecut, int num_frames, int maxSearch)
+int64_t Lookahead::scenecut(Lowres **frames, int p0, int p1, bool bRealScenecut, int num_frames, int maxSearch)
 {
     /* Only do analysis during a normal scenecut check. */
     if (bRealScenecut && cfg->param.bframes)
@@ -593,21 +592,21 @@ int Lookahead::scenecut(Lowres **frames,
     return scenecutInternal(frames, p0, p1, bRealScenecut);
 }
 
-int Lookahead::scenecutInternal(Lowres **frames, int p0, int p1, bool bRealScenecut)
+int64_t Lookahead::scenecutInternal(Lowres **frames, int p0, int p1, bool bRealScenecut)
 {
     Lowres *frame = frames[p1];
 
     est.estimateFrameCost(frames, p0, p1, p1, 0);
 
-    int icost = frame->costEst[0][0];
-    int pcost = frame->costEst[p1 - p0][0];
+    int64_t icost = frame->costEst[0][0];
+    int64_t pcost = frame->costEst[p1 - p0][0];
     float bias;
     int gopSize = frame->frameNum - lastKeyframe;
     float threshMax = (float)(cfg->param.scenecutThreshold / 100.0);
 
     /* magic numbers pulled out of thin air */
     float threshMin = (float)(threshMax * 0.25);
-    int res;
+    int64_t res;
 
     if (cfg->param.keyframeMin == cfg->param.keyframeMax)
         threshMin = threshMax;
@@ -638,7 +637,7 @@ void Lookahead::slicetypePath(Lowres **f
 {
     char paths[2][X265_LOOKAHEAD_MAX + 1];
     int num_paths = X265_MIN(cfg->param.bframes + 1, length);
-    int best_cost = MotionEstimate::COST_MAX;
+    int64_t best_cost = 0;
     int idx = 0;
 
     /* Iterate over all currently possible paths */
@@ -651,8 +650,8 @@ void Lookahead::slicetypePath(Lowres **f
         strcpy(paths[idx] + len + path, "P");
 
         /* Calculate the actual cost of the current path */
-        int cost = slicetypePathCost(frames, paths[idx], best_cost);
-        if (cost < best_cost)
+        int64_t cost = slicetypePathCost(frames, paths[idx], best_cost);
+        if (path == 0 || cost < best_cost)
         {
             best_cost = cost;
             idx ^= 1;
@@ -663,10 +662,10 @@ void Lookahead::slicetypePath(Lowres **f
     memcpy(best_paths[length % (X265_BFRAME_MAX + 1)], paths[idx ^ 1], length);
 }
 
-int Lookahead::slicetypePathCost(Lowres **frames, char *path, int threshold)
+int64_t Lookahead::slicetypePathCost(Lowres **frames, char *path, int64_t threshold)
 {
+    int64_t cost = 0;
     int loc = 1;
-    int cost = 0;


More information about the x265-commits mailing list