[x265] [PATCH] pixel: Added C Primitives for estimateCUPropagateCost and removed from lookahead

gopu at multicorewareinc.com gopu at multicorewareinc.com
Tue Apr 22 08:31:59 CEST 2014


# HG changeset patch
# User Gopu Govindaswamy
# Date 1398148277 -19800
#      Tue Apr 22 12:01:17 2014 +0530
# Node ID 9f50bf435dfe9d1de9f9a48e0793db45ad47caa9
# Parent  84315557c97ff2b10cf01910d6b131e28fce1781
pixel: Added C Primitives for estimateCUPropagateCost and removed from lookahead

diff -r 84315557c97f -r 9f50bf435dfe source/common/pixel.cpp
--- a/source/common/pixel.cpp	Mon Apr 21 22:23:48 2014 -0500
+++ b/source/common/pixel.cpp	Tue Apr 22 12:01:17 2014 +0530
@@ -865,6 +865,22 @@
         src += srcStride;
     }
 }
+
+/* Estimate the total amount of influence on future quality that could be had if we
+ * were to improve the reference samples used to inter predict any given CU. */
+void estimateCUPropagateCost(int *dst, uint16_t *propagateIn, int32_t *intraCosts, uint16_t *interCosts,
+                                        int32_t *invQscales, double *fpsFactor, int len)
+{
+    double fps = *fpsFactor / 256;
+    for (int i = 0; i < len; i++)
+    {
+        double intraCost       = intraCosts[i] * invQscales[i];
+        double propagateAmount = (double)propagateIn[i] + intraCost * fps;
+        double propagateNum    = (double)intraCosts[i] - (interCosts[i] & ((1 << 14) - 1));
+        double propagateDenom  = (double)intraCosts[i];
+        dst[i] = (int)(propagateAmount * propagateNum / propagateDenom + 0.5);
+    }
+}
 }  // end anonymous namespace
 
 namespace x265 {
@@ -1158,5 +1174,6 @@
     p.plane_copy_deinterleave_c = plane_copy_deinterleave_chroma;
     p.planecopy_cp = planecopy_cp_c;
     p.planecopy_sp = planecopy_sp_c;
+    p.propagateCost = estimateCUPropagateCost;
 }
 }
diff -r 84315557c97f -r 9f50bf435dfe source/common/primitives.h
--- a/source/common/primitives.h	Mon Apr 21 22:23:48 2014 -0500
+++ b/source/common/primitives.h	Tue Apr 22 12:01:17 2014 +0530
@@ -175,6 +175,8 @@
 typedef void (*planecopy_cp_t) (uint8_t *src, intptr_t srcStride, pixel *dst, intptr_t dstStride, int width, int height, int shift);
 typedef void (*planecopy_sp_t) (uint16_t *src, intptr_t srcStride, pixel *dst, intptr_t dstStride, int width, int height, int shift, uint16_t mask);
 
+typedef void (*cutree_propagate_cost) (int *dst, uint16_t *propagateIn, int32_t *intraCosts, uint16_t *interCosts, int32_t *invQscales, double *fpsFactor, int len);
+
 /* Define a structure containing function pointers to optimized encoder
  * primitives.  Each pointer can reference either an assembly routine,
  * a vectorized primitive, or a C function. */
@@ -247,6 +249,8 @@
     planecopy_cp_t    planecopy_cp;
     planecopy_sp_t    planecopy_sp;
 
+    cutree_propagate_cost    propagateCost;
+
     struct
     {
         filter_pp_t     filter_vpp[NUM_LUMA_PARTITIONS];
diff -r 84315557c97f -r 9f50bf435dfe source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Mon Apr 21 22:23:48 2014 -0500
+++ b/source/encoder/slicetype.cpp	Tue Apr 22 12:01:17 2014 +0530
@@ -1066,8 +1066,7 @@
     for (uint16_t blocky = 0; blocky < heightInCU; blocky++)
     {
         int cuIndex = blocky * StrideInCU;
-        /* TODO This function go into ASM */
-        estimateCUPropagateCost(scratch, propagateCost,
+        primitives.propagateCost(scratch, propagateCost,
                                 frames[b]->intraCost + cuIndex, frames[b]->lowresCosts[b - p0][p1 - b] + cuIndex,
                                 frames[b]->invQscaleFactor + cuIndex, &fpsFactor, widthInCU);
 
@@ -1170,23 +1169,6 @@
     }
 }
 
-/* Estimate the total amount of influence on future quality that could be had if we
- * were to improve the reference samples used to inter predict any given macroblock. */
-void Lookahead::estimateCUPropagateCost(int *dst, uint16_t *propagateIn, int32_t *intraCosts, uint16_t *interCosts,
-                                        int32_t *invQscales, double *fpsFactor, int len)
-{
-    double fps = *fpsFactor / 256;
-
-    for (int i = 0; i < len; i++)
-    {
-        double intraCost       = intraCosts[i] * invQscales[i];
-        double propagateAmount = (double)propagateIn[i] + intraCost * fps;
-        double propagateNum    = (double)intraCosts[i] - (interCosts[i] & LOWRES_COST_MASK);
-        double propagateDenom  = (double)intraCosts[i];
-        dst[i] = (int)(propagateAmount * propagateNum / propagateDenom + 0.5);
-    }
-}
-
 /* If MB-tree changes the quantizers, we need to recalculate the frame cost without
  * re-running lookahead. */
 int64_t Lookahead::frameCostRecalculate(Lowres** frames, int p0, int p1, int b)
diff -r 84315557c97f -r 9f50bf435dfe source/encoder/slicetype.h
--- a/source/encoder/slicetype.h	Mon Apr 21 22:23:48 2014 -0500
+++ b/source/encoder/slicetype.h	Tue Apr 22 12:01:17 2014 +0530
@@ -170,8 +170,6 @@
      * quant offsets */
     void cuTree(Lowres **frames, int numframes, bool bintra);
     void estimateCUPropagate(Lowres **frames, double average_duration, int p0, int p1, int b, int referenced);
-    void estimateCUPropagateCost(int *dst, uint16_t *propagateIn, int32_t *intraCosts, uint16_t *interCosts,
-                                 int32_t *invQscales, double *fpsFactor, int len);
     void cuTreeFinish(Lowres *frame, double averageDuration, int ref0Distance);
 
     /* called by getEstimatedPictureCost() to finalize cuTree costs */


More information about the x265-devel mailing list