~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to mpeglib/lib/mpegplay/mpegSystemStream.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#define __MPEGSYSTEMSTREAM_H
15
15
 
16
16
 
17
 
#include <stdlib.h>
18
 
#include "../input/inputPlugin.h"
19
 
#include "mpegSystemHeader.h"
20
 
 
21
 
  
22
 
 
23
 
#define FLOAT_0x10000 (double)((unsigned long)1 << 16)
24
 
  
25
 
  
26
 
// MPEG2 PACK HEADER
27
 
// SCRbase and SCRext
28
 
//                  32 .......................................0 9.........0
29
 
// [PACK_START_CODE][01---1--][--------][-----1--][--------][-----1--][-------1
30
 
 
31
 
#define ui64 unsigned long
32
 
#define ui32 unsigned int
33
 
#define i64  long
34
 
#define i32  int
35
 
 
36
 
#define MPEG1_CLK_REF  (i64)90000
37
 
#define MPEG2_CLK_REF  (i64)27000000
38
 
 
39
 
#define ZERO                    (i64)0
40
 
#define GET_SCRBASE(buf) ( ((ui64)buf[4]&0xF8)>>3   |  \
41
 
                            (ui64)buf[3]<<5         |  \
42
 
                           ((ui64)buf[2]&0x03)<<13  |  \
43
 
                           ((ui64)buf[2]&0xF8)<<12  |  \
44
 
                            (ui64)buf[1]<<20        |  \
45
 
                           ((ui64)buf[0]&0x03)<<28  |  \
46
 
                            (ui64)buf[0]&0x38 <<27 )
47
 
 
48
 
#define GET_SCREXT(buf)  ( ((ui64)buf[5]&0xFE)>>1  |  \
49
 
                           ((ui64)buf[4]&0x03)<<7 )
50
 
 
51
 
// muxrate
52
 
//      22 ......................0         stl
53
 
// ... [--------][--------][------11][rrrrr---]
54
 
#define GET_MPEG2MUXRATE(buf) ( (ui32)buf[6]<<14  |      \
55
 
                                ((ui32)buf[7])<<6 |      \
56
 
                                ((ui32)buf[8]&0x03)>>2)  \
57
 
 
58
 
#define GET_MPEG2STUFFING(buf) ((buf[9]&0x07))
59
 
  
60
 
// MPEG1 PACK HEADER
61
 
//                      SCR                                            muxrate
62
 
//                     32........................................0    22......
63
 
//[PACK_START_CODE][0010---1][--------][-------1][--------][-------1][1-------]
64
 
#define GET_SCR(buf)   ( ((ui64)buf[4]&0xFE) >>1     | \
65
 
                         ((ui64)buf[3])      <<7     | \
66
 
                         ((ui64)buf[2]&0xFE) <<14    | \
67
 
                         ((ui64)buf[1])      <<22    | \
68
 
                         ((ui64)buf[0]&0x0E) <<29 )
69
 
 
70
 
#define GET_MPEG1_PTS(x) (GET_SCR(x)) //they follow the same pattern
71
 
 
72
 
#define GET_MPEG1_MUXRATE(x) ( ((ui32)x[7]&0xFE) >>1     | \
73
 
                               ((ui32)x[6])          <<7     | \
74
 
                               ((ui32)x[5]&0x7F) <<15 )
75
 
 
76
 
#define GET_MPEG2_PTS_FLAGS(buf) ( ((ui8)buf[3]&0xC0)>>6  )
77
 
// MPEG2 PES packet (optional parameters)
78
 
//                         PTS                      
79
 
//                         32........................................0
80
 
// [PACKET_START_CODE][001x---1][--------][-------1][--------][-------1]
81
 
#define GET_MPEG2_PTS(buf)   GET_MPEG1_PTS(buf)
82
 
 
83
 
 
84
 
 
85
 
 
86
 
  
 
17
 
 
18
#include "tsSystemStream.h"
 
19
#include "psSystemStream.h"
 
20
#include "pesSystemStream.h"
 
21
 
87
22
 
88
23
class MpegSystemStream {
89
24
 
91
26
  int lHasLength;
92
27
  unsigned int syncCode;
93
28
  int lState;
 
29
  TSSystemStream*  tsSystemStream;
 
30
  PSSystemStream*  psSystemStream;
 
31
  PESSystemStream* pesSystemStream;
94
32
 
95
33
 public:
96
34
  MpegSystemStream(InputStream* input);
97
35
  ~MpegSystemStream();
98
36
 
99
 
  // returns true if init successfull
 
37
  // returns true if init successful
100
38
  int firstInitialize(MpegSystemHeader* mpegHeader);
101
39
  int nextPacket(MpegSystemHeader* mpegHeader);
102
40
  inline int eof() { return input->eof(); }
105
43
 private:
106
44
  int readSyncCode();
107
45
  int getByteDirect();
108
 
  int readHeader(unsigned int* startCode);
109
 
  int processStartCode(unsigned int startCode,MpegSystemHeader* mpegHeader);
 
46
  int demux_ts_pes_buffer(MpegSystemHeader* mpegHeader);
110
47
 
111
 
  int processPackHeader(MpegSystemHeader* mpegHeader);
112
48
  int processSystemHeader(MpegSystemHeader* mpegHeader);
113
 
 
114
 
  int processPacket(unsigned int startCode,MpegSystemHeader* mpegHeader);
115
 
  int processPacketHeader(MpegSystemHeader* mpegHeader);
116
 
  int processMPEG2PacketHeader(MpegSystemHeader* mpegHeader);
117
 
  int processPrivateHeader(MpegSystemHeader* mpegHeader);
118
 
 
119
 
  int readStartCode(unsigned int startCode,MpegSystemHeader* mpegHeader);
120
 
 
121
 
  void readSTD(unsigned char* inputBuffer,MpegSystemHeader* mpegHeader);
122
 
  void readTimeStamp(unsigned char* inputBuffer,unsigned char* hiBit,
123
 
                     unsigned long* low4Bytes);
124
 
 
125
 
  int makeClockTime(unsigned char hiBit, unsigned long low4Bytes,
126
 
                    double * clockTime);
127
49
  
128
50
 
129
51
};