]> granicus.if.org Git - libx264/commitdiff
remove x264_mc_clip1.
authorLoren Merritt <pengvado@akuvian.org>
Sun, 16 Mar 2008 21:30:40 +0000 (15:30 -0600)
committerLoren Merritt <pengvado@akuvian.org>
Sun, 16 Mar 2008 21:30:40 +0000 (15:30 -0600)
it's wrong for sufficiently perverse inputs, and clip_uint8 is faster anyway.

common/clip1.h [deleted file]
common/common.h
common/dct.c
common/mc.c
common/pixel.c
common/predict.c
common/x86/predict-c.c

diff --git a/common/clip1.h b/common/clip1.h
deleted file mode 100644 (file)
index 84dad8b..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*****************************************************************************
- * clip1.h: h264 encoder library
- *****************************************************************************
- * Copyright (C) 2003 Laurent Aimar
- * $Id: clip1.h,v 1.1 2004/06/03 19:27:06 fenrir Exp $
- *
- * Authors: Laurent Aimar <fenrir@via.ecp.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-#ifndef _CLIP1_H
-#define _CLIP1_H 1
-
-/* Clip1 table
- * XXX : only for tap filter.
- *
- * With tap filter (( 1, -5, 20, 20, -5, 1 ) + 16 )/ 32
- * -> (-2*5 * 255+16)/32 <= out <= (2*1*255 + 2*20*255+16)/32
- * -> -80 <= out <= 335
- * So we need a table of 80+335+1 = 416 entries
- */
-
-static const uint8_t x264_mc_clip1_table[80+1+335] =
-{
-    /* -80 -> -1 */
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,
-    /* 0 -> 255 */
-    0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16, 17,
-    18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
-    36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
-    54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
-    72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
-    90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,101,102,103,104,105,106,107,
-    108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,
-    126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
-    144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,
-    162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,
-    180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,
-    198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,
-    216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,
-    234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,
-    252,253,254,255,
-    /* 256 -> 340 */
-    255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-    255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-    255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-    255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-    255,255,255,255,255,255,255,255,
-};
-
-static inline uint8_t x264_mc_clip1( int x )
-{
-    return x264_mc_clip1_table[x+80];
-}
-
-static inline uint8_t x264_clip_uint8( int x )
-{
-    return x&(~255) ? (-x)>>31 : x;
-}
-
-#endif
index 2fbb069f9242bbb5170141b41baf6129e01495e1..d1c5e776fc03fedde42edb2f2b3c083780513d28 100644 (file)
@@ -102,6 +102,11 @@ void x264_log( x264_t *h, int i_level, const char *psz_fmt, ... );
 
 void x264_reduce_fraction( int *n, int *d );
 
+static inline uint8_t x264_clip_uint8( int x )
+{
+    return x&(~255) ? (-x)>>31 : x;
+}
+
 static inline int x264_clip3( int v, int i_min, int i_max )
 {
     return ( (v < i_min) ? i_min : (v > i_max) ? i_max : v );
index ae95ab5f5898374a3be39920cca72e41456cf4f7..74e5a9175aadef3d45566d40d56a8768a589dcc2 100644 (file)
 int x264_dct4_weight2_zigzag[2][16];
 int x264_dct8_weight2_zigzag[2][64];
 
-static inline int clip_uint8( int a )
-{
-    if (a&(~255))
-        return (-a)>>31;
-    else
-        return a;
-}
-
 /*
  * XXX For all dct dc : input could be equal to output so ...
  */
@@ -232,7 +224,7 @@ static void add4x4_idct( uint8_t *p_dst, int16_t dct[4][4] )
     {
         for( x = 0; x < 4; x++ )
         {
-            p_dst[x] = clip_uint8( p_dst[x] + d[y][x] );
+            p_dst[x] = x264_clip_uint8( p_dst[x] + d[y][x] );
         }
         p_dst += FDEC_STRIDE;
     }
@@ -356,7 +348,7 @@ static void add8x8_idct8( uint8_t *dst, int16_t dct[8][8] )
 #undef DST
 
 #define SRC(x)     dct[i][x]
-#define DST(x,rhs) dst[i + x*FDEC_STRIDE] = clip_uint8( dst[i + x*FDEC_STRIDE] + ((rhs) >> 6) );
+#define DST(x,rhs) dst[i + x*FDEC_STRIDE] = x264_clip_uint8( dst[i + x*FDEC_STRIDE] + ((rhs) >> 6) );
     for( i = 0; i < 8; i++ )
         IDCT8_1D
 #undef SRC
index 1fd3aecaea6968ac191b157eb1558418004c0b9e..488c5417c32e50e63f1f24136d71814d18799c59 100644 (file)
@@ -22,7 +22,6 @@
  *****************************************************************************/
 
 #include "common.h"
-#include "clip1.h"
 
 #ifdef HAVE_MMX
 #include "x86/mc.h"
@@ -163,7 +162,7 @@ static inline void mc_hh( uint8_t *src, int i_src_stride, uint8_t *dst, int i_ds
     {
         for( x = 0; x < i_width; x++ )
         {
-            dst[x] = x264_mc_clip1( ( x264_tapfilter1( &src[x] ) + 16 ) >> 5 );
+            dst[x] = x264_clip_uint8( ( x264_tapfilter1( &src[x] ) + 16 ) >> 5 );
         }
         src += i_src_stride;
         dst += i_dst_stride;
@@ -177,7 +176,7 @@ static inline void mc_hv( uint8_t *src, int i_src_stride, uint8_t *dst, int i_ds
     {
         for( x = 0; x < i_width; x++ )
         {
-            dst[x] = x264_mc_clip1( ( x264_tapfilter( &src[x], i_src_stride ) + 16 ) >> 5 );
+            dst[x] = x264_clip_uint8( ( x264_tapfilter( &src[x], i_src_stride ) + 16 ) >> 5 );
         }
         src += i_src_stride;
         dst += i_dst_stride;
@@ -206,7 +205,7 @@ static inline void mc_hc( uint8_t *src, int i_src_stride, uint8_t *dst, int i_ds
         {
             tap[5] = x264_tapfilter1( &pix[ 3*i_src_stride] );
 
-            *out = x264_mc_clip1( ( tap[0] - 5*tap[1] + 20 * tap[2] + 20 * tap[3] -5*tap[4] + tap[5] + 512 ) >> 10 );
+            *out = x264_clip_uint8( ( tap[0] - 5*tap[1] + 20 * tap[2] + 20 * tap[3] -5*tap[4] + tap[5] + 512 ) >> 10 );
 
             /* Next line */
             pix += i_src_stride;
index 9103941113130fccb489a97f83ba6bd7e0f72cf8..5200c6675f7abdd6ee0c0415df7839322ffda09f 100644 (file)
@@ -22,7 +22,6 @@
  *****************************************************************************/
 
 #include "common.h"
-#include "clip1.h"
 
 #ifdef HAVE_MMX
 #   include "x86/pixel.h"
index 1ffa5229843d8ea756abdb92faff3004ae2255b1..d6cb2a569d4d5e623037653ab8b63f103575e1dc 100644 (file)
@@ -26,7 +26,6 @@
 
 
 #include "common.h"
-#include "clip1.h"
 
 #ifdef _MSC_VER
 #undef HAVE_MMX  /* not finished now */
index 8768fbfacb4623cb6ddf8a9b95ab9703b4713241..ac33ce8a9c61c373c919985e88121e0d69cf54ed 100644 (file)
@@ -22,7 +22,6 @@
  *****************************************************************************/
 
 #include "common/common.h"
-#include "common/clip1.h"
 #include "predict.h"
 #include "pixel.h"