📄 musicout.c
字号:
for (jj = 0; jj < 12; jj++)
{
/* lfe_tmp[jj] = (short int) (info.lfe_spl_fraction[jj] * SCALE); */
double foo = floor (info.lfe_spl_fraction[jj] * SCALE + 0.5);
if (foo >= (long) SCALE) {lfe_tmp[jj] = SCALE-1; clip++;}
else if (foo < (long) -SCALE) {lfe_tmp[jj] =-SCALE; clip++;}
else lfe_tmp[jj] = foo;
}
fwrite (&lfe_tmp[0], 2, 12, lfe);
}
if (clip > 0)
printf("\n%d samples clipped\n", clip);
/***************************************************************/
/* 10/03/1995 JMZ Multilingual , WtK 7/8/95 */
if (info.no_of_multi_lingual_ch>0)
{
for(jj=0;jj<( (info.multi_lingual_fs==0) ? 12 : 6 );jj++)
for(k=0; k<info.no_of_multi_lingual_ch; k++)
for(j =0; j <3; j++)
for(ii=0; ii< SBLIMIT; ii++)
(*fraction_help_ml)[jj][k][j][ii] = (*fraction_ml)[k][ii][j][jj];
clip = 0;
for (i=0;i<( (info.multi_lingual_fs==0) ? 12 : 6 );i++)
{
for (j=0;j<3;j++)
for (k=0; k<info.no_of_multi_lingual_ch; k++)
clip += SubBandSynthesis_ml(&((*fraction_help_ml)[i][k][j][0]), k,
&((*pcm_sample_ml)[k][j][0]));
out_fifo_ml(*pcm_sample_ml, 3, &fr_ps, done, musicout_ml, &sample_frames_ml);
}
if(clip > 0) printf("\n%d MultiLingual samples clipped\n", clip);
}
/* 10/03/1995 JMZ Multilingual */
/**************************************************************/
if( print_out == 1)
{
if(frameNum == 1)
{
fp6 = fopen("SUB_ML","w+");
fp5 = fopen("DYN_CROSS","w+");
fp4 = fopen("INFODEC", "w+");
fp2 = fopen("BALDEC", "w+");
fp3 = fopen("SCFSIDEC", "w+");
fp1 = fopen("SCFDEC", "w+");
}
/*********************Ausgabe***************************************************/
fprintf(fp1, "******************** FRAME %d *****************************\n", frameNum-1);
fprintf(fp2, "\n******************** FRAME %d *****************************\n", frameNum-1);
fprintf(fp3, "\n******************** FRAME %d *****************************\n", frameNum-1);
fprintf(fp4, "******************** FRAME %d *****************************\n", frameNum-1);
fprintf(fp6, "******************** FRAME %d *****************************\n", frameNum-1);
fprintf(fp4, "version = %d, ", info.version);
fprintf(fp4, "lay = %d, ", info.lay);
fprintf(fp4, "error_protection = %d\n", info.error_protection);
fprintf(fp4, "bitrate_index = %d, ", info.bitrate_index);
fprintf(fp4, "sampling_frequency = %d,", info.sampling_frequency);
fprintf(fp4, "padding = %d, ", info.padding);
fprintf(fp4, "extension = %d\n", info.extension);
fprintf(fp4, "mode = %d, ", info.mode);
fprintf(fp4, "mode_ext = %d,", info.mode_ext);
fprintf(fp4, "copyright = %d, ", info.copyright);
fprintf(fp4, "original = %d, ", info.original);
fprintf(fp4, "emphasis = %d\n", info.emphasis);
fprintf(fp4, "center = %d, ", info.center);
fprintf(fp4, "surround = %d, ", info.surround);
fprintf(fp4, "dematrix_procedure = %d, ", info.dematrix_procedure);
fprintf(fp4, "lfe = %d\n", info.lfe);
fprintf(fp4, "no_of_multi_lingual_ch = %d, ", info.no_of_multi_lingual_ch);
fprintf(fp4, "multi_lingual_fs = %d, ", info.multi_lingual_fs);
fprintf(fp4, "multi_lingual_layer = %d\n", info.multi_lingual_layer);
fprintf(fp4, "dyn_cross_on = %d\n", info.dyn_cross_on);
fprintf(fp4, "mc_prediction_on = %d\n", info.mc_prediction_on);
#ifdef DEBUG_PREDICTION
if(info.mc_prediction_on == 1)
for(hu = 0; hu < 8; ++ hu)
{
fprintf(fp4, "mc_prediction[%d] = %d ", hu, info.mc_prediction[hu]);
for(ho = 0; ho < 4; ho++)
{
fprintf(fp4, "mc_predsi[%d][%d] = %d ", hu,ho, info.mc_predsi[hu][ho]);
fprintf(fp4, "mc_delay[%d][%d] = %d ", hu,ho, info.mc_delay_comp[hu][ho]);
fprintf(fp4, " \n");
for(hi = 0;hi <3; hi++)
fprintf(fp4, "pred_coeff[%d][%d][%d] = %d ",hu,ho,hi,info.mc_pred_coeff[hu][ho][hi]);
fprintf(fp4, " \n");
}
}
#endif
if(info.dyn_cross_on == 1)
{
fprintf(fp5, "\n******************** FRAME %d *****************************\n", frameNum-1);
fprintf(fp5,"dyn_cross_LR = %d\n",info.dyn_cross_LR);
for(ho = 0; ho < 12; ho ++)
{
fprintf(fp5,"dyn_cross[%d] = %d ",ho,info.dyn_cross_mode[ho]);
if((ho+1)%4 == 0) fprintf(fp5,"\n");
}
if (info.surround == 3)
for(ho = 0; ho < 12; ho ++)
{
fprintf(fp5,"dyn_second_stereo[%d] = %d ",ho,info.dyn_second_stereo[ho]);
if((ho+1)%4 == 0) fprintf(fp5,"\n");
}
}
fprintf(fp4, "tc_sbgr_select = %d\n", info.tc_sbgr_select);
if(info.tc_sbgr_select == 1)
fprintf(fp4, "tc_allocation = %d\n", info.tc_allocation);
else
{
for(ho = 0; ho < 12; ho ++)
{
if(info.mc_prediction[ho] == 0)
fprintf(fp4, "tc_alloc[%d] = %d\n", ho, info.tc_alloc[ho]);
else{
for(hu = 0; hu < 4; hu++)
fprintf(fp4, "predsi[%d][%d] = %d\n", ho, hu, info.mc_predsi[ho][hu]);
}
}
fprintf(fp4, "\n");
}
for(hu = 0; hu < SBLIMIT; ++hu)
{
fprintf(fp2, "\n");
fprintf(fp3, "\n");
for(hi = 0; hi < channels; hi ++)
{
fprintf(fp1, "\n");
if (layer_I_frames == 1)
fprintf(fp2, "BAL[%d][%02d] = %d ", hi, hu, I_bit_alloc[0][hi][hu]);
else
fprintf(fp2, "BAL[%d][%02d] = %d ", hi, hu, bit_alloc[hi][hu]);
fprintf(fp3, "SCFSI[%d][%02d] = %d ", hi, hu, scfsi[hi][hu]);
for( ho = 0; ho < layer_I_frames; ho ++)
{
fprintf(fp1, "SCF[%d][%d][%02d] = %d ", hi, ho, hu, scale_index[hi][ho][hu]);
}
}
for(hi = 0; hi < info.no_of_multi_lingual_ch; hi ++)
{
fprintf(fp1, "\n");
/* 960315 added FDB Multi-Lingual bitalloc */
fprintf(fp2, "BAL_ML[%d][%02d] = %d ", hi, hu, bit_alloc_ml[hi][hu]);
/* 960315 added FDB Multi-Lingual scf select info */
fprintf(fp3, "SCFSI_ML[%d][%02d] = %d ", hi, hu, scfsi_ml[hi][hu]);
/* 960315 added FDB Multi-Lingual scfs */
for( ho = 0; ho < 3; ho ++)
fprintf(fp1, "SCF_ML[%d][%d][%02d] = %d ", hi, ho, hu, scale_index_ml[hi][ho][hu]);
}
fprintf(fp1, "\n");
}
/* 960318 added FDB Multi-Lingual subband samples symbols*/
for(k=0; k<info.no_of_multi_lingual_ch; k++)
for(ii=0; ii< SBLIMIT; ii++)
{
fprintf(fp6, "SB_SYM_ML[%d][%02d]: ", k, ii);
for(jj=0;jj<( (info.multi_lingual_fs==0) ? 12 : 6 );jj++)
for(j =0; j <3; j++)
fprintf(fp6, " %6d", sym_sample_ml[jj][k][j][ii]);
fprintf(fp6, "\n");
}
/* 960318 added FDB Multi-Lingual subband samples */
for(k=0; k<info.no_of_multi_lingual_ch; k++)
for(ii=0; ii< SBLIMIT; ii++)
{
fprintf(fp6, "SB_ML[%d][%02d]: ", k, ii);
for(jj=0;jj<( (info.multi_lingual_fs==0) ? 12 : 6 );jj++)
for(j =0; j <3; j++)
fprintf(fp6, " %12.5e", (*fraction_help_ml)[jj][k][j][ii]);
fprintf(fp6, "\n");
}
fflush (fp1);
fflush (fp2);
fflush (fp3);
fflush (fp4);
fflush (fp5);
fflush (fp6);
/*******************************************************************************/
} /* endif of print_out == 1 */
/****************************************************************/
/* */
/* END OF FRAME LOOP */
/* */
/****************************************************************/
}/*end of while(!endof(bs)) - loop */
if (need_aiff)
{
#ifdef Augmentation_7ch
if (mpeg == 3)
pcm_aiff_data.numChannels = 7;
else
#endif
pcm_aiff_data.numChannels = stereo + mc_channel;
pcm_aiff_data.numSampleFrames = sample_frames;
pcm_aiff_data.sampleSize = 16;
pcm_aiff_data.sampleRate = s_freq[info.sampling_frequency]*1000;
strcpy(pcm_aiff_data.sampleType, IFF_ID_SSND);
pcm_aiff_data.blkAlgn.offset = 0;
pcm_aiff_data.blkAlgn.blockSize = 0;
if (aiff_write_headers(musicout, &pcm_aiff_data) == -1)
{
fprintf (stderr, "Could not write AIFF headers to \"%s\"\n",
decoded_file_name);
exit (1);
}
if (fr_ps.header->no_of_multi_lingual_ch>0)
{
pcm_aiff_data.numChannels = fr_ps.header->no_of_multi_lingual_ch;
pcm_aiff_data.numSampleFrames = sample_frames;
pcm_aiff_data.sampleSize = 16;
pcm_aiff_data.sampleRate = s_freq[info.sampling_frequency]*1000;
if (fr_ps.header->multi_lingual_fs==1) pcm_aiff_data.sampleRate *= 0.5;
strcpy(pcm_aiff_data.sampleType, IFF_ID_SSND);
pcm_aiff_data.blkAlgn.offset = 0;
pcm_aiff_data.blkAlgn.blockSize = 0;
if (aiff_write_headers(musicout_ml, &pcm_aiff_data) == -1)
{
fprintf (stderr, "Could not write AIFF headers to \"%s\"\n",
decoded_file_name_ml);
exit (1);
}
}
if (lfe_init == 0)
{
pcm_aiff_data.numChannels = 1;
pcm_aiff_data.numSampleFrames = sample_frames / 96;
pcm_aiff_data.sampleSize = 16;
pcm_aiff_data.sampleRate = (s_freq[info.sampling_frequency]*1000) / 96;
strcpy(pcm_aiff_data.sampleType, IFF_ID_SSND);
pcm_aiff_data.blkAlgn.offset = 0;
pcm_aiff_data.blkAlgn.blockSize = 0;
if (aiff_write_headers(lfe, &pcm_aiff_data) == -1)
{
fprintf (stderr, "Could not write AIFF headers to \"%s\"\n",
lfe_file_name);
exit (1);
}
}
}
close_bit_stream_r(&bs_mpg);
if (info.ext_bit_stream_present)
{
close_bit_stream_r(&bs_ext);
}
fclose(musicout);
if(info.lfe) fclose(lfe);
#ifdef MACINTOSH
if (need_aiff) set_mac_file_attr(decoded_file_name, VOL_REF_NUM,
CREATR_DEC_AIFF, FILTYP_DEC_AIFF);
else set_mac_file_attr(decoded_file_name, VOL_REF_NUM,
CREATR_DEC_BNRY, FILTYP_DEC_BNRY);
#endif
printf("Decoding of \"%s\" with %lu frames is finished\n", encoded_file_name, frameNum);
printf("The decoded PCM output file name is \"%s\"\n", decoded_file_name);
if (need_aiff)
printf("\"%s\" has been written with AIFF header information\n",
decoded_file_name);
if (fr_ps.header->no_of_multi_lingual_ch>0) {
printf("There are %d multilingual channels, coded at ",fr_ps.header->no_of_multi_lingual_ch);
if (fr_ps.header->multi_lingual_fs==0) printf("full"); else printf("half");
printf(" sampling rate.\n They are outputted in \"%s\".\n",decoded_file_name_ml);
if (need_aiff)
printf("Multilingual file has been written with AIFF header information\n");
}
if (total_error_count_mc != 0)
printf ("There were %d frames, which were not in multichannel!!\n", total_error_count_mc);
#ifdef Augmentation_7ch
if (total_error_count_aug != 0)
printf ("There were %d frames, which were not in augmented multichannel!!\n", total_error_count_aug);
#endif
if (print_out == 1)
{
fclose (fp1);
fclose (fp2);
fclose (fp3);
fclose (fp4);
fclose (fp5);
fclose (fp6);
}
return (1);
}
void usage (void) /* print syntax & exit */
{
fprintf (stderr,
"usage: %s queries for all arguments, or\n",
programName);
fprintf (stderr,
" %s [-a] [-h] [-i] [-m] inputBS [outPCM]\n", programName);
fprintf (stderr,"where\n");
fprintf (stderr," -a write a RAW data sound file (default: write an AIFF sound file)\n");
fprintf (stderr," -b write alloc bits per subband to stdout (default: off)\n");
fprintf (stderr," -d write dynx modes to stdout (default: off)\n");
fprintf (stderr," -h bitstreams contain a 2304 byte header (default: no header)\n");
fprintf (stderr," -i write decoded bitstream-information in a file\n");
/* default: write encoded information */
fprintf (stderr," -m encoded bitstream is a MPEG 1 Layer-2 file\n");
/* default: decode a MPEG 2 Layer-2 bitstream */
#ifdef Augmentation_7ch
fprintf (stderr," -n encoded bitstream is a MPEG 2 Layer-2 file with 7.1 augmentation\n");
/* default: decode a MPEG 2 Layer-2 bitstream */
#endif
fprintf (stderr," -s write scf bits per subband to stdout (default: off)\n");
fprintf (stderr," -t write tca modes to stdout (default: off)\n");
fprintf (stderr," inputBS input bit stream of encoded audio\n");
fprintf (stderr," outPCM output PCM sound file (dflt inName)\n");
exit (1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -