Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

363 lines
12 KiB

  1. //
  2. // MODULE : COMMON.H
  3. // PURPOSE : Common definitions and functions
  4. // AUTHOR : JBS Yadawa
  5. // CREATED : 7/20/96
  6. //
  7. //
  8. // Copyright (C) 1996 SGS-THOMSON Microelectronics
  9. //
  10. //
  11. // REVISION HISTORY :
  12. //
  13. // DATE :
  14. //
  15. // COMMENTS :
  16. //
  17. #ifndef __COMMON_H
  18. #define __COMMON_H
  19. //----------------------------------------------------------------------------
  20. // COMMON.H
  21. //----------------------------------------------------------------------------
  22. // Description : small description of the goal of the module
  23. //----------------------------------------------------------------------------
  24. // Copyright SGS Thomson Microelectronics ! Version alpha ! Jan 1st, 1995
  25. //----------------------------------------------------------------------------
  26. //----------------------------------------------------------------------------
  27. // Include files
  28. //----------------------------------------------------------------------------
  29. #include "strmini.h"
  30. #include "stdefs.h"
  31. #include "board.h"
  32. #include "staudio.h"
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. //----------------------------------------------------------------------------
  37. // Exported Constants
  38. //----------------------------------------------------------------------------
  39. #define EVAL3520A
  40. #define ON TRUE
  41. #define OFF FALSE
  42. // Card related definitions
  43. //#define LSB 0x100 // to reach lsb register (A0 = 1)
  44. #define LSB 1 // to reach lsb register (A0 = 1)
  45. #define DATA_IN 0x18
  46. //temp JBS
  47. #define ERROR_CARD_NOT_FOUND 1
  48. #define ERROR_NOT_ENOUGH_MEMORY 2
  49. #define ERROR_COMMAND_NOT_IMPLEMENTED 3
  50. #define DEFAULT_BASEIO 0x180
  51. #define ERR_SKIP 0x116
  52. #define TRAP _asm int 3;
  53. // Audio States
  54. #define AUDIO_POWER_UP 0 /* After reset */
  55. #define AUDIO_INIT 1 /* Initialisation + test of the decoders */
  56. #define AUDIO_STC_INIT 2 /* STC of audio decoder initialized */
  57. #define AUDIO_DECODE 3 /* Normal decode */
  58. #define AUDIO_FAST 4 /* "fast forward": use fast variable */
  59. #define AUDIO_SLOW 5 /* Slow down mode: use tempo variable */
  60. #define AUDIO_STEP 6 /* Used fo Step by step decoding */
  61. #define AUDIO_PAUSE 7 /* Audio decoder has been pause */
  62. #define CTRL_AUDIO 0
  63. #define CTRL_VIDEO 1
  64. #define CTRL_BOTH 2
  65. // STD definitions
  66. #define STAUDIO 45
  67. #define STVIDEO 35
  68. #define STUFF 0
  69. #define BOTH_AV 55
  70. // Buffer Constants
  71. //YOUUSS
  72. //#define MAX_HEAD_SIZE 206 // Maximum Header Size is 206
  73. //#define BUFFER_SIZE 16384 // Buffer Size is 16 kbytes
  74. #define MAX_HEAD_SIZE 206 // Maximum Header Size is 206
  75. #define BUFFER_SIZE 16384 // Buffer Size is 16 kbytes
  76. #define AUDIO_BUFFER_SIZE 4096 // Audio Buffer Size is 4 kbytes
  77. #define VIDEO_BUFFER_SIZE 16384 // Buffer Size is 16 kbytes
  78. #define MAX_BUF_SIZE BUFFER_SIZE + MAX_HEAD_SIZE // Maximum Buffer Size is 16 kbytes + 206 bytes
  79. /* define the states of the video decoder */
  80. typedef enum tagState {
  81. StatePowerup=0,
  82. StateInit,
  83. StateStartup,
  84. StatePause,
  85. StateDecode,
  86. StateFast,
  87. StateSlow,
  88. StateStep,
  89. StateWaitForDTS
  90. }STATE;
  91. typedef enum tagPlayMode {
  92. PlayModeSlow = 0,
  93. PlayModeNormal,
  94. PlayModeFast
  95. }PLAYMODE;
  96. #define NO_ERROR 0 /* No error after the test */
  97. #define NOT_DONE 1 /* requested action not done */
  98. // ERRORS
  99. /* Control related messages */
  100. #define NOT_INITIALIZED 0x10 /* Control sequencer not initialized */
  101. #define NO_FILE 0x11 /* No file opened */
  102. #define ERRCLASS 0x12 /* Error for creation of the board class */
  103. #define ERRCONTCLASS 0x13 /* Error for creation of the control class */
  104. /* Video related messages */
  105. #define NEW_ERR_V 0x100 /* Not possible to allocate Video instance */
  106. #define BAD_REG_V 0x101 /* Bad access to video registers */
  107. #define BAD_MEM_V 0x102 /* Bad memory test */
  108. #define NO_IT_V 0x103 /* No video interrupt */
  109. #define SMALL_BUF 0x104
  110. #define TEMP_REF 0x105
  111. #define FRAME_RATE 0x106
  112. #define PICT_HEAD 0x107
  113. #define FULL_BUF 0x108
  114. #define TIME_OUT 0x109
  115. #define BUF_EMPTY 0x10A
  116. #define MAIN_PROF 0x10B
  117. #define CHROMA 0x10C
  118. #define HIGH_CCIR601 0x10D
  119. #define HIGH_BIT_RATE 0x10E
  120. #define DC_PREC 0x10F
  121. #define BAD_EXT 0x110
  122. #define S_C_ERR 0x111
  123. #define DECCRASH 0x112 /* Decoder crashed after time-out */
  124. #define NEW_ERR_FIF 0x113 /* Not possible to allocate Video instance */
  125. #define ERR_FIFO_FULL 0x114
  126. #define ERR_FIFO_EMPTY 0x115
  127. /* Audio related messages */
  128. #define NEW_ERR_A 0x200 /* Not possible to allocate Audio instance */
  129. #define BAD_REG_A 0x201 /* Bad access to audio registers */
  130. #define NO_IT_A 0x202 /* No audio interrupt */
  131. #define NEW_ERR_D 0x300 /* Not possible to allocate Demux instance */
  132. #define FILE_NOT_FOUND 0x301
  133. #define NOT_ENOUGH_RAM 0x302 /* Not enough RAM available to load the bit stream */
  134. typedef enum tagStreamType {
  135. VIDEO_STREAM=0x303 ,
  136. AUDIO_STREAM,
  137. VIDEO_PACKET,
  138. AUDIO_PACKET,
  139. VIDEO_PES,
  140. AUDIO_PES,
  141. SYSTEM_STREAM,
  142. DUAL_PES,
  143. DUAL_ES
  144. } STREAMTYPE;
  145. #define END_OF_FILE 0x30C /* all the file has been read */
  146. #define END_OF_AUDIO_FILE 0x340 /* all the audio file has been read */
  147. #define END_OF_VIDEO_FILE 0x380 /* all the video file has been read */
  148. #define OK 0x30D /* eof not reached */
  149. #define BAD_STREAM 0x30E /* Not valid stream detected */
  150. #define TOO_MANY_FILES 0x30F /* NbFiles > 2 */
  151. #define TOO_FEW_FILES 0x310 /* NbFiles < 1 */
  152. #define VIDEO_FILE_NOT_FOUND 0x311 /* Cannot open Video File */
  153. #define AUDIO_FILE_NOT_FOUND 0x312 /* Cannot open Video File */
  154. /* Card related messages */
  155. #define NEW_ERR_CARD 0x400 /* Not possible to allocate Card instance */
  156. #define BAD_CARD_COM 0x401 /* Access to the command reg on board not possible */
  157. #define BAD_CARD_TIME 0x402 /* Access to the time base not possible */
  158. #define BAD_IT_VAL 0x403 /* requested interrupt not supported on this board */
  159. /*MPEG Stream Related messages*/
  160. #define NEW_ERR_M 0x500 /* Not possible to allocate Mpeg instance */
  161. typedef struct bitstream_info
  162. {
  163. BOOL modeMPEG2; /* mpeg2 - TRUE = MPEG2 */
  164. BYTE progSeq; /* progressive_seq */
  165. BYTE firstGOP[30]; /* gop_struct[30] - first GOP structure */
  166. WORD countGOP; /* count_gop */
  167. WORD horSize; /* hor_size */
  168. WORD verSize; /* vert_size */
  169. WORD horDimension; /* hor_dim */
  170. WORD verDimension; /* vert_dim */
  171. WORD pixelRatio; /* pixel_ratio */
  172. WORD frameRate; /* frame_rate */
  173. WORD displayMode; /* 1 if NTSC 0 if PAL */
  174. DWORD bitRate; /* bit_rate - bit rate from sequence header */
  175. } BITSTREAM, *P_BITSTREAM;
  176. typedef struct image
  177. {
  178. BYTE pict_type;
  179. BYTE pict_struc;
  180. WORD tempRef;
  181. BYTE first_field;
  182. BYTE nb_display_field;
  183. int pan_hor_offset[3];
  184. int pan_vert_offset[3];
  185. int buffer;
  186. DWORD dwPTS;
  187. BOOL validPTS;
  188. } PICTURE, *P_PICTURE;
  189. typedef struct
  190. {
  191. BYTE Skip ; // 2 bit field equivalent to CMD.SKP[1.0]
  192. BYTE Cmv; //1 bit
  193. BYTE Tff; //1 bit
  194. BYTE Rpt; //1 bit
  195. BYTE Exe; //1 bit
  196. BYTE Ovw; //1 bit
  197. BYTE Ffh; //4 bits
  198. BYTE Bfh; //4 bits
  199. BYTE Pct; //2 bits
  200. BYTE Seq; //1 bit
  201. BYTE Ivf;
  202. BYTE Azz;
  203. BYTE Qst;
  204. BYTE Frm;
  205. BYTE Dcp; //2 bits
  206. BYTE Pst; //2 bits
  207. BYTE Ffv; //2 bits
  208. BYTE Bfv; //4 bits
  209. BYTE Mp2;//MP2;
  210. } INSTRUCTION, *PINSTRUCTION;
  211. typedef struct {
  212. BYTE Ppr1; /* VID_PPR1 register value 3520a*/
  213. BYTE Ppr2; /* VID_PPR2 register value 3520a*/
  214. BYTE Tis; /* VID_TIS register value 3520a*/
  215. BYTE Pfh; /* VID_PFH register value 3520a*/
  216. BYTE Pfv; /* VID_PFV register value 3520a*/
  217. BOOL InvertedField; /* True when start dec on incorrect pol in to save R/2P in 3520a*/
  218. BYTE FistVsyncAfterVbv;// State variable gives first vsync to vbv position
  219. WORD Ccf ; /* CTL register value*/
  220. BOOL HalfRes;
  221. WORD Ins1; /* INS1 register value*/
  222. WORD Ins2; /* INS2 register value*/
  223. WORD Cmd ; /* CMD register value*/
  224. INSTRUCTION NextInstr; /* Next Instruction ( contains all fields of instruction) */
  225. INSTRUCTION ZeroInstr; /* Next Instruction ( contains all fields of instruction) */
  226. WORD Ctl ; /* CTL register value*/
  227. WORD Gcf ; /* GCF register value*/
  228. WORD VideoBufferSize;// Size of Video Bit Buffer
  229. WORD AudioBufferSize;// Size of Audio Bit Buffer
  230. WORD VideoState;
  231. WORD ActiveState;
  232. WORD DecodeMode;
  233. BITSTREAM StreamInfo;
  234. BOOL notInitDone; /* not_init_done - TRUE = still init'ing */
  235. BOOL useSRC; /* switch_SRC - use sample rate converter */
  236. BYTE currField; /* cur_field */
  237. BYTE fieldMode; /* field_mode */
  238. BOOL displaySecondField; /* change display to second in step by step */
  239. BOOL perFrame; /* indicates step by step decoding */
  240. // BOOL pictureDecoded;
  241. BOOL fastForward; /* fast - TRUE = decode fast */
  242. BOOL VsyncInterrupt; /* true = Vsync interrupt, FALSE = other interrupt */
  243. BOOL FirstDTS;
  244. WORD VsyncNumber; /* number of consecutive Vsync without Dsync */
  245. BYTE skipMode; /* skip - 0, 1, 2, 3 */
  246. WORD NotSkipped;
  247. WORD intMask; /* maskit_3500 - interrupt mask */
  248. WORD intStatus; /* int_stat_reg - interrupt status register */
  249. WORD hdrFirstWord; /* read_val - Contain the read data fifo */
  250. WORD hdrNextWord; /* shift_val - Special case of header position = 8 */
  251. WORD GOPindex; /* gop_index */
  252. WORD vbvReached; /* vbv_done */
  253. WORD vbvDelay; /* vbv_delay */
  254. WORD decSlowDown; /* tempo - slow down the decoder */
  255. WORD currTempRef; /* temp_ref - display temporal reference */
  256. WORD frameStoreAttr; /* attr_fs */
  257. WORD Xdo; /* horizontal origin */
  258. WORD Ydo; /* vertical origin */
  259. WORD Xd1; /* horizontal end */
  260. WORD Yd1; /* vertical end */
  261. WORD vbvBufferSize; /* vbv_buffer_size */
  262. WORD currCommand; /* command */
  263. WORD seqDispExt; /* seq_display */
  264. int currDCF; /* DCF_val */
  265. int halfVerFilter; /* DCF_val_Half */
  266. int fullVerFilter; /* DCF_val_Full */
  267. BYTE hdrHours; /* hours */
  268. BYTE hdrMinutes; /* minutes */
  269. BYTE hdrSeconds; /* seconds */
  270. BYTE pictTimeCode; /* time_code_picture */
  271. BYTE hdrPos; /* point_posit - position of header to read */
  272. WORD decAddr; /* adcard_dec - decoder board address */
  273. WORD needDataInBuff; /* empty */
  274. WORD errCode; /* err_nu */
  275. WORD defaultTbl; /* def_tab */
  276. WORD nextInstr1; /* make_ins1 */
  277. WORD nextInstr2; /* make_ins2 */
  278. WORD currPictCount; /* pict_count */
  279. WORD latestPanHor; /* latest_pan_hor */
  280. WORD latestPanVer; /* latest_pan_vert */
  281. int pictDispIndex; /* cnt_display */
  282. WORD LastPipeReset; /* last pipe reset in case of error */
  283. WORD LastBufferLevel;/* last bit buffer level */
  284. DWORD LastCdCount; /* last CD count read */
  285. DWORD LastScdCount; /* last SCD count */
  286. WORD BufferA; /* 1st frame storage address*/
  287. WORD BufferB; /* 2d frame storage address*/
  288. WORD BufferC; /* 3d frame storage address*/
  289. PICTURE pictArray[4]; /* pict_buf[4] */
  290. P_PICTURE pDecodedPict; /* decoded_pict_ptr */
  291. P_PICTURE pCurrDisplay; /* cur_display_ptr */
  292. P_PICTURE pNextDisplay; /* next_display_ptr */
  293. } VIDEO, *PVIDEO;
  294. typedef struct
  295. {
  296. WORD OriginX;
  297. WORD OriginY;
  298. WORD EndX;
  299. WORD EndY;
  300. BOOL bAudioDecoding;
  301. BOOL bVideoDecoding;
  302. VIDEO Video;
  303. AUDIO Audio;
  304. PVIDEO pVideo;
  305. PAUDIO pAudio;
  306. }CARD, *PCARD;
  307. void FARAPI Delay(DWORD Microseconds);
  308. typedef struct {
  309. WORD CtrlState;
  310. WORD ErrorMsg;
  311. WORD DecodeMode; /* defines the way decoding is performed */
  312. WORD SlowRatio; /* defines the slow down ratio (if any) */
  313. WORD ActiveState; /* Memorise the active state in case of pause */
  314. BOOL AudioOn;
  315. BOOL VideoOn;
  316. } CTRL, *PCTRL;
  317. extern PCARD pCard;
  318. #ifdef __cplusplus
  319. }
  320. #endif
  321. //------------------------------- End of File --------------------------------
  322. #endif // #ifndef __COMMON_H
  323.