home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 2 / MECOMP-CD-II.iso / amiga / datatypes / mpegsystem_datatype / classdata.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-01  |  5.7 KB  |  188 lines

  1.  
  2. #ifndef CLASSDATA_H
  3. #define CLASSDATA_H 1
  4. /*
  5. **
  6. **  $VER: classdata.h 1.5 (1.6.98)
  7. **  mpegsystem.datatype 1.5
  8. **
  9. **  mpegsystem.datatype class data
  10. **
  11. **  Written 1997/1998 by Roland 'Gizzy' Mainz
  12. **
  13. */
  14.  
  15. /*****************************************************************************/
  16. /* MPEG system stream related structures */
  17.  
  18. /* Header lengths (in bytes) */
  19. #define START_CODE_LENGTH         (4)
  20. #define PACK_HEADER_LENGTH        (8)
  21. #define SYSTEM_HEADER_LENGTH     (14)
  22. #define PACKET_LENGTH_LENGTH      (2)
  23.  
  24. /* ISO stream codes seen */
  25. #define PACK_START_CODE           (1)
  26. #define SYSTEM_START_CODE         (2)
  27. #define ISO_11172_END_CODE        (3)
  28.  
  29. #define MAX_MPEG_STREAMS (48)
  30.  
  31. /* Stream level information on required buffer size */
  32. typedef struct Stream
  33. {
  34.    UBYTE stream_id;
  35.    UBYTE pad[ 3 ];
  36.    long  STD_buffer_bound_scale;      /* defined in ISO 11172 */
  37.    long  STD_buffer_size_bound;
  38. } STREAM;
  39.  
  40. /* Pack header information structure*/
  41. typedef struct Pack_header
  42. {
  43.    long SCR;
  44.    long mux_rate;                     /* defined in ISO 11172 */
  45. } PACK_header;
  46.  
  47. /* System header information structure*/
  48. typedef struct System_header
  49. {
  50.     ULONG  header_length;
  51.     long   rate_bound;                 /* defined in ISO 11172 */
  52.     long   audio_bound;
  53.     BOOL   fixed_flag;
  54.     BOOL   CSPS_flag;
  55.     BOOL   system_audio_lock_flag;
  56.     BOOL   system_video_lock_flag;
  57.     long   video_bound;
  58.     STREAM STD_buffer_info[ MAX_MPEG_STREAMS ];
  59. } SYSTEM_header;
  60.  
  61. /* Packet header information structure*/
  62. typedef struct Packet_header
  63. {
  64.    UBYTE  stream_id;
  65.    ULONG  packetlength;
  66.    long   STD_buffer_scale;    /* defined in ISO 11172 */
  67.    long   STD_buffer_size;
  68.    long   PTS;
  69.    long   DTS;
  70.    UBYTE *packet_ptr;
  71. } PACKET_header;
  72.  
  73. /*****************************************************************************/
  74.  
  75. #define MAX_DATA_BUF_LEN (65536UL)
  76.  
  77. /* This node holds file offset and size of a single system stream packet */
  78. struct PacketBlock
  79. {
  80.     struct MinNode node;
  81.     long           system_offset; /* file offset in system stream */
  82.     long           length;        /* packet length */
  83. };
  84.  
  85. /* A single stream */
  86. struct StreamList
  87. {
  88.     BPTR                sl_handle;           /* System-stream handle                                */
  89. /* The current file position is not used here because all "virtual" streams are mapped to
  90.  * one real stream, therefore our code uses "fdin_pos" instead of "sl_handle_pos".
  91.  * See also "dispatch.c", handler/ACTION_READ.
  92.  */
  93. #ifdef COMMENTED_OUT
  94.     LONG                sl_handle_pos;       /* Current file position of "sl_handle"                */
  95. #endif /* COMMENTED_OUT */
  96.     LONG                sl_size;             /* Full size of our stream                             */
  97.     struct MinList      sl_packetblocklist;  /* List of packets referring to this particular stream */
  98. };
  99.  
  100.  
  101. /*****************************************************************************/
  102. /* Handler specific structures */
  103.  
  104. /* FileHandle context */
  105. struct StreamHandle
  106. {
  107.     struct StreamList *sl;
  108.     LONG               currpos;      /* Current file position in our virtual stream handle */
  109. };
  110.  
  111. /* Startup message for demux process */
  112. struct StartupMsg
  113. {
  114.     struct Message             sm_Message; /* Embedded exec message */
  115.     UWORD                      sm_Pad0;
  116.     struct ClassBase          *sm_CB;      /* Pointer to the class library base */
  117.     struct MPEGSystemInstData *sm_msid;    /* Pointer to the instance data */
  118. };
  119.  
  120. /*****************************************************************************/
  121.  
  122. /* mpegsystem.datatype class instance data */
  123. struct MPEGSystemInstData
  124. {
  125.     /* Misc */
  126.     struct SignalSemaphore  msid_SigSem;          /* Instance data lock                              */
  127.     UWORD                   msid_Pad0;
  128.     APTR                    msid_Pool;
  129.     STRPTR                  msid_ProjectName;     /* Shortcut to DTA_Name                            */
  130.     BPTR                    msid_VerboseOutput;   /* Verbose output. -1L means: NOVERBOSE option set */
  131.  
  132.     /* Prefs */
  133.     BOOL                    msid_DoSyntax;
  134.     BOOL                    msid_DoDebug;
  135.     BOOL                    msid_IgnoreErrors;
  136.     UWORD                   msid_Pad1;
  137.  
  138.     /* Video stream related */
  139.     Object                 *msid_CurrVideo;
  140.     ULONG                   msid_TicksPerFrame;
  141.  
  142.     /* Audio stream related */
  143.     Object                 *msid_CurrAudio;
  144.     UBYTE                  *msid_Sample;
  145.     ULONG                   msid_SampleLength;
  146.     ULONG                   msid_Period;
  147.     ULONG                   msid_SamplesPerFrame;
  148.  
  149.     /* Virtual stream splitter handler */
  150.     struct
  151.     {
  152.       struct StartupMsg  Startup;   /* handler startup message      */
  153.       struct Process    *Process;   /* handler process              */
  154.       LONG               OpenCount; /* handler open count           */
  155.       struct MsgPort    *mp;        /* reply port for async packets */
  156.       struct MinList     pktpool;   /* DOS_STDPKT pool which is used within the handler to avoid (Alloc|Free)DOSObject */
  157.     } Handler;
  158.  
  159.     /* Demultiplexer scan context */
  160.     struct
  161.     {
  162.       jmp_buf           exit_buf;
  163.       LONG              retval,
  164.                         retval2;
  165.  
  166.       BOOL              system_found; /* get_next_start_code static */
  167.  
  168.       long              curr_file_pos;
  169.       UBYTE            *curr_file_pos_in_buffer;
  170.  
  171.       UBYTE            *raw_data_buf;
  172.       UBYTE            *raw_data_buf_ptr;
  173.       long              raw_data_buf_len;
  174.       BPTR              fdin;
  175.       LONG              fdin_pos;
  176.       long              M,
  177.                         N;
  178.  
  179.       struct StreamList fd_demuxa[ MAX_MPEG_STREAMS ];
  180.     } Demux;
  181. };
  182.  
  183.  
  184. /*****************************************************************************/
  185.  
  186. #endif /* !CLASSDATA_H */
  187.  
  188.