[x264-devel] commit: Faster CAVLC mb header writing for B macroblocks ( Jason Garrett-Glaser )

git version control git at videolan.org
Sun Sep 6 19:37:00 CEST 2009


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Sat Sep  5 18:55:46 2009 -0700| [83a033e15d14fcf954c4cdfa3c7c6cd64808c1f9] | committer: Jason Garrett-Glaser 

Faster CAVLC mb header writing for B macroblocks

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

 encoder/cavlc.c |   70 ++++++++++++++++++++++--------------------------------
 1 files changed, 29 insertions(+), 41 deletions(-)

diff --git a/encoder/cavlc.c b/encoder/cavlc.c
index eb64530..06faa75 100644
--- a/encoder/cavlc.c
+++ b/encoder/cavlc.c
@@ -454,51 +454,39 @@ void x264_macroblock_write_cavlc( x264_t *h, bs_t *s )
     {
         /* All B mode */
         /* Motion Vector */
-        int i_list;
         const uint8_t (*b_list)[2] = x264_mb_type_list_table[i_mb_type];
+        const int i_ref0_max = h->mb.pic.i_fref[0] - 1;
+        const int i_ref1_max = h->mb.pic.i_fref[1] - 1;
 
         bs_write_ue( s, mb_type_b_to_golomb[ h->mb.i_partition - D_16x8 ][ i_mb_type - B_L0_L0 ] );
-
-        for( i_list = 0; i_list < 2; i_list++ )
-        {
-            const int i_ref_max = (i_list == 0 ? h->mb.pic.i_fref[0] : h->mb.pic.i_fref[1]) - 1;
-
-            if( i_ref_max )
-                switch( h->mb.i_partition )
-                {
-                    case D_16x16:
-                        if( b_list[i_list][0] ) bs_write_te( s, i_ref_max, h->mb.cache.ref[i_list][x264_scan8[0]] );
-                        break;
-                    case D_16x8:
-                        if( b_list[i_list][0] ) bs_write_te( s, i_ref_max, h->mb.cache.ref[i_list][x264_scan8[0]] );
-                        if( b_list[i_list][1] ) bs_write_te( s, i_ref_max, h->mb.cache.ref[i_list][x264_scan8[8]] );
-                        break;
-                    case D_8x16:
-                        if( b_list[i_list][0] ) bs_write_te( s, i_ref_max, h->mb.cache.ref[i_list][x264_scan8[0]] );
-                        if( b_list[i_list][1] ) bs_write_te( s, i_ref_max, h->mb.cache.ref[i_list][x264_scan8[4]] );
-                        break;
-                }
-        }
-        for( i_list = 0; i_list < 2; i_list++ )
+        switch( h->mb.i_partition )
         {
-            switch( h->mb.i_partition )
-            {
-                case D_16x16:
-                    if( b_list[i_list][0] )
-                        cavlc_mb_mvd( h, s, i_list, 0, 4 );
-                    break;
-                case D_16x8:
-                    if( b_list[i_list][0] )
-                        cavlc_mb_mvd( h, s, i_list, 0, 4 );
-                    if( b_list[i_list][1] )
-                        cavlc_mb_mvd( h, s, i_list, 8, 4 );
-                    break;
-                case D_8x16:
-                    if( b_list[i_list][0] )
-                        cavlc_mb_mvd( h, s, i_list, 0, 2 );
-                    if( b_list[i_list][1] )
-                        cavlc_mb_mvd( h, s, i_list, 4, 2 );
-            }
+            case D_16x16:
+                if( i_ref0_max && b_list[0][0] ) bs_write_te( s, i_ref0_max, h->mb.cache.ref[0][x264_scan8[0]] );
+                if( i_ref1_max && b_list[1][0] ) bs_write_te( s, i_ref1_max, h->mb.cache.ref[1][x264_scan8[0]] );
+                if( b_list[0][0] ) cavlc_mb_mvd( h, s, 0, 0, 4 );
+                if( b_list[1][0] ) cavlc_mb_mvd( h, s, 1, 0, 4 );
+                break;
+            case D_16x8:
+                if( i_ref0_max && b_list[0][0] ) bs_write_te( s, i_ref0_max, h->mb.cache.ref[0][x264_scan8[0]] );
+                if( i_ref0_max && b_list[0][1] ) bs_write_te( s, i_ref0_max, h->mb.cache.ref[0][x264_scan8[8]] );
+                if( i_ref1_max && b_list[1][0] ) bs_write_te( s, i_ref1_max, h->mb.cache.ref[1][x264_scan8[0]] );
+                if( i_ref1_max && b_list[1][1] ) bs_write_te( s, i_ref1_max, h->mb.cache.ref[1][x264_scan8[8]] );
+                if( b_list[0][0] ) cavlc_mb_mvd( h, s, 0, 0, 4 );
+                if( b_list[0][1] ) cavlc_mb_mvd( h, s, 0, 8, 4 );
+                if( b_list[1][0] ) cavlc_mb_mvd( h, s, 1, 0, 4 );
+                if( b_list[1][1] ) cavlc_mb_mvd( h, s, 1, 8, 4 );
+                break;
+            case D_8x16:
+                if( i_ref0_max && b_list[0][0] ) bs_write_te( s, i_ref0_max, h->mb.cache.ref[0][x264_scan8[0]] );
+                if( i_ref0_max && b_list[0][1] ) bs_write_te( s, i_ref0_max, h->mb.cache.ref[0][x264_scan8[4]] );
+                if( i_ref1_max && b_list[1][0] ) bs_write_te( s, i_ref1_max, h->mb.cache.ref[1][x264_scan8[0]] );
+                if( i_ref1_max && b_list[1][1] ) bs_write_te( s, i_ref1_max, h->mb.cache.ref[1][x264_scan8[4]] );
+                if( b_list[0][0] ) cavlc_mb_mvd( h, s, 0, 0, 2 );
+                if( b_list[0][1] ) cavlc_mb_mvd( h, s, 0, 4, 2 );
+                if( b_list[1][0] ) cavlc_mb_mvd( h, s, 1, 0, 2 );
+                if( b_list[1][1] ) cavlc_mb_mvd( h, s, 1, 4, 2 );
+                break;
         }
     }
     else //if( i_mb_type == B_DIRECT )



More information about the x264-devel mailing list