home *** CD-ROM | disk | FTP | other *** search
/ MPEG Toolkit / MPEG Toolkit.iso / dos / secmpeg3 / defs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-01  |  5.4 KB  |  201 lines

  1.  
  2. /* --- C ---
  3. ************************************************************************
  4. *
  5. *    Filename    : defs.h
  6. #    Description : General definitions for all module - global variables
  7. *    Part of     : SECMPEG
  8. *
  9. *    Version     : 1.0
  10. *    Language    : C
  11. *    For machine : SunOS 4.1.x, INTERACTIVE Unix 2.2.1, Linux, MS-DOS
  12. *    Compile as  : see Makefile
  13. *
  14. *    Authors     : Juergen Meyer, Frank Gadegast
  15. *    Contact     : jm@cs.tu-berlin.de, phade@cs.tu-berlin.de
  16. *
  17. ************************************************************************
  18. */
  19.  
  20. #define TIME
  21. /*
  22. #define DEBUG
  23. #define INT_DEBUG
  24. #define HUFF_DEBUG
  25. #define CODEC_DEBUG
  26. #define DES_DEBUG
  27. #define IO_DEBUG
  28. #define MV_DEBUG
  29. #define MB_DEBUG
  30. */
  31.  
  32. #define TRUE  1
  33. #define FALSE 0
  34.  
  35. typedef unsigned char BYTE;
  36.  
  37. #ifdef DOS
  38. typedef long INT;
  39. #else
  40. typedef int  INT;
  41. #endif
  42.  
  43. /* ----- CONSTANTS ----- */
  44.  
  45. #define HEADER_INFO        "SEC_MPEG"
  46. #define HEADER_ID          "FGJM_TUB"
  47.  
  48. #define IO_BUFFERSIZE      2 * 1024
  49. #define FRAME_BUFFERSIZE   9 * 1024
  50.  
  51. #define DESBLOCK           8
  52. #define BLOCKSIZE          64
  53.  
  54. #define P_FORBIDDEN        0
  55. #define P_INTRA            1
  56. #define P_PREDICTED        2
  57. #define P_INTERPOLATED     3
  58. #define P_DCINTRA          4
  59.  
  60. #define M_DECODER          1
  61. #define HUFFMAN_ESCAPE     0x1bff
  62.  
  63. #define MAX_MB             400     /* maximum of macroblocks allowed */
  64.  
  65. #define M_ENCODE           1       /* general coding I and C */
  66. #define M_DECODE           2       /* genral decoding I and C */
  67.                                    /* decoding with WRITE = checking */
  68. #define M_VALUE            3       /* generate I-value over whole stream */
  69. #define M_CENCRYPT         4       /* complete encryption of stream */
  70. #define M_CDECRYPT         5       /* complete decryption of stream */
  71.  
  72. #define I_CRC16            0
  73. #define I_CRC16FULL        1
  74. #define I_CRC32            2
  75. #define I_CRC32FULL        3
  76.  
  77. #define C_24BYTE           0
  78. #define C_HEADER           1
  79. #define C_HEADERMB         2
  80. #define C_INTRAHEADERMB    3
  81. #define C_INTRACOMPLETE    4
  82.  
  83. /* ------ ERRORS ------ */
  84. #define ERROR_NONE               0
  85. #define ERROR_BOUNDS            -1
  86. #define ERROR_HUFFMAN_READ      -2
  87. #define ERROR_HUFFMAN_ENCODE    -3
  88. #define ERROR_MARKER            -4
  89. #define ERROR_INIT_FILE         -5
  90. #define ERROR_UNRECOVERABLE     -6
  91. #define ERROR_PREMATURE_EOF     -7
  92. #define ERROR_MARKER_STRUCTURE  -8
  93. #define ERROR_WRITE             -9
  94. #define ERROR_READ             -10
  95. #define ERROR_PARAMETER        -11
  96. #define ERROR_MEMORY           -12
  97. #define ERROR_EOF              -13
  98. #define ERROR_INPUT            -14
  99. #define ERROR_ASPECT_RATIO     -15
  100. #define ERROR_PICTURE_RATE     -16
  101. #define ERROR_BIT_RATE         -17
  102. #define ERROR_FRAME_TYPE       -18
  103. #define ERROR_BAD_PICTURE_TYPE -19
  104. #define ERROR_BAD_HEADER       -20
  105.  
  106. #define ERROR_NO_MPEGI         -21
  107. #define ERROR_NO_MPEGHEADER    -22
  108. #define ERROR_OPEN_INPUT       -23
  109. #define ERROR_OPEN_OUTPUT      -24
  110. #define ERROR_NO_MPEGINFO      -25
  111. #define ERROR_STREAM           -26
  112. #define ERROR_NO_SECMPEG       -27
  113. #define ERROR_NOT_FGJM         -28
  114. #define ERROR_NOTHING_TODO     -29
  115. #define ERROR_INOTSUPPORTED    -30
  116. #define ERROR_CNOTSUPPORTED    -31
  117. #define ERROR_CRCFAILED        -32
  118. #define ERROR_USAGE              1  /* usage (user-) fault */
  119.  
  120. #ifdef NEED_ERRORS
  121. char *error_msg[] = 
  122. {
  123.     "no error",                       /* 0   */
  124.     "input Values out of bounds",     /* -1  */
  125.     "Huffman Decoder finds bad code", /* -2  */
  126.     "undefined value in encoder",     /* -3  */
  127.     "error Found in Marker",          /* -4  */
  128.     "cannot initialize files",        /* -5  */
  129.     "no recovery mode specified",     /* -6  */
  130.     "end of file unexpected",         /* -7  */
  131.     "bad Marker Structure",           /* -8  */
  132.     "cannot write output",            /* -9  */
  133.     "cannot write input",             /* -10 */
  134.     "system parameter error",         /* -11 */
  135.     "memory allocation failure",      /* -12 */
  136.     "",                               /* -13 */
  137.     "",                               /* -14 */
  138.     "",                               /* -15 */
  139.     "",                               /* -16 */
  140.     "",                               /* -17 */
  141.     "",                               /* -18 */
  142.     "",                               /* -19 */
  143.     "",                               /* -20 */
  144.     "no I-Frame where it should",     /* -21 */
  145.     "can't find secmpeg-header",      /* -22 */
  146.     "can't open input stream",        /* -23 */
  147.     "can't open output stream",       /* -24 */
  148.     "can't read secmpeg info",        /* -25 */
  149.     "abnormal end of stream",         /* -26 */
  150.     "no secmpeg-stream at all",       /* -27 */
  151.     "secmpeg-stream not from FGJM",   /* -28 */
  152.     "command-parsing fault",          /* -29 */
  153.     "integrity method not supported", /* -30 */
  154.     "security method not supported",  /* -31 */
  155.     "CRC-check failed"                /* -32 */
  156. };
  157. #endif
  158.  
  159. #define MakeStructure(named_st) ((named_st *) malloc(sizeof(named_st)))
  160.  
  161. typedef struct tag_DHUFF
  162. {
  163.   INT NumberStates;
  164.   INT state[512];
  165. }DHUFF;
  166.  
  167. typedef struct tag_EHUFF
  168. {
  169.   INT n;
  170.   INT *Hlen;
  171.   INT *Hcode;
  172. }EHUFF;
  173.  
  174. typedef struct tag_SECUREHEADER
  175. {
  176.     char    Info[8];
  177.     char    Id[8];
  178.     long    IntegrityInfo;
  179.     long    ConfidentialityInfo;
  180. } SECUREHEADER;
  181.  
  182. typedef struct tag_SECURETABLE
  183. {
  184.     unsigned short   Offset;          /* BYTE !!!! */
  185.     unsigned short   Len;
  186. } SECURETABLE;
  187.  
  188. typedef struct tag_INTEGRTABLE
  189. {
  190.     unsigned long crc;
  191.     unsigned long len;
  192. } INTEGRTABLE;
  193.  
  194. typedef struct tag_SECUREINFO
  195. {
  196.     short          IntegrityDataSize;
  197.     short          ConfidentialityDataSize;
  198.     unsigned long  NextHeader;
  199. } SECUREINFO;
  200.  
  201.