/*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; }
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++) {
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; }
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; }