home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Da Capo
/
da_capo_vol1.bin
/
programs
/
amiga
/
misc
/
mpegaudio
/
musicin.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-03-21
|
39KB
|
1,016 lines
/**********************************************************************
Copyright (c) 1991 MPEG/audio software simulation group, All Rights Reserved
musicin.c
**********************************************************************/
/**********************************************************************
* MPEG/audio coding/decoding software, work in progress *
* NOT for public distribution until verified and approved by the *
* MPEG/audio committee. For further information, please contact *
* Davis Pan, 508-493-2241, e-mail: pan@3d.enet.dec.com *
* *
* VERSION 4.0 *
* changes made since last update: *
* date programmers comment *
* 3/01/91 Douglas Wong, start of version 1.1 records *
* Davis Pan *
* 3/06/91 Douglas Wong, rename: setup.h to endef.h *
* removed extraneous variables *
* 3/21/91 J.Georges Fritsch introduction of the bit-stream *
* package. This package allows you *
* to generate the bit-stream in a *
* binary or ascii format *
* 3/31/91 Bill Aspromonte replaced the read of the SB matrix *
* by an "code generated" one *
* 5/10/91 W. Joseph Carter Ported to Macintosh and Unix. *
* Incorporated Jean-Georges Fritsch's *
* "bitstream.c" package. *
* Modified to strictly adhere to *
* encoded bitstream specs, including *
* "Berlin changes". *
* Modified user interface dialog & code *
* to accept any input & output *
* filenames desired. Also added *
* de-emphasis prompt and final bail-out *
* opportunity before encoding. *
* Added AIFF PCM sound file reading *
* capability. *
* Modified PCM sound file handling to *
* process all incoming samples and fill *
* out last encoded frame with zeros *
* (silence) if needed. *
* Located and fixed numerous software *
* bugs and table data errors. *
* 27jun91 dpwe (Aware Inc) Used new frame_params struct. *
* Clear all automatic arrays. *
* Changed some variable names, *
* simplified some code. *
* Track number of bits actually sent. *
* Fixed padding slot, stereo bitrate *
* Added joint-stereo : scales L+R. *
* 6/12/91 Earle Jennings added fix for MS_DOS in obtain_param *
* 6/13/91 Earle Jennings added stack length adjustment before *
* main for MS_DOS *
* 7/10/91 Earle Jennings conversion of all float to FLOAT *
* port to MsDos from MacIntosh completed*
* 8/ 8/91 Jens Spille Change for MS-C6.00 *
* 8/22/91 Jens Spille new obtain_parameters() *
*10/ 1/91 S.I. Sudharsanan, Ported to IBM AIX platform. *
* Don H. Lee, *
* Peter W. Farrett *
*10/ 3/91 Don H. Lee implemented CRC-16 error protection *
* newly introduced functions are *
* I_CRC_calc, II_CRC_calc and encode_CRC*
* Additions and revisions are marked *
* with "dhl" for clarity *
*11/11/91 Katherine Wang Documentation of code. *
* (variables in documentation are *
* surround by the # symbol, and an '*'*
* denotes layer I or II versions) *
* 2/11/92 W. Joseph Carter Ported new code to Macintosh. Most *
* important fixes involved changing *
* 16-bit ints to long or unsigned in *
* bit alloc routines for quant of 65535 *
* and passing proper function args. *
* Removed "Other Joint Stereo" option *
* and made bitrate be total channel *
* bitrate, irrespective of the mode. *
* Fixed many small bugs & reorganized. *
* 2/25/92 Masahiro Iwadare made code cleaner and more consistent *
* 8/07/92 Mike Coleman make exit() codes return error status *
* made slight changes for portability *
*19 aug 92 Soren H. Nielsen Changed MS-DOS file name extensions. *
* 8/25/92 Shaun Astarabadi Replaced rint() function with explicit*
* rounding for portability with MSDOS. *
* 9/22/92 jddevine@aware.com Fixed _scale_factor_calc() calls. *
*10/19/92 Masahiro Iwadare added info->mode and info->mode_ext *
* updates for AIFF format files *
* 3/10/93 Kevin Peterson In parse_args, only set non default *
* bit rate if specified in arg list. *
* Use return value from aiff_read_hdrs *
* to fseek to start of sound data *
* 7/26/93 Davis Pan fixed bug in printing info->mode_ext *
* value for joint stereo condition *
* 8/27/93 Seymour Shlien, Fixes in Unix and MSDOS ports, *
* Daniel Lauzon, and *
* Bill Truerniet *
**********************************************************************/
#ifdef MS_DOS
#include <dos.h>
#endif
#include "common.h"
#include "encoder.h"
#ifdef UNIX
#include <time.h>
#endif
/* Global variable definitions for "musicin.c" */
FILE *musicin;
Bit_stream_struc bs;
char *programName;
/* Implementations */
/************************************************************************
/*
/* obtain_parameters
/*
/* PURPOSE: Prompts for and reads user input for encoding parameters
/*
/* SEMANTICS: The parameters read are:
/* - input and output filenames
/* - sampling frequency (if AIFF file, will read from the AIFF file header)
/* - layer number
/* - mode (stereo, joint stereo, dual channel or mono)
/* - psychoacoustic model (I or II)
/* - total bitrate, irrespective of the mode
/* - de-emphasis, error protection, copyright and original or copy flags
/*
/************************************************************************/
void
obtain_parameters(fr_ps,psy,num_samples,original_file_name,encoded_file_name)
frame_params *fr_ps;
int *psy;
unsigned long *num_samples;
char original_file_name[MAX_NAME_SIZE];
char encoded_file_name[MAX_NAME_SIZE];
{
int j;
long int freq;
int model, brt;
char t[50];
IFF_AIFF pcm_aiff_data;
layer *info = fr_ps->header;
long soundPosition;
do {