⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parse.c

📁 音频编码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* *      Command line parsing related functions * *      Copyright (c) 1999 Mark Taylor * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. *//* $Id: parse.c,v 1.211.2.1 2005/11/26 14:19:02 bouvigne Exp $ */#ifdef HAVE_CONFIG_H# include <config.h>#endif#include <assert.h>#include <ctype.h>#ifdef STDC_HEADERS# include <stdlib.h># include <string.h>#else# ifndef HAVE_STRCHR#  define strchr index#  define strrchr rindex# endifchar *strchr (), *strrchr ();# ifndef HAVE_MEMCPY#  define memcpy(d, s, n) bcopy ((s), (d), (n))#  define memmove(d, s, n) bcopy ((s), (d), (n))# endif#endif#ifdef __OS2__#include <os2.h>#define PRTYC_IDLE 1#define PRTYC_REGULAR 2#define PRTYD_MINIMUM -31 #define PRTYD_MAXIMUM 31 #endif#ifdef HAVE_LIMITS_H# include <limits.h>#endif#include "lame.h"#include "set_get.h"#include "brhist.h"#include "parse.h"#include "main.h"#include "get_audio.h"#include "version.h"#ifdef WITH_DMALLOC#include <dmalloc.h>#endif#if defined DEBUG || _DEBUG#define INTERNAL_OPTS 1#else#define INTERNAL_OPTS LAME_ALPHA_VERSION#endif#if (INTERNAL_OPTS!=0)#define DEV_HELP(a) a#else#define DEV_HELP(a) #endif/* GLOBAL VARIABLES.  set by parse_args() *//* we need to clean this up */sound_file_format input_format;   int swapbytes;              /* force byte swapping   default=0*/int silent;                 /* Verbosity */int ignore_tag_errors;      /* Ignore errors in values passed for tags */int brhist;float update_interval;      /* to use Frank's time status display */int mp3_delay;              /* to adjust the number of samples truncated                               during decode */int mp3_delay_set;          /* user specified the value of the mp3 encoder                                delay to assume for decoding */int enc_delay;int enc_padding;int disable_wav_header;mp3data_struct mp3input_data; /* used by MP3 */int print_clipping_info;      /* print info whether waveform clips */int in_signed=1;int in_unsigned=0;int in_endian=order_littleEndian;int in_bitwidth=16;/**   *  Long Filename support for the WIN32 platform *   */#ifdef WIN32#include <winbase.h>static void  dosToLongFileName( char *fn ){    const int MSIZE = PATH_MAX + 1 - 4;  /*  we wanna add ".mp3" later */    WIN32_FIND_DATAA lpFindFileData;    HANDLE h = FindFirstFileA( fn, &lpFindFileData );    if ( h != INVALID_HANDLE_VALUE ) {        int   a;        char *q, *p;        FindClose( h );        for ( a = 0; a < MSIZE; a++ ) {            if ( '\0' == lpFindFileData.cFileName[a] ) break;        }        if ( a >= MSIZE || a == 0 ) return;        q = strrchr( fn, '\\' );        p = strrchr( fn, '/' );        if ( p-q > 0 ) q = p;        if ( q == NULL ) q = strrchr(fn,':');        if ( q == NULL ) strncpy( fn, lpFindFileData.cFileName, a );        else {            a += q-fn +1;            if ( a >= MSIZE ) return;            strncpy( ++q, lpFindFileData.cFileName, MSIZE-a );        }    }}#endif#if defined(WIN32)#include <windows.h>BOOL SetPriorityClassMacro(DWORD p){    HANDLE op = OpenProcess(PROCESS_ALL_ACCESS,TRUE,GetCurrentProcessId());    return SetPriorityClass(op,p);}static void setWin32Priority( lame_global_flags*  gfp, int Priority ){    if (Priority > 3) {	SetPriorityClassMacro(HIGH_PRIORITY_CLASS);        printf("==> Priority set to High.\n");    }    if (Priority < 3) {	SetPriorityClassMacro(IDLE_PRIORITY_CLASS);        printf("==> Priority set to Low.\n");    }}#endif#if defined(__OS2__)/* OS/2 priority functions */static int setOS2Priority( lame_global_flags*  gfp, int Priority ){    int rc;    switch(Priority) {     case 0:        rc = DosSetPriority(             0,                      /* Scope: only one process */             PRTYC_IDLE,             /* select priority class (idle, regular, etc) */             0,                      /* set delta */             0);                     /* Assume current process */        printf("==> Priority set to 0 (Low priority).\n");        break;    case 1:        rc = DosSetPriority(             0,                      /* Scope: only one process */             PRTYC_IDLE,             /* select priority class (idle, regular, etc) */             PRTYD_MAXIMUM,          /* set delta */             0);                     /* Assume current process */        printf("==> Priority set to 1 (Medium priority).\n");        break;    case 2:        rc = DosSetPriority(             0,                      /* Scope: only one process */             PRTYC_REGULAR,          /* select priority class (idle, regular, etc) */             PRTYD_MINIMUM,          /* set delta */             0);                     /* Assume current process */        printf("==> Priority set to 2 (Regular priority).\n");        break;            case 3:        rc = DosSetPriority(             0,                      /* Scope: only one process */             PRTYC_REGULAR,          /* select priority class (idle, regular, etc) */             0,                      /* set delta */             0);                     /* Assume current process */        printf("==> Priority set to 3 (High priority).\n");        break;    case 4:        rc = DosSetPriority(             0,                      /* Scope: only one process */             PRTYC_REGULAR,          /* select priority class (idle, regular, etc) */             PRTYD_MAXIMUM,          /* set delta */             0);                     /* Assume current process */        printf("==> Priority set to 4 (Maximum priority). I hope you enjoy it :)\n");        break;         default:        printf("==> Invalid priority specified! Assuming idle priority.\n");    }       return 0;}#endif/************************************************************************** license** PURPOSE:  Writes version and license to the file specified by fp*************************************************************************/static int  lame_version_print ( FILE* const fp ){    const char * b = get_lame_os_bitness ();    const char * v = get_lame_version ();    const char * u = get_lame_url ();    const int lenb = strlen (b);    const int lenv = strlen (v);    const int lenu = strlen (u);    const int lw = 80; /* line width of terminal in characters */    const int sw = 16; /* static width of text */        if (lw >= lenb+lenv+lenu+sw || lw < lenu+2)        /* text fits in 80 chars per line, or line even too small for url */		if( lenb > 0 )			fprintf ( fp, "LAME %s version %s (%s)\n\n", b, v, u );		else			fprintf ( fp, "LAME version %s (%s)\n\n", v, u );    else                    /* text too long, wrap url into next line, right aligned */		if( lenb > 0 )			fprintf ( fp, "LAME %s version %s\n%*s(%s)\n\n", b, v, lw-2-lenu, "", u );		else			fprintf ( fp, "LAME version %s\n%*s(%s)\n\n", v, lw-2-lenu, "", u );    if (LAME_ALPHA_VERSION)        fprintf ( fp, "warning: alpha versions should be used for testing only\n\n");        return 0;}static int  print_license ( FILE* const fp )  /* print version & license */{    lame_version_print ( fp );    fprintf ( fp,               "Can I use LAME in my commercial program?\n"              "\n"              "Yes, you can, under the restrictions of the LGPL.  In particular, you\n"              "can include a compiled version of the LAME library (for example,\n"              "lame.dll) with a commercial program.  Some notable requirements of\n"              "the LGPL:\n"                                                      "\n" );    fprintf ( fp,               "1. In your program, you cannot include any source code from LAME, with\n"              "   the exception of files whose only purpose is to describe the library\n"              "   interface (such as lame.h).\n"              "\n" );    fprintf ( fp,               "2. Any modifications of LAME must be released under the LGPL.\n"              "   The LAME project (www.mp3dev.org) would appreciate being\n"              "   notified of any modifications.\n"              "\n" );    fprintf ( fp,               "3. You must give prominent notice that your program is:\n"              "      A. using LAME (including version number)\n"              "      B. LAME is under the LGPL\n"              "      C. Provide a copy of the LGPL.  (the file COPYING contains the LGPL)\n"              "      D. Provide a copy of LAME source, or a pointer where the LAME\n"              "         source can be obtained (such as www.mp3dev.org)\n"              "   An example of prominent notice would be an \"About the LAME encoding engine\"\n"              "   button in some pull down menu within the executable of your program.\n"              "\n" );    fprintf ( fp,               "4. If you determine that distribution of LAME requires a patent license,\n"              "   you must obtain such license.\n"              "\n"              "\n" );    fprintf ( fp,               "*** IMPORTANT NOTE ***\n"              "\n"              "The decoding functions provided in LAME use the mpglib decoding engine which\n"              "is under the GPL.  They may not be used by any program not released under the\n"              "GPL unless you obtain such permission from the MPG123 project (www.mpg123.de).\n"              "\n" );    return 0;}/************************************************************************** usage** PURPOSE:  Writes command line syntax to the file specified by fp*************************************************************************/int  usage ( FILE* const fp, const char* ProgramName )  /* print general syntax */{    lame_version_print ( fp );    fprintf ( fp,              "usage: %s [options] <infile> [outfile]\n"              "\n"              "    <infile> and/or <outfile> can be \"-\", which means stdin/stdout.\n"              "\n"              "Try:\n"              "     \"%s --help\"           for general usage information\n"               " or:\n"              "     \"%s --preset help\"    for information on suggested predefined settings\n"              " or:\n"              "     \"%s --longhelp\"\n"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -