Newer
Older

Karsten Suehring
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* The copyright in this software is being made available under the BSD
* License, included below. This software may be subject to other third party
* and contributor rights, including patent rights, and no such rights are
* granted under this license.
*
* Copyright (c) 2010-2018, ITU/ISO/IEC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/** \file EncCu.cpp
\brief Coding Unit (CU) encoder class
*/
#include "EncCu.h"
#include "EncLib.h"
#include "Analyze.h"
#include "AQp.h"
#include "CommonLib/dtrace_codingstruct.h"
#include "CommonLib/Picture.h"
#include "CommonLib/UnitTools.h"
#include "CommonLib/dtrace_buffer.h"
#include <stdio.h>
#include <cmath>
#include <algorithm>
#if ENABLE_WPP_PARALLELISM
#include <mutex>
extern std::recursive_mutex g_cache_mutex;
#endif
//! \ingroup EncoderLib
//! \{
// ====================================================================================================================
// Constructor / destructor / create / destroy
// ====================================================================================================================
void EncCu::create( EncCfg* encCfg )
{
unsigned uiMaxWidth = encCfg->getMaxCUWidth();
unsigned uiMaxHeight = encCfg->getMaxCUHeight();
ChromaFormat chromaFormat = encCfg->getChromaFormatIdc();
bool BTnoRQT = encCfg->getQTBT();
unsigned numWidths = gp_sizeIdxInfo->numWidths();
unsigned numHeights = gp_sizeIdxInfo->numHeights();
unsigned maxMEPart = BTnoRQT ? 1 : NUMBER_OF_PART_SIZES;
m_pTempCS = new CodingStructure** [numWidths];
m_pBestCS = new CodingStructure** [numWidths];
m_pTempMotLUTs = new LutMotionCand**[numWidths];
m_pBestMotLUTs = new LutMotionCand**[numWidths];
m_pSplitTempMotLUTs = new LutMotionCand**[numWidths];

Karsten Suehring
committed
for( unsigned w = 0; w < numWidths; w++ )
{
m_pTempCS[w] = new CodingStructure* [numHeights];
m_pBestCS[w] = new CodingStructure* [numHeights];
m_pTempMotLUTs[w] = new LutMotionCand*[numHeights];
m_pBestMotLUTs[w] = new LutMotionCand*[numHeights];
m_pSplitTempMotLUTs[w] = new LutMotionCand*[numHeights];

Karsten Suehring
committed
for( unsigned h = 0; h < numHeights; h++ )
{
unsigned width = gp_sizeIdxInfo->sizeFrom( w );
unsigned height = gp_sizeIdxInfo->sizeFrom( h );
if( ( BTnoRQT || w == h ) && gp_sizeIdxInfo->isCuSize( width ) && gp_sizeIdxInfo->isCuSize( height ) )
{
m_pTempCS[w][h] = new CodingStructure( m_unitCache.cuCache, m_unitCache.puCache, m_unitCache.tuCache );
m_pBestCS[w][h] = new CodingStructure( m_unitCache.cuCache, m_unitCache.puCache, m_unitCache.tuCache );
m_pTempCS[w][h]->create( chromaFormat, Area( 0, 0, width, height ), false );
m_pBestCS[w][h]->create( chromaFormat, Area( 0, 0, width, height ), false );
m_pTempMotLUTs[w][h] = new LutMotionCand ;
m_pBestMotLUTs[w][h] = new LutMotionCand ;
m_pSplitTempMotLUTs[w][h] = new LutMotionCand;
m_pSplitTempMotLUTs[w][h]->currCnt = 0;
m_pSplitTempMotLUTs[w][h]->motionCand = nullptr;
m_pSplitTempMotLUTs[w][h]->motionCand = new MotionInfo[MAX_NUM_HMVP_CANDS];
m_pTempMotLUTs[w][h]->currCnt = 0;
m_pTempMotLUTs[w][h]->motionCand = nullptr;
m_pTempMotLUTs[w][h]->motionCand = new MotionInfo[MAX_NUM_HMVP_CANDS];
m_pBestMotLUTs[w][h]->currCnt = 0;
m_pBestMotLUTs[w][h]->motionCand = nullptr;
m_pBestMotLUTs[w][h]->motionCand = new MotionInfo[MAX_NUM_HMVP_CANDS];

Karsten Suehring
committed
}
else
{
m_pTempCS[w][h] = nullptr;
m_pBestCS[w][h] = nullptr;
#if JVET_L0266_HMVP
m_pTempMotLUTs[w][h] = nullptr;
m_pBestMotLUTs[w][h] = nullptr;
m_pSplitTempMotLUTs[w][h] = nullptr;
#endif

Karsten Suehring
committed
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
}
}
}
// WIA: only the weight==height case is relevant without QTBT
m_pImvTempCS = nullptr;
if( IMV_OFF != encCfg->getIMV() && !BTnoRQT )
{
m_pImvTempCS = new CodingStructure**[numWidths];
for( unsigned w = 0; w < numWidths; w++ )
{
unsigned width = gp_sizeIdxInfo->sizeFrom( w );
unsigned height = gp_sizeIdxInfo->sizeFrom( w );
m_pImvTempCS[w] = new CodingStructure*[maxMEPart];
for( unsigned p = 0; p < maxMEPart; p++ )
{
if( gp_sizeIdxInfo->isCuSize( width ) )
{
m_pImvTempCS[w][p] = new CodingStructure( m_unitCache.cuCache, m_unitCache.puCache, m_unitCache.tuCache );
m_pImvTempCS[w][p]->create( chromaFormat, Area( 0, 0, width, height ), false );
}
else
{
m_pImvTempCS[w][p] = nullptr;
}
}
}
}
m_cuChromaQpOffsetIdxPlus1 = 0;
unsigned maxDepth = numWidths + numHeights;
if( encCfg->getQTBT() )
{
m_modeCtrl = new EncModeCtrlMTnoRQT();
}
else
{
THROW( "Unknown partitioner!" );
}
#if REUSE_CU_RESULTS
m_modeCtrl->create( *encCfg );
#endif
for( unsigned ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ )
{
m_acMergeBuffer[ui].create( chromaFormat, Area( 0, 0, uiMaxWidth, uiMaxHeight ) );
}
m_CtxBuffer.resize( maxDepth );
m_CurrCtx = 0;
}
void EncCu::destroy()
{
bool BTnoRQT = m_pcEncCfg->getQTBT();
unsigned maxMEPart = BTnoRQT ? 1 : NUMBER_OF_PART_SIZES;
Loading
Loading full blame...