[x265] [PATCH] Slicetype: slicetype_frame_cost() - Used fenc

gopu at multicorewareinc.com gopu at multicorewareinc.com
Thu Aug 8 08:37:24 CEST 2013


# HG changeset patch
# User ggopu
# Date 1375943833 -19800
# Node ID 4a923d960da4a0cf6b101f46a3fd6e77cb560efa
# Parent  043eee697add99e2516193cf6afae2e7935b582b
Slicetype: slicetype_frame_cost() - Used fenc

diff -r 043eee697add -r 4a923d960da4 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Thu Aug 08 11:13:05 2013 +0530
+++ b/source/encoder/slicetype.cpp	Thu Aug 08 12:07:13 2013 +0530
@@ -34,43 +34,48 @@
 
 #include "x265.h"
 #include "lookahead.h"
+#include "primitives.h"
 
 #define NUM_MBS \
-    (frames[b]->cuWidth > 2 && frames[b]->cuHeight > 2 ? \
-     (frames[b]->cuWidth - 2) * (frames[b]->cuHeight - 2) : \
-     frames[b]->cuWidth * frames[b]->cuHeight)
+    (fenc->cuWidth > 2 && fenc->cuHeight > 2 ? \
+     (fenc->cuWidth - 2) * (fenc->cuHeight - 2) : \
+     fenc->cuWidth * fenc->cuHeight)
 
 int slicetype_frame_cost(x265::LookaheadFrame **frames, int p0, int p1, int b, int bIntraPenalty);
+int slicetype_cu_cost(x265::LookaheadFrame **frames, int p0, int p1, int b, int dist_scale_factor, int do_search[2]);
 
 int slicetype_frame_cost(x265::LookaheadFrame **frames, int p0, int p1, int b, int bIntraPenalty)
 {
     int score = 0;
     int do_search[2];
 
-    if (frames[b]->costEst[b - p0][p1 - b] >= 0 && frames[0]->rowSatds[b - p0][p1 - b][0] != -1)
-        score = frames[b]->costEst[b - p0][p1 - b];
+	x265::LookaheadFrame *fenc;
+	fenc = frames[b];
+	
+    if (fenc->costEst[b - p0][p1 - b] >= 0 && fenc->rowSatds[b - p0][p1 - b][0] != -1)
+        score = fenc->costEst[b - p0][p1 - b];
     else
     {
         int dist_scale_factor = 128;
-        x265::MV *we = frames[b]->lowresMvs[0][b - p0 - 1];
-        int *row_satd = frames[b]->rowSatds[b - p0][p1 - b];
+        x265::MV *we = fenc->lowresMvs[0][b - p0 - 1];
+        int *row_satd = fenc->rowSatds[b - p0][p1 - b];
 
         /* For each list, check to see whether we have lowres motion-searched this reference frame before. */
-        do_search[0] = b != p0 && frames[b]->lowresMvs[0][b - p0 - 1][0].x == 0x7FFF;
-        do_search[1] = b != p1 && frames[b]->lowresMvs[1][p1 - b - 1][0].x == 0x7FFF;
+        do_search[0] = b != p0 && fenc->lowresMvs[0][b - p0 - 1][0].x == 0x7FFF;
+        do_search[1] = b != p1 && fenc->lowresMvs[1][p1 - b - 1][0].x == 0x7FFF;
 
         if (do_search[0])
         {
-            frames[b]->lowresMvs[0][b - p0 - 1][0] = 0;
+            fenc->lowresMvs[0][b - p0 - 1][0] = 0;
         }
 
-        if (do_search[1]) frames[b]->lowresMvs[1][p1 - b - 1][0] = 0;
+        if (do_search[1]) fenc->lowresMvs[1][p1 - b - 1][0] = 0;
 
         if (p1 != p0)
             dist_scale_factor = (((b - p0) << 8) + ((p1 - p0) >> 1)) / (p1 - p0);
 
-        frames[b]->costEst[b - p0][p1 - b] = 0;
-        frames[b]->costEst[b - p0][p1 - b] = 0;
+        fenc->costEst[b - p0][p1 - b] = 0;
+        fenc->costEst[b - p0][p1 - b] = 0;
 
         /* Lowres lookahead goes backwards because the MVs are used as predictors in the main encode.
         * This considerably improves MV prediction overall. */
@@ -78,35 +83,35 @@
         /* The edge mbs seem to reduce the predictive quality of the
         * whole frame's score, but are needed for a spatial distribution. */
 
-        if (frames[b]->cuWidth <= 2 || frames[b]->cuHeight <= 2)
+        if (fenc->cuWidth <= 2 || fenc->cuHeight <= 2)
         {
-            for (int i = frames[b]->cuWidth - 1; i >= 0; i--)
+            for (int i = fenc->cuWidth - 1; i >= 0; i--)
             {
                 row_satd[i] = 0;
             }
 
-            for (int j = frames[b]->cuHeight - 1; j >= 0; j--)
+            for (int j = fenc->cuHeight - 1; j >= 0; j--)
             {
-                //call slicetype_mb_cost()
+                slicetype_cu_cost(frames, p0, p1, b, dist_scale_factor, do_search);
             }
         }
         else
         {
-            for (int i = frames[b]->cuWidth - 1; i >= 0; i--)
+            for (int i = fenc->cuWidth - 1; i >= 0; i--)
             {
-                for (int j = frames[b]->cuHeight - 1; j >= 0; j--)
+                for (int j = fenc->cuHeight - 1; j >= 0; j--)
                 {
-                    //call slicetype_mb_cost()
+                    slicetype_cu_cost(frames, p0, p1, b, dist_scale_factor, do_search);
                 }
             }
         }
 
-        score = frames[b]->costEst[b - p0][p1 - b];
+        score = fenc->costEst[b - p0][p1 - b];
 
         if (b != p1)
             score = (uint64_t)score * 100 / (120) + 0;
 
-        frames[b]->costEst[b - p0][p1 - b] = score;
+        fenc->costEst[b - p0][p1 - b] = score;
         x265_emms();
     }
 
@@ -114,11 +119,20 @@
     {
         // arbitrary penalty for I-blocks after B-frames
         int nmb = NUM_MBS;
-        score += (uint64_t)score * frames[b]->intraMbs[b - p0] / (nmb * 8);
+        score += (uint64_t)score * fenc->intraMbs[b - p0] / (nmb * 8);
     }
     return score;
 }
 
+int slicetype_cu_cost(x265::LookaheadFrame **frames, int p0, int p1, int b, int dist_scale_factor, int do_search[2])
+{
+	x265::LookaheadFrame *fref0 = frames[p0];
+    x265::LookaheadFrame *fref1 = frames[p1];
+    x265::LookaheadFrame *fenc  = frames[b];
+
+
+	return 0;
+}
 
 
 #if 0


More information about the x265-devel mailing list