Sophie

Sophie

distrib > Mandriva > 2010.0 > x86_64 > media > main-release > by-pkgid > f250c16c2b84c9364a2f35a71121aaa2 > files > 268

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>block_match.h</h1><a href="a00167.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: block_match.h,v 1.10 2007/09/03 14:52:40 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 _BLOCK_MATCH_H_</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span><span class="preprocessor">#define _BLOCK_MATCH_H_</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;<a class="code" href="a00196.html">libdirac_motionest/me_utils.h</a>&gt;</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00043"></a>00043 <span class="comment">//handles the business of finding the best block match</span>
<a name="l00044"></a>00044 
<a name="l00045"></a>00045 <span class="keyword">namespace </span>dirac
<a name="l00046"></a>00046 {
<a name="l00047"></a>00047 
<a name="l00048"></a><a class="code" href="a00234.html#7a049e12b5746a1b3da88a3e94d04069">00048</a>     <span class="keyword">typedef</span> std::vector&lt; std::vector&lt; MVector &gt; &gt; <a class="code" href="a00234.html#7a049e12b5746a1b3da88a3e94d04069">CandidateList</a>;
<a name="l00049"></a>00049 
<a name="l00051"></a>00051     <span class="comment">/*</span>
<a name="l00052"></a>00052 <span class="comment">        Add a new motion vector list to the set of lists consisting of the </span>
<a name="l00053"></a>00053 <span class="comment">        square neighbourhood [mv.x-xr,mv.x+xr] by </span>
<a name="l00054"></a>00054 <span class="comment">        [mv.y-yr,mv.y+yr]. Vectors that already occur in previous lists are </span>
<a name="l00055"></a>00055 <span class="comment">        not added.</span>
<a name="l00056"></a>00056 <span class="comment">    */</span>
<a name="l00057"></a>00057     <span class="keywordtype">void</span> <a class="code" href="a00234.html#524e48f9dc4ba016402cddf8f234c85e" title="Add a new motion vector list of neighbours of a vector to the set of lists.">AddNewVlist</a>( <a class="code" href="a00234.html#7a049e12b5746a1b3da88a3e94d04069">CandidateList</a>&amp; vect_list , <span class="keyword">const</span> <a class="code" href="a00091.html" title="Motion vector class - just a pair.">MVector</a>&amp; mv , <span class="keyword">const</span> <span class="keywordtype">int</span> xr , <span class="keyword">const</span> <span class="keywordtype">int</span> yr );
<a name="l00058"></a>00058 
<a name="l00060"></a>00060     <span class="comment">/*</span>
<a name="l00061"></a>00061 <span class="comment">        Add a new motion vector list to the set of lists consisting of the </span>
<a name="l00062"></a>00062 <span class="comment">        vectors of the form (mv.x+m*step,mv.y+n*step) where m lies between </span>
<a name="l00063"></a>00063 <span class="comment">        -xr and xr and n lies between -yr and yr.  Vectors that already occur </span>
<a name="l00064"></a>00064 <span class="comment">        in previous lists are not added. </span>
<a name="l00065"></a>00065 <span class="comment">    */</span>
<a name="l00066"></a>00066     <span class="keywordtype">void</span> <a class="code" href="a00234.html#524e48f9dc4ba016402cddf8f234c85e" title="Add a new motion vector list of neighbours of a vector to the set of lists.">AddNewVlist</a>( <a class="code" href="a00234.html#7a049e12b5746a1b3da88a3e94d04069">CandidateList</a>&amp; vect_list , <span class="keyword">const</span> <a class="code" href="a00091.html" title="Motion vector class - just a pair.">MVector</a>&amp; mv , <span class="keyword">const</span> <span class="keywordtype">int</span> xr , <span class="keyword">const</span> <span class="keywordtype">int</span> yr , <span class="keyword">const</span> <span class="keywordtype">int</span> step );
<a name="l00067"></a>00067 
<a name="l00069"></a>00069     <span class="comment">/*</span>
<a name="l00070"></a>00070 <span class="comment">        Add a new motion vector list to the set of lists consisting of the</span>
<a name="l00071"></a>00071 <span class="comment">        diagonal neighbourhood of height 2yr+1 pixels and width 2xr+1 centred</span>
<a name="l00072"></a>00072 <span class="comment">        on \param mv.</span>
<a name="l00073"></a>00073 <span class="comment">        Vectors that already occur in previous lists are not added.</span>
<a name="l00074"></a>00074 <span class="comment">    */</span>
<a name="l00075"></a>00075     <span class="keywordtype">void</span> <a class="code" href="a00234.html#51b044eb401b6d705c36b6a77ca43570" title="Add a new motion vector list of diagnonal neighbours of a vector to the set of lists...">AddNewVlistD</a>( <a class="code" href="a00234.html#7a049e12b5746a1b3da88a3e94d04069">CandidateList</a>&amp; vect_list , <span class="keyword">const</span> <a class="code" href="a00091.html" title="Motion vector class - just a pair.">MVector</a>&amp; mv , <span class="keyword">const</span> <span class="keywordtype">int</span> xr, <span class="keyword">const</span> <span class="keywordtype">int</span> yr);
<a name="l00076"></a>00076 
<a name="l00078"></a>00078 
<a name="l00082"></a>00082     <span class="keywordtype">void</span> <a class="code" href="a00234.html#6b1cb8f8ba391ab0cc358f8dfeba3bf4" title="Add a motion vector to the set of motion vector lists.">AddVect</a>( <a class="code" href="a00234.html#7a049e12b5746a1b3da88a3e94d04069">CandidateList</a>&amp; vect_list , <span class="keyword">const</span> <a class="code" href="a00091.html" title="Motion vector class - just a pair.">MVector</a>&amp; mv , <span class="keyword">const</span> <span class="keywordtype">int</span> list_num);
<a name="l00083"></a>00083 
<a name="l00085"></a>00085 
<a name="l00089"></a>00089     <a class="code" href="a00234.html#548820ca76f864dc8630df79b2c5c5b9" title="Type of picture data (including motion compensated residuals).">ValueType</a> <a class="code" href="a00234.html#0853b9aea00fbc49012ea28e9c8704b7" title="Get the (absolute) variation between two motion vectors.">GetVar</a>(<span class="keyword">const</span> <a class="code" href="a00091.html" title="Motion vector class - just a pair.">MVector</a>&amp; mv1,<span class="keyword">const</span> <a class="code" href="a00091.html" title="Motion vector class - just a pair.">MVector</a>&amp; mv2);
<a name="l00090"></a>00090 
<a name="l00092"></a>00092 
<a name="l00098"></a>00098     <a class="code" href="a00234.html#548820ca76f864dc8630df79b2c5c5b9" title="Type of picture data (including motion compensated residuals).">ValueType</a> <a class="code" href="a00234.html#0853b9aea00fbc49012ea28e9c8704b7" title="Get the (absolute) variation between two motion vectors.">GetVar</a>(<span class="keyword">const</span> std::vector&lt;MVector&gt;&amp; pred_list,<span class="keyword">const</span> <a class="code" href="a00091.html" title="Motion vector class - just a pair.">MVector</a>&amp; mv);
<a name="l00099"></a>00099 
<a name="l00100"></a>00100 
<a name="l00102"></a>00102 
<a name="l00103"></a>00103     <span class="comment">// Subsumes FindBestMatch and FindBestMatchSubpel</span>
<a name="l00104"></a><a class="code" href="a00015.html">00104</a>     <span class="keyword">class </span><a class="code" href="a00015.html" title="Class to do block matching.">BlockMatcher</a>
<a name="l00105"></a>00105     {
<a name="l00106"></a>00106     <span class="keyword">public</span>:
<a name="l00108"></a>00108 
<a name="l00118"></a>00118         <a class="code" href="a00015.html#b6caac3cc446d72ae7d427cfa4f68b0f" title="Constructor.">BlockMatcher</a>( <span class="keyword">const</span> <a class="code" href="a00107.html" title="A class for picture component data.">PicArray</a>&amp; ref_data , 
<a name="l00119"></a>00119                       <span class="keyword">const</span> <a class="code" href="a00107.html" title="A class for picture component data.">PicArray</a>&amp; pic_data , 
<a name="l00120"></a>00120                       <span class="keyword">const</span> <a class="code" href="a00096.html" title="Parameters for overlapped block motion compensation.">OLBParams</a>&amp; bparams ,
<a name="l00121"></a>00121                       <span class="keyword">const</span> <span class="keywordtype">int</span> precision , 
<a name="l00122"></a>00122                       <span class="keyword">const</span> <a class="code" href="a00145.html" title="A template class for two-dimensional arrays.">MvArray</a>&amp; mv_array ,
<a name="l00123"></a>00123                       <span class="keyword">const</span> <a class="code" href="a00145.html">TwoDArray&lt; MvCostData &gt;</a>&amp; cost_array);
<a name="l00124"></a>00124 
<a name="l00125"></a>00125         <a class="code" href="a00015.html#06831555e6ca28bb21169678a8c49735">~BlockMatcher</a>();
<a name="l00126"></a>00126 
<a name="l00128"></a>00128 
<a name="l00136"></a>00136         <span class="keywordtype">void</span> <a class="code" href="a00015.html#69bd6a2f1ee6fdc94bb0a2dffd370d31" title="Find the best matching vector from a list of candidates.">FindBestMatchPel</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="l00137"></a>00137                                            <span class="keyword">const</span> <a class="code" href="a00234.html#7a049e12b5746a1b3da88a3e94d04069">CandidateList</a>&amp; cand_list,
<a name="l00138"></a>00138                                            <span class="keyword">const</span> <a class="code" href="a00091.html">MVector</a>&amp; mv_prediction,
<a name="l00139"></a>00139                                            <span class="keyword">const</span> <span class="keywordtype">int</span> list_start);
<a name="l00140"></a>00140 
<a name="l00142"></a>00142 
<a name="l00150"></a>00150         <span class="keywordtype">void</span> <a class="code" href="a00015.html#90ee187e09f295a757801c842af9be66" title="Find the best matching vector from a list of candidates, to sub-pixel accuracy (TBC:...">FindBestMatchSubp</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="l00151"></a>00151                                 <span class="keyword">const</span> <a class="code" href="a00234.html#7a049e12b5746a1b3da88a3e94d04069">CandidateList</a>&amp; cand_list,
<a name="l00152"></a>00152                                 <span class="keyword">const</span> <a class="code" href="a00091.html">MVector</a>&amp; mv_prediction,
<a name="l00153"></a>00153                                 <span class="keyword">const</span> <span class="keywordtype">float</span> lambda);
<a name="l00154"></a>00154 
<a name="l00155"></a>00155         <span class="keywordtype">void</span> <a class="code" href="a00015.html#4df529c1c6ee506844db63a97b5cf870">RefineMatchSubp</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="l00156"></a>00156                              <span class="keyword">const</span> <a class="code" href="a00091.html">MVector</a>&amp; mv_prediction,
<a name="l00157"></a>00157                              <span class="keyword">const</span> <span class="keywordtype">float</span> lambda);
<a name="l00158"></a>00158 
<a name="l00160"></a>00160 
<a name="l00165"></a>00165         <a class="code" href="a00234.html#548820ca76f864dc8630df79b2c5c5b9" title="Type of picture data (including motion compensated residuals).">ValueType</a> <a class="code" href="a00015.html#e219d37cec219a0d31034ded032fe660" title="Get a measure of the difference between a motion vector and a prediction.">GetVar</a>( <span class="keyword">const</span> <a class="code" href="a00091.html">MVector</a>&amp; predmv , <span class="keyword">const</span> <a class="code" href="a00091.html">MVector</a>&amp; mv ) <span class="keyword">const</span>;
<a name="l00166"></a>00166 
<a name="l00168"></a>00168 
<a name="l00173"></a>00173         <a class="code" href="a00234.html#548820ca76f864dc8630df79b2c5c5b9" title="Type of picture data (including motion compensated residuals).">ValueType</a> <a class="code" href="a00015.html#3dc86423bed493260b6395596d86a55f" title="Get a measure of the difference between a motion vector and a prediction, to 1/8pel...">GetVarUp</a>( <span class="keyword">const</span> <a class="code" href="a00091.html">MVector</a>&amp; predmv , <span class="keyword">const</span> <a class="code" href="a00091.html">MVector</a>&amp; mv ) <span class="keyword">const</span>;
<a name="l00174"></a>00174 
<a name="l00175"></a><a class="code" href="a00015.html#302ef66860009912eb9a63d8ebc95972">00175</a>         <span class="keywordtype">void</span> <a class="code" href="a00015.html#302ef66860009912eb9a63d8ebc95972">SetPrecision</a>( <span class="keyword">const</span> <span class="keywordtype">int</span> n ){ <a class="code" href="a00015.html#2967e81cfe5aae16ba2a8c6801527961">m_precision</a> = n; }
<a name="l00176"></a>00176 
<a name="l00177"></a>00177     <span class="keyword">private</span>:
<a name="l00178"></a>00178         <span class="comment">// Local copies of the picture and reference</span>
<a name="l00179"></a><a class="code" href="a00015.html#cd8becc031f3256ca03df04402351c4a">00179</a>         <span class="keyword">const</span> <a class="code" href="a00107.html" title="A class for picture component data.">PicArray</a>&amp; <a class="code" href="a00015.html#cd8becc031f3256ca03df04402351c4a">m_pic_data</a>;
<a name="l00180"></a><a class="code" href="a00015.html#8459b385ed4ad127b2c997336b2d3d8b">00180</a>         <span class="keyword">const</span> <a class="code" href="a00107.html" title="A class for picture component data.">PicArray</a>&amp; <a class="code" href="a00015.html#8459b385ed4ad127b2c997336b2d3d8b">m_ref_data</a>;
<a name="l00181"></a>00181         
<a name="l00182"></a>00182         <span class="comment">// Local copy of the motion vector array being populated</span>
<a name="l00183"></a><a class="code" href="a00015.html#a57dc6df068f780a39fd4226e6984cca">00183</a>         <span class="keyword">const</span> <a class="code" href="a00145.html" title="A template class for two-dimensional arrays.">MvArray</a>&amp; <a class="code" href="a00015.html#a57dc6df068f780a39fd4226e6984cca">m_mv_array</a>;
<a name="l00184"></a>00184         
<a name="l00185"></a>00185         <span class="comment">// Local copy of the costs being determined through the matching</span>
<a name="l00186"></a><a class="code" href="a00015.html#5bd686ad76ce09ac9987ccf5b9ec8b12">00186</a>         <span class="keyword">const</span> <a class="code" href="a00145.html">TwoDArray&lt; MvCostData &gt;</a>&amp; <a class="code" href="a00015.html#5bd686ad76ce09ac9987ccf5b9ec8b12">m_cost_array</a>; 
<a name="l00187"></a>00187 
<a name="l00188"></a>00188         <span class="comment">// Block difference elements. Will choose between them depending </span>
<a name="l00189"></a>00189         <span class="comment">// on whether we're at the edge of the picture</span>
<a name="l00190"></a><a class="code" href="a00015.html#f235ba73c81e325b4986c4715d5c4f96">00190</a>         <a class="code" href="a00106.html" title="A class for doing block differences to pixel accuracy, inherited from BlockDiff.">PelBlockDiff</a> <a class="code" href="a00015.html#f235ba73c81e325b4986c4715d5c4f96">m_peldiff</a>;
<a name="l00191"></a>00191 
<a name="l00192"></a><a class="code" href="a00015.html#75f779db1e09ed7d04897575db3e92d9">00192</a>         <a class="code" href="a00097.html">OneDArray&lt;BlockDiffUp* &gt;</a> <a class="code" href="a00015.html#75f779db1e09ed7d04897575db3e92d9">m_subpeldiff</a>;
<a name="l00193"></a>00193 
<a name="l00194"></a>00194         <span class="comment">// The block parameters we're using</span>
<a name="l00195"></a><a class="code" href="a00015.html#aa6d7574732ac6dee84f784e4f4a53e6">00195</a>         <a class="code" href="a00096.html" title="Parameters for overlapped block motion compensation.">OLBParams</a> <a class="code" href="a00015.html#aa6d7574732ac6dee84f784e4f4a53e6">m_bparams</a>;
<a name="l00196"></a>00196 
<a name="l00197"></a>00197         <span class="comment">// The maximum variations allowed in calculating motion vector costs</span>
<a name="l00198"></a><a class="code" href="a00015.html#05299996b2f66bf4a581b39bacbf8c31">00198</a>         <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="a00015.html#05299996b2f66bf4a581b39bacbf8c31">m_var_max</a>;
<a name="l00199"></a><a class="code" href="a00015.html#2feb1e0f94107fc4689856225d8b8cfa">00199</a>         <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="a00015.html#2feb1e0f94107fc4689856225d8b8cfa">m_var_max_up</a>;
<a name="l00200"></a>00200 
<a name="l00201"></a>00201         <span class="comment">// The motion vector precision</span>
<a name="l00202"></a><a class="code" href="a00015.html#2967e81cfe5aae16ba2a8c6801527961">00202</a>         <span class="keywordtype">int</span> <a class="code" href="a00015.html#2967e81cfe5aae16ba2a8c6801527961">m_precision</a>;
<a name="l00203"></a>00203 
<a name="l00204"></a>00204     };
<a name="l00205"></a>00205 
<a name="l00206"></a>00206 } <span class="comment">// namespace dirac</span>
<a name="l00207"></a>00207 <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>