Coverage Report

Created: 2025-07-23 08:18

/src/x265/source/common/common.h
Line
Count
Source (jump to first uncovered line)
1
/*****************************************************************************
2
 * Copyright (C) 2013-2020 MulticoreWare, Inc
3
 *
4
 * Authors: Deepthi Nandakumar <deepthi@multicorewareinc.com>
5
 *          Min Chen <chenm003@163.com>
6
 *
7
 * This program is free software; you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation; either version 2 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
20
 *
21
 * This program is also available under a commercial proprietary license.
22
 * For more information, contact us at license @ x265.com.
23
 *****************************************************************************/
24
25
#ifndef X265_COMMON_H
26
#define X265_COMMON_H
27
28
#include <algorithm>
29
#include <climits>
30
#include <cmath>
31
#include <cstdarg>
32
#include <cstddef>
33
#include <cstdio>
34
#include <cstdlib>
35
#include <cstring>
36
#include <cctype>
37
#include <ctime>
38
39
#include <stdint.h>
40
#include <memory.h>
41
#include <assert.h>
42
#include <stdlib.h>
43
44
#include "x265.h"
45
46
#if ENABLE_PPA && ENABLE_VTUNE
47
#error "PPA and VTUNE cannot both be enabled. Disable one of them."
48
#endif
49
#if ENABLE_PPA
50
#include "profile/PPA/ppa.h"
51
#define ProfileScopeEvent(x) PPAScopeEvent(x)
52
#define THREAD_NAME(n,i)
53
#define PROFILE_INIT()       PPA_INIT()
54
#define PROFILE_PAUSE()
55
#define PROFILE_RESUME()
56
#elif ENABLE_VTUNE
57
#include "profile/vtune/vtune.h"
58
#define ProfileScopeEvent(x) VTuneScopeEvent _vtuneTask(x)
59
#define THREAD_NAME(n,i)     vtuneSetThreadName(n, i)
60
#define PROFILE_INIT()       vtuneInit()
61
#define PROFILE_PAUSE()      __itt_pause()
62
#define PROFILE_RESUME()     __itt_resume()
63
#else
64
#define ProfileScopeEvent(x)
65
#define THREAD_NAME(n,i)
66
#define PROFILE_INIT()
67
#define PROFILE_PAUSE()
68
#define PROFILE_RESUME()
69
#endif
70
71
0
#define FENC_STRIDE 64
72
0
#define NUM_INTRA_MODE 35
73
74
#if defined(__GNUC__)
75
0
#define ALIGN_VAR_4(T, var)  T var __attribute__((aligned(4)))
76
0
#define ALIGN_VAR_8(T, var)  T var __attribute__((aligned(8)))
77
0
#define ALIGN_VAR_16(T, var) T var __attribute__((aligned(16)))
78
0
#define ALIGN_VAR_32(T, var) T var __attribute__((aligned(32)))
79
#define ALIGN_VAR_64(T, var) T var __attribute__((aligned(64)))
80
#if defined(__MINGW32__)
81
#define fseeko fseeko64
82
#define ftello ftello64
83
#endif
84
#elif defined(_MSC_VER)
85
86
#define ALIGN_VAR_4(T, var)  __declspec(align(4)) T var
87
#define ALIGN_VAR_8(T, var)  __declspec(align(8)) T var
88
#define ALIGN_VAR_16(T, var) __declspec(align(16)) T var
89
#define ALIGN_VAR_32(T, var) __declspec(align(32)) T var
90
#define ALIGN_VAR_64(T, var) __declspec(align(64)) T var
91
#define fseeko _fseeki64
92
#define ftello _ftelli64
93
#endif // if defined(__GNUC__)
94
#if HAVE_INT_TYPES_H
95
#define __STDC_FORMAT_MACROS
96
#include <inttypes.h>
97
#define X265_LL "%" PRIu64
98
#else
99
#define X265_LL "%lld"
100
#endif
101
102
#if _DEBUG && defined(_MSC_VER)
103
#define DEBUG_BREAK() __debugbreak()
104
#elif __APPLE_CC__
105
#define DEBUG_BREAK() __builtin_trap()
106
#else
107
#define DEBUG_BREAK() abort()
108
#endif
109
110
/* If compiled with CHECKED_BUILD perform run-time checks and log any that
111
 * fail, both to stderr and to a file */
112
#if CHECKED_BUILD || _DEBUG
113
namespace X265_NS { extern int g_checkFailures; }
114
#define X265_CHECK(expr, ...) if (!(expr)) { \
115
    x265_log(NULL, X265_LOG_ERROR, __VA_ARGS__); \
116
    FILE *fp = fopen("x265_check_failures.txt", "a"); \
117
    if (fp) { fprintf(fp, "%s:%d\n", __FILE__, __LINE__); fprintf(fp, __VA_ARGS__); fclose(fp); } \
118
    g_checkFailures++; DEBUG_BREAK(); \
119
}
120
#if _MSC_VER
121
#pragma warning(disable: 4127) // some checks have constant conditions
122
#endif
123
#else
124
#define X265_CHECK(expr, ...)
125
#endif
126
127
#if HIGH_BIT_DEPTH
128
typedef uint16_t pixel;
129
typedef uint32_t sum_t;
130
typedef uint64_t sum2_t;
131
typedef uint64_t pixel4;
132
typedef int64_t  ssum2_t;
133
#define SHIFT_TO_BITPLANE 9
134
#else
135
typedef uint8_t  pixel;
136
typedef uint16_t sum_t;
137
typedef uint32_t sum2_t;
138
typedef uint32_t pixel4;
139
typedef int32_t  ssum2_t; // Signed sum
140
0
#define SHIFT_TO_BITPLANE 7
141
#endif // if HIGH_BIT_DEPTH
142
143
#if X265_DEPTH < 10
144
typedef uint32_t sse_t;
145
#else
146
typedef uint64_t sse_t;
147
#endif
148
149
#ifndef NULL
150
#define NULL 0
151
#endif
152
153
0
#define MAX_UINT        0xFFFFFFFFU // max. value of unsigned 32-bit integer
154
0
#define MAX_UINT64      0xFFFFFFFFFFFFFFFFULL // max. value of unsigned 64-bit integer
155
0
#define MAX_INT         2147483647  // max. value of signed 32-bit integer
156
0
#define MAX_INT64       0x7FFFFFFFFFFFFFFFLL  // max. value of signed 64-bit integer
157
0
#define MAX_DOUBLE      1.7e+308    // max. value of double-type value
158
159
0
#define QP_MIN          0
160
0
#define QP_MAX_SPEC     51 /* max allowed signaled QP in HEVC */
161
0
#define QP_MAX_MAX      69 /* max allowed QP to be output by rate control */
162
163
#define MIN_QPSCALE     0.21249999999999999
164
#define MAX_MAX_QPSCALE 615.46574234477100
165
#define FRAME_BRIGHTNESS_THRESHOLD  50.0 // Min % of pixels in a frame, that are above BRIGHTNESS_THRESHOLD for it to be considered a bright frame
166
#define FRAME_EDGE_THRESHOLD  10.0 // Min % of edge pixels in a frame, for it to be considered to have high edge density
167
168
169
template<typename T>
170
0
inline T x265_min(T a, T b) { return a < b ? a : b; }
Unexecuted instantiation: int x265_min<int>(int, int)
Unexecuted instantiation: short x265_min<short>(short, short)
Unexecuted instantiation: unsigned int x265_min<unsigned int>(unsigned int, unsigned int)
Unexecuted instantiation: double x265_min<double>(double, double)
171
172
template<typename T>
173
0
inline T x265_max(T a, T b) { return a > b ? a : b; }
Unexecuted instantiation: int x265_max<int>(int, int)
Unexecuted instantiation: short x265_max<short>(short, short)
Unexecuted instantiation: unsigned int x265_max<unsigned int>(unsigned int, unsigned int)
Unexecuted instantiation: double x265_max<double>(double, double)
174
175
template<typename T>
176
0
inline T x265_clip3(T minVal, T maxVal, T a) { return x265_min(x265_max(minVal, a), maxVal); }
Unexecuted instantiation: int x265_clip3<int>(int, int, int)
Unexecuted instantiation: unsigned int x265_clip3<unsigned int>(unsigned int, unsigned int, unsigned int)
Unexecuted instantiation: double x265_clip3<double>(double, double, double)
177
178
template<typename T> /* clip to pixel range, 0..255 or 0..1023 */
179
0
inline pixel x265_clip(T x) { return (pixel)x265_min<T>(T((1 << X265_DEPTH) - 1), x265_max<T>(T(0), x)); }
Unexecuted instantiation: unsigned char x265_clip<int>(int)
Unexecuted instantiation: unsigned char x265_clip<short>(short)
180
181
/* get the sign of input variable */
182
static inline int8_t x265_signOf(int32_t x)
183
0
{
184
0
    return (x >> 31) | ((int32_t)((((uint32_t) - x)) >> 31));
185
0
}
Unexecuted instantiation: api.cpp:x265_signOf(int)
Unexecuted instantiation: primitives.cpp:x265_signOf(int)
Unexecuted instantiation: pixel.cpp:x265_signOf(int)
Unexecuted instantiation: dct.cpp:x265_signOf(int)
Unexecuted instantiation: lowpassdct.cpp:x265_signOf(int)
Unexecuted instantiation: ipfilter.cpp:x265_signOf(int)
Unexecuted instantiation: intrapred.cpp:x265_signOf(int)
Unexecuted instantiation: loopfilter.cpp:x265_signOf(int)
Unexecuted instantiation: constants.cpp:x265_signOf(int)
Unexecuted instantiation: cpu.cpp:x265_signOf(int)
Unexecuted instantiation: version.cpp:x265_signOf(int)
Unexecuted instantiation: bitstream.cpp:x265_signOf(int)
Unexecuted instantiation: common.cpp:x265_signOf(int)
Unexecuted instantiation: param.cpp:x265_signOf(int)
Unexecuted instantiation: scalinglist.cpp:x265_signOf(int)
Unexecuted instantiation: framefilter.cpp:x265_signOf(int)
Unexecuted instantiation: level.cpp:x265_signOf(int)
Unexecuted instantiation: sao.cpp:x265_signOf(int)
Unexecuted instantiation: entropy.cpp:x265_signOf(int)
Unexecuted instantiation: encoder.cpp:x265_signOf(int)
Unexecuted instantiation: threading.cpp:x265_signOf(int)
Unexecuted instantiation: threadpool.cpp:x265_signOf(int)
Unexecuted instantiation: picyuv.cpp:x265_signOf(int)
Unexecuted instantiation: frame.cpp:x265_signOf(int)
Unexecuted instantiation: framedata.cpp:x265_signOf(int)
Unexecuted instantiation: cudata.cpp:x265_signOf(int)
Unexecuted instantiation: slice.cpp:x265_signOf(int)
Unexecuted instantiation: lowres.cpp:x265_signOf(int)
Unexecuted instantiation: piclist.cpp:x265_signOf(int)
Unexecuted instantiation: deblock.cpp:x265_signOf(int)
Unexecuted instantiation: temporalfilter.cpp:x265_signOf(int)
Unexecuted instantiation: bitcost.cpp:x265_signOf(int)
Unexecuted instantiation: motion.cpp:x265_signOf(int)
Unexecuted instantiation: slicetype.cpp:x265_signOf(int)
Unexecuted instantiation: frameencoder.cpp:x265_signOf(int)
Unexecuted instantiation: nal.cpp:x265_signOf(int)
Unexecuted instantiation: sei.cpp:x265_signOf(int)
Unexecuted instantiation: dpb.cpp:x265_signOf(int)
Unexecuted instantiation: ratecontrol.cpp:x265_signOf(int)
Unexecuted instantiation: reference.cpp:x265_signOf(int)
Unexecuted instantiation: weightPrediction.cpp:x265_signOf(int)
Unexecuted instantiation: wavefront.cpp:x265_signOf(int)
Unexecuted instantiation: md5.cpp:x265_signOf(int)
Unexecuted instantiation: yuv.cpp:x265_signOf(int)
Unexecuted instantiation: ringmem.cpp:x265_signOf(int)
Unexecuted instantiation: analysis.cpp:x265_signOf(int)
Unexecuted instantiation: search.cpp:x265_signOf(int)
Unexecuted instantiation: shortyuv.cpp:x265_signOf(int)
Unexecuted instantiation: predict.cpp:x265_signOf(int)
Unexecuted instantiation: quant.cpp:x265_signOf(int)
186
187
typedef int16_t  coeff_t;      // transform coefficient
188
189
0
#define X265_MIN(a, b) ((a) < (b) ? (a) : (b))
190
0
#define X265_MAX(a, b) ((a) > (b) ? (a) : (b))
191
0
#define COPY1_IF_LT(x, y) {if ((y) < (x)) (x) = (y);}
192
#define COPY2_IF_LT(x, y, a, b) \
193
0
    if ((y) < (x)) \
194
0
    { \
195
0
        (x) = (y); \
196
0
        (a) = (b); \
197
0
    }
198
#define COPY3_IF_LT(x, y, a, b, c, d) \
199
0
    if ((y) < (x)) \
200
0
    { \
201
0
        (x) = (y); \
202
0
        (a) = (b); \
203
0
        (c) = (d); \
204
0
    }
205
#define COPY4_IF_LT(x, y, a, b, c, d, e, f) \
206
0
    if ((y) < (x)) \
207
0
    { \
208
0
        (x) = (y); \
209
0
        (a) = (b); \
210
0
        (c) = (d); \
211
0
        (e) = (f); \
212
0
    }
213
0
#define X265_MIN3(a, b, c) X265_MIN((a), X265_MIN((b), (c)))
214
#define X265_MAX3(a, b, c) X265_MAX((a), X265_MAX((b), (c)))
215
0
#define X265_MIN4(a, b, c, d) X265_MIN((a), X265_MIN3((b), (c), (d)))
216
#define X265_MAX4(a, b, c, d) X265_MAX((a), X265_MAX3((b), (c), (d)))
217
0
#define QP_BD_OFFSET (6 * (X265_DEPTH - 8))
218
#define MAX_CHROMA_LAMBDA_OFFSET 36
219
220
// arbitrary, but low because SATD scores are 1/4 normal
221
0
#define X265_LOOKAHEAD_QP (12 + QP_BD_OFFSET)
222
223
// Use the same size blocks as x264.  Using larger blocks seems to give artificially
224
// high cost estimates (intra and inter both suffer)
225
0
#define X265_LOWRES_CU_SIZE   8
226
0
#define X265_LOWRES_CU_BITS   3
227
228
0
#define X265_MALLOC(type, count)    (type*)x265_malloc(sizeof(type) * (count))
229
0
#define X265_FREE(ptr)              x265_free(ptr)
230
0
#define X265_FREE_ZERO(ptr)         { x265_free(ptr); (ptr) = NULL; }
231
#define CHECKED_MALLOC(var, type, count) \
232
0
    { \
233
0
        var = (type*)x265_malloc(sizeof(type) * (count)); \
234
0
        if (!var) \
235
0
        { \
236
0
            x265_log(NULL, X265_LOG_ERROR, "malloc of size %d failed\n", sizeof(type) * (count)); \
237
0
            goto fail; \
238
0
        } \
239
0
    }
240
#define CHECKED_MALLOC_ZERO(var, type, count) \
241
0
    { \
242
0
        var = (type*)x265_malloc(sizeof(type) * (count)); \
243
0
        if (var) \
244
0
            memset((void*)var, 0, sizeof(type) * (count)); \
245
0
        else \
246
0
        { \
247
0
            x265_log(NULL, X265_LOG_ERROR, "malloc of size %d failed\n", sizeof(type) * (count)); \
248
0
            goto fail; \
249
0
        } \
250
0
    }
251
252
#if defined(_MSC_VER)
253
#define X265_LOG2F(x) (logf((float)(x)) * 1.44269504088896405f)
254
#define X265_LOG2(x) (log((double)(x)) * 1.4426950408889640513713538072172)
255
#else
256
#define X265_LOG2F(x) log2f(x)
257
0
#define X265_LOG2(x)  log2(x)
258
#endif
259
260
0
#define NUM_CU_DEPTH            4                           // maximum number of CU depths
261
#define NUM_FULL_DEPTH          5                           // maximum number of full depths
262
0
#define MIN_LOG2_CU_SIZE        3                           // log2(minCUSize)
263
0
#define MAX_LOG2_CU_SIZE        6                           // log2(maxCUSize)
264
#define MIN_CU_SIZE             (1 << MIN_LOG2_CU_SIZE)     // minimum allowable size of CU
265
0
#define MAX_CU_SIZE             (1 << MAX_LOG2_CU_SIZE)     // maximum allowable size of CU
266
267
0
#define LOG2_UNIT_SIZE          2                           // log2(unitSize)
268
0
#define UNIT_SIZE               (1 << LOG2_UNIT_SIZE)       // unit size of CU partition
269
270
0
#define LOG2_RASTER_SIZE        (MAX_LOG2_CU_SIZE - LOG2_UNIT_SIZE)
271
0
#define RASTER_SIZE             (1 << LOG2_RASTER_SIZE)
272
#define MAX_NUM_PARTITIONS      (RASTER_SIZE * RASTER_SIZE)
273
274
#define MIN_PU_SIZE             4
275
#define MIN_TU_SIZE             4
276
#define MAX_NUM_SPU_W           (MAX_CU_SIZE / MIN_PU_SIZE) // maximum number of SPU in horizontal line
277
278
0
#define MAX_LOG2_TR_SIZE 5
279
0
#define MAX_LOG2_TS_SIZE 2 // TODO: RExt
280
0
#define MAX_TR_SIZE (1 << MAX_LOG2_TR_SIZE)
281
0
#define MAX_TS_SIZE (1 << MAX_LOG2_TS_SIZE)
282
283
0
#define RDCOST_BASED_RSKIP 1
284
0
#define EDGE_BASED_RSKIP 2
285
286
0
#define COEF_REMAIN_BIN_REDUCTION   3 // indicates the level at which the VLC
287
                                      // transitions from Golomb-Rice to TU+EG(k)
288
289
0
#define SBH_THRESHOLD               4 // fixed sign bit hiding controlling threshold
290
291
0
#define C1FLAG_NUMBER               8 // maximum number of largerThan1 flag coded in one chunk:  16 in HM5
292
#define C2FLAG_NUMBER               1 // maximum number of largerThan2 flag coded in one chunk:  16 in HM5
293
294
0
#define SAO_ENCODING_RATE           0.75
295
0
#define SAO_ENCODING_RATE_CHROMA    0.5
296
297
0
#define MLS_GRP_NUM                 64 // Max number of coefficient groups, max(16, 64)
298
0
#define MLS_CG_SIZE                 4  // Coefficient group size of 4x4
299
0
#define MLS_CG_BLK_SIZE             (MLS_CG_SIZE * MLS_CG_SIZE)
300
0
#define MLS_CG_LOG2_SIZE            2
301
302
0
#define QUANT_IQUANT_SHIFT          20 // Q(QP%6) * IQ(QP%6) = 2^20
303
0
#define QUANT_SHIFT                 14 // Q(4) = 2^14
304
0
#define SCALE_BITS                  15 // Inherited from TMuC, presumably for fractional bit estimates in RDOQ
305
0
#define MAX_TR_DYNAMIC_RANGE        15 // Maximum transform dynamic range (excluding sign bit)
306
307
#define SHIFT_INV_1ST               7  // Shift after first inverse transform stage
308
#define SHIFT_INV_2ND               12 // Shift after second inverse transform stage
309
310
#define AMVP_DECIMATION_FACTOR      4
311
312
0
#define SCAN_SET_SIZE               16
313
0
#define LOG2_SCAN_SET_SIZE          4
314
315
0
#define ALL_IDX                     -1
316
0
#define PLANAR_IDX                  0
317
0
#define VER_IDX                     26 // index for intra VERTICAL   mode
318
0
#define HOR_IDX                     10 // index for intra HORIZONTAL mode
319
0
#define DC_IDX                      1  // index for intra DC mode
320
0
#define NUM_CHROMA_MODE             5  // total number of chroma modes
321
0
#define DM_CHROMA_IDX               36 // chroma mode index for derived from luma intra mode
322
323
#define MDCS_ANGLE_LIMIT            4 // distance from true angle that horiz or vertical scan is allowed
324
0
#define MDCS_LOG2_MAX_SIZE          3 // TUs with log2 of size greater than this can only use diagonal scan
325
326
#define MAX_NUM_REF_PICS            16 // max. number of pictures used for reference
327
0
#define MAX_NUM_REF                 16 // max. number of entries in picture reference list
328
0
#define MAX_NUM_SHORT_TERM_RPS      64 // max. number of short term reference picture set in SPS
329
330
0
#define REF_NOT_VALID               -1
331
332
0
#define AMVP_NUM_CANDS              2 // number of AMVP candidates
333
0
#define MRG_MAX_NUM_CANDS           5 // max number of final merge candidates
334
335
0
#define CHROMA_H_SHIFT(x) (x == X265_CSP_I420 || x == X265_CSP_I422)
336
0
#define CHROMA_V_SHIFT(x) (x == X265_CSP_I420)
337
0
#define X265_MAX_PRED_MODE_PER_CTU 85 * 2 * 8
338
339
0
#define MAX_NUM_TR_COEFFS           MAX_TR_SIZE * MAX_TR_SIZE // Maximum number of transform coefficients, for a 32x32 transform
340
0
#define MAX_NUM_TR_CATEGORIES       16                        // 32, 16, 8, 4 transform categories each for luma and chroma
341
342
0
#define PIXEL_MAX ((1 << X265_DEPTH) - 1)
343
344
0
#define INTEGRAL_PLANE_NUM          12 // 12 integral planes for 32x32, 32x24, 32x8, 24x32, 16x16, 16x12, 16x4, 12x16, 8x32, 8x8, 4x16 and 4x4.
345
346
0
#define NAL_TYPE_OVERHEAD 2
347
0
#define START_CODE_OVERHEAD 3 
348
0
#define FILLER_OVERHEAD (NAL_TYPE_OVERHEAD + START_CODE_OVERHEAD + 1)
349
350
0
#define MAX_NUM_DYN_REFINE          (NUM_CU_DEPTH * X265_REFINE_INTER_LEVELS)
351
0
#define X265_BYTE 8
352
353
#define MAX_MCSTF_TEMPORAL_WINDOW_LENGTH 8
354
355
namespace X265_NS {
356
357
enum { SAO_NUM_OFFSET = 4 };
358
359
enum SaoMergeMode
360
{
361
    SAO_MERGE_NONE,
362
    SAO_MERGE_LEFT,
363
    SAO_MERGE_UP
364
};
365
366
struct SaoCtuParam
367
{
368
    SaoMergeMode mergeMode;
369
    int  typeIdx;
370
    uint32_t bandPos;    // BO band position
371
    int  offset[SAO_NUM_OFFSET];
372
373
    void reset()
374
0
    {
375
0
        mergeMode = SAO_MERGE_NONE;
376
0
        typeIdx = -1;
377
0
        bandPos = 0;
378
0
        offset[0] = 0;
379
0
        offset[1] = 0;
380
0
        offset[2] = 0;
381
0
        offset[3] = 0;
382
0
    }
383
};
384
385
struct SAOParam
386
{
387
    SaoCtuParam* ctuParam[3];
388
    bool         bSaoFlag[2];
389
    int          numCuInWidth;
390
391
    SAOParam()
392
0
    {
393
0
        for (int i = 0; i < 3; i++)
394
0
            ctuParam[i] = NULL;
395
0
    }
396
397
    ~SAOParam()
398
0
    {
399
0
        delete[] ctuParam[0];
400
0
        delete[] ctuParam[1];
401
0
        delete[] ctuParam[2];
402
0
    }
403
};
404
enum TextType
405
{
406
    TEXT_LUMA     = 0,  // luma
407
    TEXT_CHROMA_U = 1,  // chroma U
408
    TEXT_CHROMA_V = 2,  // chroma V
409
    MAX_NUM_COMPONENT = 3
410
};
411
412
// coefficient scanning type used in ACS
413
enum ScanType
414
{
415
    SCAN_DIAG = 0,     // up-right diagonal scan
416
    SCAN_HOR = 1,      // horizontal first scan
417
    SCAN_VER = 2,      // vertical first scan
418
    NUM_SCAN_TYPE = 3
419
};
420
421
enum SignificanceMapContextType
422
{
423
    CONTEXT_TYPE_4x4 = 0,
424
    CONTEXT_TYPE_8x8 = 1,
425
    CONTEXT_TYPE_NxN = 2,
426
    CONTEXT_NUMBER_OF_TYPES = 3
427
};
428
429
/* located in pixel.cpp */
430
void extendPicBorder(pixel* recon, intptr_t stride, int width, int height, int marginX, int marginY);
431
432
/* located in common.cpp */
433
int64_t  x265_mdate(void);
434
0
#define  x265_log(param, ...) general_log(param, "x265", __VA_ARGS__)
435
0
#define  x265_log_file(param, ...) general_log_file(param, "x265", __VA_ARGS__)
436
void     general_log(const x265_param* param, const char* caller, int level, const char* fmt, ...);
437
#if _WIN32
438
void     general_log_file(const x265_param* param, const char* caller, int level, const char* fmt, ...);
439
FILE*    x265_fopen(const char* fileName, const char* mode);
440
int      x265_unlink(const char* fileName);
441
int      x265_rename(const char* oldName, const char* newName);
442
#else
443
0
#define  general_log_file(param, caller, level, fmt, ...) general_log(param, caller, level, fmt, __VA_ARGS__)
444
0
#define  x265_fopen(fileName, mode) fopen(fileName, mode)
445
0
#define  x265_unlink(fileName) unlink(fileName)
446
0
#define  x265_rename(oldName, newName) rename(oldName, newName)
447
#endif
448
/* Close a file */
449
0
#define  x265_fclose(file) if (file != NULL) fclose(file); file=NULL;
450
#define x265_fread(val, size, readSize, fileOffset,errorMessage)\
451
0
    if (fread(val, size, readSize, fileOffset) != readSize)\
452
0
    {\
453
0
        x265_log(NULL, X265_LOG_ERROR, errorMessage); \
454
0
        return; \
455
0
    }
456
int      x265_exp2fix8(double x);
457
458
double   x265_ssim2dB(double ssim);
459
double   x265_qScale2qp(double qScale);
460
double   x265_qp2qScale(double qp);
461
uint32_t x265_picturePlaneSize(int csp, int width, int height, int plane);
462
463
void*    x265_malloc(size_t size);
464
void     x265_free(void *ptr);
465
char*    x265_slurp_file(const char *filename);
466
467
/* located in primitives.cpp */
468
void     x265_setup_primitives(x265_param* param);
469
void     x265_report_simd(x265_param* param);
470
}
471
472
#include "constants.h"
473
474
#endif // ifndef X265_COMMON_H