Example #1
0
/* multiply two phpnums, potentially converting to a double. */
obj_t phpmul(obj_t a, obj_t b)
{
  long lval;
  double dval;
  unsigned char tx;

  if (ELONGP(a) && ELONGP(b)) {
    int use_dval;
    long alval = BELONG_TO_LONG(a);
    long blval = BELONG_TO_LONG(b);

    FAST_LONG_MULTIPLY(alval, blval, lval, dval, use_dval);

    if (use_dval) {
      return DOUBLE_TO_REAL(dval);
    } 
    else {
      return LONG_TO_ONUM(lval);
    }
  }

  else if (REALP(a) && REALP(b)) {
    dval = REAL_TO_DOUBLE(a) * REAL_TO_DOUBLE(b);
    return DOUBLE_TO_REAL(dval);
  } 
  else if (REALP (a) && ELONGP(b)) {
    dval = REAL_TO_DOUBLE(a) * (double) BELONG_TO_LONG(b);
    return DOUBLE_TO_REAL(dval);
  }
  else if (ELONGP(a) && REALP(b)) {
    dval = (double) BELONG_TO_LONG(a) * REAL_TO_DOUBLE(b);
    return DOUBLE_TO_REAL(dval);
  }
  phpnum_fail("jeepers creepers");
}
Example #2
0
void make_decode_tables(mpg123_handle *fr)
{
  int i,j;
  int idx = 0;
  scale_t scaleval = -(fr->lastscale < 0 ? fr->p.outscale : fr->lastscale);
  debug("MMX decode tables");
  for(i=0,j=0;i<256;i++,j++,idx+=32)
  {
    if(idx < 512+16)
      fr->decwin[idx+16] = fr->decwin[idx] = DOUBLE_TO_REAL((DOUBLE) intwinbase[j] / 65536.0 * (DOUBLE) scaleval);

    if(i % 32 == 31)
      idx -= 1023;
    if(i % 64 == 63)
      scaleval = - scaleval;
  }

  for( /* i=256 */ ;i<512;i++,j--,idx+=32)
  {
    if(idx < 512+16)
      fr->decwin[idx+16] = fr->decwin[idx] = DOUBLE_TO_REAL((DOUBLE) intwinbase[j] / 65536.0 * (DOUBLE) scaleval);

    if(i % 32 == 31)
      idx -= 1023;
    if(i % 64 == 63)
      scaleval = - scaleval;
  }
  debug("MMX decode tables done");
}
Example #3
0
/* divide two phpnums, potentially converting to a double. */
obj_t phpdiv(obj_t a, obj_t b)
{
  if ((ELONGP(b) && (BELONG_TO_LONG(b) == 0)) ||
      (REALP(b) && (REAL_TO_DOUBLE(b) == 0.0))) {
    phpnum_fail("Derision by zero");
  }
  if (ELONGP(a) && ELONGP(b)) {
    if (BELONG_TO_LONG(a) % BELONG_TO_LONG(b) == 0) { /* integer */
      long lval = BELONG_TO_LONG(a) / BELONG_TO_LONG(b);
/*       if (WITHIN_PDL_RANGE(lval)) { */
/* 	return GET_PDL(lval); */
/*       }  else { */
      return LONG_TO_ONUM(lval);
/*       } */
    } else {
      double dval = ((double) BELONG_TO_LONG (a)) / BELONG_TO_LONG(b);
      return DOUBLE_TO_REAL(dval);
    }
  }
  if ((REALP(a) && ELONGP(b)) || 
      (ELONGP(a) && REALP(b))) {
    double dval = (ELONGP(a) ?
		   (((double) BELONG_TO_LONG(a)) / REAL_TO_DOUBLE(b)) :
		   (REAL_TO_DOUBLE(a) / ((double) BELONG_TO_LONG(b))));
    return DOUBLE_TO_REAL(dval);
  }
  if (REALP(a) && REALP(b)) {
    double dval = REAL_TO_DOUBLE(a) / REAL_TO_DOUBLE(b);
    return DOUBLE_TO_REAL(dval);
  }
  phpnum_fail("no clue");
}
Example #4
0
/* subtract two phpnums, potentially converting to a double. */
obj_t phpsub(obj_t a, obj_t b)
{
    if (ELONGP(a) && ELONGP(b)) {
	long lval =  BELONG_TO_LONG(a) - BELONG_TO_LONG(b);
	/*     if (WITHIN_PDL_RANGE(dval)) { */
	/*       return GET_PDL(dval); */
	/*     } else  */
	if ( (BELONG_TO_LONG(a) & PHP_LONGMIN) != (BELONG_TO_LONG(b) & PHP_LONGMIN)
	     && (BELONG_TO_LONG(a) & PHP_LONGMIN) != (lval & PHP_LONGMIN) ) {
	    return DOUBLE_TO_REAL((double) BELONG_TO_LONG(a) - (double) BELONG_TO_LONG(b));
	} else {
	    return LONG_TO_ONUM(lval);
	}
    }
    if ((REALP(a) && ELONGP(b)) || 
	(ELONGP(a) && REALP(b))) {
	double dval = (REALP(a) ?
		       (REAL_TO_DOUBLE(a) - ((double) BELONG_TO_LONG (b))) :
		       ((double) BELONG_TO_LONG (a) - REAL_TO_DOUBLE(b)));
	return DOUBLE_TO_REAL(dval);
    }
    if (REALP(a) && REALP(b)) {
	double dval = REAL_TO_DOUBLE(a) - REAL_TO_DOUBLE(b);
	return DOUBLE_TO_REAL(dval);
    }
    phpnum_fail("phpsub: unknown operand types");
}
Example #5
0
/* add two phpnums, potentially converting to a double. */
obj_t phpadd(obj_t a, obj_t b) 
{

  if (ELONGP(a) && ELONGP(b)) {
    long lval = BELONG_TO_LONG( a ) + BELONG_TO_LONG( b );
/*     if (WITHIN_PDL_RANGE(dval)) { */
/*       return GET_PDL(dval); */
/*     } else  */
    if ( (BELONG_TO_LONG(a) & PHP_LONGMIN) == (BELONG_TO_LONG(b) & PHP_LONGMIN)
	 && (BELONG_TO_LONG(a) & PHP_LONGMIN) != (lval & PHP_LONGMIN) ) {
      return DOUBLE_TO_REAL( (double)BELONG_TO_LONG( a ) + (double)BELONG_TO_LONG( b ) );
    } else {
      return LONG_TO_ONUM( lval );
    }
  }

  if ((REALP(a) && ELONGP(b)) || (ELONGP(a) && REALP(b))) {
    double dval = (ELONGP(a) ?
		   (((double) BELONG_TO_LONG(a)) + REAL_TO_DOUBLE(b)) :
		   ((REAL_TO_DOUBLE(a) + ((double) BELONG_TO_LONG(b)))));
    return DOUBLE_TO_REAL(dval);
  }

  if (REALP(a) && REALP(b)) {
    double dval = REAL_TO_DOUBLE(a) + REAL_TO_DOUBLE(b);
    return DOUBLE_TO_REAL(dval);
  }
  phpnum_fail("I'm lost!");
}
Example #6
0
/* x86-64 doesn't use asm version */
void make_decode_tables_mmx(mpg123_handle *fr)
{
	int i,j,val;
	int idx = 0;
	short *ptr = (short *)fr->decwins;
	/* Scale is always based on 1.0 . */
	double scaleval = -0.5*(fr->lastscale < 0 ? fr->p.outscale : fr->lastscale);
	debug1("MMX decode tables with scaleval %g", scaleval);
	for(i=0,j=0;i<256;i++,j++,idx+=32)
	{
		if(idx < 512+16)
		fr->decwin_mmx[idx+16] = fr->decwin_mmx[idx] = DOUBLE_TO_REAL((double) intwinbase[j] * scaleval);
		
		if(i % 32 == 31)
		idx -= 1023;
		if(i % 64 == 63)
		scaleval = - scaleval;
	}
	
	for( /* i=256 */ ;i<512;i++,j--,idx+=32)
	{
		if(idx < 512+16)
		fr->decwin_mmx[idx+16] = fr->decwin_mmx[idx] = DOUBLE_TO_REAL((double) intwinbase[j] * scaleval);
		
		if(i % 32 == 31)
		idx -= 1023;
		if(i % 64 == 63)
		scaleval = - scaleval;
	}
	
	for(i=0; i<512; i++) {
		if(i&1) val = rounded(fr->decwin_mmx[i]*0.5);
		else val = rounded(fr->decwin_mmx[i]*-0.5);
		if(val > 32767) val = 32767;
		else if(val < -32768) val = -32768;
		ptr[i] = val;
	}
	for(i=512; i<512+32; i++) {
		if(i&1) val = rounded(fr->decwin_mmx[i]*0.5);
		else val = 0;
		if(val > 32767) val = 32767;
		else if(val < -32768) val = -32768;
		ptr[i] = val;
	}
	for(i=0; i<512; i++) {
		val = rounded(fr->decwin_mmx[511-i]*-0.5);
		if(val > 32767) val = 32767;
		else if(val < -32768) val = -32768;
		ptr[512+32+i] = val;
	}
	debug("decode tables done");
}
real* init_layer12_table_mmx(mpg123_handle *fr, real *table, double m)
{
	int i,j;
	if(!fr->p.down_sample) 
	{
		for(j=3,i=0;i<63;i++,j--)
			*table++ = DOUBLE_TO_REAL(16384 * m * pow(2.0,(double) j / 3.0));
	}
	else
	{
		for(j=3,i=0;i<63;i++,j--)
		*table++ = DOUBLE_TO_REAL(m * pow(2.0,(double) j / 3.0));
	}
	return table;
}
Example #8
0
int attribute_align_arg mpg123_eq(mpg123_handle *mh, enum mpg123_channels channel, int band, double val)
{
	if(mh == NULL) return MPG123_ERR;
	if(band < 0 || band > 31){ mh->err = MPG123_BAD_BAND; return MPG123_ERR; }
	switch(channel)
	{
		case MPG123_LEFT|MPG123_RIGHT:
			mh->equalizer[0][band] = mh->equalizer[1][band] = DOUBLE_TO_REAL(val);
		break;
		case MPG123_LEFT:  mh->equalizer[0][band] = DOUBLE_TO_REAL(val); break;
		case MPG123_RIGHT: mh->equalizer[1][band] = DOUBLE_TO_REAL(val); break;
		default:
			mh->err=MPG123_BAD_CHANNEL;
			return MPG123_ERR;
	}
	mh->have_eq_settings = TRUE;
	return MPG123_OK;
}
Example #9
0
/*---------------------------------------------------------------------*/
void bgl_init_objects() {
   bgl_init_dynamic_env();
   bgl_init_trace();
   bgl_init_symbol_table();
   bgl_init_signal();
   bgl_init_io();
   bgl_init_keyword_table();
   bgl_init_process_table();
   bgl_init_dload();
   bgl_init_socket();
   bgl_init_date();
   bgl_init_bignum();

   bigloo_mutex = bgl_make_spinlock( bigloo_mutex_name );
   bigloo_generic_mutex = bgl_make_spinlock( bigloo_mutex_name );
   quote = string_to_symbol( "QUOTE" );

   bigloo_nan = DOUBLE_TO_REAL( bgl_nan() );
   bigloo_infinity = DOUBLE_TO_REAL( bgl_infinity() );
   bigloo_minfinity = DOUBLE_TO_REAL( -bgl_infinity() );
   
}
Example #10
0
void prepare_decode_tables()
{
  int i,k,kr,divv;
  real *costab;

  for(i=0;i<5;i++)
  {
    kr=0x10>>i; divv=0x40>>i;
    costab = pnts[i];
    for(k=0;k<kr;k++)
      costab[k] = DOUBLE_TO_REAL(1.0 / (2.0 * cos(M_PI * ((DOUBLE) k * 2.0 + 1.0) / (DOUBLE) divv)));
  }
}
Example #11
0
void prepare_decode_tables()
{
#if !defined(REAL_IS_FIXED) || !defined(PRECALC_TABLES)
  int i,k,kr,divv;
  real *costab;

  for(i=0;i<5;i++)
  {
    kr=0x10>>i; divv=0x40>>i;
    costab = pnts[i];
    for(k=0;k<kr;k++)
      costab[k] = DOUBLE_TO_REAL(1.0 / (2.0 * cos(M_PI * ((double) k * 2.0 + 1.0) / (double) divv)));
  }
#endif
}
Example #12
0
obj_t string_to_float_phpnum(char *str) {
  double dval;
  int scanfretval = sscanf(str, "%lf", &dval); 
  // zend_strtod can easily be grabbed and stuck in this dir if float
  // reading problems ever show up.  (it's not their code anyway).
  // just rename the one function to string-to-double, add the file to
  // the Makefile, and uncomment this line (and comment the rest of
  // this function).
  //  dval = string_to_double(str, NULL);
  if (!scanfretval || scanfretval == EOF) {
    phpnum_fail("Failed to read a float.");
  } else {
    return DOUBLE_TO_REAL(dval);
  }
}
Example #13
0
/* init tables for layer-3 ... specific with the downsampling... */
void init_layer3(void)
{
	int i,j,k,l;

#if !defined(REAL_IS_FIXED) || !defined(PRECALC_TABLES)
	for(i=0;i<8207;i++)
	ispow[i] = DOUBLE_TO_REAL_POW43(pow((double)i,(double)4.0/3.0));

	for(i=0;i<8;i++)
	{
		const double Ci[8] = {-0.6,-0.535,-0.33,-0.185,-0.095,-0.041,-0.0142,-0.0037};
		double sq = sqrt(1.0+Ci[i]*Ci[i]);
		aa_cs[i] = DOUBLE_TO_REAL(1.0/sq);
		aa_ca[i] = DOUBLE_TO_REAL(Ci[i]/sq);
	}

	for(i=0;i<18;i++)
	{
		win[0][i]    = win[1][i]    =
			DOUBLE_TO_REAL( 0.5*sin(M_PI/72.0 * (double)(2*(i+0) +1)) / cos(M_PI * (double)(2*(i+0) +19) / 72.0) );
		win[0][i+18] = win[3][i+18] =
			DOUBLE_TO_REAL( 0.5*sin(M_PI/72.0 * (double)(2*(i+18)+1)) / cos(M_PI * (double)(2*(i+18)+19) / 72.0) );
	}
	for(i=0;i<6;i++)
	{
		win[1][i+18] = DOUBLE_TO_REAL(0.5 / cos ( M_PI * (double) (2*(i+18)+19) / 72.0 ));
		win[3][i+12] = DOUBLE_TO_REAL(0.5 / cos ( M_PI * (double) (2*(i+12)+19) / 72.0 ));
		win[1][i+24] = DOUBLE_TO_REAL(0.5 * sin( M_PI / 24.0 * (double) (2*i+13) ) / cos ( M_PI * (double) (2*(i+24)+19) / 72.0 ));
		win[1][i+30] = win[3][i] = DOUBLE_TO_REAL(0.0);
		win[3][i+6 ] = DOUBLE_TO_REAL(0.5 * sin( M_PI / 24.0 * (double) (2*i+1 ) ) / cos ( M_PI * (double) (2*(i+6 )+19) / 72.0 ));
	}

	for(i=0;i<9;i++)
	COS9[i] = DOUBLE_TO_REAL(cos( M_PI / 18.0 * (double) i));

	for(i=0;i<9;i++)
	tfcos36[i] = DOUBLE_TO_REAL(0.5 / cos ( M_PI * (double) (i*2+1) / 36.0 ));

	for(i=0;i<3;i++)
	tfcos12[i] = DOUBLE_TO_REAL(0.5 / cos ( M_PI * (double) (i*2+1) / 12.0 ));

	COS6_1 = DOUBLE_TO_REAL(cos( M_PI / 6.0 * (double) 1));
	COS6_2 = DOUBLE_TO_REAL(cos( M_PI / 6.0 * (double) 2));

#ifdef NEW_DCT9
	cos9[0]  = DOUBLE_TO_REAL(cos(1.0*M_PI/9.0));
	cos9[1]  = DOUBLE_TO_REAL(cos(5.0*M_PI/9.0));
	cos9[2]  = DOUBLE_TO_REAL(cos(7.0*M_PI/9.0));
	cos18[0] = DOUBLE_TO_REAL(cos(1.0*M_PI/18.0));
	cos18[1] = DOUBLE_TO_REAL(cos(11.0*M_PI/18.0));
	cos18[2] = DOUBLE_TO_REAL(cos(13.0*M_PI/18.0));
#endif

	for(i=0;i<12;i++)
	{
		win[2][i] = DOUBLE_TO_REAL(0.5 * sin( M_PI / 24.0 * (double) (2*i+1) ) / cos ( M_PI * (double) (2*i+7) / 24.0 ));
	}

	for(i=0;i<16;i++)
	{
		double t = tan( (double) i * M_PI / 12.0 );
		tan1_1[i] = DOUBLE_TO_REAL_15(t / (1.0+t));
		tan2_1[i] = DOUBLE_TO_REAL_15(1.0 / (1.0 + t));
		tan1_2[i] = DOUBLE_TO_REAL_15(M_SQRT2 * t / (1.0+t));
		tan2_2[i] = DOUBLE_TO_REAL_15(M_SQRT2 / (1.0 + t));

		for(j=0;j<2;j++)
		{
			double base = pow(2.0,-0.25*(j+1.0));
			double p1=1.0,p2=1.0;
			if(i > 0)
			{
				if( i & 1 ) p1 = pow(base,(i+1.0)*0.5);
				else p2 = pow(base,i*0.5);
			}
			pow1_1[j][i] = DOUBLE_TO_REAL_15(p1);
			pow2_1[j][i] = DOUBLE_TO_REAL_15(p2);
			pow1_2[j][i] = DOUBLE_TO_REAL_15(M_SQRT2 * p1);
			pow2_2[j][i] = DOUBLE_TO_REAL_15(M_SQRT2 * p2);
		}
	}
#endif

	for(j=0;j<4;j++)
	{
		const int len[4] = { 36,36,12,36 };
		for(i=0;i<len[j];i+=2) win1[j][i] = + win[j][i];

		for(i=1;i<len[j];i+=2) win1[j][i] = - win[j][i];
	}

	for(j=0;j<9;j++)
	{
		const struct bandInfoStruct *bi = &bandInfo[j];
		int *mp;
		int cb,lwin;
		const int *bdf;

		mp = map[j][0] = mapbuf0[j];
		bdf = bi->longDiff;
		for(i=0,cb = 0; cb < 8 ; cb++,i+=*bdf++)
		{
			*mp++ = (*bdf) >> 1;
			*mp++ = i;
			*mp++ = 3;
			*mp++ = cb;
		}
		bdf = bi->shortDiff+3;
		for(cb=3;cb<13;cb++)
		{
			int l = (*bdf++) >> 1;
			for(lwin=0;lwin<3;lwin++)
			{
				*mp++ = l;
				*mp++ = i + lwin;
				*mp++ = lwin;
				*mp++ = cb;
			}
			i += 6*l;
		}
		mapend[j][0] = mp;

		mp = map[j][1] = mapbuf1[j];
		bdf = bi->shortDiff+0;
		for(i=0,cb=0;cb<13;cb++)
		{
			int l = (*bdf++) >> 1;
			for(lwin=0;lwin<3;lwin++)
			{
				*mp++ = l;
				*mp++ = i + lwin;
				*mp++ = lwin;
				*mp++ = cb;
			}
			i += 6*l;
		}
		mapend[j][1] = mp;

		mp = map[j][2] = mapbuf2[j];
		bdf = bi->longDiff;
		for(cb = 0; cb < 22 ; cb++)
		{
			*mp++ = (*bdf++) >> 1;
			*mp++ = cb;
		}
		mapend[j][2] = mp;
	}

	/* Now for some serious loopings! */
	for(i=0;i<5;i++)
	for(j=0;j<6;j++)
	for(k=0;k<6;k++)
	{
		int n = k + j * 6 + i * 36;
		i_slen2[n] = i|(j<<3)|(k<<6)|(3<<12);
	}
	for(i=0;i<4;i++)
	for(j=0;j<4;j++)
	for(k=0;k<4;k++)
	{
		int n = k + j * 4 + i * 16;
		i_slen2[n+180] = i|(j<<3)|(k<<6)|(4<<12);
	}
	for(i=0;i<4;i++)
	for(j=0;j<3;j++)
	{
		int n = j + i * 3;
		i_slen2[n+244] = i|(j<<3) | (5<<12);
		n_slen2[n+500] = i|(j<<3) | (2<<12) | (1<<15);
	}
	for(i=0;i<5;i++)
	for(j=0;j<5;j++)
	for(k=0;k<4;k++)
	for(l=0;l<4;l++)
	{
		int n = l + k * 4 + j * 16 + i * 80;
		n_slen2[n] = i|(j<<3)|(k<<6)|(l<<9)|(0<<12);
	}
	for(i=0;i<5;i++)
	for(j=0;j<5;j++)
	for(k=0;k<4;k++)
	{
		int n = k + j * 4 + i * 20;
		n_slen2[n+400] = i|(j<<3)|(k<<6)|(1<<12);
	}
}
Example #14
0
real init_layer3_gainpow2_mmx(mpg123_handle *fr, int i)
{
	if(!fr->p.down_sample) return DOUBLE_TO_REAL(16384.0 * pow((double)2.0,-0.25 * (double) (i+210) ));
	else return DOUBLE_TO_REAL(pow((double)2.0,-0.25 * (double) (i+210)));
}
Example #15
0
static void I_step_two(real fraction[2][SBLIMIT],unsigned int balloc[2*SBLIMIT], unsigned int scale_index[2][SBLIMIT],mpg123_handle *fr)
{
	int i,n;
	int smpb[2*SBLIMIT]; /* values: 0-65535 */
	int *sample;
	register unsigned int *ba;
	register unsigned int *sca = (unsigned int *) scale_index;

	if(fr->stereo == 2)
	{
		int jsbound = fr->jsbound;
		register real *f0 = fraction[0];
		register real *f1 = fraction[1];
		ba = balloc;
		for(sample=smpb,i=0;i<jsbound;i++)
		{
			if((n = *ba++)) *sample++ = getbits(fr, n+1);

			if((n = *ba++)) *sample++ = getbits(fr, n+1);
		}
		for(i=jsbound;i<SBLIMIT;i++) 
		if((n = *ba++))
		*sample++ = getbits(fr, n+1);

		ba = balloc;
		for(sample=smpb,i=0;i<jsbound;i++)
		{
			if((n=*ba++))
			*f0++ = REAL_MUL_SCALE_LAYER12(DOUBLE_TO_REAL_15( ((-1)<<n) + (*sample++) + 1), fr->muls[n+1][*sca++]);
			else *f0++ = DOUBLE_TO_REAL(0.0);

			if((n=*ba++))
			*f1++ = REAL_MUL_SCALE_LAYER12(DOUBLE_TO_REAL_15( ((-1)<<n) + (*sample++) + 1), fr->muls[n+1][*sca++]);
			else *f1++ = DOUBLE_TO_REAL(0.0);
		}
		for(i=jsbound;i<SBLIMIT;i++)
		{
			if((n=*ba++))
			{
				real samp = DOUBLE_TO_REAL_15( ((-1)<<n) + (*sample++) + 1);
				*f0++ = REAL_MUL_SCALE_LAYER12(samp, fr->muls[n+1][*sca++]);
				*f1++ = REAL_MUL_SCALE_LAYER12(samp, fr->muls[n+1][*sca++]);
			}
			else *f0++ = *f1++ = DOUBLE_TO_REAL(0.0);
		}
		for(i=fr->down_sample_sblimit;i<32;i++)
		fraction[0][i] = fraction[1][i] = 0.0;
	}
	else
	{
		register real *f0 = fraction[0];
		ba = balloc;
		for(sample=smpb,i=0;i<SBLIMIT;i++)
		if ((n = *ba++))
		*sample++ = getbits(fr, n+1);

		ba = balloc;
		for(sample=smpb,i=0;i<SBLIMIT;i++)
		{
			if((n=*ba++))
			*f0++ = REAL_MUL_SCALE_LAYER12(DOUBLE_TO_REAL_15( ((-1)<<n) + (*sample++) + 1), fr->muls[n+1][*sca++]);
			else *f0++ = DOUBLE_TO_REAL(0.0);
		}
		for(i=fr->down_sample_sblimit;i<32;i++)
		fraction[0][i] = DOUBLE_TO_REAL(0.0);
	}
}
Example #16
0
void make_decode_tables(mpg123_handle *fr)
{
	int i,j;
	int idx = 0;
	/* Scale is always based on 1.0 . */
	double scaleval = -0.5*(fr->lastscale < 0 ? fr->p.outscale : fr->lastscale);
	debug1("decode tables with scaleval %g", scaleval);
#ifdef REAL_IS_FIXED
	long scaleval_long = DOUBLE_TO_REAL_15(scaleval);
#endif
	for(i=0,j=0;i<256;i++,j++,idx+=32)
	{
		if(idx < 512+16)
#ifdef REAL_IS_FIXED
		fr->decwin[idx+16] = fr->decwin[idx] = REAL_SCALE_WINDOW(intwinbase[j] * scaleval_long);
#else
		fr->decwin[idx+16] = fr->decwin[idx] = DOUBLE_TO_REAL((double) intwinbase[j] * scaleval);
#endif

		if(i % 32 == 31)
		idx -= 1023;
		if(i % 64 == 63)
#ifdef REAL_IS_FIXED
		scaleval_long = - scaleval_long;
#else
		scaleval = - scaleval;
#endif
	}

	for( /* i=256 */ ;i<512;i++,j--,idx+=32)
	{
		if(idx < 512+16)
#ifdef REAL_IS_FIXED
		fr->decwin[idx+16] = fr->decwin[idx] = REAL_SCALE_WINDOW(intwinbase[j] * scaleval_long);
#else
		fr->decwin[idx+16] = fr->decwin[idx] = DOUBLE_TO_REAL((double) intwinbase[j] * scaleval);
#endif

		if(i % 32 == 31)
		idx -= 1023;
		if(i % 64 == 63)
#ifdef REAL_IS_FIXED
		scaleval_long = - scaleval_long;
#else
		scaleval = - scaleval;
#endif
	}
#if defined(OPT_X86_64) || defined(OPT_ALTIVEC) || defined(OPT_SSE) || defined(OPT_ARM) || defined(OPT_NEON) || defined(OPT_AVX)
	if(fr->cpu_opts.type == x86_64 || fr->cpu_opts.type == altivec || fr->cpu_opts.type == sse || fr->cpu_opts.type == arm || fr->cpu_opts.type == neon || fr->cpu_opts.type == avx)
	{ /* for float SSE / AltiVec / ARM decoder */
		for(i=512; i<512+32; i++)
		{
			fr->decwin[i] = (i&1) ? fr->decwin[i] : 0;
		}
		for(i=0; i<512; i++)
		{
			fr->decwin[512+32+i] = -fr->decwin[511-i];
		}
#ifdef OPT_NEON
		if(fr->cpu_opts.type == neon)
		{
			for(i=0; i<512; i+=2)
			{
				fr->decwin[i] = -fr->decwin[i];
			}
		}
#endif
	}
#endif
	debug("decode tables done");
}
void II_step_two(unsigned int *bit_alloc,real fraction[2][4][SBLIMIT],int *scale,mpg123_handle *fr,int x1)
{
	int i,j,k,ba;
	int stereo = fr->stereo;
	int sblimit = fr->II_sblimit;
	int jsbound = fr->jsbound;
	const struct al_table *alloc2,*alloc1 = fr->alloc;
	unsigned int *bita=bit_alloc;
	int d1,step;

	for(i=0;i<jsbound;i++,alloc1+=(1<<step))
	{
		step = alloc1->bits;
		for(j=0;j<stereo;j++)
		{
			if( (ba=*bita++) ) 
			{
				k=(alloc2 = alloc1+ba)->bits;
				if( (d1=alloc2->d) < 0) 
				{
					real cm=fr->muls[k][scale[x1]];
					fraction[j][0][i] = REAL_MUL_SCALE_LAYER12(DOUBLE_TO_REAL_15((int)getbits(fr, k) + d1), cm);
					fraction[j][1][i] = REAL_MUL_SCALE_LAYER12(DOUBLE_TO_REAL_15((int)getbits(fr, k) + d1), cm);
					fraction[j][2][i] = REAL_MUL_SCALE_LAYER12(DOUBLE_TO_REAL_15((int)getbits(fr, k) + d1), cm);
				}        
				else 
				{
					const int *table[] = { 0,0,0,grp_3tab,0,grp_5tab,0,0,0,grp_9tab };
					unsigned int idx,*tab,m=scale[x1];
					idx = (unsigned int) getbits(fr, k);
					tab = (unsigned int *) (table[d1] + idx + idx + idx);
					fraction[j][0][i] = REAL_SCALE_LAYER12(fr->muls[*tab++][m]);
					fraction[j][1][i] = REAL_SCALE_LAYER12(fr->muls[*tab++][m]);
					fraction[j][2][i] = REAL_SCALE_LAYER12(fr->muls[*tab][m]);  
				}
				scale+=3;
			}
			else
			fraction[j][0][i] = fraction[j][1][i] = fraction[j][2][i] = DOUBLE_TO_REAL(0.0);
		}
	}

	for(i=jsbound;i<sblimit;i++,alloc1+=(1<<step))
	{
		step = alloc1->bits;
		bita++;	/* channel 1 and channel 2 bitalloc are the same */
		if( (ba=*bita++) )
		{
			k=(alloc2 = alloc1+ba)->bits;
			if( (d1=alloc2->d) < 0)
			{
				real cm;
				cm=fr->muls[k][scale[x1+3]];
				fraction[0][0][i] = DOUBLE_TO_REAL_15((int)getbits(fr, k) + d1);
				fraction[0][1][i] = DOUBLE_TO_REAL_15((int)getbits(fr, k) + d1);
				fraction[0][2][i] = DOUBLE_TO_REAL_15((int)getbits(fr, k) + d1);
				fraction[1][0][i] = REAL_MUL_SCALE_LAYER12(fraction[0][0][i], cm);
				fraction[1][1][i] = REAL_MUL_SCALE_LAYER12(fraction[0][1][i], cm);
				fraction[1][2][i] = REAL_MUL_SCALE_LAYER12(fraction[0][2][i], cm);
				cm=fr->muls[k][scale[x1]];
				fraction[0][0][i] = REAL_MUL_SCALE_LAYER12(fraction[0][0][i], cm);
				fraction[0][1][i] = REAL_MUL_SCALE_LAYER12(fraction[0][1][i], cm);
				fraction[0][2][i] = REAL_MUL_SCALE_LAYER12(fraction[0][2][i], cm);
			}
			else
			{
				const int *table[] = { 0,0,0,grp_3tab,0,grp_5tab,0,0,0,grp_9tab };
				unsigned int idx,*tab,m1,m2;
				m1 = scale[x1]; m2 = scale[x1+3];
				idx = (unsigned int) getbits(fr, k);
				tab = (unsigned int *) (table[d1] + idx + idx + idx);
				fraction[0][0][i] = REAL_SCALE_LAYER12(fr->muls[*tab][m1]); fraction[1][0][i] = REAL_SCALE_LAYER12(fr->muls[*tab++][m2]);
				fraction[0][1][i] = REAL_SCALE_LAYER12(fr->muls[*tab][m1]); fraction[1][1][i] = REAL_SCALE_LAYER12(fr->muls[*tab++][m2]);
				fraction[0][2][i] = REAL_SCALE_LAYER12(fr->muls[*tab][m1]); fraction[1][2][i] = REAL_SCALE_LAYER12(fr->muls[*tab][m2]);
			}
			scale+=6;
		}
		else
		{
			fraction[0][0][i] = fraction[0][1][i] = fraction[0][2][i] =
			fraction[1][0][i] = fraction[1][1][i] = fraction[1][2][i] = DOUBLE_TO_REAL(0.0);
		}
/*
	Historic comment...
	should we use individual scalefac for channel 2 or
	is the current way the right one , where we just copy channel 1 to
	channel 2 ?? 
	The current 'strange' thing is, that we throw away the scalefac
	values for the second channel ...!!
	-> changed .. now we use the scalefac values of channel one !! 
*/
	}

	if(sblimit > (fr->down_sample_sblimit) )
	sblimit = fr->down_sample_sblimit;

	for(i=sblimit;i<SBLIMIT;i++)
	for (j=0;j<stereo;j++)
	fraction[j][0][i] = fraction[j][1][i] = fraction[j][2][i] = DOUBLE_TO_REAL(0.0);
}