# HG changeset patch # User Aarthi Thirumalai # Date 1379356988 -19800 # Tue Sep 17 00:13:08 2013 +0530 # Node ID baeddbdc9ec349002f574bfc1763927f487cc88d # Parent 9a727efab9fa4048eed7330abe28cf7e088590fb ABR - Removed unused states, cleaned up the comments.
Removed states that are not used in ABR or CQP rate contnrol modes. diff -r 9a727efab9fa -r baeddbdc9ec3 source/encoder/ratecontrol.cpp --- a/source/encoder/ratecontrol.cpp Mon Sep 16 22:57:07 2013 +0530 +++ b/source/encoder/ratecontrol.cpp Tue Sep 17 00:13:08 2013 +0530 @@ -61,7 +61,7 @@ ncu = (int)((param->sourceHeight * param->sourceWidth) / pow((int)param->maxCUSize, 2.0)); lastNonBPictType = -1; baseQp = param->rc.qp; - qpm = qp = baseQp; + qp = baseQp; // heuristics- encoder specific qCompress = param->rc.qCompress; // tweak and test for x265. @@ -101,7 +101,7 @@ //qstep - value set as encoder specific. lstep = pow(2, param->rc.qpStep / 6.0); - cbrDecay = 1.0; + } void RateControl::rateControlStart(TComPic* pic, Lookahead *l, RateControlEntry* rce) @@ -116,8 +116,7 @@ lastSatd = l->getEstimatedPictureCost(pic); double q = qScale2qp(rateEstimateQscale(rce)); qp = Clip3(MIN_QP, MAX_QP, (int)(q + 0.5)); - rce->qpaRc = qpm = q; - rce->newQp = qp; + rce->qpaRc = q; accumPQpUpdate(); break; } @@ -146,15 +145,14 @@ accumPNorm *= .95; accumPNorm += 1; if (frameType == I_SLICE) - accumPQp += qpm + ipOffset; + accumPQp += qp + ipOffset; else - accumPQp += qpm; + accumPQp += qp; } double RateControl::rateEstimateQscale(RateControlEntry *rce) { double q; - // ratecontrol_entry_t rce = UNINIT(rce); int pictType = frameType; if (pictType == B_SLICE) @@ -207,8 +205,6 @@ * tolerances, the bit distribution approaches that of 2pass. */ double wantedBits, overflow = 1; - rce->pCount = ncu; - shortTermCplxSum *= 0.5; shortTermCplxCount *= 0.5; shortTermCplxSum += lastSatd / (CLIP_DURATION(frameDuration) / BASE_FRAME_DURATION); @@ -217,7 +213,6 @@ rce->blurredComplexity = shortTermCplxSum / shortTermCplxCount; rce->mvBits = 0; rce->pictType = pictType; - //need to checked where it is initialized q = getQScale(rce, wantedBitsWindow / cplxrSum); /* ABR code can potentially be counterproductive in CBR, so just don't bother. @@ -236,7 +231,6 @@ } if (pictType == I_SLICE && keyFrameInterval > 1 - /* should test _next_ pict type, but that isn't decided yet */ && lastNonBPictType != I_SLICE) { q = qp2qScale(accumPQp / accumPNorm); @@ -270,12 +264,10 @@ q = Clip3(lqmin, lqmax, q); } - //FIXME use get_diff_limited_q() ? double lmin1 = lmin[pictType]; double lmax1 = lmax[pictType]; q = Clip3(lmin1, lmax1, q); - lastQScaleFor[pictType] = - lastQScale = q; + lastQScaleFor[pictType] = q; if (curFrame->getPOC() == 0) lastQScaleFor[P_SLICE] = q * fabs(ipFactor); @@ -300,12 +292,11 @@ { rce->lastRceq = q; q /= rateFactor; - lastQScale = q; } return q; } -/* After encoding one frame, save stats and update ratecontrol state */ +/* After encoding one frame, update ratecontrol state */ int RateControl::rateControlEnd(int64_t bits, RateControlEntry* rce) { if (rateControlMode == X265_RC_ABR) @@ -320,9 +311,7 @@ * Not perfectly accurate with B-refs, but good enough. */ cplxrSum += bits * qp2qScale(rce->qpaRc) / (rce->lastRceq * fabs(pbFactor)); } - cplxrSum *= cbrDecay; wantedBitsWindow += frameDuration * bitrate; - wantedBitsWindow *= cbrDecay; rce = NULL; } totalBits += bits; diff -r 9a727efab9fa -r baeddbdc9ec3 source/encoder/ratecontrol.h --- a/source/encoder/ratecontrol.h Mon Sep 16 22:57:07 2013 +0530 +++ b/source/encoder/ratecontrol.h Tue Sep 17 00:13:08 2013 +0530 @@ -35,12 +35,10 @@ struct RateControlEntry { int pictType; - int pCount; - int newQp; int texBits; int mvBits; double blurredComplexity; - double qpaRc; /* average of macroblocks' qp before aq */ + double qpaRc; double lastRceq; }; @@ -54,9 +52,7 @@ int keyFrameInterval; /* TODO: need to initialize in init */ int qp; /* updated qp for current frame */ int baseQp; /* CQP base QP */ - double frameDuration; /* current frame duration in seconds */ - double qpm; /* qp for current macroblock: precise double for AQ */ - + double frameDuration; /* current frame duration in seconds */ double bitrate; double rateTolerance; double qCompress; @@ -71,11 +67,8 @@ int lastNonBPictType; double accumPQp; /* for determining I-frame quant */ double accumPNorm; - double lastQScale; double lastQScaleFor[3]; /* last qscale for a specific pict type, used for max_diff & ipb factor stuff */ double lstep; - double qpNoVbv; /* QP for the current frame if 1-pass VBV was disabled. */ - double cbrDecay; double lmin[3]; /* min qscale by frame type */ double lmax[3]; double shortTermCplxSum; _______________________________________________ x265-devel mailing list x265-devel@videolan.org https://mailman.videolan.org/listinfo/x265-devel