]> git.sesse.net Git - x264/blobdiff - common/quant.c
Add support for arbitrary user SEIs
[x264] / common / quant.c
index d3ba7e365855bfad74382857abd67878143089ea..08e1bae4a0eee95102ebd26efc35ea9a76a8c988 100644 (file)
@@ -1,9 +1,10 @@
 /*****************************************************************************
- * quant.c: h264 encoder library
+ * quant.c: quantization and level-run
  *****************************************************************************
- * Copyright (C) 2005-2008 x264 project
+ * Copyright (C) 2005-2010 x264 project
  *
  * Authors: Loren Merritt <lorenm@u.washington.edu>
+ *          Fiona Glaser <fiona@x264.com>
  *          Christian Heine <sennindemokrit@gmx.net>
  *
  * This program is free software; you can redistribute it and/or modify
  * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
  *****************************************************************************/
 
 #include "common.h"
 
-#ifdef HAVE_MMX
+#if HAVE_MMX
 #include "x86/quant.h"
 #endif
-#ifdef ARCH_PPC
+#if ARCH_PPC
 #   include "ppc/quant.h"
 #endif
-#ifdef ARCH_ARM
+#if ARCH_ARM
 #   include "arm/quant.h"
 #endif
 
@@ -142,7 +146,7 @@ static void x264_denoise_dct( dctcoef *dct, uint32_t *sum, uint16_t *offset, int
     for( int i = 1; i < size; i++ )
     {
         int level = dct[i];
-        int sign = level>>15;
+        int sign = level>>31;
         level = (level+sign)^sign;
         sum[i] += level;
         level -= offset[i];
@@ -177,10 +181,7 @@ static int ALWAYS_INLINE x264_decimate_score_internal( dctcoef *dct, int i_max )
     int i_score = 0;
     int idx = i_max - 1;
 
-    /* Yes, dct[idx-1] is guaranteed to be 32-bit aligned.  idx>=0 instead of 1 works correctly for the same reason */
-    while( idx >= 0 && MDCT_X2( &dct[idx-1] ) == 0 )
-        idx -= 2;
-    if( idx >= 0 && dct[idx] == 0 )
+    while( idx >= 0 && dct[idx] == 0 )
         idx--;
     while( idx >= 0 )
     {
@@ -216,10 +217,7 @@ static int x264_decimate_score64( dctcoef *dct )
 
 static int ALWAYS_INLINE x264_coeff_last_internal( dctcoef *l, int i_count )
 {
-    int i_last;
-    for( i_last = i_count-1; i_last >= 3; i_last -= 4 )
-        if( M64( l+i_last-3 ) )
-            break;
+    int i_last = i_count-1;
     while( i_last >= 0 && l[i_last] == 0 )
         i_last--;
     return i_last;
@@ -287,10 +285,11 @@ void x264_quant_init( x264_t *h, int cpu, x264_quant_function_t *pf )
     pf->coeff_level_run[  DCT_LUMA_AC] = x264_coeff_level_run15;
     pf->coeff_level_run[ DCT_LUMA_4x4] = x264_coeff_level_run16;
 
-#ifdef HAVE_MMX
+#if !X264_HIGH_BIT_DEPTH
+#if HAVE_MMX
     if( cpu&X264_CPU_MMX )
     {
-#ifdef ARCH_X86
+#if ARCH_X86
         pf->quant_4x4 = x264_quant_4x4_mmx;
         pf->quant_8x8 = x264_quant_8x8_mmx;
         pf->dequant_4x4 = x264_dequant_4x4_mmx;
@@ -308,7 +307,7 @@ void x264_quant_init( x264_t *h, int cpu, x264_quant_function_t *pf )
     if( cpu&X264_CPU_MMXEXT )
     {
         pf->quant_2x2_dc = x264_quant_2x2_dc_mmxext;
-#ifdef ARCH_X86
+#if ARCH_X86
         pf->quant_4x4_dc = x264_quant_4x4_dc_mmxext;
         pf->decimate_score15 = x264_decimate_score15_mmxext;
         pf->decimate_score16 = x264_decimate_score16_mmxext;
@@ -395,7 +394,7 @@ void x264_quant_init( x264_t *h, int cpu, x264_quant_function_t *pf )
     }
 #endif // HAVE_MMX
 
-#ifdef HAVE_ALTIVEC
+#if HAVE_ALTIVEC
     if( cpu&X264_CPU_ALTIVEC ) {
         pf->quant_2x2_dc = x264_quant_2x2_dc_altivec;
         pf->quant_4x4_dc = x264_quant_4x4_dc_altivec;
@@ -407,7 +406,7 @@ void x264_quant_init( x264_t *h, int cpu, x264_quant_function_t *pf )
     }
 #endif
 
-#ifdef HAVE_ARMV6
+#if HAVE_ARMV6
     if( cpu&X264_CPU_ARMV6 )
         pf->coeff_last[DCT_CHROMA_DC] = x264_coeff_last4_arm;
 
@@ -425,6 +424,7 @@ void x264_quant_init( x264_t *h, int cpu, x264_quant_function_t *pf )
         pf->coeff_last[DCT_LUMA_8x8] = x264_coeff_last64_neon;
     }
 #endif
+#endif // !X264_HIGH_BIT_DEPTH
     pf->coeff_last[  DCT_LUMA_DC] = pf->coeff_last[DCT_LUMA_4x4];
     pf->coeff_last[DCT_CHROMA_AC] = pf->coeff_last[ DCT_LUMA_AC];
     pf->coeff_level_run[  DCT_LUMA_DC] = pf->coeff_level_run[DCT_LUMA_4x4];