[x264-devel] commit: Use a 16-bit buffer in hpel_filter regardless of bit depth ( Oskar Arvidsson )

git at videolan.org git at videolan.org
Fri Nov 19 23:50:10 CET 2010


x264 | branch: master | Oskar Arvidsson <oskar at irock.se> | Sat Nov 13 14:42:54 2010 +0100| [c593bcf901e0bb681fdc41023ecd0aebbaafb98e] | committer: Jason Garrett-Glaser 

Use a 16-bit buffer in hpel_filter regardless of bit depth
This only works up to and including 10-bit (but we don't support anything higher yet).

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

 common/macroblock.c |    2 +-
 common/mc.c         |    8 +++++---
 common/mc.h         |    2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/common/macroblock.c b/common/macroblock.c
index 99302d0..5c76d3f 100644
--- a/common/macroblock.c
+++ b/common/macroblock.c
@@ -333,7 +333,7 @@ int x264_macroblock_thread_allocate( x264_t *h, int b_lookahead )
     int scratch_size = 0;
     if( !b_lookahead )
     {
-        int buf_hpel = (h->thread[0]->fdec->i_width[0]+48) * sizeof(dctcoef);
+        int buf_hpel = (h->thread[0]->fdec->i_width[0]+48) * sizeof(int16_t);
         int buf_ssim = h->param.analyse.b_ssim * 8 * (h->param.i_width/4+3) * sizeof(int);
         int me_range = X264_MIN(h->param.analyse.i_me_range, h->param.analyse.i_mv_range);
         int buf_tesa = (h->param.analyse.i_me_method >= X264_ME_ESA) *
diff --git a/common/mc.c b/common/mc.c
index acc2312..ef45eff 100644
--- a/common/mc.c
+++ b/common/mc.c
@@ -177,18 +177,20 @@ static void mc_copy( pixel *src, int i_src_stride, pixel *dst, int i_dst_stride,
 
 #define TAPFILTER(pix, d) ((pix)[x-2*d] + (pix)[x+3*d] - 5*((pix)[x-d] + (pix)[x+2*d]) + 20*((pix)[x] + (pix)[x+d]))
 static void hpel_filter( pixel *dsth, pixel *dstv, pixel *dstc, pixel *src,
-                         int stride, int width, int height, dctcoef *buf )
+                         int stride, int width, int height, int16_t *buf )
 {
+    const int pad = (BIT_DEPTH > 9) ? (-10 * PIXEL_MAX) : 0;
     for( int y = 0; y < height; y++ )
     {
         for( int x = -2; x < width+3; x++ )
         {
             int v = TAPFILTER(src,stride);
             dstv[x] = x264_clip_pixel( (v + 16) >> 5 );
-            buf[x+2] = v;
+            /* transform v for storage in a 16-bit integer */
+            buf[x+2] = v + pad;
         }
         for( int x = 0; x < width; x++ )
-            dstc[x] = x264_clip_pixel( (TAPFILTER(buf+2,1) + 512) >> 10 );
+            dstc[x] = x264_clip_pixel( (TAPFILTER(buf+2,1) - 32*pad + 512) >> 10 );
         for( int x = 0; x < width; x++ )
             dsth[x] = x264_clip_pixel( (TAPFILTER(src,1) + 16) >> 5 );
         dsth += stride;
diff --git a/common/mc.h b/common/mc.h
index a04b5c5..df16355 100644
--- a/common/mc.h
+++ b/common/mc.h
@@ -98,7 +98,7 @@ typedef struct
                                      pixel *src, int i_src, int w, int h );
 
     void (*hpel_filter)( pixel *dsth, pixel *dstv, pixel *dstc, pixel *src,
-                         int i_stride, int i_width, int i_height, dctcoef *buf );
+                         int i_stride, int i_width, int i_height, int16_t *buf );
 
     /* prefetch the next few macroblocks of fenc or fdec */
     void (*prefetch_fenc)( pixel *pix_y, int stride_y,



More information about the x264-devel mailing list