[x265-commits] [x265] rc : bug fix for quality drop with larger number of frame...

Aarthi at videolan.org Aarthi at videolan.org
Fri Oct 4 22:02:59 CEST 2013


details:   http://hg.videolan.org/x265/rev/b960d808d0be
branches:  
changeset: 4208:b960d808d0be
user:      Aarthi Thirumalai
date:      Fri Oct 04 17:00:21 2013 +0530
description:
rc : bug fix for quality drop with larger number of frame threads.
Subject: [x265] Using int16_t rather than uint16_t in weightpUni primitive; inputs can be signed

details:   http://hg.videolan.org/x265/rev/491996e415b0
branches:  
changeset: 4209:491996e415b0
user:      Shazeb Nawaz Khan <shazeb at multicorewareinc.com>
date:      Fri Oct 04 16:40:04 2013 +0530
description:
Using int16_t rather than uint16_t in weightpUni primitive; inputs can be signed
Subject: [x265] Fix for Testbench fail in weightpUni for Pixel input

details:   http://hg.videolan.org/x265/rev/e1404a7a05b0
branches:  
changeset: 4210:e1404a7a05b0
user:      Shazeb Nawaz Khan <shazeb at multicorewareinc.com>
date:      Fri Oct 04 17:07:48 2013 +0530
description:
Fix for Testbench fail in weightpUni for Pixel input

diffstat:

 source/Lib/TLibCommon/TComWeightPrediction.cpp |   8 +++---
 source/common/pixel.cpp                        |   2 +-
 source/common/primitives.h                     |   2 +-
 source/common/vec/pixel.inc                    |   4 +-
 source/common/vec/pixel8.inc                   |  32 ++++++++++++++++++++++++-
 source/encoder/ratecontrol.cpp                 |   3 +-
 source/test/pixelharness.cpp                   |  23 +++++-------------
 7 files changed, 47 insertions(+), 27 deletions(-)

diffs (202 lines):

diff -r cfc69c57d335 -r e1404a7a05b0 source/Lib/TLibCommon/TComWeightPrediction.cpp
--- a/source/Lib/TLibCommon/TComWeightPrediction.cpp	Fri Oct 04 18:42:00 2013 +0530
+++ b/source/Lib/TLibCommon/TComWeightPrediction.cpp	Fri Oct 04 17:07:48 2013 +0530
@@ -431,7 +431,7 @@ void TComWeightPrediction::addWeightUni(
         srcStride = srcYuv0->m_width;
         dstStride  = outDstYuv->getStride();
 
-        primitives.weightpUni((uint16_t *)srcY0, dstY, srcStride, dstStride, width, height, w0, round, shift, offset);
+        primitives.weightpUni((int16_t *)srcY0, dstY, srcStride, dstStride, width, height, w0, round, shift, offset);
     }
 
     // Chroma U : --------------------------------------------
@@ -447,7 +447,7 @@ void TComWeightPrediction::addWeightUni(
     width  >>= 1;
     height >>= 1;
 
-    primitives.weightpUni((uint16_t *)srcU0, dstU, srcStride, dstStride, width, height, w0, round, shift, offset);
+    primitives.weightpUni((int16_t *)srcU0, dstU, srcStride, dstStride, width, height, w0, round, shift, offset);
 
     // Chroma V : --------------------------------------------
     w0      = wp0[2].w;
@@ -455,7 +455,7 @@ void TComWeightPrediction::addWeightUni(
     shift   = wp0[2].shift + shiftNum;
     round   = shift ? (1 << (shift - 1)) : 0;
 
-    primitives.weightpUni((uint16_t *)srcV0, dstV, srcStride, dstStride, width, height, w0, round, shift, offset);
+    primitives.weightpUni((int16_t *)srcV0, dstV, srcStride, dstStride, width, height, w0, round, shift, offset);
 }
 
 //=======================================================
@@ -669,5 +669,5 @@ void TComWeightPrediction::xWeightedPred
     {
         getWpScaling(cu, -1, refIdx, pwpTmp, pwp);
     }
-    addWeightUni(srcYuv, partAddr, width, height, pwp, outPredYuv, true);
+    addWeightUni(srcYuv, partAddr, width, height, pwp, outPredYuv);
 }
diff -r cfc69c57d335 -r e1404a7a05b0 source/common/pixel.cpp
--- a/source/common/pixel.cpp	Fri Oct 04 18:42:00 2013 +0530
+++ b/source/common/pixel.cpp	Fri Oct 04 17:07:48 2013 +0530
@@ -861,7 +861,7 @@ void Setup_C_PixelPrimitives(EncoderPrim
     p.transpose[4] = transpose<64>;
 
     p.weightpUniPixel = weightUnidir<pixel>;
-    p.weightpUni = weightUnidir<uint16_t>;
+    p.weightpUni = weightUnidir<int16_t>;
 
     p.pixelsub_sp = pixelsub_sp_c;
     p.pixeladd_pp = pixeladd_pp_c;
diff -r cfc69c57d335 -r e1404a7a05b0 source/common/primitives.h
--- a/source/common/primitives.h	Fri Oct 04 18:42:00 2013 +0530
+++ b/source/common/primitives.h	Fri Oct 04 17:07:48 2013 +0530
@@ -231,7 +231,7 @@ typedef void (*extendCURowBorder_t)(pixe
 
 
 typedef void (*weightpUniPixel_t)(pixel *src, pixel *dst, intptr_t srcStride, intptr_t dstStride, int width, int height, int w0, int round, int shift, int offset);
-typedef void (*weightpUni_t)(uint16_t *src, pixel *dst, intptr_t srcStride, intptr_t dstStride, int width, int height, int w0, int round, int shift, int offset);
+typedef void (*weightpUni_t)(int16_t *src, pixel *dst, intptr_t srcStride, intptr_t dstStride, int width, int height, int w0, int round, int shift, int offset);
 typedef void (*scale_t)(pixel *dst, pixel *src, intptr_t stride);
 typedef void (*downscale_t)(pixel *src0, pixel *dstf, pixel *dsth, pixel *dstv, pixel *dstc,
                             intptr_t src_stride, intptr_t dst_stride, int width, int height);
diff -r cfc69c57d335 -r e1404a7a05b0 source/common/vec/pixel.inc
--- a/source/common/vec/pixel.inc	Fri Oct 04 18:42:00 2013 +0530
+++ b/source/common/vec/pixel.inc	Fri Oct 04 17:07:48 2013 +0530
@@ -168,8 +168,8 @@ void NAME(Setup_Vec_PixelPrimitives)(Enc
     p.blockfil_s[BLOCK_32x32] = blockfil_s_32;
 #endif
 
-    p.weightpUniPixel = weightUnidir<pixel>;
-    p.weightpUni = weightUnidir<uint16_t>;
+    p.weightpUniPixel = weightUnidirPixel;
+    p.weightpUni = weightUnidir;
 
     p.calcresidual[BLOCK_4x4] = getResidual4;
     p.calcresidual[BLOCK_8x8] = getResidual8;
diff -r cfc69c57d335 -r e1404a7a05b0 source/common/vec/pixel8.inc
--- a/source/common/vec/pixel8.inc	Fri Oct 04 18:42:00 2013 +0530
+++ b/source/common/vec/pixel8.inc	Fri Oct 04 17:07:48 2013 +0530
@@ -246,8 +246,7 @@ void calcRecons(pixel* pPred, short* pRe
     }
 }
 
-template <typename T>
-void weightUnidir(T *src, pixel *dst, intptr_t srcStride, intptr_t dstStride, int width, int height, int w0, int round, int shift, int offset)
+void weightUnidir(int16_t *src, pixel *dst, intptr_t srcStride, intptr_t dstStride, int width, int height, int w0, int round, int shift, int offset)
 {
     int x, y;
     Vec8s tmp;
@@ -274,3 +273,32 @@ void weightUnidir(T *src, pixel *dst, in
         dst += dstStride;
     }
 }
+
+void weightUnidirPixel(pixel *src, pixel *dst, intptr_t srcStride, intptr_t dstStride, int width, int height, int w0, int round, int shift, int offset)
+{
+    int x, y;
+    Vec16uc tmp;
+
+    Vec4i vw0(w0), vsrc, iofs(IF_INTERNAL_OFFS), ofs(offset), vround(round), vdst;
+    for (y = height - 1; y >= 0; y--)
+    {
+        for (x = 0; x <= width - 4; x += 4)
+        {
+            tmp = load_partial(const_int(4), src + x);
+            // The intermediate results would outgrow 16 bits because internal offset is too high
+            vsrc = extend_low(extend_low(tmp));
+            vdst = ((vw0 * (vsrc + iofs) + vround) >> shift) + ofs;
+            store_partial(const_int(4), dst + x, compress_unsafe(compress_saturated(vdst, vdst), 0));
+        }
+
+        if (width > x)
+        {
+            tmp  = load_partial(const_int(4), src + x);
+            vsrc = extend_low(extend_low(tmp));
+            vdst = ((vw0 * (vsrc + iofs) + vround) >> shift) + ofs;
+            compress_unsafe(compress_saturated(vdst, vdst), 0).store_partial(2, dst + x);
+        }
+        src += srcStride;
+        dst += dstStride;
+    }
+}
diff -r cfc69c57d335 -r e1404a7a05b0 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Fri Oct 04 18:42:00 2013 +0530
+++ b/source/encoder/ratecontrol.cpp	Fri Oct 04 17:07:48 2013 +0530
@@ -191,7 +191,7 @@ double RateControl::rateEstimateQscale(R
     }
     else
     {
-        double abrBuffer = 0.9 * rateTolerance * bitrate;
+        double abrBuffer = 1.5 * rateTolerance * bitrate ;
 
         /* 1pass ABR */
 
@@ -264,6 +264,7 @@ double RateControl::rateEstimateQscale(R
                 if (overflow > 1.5)
                     rfAdapt = 2;
                 lqmax *= pow(lstep, rfAdapt);
+                lqmin /= pow(lstep, rfAdapt / frameThreads);
             }
             else if (overflow < 0.9)
             {
diff -r cfc69c57d335 -r e1404a7a05b0 source/test/pixelharness.cpp
--- a/source/test/pixelharness.cpp	Fri Oct 04 18:42:00 2013 +0530
+++ b/source/test/pixelharness.cpp	Fri Oct 04 17:07:48 2013 +0530
@@ -343,8 +343,8 @@ bool PixelHarness::check_weightpUni(weig
     int offset = (rand() % 256) - 128;
     for (int i = 0; i < ITERS; i++)
     {
-        opt((uint16_t*)sbuf1 + j, opt_dest, 64, 64, width, height, w0, round, shift, offset);
-        ref((uint16_t*)sbuf1 + j, ref_dest, 64, 64, width, height, w0, round, shift, offset);
+        opt((int16_t*)sbuf1 + j, opt_dest, 64, 64, width, height, w0, round, shift, offset);
+        ref((int16_t*)sbuf1 + j, ref_dest, 64, 64, width, height, w0, round, shift, offset);
 
         if (memcmp(ref_dest, opt_dest, 64 * 64 * sizeof(pixel)))
             return false;
@@ -371,8 +371,8 @@ bool PixelHarness::check_weightpUni(weig
     int offset = (rand() % 256) - 128;
     for (int i = 0; i < ITERS; i++)
     {
-        opt((pixel *)sbuf1 + j, opt_dest, 64, 64, width, height, w0, round, shift, offset);
-        ref((pixel *)sbuf1 + j, ref_dest, 64, 64, width, height, w0, round, shift, offset);
+        opt(pbuf1 + j, opt_dest, 64, 64, width, height, w0, round, shift, offset);
+        ref(pbuf1 + j, ref_dest, 64, 64, width, height, w0, round, shift, offset);
 
         if (memcmp(ref_dest, opt_dest, 64 * 64 * sizeof(pixel)))
             return false;
@@ -636,16 +636,7 @@ bool PixelHarness::testCorrectness(const
     {
         if (!check_weightpUni(ref.weightpUniPixel, opt.weightpUniPixel))
         {
-            printf("Weighted Prediction for Unidir failed!\n");
-            return false;
-        }
-    }
-
-    if (opt.weightpUniPixel)
-    {
-        if (!check_weightpUni(ref.weightpUniPixel, opt.weightpUniPixel))
-        {
-            printf("Weighted Prediction for Unidir failed!\n");
+            printf("Weighted Prediction for Unidir (Pixel) failed!\n");
             return false;
         }
     }
@@ -654,7 +645,7 @@ bool PixelHarness::testCorrectness(const
     {
         if (!check_weightpUni(ref.weightpUni, opt.weightpUni))
         {
-            printf("Weighted Prediction for Unidir failed!\n");
+            printf("Weighted Prediction for Unidir (int16_t) failed!\n");
             return false;
         }
     }
@@ -806,7 +797,7 @@ void PixelHarness::measureSpeed(const En
     if (opt.weightpUni)
     {
         printf("WeightpUni");
-        REPORT_SPEEDUP(opt.weightpUni, ref.weightpUni, (uint16_t*)sbuf1, pbuf1, 64, 64, 32, 32, 128, 1 << 9, 10, 100);
+        REPORT_SPEEDUP(opt.weightpUni, ref.weightpUni, (int16_t*)sbuf1, pbuf1, 64, 64, 32, 32, 128, 1 << 9, 10, 100);
     }
 
     if (opt.pixelsub_sp)


More information about the x265-commits mailing list