📄 common.h
字号:
/********************************************************************** * Copyright (c) 1995 MPEG/audio software simulation group * All Rights Reserved * $Id: common.h,v 1.1 1996/04/18 03:39:59 rowlands Exp $ * * MPEG/audio coding/decoding software, work in progress * NOT for public distribution until verified and approved by the * MPEG/audio committee. * * $Log: common.h,v $ * Revision 1.1 1996/04/18 03:39:59 rowlands * Initial revision * * Revision 1.4 1995/04/06 05:49:24 rowlands * Moved machine #define to makefile * * Revision 1.3 1995/04/06 05:01:42 rowlands * Ran decoder through protoize to convert to ANSI C. * * Revision 1.2 1995/04/06 04:56:00 rowlands * Added header, RCS info and cleaned up prototypes in initial revision. * **********************************************************************//********************************************************************** * VERSION 2.5 * * changes made since last update: * * date programmers comment * * 2/25/91 Douglas Wong start of version 1.0 records * * 3/06/91 Douglas Wong rename setup.h to dedef.h * * removed extraneous variables * * removed window_samples (now part of * * filter_samples) * * 3/07/91 Davis Pan changed output file to "codmusic" * * 5/10/91 Vish (PRISM) Ported to Macintosh and Unix. * * Incorporated new "out_fifo()" which * * writes out last incomplete buffer. * * Incorporated all AIFF routines which * * are also compatible with SUN. * * Incorporated user interface for * * specifying sound file names. * * Also incorporated user interface for * * writing AIFF compatible sound files. * * 27jun91 dpwe (Aware) Added musicout and &sample_frames as * * args to out_fifo (were glob refs). * * Used new 'frame_params' struct. * * Clean,simplify, track clipped output * * and total bits/frame received. * * 7/10/91 Earle Jennings changed to floats to FLOAT * *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 * * buffer_CRC and recover_CRC_error * * Additions and revisions are marked * * with "dhl" for clarity * * 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. * ********************************************************************** * * * * * MPEG/audio Phase 2 coding/decoding multichannel * * * * Version 1.0 * * * * 7/27/93 Susanne Ritscher, IRT Munich * * * * thanks to * * Ralf Schwalbe, Telekom FTZ Berlin * * Heiko Purnhagen, Uni Hannover * * * * Version 2.0 * * * * 8/27/93 Susanne Ritscher, IRT Munich * * Channel-Switching is working * * * * Version 2.1 * * * * 9/1/93 Susanne Ritscher, IRT Munich * * all channels normalized * * * * Version 3.0 * * * * 06/16/94 Ralf Schwalbe, Telekom FTZ Berlin * * all sources and variables adapted due to MPEG-2 - * * DIS from March 1994 * * - dematrix and denormalize procedure * * - new tc - allocation (0-7) * * - some new structures and variables as a basis * * for further decoding modes * ********************************************************************** * * * Version 1.0 Shareware * * * * 07/12/94 Ralf Schwalbe, Telekom FTZ Berlin * * Tel: +49 30 6708 2406 * * Fax: +49 30 6774 539 * * * * 04/11/94 Ralf Schwalbe. Telekom FTZ Berlin * * - decoding extension bitstream * * - some new subroutines, globale variables and * * structures (important to handle the ext. bitst.)* * - changed all functions to ANSI-C funktion header * * - corrected some bugs to decode bitstreams > 512kB* * * * Version 1.1 Shareware * * * * 07/12/94 Ralf Schwalbe, Telekom FTZ Berlin * * Tel: +49 30 6708 2406 * * Fax: +49 30 6774 539 * * * **********************************************************************/#define VERSION "1.1" /* R.S for Shareware *//************************************************************************* Global Conditional Compile Switches************************************************************************//*#define PRINTOUT*//*#define UNIX */ /* Unix conditional compile switch *//*#define MACINTOSH */ /* Macintosh conditional compile switch *//*#define MS_DOS */ /* IBM PC conditional compile switch Microsoft C ver. 6.0 */#ifdef UNIX#define TABLES_PATH "tables/" /* to find data files *//* name of environment variable holding path of table files */#define MPEGTABENV "MPEGTABLES"#define PATH_SEPARATOR "/" /* how to build paths */#define PROTO_ARGS /* unix gcc uses arg. prototypes */#endif /* UNIX */#ifdef MACINTOSH/* #define TABLES_PATH ":tables:" /* where to find data files */#define PROTO_ARGS /* Mac uses argument prototypes */#endif /* MACINTOSH */#ifdef MS_DOS#define PROTO_ARGS /* DOS uses argument prototypes */#endif /* MS_DOS *//* MS_DOS and VMS do not define TABLES_PATH, so OpenTableFile will default to finding the data files in the default directory *//************************************************************************* Global Include Files************************************************************************/#include <stdio.h>#include <string.h>#include <math.h>#ifdef UNIX#include <unistd.h> /* removed 92-08-05 shn */#include <stdlib.h> /* put in 92-08-05 shn */#endif /* UNIX */#ifdef MACINTOSH#include <stdlib.h>#include <console.h>#endif /* MACINTOSH */#ifdef MS_DOS/* #include <alloc.h> */ /* removed 92-07-08 sr */#include <malloc.h> /* put in 92-07-08 sr *//* #include <mem.h> */ /* removed 92-07-08 sr */#include <stdlib.h>#endif /* MS_DOS */#define SEEK_SET 0#define SEEK_CUR 1#define SEEK_END 2/************************************************************************* Global Definitions************************************************************************/extern int pred_coef_table[8][14]; /* def. in decode.c */extern int read_ext_header,ext_error;extern unsigned long frameNum,ext_total;/* General Definitions */#ifdef MS_DOS#define FLOAT double#else#define FLOAT float#endif#define FALSE 0#define TRUE (!FALSE)#define NULL_CHAR '\0'#define MAX_U_32_NUM 0xFFFFFFFF#define PI 3.14159265358979#define PI4 PI/4#define PI64 PI/64#define LN_TO_LOG10 0.2302585093#define VOL_REF_NUM 0#define MPEG_AUDIO_ID 1#define MAC_WINDOW_SIZE 24#define MONO 1#define STEREO 2#define BITS_IN_A_BYTE 8#define WORD 16#define MAX_NAME_SIZE 81#define SBLIMIT 32#define FFT_SIZE 1024#define HAN_SIZE 512#define SCALE_BLOCK 12#define SCALE_RANGE 64#define SCALE 32768.0#define CRC16_POLYNOMIAL 0x8005/* Sync - Word for multichannel extern bitstream */#define EXT_SYNCWORD 0x7ff/* MPEG Header Definitions - Mode Values */#define MPG_MD_STEREO 0#define MPG_MD_JOINT_STEREO 1#define MPG_MD_DUAL_CHANNEL 2#define MPG_MD_MONO 3#define MPG_MD_NONE 4/* Multi-channel Definitions - Mode Values */#define MPG_MC_STEREO 0#define MPG_MC_NONE 6/* AIFF Definitions */#ifndef MS_DOS#define IFF_ID_FORM "FORM" /* HP400 unix v8.0: double qoutes 1992-07-24 shn */#define IFF_ID_AIFF "AIFF"#define IFF_ID_COMM "COMM"#define IFF_ID_SSND "SSND"#define IFF_ID_MPEG "MPEG"#else#define IFF_ID_FORM "FORM"#define IFF_ID_AIFF "AIFF"#define IFF_ID_COMM "COMM"#define IFF_ID_SSND "SSND"#define IFF_ID_MPEG "MPEG"#endif/* "bit_stream.h" Definitions */#define MINIMUM 4 /* Minimum size of the buffer in bytes */#define MAX_LENGTH 32 /* Maximum length of word written or read from bit stream */#define READ_MODE 0#define WRITE_MODE 1#define ALIGNING 8#define BINARY 0#define ASCII 1#define BS_FORMAT ASCII /* BINARY or ASCII = 2x bytes */#define BUFFER_SIZE 4096#define MIN(A, B) ((A) < (B) ? (A) : (B))#define MAX(A, B) ((A) > (B) ? (A) : (B))/************************************************************************* Global Type Definitions************************************************************************//* Structure for Reading Layer II Allocation Tables from File */typedef struct { unsigned int steps; unsigned int bits; unsigned int group; unsigned int quant;} sb_alloc, *alloc_ptr;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -