Updating Contact email
[BrunelResearch-dirac.git] / libdirac_decoder / seq_decompress.h
blob809dd425aee6239d7ea025afbbc8f20513389916
1 /* ***** BEGIN LICENSE BLOCK *****
3 * $Id$ $Name$
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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.
16 * The Original Code is BBC Research and Development code.
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.
23 * Contributor(s): Thomas Davies (Original Author),
24 * Scott R Ladd,
25 * Anuradha Suraparaju
26 * Andrew Kennedy
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 ***** */
42 #ifndef _SEQ_DECOMPRESS_H_
43 #define _SEQ_DECOMPRESS_H_
45 ///////////////////////////////////////////
46 //---------------------------------------//
47 //Class to manage decompressing sequences//
48 //---------------------------------------//
49 ///////////////////////////////////////////
51 #include "libdirac_common/common.h"
52 #include "libdirac_byteio/parseunit_byteio.h"
53 #include <iostream>
55 namespace dirac
57 class PictureBuffer;
58 class Picture;
59 class PictureDecompressor;
61 //! Decompresses a sequence of pictures from a stream.
62 /*!
63 This class decompresses a sequence of frames, picture by picture.
65 class SequenceDecompressor{
66 public:
68 //! Constructor
69 /*!
70 Initializes the decompressor with an input stream and level of
71 output detail.
72 \param parseunit First access-unit of new sequence
73 \param verbosity when true, increases the amount of information displayed during decompression
75 SequenceDecompressor(ParseUnitByteIO& parseunit, bool verbosity);
77 //! Destructor
78 /*!
79 Closes files and releases resources.
81 ~SequenceDecompressor();
83 //! Marks beginning of a new AccessUnit
84 /*!
85 \param parseunit_byteio AccessUnit info in Dirac-stream format
87 void NewAccessUnit(ParseUnitByteIO& parseunit_byteio);
90 //! Decompress the next picture in sequence
91 /*!
92 This function decodes the next picture in coding order and returns
93 the next picture in display order. In general these will differ, and
94 because of re-ordering there is a delay which needs to be imposed.
95 This creates problems at the start and at the end of the sequence
96 which must be dealt with. At the start we just keep outputting
97 picture 0. At the end you will need to loop for longer to get all
98 the pictures out. It's up to the calling function to do something
99 with the decoded pictures as they come out -- write them to screen
100 or to file, as required.
102 \param p_parseunit_byteio Picture information in Dirac-stream format
103 \return reference to the next locally decoded picture available for display
105 const Picture* DecompressNextPicture(ParseUnitByteIO* p_parseunit_byteio);
107 //! Get the next picture available for display
108 const Picture* GetNextPicture();
110 //! Get the next picture parameters
111 const PictureParams* GetNextPictureParams() const;
112 //! Determine if decompression is complete.
114 Indicates whether or not the last picture in the sequence has been
115 decompressed.
116 \return true if last picture has been compressed; false if not
118 bool Finished();
119 //! Interrogates for parse parameters.
121 Returns the parse parameters used for this decompression run.
123 \return parse parameters.
125 ParseParams & GetParseParams() { return m_parse_params; }
128 //! Interrogates for source parameters.
130 Returns the source parameters used for this decompression run.
132 \return source parameters.
134 SourceParams & GetSourceParams() { return m_srcparams; }
137 //! Interrogates for coding parameters.
139 Returns the decoder parameters used for this decompression run.
141 \return decoder parameters.
143 DecoderParams & GetDecoderParams() { return m_decparams; }
144 private:
145 //! Copy constructor is private and body-less
147 Copy constructor is private and body-less. This class should not
148 be copied.
151 SequenceDecompressor(const SequenceDecompressor& cpy);
153 //! Assignment = is private and body-less
155 Assignment = is private and body-less. This class should not be
156 assigned.
159 SequenceDecompressor& operator=(const SequenceDecompressor& rhs);
162 //Member variables
164 //! Completion flag, returned via the Finished method
165 bool m_all_done;
166 //! Parameters for the decompression, as provided in constructor
167 DecoderParams m_decparams;
168 //! The parse parameters obtained from the stream header
169 ParseParams m_parse_params;
170 //! The source parameters obtained from the stream header
171 SourceParams m_srcparams;
172 //! A picture buffer used for local storage of pictures whilst pending re-ordering or being used for reference.
173 PictureBuffer* m_pbuffer;
174 //! Number of the picture in coded order which is to be decoded
175 int m_current_code_pnum;
176 //! A delay so that we don't display what we haven't decoded
177 int m_delay;
178 //! Index, in display order, of the last picture read
179 int m_last_picture_read;
180 //! Index, in display order of the picture to be displayed next - computed from delay and current_code_pnum
181 int m_show_pnum;
182 //! Picture decompressor object
183 PictureDecompressor *m_pdecoder;
184 //! Highest picture-num processed - for tracking end-of-sequence
185 int m_highest_pnum;
188 } // namespace dirac
190 #endif