home *** CD-ROM | disk | FTP | other *** search
-
- /* --- C ---
- ************************************************************************
- *
- * Filename : defs.h
- # Description : General definitions for all module - global variables
- * Part of : SECMPEG
- *
- * Version : 1.0
- * Language : C
- * For machine : SunOS 4.1.x, INTERACTIVE Unix 2.2.1, Linux, MS-DOS
- * Compile as : see Makefile
- *
- * Authors : Juergen Meyer, Frank Gadegast
- * Contact : jm@cs.tu-berlin.de, phade@cs.tu-berlin.de
- *
- ************************************************************************
- */
-
- #define TIME
- /*
- #define DEBUG
- #define INT_DEBUG
- #define HUFF_DEBUG
- #define CODEC_DEBUG
- #define DES_DEBUG
- #define IO_DEBUG
- #define MV_DEBUG
- #define MB_DEBUG
- */
-
- #define TRUE 1
- #define FALSE 0
-
- typedef unsigned char BYTE;
-
- #ifdef DOS
- typedef long INT;
- #else
- typedef int INT;
- #endif
-
- /* ----- CONSTANTS ----- */
-
- #define HEADER_INFO "SEC_MPEG"
- #define HEADER_ID "FGJM_TUB"
-
- #define IO_BUFFERSIZE 2 * 1024
- #define FRAME_BUFFERSIZE 9 * 1024
-
- #define DESBLOCK 8
- #define BLOCKSIZE 64
-
- #define P_FORBIDDEN 0
- #define P_INTRA 1
- #define P_PREDICTED 2
- #define P_INTERPOLATED 3
- #define P_DCINTRA 4
-
- #define M_DECODER 1
- #define HUFFMAN_ESCAPE 0x1bff
-
- #define MAX_MB 400 /* maximum of macroblocks allowed */
-
- #define M_ENCODE 1 /* general coding I and C */
- #define M_DECODE 2 /* genral decoding I and C */
- /* decoding with WRITE = checking */
- #define M_VALUE 3 /* generate I-value over whole stream */
- #define M_CENCRYPT 4 /* complete encryption of stream */
- #define M_CDECRYPT 5 /* complete decryption of stream */
-
- #define I_CRC16 0
- #define I_CRC16FULL 1
- #define I_CRC32 2
- #define I_CRC32FULL 3
-
- #define C_24BYTE 0
- #define C_HEADER 1
- #define C_HEADERMB 2
- #define C_INTRAHEADERMB 3
- #define C_INTRACOMPLETE 4
-
- /* ------ ERRORS ------ */
- #define ERROR_NONE 0
- #define ERROR_BOUNDS -1
- #define ERROR_HUFFMAN_READ -2
- #define ERROR_HUFFMAN_ENCODE -3
- #define ERROR_MARKER -4
- #define ERROR_INIT_FILE -5
- #define ERROR_UNRECOVERABLE -6
- #define ERROR_PREMATURE_EOF -7
- #define ERROR_MARKER_STRUCTURE -8
- #define ERROR_WRITE -9
- #define ERROR_READ -10
- #define ERROR_PARAMETER -11
- #define ERROR_MEMORY -12
- #define ERROR_EOF -13
- #define ERROR_INPUT -14
- #define ERROR_ASPECT_RATIO -15
- #define ERROR_PICTURE_RATE -16
- #define ERROR_BIT_RATE -17
- #define ERROR_FRAME_TYPE -18
- #define ERROR_BAD_PICTURE_TYPE -19
- #define ERROR_BAD_HEADER -20
-
- #define ERROR_NO_MPEGI -21
- #define ERROR_NO_MPEGHEADER -22
- #define ERROR_OPEN_INPUT -23
- #define ERROR_OPEN_OUTPUT -24
- #define ERROR_NO_MPEGINFO -25
- #define ERROR_STREAM -26
- #define ERROR_NO_SECMPEG -27
- #define ERROR_NOT_FGJM -28
- #define ERROR_NOTHING_TODO -29
- #define ERROR_INOTSUPPORTED -30
- #define ERROR_CNOTSUPPORTED -31
- #define ERROR_CRCFAILED -32
- #define ERROR_USAGE 1 /* usage (user-) fault */
-
- #ifdef NEED_ERRORS
- char *error_msg[] =
- {
- "no error", /* 0 */
- "input Values out of bounds", /* -1 */
- "Huffman Decoder finds bad code", /* -2 */
- "undefined value in encoder", /* -3 */
- "error Found in Marker", /* -4 */
- "cannot initialize files", /* -5 */
- "no recovery mode specified", /* -6 */
- "end of file unexpected", /* -7 */
- "bad Marker Structure", /* -8 */
- "cannot write output", /* -9 */
- "cannot write input", /* -10 */
- "system parameter error", /* -11 */
- "memory allocation failure", /* -12 */
- "", /* -13 */
- "", /* -14 */
- "", /* -15 */
- "", /* -16 */
- "", /* -17 */
- "", /* -18 */
- "", /* -19 */
- "", /* -20 */
- "no I-Frame where it should", /* -21 */
- "can't find secmpeg-header", /* -22 */
- "can't open input stream", /* -23 */
- "can't open output stream", /* -24 */
- "can't read secmpeg info", /* -25 */
- "abnormal end of stream", /* -26 */
- "no secmpeg-stream at all", /* -27 */
- "secmpeg-stream not from FGJM", /* -28 */
- "command-parsing fault", /* -29 */
- "integrity method not supported", /* -30 */
- "security method not supported", /* -31 */
- "CRC-check failed" /* -32 */
- };
- #endif
-
- #define MakeStructure(named_st) ((named_st *) malloc(sizeof(named_st)))
-
- typedef struct tag_DHUFF
- {
- INT NumberStates;
- INT state[512];
- }DHUFF;
-
- typedef struct tag_EHUFF
- {
- INT n;
- INT *Hlen;
- INT *Hcode;
- }EHUFF;
-
- typedef struct tag_SECUREHEADER
- {
- char Info[8];
- char Id[8];
- long IntegrityInfo;
- long ConfidentialityInfo;
- } SECUREHEADER;
-
- typedef struct tag_SECURETABLE
- {
- unsigned short Offset; /* BYTE !!!! */
- unsigned short Len;
- } SECURETABLE;
-
- typedef struct tag_INTEGRTABLE
- {
- unsigned long crc;
- unsigned long len;
- } INTEGRTABLE;
-
- typedef struct tag_SECUREINFO
- {
- short IntegrityDataSize;
- short ConfidentialityDataSize;
- unsigned long NextHeader;
- } SECUREINFO;
-
-