Example #1
0
int
decode_layer2_frame(PMPSTR mp, unsigned char *pcm_sample, int *pcm_point)
{
    real    fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */
    sideinfo_layer_II si;
    struct frame *fr = &(mp->fr);
    int     single = fr->single;
    int     i, j, clip = 0;

    II_select_table(fr);
    II_step_one(mp, &si, fr);

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

    if (single >= 0) {
        for (i = 0; i < SCALE_BLOCK; i++) {
            II_step_two(mp, &si, fr, i >> 2, fraction);
            for (j = 0; j < 3; j++) {
                clip += synth_1to1_mono(mp, fraction[single][j], pcm_sample, pcm_point);
            }
        }
    }
    else {
        for (i = 0; i < SCALE_BLOCK; i++) {
Example #2
0
	//--------------------------------------------------------------------------------------------------------------
	int DecodeLayer2( MPEGFrameInfo* pFrameInfo, unsigned char* pOut, int* pOutSize )
	{
		int clip=0;
		int i,j;
		int stereo = pFrameInfo->dwChannels;
		float pFrameInfoaction[2][4][MPEG_SBLimit]; /* pick_table clears unused subbands */
		unsigned int bit_alloc[64];
		int scale[192];

		II_select_table(pFrameInfo);
		pFrameInfo->nJointStereo = (pFrameInfo->dwChannels == 1) ? (pFrameInfo->bJointMode<<2)+4 : pFrameInfo->nTableSelect;

		II_step_one(bit_alloc, scale, pFrameInfo);

		for (i=0;i<MPEG_ScaleBlock;i++) 
		{
			II_step_two(bit_alloc,pFrameInfoaction,scale,pFrameInfo,i>>2);
			for (j=0;j<3;j++)
			{
				if( stereo == 1 )
				{
					clip += Synth_1to1_Mono(pFrameInfoaction[0][j],pOut,pOutSize);
				}
				else
				{
					int p1 = *pOutSize;
					clip += Synth_1to1(pFrameInfoaction[0][j],0,pOut,&p1);
					clip += Synth_1to1(pFrameInfoaction[1][j],1,pOut,pOutSize);
				}
			}
		}

		return clip;
	}
Example #3
0
int mpg123_do_layer2(struct frame *fr)
{
	int i, j;
	int stereo = fr->stereo;
	real fraction[2][4][SBLIMIT];	/* pick_table clears unused subbands */
	unsigned int bit_alloc[64];
	int scale[192];
	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 (fr->jsbound > fr->II_sblimit)
		fr->jsbound = 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)
			{
				(fr->synth_mono) (fraction[single][j], mpg123_pcm_sample, &mpg123_pcm_point);
			}
			else
			{
				int p1 = mpg123_pcm_point;

				(fr->synth) (fraction[0][j], 0, mpg123_pcm_sample, &p1);
				(fr->synth) (fraction[1][j], 1, mpg123_pcm_sample, &mpg123_pcm_point);
			}

			/*    if(mpg123_pcm_point >= audiobufsize)
			   audio_flush(outmode,ai); */
		}
	}
	if (mpg123_info->output_audio)
	{

		mpg123_ip.add_vis_pcm(mpg123_ip.output->written_time(), mpg123_cfg.resolution == 16 ? FMT_S16_NE : FMT_U8,
				      mpg123_cfg.channels == 2 ? fr->stereo : 1, mpg123_pcm_point, mpg123_pcm_sample);

		while (mpg123_ip.output->buffer_free() < mpg123_pcm_point && mpg123_info->going && mpg123_info->jump_to_time == -1)
			xmms_usleep(10000);
		if (mpg123_info->going && mpg123_info->jump_to_time == -1)
			mpg123_ip.output->write_audio(mpg123_pcm_sample, mpg123_pcm_point);
		

	}
	mpg123_pcm_point = 0;

	return 1;
}
Example #4
0
int do_layer2(mpg123_handle *fr)
{
	int clip=0;
	int i,j;
	int stereo = fr->stereo;
	/* pick_table clears unused subbands */
	/* replacement for real fraction[2][4][SBLIMIT], needs alignment. */
	real (*fraction)[4][SBLIMIT] = fr->layer2.fraction;
	unsigned int bit_alloc[64];
	int scale[192];
	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(fr->jsbound > fr->II_sblimit)
	{
		fprintf(stderr, "Truncating stereo boundary to sideband limit.\n");
		fr->jsbound=fr->II_sblimit;
	}

	/* TODO: What happens with mono mixing, actually? */
	if(stereo == 1 || single == SINGLE_MIX) /* also, mix not really handled */
	single = SINGLE_LEFT;

	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 != SINGLE_STEREO)
			clip += (fr->synth_mono)(fraction[single][j], fr);
			else
			clip += (fr->synth_stereo)(fraction[0][j], fraction[1][j], fr);
		}
	}

	return clip;
}
Example #5
0
int do_layer2(struct mpstr *mp,struct frame *fr,int outmode,struct audio_info_struct *ai)
{
  int clip=0;
  int i,j;
  int stereo = fr->stereo;
  real fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */
  unsigned int bit_alloc[64];
  int scale[192];
  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 += (fr->synth_mono) (fraction[single][j],pcm_sample,&pcm_point);
      }
      else {
          int p1 = pcm_point;
          clip += (fr->synth) (fraction[0][j],0,pcm_sample,&p1);
          clip += (fr->synth) (fraction[1][j],1,pcm_sample,&pcm_point);
      }

      if(pcm_point >= audiobufsize)
        audio_flush(outmode,ai);
    }
  }

  return clip;
}
Example #6
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;
}
Example #7
0
int sha123_do_layer2(sha123_t * sha123)
{
  sha123_frame_t *fr = &sha123->frame;
  int i, j;
  const int stereo = 1 << fr->info.log2chan;
  real fraction[2][4][SBLIMIT];	/* pick_table clears unused subbands */
  unsigned int bit_alloc[64];
  int scale[192];
  int single = fr->info.log2chan;

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

  II_step_one(bit_alloc, scale, fr, &sha123->bsi);

  for (i = 0; i < SCALE_BLOCK; i++) {
    II_step_two(bit_alloc, fraction, scale, fr, i >> 2, &sha123->bsi);
    for (j = 0; j < 3; j++) {
      if (single >= 0) {
	fr->synth_mn(fraction[single][j], sha123->pcm_sample,
		       &sha123->pcm_point);
      } else {
	int p1 = sha123->pcm_point;

	fr->synth_st(fraction[0][j], 0, sha123->pcm_sample, &p1);
	fr->synth_st(fraction[1][j], 1, sha123->pcm_sample, &sha123->pcm_point);
      }

      /*    if(sha123->pcm_point >= audiobufsize)
	    audio_flush(outmode,ai); */
    }
  }
  sha123->pcm_point = 0;

  return 1;
}
Example #8
0
int do_layer2(struct StaticData * psd, struct mpstr * gmp, struct frame *fr,unsigned char *pcm_sample,int *pcm_point)
{
    int clip=0;
    int i,j;
    int stereo = fr->stereo;
    float fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */
    unsigned int bit_alloc[64];
    int scale[192];
    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(psd, bit_alloc, scale, fr);

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