Commit | Line | Data |
---|---|---|
72b9787e JB |
1 | /***************************************************************************** |
2 | * Copyright (C) 2013 x265 project | |
3 | * | |
4 | * Authors: Steve Borho <steve@borho.org> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. | |
19 | * | |
20 | * This program is also available under a commercial proprietary license. | |
21 | * For more information, contact us at license @ x265.com. | |
22 | *****************************************************************************/ | |
23 | ||
24 | #ifndef X265_MOTIONESTIMATE_H | |
25 | #define X265_MOTIONESTIMATE_H | |
26 | ||
27 | #include "primitives.h" | |
28 | #include "reference.h" | |
29 | #include "mv.h" | |
30 | #include "bitcost.h" | |
31 | ||
32 | namespace x265 { | |
33 | // private x265 namespace | |
34 | ||
35 | class MotionEstimate : public BitCost | |
36 | { | |
37 | protected: | |
38 | ||
39 | /* Aligned copy of original pixels, extra room for manual alignment */ | |
40 | pixel *fencplane; | |
41 | intptr_t fencLumaStride; | |
42 | ||
43 | pixelcmp_t sad; | |
44 | pixelcmp_t satd; | |
45 | pixelcmp_t sa8d; | |
46 | pixelcmp_x3_t sad_x3; | |
47 | pixelcmp_x4_t sad_x4; | |
48 | ||
49 | intptr_t blockOffset; | |
50 | int partEnum; | |
51 | int searchMethod; | |
52 | int subpelRefine; | |
53 | ||
54 | /* subpel generation buffers */ | |
55 | int blockwidth; | |
56 | int blockheight; | |
57 | ||
58 | MotionEstimate& operator =(const MotionEstimate&); | |
59 | ||
60 | public: | |
61 | ||
62 | static const int COST_MAX = 1 << 28; | |
63 | ||
64 | pixel *fenc; | |
65 | ||
66 | MotionEstimate(); | |
67 | ||
68 | ~MotionEstimate(); | |
69 | ||
70 | void setSearchMethod(int i) { searchMethod = i; } | |
71 | ||
72 | void setSubpelRefine(int i) { subpelRefine = i; } | |
73 | ||
74 | /* Methods called at slice setup */ | |
75 | ||
76 | void setSourcePlane(pixel *Y, intptr_t luma) | |
77 | { | |
78 | fencplane = Y; | |
79 | fencLumaStride = luma; | |
80 | } | |
81 | ||
82 | void setSourcePU(intptr_t offset, int pwidth, int pheight); | |
83 | ||
84 | /* buf*() and motionEstimate() methods all use cached fenc pixels and thus | |
85 | * require setSourcePU() to be called prior. */ | |
86 | ||
87 | inline int bufSAD(pixel *fref, intptr_t stride) { return sad(fenc, FENC_STRIDE, fref, stride); } | |
88 | ||
89 | inline int bufSA8D(pixel *fref, intptr_t stride) { return sa8d(fenc, FENC_STRIDE, fref, stride); } | |
90 | ||
91 | inline int bufSATD(pixel *fref, intptr_t stride) { return satd(fenc, FENC_STRIDE, fref, stride); } | |
92 | ||
93 | int motionEstimate(ReferencePlanes *ref, const MV & mvmin, const MV & mvmax, const MV & qmvp, int numCandidates, const MV * mvc, int merange, MV & outQMv); | |
94 | ||
95 | int subpelCompare(ReferencePlanes * ref, const MV &qmv, pixelcmp_t); | |
96 | ||
97 | protected: | |
98 | ||
99 | inline void StarPatternSearch(ReferencePlanes *ref, | |
100 | const MV & mvmin, | |
101 | const MV & mvmax, | |
102 | MV & bmv, | |
103 | int & bcost, | |
104 | int & bPointNr, | |
105 | int & bDistance, | |
106 | int earlyExitIters, | |
107 | int merange); | |
108 | }; | |
109 | } | |
110 | ||
111 | #endif // ifndef X265_MOTIONESTIMATE_H |