[x264-devel] commit: Simplify some code in b-adapt 2's trellis (Henrik Gramner )

git version control git at videolan.org
Tue Oct 13 03:49:22 CEST 2009


x264 | branch: master | Henrik Gramner <hengar-6 at student.ltu.se> | Mon Oct 12 15:44:13 2009 -0700| [9045fbed2d696e04d402fc8b545d761ec6c41d34] | committer: Jason Garrett-Glaser 

Simplify some code in b-adapt 2's trellis

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=9045fbed2d696e04d402fc8b545d761ec6c41d34
---

 encoder/slicetype.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/encoder/slicetype.c b/encoder/slicetype.c
index 8183ae4..bea12f1 100644
--- a/encoder/slicetype.c
+++ b/encoder/slicetype.c
@@ -621,23 +621,21 @@ static void x264_slicetype_path( x264_t *h, x264_mb_analysis_t *a, x264_frame_t
 {
     char paths[X264_BFRAME_MAX+2][X264_LOOKAHEAD_MAX] = {{0}};
     int num_paths = X264_MIN(max_bframes+1, length);
-    int suffix_size, loc, path;
+    int path;
     int best_cost = COST_MAX;
     int best_path_index = 0;
-    length = X264_MIN(length,X264_LOOKAHEAD_MAX);
+    length = X264_MIN( length, X264_LOOKAHEAD_MAX );
 
-    /* Iterate over all currently possible paths and add suffixes to each one */
-    for( suffix_size = 0; suffix_size < num_paths; suffix_size++ )
-    {
-        memcpy( paths[suffix_size], best_paths[length - (suffix_size + 1)], length - (suffix_size + 1) );
-        for( loc = 0; loc < suffix_size; loc++ )
-            strcat( paths[suffix_size], "B" );
-        strcat( paths[suffix_size], "P" );
-    }
-
-    /* Calculate the actual cost of each of the current paths */
+    /* Iterate over all currently possible paths */
     for( path = 0; path < num_paths; path++ )
     {
+        /* Add suffixes to the current path */
+        int len = length - (path + 1);
+        memcpy( paths[path], best_paths[len], len );
+        memset( paths[path]+len, 'B', path );
+        strcat( paths[path], "P" );
+
+        /* Calculate the actual cost of the current path */
         int cost = x264_slicetype_path_cost( h, a, frames, paths[path], best_cost );
         if( cost < best_cost )
         {



More information about the x264-devel mailing list