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

📄 musicin.c

📁 MPEG 2的音频编码软件。喜欢多媒体的开发人员可以看看。
💻 C
📖 第 1 页 / 共 5 页
字号:
		    bool = *cha_sw > 2;
		else
		    bool = *cha_sw > 0;
		if (bool)
		    printf ("!!! Channel-switching mode %d cannot be used together with Configuration: %d !!!\n", *cha_sw, fr_ps->config);
	    } while (bool);
	}

#ifdef Augmentation_7ch
	if (fr_ps->stereoaug == 2)  /* 7.1 channel mode */
	{
	    if (*aug_cha_sw == 0 || info->aug_mtx_proc == 3)
	    {
		*aug_cha_sw = 0;
		printf ("Aug Channel-switching is not used!\n");
		printf ("Which mode of Aug Channel-switching do you want? (not used) ");
		gets (t);
		printf("Aug CHA mode: %d\n", *aug_cha_sw);
	    }
	    else
	    {
		*aug_cha_sw = 1;
		printf ("Aug Channel-switching is used\n");	 
		do
		{
		    printf ("Which mode of Aug Channel-switching do you want? (-1 ... 7) ");
		    gets (t);
		    *aug_cha_sw = atoi (t);
		    printf ("Aug CHA mode: %d\n", *aug_cha_sw);

		    if (info->aug_mtx_proc == 0 || info->aug_mtx_proc == -1)
			bool = *aug_cha_sw > 7;
		    else if (info->aug_mtx_proc == 1)
			bool = *aug_cha_sw > 3;
		    else
			bool = *aug_cha_sw > 0;

		    if (bool)
		        printf ("!!! TCA7 mode %d cannot be used together with aug_mtx_proc: %d !!!\n",
				*aug_cha_sw, info->aug_mtx_proc);
		} while (bool);
	    }
	}
	else
#endif
	    *aug_cha_sw = 0;

	/********* 27/07/95, WtK , phantom coding ********************/
	if ((fr_ps->stereomc > 0) && (info->center == 1))
	{
	    printf ("Do you want to use Phantom Coding of the Center signal? (y/<n>) ");
	    gets (t);
	    if ((*t == 'y') || (*t == 'Y'))
	    {
		printf (">>> Phantom Coding is used.\n");
		fr_ps->phantom_c = 1;
	    } 
	    else
	    {
		printf (">>> No Phantom Coding.\n");	 
		fr_ps->phantom_c = 0;
	    }
        }

	/********* 05/24/95, SR , dynamic cross_talk ********************/
	printf ("Do you want to have Dynamic Crosstalk?(y/<n>) ");
	gets (t);
	if (*t == 'y')  
	{
	    printf ("Dynamic Crosstalk is used!\n");
	    bool = 1;
	    do
	    {
		printf ("Which mode of Dynamic Crosstalk do you want? (-1 ... 14) ");
		gets (t);
		*dyn_cr = atoi (t);
		printf ("DynX mode: %d\n", *dyn_cr);
		if (fr_ps->phantom_c && fr_ps->config == 320)
		    bool = ((*dyn_cr==9) || (*dyn_cr==10) || (*dyn_cr==11) || (*dyn_cr==12) || (*dyn_cr==14));
		else if (fr_ps->phantom_c && ((fr_ps->config==310) || (fr_ps->config==220)))
		    bool = (*dyn_cr==4);
		else
		    bool = 0;
		if (bool)
		    printf ("!!! Dynamic Crosstalk mode %d cannot be used together with Phantom Coding !!!\n", *dyn_cr);
	    } while (bool);

#ifdef Augmentation_7ch
	    if (fr_ps->stereoaug == 2)  /* 7.1 channel mode */
	    {
		bool = 1;
		do
		{
		    printf ("Which mode of Aug Dynamic Crosstalk do you want? (-1 ... 18) ");
		    gets (t);
		    *aug_dyn_cr = atoi (t);
		    printf ("Aug DynX mode: %d\n", *aug_dyn_cr);
		    bool = *aug_dyn_cr > 18;

		    if (bool)
			printf ("!!! Aug Dynamic Crosstalk mode %d cannot be used !!!\n", *aug_dyn_cr);
		} while (bool);
	    }
#endif
	} 
	else
	{
	    *dyn_cr = 0;
	    printf ("Dynamic Crosstalk is not used\n");	 
	    printf ("Which mode of Dynamic Crosstalk do you want? (not used) ");
	    gets (t);
	    printf ("DynX mode: %d\n", *dyn_cr);
#ifdef Augmentation_7ch
	    if (fr_ps->stereoaug == 2)  /* 7.1 channel mode */
	    {
	        *aug_dyn_cr = 0;
		printf ("Which mode of Aug Dynamic Crosstalk do you want? (-1 ... 18) ");
		gets (t);
		printf ("Aug DynX mode: %d\n", *aug_dyn_cr);
	    }
#endif
	}
	bool = 1;
	do
	{
	    printf ("Value for dyn_cross_LR?(<0>/1) ");
	    gets (t);
	    *dyn_cr_LR = atoi (t);
	    bool = *dyn_cr_LR < -1 || *dyn_cr_LR > 1;

	    if (bool)
		printf ("!!! dyn_cross_LR %d invalid value -1, 0 or 1 !!!\n", *dyn_cr_LR);
	} while (bool);
	printf ("dyn_cross_LR: %d\n", *dyn_cr_LR);

	/********* 27/01/97, FdB, select prediction ********************/
	if (fr_ps->stereomc > 0 && fr_ps->config != 202 && fr_ps->config != 102)
	{
	    printf ("Do you want to use MC prediction? (y/<n>) ");
	    gets (t);
	    if ((*t == 'y') || (*t == 'Y'))
	    {
		printf (">>> MC prediction is used.\n");
		info->mc_prediction_on = 1;
	    } 
	    else
	    {
		printf (">>> No MC prediction.\n");	 
		info->mc_prediction_on = 0;
	    }
        }
    }

    /* YBKim060695 ancillary */
    printf ("Do you want to use ancillary part ? (y:<n>): ");
    gets (t);
    *ancillaryUse = (*t == 'y' || *t == 'Y');
    printf ("Ancillary: %d\n", *ancillaryUse);

    printf ("How verbose would you like the output ? (0, <1>, 2, 3): ");
    gets (t);
    if (*t >= '0' && *t <= '3')
	*verbosity = atoi (t);
    else
	*verbosity = DFLT_VERB;
    printf ("Verbose level: %d\n", *verbosity);

    printf ("Do you wish to exit (last chance before encoding)? (y/<n>): ");
    gets (t);
    if (*t == 'y' || *t == 'Y')
	exit (1);
}   

/************************************************************************
/*
/* parse_args
/*
/* PURPOSE:  Sets encoding parameters to the specifications of the
/* command line.  Default settings are used for parameters
/* not specified in the command line.
/*
/* SEMANTICS:  The command line is parsed according to the following
/* syntax:
/*
/* -l  is followed by the layer number
/* -m  is followed by the mode of the two front channels
/* -r  is followed by the sampling rate
/* -b  is followed by the total bitrate, irrespective of the mode
/* -B  is followed by the MPEG1 bitrate, irrespective of the mode
/* -d  is followed by the emphasis flag
/* -c  turns the copyright flag on
/* -o  turns the original flag on
/* -e  turns the error_protection flag on
/* -C  is followed by the configuration code "???" (front,rear,2ndstereo) channels
/* -L  turns the LFE flag on
/* -x  is followed by the matrix
/* -k  is followed by a fixed tca value, or if '-1' a random value 
/* -y  is followed by the dynamic crosstalk mode, or if '-1' a random value 
#ifdef Augmentation_7ch
/* -X  is followed by the 7.1-ch aug. matrix
/* -K  is followed by a fixed 7.1-ch aug. tca value, or if '-1' a random value 
/* -Y  is followed by the 7.1-ch aug. dynX mode, or if '-1' a random value 
#endif
/* -w  sets phantom coding /* 27/07/95: '-p' already reserved for psy */
/* -g  sets MultiLingual coding
/* -D  turns the dyn_cross_LR flag on
/* -P  turns the 'random prediction values' flag on
/* -n  is followed by the number of ancillary data bytes
/* -a  turns the ancillary flag on
/* -v  sets level of verbosity of debug and progress messages
/*
/* If the input file is in AIFF format, the sampling frequency is read
/* from the AIFF header.
/*
/* The input and output filenames are read into #inpath# and #outpath#.
/*
/************************************************************************/
 
void
parse_args(int argc, char **argv,
	frame_params *fr_ps,
	int *psy,
	long unsigned int *num_samples,
	long unsigned int *num_samples_ml,
	char *original_file_name,
	char *encoded_file_name,
	IFF_AIFF *pcm_aiff_data,
	IFF_AIFF *pcm_aiff_data_ml,
	int *aiff,
	int *byte_per_sample,
	int *mat_mode,
	int *aug_mat_mode,
	int *cha_sw,
	int *aug_cha_sw,
	char *encoded_file_name_ext,
	int *bit_rate,
	char *encoded_file_name_mpg,
	int *dyn_cr,
	int *dyn_cr_LR,
	int *aug_dyn_cr,
	int *ancillaryUse,
	int *verbosity)
{
    FLOAT srate;
    int	 brate = DFLT_BRT;    /* MPEG1 bitrate */
    layer *info = fr_ps->header;
    int   err = 0, bool, i = 0;
    int   ml_present = 0; /* MultiLingual coding */
    
    fr_ps->mnr_min = 0.0;
    *aiff = 0;
    *bit_rate = DFLT_BRT;    /* total bitrate */
    fr_ps->phantom_c = 0;
    *verbosity = DFLT_VERB;
 
    /* preset defaults */
    original_file_name[0] = NULL_CHAR;
    encoded_file_name[0] = NULL_CHAR;
    info->lay = DFLT_LAY;
    switch(DFLT_MOD)
    {
	case 'r': info->mode = MPG_MD_STEREO; info->mode_ext = 0; break;
	case 'd': info->mode = MPG_MD_DUAL_CHANNEL; info->mode_ext=0; break;
	case 'j': info->mode = MPG_MD_JOINT_STEREO; break;
	case 'm': info->mode = MPG_MD_MONO; info->mode_ext = 0; break;
	default : fprintf(stderr, "%s: Bad mode dflt %c\n", programName, DFLT_MOD);
		  abort ();
    }
    *psy = DFLT_PSY;
    if ((info->sampling_frequency = SmpFrqIndex ((long) (1000*DFLT_SFQ))) < 0)
    {
        fprintf (stderr, "%s: bad sfrq default %.2f\n", programName, DFLT_SFQ);
        abort ();
    }
    info->bitrate_index = DFLT_BRT;
    if ((info->bitrate_index = BitrateIndex (info->lay, DFLT_BRT)) < 0)
    {
	fprintf (stderr, "%s: bad default bitrate %u\n", programName, DFLT_BRT);
	abort ();
    }
    switch(DFLT_EMP)
    {
	case 'n': info->emphasis = 0; break;
	case '5': info->emphasis = 1; break;
	case 'c': info->emphasis = 3; break;
	default : fprintf (stderr, "%s: Bad emph dflt %c\n", programName, DFLT_EMP);
		  abort ();
    }
    info->copyright = 0;
    info->original = 0;
    info->error_protection = FALSE;
  
    /* process args */
    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 'l':	info->lay = atoi(arg);
				argUsed = 1;
				if (info->lay < 1 || info->lay > 2)
				{
				   fprintf(stderr,"%s: -l layer must be 1 or 2, not %s\n",
					programName, arg);
				   err = 1;
				}
				break;

		    case 'm':	argUsed = 1;
				if (*arg == 's')
				    { info->mode = MPG_MD_STEREO; info->mode_ext = 0; }
				else if (*arg == 'd')
				    { info->mode = MPG_MD_DUAL_CHANNEL; info->mode_ext = 0; }
				else if (*arg == 'j')
				    { info->mode = MPG_MD_JOINT_STEREO; }
				else if (*arg == 'm')
				    { info->mode = MPG_MD_MONO; info->mode_ext = 0; }
				else if (*arg == 'n')
				    { info->mode = MPG_MD_NONE; info->mode_ext = 0; }
				else 
				{
				    fprintf (stderr, "%s: -m mode must be s/d/j/m not %s\n",
						     programName, arg);
				    err = 1;
				}
				break;

		    case 'r':	srate = atof(arg);
				argUsed = 1;
				if ((info->sampling_frequency =
				    SmpFrqIndex ((long) (1000*srate))) < 0)
				    err = 1;
				break;

		    case 'b':	*bit_rate = atoi(arg);
				argUsed = 1;
				if (*bit_rate > brate)
				{
				    info->ext_bit_stream_present = 1;
				    info->ext_length = ((*bit_rate - brate) * 144) / s_freq[info->sampling_frequency];
				}
				else
				{
				    info->ext_bit_stream_present = 0;
				    brate = *bit_rate;
				}
				break;

		    case 'B':	brate = atoi(arg);
				argUsed = 1;
				if (*bit_rate > brate)
				{
				    info->ext_bit_stream_present = 1;
				    info->ext_length = ((*bit_rate - brate) * 144) / s_freq[info->sampling_frequency];
				}
				else
				    info->ext_bit_stream_present = 0;
				break;

		    case 'C':	fr_ps->config = atoi(arg);
				argUsed = 1;
				break;

		    case 'd':	argUsed = 1;
				if (*arg == 'n')	info->emphasis = 0;
				else if (*arg == '5')	info->emphasis = 1;
				else if (*arg == 'c')	info->emphasis = 3;
				else 
				{
				    fprintf (stderr, "%s: -d emp must be n/5/c not %s\n",
						     programName, arg);
				    err = 1;

⌨️ 快捷键说明

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