📄 musicout.c
字号:
for (sb=0; sb<SBLIMIT; sb++) { /* Hybrid synthesis. */ III_hybrid(hybridIn[sb], hybridOut[sb], sb, ch, &(III_side_info.ch[ch].gr[gr]), &fr_ps,fp_imdct); } for (ss=0;ss<18;ss++) /*Frequency inversion for polyphase.*/ for (sb=0; sb<SBLIMIT; sb++) { if ((ss%2) && (sb%2)) hybridOut[sb][ss] = -hybridOut[sb][ss]; }#ifdef DEBUG_COMPEN for (sb=0; sb<SBLIMIT; sb++) for (ss=0;ss<18;ss++) fprintf(fp_compen,"imdct[%d][%d] = %f\n",sb,ss,hybridOut[sb][ss]);#endif for (ss=0;ss<18;ss++) { /* Polyphase synthesis */ for (sb=0; sb<SBLIMIT; sb++) polyPhaseIn[sb] = hybridOut[sb][ss]; clip += SubBandSynthesis (polyPhaseIn, ch, &((*pcm_sample)[ch][ss][0]),fp_poly); } } /* Output PCM sample points for one granule. */ out_fifo(*pcm_sample, 18, &fr_ps, done, musicout, &sample_frames); } if(clip > 0) printf("%d samples clipped.\n", clip); break; } }/* skip ancillary data HP 22-nov-95 */ if (info.bitrate_index > 0) { /* if not free-format */ long anc_len; anc_len = (int)((double)samplesPerFrame / s_freq[info.version][info.sampling_frequency] * (double)bitrate[info.version][info.lay-1][info.bitrate_index] / (double)bitsPerSlot); if (info.padding) anc_len++; anc_len *= bitsPerSlot; anc_len -= sstell(&bs)-gotBits+SYNC_WORD_LNGTH; for (j=0; j<anc_len; j++) get1bit(&bs); } } if (Arguments.need_aiff) { pcm_aiff_data.numChannels = stereo; pcm_aiff_data.numSampleFrames = sample_frames; pcm_aiff_data.sampleSize = 16; pcm_aiff_data.sampleRate = s_freq[info.version][info.sampling_frequency]*1000; 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) { printf("Could not write AIFF headers to \"%s\"\n", Arguments.decoded_file_name); exit(2); } } printf("Avg slots/frame = %.3f; b/smp = %.2f; br = %.3f kbps\n", (FLOAT) gotBits / (frameNum * bitsPerSlot), (FLOAT) gotBits / (frameNum * samplesPerFrame), (FLOAT) gotBits / (frameNum * samplesPerFrame) * s_freq[info.version][info.sampling_frequency]); close_bit_stream_r(&bs); fclose(musicout); /* for the correct AIFF header information */ /* on the Macintosh */ /* the file type and the file creator for */ /* Macintosh compatible Digidesign is set */#ifdef MACINTOSH if (Arguments.need_aiff) set_mac_file_attr(Arguments.decoded_file_name, VOL_REF_NUM, CREATR_DEC_AIFF, FILTYP_DEC_AIFF); else set_mac_file_attr(Arguments.decoded_file_name, VOL_REF_NUM, CREATR_DEC_BNRY, FILTYP_DEC_BNRY);#endif printf("Decoding of \"%s\" is finished\n", Arguments.encoded_file_name); printf("The decoded PCM output file name is \"%s\"\n", Arguments.decoded_file_name); if (Arguments.need_aiff) printf("\"%s\" has been written with AIFF header information\n", Arguments.decoded_file_name);#ifdef DEBUG_PRINT#ifdef DEBUG_HUFFMAN fclose(fp_huffman);#endif#ifdef DEBUG_HUFFMAN fclose(fp_requan);#endif #ifdef DEBUG_SCALEFAC fclose(fp_scalefac);#endif#ifdef DEBUG_STEREO fclose(fp_stereo);#endif#ifdef DEBUG_REORDER fclose(fp_reorder);#endif #ifdef DEBUG_ANTIALIAS fclose(fp_antialias);#endif #ifdef DEBUG_IMDCT fclose(fp_imdct);#endif#ifdef DEBUG_COMPEN fclose(fp_compen);#endif #ifdef DEBUG_POLY fclose(fp_poly);#endif #endif #ifdef CAPT_BS fclose(fp_capt_bs);#endif#ifdef CAPT_CODE_BOOK fclose(fp_capt_codebook);#endif exit( 0 );}static void usage() /* print syntax & exit */{ fprintf(stderr, "usage: %s queries for all arguments, or\n", programName); fprintf(stderr, " %s [-A][-s sb] inputBS [outPCM]\n", programName); fprintf(stderr,"where\n"); fprintf(stderr," -A write an AIFF output PCM sound file\n"); fprintf(stderr," -s sb resynth only up to this sb (debugging only)\n"); fprintf(stderr," inputBS input bit stream of encoded audio\n"); fprintf(stderr," outPCM output PCM sound file (dflt inName+%s)\n", DFLT_OPEXT); exit(1);}static void GetArguments(argc, argv,Arguments) int argc; char **argv; Arguments_t *Arguments;{ char t[50]; programName = argv[0]; if(argc==1) { /* no command line args -> interact */ do { printf ("Enter encoded file name <required>: "); gets (Arguments->encoded_file_name); if (Arguments->encoded_file_name[0] == NULL_CHAR) printf ("Encoded file name is required. \n"); } while (Arguments->encoded_file_name[0] == NULL_CHAR); printf (">>> Encoded file name is: %s \n", Arguments->encoded_file_name);#ifdef MS_DOS printf ("Enter MPEG decoded file name <%s>: ", new_ext(Arguments->encoded_file_name, DFLT_OPEXT)); /* 92-08-19 shn */#else printf ("Enter MPEG decoded file name <%s%s>: ", Arguments->encoded_file_name, DFLT_OPEXT);#endif gets (Arguments->decoded_file_name); if (Arguments->decoded_file_name[0] == NULL_CHAR) {#ifdef MS_DOS /* replace old extension with new one, 92-08-19 shn */ strcpy(Arguments->decoded_file_name, new_ext(Arguments->encoded_file_name, DFLT_OPEXT));#else strcat (strcpy(Arguments->decoded_file_name, Arguments->encoded_file_name), DFLT_OPEXT);#endif } printf (">>> MPEG decoded file name is: %s \n", Arguments->decoded_file_name); printf( "Do you wish to write an AIFF compatible sound file ? (y/<n>) : "); gets(t); if (*t == 'y' || *t == 'Y') Arguments->need_aiff = TRUE; else Arguments->need_aiff = FALSE; if (Arguments->need_aiff) printf(">>> An AIFF compatible sound file will be written\n"); else printf(">>> A non-headered PCM sound file will be written\n"); printf( "Do you wish to exit (last chance before decoding) ? (y/<n>) : "); gets(t); if (*t == 'y' || *t == 'Y') exit(0); } else { /* interpret CL Args */ int i=0, err=0; Arguments->need_aiff = FALSE; Arguments->need_esps = FALSE; /* MI */ Arguments->encoded_file_name[0] = '\0'; Arguments->decoded_file_name[0] = '\0'; while(++i<argc && err == 0) { char c, *token, *arg, *nextArg; int argUsed; token = argv[i]; if(*token++ == '-') { if(i+1 < argc) nextArg = argv[i+1]; else nextArg = ""; argUsed = 0; while(c = *token++) { if(*token /* NumericQ(token) */) arg = token; else arg = nextArg; switch(c) { case 's': Arguments->topSb = atoi(arg); argUsed = 1; if(Arguments->topSb<1 || Arguments->topSb>SBLIMIT) { fprintf(stderr, "%s: -s band %s not %d..%d\n", programName, arg, 1, SBLIMIT); err = 1; } break; case 'A': Arguments->need_aiff = TRUE; break; case 'E': Arguments->need_esps = TRUE; break; /* MI */ default: fprintf(stderr,"%s: unrecognized option %c\n", programName, c); err = 1; break; } if(argUsed) { if(arg == token) token = ""; /* no more from token */ else ++i; /* skip arg we used */ arg = ""; argUsed = 0; } } } else { if(Arguments->encoded_file_name[0] == '\0') strcpy(Arguments->encoded_file_name, argv[i]); else if(Arguments->decoded_file_name[0] == '\0') strcpy(Arguments->decoded_file_name, argv[i]); else { fprintf(stderr, "%s: excess arg %s\n", programName, argv[i]); err = 1; } } } if(err || Arguments->encoded_file_name[0] == '\0') usage(); /* never returns */ if(Arguments->decoded_file_name[0] == '\0') { strcpy(Arguments->decoded_file_name, Arguments->encoded_file_name); strcat(Arguments->decoded_file_name, DFLT_OPEXT); } } /* report results of dialog / command line */ printf("Input file = '%s' output file = '%s'\n", Arguments->encoded_file_name, Arguments->decoded_file_name); if(Arguments->need_aiff) printf("Output file written in AIFF format\n"); if(Arguments->need_esps) printf("Output file written in ESPS format\n"); /* MI */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -