1 /*****************************************************************************
2 * Copyright (C) 2013 x265 project
4 * Authors: Steve Borho <steve@borho.org>
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.
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.
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.
20 * This program is also available under a commercial proprietary license.
21 * For more information, contact us at license @ x265.com.
22 *****************************************************************************/
24 #ifndef X265_MOTIONESTIMATE_H
25 #define X265_MOTIONESTIMATE_H
27 #include "primitives.h"
28 #include "reference.h"
34 // private x265 namespace
36 class MotionEstimate
: public BitCost
43 int absPartIdx
; // part index of PU, including CU offset within CTU
55 pixelcmp_t chromaSatd
;
57 MotionEstimate
& operator =(const MotionEstimate
&);
61 static const int COST_MAX
= 1 << 28;
70 void init(int method
, int refine
, int csp
);
72 /* Methods called at slice setup */
74 void setSourcePU(pixel
*fencY
, intptr_t stride
, intptr_t offset
, int pwidth
, int pheight
);
75 void setSourcePU(const Yuv
& srcFencYuv
, int ctuAddr
, int cuPartIdx
, int puPartIdx
, int pwidth
, int pheight
);
77 /* buf*() and motionEstimate() methods all use cached fenc pixels and thus
78 * require setSourcePU() to be called prior. */
80 inline int bufSAD(const pixel
* fref
, intptr_t stride
) { return sad(fencPUYuv
.m_buf
[0], FENC_STRIDE
, fref
, stride
); }
82 inline int bufSATD(const pixel
* fref
, intptr_t stride
) { return satd(fencPUYuv
.m_buf
[0], FENC_STRIDE
, fref
, stride
); }
84 inline int bufChromaSATD(const Yuv
& refYuv
, int puPartIdx
)
86 return chromaSatd(refYuv
.getCbAddr(puPartIdx
), refYuv
.m_csize
, fencPUYuv
.m_buf
[1], fencPUYuv
.m_csize
) +
87 chromaSatd(refYuv
.getCrAddr(puPartIdx
), refYuv
.m_csize
, fencPUYuv
.m_buf
[2], fencPUYuv
.m_csize
);
90 int motionEstimate(ReferencePlanes
* ref
, const MV
& mvmin
, const MV
& mvmax
, const MV
& qmvp
, int numCandidates
, const MV
* mvc
, int merange
, MV
& outQMv
);
92 int subpelCompare(ReferencePlanes
* ref
, const MV
&qmv
, pixelcmp_t
);
96 inline void StarPatternSearch(ReferencePlanes
*ref
,
108 #endif // ifndef X265_MOTIONESTIMATE_H