예제 #1
0
파일: ibCmd.c 프로젝트: 9072997/wikireader
unsigned int create_send_setup( const ibBoard_t *board,
	const Addr4882_t addressList[], uint8_t *cmdString )
{
	unsigned int i, j;
	unsigned int board_pad;
	int board_sad;

	if( addressList == NULL )
	{
		fprintf(stderr, "libgpib: bug! addressList NULL in create_send_setup()\n");
		return 0;
	}
	if( addressListIsValid( addressList ) == 0 )
	{
		fprintf(stderr, "libgpib: bug! bad address list\n");
		return 0;
	}

	i = 0;
	/* controller's talk address */
	if(query_pad(board, &board_pad) < 0) return 0;
	cmdString[i++] = MTA(board_pad);
	if(query_sad(board, &board_sad) < 0) return 0;
	if(board_sad >= 0 )
		cmdString[i++] = MSA(board_sad);
	cmdString[ i++ ] = UNL;
	for( j = 0; j < numAddresses( addressList ); j++ )
	{
		unsigned int pad;
		int sad;

		pad = extractPAD( addressList[ j ] );
		sad = extractSAD( addressList[ j ] );
		cmdString[ i++ ] = MLA( pad );
		if( sad >= 0)
			cmdString[ i++ ] = MSA( sad );
	}

	return i;
}
예제 #2
0
void GGLAssembler::mul_factor_add(  component_t& d,
                                    const integer_t& v,
                                    const integer_t& f,
                                    const component_t& a)
{
    // XXX: we could have special cases for 1 bit mul
    Scratch scratches(registerFile());

    int vs = v.size();
    int fs = f.size();
    int as = a.h;
    int ms = vs+fs;

    ALOGE_IF(ms>=32, "mul_factor_add overflow vs=%d, fs=%d, as=%d", vs, fs, as);

    integer_t add(a.reg, a.h, a.flags);

    // 'a' is a component_t but it is guaranteed to have
    // its high bits set to 0. However in the dithering case,
    // we can't get away with truncating the potentially bad bits
    // so extraction is needed.

   if ((mDithering) && (a.size() < ms)) {
        // we need to expand a
        if (!(a.flags & CORRUPTIBLE)) {
            // ... but it's not corruptible, so we need to pick a
            // temporary register.
            // Try to uses the destination register first (it's likely
            // to be usable, unless it aliases an input).
            if (d.reg!=a.reg && d.reg!=v.reg && d.reg!=f.reg) {
                add.reg = d.reg;
            } else {
                add.reg = scratches.obtain();
            }
        }
        expand(add, a, ms); // extracts and expands
        as = ms;
    }

    if (ms == as) {
        if (vs<16 && fs<16) SMLABB(AL, d.reg, v.reg, f.reg, add.reg);
        else                MLA(AL, 0, d.reg, v.reg, f.reg, add.reg);
    } else {
        int temp = d.reg;
        if (temp == add.reg) {
            // the mul will modify add.reg, we need an intermediary reg
            if (v.flags & CORRUPTIBLE)      temp = v.reg;
            else if (f.flags & CORRUPTIBLE) temp = f.reg;
            else                            temp = scratches.obtain();
        }

        if (vs<16 && fs<16) SMULBB(AL, temp, v.reg, f.reg);
        else                MUL(AL, 0, temp, v.reg, f.reg);

        if (ms>as) {
            ADD(AL, 0, d.reg, temp, reg_imm(add.reg, LSL, ms-as));
        } else if (ms<as) {
            // not sure if we should expand the mul instead?
            ADD(AL, 0, d.reg, temp, reg_imm(add.reg, LSR, as-ms));
        }
    }

    d.h = ms;
    if (mDithering) {
        d.l = a.l; 
    } else {
        d.l = fs>a.l ? fs : a.l;
        d.flags |= CLEAR_LO;
    }
}
예제 #3
0
파일: synth.c 프로젝트: dnwang/android_demo
/*
 * NAME:	synth->half()
 * DESCRIPTION:	perform half frequency PCM synthesis
 */
static
void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
                unsigned int nch, unsigned int ns) {
    unsigned int phase, ch, s, sb, pe, po;
    mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8];
    mad_fixed_t const (*sbsample)[36][32];
    register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
    register mad_fixed_t const (*Dptr)[32], *ptr;
    register mad_fixed64hi_t hi;
    register mad_fixed64lo_t lo;

    for (ch = 0; ch < nch; ++ch) {
        sbsample = &frame->sbsample[ch];
        filter = &synth->filter[ch];
        phase = synth->phase;
        pcm1 = synth->pcm.samples[ch];

        for (s = 0; s < ns; ++s) {
            dct32((*sbsample)[s], phase >> 1,
                  (*filter)[0][phase & 1], (*filter)[1][phase & 1]);

            pe = phase & ~1;
            po = ((phase - 1) & 0xf) | 1;

            /* calculate 16 samples */

            fe = &(*filter)[0][phase & 1][0];
            fx = &(*filter)[0][~phase & 1][0];
            fo = &(*filter)[1][~phase & 1][0];

            Dptr = &D[0];

            ptr = *Dptr + po;
            ML0(hi, lo, (*fx)[0], ptr[0]);
            MLA(hi, lo, (*fx)[1], ptr[14]);
            MLA(hi, lo, (*fx)[2], ptr[12]);
            MLA(hi, lo, (*fx)[3], ptr[10]);
            MLA(hi, lo, (*fx)[4], ptr[8]);
            MLA(hi, lo, (*fx)[5], ptr[6]);
            MLA(hi, lo, (*fx)[6], ptr[4]);
            MLA(hi, lo, (*fx)[7], ptr[2]);
            MLN(hi, lo);

            ptr = *Dptr + pe;
            MLA(hi, lo, (*fe)[0], ptr[0]);
            MLA(hi, lo, (*fe)[1], ptr[14]);
            MLA(hi, lo, (*fe)[2], ptr[12]);
            MLA(hi, lo, (*fe)[3], ptr[10]);
            MLA(hi, lo, (*fe)[4], ptr[8]);
            MLA(hi, lo, (*fe)[5], ptr[6]);
            MLA(hi, lo, (*fe)[6], ptr[4]);
            MLA(hi, lo, (*fe)[7], ptr[2]);

            *pcm1++ = SHIFT(MLZ(hi, lo));

            pcm2 = pcm1 + 14;

            for (sb = 1; sb < 16; ++sb) {
                ++fe;
                ++Dptr;

                /* D[32 - sb][i] == -D[sb][31 - i] */

                if (!(sb & 1)) {
                    ptr = *Dptr + po;
                    ML0(hi, lo, (*fo)[0], ptr[0]);
                    MLA(hi, lo, (*fo)[1], ptr[14]);
                    MLA(hi, lo, (*fo)[2], ptr[12]);
                    MLA(hi, lo, (*fo)[3], ptr[10]);
                    MLA(hi, lo, (*fo)[4], ptr[8]);
                    MLA(hi, lo, (*fo)[5], ptr[6]);
                    MLA(hi, lo, (*fo)[6], ptr[4]);
                    MLA(hi, lo, (*fo)[7], ptr[2]);
                    MLN(hi, lo);

                    ptr = *Dptr + pe;
                    MLA(hi, lo, (*fe)[7], ptr[2]);
                    MLA(hi, lo, (*fe)[6], ptr[4]);
                    MLA(hi, lo, (*fe)[5], ptr[6]);
                    MLA(hi, lo, (*fe)[4], ptr[8]);
                    MLA(hi, lo, (*fe)[3], ptr[10]);
                    MLA(hi, lo, (*fe)[2], ptr[12]);
                    MLA(hi, lo, (*fe)[1], ptr[14]);
                    MLA(hi, lo, (*fe)[0], ptr[0]);

                    *pcm1++ = SHIFT(MLZ(hi, lo));

                    ptr = *Dptr - po;
                    ML0(hi, lo, (*fo)[7], ptr[31 - 2]);
                    MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
                    MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
                    MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
                    MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
                    MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
                    MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
                    MLA(hi, lo, (*fo)[0], ptr[31 - 16]);

                    ptr = *Dptr - pe;
                    MLA(hi, lo, (*fe)[0], ptr[31 - 16]);
                    MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
                    MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
                    MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
                    MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
                    MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
                    MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
                    MLA(hi, lo, (*fe)[7], ptr[31 - 2]);

                    *pcm2-- = SHIFT(MLZ(hi, lo));
                }

                ++fo;
            }

            ++Dptr;

            ptr = *Dptr + po;
            ML0(hi, lo, (*fo)[0], ptr[0]);
            MLA(hi, lo, (*fo)[1], ptr[14]);
            MLA(hi, lo, (*fo)[2], ptr[12]);
            MLA(hi, lo, (*fo)[3], ptr[10]);
            MLA(hi, lo, (*fo)[4], ptr[8]);
            MLA(hi, lo, (*fo)[5], ptr[6]);
            MLA(hi, lo, (*fo)[6], ptr[4]);
            MLA(hi, lo, (*fo)[7], ptr[2]);

            *pcm1 = SHIFT(-MLZ(hi, lo));
            pcm1 += 8;

            phase = (phase + 1) % 16;
        }
    }
}
예제 #4
0
/*
 * NAME:	synth->half()
 * DESCRIPTION:	perform half frequency PCM synthesis
 */
static
void synth_half(struct mad_synth *synth, struct mad_frame /*const*/ *frame,
		unsigned int nch, unsigned int ns)
{
  unsigned int phase, ch, s, sb, pe, po;
  short int *pcm1, *pcm2;
  mad_fixed_t (*filter)[2][2][16][8];
  mad_fixed_t (*sbsample)[36][32];
  register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
  register mad_fixed_t const (*Dptr)[32], *ptr ;
  register mad_fixed64hi_t hi;
  register mad_fixed64lo_t lo;
  mad_fixed_t raw_sample;
  
  static short int short_sample_buff[16];

  phase = synth->phase;

  for (s = 0; s < ns; ++s)
  {
    memset (short_sample_buff, 0x00, sizeof(short_sample_buff));

    for (ch = 0; ch < nch; ++ch)
    {
      sbsample = &frame->sbsample[ch];
      filter   = &synth->filter[ch];      
      pcm1     = short_sample_buff;

      dct32((*sbsample)[s], phase >> 1,
	    (*filter)[0][phase & 1], (*filter)[1][phase & 1]);

      pe = phase & ~1;
      po = ((phase - 1) & 0xf) | 1;

      /* calculate 16 samples */

      fe = &(*filter)[0][ phase & 1][0];
      fx = &(*filter)[0][~phase & 1][0];
      fo = &(*filter)[1][~phase & 1][0];

      Dptr = &D[0];

      ptr = *Dptr + po;
      ML0(hi, lo, (*fx)[0], ptr[ 0]);
      MLA(hi, lo, (*fx)[1], ptr[14]);
      MLA(hi, lo, (*fx)[2], ptr[12]);
      MLA(hi, lo, (*fx)[3], ptr[10]);
      MLA(hi, lo, (*fx)[4], ptr[ 8]);
      MLA(hi, lo, (*fx)[5], ptr[ 6]);
      MLA(hi, lo, (*fx)[6], ptr[ 4]);
      MLA(hi, lo, (*fx)[7], ptr[ 2]);
      MLN(hi, lo);

      ptr = *Dptr + pe;
      MLA(hi, lo, (*fe)[0], ptr[ 0]);
      MLA(hi, lo, (*fe)[1], ptr[14]);
      MLA(hi, lo, (*fe)[2], ptr[12]);
      MLA(hi, lo, (*fe)[3], ptr[10]);
      MLA(hi, lo, (*fe)[4], ptr[ 8]);
      MLA(hi, lo, (*fe)[5], ptr[ 6]);
      MLA(hi, lo, (*fe)[6], ptr[ 4]);
      MLA(hi, lo, (*fe)[7], ptr[ 2]);

      raw_sample = SHIFT(MLZ(hi, lo));
      raw_sample = scale(raw_sample);
      (*pcm1++) += (short int)raw_sample;
      pcm2 = pcm1 + 14;

      for (sb = 1; sb < 16; ++sb)
      {
        ++fe;
        ++Dptr;

        /* D[32 - sb][i] == -D[sb][31 - i] */

        ptr = *Dptr + po;
        ML0(hi, lo, (*fo)[0], ptr[ 0]);
        MLA(hi, lo, (*fo)[1], ptr[14]);
        MLA(hi, lo, (*fo)[2], ptr[12]);
        MLA(hi, lo, (*fo)[3], ptr[10]);
        MLA(hi, lo, (*fo)[4], ptr[ 8]);
        MLA(hi, lo, (*fo)[5], ptr[ 6]);
        MLA(hi, lo, (*fo)[6], ptr[ 4]);
        MLA(hi, lo, (*fo)[7], ptr[ 2]);
        MLN(hi, lo);

        ptr = *Dptr + pe;
        MLA(hi, lo, (*fe)[7], ptr[ 2]);
        MLA(hi, lo, (*fe)[6], ptr[ 4]);
        MLA(hi, lo, (*fe)[5], ptr[ 6]);
        MLA(hi, lo, (*fe)[4], ptr[ 8]);
        MLA(hi, lo, (*fe)[3], ptr[10]);
        MLA(hi, lo, (*fe)[2], ptr[12]);
        MLA(hi, lo, (*fe)[1], ptr[14]);
        MLA(hi, lo, (*fe)[0], ptr[ 0]);

        raw_sample = SHIFT(MLZ(hi, lo));
        raw_sample = scale(raw_sample);
        (*pcm1++) += (short int)raw_sample;

        ptr = *Dptr - pe;
        ML0(hi, lo, (*fe)[0], ptr[31 - 16]);
        MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
        MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
        MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
        MLA(hi, lo, (*fe)[4], ptr[31 -  8]);
        MLA(hi, lo, (*fe)[5], ptr[31 -  6]);
        MLA(hi, lo, (*fe)[6], ptr[31 -  4]);
        MLA(hi, lo, (*fe)[7], ptr[31 -  2]);

        ptr = *Dptr - po;
        MLA(hi, lo, (*fo)[7], ptr[31 -  2]);
        MLA(hi, lo, (*fo)[6], ptr[31 -  4]);
        MLA(hi, lo, (*fo)[5], ptr[31 -  6]);
        MLA(hi, lo, (*fo)[4], ptr[31 -  8]);
        MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
        MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
        MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
        MLA(hi, lo, (*fo)[0], ptr[31 - 16]);

        raw_sample = SHIFT(MLZ(hi, lo));
        raw_sample = scale(raw_sample);
        (*pcm2--) += (short int)raw_sample;

        ++fo;
      }

      Dptr++;

      ptr = *Dptr + po;
      ML0(hi, lo, (*fo)[0], ptr[ 0]);
      MLA(hi, lo, (*fo)[1], ptr[14]);
      MLA(hi, lo, (*fo)[2], ptr[12]);
      MLA(hi, lo, (*fo)[3], ptr[10]);
      MLA(hi, lo, (*fo)[4], ptr[ 8]);
      MLA(hi, lo, (*fo)[5], ptr[ 6]);
      MLA(hi, lo, (*fo)[6], ptr[ 4]);
      MLA(hi, lo, (*fo)[7], ptr[ 2]);

      raw_sample = SHIFT(-MLZ(hi, lo));
      raw_sample = scale(raw_sample);
      (*pcm1) += (short int)raw_sample;

    } /* Channel For */

    /* Block render */
    //--render_sample_block(short_sample_buff, 16);
    WriteMP3ToBuffer(short_sample_buff,16);
    phase = (phase + 1) % 16;

  }/* Block For */
}