Exemple #1
0
/*int do_layer1(struct frame *fr,int outmode,struct audio_info_struct *ai) */
int do_layer1(PMPSTR mp, unsigned char *pcm_sample,int *pcm_point)
{
  int clip=0;
  unsigned int balloc[2*SBLIMIT];
  unsigned int scale_index[2][SBLIMIT];
  real fraction[2][SBLIMIT];
  struct frame *fr=&(mp->fr);
  int i,stereo = fr->stereo;
  int single = fr->single;

  fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext<<2)+4 : 32;

  if(stereo == 1 || single == 3)
    single = 0;

  I_step_one(balloc,scale_index,fr);

  for (i=0;i<SCALE_BLOCK;i++)
  {
    I_step_two(fraction,balloc,scale_index,fr);

    if(single >= 0)
    {
      clip += synth_1to1_mono( mp, (real *) fraction[single],pcm_sample,pcm_point);
    }
    else {
        int p1 = *pcm_point;
        clip += synth_1to1( mp, (real *) fraction[0],0,pcm_sample,&p1);
        clip += synth_1to1( mp, (real *) fraction[1],1,pcm_sample,pcm_point);
    }
  }

  return clip;
}
Exemple #2
0
int
decode_layer1_frame(PMPSTR mp, unsigned char *pcm_sample, int *pcm_point)
{
    real    fraction[2][SBLIMIT]; /* FIXME: change real -> double ? */
    sideinfo_layer_I si;
    struct frame *fr = &(mp->fr);
    int     single = fr->single;
    int     i, clip = 0;

    I_step_one(mp, &si);

    if (fr->stereo == 1 || single == 3)
        single = 0;

    if (single >= 0) {
        /* decoding one of possibly two channels */
        for (i = 0; i < SCALE_BLOCK; i++) {
            I_step_two(mp, &si, fraction);
            clip += synth_1to1_mono(mp, (real *) fraction[single], pcm_sample, pcm_point);
        }
    }
    else {
        for (i = 0; i < SCALE_BLOCK; i++) {
            int     p1 = *pcm_point;
            I_step_two(mp, &si, fraction);
            clip += synth_1to1(mp, (real *) fraction[0], 0, pcm_sample, &p1);
            clip += synth_1to1(mp, (real *) fraction[1], 1, pcm_sample, pcm_point);
        }
    }

    return clip;
}
Exemple #3
0
int synth_1to1_mono(PMPSTR mp, real *bandPtr,int *pnt)
{
  int ret;
  int pnt1 = 0;

  ret = synth_1to1(mp,bandPtr,0,&pnt1);
  *pnt += 64;

  return ret;
}
Exemple #4
0
int do_layer2( PMPSTR mp,unsigned char *pcm_sample,int *pcm_point)
//int do_layer2(struct frame *fr,int outmode,struct audio_info_struct *ai)
{
    int clip=0;
    int i,j;
    real fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */
    unsigned int bit_alloc[64];
    int scale[192];
    struct frame *fr=&(mp->fr);
    int stereo = fr->stereo;
    int single = fr->single;

    II_select_table(fr);
    fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ?
                  (fr->mode_ext<<2)+4 : fr->II_sblimit;

    if(stereo == 1 || single == 3)
        single = 0;

    II_step_one(bit_alloc, scale, fr);

    for (i=0; i<SCALE_BLOCK; i++)
    {
        II_step_two(bit_alloc,fraction,scale,fr,i>>2);
        for (j=0; j<3; j++)
        {
            if(single >= 0)
            {
                clip += synth_1to1_mono(mp, fraction[single][j],pcm_sample,pcm_point);
            }
            else {
                int p1 = *pcm_point;
                clip += synth_1to1(mp, fraction[0][j],0,pcm_sample,&p1);
                clip += synth_1to1(mp, fraction[1][j],1,pcm_sample,pcm_point);
            }
        }
    }

    return clip;
}
static int synth_1to1_r(real *bandPtr,int channel,unsigned char *out,int *pnt)
{
    int i,ret;

    ret = synth_1to1(bandPtr,channel,out,pnt);
    out = out + *pnt - 128;

    for(i=0; i<32; i++) {
        ((short *)out)[0] = ((short *)out)[1];
        out+=4;
    }

    return ret;
}
static int synth_1to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
    int i,ret;

    ret = synth_1to1(bandPtr,0,samples,pnt);
    samples = samples + *pnt - 128;

    for(i=0; i<32; i++) {
        ((short *)samples)[1] = ((short *)samples)[0];
        samples+=4;
    }

    return ret;
}
int synth_1to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt) 
{
  short samples_tmp[64];
  short *tmp1 = samples_tmp;
  int i,ret;
  int pnt1 = 0;

  ret = synth_1to1(bandPtr,0,(unsigned char *)samples_tmp,&pnt1);
  samples += *pnt;

  for(i=0;i<32;i++) {
    *samples++ = conv16to8[*tmp1>>AUSHIFT];
    tmp1+=2;
  }
  *pnt += 32;

  return ret;
}
Exemple #8
0
int synth_1to1_mono(struct mpstr *mp, real *bandPtr,unsigned char *samples,int *pnt)
{
  short samples_tmp[64];
  short *tmp1 = samples_tmp;
  int i,ret;
  int pnt1 = 0;

  ret = synth_1to1(mp, bandPtr,0,(unsigned char *) samples_tmp,&pnt1);
  samples += *pnt;

  for(i=0;i<32;i++) {
    *( (short *) samples) = *tmp1;
    samples += 2;
    tmp1 += 2;
  }
  *pnt += 64;

  return ret;
}
int synth_1to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
{
  short samples_tmp[64];
  short *tmp1 = samples_tmp + channel;
  int i,ret;
  int pnt1 = 0;

  ret = synth_1to1(bandPtr,channel,(unsigned char *)samples_tmp,&pnt1);
  samples += channel + *pnt;

  for(i=0;i<32;i++) {
    *samples = conv16to8[*tmp1>>AUSHIFT];
    samples += 2;
    tmp1 += 2;
  }
  *pnt += 64;

  return ret;
}
Exemple #10
0
#include "mpg123lib_intern.h"

/* 8bit functions silenced for FLOATOUT */

int synth_1to1_8bit(real *bandPtr,int channel, mpg123_handle *fr, int final)
{
  sample_t samples_tmp[64];
  sample_t *tmp1 = samples_tmp + channel;
  int i,ret;

  /* save buffer stuff, trick samples_tmp into there, decode, restore */
  unsigned char *samples = fr->buffer.data;
  int pnt = fr->buffer.fill;
  fr->buffer.data = (unsigned char*) samples_tmp;
  fr->buffer.fill = 0;
  ret = synth_1to1(bandPtr, channel, fr, 0);
  fr->buffer.data = samples; /* restore original value */

  samples += channel + pnt;
  for(i=0;i<32;i++) {
#ifdef FLOATOUT
    *samples = 0;
#else
    *samples = fr->conv16to8[*tmp1>>AUSHIFT];
#endif
    samples += 2;
    tmp1 += 2;
  }
  fr->buffer.fill = pnt + (final ? 64 : 0 );

  return ret;