<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Dirac Video Codec</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body bgcolor="#ffffff"> <h1 align="center" color="#606080"> Dirac - A Video Codec </h1> <p align="center"> Created by the <a href="http://www.bbc.co.uk">British Broadcasting Corporation</a>. </p> <hr> <!-- Generated by Doxygen 1.5.4 --> <h1>frame_compress.h</h1><a href="a00188.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* ***** BEGIN LICENSE BLOCK *****</span> <a name="l00002"></a>00002 <span class="comment">*</span> <a name="l00003"></a>00003 <span class="comment">* $Id: frame_compress.h,v 1.16 2007/12/12 14:01:51 tjdwave Exp $ $Name: Dirac_0_9_1 $</span> <a name="l00004"></a>00004 <span class="comment">*</span> <a name="l00005"></a>00005 <span class="comment">* Version: MPL 1.1/GPL 2.0/LGPL 2.1</span> <a name="l00006"></a>00006 <span class="comment">*</span> <a name="l00007"></a>00007 <span class="comment">* The contents of this file are subject to the Mozilla Public License</span> <a name="l00008"></a>00008 <span class="comment">* Version 1.1 (the "License"); you may not use this file except in compliance</span> <a name="l00009"></a>00009 <span class="comment">* with the License. You may obtain a copy of the License at</span> <a name="l00010"></a>00010 <span class="comment">* http://www.mozilla.org/MPL/</span> <a name="l00011"></a>00011 <span class="comment">*</span> <a name="l00012"></a>00012 <span class="comment">* Software distributed under the License is distributed on an "AS IS" basis,</span> <a name="l00013"></a>00013 <span class="comment">* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for</span> <a name="l00014"></a>00014 <span class="comment">* the specific language governing rights and limitations under the License.</span> <a name="l00015"></a>00015 <span class="comment">*</span> <a name="l00016"></a>00016 <span class="comment">* The Original Code is BBC Research and Development code.</span> <a name="l00017"></a>00017 <span class="comment">*</span> <a name="l00018"></a>00018 <span class="comment">* The Initial Developer of the Original Code is the British Broadcasting</span> <a name="l00019"></a>00019 <span class="comment">* Corporation.</span> <a name="l00020"></a>00020 <span class="comment">* Portions created by the Initial Developer are Copyright (C) 2004.</span> <a name="l00021"></a>00021 <span class="comment">* All Rights Reserved.</span> <a name="l00022"></a>00022 <span class="comment">*</span> <a name="l00023"></a>00023 <span class="comment">* Contributor(s): Thomas Davies (Original Author),</span> <a name="l00024"></a>00024 <span class="comment">* Scott R Ladd,</span> <a name="l00025"></a>00025 <span class="comment">* Anuradha Suraparaju</span> <a name="l00026"></a>00026 <span class="comment">* Andrew Kennedy</span> <a name="l00027"></a>00027 <span class="comment">*</span> <a name="l00028"></a>00028 <span class="comment">* Alternatively, the contents of this file may be used under the terms of</span> <a name="l00029"></a>00029 <span class="comment">* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser</span> <a name="l00030"></a>00030 <span class="comment">* Public License Version 2.1 (the "LGPL"), in which case the provisions of</span> <a name="l00031"></a>00031 <span class="comment">* the GPL or the LGPL are applicable instead of those above. If you wish to</span> <a name="l00032"></a>00032 <span class="comment">* allow use of your version of this file only under the terms of the either</span> <a name="l00033"></a>00033 <span class="comment">* the GPL or LGPL and not to allow others to use your version of this file</span> <a name="l00034"></a>00034 <span class="comment">* under the MPL, indicate your decision by deleting the provisions above</span> <a name="l00035"></a>00035 <span class="comment">* and replace them with the notice and other provisions required by the GPL</span> <a name="l00036"></a>00036 <span class="comment">* or LGPL. If you do not delete the provisions above, a recipient may use</span> <a name="l00037"></a>00037 <span class="comment">* your version of this file under the terms of any one of the MPL, the GPL</span> <a name="l00038"></a>00038 <span class="comment">* or the LGPL.</span> <a name="l00039"></a>00039 <span class="comment">* ***** END LICENSE BLOCK ***** */</span> <a name="l00040"></a>00040 <a name="l00041"></a>00041 <a name="l00042"></a>00042 <span class="preprocessor">#ifndef _FRAME_COMPRESS_H_</span> <a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#define _FRAME_COMPRESS_H_</span> <a name="l00044"></a>00044 <span class="preprocessor"></span> <a name="l00045"></a>00045 <span class="preprocessor">#include <<a class="code" href="a00186.html">libdirac_common/frame_buffer.h</a>></span> <a name="l00046"></a>00046 <span class="preprocessor">#include <<a class="code" href="a00167.html">libdirac_common/common.h</a>></span> <a name="l00047"></a>00047 <span class="preprocessor">#include <<a class="code" href="a00197.html">libdirac_common/motion.h</a>></span> <a name="l00048"></a>00048 <span class="preprocessor">#include <<a class="code" href="a00187.html">libdirac_byteio/frame_byteio.h</a>></span> <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="keyword">namespace </span>dirac <a name="l00051"></a>00051 { <a name="l00052"></a>00052 <a name="l00053"></a>00053 <span class="keyword">class </span>MvData; <a name="l00054"></a>00054 <a name="l00056"></a>00056 <a name="l00061"></a><a class="code" href="a00076.html">00061</a> <span class="keyword">class </span><a class="code" href="a00076.html" title="Compress a single image frame.">FrameCompressor</a> <a name="l00062"></a>00062 { <a name="l00063"></a>00063 <span class="keyword">public</span>: <a name="l00065"></a>00065 <a name="l00071"></a>00071 <a class="code" href="a00076.html#699f576f5b9e743aac1eff974c71aa11" title="Constructor.">FrameCompressor</a>( <a class="code" href="a00066.html" title="Parameters for the encoding process.">EncoderParams</a>& encp ); <a name="l00072"></a>00072 <a name="l00074"></a>00074 <a class="code" href="a00076.html#3d07324840fd2b3720edf05066f0766f" title="Destructor.">~FrameCompressor</a>( ); <a name="l00075"></a>00075 <a name="l00077"></a>00077 <a name="l00082"></a>00082 <span class="keywordtype">bool</span> <a class="code" href="a00076.html#7630ff8790378db4d3f4230ab46c5956" title="Performs motion estimation for a frame and writes the data locally.">MotionEstimate</a>( <span class="keyword">const</span> <a class="code" href="a00073.html" title="Holds frames both for reference and to overcome reordering delay.">FrameBuffer</a>& my_fbuffer, <a name="l00083"></a>00083 <span class="keywordtype">int</span> fnum); <a name="l00084"></a>00084 <a name="l00086"></a>00086 <a name="l00092"></a>00092 <a class="code" href="a00074.html" title="A compressed frame in Dirac bytestream format.">FrameByteIO</a>* <a class="code" href="a00076.html#ec94b44bdfe2889f578bd753bbea9b87" title="Compress a specific frame within a group of pictures (GOP).">Compress</a>( <a class="code" href="a00073.html" title="Holds frames both for reference and to overcome reordering delay.">FrameBuffer</a>& my_fbuffer , <a name="l00093"></a>00093 <span class="keywordtype">int</span> fnum ); <a name="l00094"></a>00094 <a name="l00096"></a><a class="code" href="a00076.html#fe214cc98ca78f73314f0aa73d103bf4">00096</a> <span class="keywordtype">bool</span> <a class="code" href="a00076.html#fe214cc98ca78f73314f0aa73d103bf4" title="Returns true if the frame has been skipped rather than coded normally.">IsSkipped</a>(){ <span class="keywordflow">return</span> <a class="code" href="a00076.html#bc99378f5822bbc844fe1f3cc8fb8a9e">m_skipped</a>; } <a name="l00097"></a>00097 <a name="l00099"></a><a class="code" href="a00076.html#b459c0bc6b4d95c037d7d2612a7d176f">00099</a> <span class="keywordtype">bool</span> <a class="code" href="a00076.html#b459c0bc6b4d95c037d7d2612a7d176f" title="Returns true if Motion estimation data is available.">IsMEDataAvail</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="a00076.html#de65740b5ad55390a6903c7bb5645cfe">m_medata_avail</a>; } <a name="l00100"></a>00100 <a name="l00102"></a>00102 <span class="keyword">const</span> <a class="code" href="a00087.html" title="Class for all the motion estimation data.">MEData</a>* <a class="code" href="a00076.html#516e9610adfc0e339605167aa4031c3b" title="Returns the motion estimation data.">GetMEData</a>() <span class="keyword">const</span>; <a name="l00103"></a>00103 <a name="l00104"></a>00104 <span class="keyword">private</span>: <a name="l00106"></a>00106 <a name="l00110"></a>00110 <a class="code" href="a00076.html#699f576f5b9e743aac1eff974c71aa11" title="Constructor.">FrameCompressor</a>( <span class="keyword">const</span> <a class="code" href="a00076.html" title="Compress a single image frame.">FrameCompressor</a>& cpy ); <a name="l00111"></a>00111 <a name="l00113"></a>00113 <a name="l00117"></a>00117 <a class="code" href="a00076.html" title="Compress a single image frame.">FrameCompressor</a>& <a class="code" href="a00076.html#e4ca6805a20ee61895e1cbb904a6a970" title="Assignment = is private and body-less.">operator=</a>(<span class="keyword">const</span> <a class="code" href="a00076.html" title="Compress a single image frame.">FrameCompressor</a>& rhs); <a name="l00118"></a>00118 <a name="l00120"></a>00120 <span class="keywordtype">void</span> <a class="code" href="a00076.html#f5cccd306b0aeb3dca84a992b5bb7660" title="Analyses the ME data and returns true if a cut is detected, false otherwise.">AnalyseMEData</a>( <span class="keyword">const</span> <a class="code" href="a00087.html" title="Class for all the motion estimation data.">MEData</a>& ); <a name="l00121"></a>00121 <a name="l00123"></a>00123 <span class="keywordtype">void</span> <a class="code" href="a00076.html#686bd8f55efeaf26065fce0e72aca35f" title="Compresses the motion vector data.">CompressMVData</a>(<a class="code" href="a00102.html" title="Represents compressed sequence-parameter data used in an AccessUnit.">MvDataByteIO</a>* mv_data); <a name="l00124"></a>00124 <a name="l00126"></a>00126 <span class="keywordtype">float</span> <a class="code" href="a00076.html#17534919637e3686dcc2137ffbc4ae72" title="Returns the value lambda according to frame and component type.">GetCompLambda</a>( <span class="keyword">const</span> <a class="code" href="a00078.html" title="Parameters for initialising frame class objects.">FrameParams</a>& fparams, <a name="l00127"></a>00127 <span class="keyword">const</span> <a class="code" href="a00226.html#39dd89c4c7484412efd87d41548271cd" title="Types of picture component.">CompSort</a> csort ); <a name="l00128"></a>00128 <a name="l00129"></a>00129 <span class="keywordtype">void</span> <a class="code" href="a00076.html#d486fb24403a3b06a5b3bdea081c9045">SelectQuantisers</a>( <a class="code" href="a00023.html" title="A class for picture component data.">CoeffArray</a>& coeff_data , <a name="l00130"></a>00130 <a class="code" href="a00136.html" title="A class encapulating all the subbands produced by a transform.">SubbandList</a>& bands , <a name="l00131"></a>00131 <span class="keyword">const</span> <span class="keywordtype">float</span> lambda, <a name="l00132"></a>00132 <a class="code" href="a00105.html" title="A template class for one-dimensional arrays.">OneDArray<unsigned int></a>& est_counts, <a name="l00133"></a>00133 <span class="keyword">const</span> <a class="code" href="a00168.html#c01e150ebe1e8dee39d5431ab23e8ec5">CodeBlockMode</a> cb_mode, <a name="l00134"></a>00134 <span class="keyword">const</span> <a class="code" href="a00080.html" title="Frame type Class.">FrameSort</a> fsort, <a name="l00135"></a>00135 <span class="keyword">const</span> <a class="code" href="a00226.html#39dd89c4c7484412efd87d41548271cd" title="Types of picture component.">CompSort</a> csort ); <a name="l00136"></a>00136 <a name="l00137"></a>00137 <span class="keywordtype">int</span> <a class="code" href="a00076.html#0e4f32cb5ccc4e9d91d45cd54238c718">SelectMultiQuants</a>( <a class="code" href="a00023.html" title="A class for picture component data.">CoeffArray</a>& coeff_data , <a name="l00138"></a>00138 <a class="code" href="a00136.html" title="A class encapulating all the subbands produced by a transform.">SubbandList</a>& bands , <a name="l00139"></a>00139 <span class="keyword">const</span> <span class="keywordtype">int</span> band_num, <a name="l00140"></a>00140 <span class="keyword">const</span> <span class="keywordtype">float</span> lambda, <a name="l00141"></a>00141 <span class="keyword">const</span> <a class="code" href="a00080.html" title="Frame type Class.">FrameSort</a> fsort, <a name="l00142"></a>00142 <span class="keyword">const</span> <a class="code" href="a00226.html#39dd89c4c7484412efd87d41548271cd" title="Types of picture component.">CompSort</a> csort ); <a name="l00143"></a>00143 <a name="l00144"></a>00144 <span class="keywordtype">void</span> <a class="code" href="a00076.html#51037af7a02a0b340641de665bd5b877">SetupCodeBlocks</a>( <a class="code" href="a00136.html" title="A class encapulating all the subbands produced by a transform.">SubbandList</a>& bands ); <a name="l00145"></a>00145 <a name="l00146"></a>00146 <a name="l00147"></a>00147 <span class="keywordtype">void</span> <a class="code" href="a00076.html#693040c918287ef2369e91962ae5c578">AddSubAverage</a>(<a class="code" href="a00023.html" title="A class for picture component data.">CoeffArray</a>& coeff_data,<span class="keywordtype">int</span> xl,<span class="keywordtype">int</span> yl,<a class="code" href="a00226.html#521776b4db3589284c5b7acb2b38a4b1" title="Addition or subtraction.">AddOrSub</a> dirn); <a name="l00148"></a>00148 <a name="l00149"></a>00149 <span class="keyword">private</span>: <a name="l00150"></a>00150 <a name="l00151"></a>00151 <span class="comment">//member variables</span> <a name="l00152"></a>00152 <span class="comment">// a local copy of the encoder params</span> <a name="l00153"></a><a class="code" href="a00076.html#931e5bd8f33467640183cef453a3f7a2">00153</a> <a class="code" href="a00066.html" title="Parameters for the encoding process.">EncoderParams</a>& <a class="code" href="a00076.html#931e5bd8f33467640183cef453a3f7a2">m_encparams</a>; <a name="l00154"></a>00154 <a name="l00155"></a>00155 <span class="comment">// Pointer to the motion vector data</span> <a name="l00156"></a><a class="code" href="a00076.html#8ba4211c7943728e0b2dd458922cb503">00156</a> <a class="code" href="a00087.html" title="Class for all the motion estimation data.">MEData</a>* <a class="code" href="a00076.html#8ba4211c7943728e0b2dd458922cb503">m_me_data</a>; <a name="l00157"></a>00157 <a name="l00158"></a>00158 <span class="comment">// True if the frame has been skipped, false otherwise</span> <a name="l00159"></a><a class="code" href="a00076.html#bc99378f5822bbc844fe1f3cc8fb8a9e">00159</a> <span class="keywordtype">bool</span> <a class="code" href="a00076.html#bc99378f5822bbc844fe1f3cc8fb8a9e">m_skipped</a>; <a name="l00160"></a>00160 <a name="l00161"></a>00161 <span class="comment">// True if we use global motion vectors, false otherwise</span> <a name="l00162"></a><a class="code" href="a00076.html#994bc7c572308123a1ba7d37495b69dc">00162</a> <span class="keywordtype">bool</span> <a class="code" href="a00076.html#994bc7c572308123a1ba7d37495b69dc">m_use_global</a>; <a name="l00163"></a>00163 <a name="l00164"></a>00164 <span class="comment">// True if we use block motion vectors, false otherwise</span> <a name="l00165"></a><a class="code" href="a00076.html#7b3c4f497278ac9dd1a95c941e89ed9d">00165</a> <span class="keywordtype">bool</span> <a class="code" href="a00076.html#7b3c4f497278ac9dd1a95c941e89ed9d">m_use_block_mv</a>; <a name="l00166"></a>00166 <a name="l00167"></a>00167 <span class="comment">// Prediction mode to use if we only have global motion vectors</span> <a name="l00168"></a><a class="code" href="a00076.html#6b11bc64e5c89613c077a2710da5a84e">00168</a> <a class="code" href="a00226.html#b8a7aad3ab6de8cc3709dcacde946964" title="Prediction modes for blocks.">PredMode</a> <a class="code" href="a00076.html#6b11bc64e5c89613c077a2710da5a84e">m_global_pred_mode</a>; <a name="l00169"></a>00169 <a name="l00170"></a>00170 <span class="comment">// True if motion estimation data is available</span> <a name="l00171"></a><a class="code" href="a00076.html#de65740b5ad55390a6903c7bb5645cfe">00171</a> <span class="keywordtype">bool</span> <a class="code" href="a00076.html#de65740b5ad55390a6903c7bb5645cfe">m_medata_avail</a>; <a name="l00172"></a>00172 <a name="l00173"></a>00173 <span class="comment">// True if we have detected a cut</span> <a name="l00174"></a><a class="code" href="a00076.html#c508ef6bea2d13da66658820dd002161">00174</a> <span class="keywordtype">bool</span> <a class="code" href="a00076.html#c508ef6bea2d13da66658820dd002161">m_is_a_cut</a>; <a name="l00175"></a>00175 <a name="l00176"></a>00176 <span class="comment">// The proportion of intra blocks that motion estimation has found</span> <a name="l00177"></a><a class="code" href="a00076.html#99bee51c8b3ae2bc59a46c527097ab31">00177</a> <span class="keywordtype">double</span> <a class="code" href="a00076.html#99bee51c8b3ae2bc59a46c527097ab31">m_intra_ratio</a>; <a name="l00178"></a>00178 }; <a name="l00179"></a>00179 <a name="l00180"></a>00180 } <span class="comment">// namespace dirac</span> <a name="l00181"></a>00181 <a name="l00182"></a>00182 <span class="preprocessor">#endif</span> </pre></div><hr> <p align="center"><small> © 2004 British Broadcasting Corporation. Dirac code licensed under the <a href="http://www.mozilla.org/MPL/">Mozilla Public License (MPL) Version 1.1</a>.<br> HTML documentation generated by Dimitri van Heesch's excellent <a href="http://www.doxygen.org">Doxygen</a> tool. </small></p> </body> </html>