Coverage Report

Created: 2022-08-24 06:17

/src/x265/source/common/cudata.h
Line
Count
Source (jump to first uncovered line)
1
/*****************************************************************************
2
 * Copyright (C) 2013-2020 MulticoreWare, Inc
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_CUDATA_H
25
#define X265_CUDATA_H
26
27
#include "common.h"
28
#include "slice.h"
29
#include "mv.h"
30
31
307k
#define NUM_TU_DEPTH 21
32
33
namespace X265_NS {
34
// private namespace
35
36
class FrameData;
37
class Slice;
38
struct TUEntropyCodingParameters;
39
struct CUDataMemPool;
40
41
enum PartSize
42
{
43
    SIZE_2Nx2N, // symmetric motion partition,  2Nx2N
44
    SIZE_2NxN,  // symmetric motion partition,  2Nx N
45
    SIZE_Nx2N,  // symmetric motion partition,   Nx2N
46
    SIZE_NxN,   // symmetric motion partition,   Nx N
47
    SIZE_2NxnU, // asymmetric motion partition, 2Nx( N/2) + 2Nx(3N/2)
48
    SIZE_2NxnD, // asymmetric motion partition, 2Nx(3N/2) + 2Nx( N/2)
49
    SIZE_nLx2N, // asymmetric motion partition, ( N/2)x2N + (3N/2)x2N
50
    SIZE_nRx2N, // asymmetric motion partition, (3N/2)x2N + ( N/2)x2N
51
    NUM_SIZES
52
};
53
54
enum PredMode
55
{
56
    MODE_NONE  = 0,
57
    MODE_INTER = (1 << 0),
58
    MODE_INTRA = (1 << 1),
59
    MODE_SKIP  = (1 << 2) | MODE_INTER
60
};
61
62
// motion vector predictor direction used in AMVP
63
enum MVP_DIR
64
{
65
    MD_LEFT = 0,    // MVP of left block
66
    MD_ABOVE,       // MVP of above block
67
    MD_ABOVE_RIGHT, // MVP of above right block
68
    MD_BELOW_LEFT,  // MVP of below left block
69
    MD_ABOVE_LEFT,  // MVP of above left block
70
    MD_COLLOCATED   // MVP of temporal neighbour
71
};
72
73
struct CUGeom
74
{
75
    enum {
76
        INTRA           = 1<<0, // CU is intra predicted
77
        PRESENT         = 1<<1, // CU is not completely outside the frame
78
        SPLIT_MANDATORY = 1<<2, // CU split is mandatory if CU is inside frame and can be split
79
        LEAF            = 1<<3, // CU is a leaf node of the CTU
80
        SPLIT           = 1<<4, // CU is currently split in four child CUs.
81
    };
82
    
83
    // (1 + 4 + 16 + 64) = 85.
84
    enum { MAX_GEOMS = 85 };
85
86
    uint32_t log2CUSize;    // Log of the CU size.
87
    uint32_t childOffset;   // offset of the first child CU from current CU
88
    uint32_t absPartIdx;    // Part index of this CU in terms of 4x4 blocks.
89
    uint32_t numPartitions; // Number of 4x4 blocks in the CU
90
    uint32_t flags;         // CU flags.
91
    uint32_t depth;         // depth of this CU relative from CTU
92
    uint32_t geomRecurId;   // Unique geom id from 0 to MAX_GEOMS - 1 for every depth
93
};
94
95
struct MVField
96
{
97
    MV  mv;
98
    int refIdx;
99
};
100
101
// Structure that keeps the neighbour's MV information.
102
struct InterNeighbourMV
103
{
104
    // Neighbour MV. The index represents the list.
105
    MV mv[2];
106
107
    // Collocated right bottom CU addr.
108
    uint32_t cuAddr[2];
109
110
    // For spatial prediction, this field contains the reference index
111
    // in each list (-1 if not available).
112
    //
113
    // For temporal prediction, the first value is used for the 
114
    // prediction with list 0. The second value is used for the prediction 
115
    // with list 1. For each value, the first four bits are the reference index 
116
    // associated to the PMV, and the fifth bit is the list associated to the PMV.
117
    // if both reference indices are -1, then unifiedRef is also -1
118
    union { int16_t refIdx[2]; int32_t unifiedRef; };
119
};
120
121
typedef void(*cucopy_t)(uint8_t* dst, uint8_t* src); // dst and src are aligned to MIN(size, 32)
122
typedef void(*cubcast_t)(uint8_t* dst, uint8_t val); // dst is aligned to MIN(size, 32)
123
124
// Partition count table, index represents partitioning mode.
125
const uint32_t nbPartsTable[8] = { 1, 2, 2, 4, 2, 2, 2, 2 };
126
127
// Partition table.
128
// First index is partitioning mode. Second index is partition index.
129
// Third index is 0 for partition sizes, 1 for partition offsets. The 
130
// sizes and offsets are encoded as two packed 4-bit values (X,Y). 
131
// X and Y represent 1/4 fractions of the block size.
132
const uint32_t partTable[8][4][2] =
133
{
134
    //        XY
135
    { { 0x44, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 } }, // SIZE_2Nx2N.
136
    { { 0x42, 0x00 }, { 0x42, 0x02 }, { 0x00, 0x00 }, { 0x00, 0x00 } }, // SIZE_2NxN.
137
    { { 0x24, 0x00 }, { 0x24, 0x20 }, { 0x00, 0x00 }, { 0x00, 0x00 } }, // SIZE_Nx2N.
138
    { { 0x22, 0x00 }, { 0x22, 0x20 }, { 0x22, 0x02 }, { 0x22, 0x22 } }, // SIZE_NxN.
139
    { { 0x41, 0x00 }, { 0x43, 0x01 }, { 0x00, 0x00 }, { 0x00, 0x00 } }, // SIZE_2NxnU.
140
    { { 0x43, 0x00 }, { 0x41, 0x03 }, { 0x00, 0x00 }, { 0x00, 0x00 } }, // SIZE_2NxnD.
141
    { { 0x14, 0x00 }, { 0x34, 0x10 }, { 0x00, 0x00 }, { 0x00, 0x00 } }, // SIZE_nLx2N.
142
    { { 0x34, 0x00 }, { 0x14, 0x30 }, { 0x00, 0x00 }, { 0x00, 0x00 } }  // SIZE_nRx2N.
143
};
144
145
// Partition Address table.
146
// First index is partitioning mode. Second index is partition address.
147
const uint32_t partAddrTable[8][4] =
148
{
149
    { 0x00, 0x00, 0x00, 0x00 }, // SIZE_2Nx2N.
150
    { 0x00, 0x08, 0x08, 0x08 }, // SIZE_2NxN.
151
    { 0x00, 0x04, 0x04, 0x04 }, // SIZE_Nx2N.
152
    { 0x00, 0x04, 0x08, 0x0C }, // SIZE_NxN.
153
    { 0x00, 0x02, 0x02, 0x02 }, // SIZE_2NxnU.
154
    { 0x00, 0x0A, 0x0A, 0x0A }, // SIZE_2NxnD.
155
    { 0x00, 0x01, 0x01, 0x01 }, // SIZE_nLx2N.
156
    { 0x00, 0x05, 0x05, 0x05 }  // SIZE_nRx2N.
157
};
158
159
// Holds part data for a CU of a given size, from an 8x8 CU to a CTU
160
class CUData
161
{
162
public:
163
164
    cubcast_t s_partSet[NUM_FULL_DEPTH]; // pointer to broadcast set functions per absolute depth
165
    uint32_t  s_numPartInCUSize;
166
167
    bool          m_vbvAffected;
168
169
    FrameData*    m_encData;
170
    const Slice*  m_slice;
171
172
    cucopy_t      m_partCopy;         // pointer to function that copies m_numPartitions elements
173
    cubcast_t     m_partSet;          // pointer to function that sets m_numPartitions elements
174
    cucopy_t      m_subPartCopy;      // pointer to function that copies m_numPartitions/4 elements, may be NULL
175
    cubcast_t     m_subPartSet;       // pointer to function that sets m_numPartitions/4 elements, may be NULL
176
177
    uint32_t      m_cuAddr;           // address of CTU within the picture in raster order
178
    uint32_t      m_absIdxInCTU;      // address of CU within its CTU in Z scan order
179
    uint32_t      m_cuPelX;           // CU position within the picture, in pixels (X)
180
    uint32_t      m_cuPelY;           // CU position within the picture, in pixels (Y)
181
    uint32_t      m_numPartitions;    // maximum number of 4x4 partitions within this CU
182
183
    uint32_t      m_chromaFormat;
184
    uint32_t      m_hChromaShift;
185
    uint32_t      m_vChromaShift;
186
187
    /* multiple slices informations */
188
    uint8_t      m_bFirstRowInSlice;
189
    uint8_t      m_bLastRowInSlice;
190
    uint8_t      m_bLastCuInSlice;
191
192
    /* Per-part data, stored contiguously */
193
    int8_t*       m_qp;               // array of QP values
194
    int8_t*       m_qpAnalysis;       // array of QP values for analysis reuse
195
    uint8_t*      m_log2CUSize;       // array of cu log2Size TODO: seems redundant to depth
196
    uint8_t*      m_lumaIntraDir;     // array of intra directions (luma)
197
    uint8_t*      m_tqBypass;         // array of CU lossless flags
198
    int8_t*       m_refIdx[2];        // array of motion reference indices per list
199
    uint8_t*      m_cuDepth;          // array of depths
200
    uint8_t*      m_predMode;         // array of prediction modes
201
    uint8_t*      m_partSize;         // array of partition sizes
202
    uint8_t*      m_mergeFlag;        // array of merge flags
203
    uint8_t*      m_skipFlag[2];
204
    uint8_t*      m_interDir;         // array of inter directions
205
    uint8_t*      m_mvpIdx[2];        // array of motion vector predictor candidates or merge candidate indices [0]
206
    uint8_t*      m_tuDepth;          // array of transform indices
207
    uint8_t*      m_transformSkip[3]; // array of transform skipping flags per plane
208
    uint8_t*      m_cbf[3];           // array of coded block flags (CBF) per plane
209
    uint8_t*      m_chromaIntraDir;   // array of intra directions (chroma)
210
    enum { BytesPerPartition = 24 };  // combined sizeof() of all per-part data
211
212
    sse_t*        m_distortion;
213
    coeff_t*      m_trCoeff[3];       // transformed coefficient buffer per plane
214
    int8_t        m_refTuDepth[NUM_TU_DEPTH];   // TU depth of CU at depths 0, 1 and 2
215
216
    MV*           m_mv[2];            // array of motion vectors per list
217
    MV*           m_mvd[2];           // array of coded motion vector deltas per list
218
    enum { TMVP_UNIT_MASK = 0xF0 };  // mask for mapping index to into a compressed (reference) MV field
219
220
    const CUData* m_cuAboveLeft;      // pointer to above-left neighbor CTU
221
    const CUData* m_cuAboveRight;     // pointer to above-right neighbor CTU
222
    const CUData* m_cuAbove;          // pointer to above neighbor CTU
223
    const CUData* m_cuLeft;           // pointer to left neighbor CTU
224
    double m_meanQP;
225
    uint64_t      m_fAc_den[3];
226
    uint64_t      m_fDc_den[3];
227
228
    /* Feature values per CTU for dynamic refinement */
229
    uint64_t*       m_collectCURd;
230
    uint32_t*       m_collectCUVariance;
231
    uint32_t*       m_collectCUCount;
232
233
    CUData();
234
235
    void     initialize(const CUDataMemPool& dataPool, uint32_t depth, const x265_param& param, int instance);
236
    static void calcCTUGeoms(uint32_t ctuWidth, uint32_t ctuHeight, uint32_t maxCUSize, uint32_t minCUSize, CUGeom cuDataArray[CUGeom::MAX_GEOMS]);
237
238
    void     initCTU(const Frame& frame, uint32_t cuAddr, int qp, uint32_t firstRowInSlice, uint32_t lastRowInSlice, uint32_t lastCUInSlice);
239
    void     initSubCU(const CUData& ctu, const CUGeom& cuGeom, int qp);
240
    void     initLosslessCU(const CUData& cu, const CUGeom& cuGeom);
241
242
    void     copyPartFrom(const CUData& cu, const CUGeom& childGeom, uint32_t subPartIdx);
243
    void     setEmptyPart(const CUGeom& childGeom, uint32_t subPartIdx);
244
    void     copyToPic(uint32_t depth) const;
245
246
    /* RD-0 methods called only from encodeResidue */
247
    void     copyFromPic(const CUData& ctu, const CUGeom& cuGeom, int csp, bool copyQp = true);
248
    void     updatePic(uint32_t depth, int picCsp) const;
249
250
775k
    void     setPartSizeSubParts(PartSize size)    { m_partSet(m_partSize, (uint8_t)size); }
251
775k
    void     setPredModeSubParts(PredMode mode)    { m_partSet(m_predMode, (uint8_t)mode); }
252
0
    void     clearCbf()                            { m_partSet(m_cbf[0], 0); if (m_chromaFormat != X265_CSP_I400) { m_partSet(m_cbf[1], 0); m_partSet(m_cbf[2], 0);} }
253
254
    /* these functions all take depth as an absolute depth from CTU, it is used to calculate the number of parts to copy */
255
110k
    void     setQPSubParts(int8_t qp, uint32_t absPartIdx, uint32_t depth)                    { s_partSet[depth]((uint8_t*)m_qp + absPartIdx, (uint8_t)qp); }
256
5.76M
    void     setTUDepthSubParts(uint8_t tuDepth, uint32_t absPartIdx, uint32_t depth)         { s_partSet[depth](m_tuDepth + absPartIdx, tuDepth); }
257
3.59M
    void     setLumaIntraDirSubParts(uint8_t dir, uint32_t absPartIdx, uint32_t depth)        { s_partSet[depth](m_lumaIntraDir + absPartIdx, dir); }
258
4.63M
    void     setChromIntraDirSubParts(uint8_t dir, uint32_t absPartIdx, uint32_t depth)       { s_partSet[depth](m_chromaIntraDir + absPartIdx, dir); }
259
5.76M
    void     setCbfSubParts(uint8_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t depth) { s_partSet[depth](m_cbf[ttype] + absPartIdx, cbf); }
260
7.73M
    void     setCbfPartRange(uint8_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t coveredPartIdxes) { memset(m_cbf[ttype] + absPartIdx, cbf, coveredPartIdxes); }
261
5.76M
    void     setTransformSkipSubParts(uint8_t tskip, TextType ttype, uint32_t absPartIdx, uint32_t depth) { s_partSet[depth](m_transformSkip[ttype] + absPartIdx, tskip); }
262
7.74M
    void     setTransformSkipPartRange(uint8_t tskip, TextType ttype, uint32_t absPartIdx, uint32_t coveredPartIdxes) { memset(m_transformSkip[ttype] + absPartIdx, tskip, coveredPartIdxes); }
263
264
    bool     setQPSubCUs(int8_t qp, uint32_t absPartIdx, uint32_t depth);
265
266
    void     setPUInterDir(uint8_t dir, uint32_t absPartIdx, uint32_t puIdx);
267
    void     setPUMv(int list, const MV& mv, int absPartIdx, int puIdx);
268
    void     setPURefIdx(int list, int8_t refIdx, int absPartIdx, int puIdx);
269
270
46.4M
    uint8_t  getCbf(uint32_t absPartIdx, TextType ttype, uint32_t tuDepth) const { return (m_cbf[ttype][absPartIdx] >> tuDepth) & 0x1; }
271
1.03M
    bool     getQtRootCbf(uint32_t absPartIdx) const                             { return (m_cbf[0][absPartIdx] || ((m_chromaFormat != X265_CSP_I400) && (m_cbf[1][absPartIdx] || m_cbf[2][absPartIdx]))); }
272
    int8_t   getRefQP(uint32_t currAbsIdxInCTU) const;
273
    uint32_t getInterMergeCandidates(uint32_t absPartIdx, uint32_t puIdx, MVField (*candMvField)[2], uint8_t* candDir) const;
274
    void     clipMv(MV& outMV) const;
275
    int      getPMV(InterNeighbourMV *neighbours, uint32_t reference_list, uint32_t refIdx, MV* amvpCand, MV* pmv) const;
276
    void     getNeighbourMV(uint32_t puIdx, uint32_t absPartIdx, InterNeighbourMV* neighbours) const;
277
    void     getIntraTUQtDepthRange(uint32_t tuDepthRange[2], uint32_t absPartIdx) const;
278
    void     getInterTUQtDepthRange(uint32_t tuDepthRange[2], uint32_t absPartIdx) const;
279
0
    uint32_t getBestRefIdx(uint32_t subPartIdx) const { return ((m_interDir[subPartIdx] & 1) << m_refIdx[0][subPartIdx]) | 
280
0
                                                              (((m_interDir[subPartIdx] >> 1) & 1) << (m_refIdx[1][subPartIdx] + 16)); }
281
0
    uint32_t getPUOffset(uint32_t puIdx, uint32_t absPartIdx) const { return (partAddrTable[(int)m_partSize[absPartIdx]][puIdx] << (m_slice->m_param->unitSizeDepth - m_cuDepth[absPartIdx]) * 2) >> 4; }
282
283
0
    uint32_t getNumPartInter(uint32_t absPartIdx) const              { return nbPartsTable[(int)m_partSize[absPartIdx]]; }
284
38.7M
    bool     isIntra(uint32_t absPartIdx) const   { return m_predMode[absPartIdx] == MODE_INTRA; }
285
3.75M
    bool     isInter(uint32_t absPartIdx) const   { return !!(m_predMode[absPartIdx] & MODE_INTER); }
286
0
    bool     isSkipped(uint32_t absPartIdx) const { return m_predMode[absPartIdx] == MODE_SKIP; }
287
0
    bool     isBipredRestriction() const          { return m_log2CUSize[0] == 3 && m_partSize[0] != SIZE_2Nx2N; }
288
289
    void     getPartIndexAndSize(uint32_t puIdx, uint32_t& absPartIdx, int& puWidth, int& puHeight) const;
290
    void     getMvField(const CUData* cu, uint32_t absPartIdx, int picList, MVField& mvField) const;
291
292
    void     getAllowedChromaDir(uint32_t absPartIdx, uint32_t* modeList) const;
293
    int      getIntraDirLumaPredictor(uint32_t absPartIdx, uint32_t* intraDirPred) const;
294
295
86.3k
    uint32_t getSCUAddr() const                  { return (m_cuAddr << m_slice->m_param->unitSizeDepth * 2) + m_absIdxInCTU; }
296
    uint32_t getCtxSplitFlag(uint32_t absPartIdx, uint32_t depth) const;
297
    uint32_t getCtxSkipFlag(uint32_t absPartIdx) const;
298
    void     getTUEntropyCodingParameters(TUEntropyCodingParameters &result, uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma) const;
299
300
    const CUData* getPULeft(uint32_t& lPartUnitIdx, uint32_t curPartUnitIdx) const;
301
    const CUData* getPUAbove(uint32_t& aPartUnitIdx, uint32_t curPartUnitIdx) const;
302
    const CUData* getPUAboveLeft(uint32_t& alPartUnitIdx, uint32_t curPartUnitIdx) const;
303
    const CUData* getPUAboveRight(uint32_t& arPartUnitIdx, uint32_t curPartUnitIdx) const;
304
    const CUData* getPUBelowLeft(uint32_t& blPartUnitIdx, uint32_t curPartUnitIdx) const;
305
306
    const CUData* getQpMinCuLeft(uint32_t& lPartUnitIdx, uint32_t currAbsIdxInCTU) const;
307
    const CUData* getQpMinCuAbove(uint32_t& aPartUnitIdx, uint32_t currAbsIdxInCTU) const;
308
309
    const CUData* getPUAboveRightAdi(uint32_t& arPartUnitIdx, uint32_t curPartUnitIdx, uint32_t partUnitOffset) const;
310
    const CUData* getPUBelowLeftAdi(uint32_t& blPartUnitIdx, uint32_t curPartUnitIdx, uint32_t partUnitOffset) const;
311
312
protected:
313
314
    template<typename T>
315
    void setAllPU(T *p, const T& val, int absPartIdx, int puIdx);
316
317
    int8_t getLastCodedQP(uint32_t absPartIdx) const;
318
    int  getLastValidPartIdx(int absPartIdx) const;
319
320
    bool hasEqualMotion(uint32_t absPartIdx, const CUData& candCU, uint32_t candAbsPartIdx) const;
321
322
    /* Check whether the current PU and a spatial neighboring PU are in same merge region */
323
0
    bool isDiffMER(int xN, int yN, int xP, int yP) const { return ((xN >> 2) != (xP >> 2)) || ((yN >> 2) != (yP >> 2)); }
324
325
    // add possible motion vector predictor candidates
326
    bool getDirectPMV(MV& pmv, InterNeighbourMV *neighbours, uint32_t picList, uint32_t refIdx) const;
327
    bool getIndirectPMV(MV& outMV, InterNeighbourMV *neighbours, uint32_t reference_list, uint32_t refIdx) const;
328
    void getInterNeighbourMV(InterNeighbourMV *neighbour, uint32_t partUnitIdx, MVP_DIR dir) const;
329
330
    bool getColMVP(MV& outMV, int& outRefIdx, int picList, int cuAddr, int absPartIdx) const;
331
    bool getCollocatedMV(int cuAddr, int partUnitIdx, InterNeighbourMV *neighbour) const;
332
333
    MV scaleMvByPOCDist(const MV& inMV, int curPOC, int curRefPOC, int colPOC, int colRefPOC) const;
334
335
    void     deriveLeftRightTopIdx(uint32_t puIdx, uint32_t& partIdxLT, uint32_t& partIdxRT) const;
336
337
    uint32_t deriveCenterIdx(uint32_t puIdx) const;
338
    uint32_t deriveRightBottomIdx(uint32_t puIdx) const;
339
    uint32_t deriveLeftBottomIdx(uint32_t puIdx) const;
340
};
341
342
// TU settings for entropy encoding
343
struct TUEntropyCodingParameters
344
{
345
    const uint16_t *scan;
346
    const uint16_t *scanCG;
347
    ScanType        scanType;
348
    uint32_t        firstSignificanceMapContext;
349
};
350
351
struct CUDataMemPool
352
{
353
    uint8_t* charMemBlock;
354
    coeff_t* trCoeffMemBlock;
355
    MV*      mvMemBlock;
356
    sse_t*   distortionMemBlock;
357
    uint64_t* dynRefineRdBlock;
358
    uint32_t* dynRefCntBlock;
359
    uint32_t* dynRefVarBlock;
360
361
91.2k
    CUDataMemPool() { charMemBlock = NULL; trCoeffMemBlock = NULL; mvMemBlock = NULL; distortionMemBlock = NULL; 
362
91.2k
                      dynRefineRdBlock = NULL; dynRefCntBlock = NULL; dynRefVarBlock = NULL;}
363
364
    bool create(uint32_t depth, uint32_t csp, uint32_t numInstances, const x265_param& param)
365
79.5k
    {
366
79.5k
        uint32_t numPartition = param.num4x4Partitions >> (depth * 2);
367
79.5k
        uint32_t cuSize = param.maxCUSize >> depth;
368
79.5k
        uint32_t sizeL = cuSize * cuSize;
369
79.5k
        if (csp == X265_CSP_I400)
370
0
        {
371
0
            CHECKED_MALLOC(trCoeffMemBlock, coeff_t, (sizeL) * numInstances);
372
0
        }
373
79.5k
        else
374
79.5k
        {            
375
79.5k
            uint32_t sizeC = sizeL >> (CHROMA_H_SHIFT(csp) + CHROMA_V_SHIFT(csp));
376
79.5k
            CHECKED_MALLOC(trCoeffMemBlock, coeff_t, (sizeL + sizeC * 2) * numInstances);
377
79.5k
        }
378
79.5k
        CHECKED_MALLOC(charMemBlock, uint8_t, numPartition * numInstances * CUData::BytesPerPartition);
379
79.5k
        CHECKED_MALLOC_ZERO(mvMemBlock, MV, numPartition * 4 * numInstances);
380
79.5k
        CHECKED_MALLOC(distortionMemBlock, sse_t, numPartition * numInstances);
381
79.5k
        return true;
382
0
    fail:
383
0
        return false;
384
79.5k
    }
385
386
    void destroy()
387
79.5k
    {
388
79.5k
        X265_FREE(trCoeffMemBlock);
389
79.5k
        X265_FREE(mvMemBlock);
390
79.5k
        X265_FREE(charMemBlock);
391
79.5k
        X265_FREE(distortionMemBlock);
392
79.5k
    }
393
};
394
}
395
396
#endif // ifndef X265_CUDATA_H