/*****************************************************************************
- * 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
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];
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 )
{
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;
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;
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;
}
#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;
}
#endif
-#ifdef HAVE_ARMV6
+#if HAVE_ARMV6
if( cpu&X264_CPU_ARMV6 )
pf->coeff_last[DCT_CHROMA_DC] = x264_coeff_last4_arm;
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];