<!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>quant_chooser.h</h1><a href="a00222.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: quant_chooser.h,v 1.7 2008/05/27 01:29:54 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 <a name="l00039"></a>00039 <span class="preprocessor">#ifndef _QUANT_CHOOSER_H_</span> <a name="l00040"></a>00040 <span class="preprocessor"></span><span class="preprocessor">#define _QUANT_CHOOSER_H_</span> <a name="l00041"></a>00041 <span class="preprocessor"></span> <a name="l00042"></a>00042 <span class="preprocessor">#include <<a class="code" href="a00162.html">libdirac_common/arrays.h</a>></span> <a name="l00043"></a>00043 <span class="preprocessor">#include <<a class="code" href="a00233.html">libdirac_common/wavelet_utils.h</a>></span> <a name="l00044"></a>00044 <span class="preprocessor">#include <<a class="code" href="a00171.html">libdirac_common/common.h</a>></span> <a name="l00045"></a>00045 <a name="l00046"></a>00046 <span class="keyword">namespace </span>dirac <a name="l00047"></a>00047 { <a name="l00049"></a>00049 <a name="l00052"></a><a class="code" href="a00123.html">00052</a> <span class="keyword">class </span><a class="code" href="a00123.html" title="Choose a quantiser.">QuantChooser</a> <a name="l00053"></a>00053 { <a name="l00054"></a>00054 <span class="keyword">public</span>: <a name="l00055"></a>00055 <a name="l00057"></a>00057 <a class="code" href="a00123.html#b4008c1b0b284aa7bf0fec0211a356b2" title="Constructor.">QuantChooser</a>( <span class="keyword">const</span> <a class="code" href="a00021.html" title="A class for wavelet coefficient data.">CoeffArray</a>& pic_data , <span class="keyword">const</span> <span class="keywordtype">float</span> lambda ); <a name="l00058"></a>00058 <a name="l00060"></a>00060 <span class="keywordtype">int</span> <a class="code" href="a00123.html#94aa3cb0a2c4b1c53563009b4e72ac9e" title="Finds the best quantisers for the subband, returning the predicted number of bits...">GetBestQuant</a>( <a class="code" href="a00140.html" title="Class encapsulating all the metadata relating to a wavelet subband.">Subband</a>& node ); <a name="l00061"></a>00061 <a name="l00063"></a><a class="code" href="a00123.html#25a6358d5c860118c0fba48f7b3f9aa7">00063</a> <span class="keywordtype">void</span> <a class="code" href="a00123.html#25a6358d5c860118c0fba48f7b3f9aa7" title="Sets the factor used for correcting the entropy calculation.">SetEntropyCorrection</a>( <span class="keyword">const</span> <span class="keywordtype">float</span> ecfac ){ <a class="code" href="a00123.html#590dfac0e4c699164c3e4d644dc020d6" title="A value for correcting the crude calculation of the entropy.">m_entropy_correctionfactor</a> = ecfac; } <a name="l00064"></a>00064 <span class="keyword">private</span>: <a name="l00066"></a>00066 <a class="code" href="a00123.html#b4008c1b0b284aa7bf0fec0211a356b2" title="Constructor.">QuantChooser</a>(<span class="keyword">const</span> <a class="code" href="a00123.html" title="Choose a quantiser.">QuantChooser</a>& cpy); <a name="l00067"></a>00067 <a name="l00069"></a>00069 <a class="code" href="a00123.html" title="Choose a quantiser.">QuantChooser</a>& <a class="code" href="a00123.html#76129e37e5a673a6b06759ff93d52804" title="Assignment = is private and body-less. This class should not be assigned.">operator=</a>(<span class="keyword">const</span> <a class="code" href="a00123.html" title="Choose a quantiser.">QuantChooser</a>& rhs); <a name="l00070"></a>00070 <a name="l00072"></a>00072 <span class="keywordtype">void</span> <a class="code" href="a00123.html#118277e052f8841e6b54ff5dffca97f5" title="Calculate errors and entropies for integral-bit quantisers.">IntegralErrorCalc</a>( <a class="code" href="a00140.html" title="Class encapsulating all the metadata relating to a wavelet subband.">Subband</a>& node , <span class="keyword">const</span> <span class="keywordtype">int</span> xratio , <span class="keyword">const</span> <span class="keywordtype">int</span> yratio ); <a name="l00073"></a>00073 <a name="l00075"></a>00075 <span class="keywordtype">void</span> <a class="code" href="a00123.html#1712934bc7565b989e82d8b15114e4c7" title="Calculate errors and entropies for non-integral-bit quantisers.">NonIntegralErrorCalc</a>( <a class="code" href="a00140.html" title="Class encapsulating all the metadata relating to a wavelet subband.">Subband</a>& node, <span class="keyword">const</span> <span class="keywordtype">int</span> xratio, <span class="keyword">const</span> <span class="keywordtype">int</span> yratio ); <a name="l00076"></a>00076 <a name="l00078"></a>00078 <span class="keywordtype">void</span> <a class="code" href="a00123.html#9b012b530041db7d25dfde424363f0be" title="Having got statistics, calculate the Lagrangian costs.">LagrangianCalc</a>(); <a name="l00079"></a>00079 <a name="l00081"></a>00081 <span class="keywordtype">void</span> <a class="code" href="a00123.html#f17ae1bc4f93e2849c60651afd1925cf" title="Select the best quantisation index on the basis of the Lagrangian calculations.">SelectBestQuant</a>(); <a name="l00082"></a>00082 <a name="l00083"></a>00083 <a class="code" href="a00234.html#00c36803f51328ff862631abde5071c5" title="Type of wavelet coefficient data (should be larger than ValueType).">CoeffType</a> <a class="code" href="a00123.html#fc292bb9a7a0075a70a020ffb71ee227">BlockAbsMax</a>( <span class="keyword">const</span> <a class="code" href="a00140.html" title="Class encapsulating all the metadata relating to a wavelet subband.">Subband</a>& node ); <a name="l00084"></a>00084 <a name="l00086"></a>00086 <span class="keywordtype">void</span> <a class="code" href="a00123.html#ea66de733967c2d82786b2cb62a8fe1d" title="Set the skip flag for a codeblock.">SetSkip</a>( <a class="code" href="a00017.html" title="Class for encapsulating metadata concerning a block of coefficients in a subband...">CodeBlock</a>& cblock , <span class="keyword">const</span> <span class="keywordtype">int</span> qidx); <a name="l00087"></a>00087 <a name="l00088"></a>00088 <span class="keyword">private</span>: <a name="l00090"></a><a class="code" href="a00123.html#8b5e507767013c31822cf6aa369819dd">00090</a> <span class="keywordtype">float</span> <a class="code" href="a00123.html#8b5e507767013c31822cf6aa369819dd" title="The perceptual weighting factor of the subband being tested.">m_subband_wt</a>; <a name="l00091"></a>00091 <a name="l00093"></a><a class="code" href="a00123.html#6fd66c1c7399e9e802a2dea489437953">00093</a> <span class="keywordtype">int</span> <a class="code" href="a00123.html#6fd66c1c7399e9e802a2dea489437953" title="The smallest quantisation index being tested.">m_bottom_idx</a>; <a name="l00095"></a><a class="code" href="a00123.html#13e688ed5a6e2babf9b84057c0986117">00095</a> <span class="keywordtype">int</span> <a class="code" href="a00123.html#13e688ed5a6e2babf9b84057c0986117" title="The largest quantisation index being tested.">m_top_idx</a>; <a name="l00097"></a><a class="code" href="a00123.html#f7078dbc4f4d85d2e48aec028f178015">00097</a> <span class="keywordtype">int</span> <a class="code" href="a00123.html#f7078dbc4f4d85d2e48aec028f178015" title="The step we use in jumping through the list of quantisers.">m_index_step</a>; <a name="l00098"></a>00098 <a name="l00100"></a><a class="code" href="a00123.html#d6f107fdc61d82529444922c1e048608">00100</a> <span class="keywordtype">int</span> <a class="code" href="a00123.html#d6f107fdc61d82529444922c1e048608" title="The index of the quantiser with the lowest cost.">m_min_idx</a>; <a name="l00101"></a>00101 <a name="l00103"></a><a class="code" href="a00123.html#ec670e4a012d587220aaa648c28ff4c2">00103</a> <span class="keyword">const</span> <a class="code" href="a00021.html" title="A class for wavelet coefficient data.">CoeffArray</a>& <a class="code" href="a00123.html#ec670e4a012d587220aaa648c28ff4c2" title="A local reference to the data under consideration.">m_coeff_data</a>; <a name="l00104"></a>00104 <a name="l00106"></a><a class="code" href="a00123.html#0e65c5fe7ec8f27c4222d7700991ffbf">00106</a> <span class="keyword">const</span> <span class="keywordtype">float</span> <a class="code" href="a00123.html#0e65c5fe7ec8f27c4222d7700991ffbf" title="The lambda value to be used in the Lagrangian calculation.">m_lambda</a>; <a name="l00107"></a>00107 <a name="l00109"></a><a class="code" href="a00123.html#590dfac0e4c699164c3e4d644dc020d6">00109</a> <span class="keywordtype">float</span> <a class="code" href="a00123.html#590dfac0e4c699164c3e4d644dc020d6" title="A value for correcting the crude calculation of the entropy.">m_entropy_correctionfactor</a>; <a name="l00110"></a>00110 <a name="l00112"></a><a class="code" href="a00123.html#a210a777c3f61fb555c413452fb5e342">00112</a> <a class="code" href="a00097.html">OneDArray<int></a> <a class="code" href="a00123.html#a210a777c3f61fb555c413452fb5e342" title="An array used to count the number of zeroes.">m_count0</a>; <a name="l00114"></a><a class="code" href="a00123.html#69715c011a40dffde4fd96b7dee834d7">00114</a> <span class="keywordtype">int</span> <a class="code" href="a00123.html#69715c011a40dffde4fd96b7dee834d7" title="The number of ones (equal to the number of coefficients).">m_count1</a>; <a name="l00116"></a><a class="code" href="a00123.html#fa041ef829fc62ac759491bd61f9b4d0">00116</a> <a class="code" href="a00097.html">OneDArray<int></a> <a class="code" href="a00123.html#fa041ef829fc62ac759491bd61f9b4d0" title="An array used to count the number of positive values.">m_countPOS</a>; <a name="l00118"></a><a class="code" href="a00123.html#d66ccd7833e3a19aa53d2889d998d4bf">00118</a> <a class="code" href="a00097.html">OneDArray<int></a> <a class="code" href="a00123.html#d66ccd7833e3a19aa53d2889d998d4bf" title="An array used to count the number of negative values.">m_countNEG</a>; <a name="l00120"></a><a class="code" href="a00123.html#9ea4f96aa731f3fa6136a0ae9c351b16">00120</a> <a class="code" href="a00097.html">OneDArray<double></a> <a class="code" href="a00123.html#9ea4f96aa731f3fa6136a0ae9c351b16" title="An array used to collate the sum of the perceptually-weighted errors.">m_error_total</a>; <a name="l00122"></a><a class="code" href="a00123.html#cec75d9dfa84f59835e6c698750f6def">00122</a> <a class="code" href="a00097.html">OneDArray<CostType></a> <a class="code" href="a00123.html#cec75d9dfa84f59835e6c698750f6def" title="An array used to collate the computed costs.">m_costs</a>; <a name="l00123"></a>00123 <a name="l00124"></a>00124 }; <a name="l00125"></a>00125 <a name="l00126"></a>00126 } <span class="comment">// namespace dirac</span> <a name="l00127"></a>00127 <a name="l00128"></a>00128 <a name="l00129"></a>00129 <a name="l00130"></a>00130 <span class="preprocessor">#endif</span> </pre></div></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>