1 
2 /*
3  *  videostrm.hpp:  Video stream elementary input stream
4  *
5  *  Copyright (C) 2001 Andrew Stevens <andrew.stevens@philips.com>
6  *
7  *
8  *  This program is free software; you can redistribute it and/or
9  *  modify it under the terms of version 2 of the GNU General Public License
10  *  as published by the Free Software Foundation.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  */
21 
22 #ifndef __VIDEOSTRM_H__
23 #define __VIDEOSTRM_H__
24 
25 #include "inputstrm.hpp"
26 #include "interact.hpp"
27 #include "stream_params.hpp"
28 
29 class VideoStream : public ElementaryStream
30 {
31 public:
32 	VideoStream(IBitStream &ibs, VideoParams *parms,
33                 Multiplexor &into);
34 	void Init( const int stream_num );
35 
36     static bool Probe(IBitStream &bs );
37 
38 	void Close();
39 
DecoderOrder()40     inline int DecoderOrder() { return au->dorder; }
AUType()41 	inline int AUType()	{ return au->type; }
42 
43     bool SeqEndRunOut();
44 
45     const AUnit *NextIFrame();
46 
47 
NextAUType()48 	inline int NextAUType()
49 		{
50 			AUnit *p_au = Lookahead();
51 			if( p_au != 0 )
52 				return p_au->type;
53 			else
54 				return NOFRAME;
55 		}
56 
57 
NominalBitRate()58 	virtual unsigned int NominalBitRate()
59 		{
60 			return bit_rate * 400;
61 		}
62 
63     virtual void OutputGOPControlSector();
64 	bool RunOutComplete();
65 	virtual bool MuxPossible(clockticks currentSCR);
66     virtual void AUMuxed( bool first_in_sector ) ;
67 
68     void SetMaxStdBufferDelay( unsigned int demux_rate );
69 	void OutputSector();
70 
71 
72 protected:
73     static const unsigned int MAX_GOP_LENGTH = 128;
74 	void OutputSeqhdrInfo();
75 	virtual void FillAUbuffer(unsigned int frames_to_buffer);
76 	virtual void NextDTSPTS(  );
77 	void ScanFirstSeqHeader();
78     uint8_t NewAUTimestamps( int AUtype );
79     bool NewAUBuffers( int AUtype );
80 
81     unsigned int ExcludeNextIFramePayload();
82 
83 public:
84     unsigned int num_sequence 	;
85     unsigned int num_seq_end	;
86     unsigned int num_pictures 	;
87     unsigned int num_groups 	;
88     unsigned int num_frames[4] 	;
89          int64_t avg_frames[4]  ;
90 
91     unsigned int horizontal_size;
92     unsigned int vertical_size 	;
93      unsigned int aspect_ratio	;
94     unsigned int picture_rate	;
95     unsigned int bit_rate 	;
96     unsigned int vbv_buffer_size;
97     unsigned int CSPF 		;
98     double secs_per_frame;
99 
100 
101 	bool dtspts_for_all_au;     // Ensure every AU has a timestamp
102                                 // (no two AU can start in one sector)
103     bool gop_control_packet;
104 
105 protected:
106 
107 
108 	/* State variables for scanning source bit-stream */
109     AUnit access_unit;
110 	int fields_presented;
111     int group_start_pic;
112 	int group_start_field;
113     int group_start_SCR;
114     int temporal_reference;
115     unsigned int pict_struct;
116 	int pulldown_32;
117 	int repeat_first_field;
118 	int prev_temp_ref;
119     int ref_present;
120     int prev_ref_present;
121     double frame_rate;
122 	double max_bits_persec;
123 	int AU_pict_data;
124 	int AU_hdr;
125     clockticks max_STD_buffer_delay;
126     VideoParams *parms;
127 };
128 
129 //
130 // DVD's generate control sectors for each GOP...
131 //
132 
133 class DVDVideoStream : public VideoStream
134 {
135 public:
DVDVideoStream(IBitStream & ibs,VideoParams * parms,Multiplexor & into)136 	DVDVideoStream(IBitStream &ibs,VideoParams *parms,Multiplexor &into) :
137         VideoStream( ibs, parms, into )
138         {
139             gop_control_packet = true;
140         }
141     void OutputGOPControlSector();
142 };
143 
144 #endif // __INPUTSTRM_H__
145 
146 
147 /*
148  * Local variables:
149  *  c-file-style: "stroustrup"
150  *  tab-width: 4
151  *  indent-tabs-mode: nil
152  * End:
153  */
154