📄 parse.c
字号:
ERRORF("Must specify lowpass width with --lowpass-width freq, freq >= 0 kHz\n"); LAME_ERROR_EXIT(); } } else if (strcmp(token, "highpass")==0) { argUsed=1; gfp->highpassfreq = (( 1000.0 * atof( nextArg ) ) + 0.5); if (gfp->highpassfreq < 1) { ERRORF("Must specify highpass with --highpass freq, freq >= 0.001 kHz\n"); LAME_ERROR_EXIT(); } } else if (strcmp(token, "highpass-width")==0) { argUsed=1; gfp->highpasswidth = (( 1000.0 * atof( nextArg ) ) + 0.5); if (gfp->highpasswidth < 0) { ERRORF("Must specify highpass width with --highpass-width freq, freq >= 0 kHz\n"); LAME_ERROR_EXIT(); } } else if (strcmp(token, "cwlimit")==0) { argUsed=1; gfp->cwlimit = atof( nextArg ); if (gfp->cwlimit <= 0 ) { ERRORF("Must specify cwlimit in kHz\n"); LAME_ERROR_EXIT(); } } else if (strcmp(token, "comp")==0) { argUsed=1; gfp->compression_ratio = atof( nextArg ); if (gfp->compression_ratio < 1.0 ) { ERRORF("Must specify compression ratio >= 1.0\n"); LAME_ERROR_EXIT(); } } /* some more GNU-ish options could be added * version => complete name, version and license info (normal exit) * quiet/silent => no messages on screen * brief => few messages on screen (name, status report) * verbose => all infos to screen (brhist, internal flags/filters) * o/output file => specifies output filename * O => stdout * i/input file => specifies input filename * I => stdin */ else if (strcmp(token, "version") ==0 ||strcmp(token, "license")==0){ lame_print_license(gfp,programName); /* doesn't return */ } else if (strcmp(token, "help") ==0 ||strcmp(token, "usage")==0){ lame_short_help(gfp,programName); /* doesn't return */ } else if (strcmp(token, "longhelp") ==0){ lame_help(gfp,programName); /* doesn't return */ } else if (strcmp(token, "preset")==0) { argUsed=1; if (strcmp(nextArg,"phone")==0) { /* when making changes, please update help text too */ gfp->out_samplerate = 8000; gfp->lowpassfreq=3200; gfp->lowpasswidth=1000; gfp->no_short_blocks=1; gfp->quality = 5; gfp->mode = MPG_MD_MONO; gfp->mode_fixed = 1; gfp->brate = 16; gfp->VBR_q=6; gfp->VBR_min_bitrate_kbps=8; gfp->VBR_max_bitrate_kbps=56; } else if (strcmp(nextArg,"sw")==0) { /* when making changes, please update help text too */ gfp->out_samplerate = 11025; gfp->lowpassfreq=4800; gfp->lowpasswidth=500; gfp->quality = 5; gfp->mode = MPG_MD_MONO; gfp->mode_fixed = 1; gfp->brate = 24; gfp->VBR_q=5; gfp->VBR_min_bitrate_kbps=8; gfp->VBR_max_bitrate_kbps=64; } else if (strcmp(nextArg,"am")==0) { /* when making changes, please update help text too */ gfp->out_samplerate = 16000; gfp->lowpassfreq=7200; gfp->lowpasswidth=500; gfp->quality = 5; gfp->mode = MPG_MD_MONO; gfp->mode_fixed = 1; gfp->brate = 32; gfp->VBR_q=5; gfp->VBR_min_bitrate_kbps=16; gfp->VBR_max_bitrate_kbps=128; } else if (strcmp(nextArg,"fm")==0) { /* when making changes, please update help text too */ gfp->out_samplerate = 22050; gfp->lowpassfreq=9950; gfp->lowpasswidth=880; gfp->quality = 5; gfp->mode = MPG_MD_JOINT_STEREO; gfp->mode_fixed = 1; gfp->brate = 64; gfp->VBR_q=5; gfp->VBR_min_bitrate_kbps=24; gfp->VBR_max_bitrate_kbps=160; } else if (strcmp(nextArg,"voice")==0) { /* when making changes, please update help text too */ gfp->out_samplerate = 32000; gfp->lowpassfreq=12300; gfp->lowpasswidth=2000; gfp->no_short_blocks=1; gfp->quality = 5; gfp->mode = MPG_MD_MONO; gfp->mode_fixed = 1; gfp->brate = 56; gfp->VBR_q=4; gfp->VBR_min_bitrate_kbps=32; gfp->VBR_max_bitrate_kbps=128; } else if (strcmp(nextArg,"radio")==0) { /* when making changes, please update help text too */ gfp->lowpassfreq=15000; gfp->lowpasswidth=0; gfp->quality = 5; gfp->mode = MPG_MD_JOINT_STEREO; gfp->mode_fixed = 1; gfp->brate = 112; gfp->VBR_q=4; gfp->VBR_min_bitrate_kbps=64; gfp->VBR_max_bitrate_kbps=256; } else if (strcmp(nextArg,"tape")==0) { /* when making changes, please update help text too */ gfp->lowpassfreq=18500; gfp->lowpasswidth=2000; gfp->quality = 5; gfp->mode = MPG_MD_JOINT_STEREO; gfp->mode_fixed = 1; gfp->brate = 128; gfp->VBR_q=4; gfp->VBR_min_bitrate_kbps=96; gfp->VBR_max_bitrate_kbps=320; } else if (strcmp(nextArg,"hifi")==0) { /* when making changes, please update help text too */ gfp->lowpassfreq=20240; gfp->lowpasswidth=2200; gfp->quality = 2; gfp->mode = MPG_MD_JOINT_STEREO; gfp->mode_fixed = 1; gfp->brate = 160; gfp->VBR_q=3; gfp->VBR_min_bitrate_kbps=112; gfp->VBR_max_bitrate_kbps=320; } else if (strcmp(nextArg,"cd")==0) { /* when making changes, please update help text too */ gfp->lowpassfreq=-1; gfp->highpassfreq=-1; gfp->quality = 2; gfp->mode = MPG_MD_STEREO; gfp->mode_fixed = 1; gfp->brate = 192; gfp->VBR_q=2; gfp->VBR_min_bitrate_kbps=128; gfp->VBR_max_bitrate_kbps=320; } else if (strcmp(nextArg,"studio")==0) { /* when making changes, please update help text too */ gfp->lowpassfreq=-1; gfp->highpassfreq=-1; gfp->quality = 2; gfp->mode = MPG_MD_STEREO; gfp->mode_fixed = 1; gfp->brate = 256; gfp->VBR_q=0; gfp->VBR_min_bitrate_kbps=160; gfp->VBR_max_bitrate_kbps=320; } else if (strcmp(nextArg,"help")==0) { lame_presets_info(gfp,programName); /* doesn't return */ } else { ERRORF("%s: --preset type, type must be phone, voice, fm, tape, hifi, cd or studio, not %s\n", programName, nextArg); LAME_ERROR_EXIT(); } } /* --preset */ else { ERRORF("%s: unrec option --%s\n", programName, token); } i += argUsed; } else while( (c = *token++) ) { if(*token ) arg = token; else arg = nextArg; switch(c) { case 'm': argUsed = 1; gfp->mode_fixed = 1; if (*arg == 's') { gfp->mode = MPG_MD_STEREO; } else if (*arg == 'd') { gfp->mode = MPG_MD_DUAL_CHANNEL; } else if (*arg == 'j') { gfp->mode = MPG_MD_JOINT_STEREO; } else if (*arg == 'f') { gfp->mode = MPG_MD_JOINT_STEREO; gfp->force_ms=1; } else if (*arg == 'm') { gfp->mode = MPG_MD_MONO; } else { ERRORF("%s: -m mode must be s/d/j/f/m not %s\n", programName, arg); err = 1; } break; case 'V': argUsed = 1; /* to change VBR default look in lame.h */ if (gfp->VBR == vbr_off) gfp->VBR = vbr_default; gfp->VBR_q = atoi(arg); if (gfp->VBR_q <0) gfp->VBR_q=0; if (gfp->VBR_q >9) gfp->VBR_q=9; gfp->quality = 2; break; case 'q': argUsed = 1; user_quality = atoi(arg); if (user_quality<0) user_quality=0; if (user_quality>9) user_quality=9; break; case 's': argUsed = 1; srate = atof( arg ); /* samplerate = rint( 1000.0 * srate ); $A */ gfp->in_samplerate = (( 1000.0 * srate ) + 0.5); break; case 'b': argUsed = 1; gfp->brate = atoi(arg); gfp->VBR_min_bitrate_kbps=gfp->brate; break; case 'B': argUsed = 1; gfp->VBR_max_bitrate_kbps=atoi(arg); break; case 'F': gfp->VBR_hard_min=1; break; case 't': /* dont write VBR tag */ gfp->bWriteVbrTag=0; break; case 'r': /* force raw pcm input file */#ifdef LIBSNDFILE ERRORF("WARNING: libsndfile may ignore -r and perform fseek's on the input.\n" "Compile without libsndfile if this is a problem.\n");#endif gfp->input_format=sf_raw; break; case 'x': /* force byte swapping */ gfp->swapbytes=TRUE; break; case 'p': /* (jo) error_protection: add crc16 information to stream */ gfp->error_protection = 1; break; case 'a': /* autoconvert input file from stereo to mono - for mono mp3 encoding */ autoconvert=1; gfp->mode=MPG_MD_MONO; gfp->mode_fixed=1; break; case 'h': gfp->quality = 2; break; case 'k': gfp->lowpassfreq=-1; gfp->highpassfreq=-1; break; case 'd': gfp->allow_diff_short = 1; break; case 'v': /* to change VBR default look in lame.h */ gfp->VBR = vbr_default; gfp->quality = 2; break; case 'S': gfp->silent = TRUE; break; case 'X': argUsed = 1; gfp->experimentalX=atoi(arg); break; case 'Y': gfp->experimentalY = TRUE; break; case 'Z': gfp->experimentalZ = TRUE; break; case 'f': gfp->quality= 7; break; case 'g': /* turn on gtk analysis */ gfp->gtkflag = TRUE; break; case 'e': argUsed = 1; if (*arg == 'n') gfp->emphasis = 0; else if (*arg == '5') gfp->emphasis = 1; else if (*arg == 'c') gfp->emphasis = 3; else { ERRORF("%s: -e emp must be n/5/c not %s\n", programName, arg); err = 1; } break; case 'c': gfp->copyright = 1; break; case 'o': gfp->original = 0; break; case '?': lame_help(gfp,programName); /* doesn't return */ default: ERRORF("%s: unrec 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(gfp->inPath[0] == '\0') strncpy(gfp->inPath, argv[i], MAX_NAME_SIZE); else if(gfp->outPath[0] == '\0') strncpy(gfp->outPath, argv[i], MAX_NAME_SIZE); else { ERRORF("%s: excess arg %s\n", programName, argv[i]); err = 1; } } } /* loop over args */ if(err || gfp->inPath[0] == '\0') lame_usage(gfp,programName); /* never returns */ if (gfp->inPath[0]=='-') gfp->silent=1; /* turn off status - it's broken for stdin */ if(gfp->outPath[0] == '\0') { if (gfp->inPath[0]=='-') { /* if input is stdin, default output is stdout */ strcpy(gfp->outPath,"-"); }else { strncpy(gfp->outPath, gfp->inPath, MAX_NAME_SIZE - 4); if (gfp->decode_only) { strncat(gfp->outPath, ".wav", 4 ); } else if (gfp->ogg) { strncat(gfp->outPath, ".ogg", 4 ); }else{ strncat(gfp->outPath, ".mp3", 4 ); } } } /* some file options not allowed with stdout */ if (gfp->outPath[0]=='-') { gfp->bWriteVbrTag=0; /* turn off VBR tag */ if (gfp->id3tag_used) { gfp->id3tag_used=0; /* turn of id3 tagging */ ERRORF("id3tag ignored: id3 tagging not supported for stdout.\n"); } } /* if user did not explicitly specify input is mp3, check file name */ if (gfp->input_format != sf_mp3 || gfp->input_format != sf_ogg) { if (!(strcmp((char *) &gfp->inPath[strlen(gfp->inPath)-4],".mp3"))) gfp->input_format = sf_mp3; else if (!(strcmp((char *) &gfp->inPath[strlen(gfp->inPath)-4],".ogg"))) gfp->input_format = sf_ogg; } #if !(defined HAVEMPGLIB || defined AMIGA_MPEGA) if (gfp->input_format == sf_mp3) { ERRORF("Error: libmp3lame not compiled with mp3 *decoding* support \n"); LAME_ERROR_EXIT(); }#endif /* default guess for number of channels */ if (autoconvert) gfp->num_channels=2; else if (gfp->mode == MPG_MD_MONO) gfp->num_channels=1; else gfp->num_channels=2; /* user specified a quality value. override any defaults set above */ if (user_quality) gfp->quality=user_quality; if (gfp->free_format) { if (gfp->brate<8) { ERRORF("For free format, specify a bitrate between 8 and 320kbs\n"); LAME_ERROR_EXIT(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -