]> git.videolan.org Git - x264.git/commitdiff
Use a 16-bit buffer in hpel_filter regardless of bit depth
authorOskar Arvidsson <oskar@irock.se>
Sat, 13 Nov 2010 13:42:54 +0000 (14:42 +0100)
committerJason Garrett-Glaser <darkshikari@gmail.com>
Thu, 18 Nov 2010 17:58:13 +0000 (09:58 -0800)
This only works up to and including 10-bit (but we don't support anything higher yet).

common/macroblock.c
common/mc.c
common/mc.h

index 99302d03b495d31f110ed5e580c1792fba6639a1..5c76d3f8d5486d579298cdd8004f2e599b61d613 100644 (file)
@@ -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) *
index acc2312056c03d413f54154c004172f18af868c1..ef45eff181cf234321466a87e130c62f18520f16 100644 (file)
@@ -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;
index a04b5c5a6c0d098b1b22dc0a06f28b0a3e70f4cf..df16355c618ec8ccb05b927412d1c76c633878bf 100644 (file)
@@ -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,