# Dirac - A Video Codec

Created by the British Broadcasting Corporation.

seq_compress.h
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2 *
3 * $Id: seq_compress.h,v 1.33 2008/10/20 04:20:12 asuraparaju Exp $ $Name: Dirac_1_0_2 $
4 *
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 *
7 * The contents of this file are subject to the Mozilla Public License
8 * Version 1.1 (the "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
11 *
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
14 * the specific language governing rights and limitations under the License.
15 *
16 * The Original Code is BBC Research and Development code.
17 *
18 * The Initial Developer of the Original Code is the British Broadcasting
19 * Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 2004.
21 * All Rights Reserved.
22 *
23 * Contributor(s): Thomas Davies (Original Author),
24 * Scott R Ladd,
25 * Anuradha Suraparaju
26 * Andrew Kennedy
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
30 * Public License Version 2.1 (the "LGPL"), in which case the provisions of
31 * the GPL or the LGPL are applicable instead of those above. If you wish to
32 * allow use of your version of this file only under the terms of the either
33 * the GPL or LGPL and not to allow others to use your version of this file
34 * under the MPL, indicate your decision by deleting the provisions above
35 * and replace them with the notice and other provisions required by the GPL
36 * or LGPL. If you do not delete the provisions above, a recipient may use
37 * your version of this file under the terms of any one of the MPL, the GPL
38 * or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
40
41 #ifndef _SEQ_COMPRESS_H_
42 #define _SEQ_COMPRESS_H_
43
45 //-------------------------------------//
46 //Class to manage compressing sequences//
47 //-------------------------------------//
49
50 #include <libdirac_byteio/dirac_byte_stream.h>
51 #include <libdirac_common/common.h>
52 #include <libdirac_encoder/enc_queue.h>
53 #include <libdirac_common/pic_io.h>
54 #include <libdirac_common/dirac_assertions.h>
55 #include <libdirac_encoder/quality_monitor.h>
56 #include <libdirac_encoder/picture_compress.h>
57 #include <libdirac_encoder/rate_control.h>
58
59 #include <fstream>
60
61 namespace dirac
62 {
63
65
73 class SequenceCompressor{
74 public:
76
84 SequenceCompressor(StreamPicInput* pin,
85 EncoderParams& encp,
86 DiracByteStream& dirac_byte_stream);
87
89
92 virtual ~SequenceCompressor();
93
95
103 virtual bool LoadNextFrame() = 0;
104
106
125 const EncPicture *CompressNextPicture();
126
128 virtual void SetPicTypeAndRefs( PictureParams& pparams ) = 0;
129
131 const EncPicture *GetPictureEncoded();
132
133 DiracByteStats EndSequence();
134
136
141 bool Finished(){return m_all_done;}
142
144 void SignalEOS() { m_eos_signalled = true; }
145
147 int PTSOffset(){return m_delay;}
148
149 protected:
150
152 void SetMotionParameters();
153
155
161 virtual int CodedToDisplay(const int pnum) = 0;
162
164 void MakeSequenceReport();
165
167 virtual void CleanBuffers();
168
170 //Purely virtual. The child class will have to define it.
171 virtual void UpdateCBRModel(EncPicture& my_picture, const PictureByteIO* picture_byteio) = 0;
172
174 void UpdateIntraPicCBRModel( const PictureParams& , const bool is_a_cut );
175
177 bool CanEncode();
178
180 bool m_all_done;
181
183
188 bool m_just_finished;
189
191 OLBParams* m_basic_olb_params0;
192
194 OLBParams* m_basic_olb_params1;
195
197 const OLBParams* m_basic_olb_params2;
198
200 OLBParams* m_intra_olbp;
201
203 SourceParams& m_srcparams;
204
206 EncoderParams& m_encparams;
207
209 PicturePredParams& m_predparams;
210
212 int m_L1_sep;
213
215 PictureParams m_pparams;
216
218 StreamPicInput* m_pic_in;
219
221 EncQueue m_enc_pbuffer;
222
223 //state variables for CompressNextPicture
224
226 int m_current_display_pnum;
227
229 int m_current_code_pnum;
230
232 int m_show_pnum;
233
235 int m_last_picture_read;
236
238 int m_gop_start_num;
239
241 int m_delay;
242
244 QualityMonitor m_qmonitor;
245
247 RateController* m_ratecontrol;
248
250 PictureCompressor m_pcoder;
251
253 DiracByteStream& m_dirac_byte_stream;
254
256 bool m_eos_signalled;
257
258 private:
260
264 SequenceCompressor(const SequenceCompressor& cpy);
265
267
271 SequenceCompressor& operator=(const SequenceCompressor& rhs);
272
273
274 };
275
277
283 class FrameSequenceCompressor : public SequenceCompressor
284 {
285 public:
287
296 FrameSequenceCompressor(StreamPicInput* pin,
297 EncoderParams& encp,
298 DiracByteStream& dirac_byte_stream);
299
301
304 virtual ~FrameSequenceCompressor(){};
305
307
313 virtual bool LoadNextFrame();
314
316 virtual void SetPicTypeAndRefs( PictureParams& pparams );
317
318 protected:
319 virtual int CodedToDisplay(const int pnum);
320 virtual void UpdateCBRModel(EncPicture& my_picture, const PictureByteIO* picture_byteio);
321
322 };
323
325
331 class FieldSequenceCompressor : public SequenceCompressor
332 {
333 public:
335
343 FieldSequenceCompressor(StreamPicInput* pin,
344 EncoderParams& encp,
345 DiracByteStream& dirac_byte_stream);
346
348
351 virtual ~FieldSequenceCompressor();
352
354
361 virtual bool LoadNextFrame();
362
363
365 virtual void SetPicTypeAndRefs( PictureParams& pparams );
366
367 protected:
368
369 virtual int CodedToDisplay(const int pnum);
370
371 virtual void UpdateCBRModel(EncPicture& my_picture, const PictureByteIO* picture_byteio);
372 private:
374
378 void PreMotionEstmationFilter (PicArray& comp);
379
380 // Field1 bytes
381 int m_field1_bytes;
382 // Field2 bytes
383 int m_field2_bytes;
384 };
385 } // namespace dirac
386
387 #endif

© 2004 British Broadcasting Corporation. Dirac code licensed under the Mozilla Public License (MPL) Version 1.1.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.