[x265] [PATCH] slicetype: added satd calc for bidirectional

gopu at multicorewareinc.com gopu at multicorewareinc.com
Mon Aug 12 23:21:25 CEST 2013


# HG changeset patch
# User ggopu
# Date 1376342467 25200
# Node ID 7516958758674687cb22a815531c6872c5cdf08b
# Parent  8438cad92049281833caa951cc48f6d90c7434eb
slicetype: added satd calc for bidirectional

diff -r 8438cad92049 -r 751695875867 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Sun Aug 11 21:41:12 2013 -0700
+++ b/source/encoder/slicetype.cpp	Mon Aug 12 14:21:07 2013 -0700
@@ -38,7 +38,7 @@
 
 #define QP_BD_OFFSET (6*(X265_DEPTH-8))
 // arbitrary, but low because SATD scores are 1/4 normal
-#define X264_LOOKAHEAD_QP (12+QP_BD_OFFSET)
+#define X265_LOOKAHEAD_QP (12+QP_BD_OFFSET)
 
 // Under Construction
 #if defined(_MSC_VER)
@@ -46,6 +46,12 @@
 #pragma warning(disable: 4189) // unused local variable
 #endif
 
+#define CLIP_MV( mv ) \
+    { \
+        mv.x = x265_clip3( mv.x, mvmin.x, mvmax.x ); \
+        mv.y = x265_clip3( mv.y, mvmin.y, mvmax.y ); \
+    }
+
 namespace x265 {
 
 struct Lookahead
@@ -61,7 +67,7 @@
     
     Lookahead(int _frameQueueSize)
     {
-        me.setQP(X264_LOOKAHEAD_QP, 1.0);
+        me.setQP(X265_LOOKAHEAD_QP, 1.0);
         me.setSearchMethod(X265_DIA_SEARCH);
         frameQueueSize = _frameQueueSize;
         frames = new LookaheadFrame*[frameQueueSize];
@@ -76,6 +82,25 @@
     int estimateCUCost(int cux, int cuy, int p0, int p1, int b, int do_search[2]);
 };
 
+static inline int16_t x265_clip3( int16_t v, int16_t i_min, int16_t i_max )
+{
+    return ( (v < i_min) ? i_min : (v > i_max) ? i_max : v );
+}
+
+static inline void pixel_avg_wxh( pixel *dst,  intptr_t i_dst,
+                                  pixel *src1, intptr_t i_src1,
+                                  pixel *src2, intptr_t i_src2, int width, int height )
+{
+    for( int y = 0; y < height; y++ )
+    {
+        for( int x = 0; x < width; x++ )
+            dst[x] = ( src1[x] + src2[x] + 1 ) >> 1;
+        src1 += i_src1;
+        src2 += i_src2;
+        dst += i_dst;
+    }
+}
+
 static inline int16_t x265_median( int16_t a, int16_t b, int16_t c )
 {
     int16_t t = (a-b)&((a-b)>>31);
@@ -206,7 +231,42 @@
     }
     if (b_bidir)
     {
-        // TODO: add bidir
+       
+        MV mvr = fref1->lowresMvs[0][p1 - p0 - 1][cu_xy];
+        MV dmv[2];
+
+        //Need to identify use of this variable 
+        int16_t dist_scale_factor = 1;
+
+        dmv[0].x = ( mvr.x * dist_scale_factor + 128 ) >> 8;
+        dmv[0].y = ( mvr.y * dist_scale_factor + 128 ) >> 8;
+        dmv[1].x = dmv[0].x - mvr.x;
+        dmv[1].y = dmv[0].y - mvr.y;
+
+        CLIP_MV( dmv[0] );
+        CLIP_MV( dmv[1] );
+
+        /* start bidirectional  */
+        int i_cost;
+
+        /* need to check this also */
+        int subpel_refine  = 0;
+
+        if(subpel_refine)
+        {
+            MV  mv0 = dmv[0];
+            MV  mv1 = dmv[1];
+            int hpel_idx1 = ((mv0.x&2)>>1) + ((mv0).y&2); 
+            int hpel_idx2 = (((mv1).x&2)>>1) + ((mv1).y&2); 
+
+            pixel *src1 = fref1->m_lumaPlane[0][0] + ((mv0).x>>2) + ((mv0).y>>2) * fref1->m_lumaStride; 
+            pixel *src2 = fref1->m_lumaPlane[0][0] + ((mv1).x>>2) + ((mv1).y>>2) * fref1->m_lumaStride; 
+            pixel *pix1;
+
+            pixel_avg_wxh( pix1, cu_size, src1, fref0->m_lumaStride, src2, fref1->m_lumaStride, fref1->cuWidth, fref1->cuHeight);
+            /* TODO Call satd cost analysis */
+        }
+        
     }
 
     // TODO: copy intra SATD cost analysis here (DC + planar + all-angs)


More information about the x265-devel mailing list