/work/vvenc/source/Lib/EncoderLib/InterSearch.h
Line | Count | Source |
1 | | /* ----------------------------------------------------------------------------- |
2 | | The copyright in this software is being made available under the Clear BSD |
3 | | License, included below. No patent rights, trademark rights and/or |
4 | | other Intellectual Property Rights other than the copyrights concerning |
5 | | the Software are granted under this license. |
6 | | |
7 | | The Clear BSD License |
8 | | |
9 | | Copyright (c) 2019-2026, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVenC Authors. |
10 | | All rights reserved. |
11 | | |
12 | | Redistribution and use in source and binary forms, with or without modification, |
13 | | are permitted (subject to the limitations in the disclaimer below) provided that |
14 | | the following conditions are met: |
15 | | |
16 | | * Redistributions of source code must retain the above copyright notice, |
17 | | this list of conditions and the following disclaimer. |
18 | | |
19 | | * Redistributions in binary form must reproduce the above copyright |
20 | | notice, this list of conditions and the following disclaimer in the |
21 | | documentation and/or other materials provided with the distribution. |
22 | | |
23 | | * Neither the name of the copyright holder nor the names of its |
24 | | contributors may be used to endorse or promote products derived from this |
25 | | software without specific prior written permission. |
26 | | |
27 | | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY |
28 | | THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
29 | | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
30 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
31 | | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
32 | | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
33 | | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
34 | | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
35 | | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
36 | | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
37 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
38 | | POSSIBILITY OF SUCH DAMAGE. |
39 | | |
40 | | |
41 | | ------------------------------------------------------------------------------------------- */ |
42 | | /** \file InterSearch.h |
43 | | \brief inter search class (header) |
44 | | */ |
45 | | |
46 | | #pragma once |
47 | | |
48 | | #include "CABACWriter.h" |
49 | | #include "CommonLib/MotionInfo.h" |
50 | | #include "CommonLib/InterPrediction.h" |
51 | | #include "CommonLib/TrQuant.h" |
52 | | #include "CommonLib/Unit.h" |
53 | | #include "CommonLib/UnitPartitioner.h" |
54 | | #include "CommonLib/RdCost.h" |
55 | | #include "CommonLib/CommonDef.h" |
56 | | #include "CommonLib/AffineGradientSearch.h" |
57 | | #include "BvSearchOps.h" |
58 | | |
59 | | #include <unordered_map> |
60 | | #include <vector> |
61 | | |
62 | | //! \ingroup EncoderLib |
63 | | //! \{ |
64 | | |
65 | | namespace vvenc { |
66 | | |
67 | | // ==================================================================================================================== |
68 | | // Class definition |
69 | | // ==================================================================================================================== |
70 | | |
71 | | static const uint32_t MAX_NUM_REF_LIST_ADAPT_SR = 2; |
72 | | static const uint32_t MAX_IDX_ADAPT_SR = MAX_REF_PICS; |
73 | | static const uint32_t NUM_MV_PREDICTORS = 3; |
74 | | |
75 | | struct ModeInfo |
76 | | { |
77 | | uint32_t mergeCand; |
78 | | bool isRegularMerge; |
79 | | bool isMMVD; |
80 | | bool isCIIP; |
81 | | bool isBioOrDmvr; |
82 | | bool isAffine; |
83 | 0 | ModeInfo() {} |
84 | | |
85 | | ModeInfo(const uint32_t mergeCand, const bool isRegularMerge, const bool isMMVD, const bool isCIIP, const bool BioOrDmvr, const bool Affine) : |
86 | 0 | mergeCand(mergeCand), isRegularMerge(isRegularMerge), isMMVD(isMMVD), isCIIP(isCIIP), isBioOrDmvr(BioOrDmvr), isAffine(Affine) {} |
87 | | }; |
88 | | |
89 | | struct BlkUniMvInfo |
90 | | { |
91 | | Mv uniMvs[2][MAX_REF_PICS]; |
92 | | int x, y, w, h; |
93 | | }; |
94 | | |
95 | | struct BlkRecord |
96 | | { |
97 | | std::unordered_map<Mv, Distortion> bvRecord; |
98 | | }; |
99 | | |
100 | | struct BlkUniMvInfoBuffer |
101 | | { |
102 | 0 | const BlkUniMvInfo* getBlkUniMvInfo(int i) const { return &m_uniMvList[(m_uniMvListIdx - 1 - i + m_uniMvListMaxSize) % (m_uniMvListMaxSize)]; } |
103 | 0 | BlkUniMvInfo* getBlkUniMvInfo(int i) { return &m_uniMvList[(m_uniMvListIdx - 1 - i + m_uniMvListMaxSize) % (m_uniMvListMaxSize)]; } |
104 | | // calls fn with each entry from the newest, in the order of getBlkUniMvInfo( 0 ... m_uniMvListSize - 1 ), without its modulo |
105 | | template<typename Fn> |
106 | | void forEachNewestFirst( Fn&& fn ) const |
107 | 0 | { |
108 | 0 | for( int i = 0, idx = m_uniMvListIdx; i < m_uniMvListSize; i++ ) |
109 | 0 | { |
110 | 0 | idx = idx == 0 ? m_uniMvListMaxSize - 1 : idx - 1; |
111 | 0 | fn( m_uniMvList[idx] ); |
112 | 0 | } |
113 | 0 | } Unexecuted instantiation: InterSearch.cpp:void vvenc::BlkUniMvInfoBuffer::forEachNewestFirst<vvenc::InterSearch::xMotionEstimation(vvenc::CodingUnit&, vvenc::UnitBuf<short const>&, vvenc::RefPicList, vvenc::Mv&, int, vvenc::Mv&, int&, unsigned int&, unsigned long&, vvenc::AMVPInfo const&, bool)::$_1>(vvenc::InterSearch::xMotionEstimation(vvenc::CodingUnit&, vvenc::UnitBuf<short const>&, vvenc::RefPicList, vvenc::Mv&, int, vvenc::Mv&, int&, unsigned int&, unsigned long&, vvenc::AMVPInfo const&, bool)::$_1&&) const Unexecuted instantiation: InterSearch.cpp:void vvenc::BlkUniMvInfoBuffer::forEachNewestFirst<vvenc::InterSearch::xTZSearch(vvenc::CodingUnit const&, vvenc::RefPicList, int, vvenc::InterSearch::TZSearchStruct&, vvenc::Mv&, unsigned long&, bool, bool)::$_0>(vvenc::InterSearch::xTZSearch(vvenc::CodingUnit const&, vvenc::RefPicList, int, vvenc::InterSearch::TZSearchStruct&, vvenc::Mv&, unsigned long&, bool, bool)::$_0&&) const |
114 | | |
115 | | void insertUniMvCands( const Area& blkArea, const Mv* cMvTemp) |
116 | 0 | { |
117 | 0 | BlkUniMvInfo* curMvInfo = m_uniMvList + m_uniMvListIdx; |
118 | 0 | int j = 0; |
119 | 0 | for (; j < m_uniMvListSize; j++) |
120 | 0 | { |
121 | 0 | BlkUniMvInfo* prevMvInfo = getBlkUniMvInfo( j ); |
122 | 0 | if ((blkArea.x == prevMvInfo->x) && (blkArea.y == prevMvInfo->y) && (blkArea.width == prevMvInfo->w) && (blkArea.height == prevMvInfo->h)) |
123 | 0 | { |
124 | 0 | break; |
125 | 0 | } |
126 | 0 | } |
127 | | |
128 | | // DTRACE( g_trace_ctx, D_TMP, "%d unimv insert %d, %d [%d %d] \n", g_trace_ctx->getChannelCounter(D_TMP), blkArea.x, blkArea.y, blkArea.width, blkArea.height ); |
129 | 0 | if (j < m_uniMvListSize) |
130 | 0 | { |
131 | 0 | curMvInfo = getBlkUniMvInfo( j ); |
132 | 0 | } |
133 | |
|
134 | 0 | ::memcpy(curMvInfo->uniMvs, cMvTemp, 2 * MAX_REF_PICS * sizeof(Mv)); |
135 | 0 | if (j == m_uniMvListSize) // new element |
136 | 0 | { |
137 | 0 | curMvInfo->x = blkArea.x; |
138 | 0 | curMvInfo->y = blkArea.y; |
139 | 0 | curMvInfo->w = blkArea.width; |
140 | 0 | curMvInfo->h = blkArea.height; |
141 | 0 | m_uniMvListSize = std::min(m_uniMvListSize + 1, m_uniMvListMaxSize); |
142 | 0 | m_uniMvListIdx = (m_uniMvListIdx + 1) % (m_uniMvListMaxSize); |
143 | 0 | } |
144 | 0 | } |
145 | | |
146 | | void savePrevUniMvInfo(const CompArea& blkArea, BlkUniMvInfo &tmpUniMvInfo, bool& isUniMvInfoSaved) |
147 | 0 | { |
148 | 0 | int j = 0; |
149 | 0 | const BlkUniMvInfo* curMvInfo = nullptr; |
150 | 0 | for (; j < m_uniMvListSize; j++) |
151 | 0 | { |
152 | 0 | curMvInfo = getBlkUniMvInfo( j ); |
153 | 0 | if ((blkArea.x == curMvInfo->x) && (blkArea.y == curMvInfo->y) && (blkArea.width == curMvInfo->w) && (blkArea.height == curMvInfo->h)) |
154 | 0 | { |
155 | 0 | break; |
156 | 0 | } |
157 | 0 | } |
158 | |
|
159 | 0 | if (j < m_uniMvListSize) |
160 | 0 | { |
161 | | // DTRACE( g_trace_ctx, D_TMP, "%d unimv save %d, %d [%d %d] \n", g_trace_ctx->getChannelCounter(D_TMP), curMvInfo->x, curMvInfo->y, curMvInfo->w, curMvInfo->h ); |
162 | 0 | isUniMvInfoSaved = true; |
163 | 0 | tmpUniMvInfo = *curMvInfo; |
164 | 0 | } |
165 | 0 | } |
166 | | |
167 | | void addUniMvInfo( const BlkUniMvInfo &tmpUniMVInfo) |
168 | 0 | { |
169 | 0 | int j = 0; |
170 | 0 | BlkUniMvInfo* curMvInfo = nullptr; |
171 | 0 | for (; j < m_uniMvListSize; j++) |
172 | 0 | { |
173 | 0 | curMvInfo = getBlkUniMvInfo( j ); |
174 | 0 | if ((tmpUniMVInfo.x == curMvInfo->x) && (tmpUniMVInfo.y == curMvInfo->y) && (tmpUniMVInfo.w == curMvInfo->w) && (tmpUniMVInfo.h == curMvInfo->h)) |
175 | 0 | { |
176 | 0 | break; |
177 | 0 | } |
178 | 0 | } |
179 | | |
180 | | // DTRACE( g_trace_ctx, D_TMP, "%d unimv add %d, %d [%d %d] \n", g_trace_ctx->getChannelCounter(D_TMP), tmpUniMVInfo.x, tmpUniMVInfo.y, tmpUniMVInfo.w, tmpUniMVInfo.h ); |
181 | 0 | if (j < m_uniMvListSize) |
182 | 0 | { |
183 | 0 | *curMvInfo = tmpUniMVInfo; |
184 | 0 | } |
185 | 0 | else |
186 | 0 | { |
187 | 0 | m_uniMvList[m_uniMvListIdx] = tmpUniMVInfo; |
188 | 0 | m_uniMvListIdx = (m_uniMvListIdx + 1) % m_uniMvListMaxSize; |
189 | 0 | m_uniMvListSize = std::min(m_uniMvListSize + 1, m_uniMvListMaxSize); |
190 | 0 | } |
191 | 0 | } |
192 | | |
193 | 5.11k | void resetUniMvList () { m_uniMvListIdx = 0; m_uniMvListSize = 0; } |
194 | | |
195 | | BlkUniMvInfoBuffer() |
196 | 10.2k | { |
197 | 10.2k | m_uniMvListIdx = 0; |
198 | 10.2k | m_uniMvListSize = 0; |
199 | 10.2k | } |
200 | | |
201 | | ~BlkUniMvInfoBuffer() |
202 | 10.2k | { |
203 | 10.2k | m_uniMvListIdx = 0; |
204 | 10.2k | m_uniMvListSize = 0; |
205 | 10.2k | } |
206 | | |
207 | | static constexpr int m_uniMvListMaxSize = 15; |
208 | | BlkUniMvInfo m_uniMvList[m_uniMvListMaxSize]; |
209 | | int m_uniMvListIdx; |
210 | | int m_uniMvListSize; |
211 | | }; |
212 | | |
213 | | class EncPicture; |
214 | | class EncModeCtrl; |
215 | | class EncCu; |
216 | | |
217 | | struct AffineMVInfo |
218 | | { |
219 | | Mv affMVs[2][MAX_REF_PICS][3]; |
220 | | int x, y, w, h; |
221 | | }; |
222 | | |
223 | | typedef struct |
224 | | { |
225 | | Mv acMvAffine4Para[2][3]; |
226 | | Mv acMvAffine6Para[2][3]; |
227 | | int16_t affine4ParaRefIdx[2]; |
228 | | int16_t affine6ParaRefIdx[2]; |
229 | | bool affine4ParaAvail; |
230 | | bool affine6ParaAvail; |
231 | | } EncAffineMotion; |
232 | | |
233 | | struct AffineProfList |
234 | | { |
235 | | AffineProfList() |
236 | 10.2k | { |
237 | 10.2k | m_affMVListMaxSize = 0; |
238 | 10.2k | m_affMVList = nullptr; |
239 | 10.2k | m_affMVListIdx = 0; |
240 | 10.2k | m_affMVListSize = 0; |
241 | 10.2k | } |
242 | | |
243 | | void init( bool bLowDelay ) |
244 | 10.2k | { |
245 | 10.2k | m_affMVListMaxSize = bLowDelay ? AFFINE_ME_LIST_SIZE_LD : AFFINE_ME_LIST_SIZE; |
246 | 10.2k | if( !m_affMVList) |
247 | 10.2k | { |
248 | 10.2k | m_affMVList = new AffineMVInfo[m_affMVListMaxSize]; |
249 | 10.2k | } |
250 | 10.2k | m_affMVListIdx = 0; |
251 | 10.2k | m_affMVListSize = 0; |
252 | 10.2k | } |
253 | | |
254 | | ~AffineProfList() |
255 | 10.2k | { |
256 | 10.2k | if( m_affMVList) |
257 | 10.2k | { |
258 | 10.2k | delete[] m_affMVList; |
259 | 10.2k | m_affMVList = nullptr; |
260 | 10.2k | } |
261 | 10.2k | m_affMVListIdx = 0; |
262 | 10.2k | m_affMVListSize = 0; |
263 | 10.2k | } |
264 | | |
265 | 5.11k | void resetAffineMVList() { m_affMVListIdx = 0; m_affMVListSize = 0; } |
266 | | bool savePrevAffMVInfo(int idx, AffineMVInfo &tmpMVInfo ) |
267 | 81.1k | { |
268 | 81.1k | if( m_affMVListSize > idx) |
269 | 0 | { |
270 | 0 | tmpMVInfo = m_affMVList[(m_affMVListIdx - 1 - idx + m_affMVListMaxSize) % m_affMVListMaxSize]; |
271 | 0 | return true; |
272 | 0 | } |
273 | | |
274 | 81.1k | return false; |
275 | 81.1k | } |
276 | | |
277 | | void addAffMVInfo(AffineMVInfo &tmpMVInfo) |
278 | 0 | { |
279 | 0 | int j = 0; |
280 | 0 | AffineMVInfo *prevInfo = nullptr; |
281 | 0 | for (; j < m_affMVListSize; j++) |
282 | 0 | { |
283 | 0 | prevInfo = m_affMVList + ((m_affMVListIdx - j - 1 + m_affMVListMaxSize) % (m_affMVListMaxSize)); |
284 | 0 | if ((tmpMVInfo.x == prevInfo->x) && (tmpMVInfo.y == prevInfo->y) && (tmpMVInfo.w == prevInfo->w) && (tmpMVInfo.h == prevInfo->h)) |
285 | 0 | { |
286 | 0 | break; |
287 | 0 | } |
288 | 0 | } |
289 | 0 | if (j < m_affMVListSize) |
290 | 0 | { |
291 | 0 | *prevInfo = tmpMVInfo; |
292 | 0 | } |
293 | 0 | else |
294 | 0 | { |
295 | 0 | m_affMVList[m_affMVListIdx] = tmpMVInfo; |
296 | 0 | m_affMVListIdx = (m_affMVListIdx + 1) % m_affMVListMaxSize; |
297 | 0 | m_affMVListSize = std::min(m_affMVListSize + 1, m_affMVListMaxSize); |
298 | 0 | } |
299 | 0 | } |
300 | | |
301 | | void insert( const AffineMVInfo& cMvTemp, const Area& area ) |
302 | 0 | { |
303 | 0 | AffineMVInfo *affMVInfo = m_affMVList + m_affMVListIdx; |
304 | | |
305 | | //check; |
306 | 0 | int j = 0; |
307 | 0 | for (; j < m_affMVListSize; j++) |
308 | 0 | { |
309 | 0 | AffineMVInfo *prevMvInfo = m_affMVList + ((m_affMVListIdx - j - 1 + m_affMVListMaxSize) % (m_affMVListMaxSize)); |
310 | 0 | if ((area.x == prevMvInfo->x) && (area.y == prevMvInfo->y) && (area.width == prevMvInfo->w) && (area.height == prevMvInfo->h)) |
311 | 0 | { |
312 | 0 | break; |
313 | 0 | } |
314 | 0 | } |
315 | 0 | if (j < m_affMVListSize) |
316 | 0 | { |
317 | 0 | affMVInfo = m_affMVList + ((m_affMVListIdx - j - 1 + m_affMVListMaxSize) % (m_affMVListMaxSize)); |
318 | 0 | } |
319 | |
|
320 | 0 | ::memcpy(affMVInfo->affMVs, cMvTemp.affMVs, sizeof(cMvTemp.affMVs)); |
321 | |
|
322 | 0 | if (j == m_affMVListSize) |
323 | 0 | { |
324 | 0 | affMVInfo->x = area.x; |
325 | 0 | affMVInfo->y = area.y; |
326 | 0 | affMVInfo->w = area.width; |
327 | 0 | affMVInfo->h = area.height; |
328 | 0 | m_affMVListSize = std::min(m_affMVListSize + 1, m_affMVListMaxSize); |
329 | 0 | m_affMVListIdx = (m_affMVListIdx + 1) % (m_affMVListMaxSize); |
330 | 0 | } |
331 | 0 | } |
332 | | |
333 | | AffineMVInfo* m_affMVList; |
334 | | int m_affMVListIdx; |
335 | | int m_affMVListSize; |
336 | | int m_affMVListMaxSize; |
337 | | }; |
338 | | |
339 | | struct ReuseUniMv |
340 | | { |
341 | | Mv* m_reusedUniMVs[6][6][32][32]; |
342 | | |
343 | | ReuseUniMv(); |
344 | | ~ReuseUniMv(); |
345 | | void resetReusedUniMvs(); |
346 | | }; |
347 | | |
348 | | // The SATDs of the affine AMVP candidates tested for the CU under test. Later searches of the CU bring many candidates |
349 | | // back, and the same inputs give the same prediction and SATD. A full table overwrites its oldest entry: a lost entry |
350 | | // only costs the test again. |
351 | | class AffineTemplateDistCache |
352 | | { |
353 | | public: |
354 | | void startCu( const Picture* picture, const int poc, const Area& area ) |
355 | 0 | { |
356 | 0 | if( picture != m_picture || poc != m_poc || !( area == m_area ) ) |
357 | 0 | { |
358 | 0 | m_picture = picture; |
359 | 0 | m_poc = poc; |
360 | 0 | m_area = area; |
361 | 0 | m_size = 0; |
362 | 0 | m_next = 0; |
363 | 0 | } |
364 | 0 | } |
365 | | |
366 | | bool find( const Picture* ref, const Mv* mv, const int mvNum, const int predSettings, Distortion& dist ) const |
367 | 0 | { |
368 | 0 | for( int i = 0; i < m_size; i++ ) |
369 | 0 | { |
370 | 0 | const Entry& entry = m_entries[i]; |
371 | 0 | if( entry.ref == ref && entry.predSettings == predSettings && entry.mv[0] == mv[0] && entry.mv[1] == mv[1] && ( mvNum == 2 || entry.mv[2] == mv[2] ) ) |
372 | 0 | { |
373 | 0 | dist = entry.dist; |
374 | 0 | return true; |
375 | 0 | } |
376 | 0 | } |
377 | 0 | return false; |
378 | 0 | } |
379 | | |
380 | | void add( const Picture* ref, const Mv* mv, const int predSettings, const Distortion dist ) |
381 | 0 | { |
382 | 0 | Entry& entry = m_entries[m_next]; |
383 | 0 | entry.ref = ref; |
384 | 0 | entry.mv[0] = mv[0]; |
385 | 0 | entry.mv[1] = mv[1]; |
386 | 0 | entry.mv[2] = mv[2]; |
387 | 0 | entry.predSettings = predSettings; |
388 | 0 | entry.dist = dist; |
389 | 0 | m_next = ( m_next + 1 ) % NUM_ENTRIES; |
390 | 0 | if( m_size < NUM_ENTRIES ) |
391 | 0 | { |
392 | 0 | m_size++; |
393 | 0 | } |
394 | 0 | } |
395 | | |
396 | | private: |
397 | | struct Entry |
398 | | { |
399 | | const Picture* ref; |
400 | | Mv mv[3]; |
401 | | int predSettings; |
402 | | Distortion dist; |
403 | | }; |
404 | | static const int NUM_ENTRIES = 32; |
405 | | |
406 | | Entry m_entries[NUM_ENTRIES]; |
407 | | const Picture* m_picture = nullptr; |
408 | | int m_poc = 0; |
409 | | Area m_area; |
410 | | int m_size = 0; |
411 | | int m_next = 0; |
412 | | }; |
413 | | |
414 | | // What affine motion searches of one block found at the control-point MVs they tested: the distortion of the prediction |
415 | | // and the gradient step from there. A block is searched many times (per reference and list, per model, again when other |
416 | | // split paths reach it), and the searches come back to the same MVs. Both numbers depend only on the key, so they are read |
417 | | // back. A direct-mapped table: a new set takes the slot of an old one, and a new picture empties the table. |
418 | | class AffineMeResultCache |
419 | | { |
420 | | public: |
421 | | static constexpr int NUM_ENTRIES_LOG2 = 10; |
422 | | static constexpr int NUM_ENTRIES = 1 << NUM_ENTRIES_LOG2; |
423 | | |
424 | | void startSearch( const Picture* picture, const int poc, const Picture* ref, const Area& area, const int settings, const int otherRefIdx, const Mv* otherMv, const int mvNum ) |
425 | 0 | { |
426 | 0 | if( m_entries.empty() ) |
427 | 0 | { |
428 | 0 | m_entries.resize( NUM_ENTRIES ); |
429 | 0 | } |
430 | 0 | if( picture != m_picture || poc != m_poc ) |
431 | 0 | { |
432 | 0 | m_picture = picture; |
433 | 0 | m_poc = poc; |
434 | 0 | m_generation++; |
435 | 0 | } |
436 | 0 | m_search.ref = ref; |
437 | 0 | m_search.x = area.x; |
438 | 0 | m_search.y = area.y; |
439 | 0 | m_search.width = area.width; |
440 | 0 | m_search.height = area.height; |
441 | 0 | m_search.settings = settings; |
442 | 0 | m_search.otherRefIdx = otherRefIdx; |
443 | 0 | for( int i = 0; i < 3; i++ ) |
444 | 0 | { |
445 | 0 | m_search.otherMv[i] = otherMv && i < mvNum ? otherMv[i] : Mv(); |
446 | 0 | } |
447 | 0 | m_mvNum = mvNum; |
448 | 0 | uint64_t h = ( uint64_t( uintptr_t( ref ) ) >> 4 ) ^ ( uint64_t( uint32_t( area.x ) ) << 40 ) ^ ( uint64_t( uint32_t( area.y ) ) << 24 ) ^ ( uint64_t( uint32_t( area.width ) ) << 12 ) ^ uint64_t( uint32_t( area.height ) ); |
449 | 0 | h = ( h ^ uint64_t( uint32_t( settings ) ) ) * HASH_MUL; |
450 | 0 | if( otherMv ) |
451 | 0 | { |
452 | 0 | h = ( h ^ uint64_t( uint32_t( otherRefIdx ) ) ) * HASH_MUL; |
453 | 0 | for( int i = 0; i < mvNum; i++ ) |
454 | 0 | { |
455 | 0 | h = ( h ^ uint64_t( uint32_t( otherMv[i].hor ) ) ^ ( uint64_t( uint32_t( otherMv[i].ver ) ) << 32 ) ) * HASH_MUL; |
456 | 0 | } |
457 | 0 | } |
458 | 0 | m_searchHash = h; |
459 | 0 | } |
460 | | |
461 | | bool findDist( const Mv* mv, Distortion& dist ) const |
462 | 0 | { |
463 | 0 | const Entry& entry = m_entries[slot( mv )]; |
464 | 0 | if( entry.hasDist && isFor( entry, mv ) ) |
465 | 0 | { |
466 | 0 | dist = entry.dist; |
467 | 0 | return true; |
468 | 0 | } |
469 | 0 | return false; |
470 | 0 | } |
471 | | |
472 | | void addDist( const Mv* mv, const Distortion dist ) |
473 | 0 | { |
474 | 0 | Entry& entry = claim( mv ); |
475 | 0 | entry.dist = dist; |
476 | 0 | entry.hasDist = true; |
477 | 0 | } |
478 | | |
479 | | bool findStep( const Mv* mv, double* step, const int numParams ) const |
480 | 0 | { |
481 | 0 | const Entry& entry = m_entries[slot( mv )]; |
482 | 0 | if( entry.hasStep && isFor( entry, mv ) ) |
483 | 0 | { |
484 | 0 | std::copy_n( entry.step, numParams, step ); |
485 | 0 | return true; |
486 | 0 | } |
487 | 0 | return false; |
488 | 0 | } |
489 | | |
490 | | void addStep( const Mv* mv, const double* step, const int numParams ) |
491 | 0 | { |
492 | 0 | Entry& entry = claim( mv ); |
493 | 0 | std::copy_n( step, numParams, entry.step ); |
494 | 0 | entry.hasStep = true; |
495 | 0 | } |
496 | | |
497 | | private: |
498 | | static constexpr uint64_t HASH_MUL = 0x9E3779B97F4A7C15ull; |
499 | | |
500 | | struct Search |
501 | | { |
502 | | const Picture* ref = nullptr; |
503 | | int x = 0, y = 0, width = 0, height = 0; |
504 | | int settings = 0, otherRefIdx = 0; |
505 | | Mv otherMv[3]; |
506 | | }; |
507 | | |
508 | | struct Entry |
509 | | { |
510 | | Search search; |
511 | | Mv mv[3]; |
512 | | uint32_t generation = 0; |
513 | | bool hasDist = false; |
514 | | bool hasStep = false; |
515 | | Distortion dist = 0; |
516 | | double step[6]; |
517 | | }; |
518 | | |
519 | | int slot( const Mv* mv ) const |
520 | 0 | { |
521 | 0 | uint64_t h = m_searchHash; |
522 | 0 | for( int i = 0; i < m_mvNum; i++ ) |
523 | 0 | { |
524 | 0 | h = ( h ^ uint64_t( uint32_t( mv[i].hor ) ) ^ ( uint64_t( uint32_t( mv[i].ver ) ) << 32 ) ) * HASH_MUL; |
525 | 0 | } |
526 | 0 | return int( h >> ( 64 - NUM_ENTRIES_LOG2 ) ); |
527 | 0 | } |
528 | | |
529 | | bool isFor( const Entry& entry, const Mv* mv ) const |
530 | 0 | { |
531 | 0 | for( int i = 0; i < m_mvNum; i++ ) |
532 | 0 | { |
533 | 0 | if( entry.mv[i] != mv[i] ) |
534 | 0 | { |
535 | 0 | return false; |
536 | 0 | } |
537 | 0 | } |
538 | 0 | const Search& a = entry.search; |
539 | 0 | const Search& b = m_search; |
540 | 0 | return entry.generation == m_generation && a.ref == b.ref && a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height |
541 | 0 | && a.settings == b.settings && a.otherRefIdx == b.otherRefIdx && a.otherMv[0] == b.otherMv[0] && a.otherMv[1] == b.otherMv[1] && a.otherMv[2] == b.otherMv[2]; |
542 | 0 | } |
543 | | |
544 | | Entry& claim( const Mv* mv ) |
545 | 0 | { |
546 | 0 | Entry& entry = m_entries[slot( mv )]; |
547 | 0 | if( !isFor( entry, mv ) ) |
548 | 0 | { |
549 | 0 | entry.search = m_search; |
550 | 0 | entry.generation = m_generation; |
551 | 0 | for( int i = 0; i < 3; i++ ) |
552 | 0 | { |
553 | 0 | entry.mv[i] = i < m_mvNum ? mv[i] : Mv(); |
554 | 0 | } |
555 | 0 | entry.hasDist = false; |
556 | 0 | entry.hasStep = false; |
557 | 0 | } |
558 | 0 | return entry; |
559 | 0 | } |
560 | | |
561 | | std::vector<Entry> m_entries; |
562 | | Search m_search; |
563 | | uint64_t m_searchHash = 0; |
564 | | int m_mvNum = 0; |
565 | | const Picture* m_picture = nullptr; |
566 | | int m_poc = 0; |
567 | | uint32_t m_generation = 1; |
568 | | }; |
569 | | |
570 | | /// encoder search class |
571 | | class InterSearch : public InterPrediction, AffineGradientSearch |
572 | | { |
573 | | private: |
574 | | EncModeCtrl* m_modeCtrl; |
575 | | |
576 | | PelStorage m_tmpPredStorage[NUM_REF_PIC_LIST_01]; |
577 | | PelStorage m_symStartPredB; // luma only: the SMVD start search's list-B prediction kept for the next list-A candidate |
578 | | PelStorage m_tmpStorageLCU; |
579 | | AffineTemplateDistCache m_affineTemplateDists; |
580 | | AffineMeResultCache m_affineMeResults; |
581 | | CodingStructure** m_pSaveCS; |
582 | | |
583 | | ClpRng m_lumaClpRng; |
584 | | Mv m_acBVs[2 * IBC_NUM_CANDIDATES]; |
585 | | unsigned int m_numBVs; |
586 | | BvSearchOps m_bvSearchOps; |
587 | | std::vector<unsigned> m_bvBits; // the block vector bits of one line of search positions |
588 | | IbcBvCand* m_defaultCachedBvs; |
589 | | std::unordered_map< Position, std::unordered_map< Size, BlkRecord> > m_ctuRecord; |
590 | | CompStorage m_orgResiCb[4], m_orgResiCr[4]; // 0:std, 1-3:jointCbCr |
591 | | |
592 | | protected: |
593 | | // interface to option |
594 | | const VVEncCfg* m_pcEncCfg; |
595 | | |
596 | | // interface to classes |
597 | | TrQuant* m_pcTrQuant; |
598 | | |
599 | | // ME parameters |
600 | | int m_iSearchRange; |
601 | | int m_bipredSearchRange; // Search range for bi-prediction |
602 | | vvencMESearchMethod m_motionEstimationSearchMethod; |
603 | | int m_motionEstimationSearchMethodSCC; |
604 | | int m_aaiAdaptSR[MAX_NUM_REF_LIST_ADAPT_SR][MAX_IDX_ADAPT_SR]; |
605 | | |
606 | | // RD computation |
607 | | CABACWriter* m_CABACEstimator; |
608 | | CtxCache* m_CtxCache; |
609 | | DistParam m_cDistParam; |
610 | | RdCost* m_pcRdCost; |
611 | | std::vector<uint32_t> m_mvBitsHor; // xPatternSearch: the motion vector bits of each column's horizontal component |
612 | | |
613 | | Distortion m_hevcCost; |
614 | | EncAffineMotion m_affineMotion; |
615 | | PelStorage m_tmpAffiStorage; |
616 | | Pel* m_tmpAffiError; |
617 | | Pel* m_tmpAffiDeri[2]; |
618 | | MotionInfo m_subPuMiBuf[(MAX_CU_SIZE * MAX_CU_SIZE) >> (MIN_CU_LOG2 << 1)]; |
619 | | // Misc. |
620 | | Pel* m_pTempPel; |
621 | | |
622 | | // AMVP cost computation |
623 | | uint32_t m_auiMVPIdxCost[AMVP_MAX_NUM_CANDS+1][AMVP_MAX_NUM_CANDS+1]; |
624 | | Distortion m_estMinDistSbt[NUMBER_SBT_MODE + 1]; // estimated minimum SSE value of the PU if using a SBT mode |
625 | | uint8_t m_sbtRdoOrder[NUMBER_SBT_MODE]; // order of SBT mode in RDO |
626 | | uint64_t m_tuResiBits[MAX_NUM_TBLOCKS]; // residual bits per component of the CU's single TU |
627 | | bool m_tuResiBitsValid = false; |
628 | | Ctx m_tuLumaCtx; // what luma's coefficients of that TU left in the coefficient contexts |
629 | | Ctx m_tuChromaCtx; // what chroma's left there |
630 | | bool m_skipSbtAll; // to skip all SBT modes for the current PU |
631 | | |
632 | | BcwMotionParam m_uniMotions; |
633 | | uint64_t m_modeTestId = 1; |
634 | | |
635 | | // The BCW passes of a mode test repeat the AMVP derivation with the same inputs: the block, its neighbours, the list, the reference |
636 | | // and the MV resolution. So each result holds for the mode test it was found in. |
637 | | struct AmvpResult |
638 | | { |
639 | | uint64_t modeTestId = 0; |
640 | | AMVPInfo info; |
641 | | Mv mvPred; |
642 | | Distortion dist; |
643 | | int mvpIdx; |
644 | | }; |
645 | | AmvpResult m_amvpResults[IMV_HPEL + 1][NUM_REF_PIC_LIST_01][MAX_REF_PICS]; |
646 | | uint8_t m_estWeightIdxBits[BCW_NUM] = { 4, 3, 1, 2, 4 }; |
647 | | bool m_affineModeSelected; |
648 | | |
649 | | public: |
650 | | ReuseUniMv* m_ReuseUniMv; |
651 | | BlkUniMvInfoBuffer* m_BlkUniMvInfoBuffer; |
652 | | AffineProfList* m_AffineProfList; |
653 | | bool m_clipMvInSubPic; |
654 | | |
655 | | public: |
656 | | InterSearch(); |
657 | | virtual ~InterSearch(); |
658 | | |
659 | | void init ( const VVEncCfg& encCfg, TrQuant* pTrQuant, RdCost* pRdCost, EncModeCtrl* pModeCtrl, CodingStructure **pSaveCS ); |
660 | | void setCtuEncRsrc ( CABACWriter* cabacEstimator, CtxCache* ctxCache, ReuseUniMv* pReuseUniMv, BlkUniMvInfoBuffer* pBlkUniMvInfoBuffer, AffineProfList* pAffineProfList, IbcBvCand* pCachedBvs ); |
661 | | |
662 | | void destroy (); |
663 | | |
664 | | /// encoder estimation - inter prediction (non-skip) |
665 | | bool predInterSearch ( CodingUnit& cu, Partitioner& partitioner, double& bestCostInter); |
666 | | |
667 | | /// set ME search range |
668 | | // bestCost: the cost to beat. A candidate at or above it needs no contexts left behind. |
669 | | void encodeResAndCalcRdInterCU ( CodingStructure &cs, Partitioner &partitioner, const bool skipResidual, const double bestCost = MAX_DOUBLE ); |
670 | | |
671 | | void setSearchRange ( const Slice* slice, const VVEncCfg& encCfg ); |
672 | | |
673 | | void resetSavedAffineMotion (); |
674 | | void storeAffineMotion ( Mv acAffineMv[2][3], int16_t affineRefIdx[2], EAffineModel affineType, int BcwIdx); |
675 | | void loadGlobalUniMvs ( const Area& lumaArea, const PreCalcValues& pcv); |
676 | | |
677 | | uint8_t skipSbtByRDCost ( int width, int height, int mtDepth, uint8_t sbtIdx, uint8_t sbtPos, double bestCost, Distortion distSbtOff, double costSbtOff, bool rootCbfSbtOff ); |
678 | 0 | bool getSkipSbtAll () const { return m_skipSbtAll; } |
679 | 0 | uint8_t getSbtRdoOrder ( uint8_t idx ) const { assert( m_sbtRdoOrder[idx] < NUMBER_SBT_MODE ); assert( (uint32_t)( m_estMinDistSbt[m_sbtRdoOrder[idx]] >> 2 ) < ( MAX_UINT >> 1 ) ); return m_sbtRdoOrder[idx]; } |
680 | 0 | Distortion getEstDistSbt ( uint8_t sbtMode) const { return m_estMinDistSbt[sbtMode]; } |
681 | 0 | void initSbtRdoOrder ( uint8_t sbtMode ) { m_sbtRdoOrder[0] = sbtMode; m_estMinDistSbt[0] = m_estMinDistSbt[sbtMode]; } |
682 | | |
683 | | void getBestSbt ( CodingStructure* tempCS, CodingUnit* cu, uint8_t& histBestSbt, Distortion& curPuSse, uint8_t sbtAllowed, bool doPreAnalyzeResi, bool mtsAllowed ); |
684 | | bool predIBCSearch (CodingUnit& cu, Partitioner& partitioner); |
685 | | bool searchBvIBC (const CodingUnit& pu, int xPos, int yPos, int width, int height, int picWidth, int picHeight, int xBv, int yBv, int ctuSize) const; |
686 | | |
687 | 4.65k | void resetCtuRecordIBC () { m_ctuRecord.clear(); } |
688 | | |
689 | 0 | void resetBufferedUniMotions() { m_uniMotions.reset(); m_modeTestId++; } |
690 | 0 | uint8_t getWeightIdxBits ( uint8_t bcwIdx ) { return m_estWeightIdxBits[bcwIdx]; } |
691 | 0 | void setAffineModeSelected ( bool flag ) { m_affineModeSelected = flag; } |
692 | | |
693 | | private: |
694 | | unsigned xMergeCandLists ( Mv* dst, unsigned dn, const unsigned dstTotalLength, const Mv* src, const unsigned sn ) const; |
695 | | // the IBC block vector bits of the count search positions ( x0 + i * xStep, y ) or ( x, y0 + i * yStep ), valid up |
696 | | // to the next call |
697 | | const unsigned* xGetBvBitsRow ( const int x0, const int xStep, const int count, const int y, const bool useIMV ); |
698 | | const unsigned* xGetBvBitsColumn ( const int x, const int y0, const int yStep, const int count, const bool useIMV ); |
699 | | void xCalcMinDistSbt ( CodingStructure &cs, const CodingUnit& cu, const uint8_t sbtAllowed ); |
700 | | /// sub-function for motion vector refinement used in fractional-pel accuracy; centreDistNoMv is the centre position's |
701 | | /// distortion without the MV cost when already known (else MAX_DISTORTION), bestDistNoMv returns the winner's |
702 | | Distortion xPatternRefinement ( const CPelBuf* pcPatternKey, Mv baseRefMv, int iFrac, Mv& rcMvFrac, Distortion& uiDistBest, int& patternId, CPelBuf* pattern, bool useAltHpelIf, |
703 | | Distortion centreDistNoMv, Distortion& bestDistNoMv ); |
704 | | |
705 | | typedef struct |
706 | | { |
707 | | int left; |
708 | | int right; |
709 | | int top; |
710 | | int bottom; |
711 | | } SearchRange; |
712 | | |
713 | | typedef struct |
714 | | { |
715 | | SearchRange searchRange; |
716 | | const CPelBuf* pcPatternKey; |
717 | | const Pel* piRefY; |
718 | | int iRefStride; |
719 | | int iBestX; |
720 | | int iBestY; |
721 | | uint32_t uiBestRound; |
722 | | uint32_t uiBestDistance; |
723 | | Distortion uiBestSad; |
724 | | uint8_t ucPointNr; |
725 | | int subShiftMode; |
726 | | unsigned imvShift; |
727 | | bool useAltHpelIf; |
728 | | bool zeroMV; |
729 | | } TZSearchStruct; |
730 | | |
731 | | // sub-functions for ME |
732 | | struct StartPositions; |
733 | | struct BlockMvClip; |
734 | | template<typename OnCost> |
735 | | void xCostsOfStartPositions ( const StartPositions& startPositions, const int first, const TZSearchStruct& cStruct, OnCost&& onCost ); |
736 | | inline void xTZSearchHelp ( TZSearchStruct& rcStruct, const int iSearchX, const int iSearchY, const uint8_t ucPointNr, const uint32_t uiDistance ); |
737 | | inline void xTZSearchQueued ( TZSearchStruct& rcStruct, const int iSearchX, const int iSearchY, const uint8_t ucPointNr, const uint32_t uiDistance ); |
738 | | inline void xTZSearchFlush ( TZSearchStruct& rcStruct ); |
739 | | struct TZCandidate |
740 | | { |
741 | | int x; |
742 | | int y; |
743 | | Distortion mvCost; |
744 | | uint32_t distance; |
745 | | uint8_t pointNr; |
746 | | }; |
747 | | TZCandidate m_tzQueue[4]; |
748 | | int m_tzQueued = 0; |
749 | | inline void xTZAcceptIfBetter ( TZSearchStruct& rcStruct, const TZCandidate& candidate, const Distortion sad ); |
750 | | inline void xTZ2PointSearch ( TZSearchStruct& rcStruct ); |
751 | | inline void xTZ4PointSquareSearch ( TZSearchStruct& rcStruct, const int iStartX, const int iStartY, const int iDist ); |
752 | | inline void xTZ8PointSquareSearch ( TZSearchStruct& rcStruct, const int iStartX, const int iStartY, const int iDist ); |
753 | | inline void xTZ8PointDiamondSearch( TZSearchStruct& rcStruct, const int iStartX, const int iStartY, const int iDist, const bool bCheckCornersAtDist1 ); |
754 | | |
755 | | // ------------------------------------------------------------------------------------------------------------------- |
756 | | // Inter search (AMP) |
757 | | // ------------------------------------------------------------------------------------------------------------------- |
758 | | |
759 | | void xEstimateMvPredAMVP ( CodingUnit& cu, CPelUnitBuf& origBuf, RefPicList refPicList, int iRefIdx, Mv& rcMvPred, AMVPInfo& amvpInfo, Distortion& distBiP ); |
760 | | void xCheckBestMVP ( RefPicList refPicList, const Mv& cMv, Mv& rcMvPred, int& riMVPIdx, AMVPInfo& amvpInfo, uint32_t& ruiBits, Distortion& ruiCost, const uint8_t imv); |
761 | | Distortion xGetTemplateCost ( const CodingUnit& cu, CPelUnitBuf& origBuf, PelUnitBuf& predBuf, Mv cMvCand, int iMVPIdx, int iMVPNum, RefPicList refPicList, int iRefIdx ); |
762 | | |
763 | | void xCopyAMVPInfo ( AMVPInfo* pSrc, AMVPInfo* pDst ); |
764 | | uint32_t xGetMvpIdxBits ( int iIdx, int iNum ); |
765 | | void xGetBlkBits ( bool bPSlice, int iPartIdx, uint32_t uiLastMode, uint32_t uiBlkBit[3]); |
766 | | |
767 | | |
768 | | // ------------------------------------------------------------------------------------------------------------------- |
769 | | // motion estimation |
770 | | // ------------------------------------------------------------------------------------------------------------------- |
771 | | |
772 | | void xMotionEstimation ( CodingUnit& cu, |
773 | | CPelUnitBuf& origBuf, |
774 | | RefPicList refPicList, |
775 | | Mv& rcMvPred, |
776 | | int iRefIdxPred, |
777 | | Mv& rcMv, |
778 | | int& riMVPIdx, |
779 | | uint32_t& ruiBits, |
780 | | Distortion& ruiCost, |
781 | | const AMVPInfo& amvpInfo, |
782 | | bool bBi = false |
783 | | ); |
784 | | |
785 | | void xTZSearch( const CodingUnit& cu, |
786 | | RefPicList refPicList, |
787 | | int iRefIdxPred, |
788 | | TZSearchStruct& cStruct, |
789 | | Mv& rcMv, |
790 | | Distortion& ruiSAD, |
791 | | const bool bExtendedSettings, |
792 | | const bool bFastSettings = false |
793 | | ); |
794 | | |
795 | | void xClipMvSearch ( Mv& rcMv, const Position& pos, const struct Size& size, const PreCalcValues& pcv, const int ifpLines ); |
796 | | |
797 | | void xClipMvToFppLine ( Mv& mv, const int yB, const int nH, const int ifpLines, const PreCalcValues& pcv ); |
798 | | void xCheckAndClipMvToFppLine ( Mv& mv, const int yB, const int nH, const int ifpLines, const PreCalcValues& pcv ); |
799 | | void xSetSearchRange ( const CodingUnit& cu, |
800 | | const Mv& cMvPred, |
801 | | const int iSrchRng, |
802 | | SearchRange& sr |
803 | | ); |
804 | | |
805 | | void xPatternSearchFast ( const CodingUnit& cu, |
806 | | RefPicList refPicList, |
807 | | int iRefIdxPred, |
808 | | TZSearchStruct& cStruct, |
809 | | Mv& rcMv, |
810 | | Distortion& ruiSAD |
811 | | ); |
812 | | |
813 | | void xPatternSearch ( TZSearchStruct& cStruct, |
814 | | Mv& rcMv, |
815 | | Distortion& ruiSAD, |
816 | | const Mv& knownPosition, |
817 | | const Distortion knownCost |
818 | | ); |
819 | | |
820 | | void xPatternSearchIntRefine ( CodingUnit& cu, |
821 | | TZSearchStruct& cStruct, |
822 | | Mv& rcMv, |
823 | | Mv& rcMvPred, |
824 | | int& riMVPIdx, |
825 | | uint32_t& uiBits, |
826 | | Distortion& ruiCost, |
827 | | const AMVPInfo& amvpInfo, |
828 | | double fWeight |
829 | | ); |
830 | | |
831 | | void xPatternSearchFracDIF ( const CodingUnit& cu, |
832 | | RefPicList refPicList, |
833 | | int iRefIdx, |
834 | | TZSearchStruct& cStruct, |
835 | | const Mv& rcMvInt, |
836 | | Mv& rcMvHalf, |
837 | | Mv& rcMvQter, |
838 | | Distortion& ruiCost |
839 | | ); |
840 | | |
841 | | // the bi search reads only the luma of the other list's prediction (2 * org - other) |
842 | | void xPredOtherListLuma( CodingUnit& cu, PelUnitBuf& pred, const RefPicList list ); |
843 | | void xPredAffineInterSearch ( CodingUnit& cu, |
844 | | CPelUnitBuf& origBuf, |
845 | | int puIdx, |
846 | | uint32_t& lastMode, |
847 | | Distortion& affineCost, |
848 | | Mv hevcMv[2][MAX_REF_PICS], |
849 | | Mv mvAffine4Para[2][MAX_REF_PICS][3], |
850 | | int refIdx4Para[2], |
851 | | uint8_t BcwIdx = BCW_DEFAULT, |
852 | | bool enforceBcwPred = false, |
853 | | uint32_t BcwIdxBits = 0 |
854 | | ); |
855 | | |
856 | | void xAffineMotionEstimation ( CodingUnit& cu, |
857 | | CPelUnitBuf& origBuf, |
858 | | RefPicList refPicList, |
859 | | Mv acMvPred[3], |
860 | | int iRefIdxPred, |
861 | | Mv acMv[3], |
862 | | uint32_t& ruiBits, |
863 | | Distortion& ruiCost, |
864 | | int& mvpIdx, |
865 | | const AffineAMVPInfo& aamvpi, |
866 | | bool bBi = false |
867 | | ); |
868 | | |
869 | | bool xEstimateAffineAMVP ( CodingUnit& cu, AffineAMVPInfo& affineAMVPInfo, CPelUnitBuf& origBuf, RefPicList refPicList, int iRefIdx, Mv acMvPred[3], Distortion& distBiP); |
870 | | |
871 | | Distortion xGetAffineTemplateCost ( CodingUnit& cu, CPelUnitBuf& origBuf, PelUnitBuf& predBuf, Mv acMvCand[3], int iMVPIdx, int iMVPNum, RefPicList refPicList, int iRefIdx); |
872 | | void xCopyAffineAMVPInfo ( AffineAMVPInfo& src, AffineAMVPInfo& dst ); |
873 | | void xCheckBestAffineMVP ( CodingUnit& cu, AffineAMVPInfo &affineAMVPInfo, RefPicList refPicList, Mv acMv[3], Mv acMvPred[3], int& riMVPIdx, uint32_t& ruiBits, Distortion& ruiCost ); |
874 | | uint32_t xCalcAffineMVBits ( CodingUnit& cu, Mv mvCand[3], Mv mvPred[3]); |
875 | | |
876 | | Distortion xGetSymCost ( const CodingUnit& cu, CPelUnitBuf& origBuf, RefPicList eCurRefPicList, const MvField& cCurMvField, MvField& cTarMvField , int BcwIdx ); |
877 | | CPelBuf xSymPred ( const CodingUnit& cu, RefPicList refList, const MvField& mvField, PelUnitBuf& predStorage ); |
878 | | CPelBuf xSymHighFreq ( const CodingUnit& cu, CPelUnitBuf& origBuf, const CPelBuf& predBufA ); |
879 | | Distortion xSymHadCost ( const CodingUnit& cu, const CPelBuf& highFreqA, const CPelBuf& predBufB, RefPicList eTarRefPicList ); |
880 | | CPelBuf xPredSymLuma ( const CodingUnit& cu, const Picture* refPic, const Mv& mv, PelUnitBuf& predBuf ); |
881 | | CPelBuf xPredLumaReadOnly ( const CodingUnit& cu, const Picture* refPic, const Mv& mv, PelUnitBuf& predBuf ); |
882 | | Distortion xSymRefineMvSearch ( CodingUnit& cu, CPelUnitBuf& origBuf, Mv& rcMvCurPred, Mv& rcMvTarPred, RefPicList refPicList, |
883 | | MvField& rCurMvField, MvField& rTarMvField, Distortion uiMinCost, int searchPattern, int nSearchStepShift, uint32_t uiMaxSearchRounds, int BcwIdx ); |
884 | | void xSymMotionEstimation ( CodingUnit& cu, CPelUnitBuf& origBuf, Mv& rcMvCurPred, Mv& rcMvTarPred, RefPicList refPicList, MvField& rCurMvField, MvField& rTarMvField, Distortion& ruiCost, int BcwIdx ); |
885 | | double xGetMEDistortionWeight ( uint8_t BcwIdx, RefPicList refPicList); |
886 | | |
887 | | void xSymMvdCheckBestMvp ( CodingUnit& cu, CPelUnitBuf& origBuf, Mv curMv, RefPicList curRefList, AMVPInfo amvpInfo[2][MAX_REF_PICS], |
888 | | int32_t BcwIdx, Mv cMvPredSym[2], int32_t mvpIdxSym[2], Distortion& bestCost, bool skip ); |
889 | | |
890 | | bool xReadBufferedAffineUniMv ( CodingUnit& cu, RefPicList eRefPicList, int32_t iRefIdx, Mv acMvPred[3], Mv acMv[3], uint32_t& ruiBits, Distortion& ruiCost, int& mvpIdx, const AffineAMVPInfo& aamvpi ); |
891 | | bool xReadBufferedUniMv ( CodingUnit& cu, RefPicList eRefPicList, int32_t iRefIdx, Mv& pcMvPred, Mv& rcMv, uint32_t& ruiBits, Distortion& ruiCost); |
892 | | |
893 | | void xExtDIFUpSamplingH ( CPelBuf* pcPattern, bool useAltHpelIf); |
894 | | void xFilterVerFromReference ( const CPelBuf* pattern, int rowOffset, Pel* dst, int dstStride, int height, int quarterFrac, bool useAltHpelIf ); |
895 | | void xExtDIFUpSamplingQ ( CPelBuf* pcPatternKey, Mv halfPelRef, int& patternId ); |
896 | | |
897 | | void xEncodeInterResidualQT ( CodingStructure &cs, Partitioner &partitioner, const ComponentID compID ); |
898 | | void xEstimateInterResidualQT ( CodingStructure &cs, Partitioner &partitioner, const Ctx& ctxStart, Distortion *puiZeroDist = NULL ); |
899 | | uint64_t xGetSymbolFracBitsInter ( CodingStructure &cs, Partitioner &partitioner ); |
900 | | void xSetIntraSearchRangeIBC ( CodingUnit& pu, int iRoiWidth, int iRoiHeight, Mv& rcMvSrchRngLT, Mv& rcMvSrchRngRB); |
901 | | void xIBCEstimation ( CodingUnit& cu, PelUnitBuf& origBuf, Mv* pcMvPred, Mv& rcMv, Distortion& ruiCost ); |
902 | | void xIBCSearchMVCandUpdate ( Distortion uiSad, int x, int y, Distortion* uiSadBestCand, Mv* cMVCand); |
903 | | int xIBCSearchMVChromaRefine ( CodingUnit& cu, int iRoiWidth, int iRoiHeight, int cuPelX, int cuPelY, Distortion* uiSadBestCand, Mv* cMVCand); |
904 | | void xIntraPatternSearchIBC ( CodingUnit& pu, TZSearchStruct& cStruct, Mv& rcMv, Distortion& ruiCost, Mv* cMvSrchRngLT, Mv* cMvSrchRngRB, Mv* pcMvPred); |
905 | | };// END CLASS DEFINITION EncSearch |
906 | | |
907 | | } // namespace vvenc |
908 | | |
909 | | //! \} |
910 | | |