# Dirac - A Video Codec

Created by the British Broadcasting Corporation.

pixel_match.h
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2 *
3 * $Id: pixel_match.h,v 1.11 2008/08/27 00:20:52 asuraparaju Exp $ $Name: Dirac_1_0_2 $
4 *
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 *
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/
11 *
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.
15 *
16 * The Original Code is BBC Research and Development code.
17 *
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.
22 *
23 * Contributor(s): Thomas Davies (Original Author)
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
27 * Public License Version 2.1 (the "LGPL"), in which case the provisions of
28 * the GPL or the LGPL are applicable instead of those above. If you wish to
29 * allow use of your version of this file only under the terms of the either
30 * the GPL or LGPL and not to allow others to use your version of this file
31 * under the MPL, indicate your decision by deleting the provisions above
32 * and replace them with the notice and other provisions required by the GPL
33 * or LGPL. If you do not delete the provisions above, a recipient may use
34 * your version of this file under the terms of any one of the MPL, the GPL
35 * or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
37
38 #ifndef _PIXEL_MATCH_H_
39 #define _PIXEL_MATCH_H_
40
41 /* *************************************************************************
42 *
43 * Class for getting motion vectors to pixel-accuracy
44 *
45 * The class could be implemented in any number of ways. The approach taken
46 * has been to do hierarchical matching, which means doing block matching
47 * on smaller, downcoverted versions of the pictures in order to get a wider
48 * effective search range. At each level of searching the vectors discovered
49 * can be used as guides to the next level of searching, and in this way
50 * large motions can be detected easily. The danger is that the motions of
51 * small objects can be overlooked.
52 *
53 * *************************************************************************/
54
55 #include <libdirac_common/common.h>
56 #include <libdirac_common/motion.h>
57 #include <libdirac_motionest/block_match.h>
58 namespace dirac
59 {
60 class EncQueue;
61 class MvData;
62 class EncoderParams;
63 class PicArray;
64
65
66 class PixelMatcher
67 {
68 public:
69
71 PixelMatcher( const EncoderParams& encp);
72
74 /* Do the searching.
75
76 \param my_buffer the buffer of pictures from which pictures are taken
77 \param pic_num the number of the picture for which motion is to be estimated
78 \param mv_data class in which the measured motion vectors are stored, together with costs
79
80 */
81 void DoSearch( EncQueue& my_buffer, int pic_num );
82
83 private:
84
85 // Member variables
86
88 const EncoderParams& m_encparams;
89
91 const PicturePredParams* m_predparams;
92
93 // the depth of the hierarchical match
94 int m_depth;
95
96 // the level we're at (from 0 to depth)
97 int m_level;
98
99 // the search-range sizes for the hierarchical match
100 int m_xr, m_yr;
101
102 // the search-range sizes for when hierarchical match fails
103 int m_big_xr, m_big_yr;
104
105 // the temporal distances to the reference pictures
106 int m_tdiff[2];
107
108 // the picture sort - I, L1 or L2
109 PictureSort m_psort;
110
111 // list of candidate vectors for checking
112 CandidateList m_cand_list;
113
114 // Prediction used for each block. This is derived from neighbouring blocks
115 // and is used to control the variation in the motion vector field.
116 MVector m_mv_prediction;
117
118 // The value used in computing block cost means with a simple recursive filter
119 double m_rho;
120
121 // The mean of the block cost
122 double m_cost_mean;
123
124 // The mean of the square of the block cost
125 double m_cost_mean_sq;
126
127 private:
128
129 // Functions
130
132 void MakePicHierarchy(const PicArray& data, OneDArray< PicArray* >& down_data);
133
135 void MakeMEDataHierarchy(const OneDArray< PicArray*>& down_data,
136 OneDArray< MEData* >& me_data_set );
137
139 void TidyPics( OneDArray< PicArray*>& down_data );
140
142 void TidyMEData( OneDArray< MEData*>& me_data_set );
143
145 void MatchPic(const PicArray& ref_data , const PicArray& pic_data , MEData& me_data ,
146 const MvData& guide_data, const int ref_id);
147
149 void DoBlock(const int xpos, const int ypos ,
150 const MvArray& guide_array,
151 BlockMatcher& block_match);
152
153 };
154
155 } // namespace dirac
156
157 #endif

© 2004 British Broadcasting Corporation. Dirac code licensed under the Mozilla Public License (MPL) Version 1.1.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.