]> git.videolan.org Git - x264.git/commitdiff
allow i4x4 and i8x8 down-left prediction with emulated top-right samples.
authorLoren Merritt <pengvado@videolan.org>
Sat, 24 Sep 2005 16:58:36 +0000 (16:58 +0000)
committerLoren Merritt <pengvado@videolan.org>
Sat, 24 Sep 2005 16:58:36 +0000 (16:58 +0000)
based on a patch by Johannes Reinhardt (Johannes dot Reinhardt at uni-konstanz dot de)

git-svn-id: svn://svn.videolan.org/x264/trunk@296 df754926-b1dd-0310-bc7b-ec298dee348c

encoder/analyse.c
encoder/macroblock.c

index 0c59c550f8eec398ba8880d04eb1f0b3548d43a8..46b16e321e5134235cb48b3a5be0ae1d72d8c663 100644 (file)
@@ -364,23 +364,21 @@ static void predict_8x8chroma_mode_available( unsigned int i_neighbour, int *mod
 static void predict_4x4_mode_available( unsigned int i_neighbour,
                                         int *mode, int *pi_count )
 {
-    /* FIXME even when b_tr == 0 there is some case where missing pixels
-     * are emulated and thus more mode are available TODO
-     * analysis and encode should be fixed too */
     int b_l = i_neighbour & MB_LEFT;
     int b_t = i_neighbour & MB_TOP;
-    int b_tr = i_neighbour & MB_TOPRIGHT;
 
     if( b_l && b_t )
     {
         *mode++ = I_PRED_4x4_DC;
         *mode++ = I_PRED_4x4_H;
         *mode++ = I_PRED_4x4_V;
+        *mode++ = I_PRED_4x4_DDL;
         *mode++ = I_PRED_4x4_DDR;
         *mode++ = I_PRED_4x4_VR;
         *mode++ = I_PRED_4x4_HD;
+        *mode++ = I_PRED_4x4_VL;
         *mode++ = I_PRED_4x4_HU;
-        *pi_count = 7;
+        *pi_count = 9;
     }
     else if( b_l )
     {
@@ -393,20 +391,15 @@ static void predict_4x4_mode_available( unsigned int i_neighbour,
     {
         *mode++ = I_PRED_4x4_DC_TOP;
         *mode++ = I_PRED_4x4_V;
-        *pi_count = 2;
+        *mode++ = I_PRED_4x4_DDL;
+        *mode++ = I_PRED_4x4_VL;
+        *pi_count = 4;
     }
     else
     {
         *mode++ = I_PRED_4x4_DC_128;
         *pi_count = 1;
     }
-
-    if( b_t && b_tr )
-    {
-        *mode++ = I_PRED_4x4_DDL;
-        *mode++ = I_PRED_4x4_VL;
-        (*pi_count) += 2;
-    }
 }
 
 static void x264_mb_analyse_intra_chroma( x264_t *h, x264_mb_analysis_t *a )
@@ -542,6 +535,11 @@ static void x264_mb_analyse_intra( x264_t *h, x264_mb_analysis_t *a, int i_cost_
 
             i_best = COST_MAX;
             predict_4x4_mode_available( h->mb.i_neighbour4[idx], predict_mode, &i_max );
+
+            if( (h->mb.i_neighbour4[i] & (MB_TOPRIGHT|MB_TOP)) == MB_TOP )
+                /* emulate missing topright samples */
+                *(uint32_t*) &p_dst_by[4 - i_stride] = p_dst_by[3 - i_stride] * 0x01010101U;
+
             for( i = 0; i < i_max; i++ )
             {
                 int i_sad;
index e1514fbbbc62ec1b89f765e0919d6e18476fe4a4..0b767038bdd511aec1e38c1b1b4505a7cc8cc30c 100644 (file)
@@ -593,6 +593,10 @@ void x264_macroblock_encode( x264_t *h )
             uint8_t  *p_dst = &h->mb.pic.p_fdec[0][4 * block_idx_x[i] + 4 * block_idx_y[i] * i_dst];
             int      i_mode = h->mb.cache.intra4x4_pred_mode[x264_scan8[i]];
 
+            if( (h->mb.i_neighbour4[i] & (MB_TOPRIGHT|MB_TOP)) == MB_TOP )
+                /* emulate missing topright samples */
+                *(uint32_t*) &p_dst[4 - i_dst] = p_dst[3 - i_dst] * 0x01010101U;
+
             h->predict_4x4[i_mode]( p_dst, i_dst );
             x264_mb_encode_i4x4( h, i, i_qp );
             h->mb.cache.intra4x4_pred_mode[x264_scan8[i]] = x264_mb_pred_mode4x4_fix(i_mode);