Commit 58d2349d authored by Fiona Glaser's avatar Fiona Glaser

Massive cosmetic and syntax cleanup

Convert all applicable loops to use C99 loop index syntax.
Clean up most inconsistent syntax in ratecontrol.c, visualize, ppc, etc.
Replace log(x)/log(2) constructs with log2, and similar with log10.
Fix all -Wshadow violations.
Fix visualize support.
parent 3b31b6cd
...@@ -787,21 +787,14 @@ const uint16_t x264_cabac_entropy[128][2] = ...@@ -787,21 +787,14 @@ const uint16_t x264_cabac_entropy[128][2] =
void x264_cabac_context_init( x264_cabac_t *cb, int i_slice_type, int i_qp, int i_model ) void x264_cabac_context_init( x264_cabac_t *cb, int i_slice_type, int i_qp, int i_model )
{ {
const int8_t (*cabac_context_init)[460][2]; const int8_t (*cabac_context_init)[460][2];
int i;
if( i_slice_type == SLICE_TYPE_I ) if( i_slice_type == SLICE_TYPE_I )
{
cabac_context_init = &x264_cabac_context_init_I; cabac_context_init = &x264_cabac_context_init_I;
}
else else
{
cabac_context_init = &x264_cabac_context_init_PB[i_model]; cabac_context_init = &x264_cabac_context_init_PB[i_model];
}
for( i = 0; i < 460; i++ ) for( int i = 0; i < 460; i++ )
{
cb->state[i] = x264_clip3( (((*cabac_context_init)[i][0] * i_qp) >> 4) + (*cabac_context_init)[i][1], 1, 126 ); cb->state[i] = x264_clip3( (((*cabac_context_init)[i][0] * i_qp) >> 4) + (*cabac_context_init)[i][1], 1, 126 );
}
} }
void x264_cabac_encode_init( x264_cabac_t *cb, uint8_t *p_data, uint8_t *p_end ) void x264_cabac_encode_init( x264_cabac_t *cb, uint8_t *p_data, uint8_t *p_end )
...@@ -824,9 +817,7 @@ static inline void x264_cabac_putbyte( x264_cabac_t *cb ) ...@@ -824,9 +817,7 @@ static inline void x264_cabac_putbyte( x264_cabac_t *cb )
cb->i_queue -= 8; cb->i_queue -= 8;
if( (out & 0xff) == 0xff ) if( (out & 0xff) == 0xff )
{
cb->i_bytes_outstanding++; cb->i_bytes_outstanding++;
}
else else
{ {
int carry = out >> 8; int carry = out >> 8;
...@@ -886,10 +877,9 @@ void x264_cabac_encode_bypass( x264_cabac_t *cb, int b ) ...@@ -886,10 +877,9 @@ void x264_cabac_encode_bypass( x264_cabac_t *cb, int b )
void x264_cabac_encode_ue_bypass( x264_cabac_t *cb, int exp_bits, int val ) void x264_cabac_encode_ue_bypass( x264_cabac_t *cb, int exp_bits, int val )
{ {
int k, i; int k, i;
uint32_t x;
for( k = exp_bits; val >= (1<<k); k++ ) for( k = exp_bits; val >= (1<<k); k++ )
val -= 1<<k; val -= 1<<k;
x = (((1<<(k-exp_bits))-1)<<(k+1))+val; uint32_t x = (((1<<(k-exp_bits))-1)<<(k+1))+val;
k = 2*k+1-exp_bits; k = 2*k+1-exp_bits;
i = ((k-1)&7)+1; i = ((k-1)&7)+1;
do { do {
......
...@@ -451,8 +451,7 @@ int x264_param_apply_profile( x264_param_t *param, const char *profile ) ...@@ -451,8 +451,7 @@ int x264_param_apply_profile( x264_param_t *param, const char *profile )
static int parse_enum( const char *arg, const char * const *names, int *dst ) static int parse_enum( const char *arg, const char * const *names, int *dst )
{ {
int i; for( int i = 0; names[i]; i++ )
for( i = 0; names[i]; i++ )
if( !strcmp( arg, names[i] ) ) if( !strcmp( arg, names[i] ) )
{ {
*dst = i; *dst = i;
...@@ -527,10 +526,10 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value ) ...@@ -527,10 +526,10 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
if( strchr( name, '_' ) ) // s/_/-/g if( strchr( name, '_' ) ) // s/_/-/g
{ {
char *p; char *c;
name_buf = strdup(name); name_buf = strdup(name);
while( (p = strchr( name_buf, '_' )) ) while( (c = strchr( name_buf, '_' )) )
*p = '-'; *c = '-';
name = name_buf; name = name_buf;
} }
...@@ -892,9 +891,9 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value ) ...@@ -892,9 +891,9 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
p->rc.f_aq_strength = atof(value); p->rc.f_aq_strength = atof(value);
OPT("pass") OPT("pass")
{ {
int i = x264_clip3( atoi(value), 0, 3 ); int pass = x264_clip3( atoi(value), 0, 3 );
p->rc.b_stat_write = i & 1; p->rc.b_stat_write = pass & 1;
p->rc.b_stat_read = i & 2; p->rc.b_stat_read = pass & 2;
} }
OPT("stats") OPT("stats")
{ {
......
...@@ -165,8 +165,8 @@ static ALWAYS_INLINE void x264_median_mv( int16_t *dst, int16_t *a, int16_t *b, ...@@ -165,8 +165,8 @@ static ALWAYS_INLINE void x264_median_mv( int16_t *dst, int16_t *a, int16_t *b,
static ALWAYS_INLINE int x264_predictor_difference( int16_t (*mvc)[2], intptr_t i_mvc ) static ALWAYS_INLINE int x264_predictor_difference( int16_t (*mvc)[2], intptr_t i_mvc )
{ {
int sum = 0, i; int sum = 0;
for( i = 0; i < i_mvc-1; i++ ) for( int i = 0; i < i_mvc-1; i++ )
{ {
sum += abs( mvc[i][0] - mvc[i+1][0] ) sum += abs( mvc[i][0] - mvc[i+1][0] )
+ abs( mvc[i][1] - mvc[i+1][1] ); + abs( mvc[i][1] - mvc[i+1][1] );
......
...@@ -167,7 +167,7 @@ uint32_t x264_cpu_detect( void ) ...@@ -167,7 +167,7 @@ uint32_t x264_cpu_detect( void )
/* 6/9 (pentium-m "banias"), 6/13 (pentium-m "dothan"), and 6/14 (core1 "yonah") /* 6/9 (pentium-m "banias"), 6/13 (pentium-m "dothan"), and 6/14 (core1 "yonah")
* theoretically support sse2, but it's significantly slower than mmx for * theoretically support sse2, but it's significantly slower than mmx for
* almost all of x264's functions, so let's just pretend they don't. */ * almost all of x264's functions, so let's just pretend they don't. */
if( family==6 && (model==9 || model==13 || model==14) ) if( family == 6 && (model == 9 || model == 13 || model == 14) )
{ {
cpu &= ~(X264_CPU_SSE2|X264_CPU_SSE3); cpu &= ~(X264_CPU_SSE2|X264_CPU_SSE3);
assert(!(cpu&(X264_CPU_SSSE3|X264_CPU_SSE4))); assert(!(cpu&(X264_CPU_SSSE3|X264_CPU_SSE4)));
...@@ -188,14 +188,15 @@ uint32_t x264_cpu_detect( void ) ...@@ -188,14 +188,15 @@ uint32_t x264_cpu_detect( void )
{ {
// Cache and TLB Information // Cache and TLB Information
static const char cache32_ids[] = { 0x0a, 0x0c, 0x41, 0x42, 0x43, 0x44, 0x45, 0x82, 0x83, 0x84, 0x85, 0 }; static const char cache32_ids[] = { 0x0a, 0x0c, 0x41, 0x42, 0x43, 0x44, 0x45, 0x82, 0x83, 0x84, 0x85, 0 };
static const char cache64_ids[] = { 0x22, 0x23, 0x25, 0x29, 0x2c, 0x46, 0x47, 0x49, 0x60, 0x66, 0x67, 0x68, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7c, 0x7f, 0x86, 0x87, 0 }; static const char cache64_ids[] = { 0x22, 0x23, 0x25, 0x29, 0x2c, 0x46, 0x47, 0x49, 0x60, 0x66, 0x67,
0x68, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7c, 0x7f, 0x86, 0x87, 0 };
uint32_t buf[4]; uint32_t buf[4];
int max, i=0, j; int max, i = 0;
do { do {
x264_cpu_cpuid( 2, buf+0, buf+1, buf+2, buf+3 ); x264_cpu_cpuid( 2, buf+0, buf+1, buf+2, buf+3 );
max = buf[0]&0xff; max = buf[0]&0xff;
buf[0] &= ~0xff; buf[0] &= ~0xff;
for(j=0; j<4; j++) for( int j = 0; j < 4; j++ )
if( !(buf[j]>>31) ) if( !(buf[j]>>31) )
while( buf[j] ) while( buf[j] )
{ {
...@@ -241,9 +242,7 @@ uint32_t x264_cpu_detect( void ) ...@@ -241,9 +242,7 @@ uint32_t x264_cpu_detect( void )
int error = sysctl( selectors, 2, &has_altivec, &length, NULL, 0 ); int error = sysctl( selectors, 2, &has_altivec, &length, NULL, 0 );
if( error == 0 && has_altivec != 0 ) if( error == 0 && has_altivec != 0 )
{
cpu |= X264_CPU_ALTIVEC; cpu |= X264_CPU_ALTIVEC;
}
return cpu; return cpu;
} }
...@@ -252,7 +251,7 @@ uint32_t x264_cpu_detect( void ) ...@@ -252,7 +251,7 @@ uint32_t x264_cpu_detect( void )
uint32_t x264_cpu_detect( void ) uint32_t x264_cpu_detect( void )
{ {
static void (* oldsig)( int ); static void (*oldsig)( int );
oldsig = signal( SIGILL, sigill_handler ); oldsig = signal( SIGILL, sigill_handler );
if( sigsetjmp( jmpbuf, 1 ) ) if( sigsetjmp( jmpbuf, 1 ) )
......
...@@ -38,16 +38,13 @@ int x264_dct8_weight2_zigzag[2][64]; ...@@ -38,16 +38,13 @@ int x264_dct8_weight2_zigzag[2][64];
static void dct4x4dc( int16_t d[16] ) static void dct4x4dc( int16_t d[16] )
{ {
int16_t tmp[16]; int16_t tmp[16];
int s01, s23;
int d01, d23;
int i;
for( i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
s01 = d[i*4+0] + d[i*4+1]; int s01 = d[i*4+0] + d[i*4+1];
d01 = d[i*4+0] - d[i*4+1]; int d01 = d[i*4+0] - d[i*4+1];
s23 = d[i*4+2] + d[i*4+3]; int s23 = d[i*4+2] + d[i*4+3];
d23 = d[i*4+2] - d[i*4+3]; int d23 = d[i*4+2] - d[i*4+3];
tmp[0*4+i] = s01 + s23; tmp[0*4+i] = s01 + s23;
tmp[1*4+i] = s01 - s23; tmp[1*4+i] = s01 - s23;
...@@ -55,12 +52,12 @@ static void dct4x4dc( int16_t d[16] ) ...@@ -55,12 +52,12 @@ static void dct4x4dc( int16_t d[16] )
tmp[3*4+i] = d01 + d23; tmp[3*4+i] = d01 + d23;
} }
for( i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
s01 = tmp[i*4+0] + tmp[i*4+1]; int s01 = tmp[i*4+0] + tmp[i*4+1];
d01 = tmp[i*4+0] - tmp[i*4+1]; int d01 = tmp[i*4+0] - tmp[i*4+1];
s23 = tmp[i*4+2] + tmp[i*4+3]; int s23 = tmp[i*4+2] + tmp[i*4+3];
d23 = tmp[i*4+2] - tmp[i*4+3]; int d23 = tmp[i*4+2] - tmp[i*4+3];
d[i*4+0] = ( s01 + s23 + 1 ) >> 1; d[i*4+0] = ( s01 + s23 + 1 ) >> 1;
d[i*4+1] = ( s01 - s23 + 1 ) >> 1; d[i*4+1] = ( s01 - s23 + 1 ) >> 1;
...@@ -72,16 +69,13 @@ static void dct4x4dc( int16_t d[16] ) ...@@ -72,16 +69,13 @@ static void dct4x4dc( int16_t d[16] )
static void idct4x4dc( int16_t d[16] ) static void idct4x4dc( int16_t d[16] )
{ {
int16_t tmp[16]; int16_t tmp[16];
int s01, s23;
int d01, d23;
int i;
for( i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
s01 = d[i*4+0] + d[i*4+1]; int s01 = d[i*4+0] + d[i*4+1];
d01 = d[i*4+0] - d[i*4+1]; int d01 = d[i*4+0] - d[i*4+1];
s23 = d[i*4+2] + d[i*4+3]; int s23 = d[i*4+2] + d[i*4+3];
d23 = d[i*4+2] - d[i*4+3]; int d23 = d[i*4+2] - d[i*4+3];
tmp[0*4+i] = s01 + s23; tmp[0*4+i] = s01 + s23;
tmp[1*4+i] = s01 - s23; tmp[1*4+i] = s01 - s23;
...@@ -89,12 +83,12 @@ static void idct4x4dc( int16_t d[16] ) ...@@ -89,12 +83,12 @@ static void idct4x4dc( int16_t d[16] )
tmp[3*4+i] = d01 + d23; tmp[3*4+i] = d01 + d23;
} }
for( i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
s01 = tmp[i*4+0] + tmp[i*4+1]; int s01 = tmp[i*4+0] + tmp[i*4+1];
d01 = tmp[i*4+0] - tmp[i*4+1]; int d01 = tmp[i*4+0] - tmp[i*4+1];
s23 = tmp[i*4+2] + tmp[i*4+3]; int s23 = tmp[i*4+2] + tmp[i*4+3];
d23 = tmp[i*4+2] - tmp[i*4+3]; int d23 = tmp[i*4+2] - tmp[i*4+3];
d[i*4+0] = s01 + s23; d[i*4+0] = s01 + s23;
d[i*4+1] = s01 - s23; d[i*4+1] = s01 - s23;
...@@ -106,13 +100,10 @@ static void idct4x4dc( int16_t d[16] ) ...@@ -106,13 +100,10 @@ static void idct4x4dc( int16_t d[16] )
static inline void pixel_sub_wxh( int16_t *diff, int i_size, static inline void pixel_sub_wxh( int16_t *diff, int i_size,
uint8_t *pix1, int i_pix1, uint8_t *pix2, int i_pix2 ) uint8_t *pix1, int i_pix1, uint8_t *pix2, int i_pix2 )
{ {
int y, x; for( int y = 0; y < i_size; y++ )
for( y = 0; y < i_size; y++ )
{ {
for( x = 0; x < i_size; x++ ) for( int x = 0; x < i_size; x++ )
{
diff[x + y*i_size] = pix1[x] - pix2[x]; diff[x + y*i_size] = pix1[x] - pix2[x];
}
pix1 += i_pix1; pix1 += i_pix1;
pix2 += i_pix2; pix2 += i_pix2;
} }
...@@ -122,16 +113,15 @@ static void sub4x4_dct( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 ) ...@@ -122,16 +113,15 @@ static void sub4x4_dct( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 )
{ {
int16_t d[16]; int16_t d[16];
int16_t tmp[16]; int16_t tmp[16];
int i;
pixel_sub_wxh( d, 4, pix1, FENC_STRIDE, pix2, FDEC_STRIDE ); pixel_sub_wxh( d, 4, pix1, FENC_STRIDE, pix2, FDEC_STRIDE );
for( i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
const int s03 = d[i*4+0] + d[i*4+3]; int s03 = d[i*4+0] + d[i*4+3];
const int s12 = d[i*4+1] + d[i*4+2]; int s12 = d[i*4+1] + d[i*4+2];
const int d03 = d[i*4+0] - d[i*4+3]; int d03 = d[i*4+0] - d[i*4+3];
const int d12 = d[i*4+1] - d[i*4+2]; int d12 = d[i*4+1] - d[i*4+2];
tmp[0*4+i] = s03 + s12; tmp[0*4+i] = s03 + s12;
tmp[1*4+i] = 2*d03 + d12; tmp[1*4+i] = 2*d03 + d12;
...@@ -139,12 +129,12 @@ static void sub4x4_dct( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 ) ...@@ -139,12 +129,12 @@ static void sub4x4_dct( int16_t dct[16], uint8_t *pix1, uint8_t *pix2 )
tmp[3*4+i] = d03 - 2*d12; tmp[3*4+i] = d03 - 2*d12;
} }
for( i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
const int s03 = tmp[i*4+0] + tmp[i*4+3]; int s03 = tmp[i*4+0] + tmp[i*4+3];
const int s12 = tmp[i*4+1] + tmp[i*4+2]; int s12 = tmp[i*4+1] + tmp[i*4+2];
const int d03 = tmp[i*4+0] - tmp[i*4+3]; int d03 = tmp[i*4+0] - tmp[i*4+3];
const int d12 = tmp[i*4+1] - tmp[i*4+2]; int d12 = tmp[i*4+1] - tmp[i*4+2];
dct[i*4+0] = s03 + s12; dct[i*4+0] = s03 + s12;
dct[i*4+1] = 2*d03 + d12; dct[i*4+1] = 2*d03 + d12;
...@@ -184,17 +174,16 @@ static int sub4x4_dct_dc( uint8_t *pix1, uint8_t *pix2 ) ...@@ -184,17 +174,16 @@ static int sub4x4_dct_dc( uint8_t *pix1, uint8_t *pix2 )
static void sub8x8_dct_dc( int16_t dct[4], uint8_t *pix1, uint8_t *pix2 ) static void sub8x8_dct_dc( int16_t dct[4], uint8_t *pix1, uint8_t *pix2 )
{ {
int d0, d1, d2, d3;
dct[0] = sub4x4_dct_dc( &pix1[0], &pix2[0] ); dct[0] = sub4x4_dct_dc( &pix1[0], &pix2[0] );
dct[1] = sub4x4_dct_dc( &pix1[4], &pix2[4] ); dct[1] = sub4x4_dct_dc( &pix1[4], &pix2[4] );
dct[2] = sub4x4_dct_dc( &pix1[4*FENC_STRIDE+0], &pix2[4*FDEC_STRIDE+0] ); dct[2] = sub4x4_dct_dc( &pix1[4*FENC_STRIDE+0], &pix2[4*FDEC_STRIDE+0] );
dct[3] = sub4x4_dct_dc( &pix1[4*FENC_STRIDE+4], &pix2[4*FDEC_STRIDE+4] ); dct[3] = sub4x4_dct_dc( &pix1[4*FENC_STRIDE+4], &pix2[4*FDEC_STRIDE+4] );
/* 2x2 DC transform */ /* 2x2 DC transform */
d0 = dct[0] + dct[1]; int d0 = dct[0] + dct[1];
d1 = dct[2] + dct[3]; int d1 = dct[2] + dct[3];
d2 = dct[0] - dct[1]; int d2 = dct[0] - dct[1];
d3 = dct[2] - dct[3]; int d3 = dct[2] - dct[3];
dct[0] = d0 + d1; dct[0] = d0 + d1;
dct[2] = d2 + d3; dct[2] = d2 + d3;
dct[1] = d0 - d1; dct[1] = d0 - d1;
...@@ -205,15 +194,13 @@ static void add4x4_idct( uint8_t *p_dst, int16_t dct[16] ) ...@@ -205,15 +194,13 @@ static void add4x4_idct( uint8_t *p_dst, int16_t dct[16] )
{ {
int16_t d[16]; int16_t d[16];
int16_t tmp[16]; int16_t tmp[16];
int x, y;
int i;
for( i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
const int s02 = dct[0*4+i] + dct[2*4+i]; int s02 = dct[0*4+i] + dct[2*4+i];
const int d02 = dct[0*4+i] - dct[2*4+i]; int d02 = dct[0*4+i] - dct[2*4+i];
const int s13 = dct[1*4+i] + (dct[3*4+i]>>1); int s13 = dct[1*4+i] + (dct[3*4+i]>>1);
const int d13 = (dct[1*4+i]>>1) - dct[3*4+i]; int d13 = (dct[1*4+i]>>1) - dct[3*4+i];
tmp[i*4+0] = s02 + s13; tmp[i*4+0] = s02 + s13;
tmp[i*4+1] = d02 + d13; tmp[i*4+1] = d02 + d13;
...@@ -221,12 +208,12 @@ static void add4x4_idct( uint8_t *p_dst, int16_t dct[16] ) ...@@ -221,12 +208,12 @@ static void add4x4_idct( uint8_t *p_dst, int16_t dct[16] )
tmp[i*4+3] = s02 - s13; tmp[i*4+3] = s02 - s13;
} }
for( i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {
const int s02 = tmp[0*4+i] + tmp[2*4+i]; int s02 = tmp[0*4+i] + tmp[2*4+i];
const int d02 = tmp[0*4+i] - tmp[2*4+i]; int d02 = tmp[0*4+i] - tmp[2*4+i];
const int s13 = tmp[1*4+i] + (tmp[3*4+i]>>1); int s13 = tmp[1*4+i] + (tmp[3*4+i]>>1);
const int d13 = (tmp[1*4+i]>>1) - tmp[3*4+i]; int d13 = (tmp[1*4+i]>>1) - tmp[3*4+i];
d[0*4+i] = ( s02 + s13 + 32 ) >> 6; d[0*4+i] = ( s02 + s13 + 32 ) >> 6;
d[1*4+i] = ( d02 + d13 + 32 ) >> 6; d[1*4+i] = ( d02 + d13 + 32 ) >> 6;
...@@ -235,9 +222,9 @@ static void add4x4_idct( uint8_t *p_dst, int16_t dct[16] ) ...@@ -235,9 +222,9 @@ static void add4x4_idct( uint8_t *p_dst, int16_t dct[16] )
} }
for( y = 0; y < 4; y++ ) for( int y = 0; y < 4; y++ )
{ {
for( x = 0; x < 4; x++ ) for( int x = 0; x < 4; x++ )
p_dst[x] = x264_clip_uint8( p_dst[x] + d[y*4+x] ); p_dst[x] = x264_clip_uint8( p_dst[x] + d[y*4+x] );
p_dst += FDEC_STRIDE; p_dst += FDEC_STRIDE;
} }
...@@ -264,22 +251,22 @@ static void add16x16_idct( uint8_t *p_dst, int16_t dct[16][16] ) ...@@ -264,22 +251,22 @@ static void add16x16_idct( uint8_t *p_dst, int16_t dct[16][16] )
****************************************************************************/ ****************************************************************************/
#define DCT8_1D {\ #define DCT8_1D {\
const int s07 = SRC(0) + SRC(7);\ int s07 = SRC(0) + SRC(7);\
const int s16 = SRC(1) + SRC(6);\ int s16 = SRC(1) + SRC(6);\
const int s25 = SRC(2) + SRC(5);\ int s25 = SRC(2) + SRC(5);\
const int s34 = SRC(3) + SRC(4);\ int s34 = SRC(3) + SRC(4);\
const int a0 = s07 + s34;\ int a0 = s07 + s34;\
const int a1 = s16 + s25;\ int a1 = s16 + s25;\
const int a2 = s07 - s34;\ int a2 = s07 - s34;\
const int a3 = s16 - s25;\ int a3 = s16 - s25;\
const int d07 = SRC(0) - SRC(7);\ int d07 = SRC(0) - SRC(7);\
const int d16 = SRC(1) - SRC(6);\ int d16 = SRC(1) - SRC(6);\
const int d25 = SRC(2) - SRC(5);\ int d25 = SRC(2) - SRC(5);\
const int d34 = SRC(3) - SRC(4);\ int d34 = SRC(3) - SRC(4);\
const int a4 = d16 + d25 + (d07 + (d07>>1));\ int a4 = d16 + d25 + (d07 + (d07>>1));\
const int a5 = d07 - d34 - (d25 + (d25>>1));\ int a5 = d07 - d34 - (d25 + (d25>>1));\
const int a6 = d07 + d34 - (d16 + (d16>>1));\ int a6 = d07 + d34 - (d16 + (d16>>1));\
const int a7 = d16 - d25 + (d34 + (d34>>1));\ int a7 = d16 - d25 + (d34 + (d34>>1));\
DST(0) = a0 + a1 ;\ DST(0) = a0 + a1 ;\
DST(1) = a4 + (a7>>2);\ DST(1) = a4 + (a7>>2);\
DST(2) = a2 + (a3>>1);\ DST(2) = a2 + (a3>>1);\
...@@ -292,21 +279,20 @@ static void add16x16_idct( uint8_t *p_dst, int16_t dct[16][16] ) ...@@ -292,21 +279,20 @@ static void add16x16_idct( uint8_t *p_dst, int16_t dct[16][16] )
static void sub8x8_dct8( int16_t dct[64], uint8_t *pix1, uint8_t *pix2 ) static void sub8x8_dct8( int16_t dct[64], uint8_t *pix1, uint8_t *pix2 )
{ {
int i;
int16_t tmp[64]; int16_t tmp[64];
pixel_sub_wxh( tmp, 8, pix1, FENC_STRIDE, pix2, FDEC_STRIDE ); pixel_sub_wxh( tmp, 8, pix1, FENC_STRIDE, pix2, FDEC_STRIDE );
#define SRC(x) tmp[x*8+i] #define SRC(x) tmp[x*8+i]
#define DST(x) tmp[x*8+i] #define DST(x) tmp[x*8+i]
for( i = 0; i < 8; i++ ) for( int i = 0; i < 8; i++ )
DCT8_1D DCT8_1D
#undef SRC #undef SRC
#undef DST #undef DST
#define SRC(x) tmp[i*8+x] #define SRC(x) tmp[i*8+x]
#define DST(x) dct[x*8+i] #define DST(x) dct[x*8+i]
for( i = 0; i < 8; i++ ) for( int i = 0; i < 8; i++ )
DCT8_1D DCT8_1D
#undef SRC #undef SRC
#undef DST #undef DST
...@@ -321,22 +307,22 @@ static void sub16x16_dct8( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 ) ...@@ -321,22 +307,22 @@ static void sub16x16_dct8( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 )
} }
#define IDCT8_1D {\ #define IDCT8_1D {\
const int a0 = SRC(0) + SRC(4);\ int a0 = SRC(0) + SRC(4);\
const int a2 = SRC(0) - SRC(4);\ int a2 = SRC(0) - SRC(4);\
const int a4 = (SRC(2)>>1) - SRC(6);\ int a4 = (SRC(2)>>1) - SRC(6);\
const int a6 = (SRC(6)>>1) + SRC(2);\ int a6 = (SRC(6)>>1) + SRC(2);\
const int b0 = a0 + a6;\ int b0 = a0 + a6;\
const int b2 = a2 + a4;\ int b2 = a2 + a4;\
const int b4 = a2 - a4;\ int b4 = a2 - a4;\
const int b6 = a0 - a6;\ int b6 = a0 - a6;\
const int a1 = -SRC(3) + SRC(5) - SRC(7) - (SRC(7)>>1);\ int a1 = -SRC(3) + SRC(5) - SRC(7) - (SRC(7)>>1);\
const int a3 = SRC(1) + SRC(7) - SRC(3) - (SRC(3)>>1);\ int a3 = SRC(1) + SRC(7) - SRC(3) - (SRC(3)>>1);\
const int a5 = -SRC(1) + SRC(7) + SRC(5) + (SRC(5)>>1);\ int a5 = -SRC(1) + SRC(7) + SRC(5) + (SRC(5)>>1);\
const int a7 = SRC(3) + SRC(5) + SRC(1) + (SRC(1)>>1);\ int a7 = SRC(3) + SRC(5) + SRC(1) + (SRC(1)>>1);\
const int b1 = (a7>>2) + a1;\ int b1 = (a7>>2) + a1;\
const int b3 = a3 + (a5>>2);\ int b3 = a3 + (a5>>2);\
const int b5 = (a3>>2) - a5;\ int b5 = (a3>>2) - a5;\
const int b7 = a7 - (a1>>2);\ int b7 = a7 - (a1>>2);\
DST(0, b0 + b7);\ DST(0, b0 + b7);\
DST(1, b2 + b5);\ DST(1, b2 + b5);\
DST(2, b4 + b3);\ DST(2, b4 + b3);\
...@@ -349,20 +335,18 @@ static void sub16x16_dct8( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 ) ...@@ -349,20 +335,18 @@ static void sub16x16_dct8( int16_t dct[4][64], uint8_t *pix1, uint8_t *pix2 )
static void add8x8_idct8( uint8_t *dst, int16_t dct[64] ) static void add8x8_idct8( uint8_t *dst, int16_t dct[64] )
{ {
int i;
dct[0] += 32; // rounding for the >>6 at the end dct[0] += 32; // rounding for the >>6 at the end
#define SRC(x) dct[x*8+i] #define SRC(x) dct[x*8+i]
#define DST(x,rhs) dct[x*8+i] = (rhs) #define DST(x,rhs) dct[x*8+i] = (rhs)
for( i = 0; i < 8; i++ ) for( int i = 0; i < 8; i++ )
IDCT8_1D IDCT8_1D