Sophie

Sophie

distrib > Mandriva > 2010.0 > x86_64 > by-pkgid > f250c16c2b84c9364a2f35a71121aaa2 > files > 368

lib64dirac-devel-1.0.2-2mdv2010.0.x86_64.rpm

<!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.9 -->
<h1>pixel_match.h</h1><a href="a00217.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: pixel_match.h,v 1.11 2008/08/27 00:20:52 asuraparaju Exp $ $Name: Dirac_1_0_2 $</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">*</span>
<a name="l00025"></a>00025 <span class="comment">* Alternatively, the contents of this file may be used under the terms of</span>
<a name="l00026"></a>00026 <span class="comment">* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser</span>
<a name="l00027"></a>00027 <span class="comment">* Public License Version 2.1 (the "LGPL"), in which case the provisions of</span>
<a name="l00028"></a>00028 <span class="comment">* the GPL or the LGPL are applicable instead of those above. If you wish to</span>
<a name="l00029"></a>00029 <span class="comment">* allow use of your version of this file only under the terms of the either</span>
<a name="l00030"></a>00030 <span class="comment">* the GPL or LGPL and not to allow others to use your version of this file</span>
<a name="l00031"></a>00031 <span class="comment">* under the MPL, indicate your decision by deleting the provisions above</span>
<a name="l00032"></a>00032 <span class="comment">* and replace them with the notice and other provisions required by the GPL</span>
<a name="l00033"></a>00033 <span class="comment">* or LGPL. If you do not delete the provisions above, a recipient may use</span>
<a name="l00034"></a>00034 <span class="comment">* your version of this file under the terms of any one of the MPL, the GPL</span>
<a name="l00035"></a>00035 <span class="comment">* or the LGPL.</span>
<a name="l00036"></a>00036 <span class="comment">* ***** END LICENSE BLOCK ***** */</span>
<a name="l00037"></a>00037 
<a name="l00038"></a>00038 <span class="preprocessor">#ifndef _PIXEL_MATCH_H_</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span><span class="preprocessor">#define _PIXEL_MATCH_H_</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span>
<a name="l00041"></a>00041 <span class="comment">/* *************************************************************************</span>
<a name="l00042"></a>00042 <span class="comment">*</span>
<a name="l00043"></a>00043 <span class="comment">* Class for getting motion vectors to pixel-accuracy</span>
<a name="l00044"></a>00044 <span class="comment">*</span>
<a name="l00045"></a>00045 <span class="comment">* The class could be implemented in any number of ways. The approach taken</span>
<a name="l00046"></a>00046 <span class="comment">* has been to do hierarchical matching, which means doing block matching</span>
<a name="l00047"></a>00047 <span class="comment">* on smaller, downcoverted versions of the pictures in order to get a wider</span>
<a name="l00048"></a>00048 <span class="comment">* effective search range. At each level of searching the vectors discovered</span>
<a name="l00049"></a>00049 <span class="comment">* can be used as guides to the next level of searching, and in this way</span>
<a name="l00050"></a>00050 <span class="comment">* large motions can be detected easily. The danger is that the motions of</span>
<a name="l00051"></a>00051 <span class="comment">* small objects can be overlooked.</span>
<a name="l00052"></a>00052 <span class="comment">*</span>
<a name="l00053"></a>00053 <span class="comment">* *************************************************************************/</span>
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 <span class="preprocessor">#include &lt;<a class="code" href="a00171.html">libdirac_common/common.h</a>&gt;</span>
<a name="l00056"></a>00056 <span class="preprocessor">#include &lt;<a class="code" href="a00200.html">libdirac_common/motion.h</a>&gt;</span>
<a name="l00057"></a>00057 <span class="preprocessor">#include &lt;<a class="code" href="a00167.html">libdirac_motionest/block_match.h</a>&gt;</span>
<a name="l00058"></a>00058 <span class="keyword">namespace </span>dirac
<a name="l00059"></a>00059 {
<a name="l00060"></a>00060     <span class="keyword">class </span>EncQueue;
<a name="l00061"></a>00061     <span class="keyword">class </span>MvData;
<a name="l00062"></a>00062     <span class="keyword">class </span>EncoderParams;
<a name="l00063"></a>00063     <span class="keyword">class </span>PicArray;
<a name="l00064"></a>00064 
<a name="l00065"></a>00065 
<a name="l00066"></a><a class="code" href="a00116.html">00066</a>     <span class="keyword">class </span><a class="code" href="a00116.html">PixelMatcher</a>
<a name="l00067"></a>00067     {
<a name="l00068"></a>00068     <span class="keyword">public</span>:
<a name="l00069"></a>00069 
<a name="l00071"></a>00071         <a class="code" href="a00116.html#ef96b2a1af2007e87b691150d2a94d9c" title="Constructor.">PixelMatcher</a>( <span class="keyword">const</span> <a class="code" href="a00063.html" title="Parameters for the encoding process.">EncoderParams</a>&amp; encp);
<a name="l00072"></a>00072 
<a name="l00074"></a>00074         <span class="comment">/* Do the searching.</span>
<a name="l00075"></a>00075 <span class="comment"></span>
<a name="l00076"></a>00076 <span class="comment">        \param  my_buffer  the buffer of pictures from which pictures are taken</span>
<a name="l00077"></a>00077 <span class="comment">        \param  pic_num  the number of the picture for which motion is to be estimated</span>
<a name="l00078"></a>00078 <span class="comment">        \param  mv_data    class in which the measured motion vectors are stored, together with costs</span>
<a name="l00079"></a>00079 <span class="comment">        </span>
<a name="l00080"></a>00080 <span class="comment">        */</span>
<a name="l00081"></a>00081         <span class="keywordtype">void</span> <a class="code" href="a00116.html#4eb49fd57474522d153dcc1742ca6aef" title="Do the actual search.">DoSearch</a>( <a class="code" href="a00065.html" title="Holds pictures both for reference and to overcome reordering delay.">EncQueue</a>&amp; my_buffer, <span class="keywordtype">int</span> pic_num ); 
<a name="l00082"></a>00082 
<a name="l00083"></a>00083     <span class="keyword">private</span>:
<a name="l00084"></a>00084 
<a name="l00085"></a>00085         <span class="comment">// Member variables</span>
<a name="l00086"></a>00086 
<a name="l00088"></a><a class="code" href="a00116.html#0a8bb513df45b9db2d8ba9356b7dca7a">00088</a>         <span class="keyword">const</span> <a class="code" href="a00063.html" title="Parameters for the encoding process.">EncoderParams</a>&amp; <a class="code" href="a00116.html#0a8bb513df45b9db2d8ba9356b7dca7a" title="Local reference to the encoder params.">m_encparams</a>;
<a name="l00089"></a>00089 
<a name="l00091"></a><a class="code" href="a00116.html#5cbb26959c9d2d9aa0e6d5811e087041">00091</a>         <span class="keyword">const</span> <a class="code" href="a00114.html" title="Structure to hold motion parameters when motion comp is used.">PicturePredParams</a>* <a class="code" href="a00116.html#5cbb26959c9d2d9aa0e6d5811e087041" title="Local reference to the picture pred params.">m_predparams</a>;
<a name="l00092"></a>00092 
<a name="l00093"></a>00093         <span class="comment">// the depth of the hierarchical match </span>
<a name="l00094"></a><a class="code" href="a00116.html#d360831fe629a2ec914cfa0fc3faaacd">00094</a>         <span class="keywordtype">int</span> <a class="code" href="a00116.html#d360831fe629a2ec914cfa0fc3faaacd">m_depth</a>;
<a name="l00095"></a>00095 
<a name="l00096"></a>00096         <span class="comment">// the level we're at (from 0 to depth)</span>
<a name="l00097"></a><a class="code" href="a00116.html#939e4b54b2e27ad0629bbc7abae2a954">00097</a>         <span class="keywordtype">int</span> <a class="code" href="a00116.html#939e4b54b2e27ad0629bbc7abae2a954">m_level</a>;
<a name="l00098"></a>00098 
<a name="l00099"></a>00099         <span class="comment">// the search-range sizes for the hierarchical match</span>
<a name="l00100"></a><a class="code" href="a00116.html#14fd8611c266d14d0400d40bf7d2ec64">00100</a>         <span class="keywordtype">int</span> <a class="code" href="a00116.html#a8644f8d52a1190b55f52c3b4b6a7ecf">m_xr</a>, <a class="code" href="a00116.html#14fd8611c266d14d0400d40bf7d2ec64">m_yr</a>;
<a name="l00101"></a>00101         
<a name="l00102"></a>00102         <span class="comment">// the search-range sizes for when hierarchical match fails</span>
<a name="l00103"></a><a class="code" href="a00116.html#0bc6a312ce84713d0c92dd47c0d291f8">00103</a>         <span class="keywordtype">int</span> <a class="code" href="a00116.html#6c4e8ba863f6e9c25f47c90b856b1a25">m_big_xr</a>, <a class="code" href="a00116.html#0bc6a312ce84713d0c92dd47c0d291f8">m_big_yr</a>;
<a name="l00104"></a>00104         
<a name="l00105"></a>00105         <span class="comment">// the temporal distances to the reference pictures</span>
<a name="l00106"></a><a class="code" href="a00116.html#0c50a5e8f29d285f66318fe79ac37b94">00106</a>         <span class="keywordtype">int</span> <a class="code" href="a00116.html#0c50a5e8f29d285f66318fe79ac37b94">m_tdiff</a>[2];
<a name="l00107"></a>00107 
<a name="l00108"></a>00108         <span class="comment">// the picture sort - I, L1 or L2</span>
<a name="l00109"></a><a class="code" href="a00116.html#63a1d89cb214d1e6a5e5af0172ca9242">00109</a>         <a class="code" href="a00115.html" title="Picture type Class.">PictureSort</a> <a class="code" href="a00116.html#63a1d89cb214d1e6a5e5af0172ca9242">m_psort</a>;
<a name="l00110"></a>00110 
<a name="l00111"></a>00111         <span class="comment">// list of candidate vectors for checking</span>
<a name="l00112"></a><a class="code" href="a00116.html#0b21ec8d6bc104306c762ece18015f5c">00112</a>         <a class="code" href="a00234.html#7a049e12b5746a1b3da88a3e94d04069">CandidateList</a> <a class="code" href="a00116.html#0b21ec8d6bc104306c762ece18015f5c">m_cand_list</a>;
<a name="l00113"></a>00113 
<a name="l00114"></a>00114         <span class="comment">// Prediction used for each block. This is derived from neighbouring blocks</span>
<a name="l00115"></a>00115         <span class="comment">// and is used to control the variation in the motion vector field.</span>
<a name="l00116"></a><a class="code" href="a00116.html#20939032bca4d2e8f370dec1e42a8c81">00116</a>         <a class="code" href="a00091.html">MVector</a> <a class="code" href="a00116.html#20939032bca4d2e8f370dec1e42a8c81">m_mv_prediction</a>;
<a name="l00117"></a>00117         
<a name="l00118"></a>00118         <span class="comment">// The value used in computing block cost means with a simple recursive filter</span>
<a name="l00119"></a><a class="code" href="a00116.html#23e35b046f8616d614bb36646fc0357a">00119</a>         <span class="keywordtype">double</span> <a class="code" href="a00116.html#23e35b046f8616d614bb36646fc0357a">m_rho</a>;
<a name="l00120"></a>00120         
<a name="l00121"></a>00121         <span class="comment">// The mean of the block cost</span>
<a name="l00122"></a><a class="code" href="a00116.html#aaf4357252197ee079d9aaede854a5bf">00122</a>         <span class="keywordtype">double</span> <a class="code" href="a00116.html#aaf4357252197ee079d9aaede854a5bf">m_cost_mean</a>;
<a name="l00123"></a>00123         
<a name="l00124"></a>00124         <span class="comment">// The mean of the square of the block cost</span>
<a name="l00125"></a><a class="code" href="a00116.html#a23b68768042f5604196a873fee24599">00125</a>         <span class="keywordtype">double</span> <a class="code" href="a00116.html#a23b68768042f5604196a873fee24599">m_cost_mean_sq</a>;
<a name="l00126"></a>00126         
<a name="l00127"></a>00127     <span class="keyword">private</span>:
<a name="l00128"></a>00128 
<a name="l00129"></a>00129         <span class="comment">// Functions</span>
<a name="l00130"></a>00130 
<a name="l00132"></a>00132         <span class="keywordtype">void</span> <a class="code" href="a00116.html#0e1078abccd200bbc4f3f54eb4851815" title="Make down-converted pictures.">MakePicHierarchy</a>(<span class="keyword">const</span> <a class="code" href="a00107.html" title="A class for picture component data.">PicArray</a>&amp; data, <a class="code" href="a00097.html" title="A template class for one-dimensional arrays.">OneDArray&lt; PicArray* &gt;</a>&amp; down_data);
<a name="l00133"></a>00133 
<a name="l00135"></a>00135         <span class="keywordtype">void</span> <a class="code" href="a00116.html#c860e25a3bcca455e40c64ef5d1a2051" title="Make a hierarchy of MvData structures.">MakeMEDataHierarchy</a>(<span class="keyword">const</span> <a class="code" href="a00097.html" title="A template class for one-dimensional arrays.">OneDArray&lt; PicArray*&gt;</a>&amp; down_data,
<a name="l00136"></a>00136                                            <a class="code" href="a00097.html">OneDArray&lt; MEData* &gt;</a>&amp; me_data_set );
<a name="l00137"></a>00137 
<a name="l00139"></a>00139         <span class="keywordtype">void</span> <a class="code" href="a00116.html#b1d3a0b8f2d7fcad85946d7a9d1a92f7" title="Tidy up the allocations made in building the picture hirearchy.">TidyPics</a>( <a class="code" href="a00097.html" title="A template class for one-dimensional arrays.">OneDArray&lt; PicArray*&gt;</a>&amp; down_data );
<a name="l00140"></a>00140 
<a name="l00142"></a>00142         <span class="keywordtype">void</span> <a class="code" href="a00116.html#286635372cff9045a10d1f51c9888399" title="Tidy up the allocations made in building the MV data hirearchy.">TidyMEData</a>( <a class="code" href="a00097.html">OneDArray&lt; MEData*&gt;</a>&amp; me_data_set );
<a name="l00143"></a>00143 
<a name="l00145"></a>00145         <span class="keywordtype">void</span> <a class="code" href="a00116.html#77c1e25f890c2fd6b21c1bf713727799" title="Match the picture data.">MatchPic</a>(<span class="keyword">const</span> <a class="code" href="a00107.html" title="A class for picture component data.">PicArray</a>&amp; ref_data , <span class="keyword">const</span> <a class="code" href="a00107.html" title="A class for picture component data.">PicArray</a>&amp; pic_data , <a class="code" href="a00082.html" title="Class for all the motion estimation data.">MEData</a>&amp; me_data ,
<a name="l00146"></a>00146                       <span class="keyword">const</span> <a class="code" href="a00093.html" title="Class for all the motion vector data.">MvData</a>&amp; guide_data, <span class="keyword">const</span> <span class="keywordtype">int</span> ref_id);
<a name="l00147"></a>00147 
<a name="l00149"></a>00149         <span class="keywordtype">void</span> <a class="code" href="a00116.html#3fd8ce48e9e8df32284c0aa43aa4a202" title="Do a given block.">DoBlock</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> xpos, <span class="keyword">const</span> <span class="keywordtype">int</span> ypos , 
<a name="l00150"></a>00150                      <span class="keyword">const</span> <a class="code" href="a00145.html" title="A template class for two-dimensional arrays.">MvArray</a>&amp; guide_array,
<a name="l00151"></a>00151                      <a class="code" href="a00015.html" title="Class to do block matching.">BlockMatcher</a>&amp; block_match);
<a name="l00152"></a>00152 
<a name="l00153"></a>00153     };
<a name="l00154"></a>00154 
<a name="l00155"></a>00155 } <span class="comment">// namespace dirac</span>
<a name="l00156"></a>00156 
<a name="l00157"></a>00157 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr>
<p align="center"><small>
&copy; 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>