Coverage Report

Created: 2026-04-01 07:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vvenc/source/Lib/CommonLib/x86/InitX86.cpp
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
43
44
/*
45
 * \ingroup CommonLib
46
 * \file    InitX86.cpp
47
 * \brief   Initialize encoder SIMD functions.
48
 */
49
50
#include "CommonDefX86.h"
51
#include "InterpolationFilter.h"
52
#include "TrQuant.h"
53
#include "RdCost.h"
54
#include "Unit.h"
55
#include "LoopFilter.h"
56
#include "AdaptiveLoopFilter.h"
57
#include "SampleAdaptiveOffset.h"
58
#include "InterPrediction.h"
59
#include "IntraPrediction.h"
60
#include "AffineGradientSearch.h"
61
#include "MCTF.h"
62
#include "TrQuant_EMT.h"
63
#include "QuantRDOQ2.h"
64
#include "SEIFilmGrainAnalyzer.h"
65
66
#ifdef TARGET_SIMD_X86
67
68
//! \ingroup CommonLib
69
//! \{
70
71
#  if defined( REAL_TARGET_X86 ) \
72
    || ( defined( SIMD_EVERYWHERE_EXTENSION_LEVEL_ID ) && SIMD_EVERYWHERE_EXTENSION_LEVEL_ID >= X86_SIMD_AVX2 )
73
#    define ENABLE_AVX2_IMPLEMENTATIONS 1
74
#  else
75
#    define ENABLE_AVX2_IMPLEMENTATIONS 0
76
#  endif
77
78
namespace vvenc {
79
80
#if ENABLE_SIMD_OPT_MCIF
81
void InterpolationFilter::initInterpolationFilterX86( /*int iBitDepthY, int iBitDepthC*/ )
82
0
{
83
0
  auto vext = read_x86_extension_flags();
84
0
  switch (vext){
85
0
  case AVX512:
86
0
  case AVX2:
87
0
#if ENABLE_AVX2_IMPLEMENTATIONS
88
0
    _initInterpolationFilterX86<AVX2>(/*iBitDepthY, iBitDepthC*/);
89
0
    break;
90
0
#endif
91
0
  case AVX:
92
    //_initInterpolationFilterX86<AVX>(/*iBitDepthY, iBitDepthC*/);
93
    //break;
94
0
  case SSE42:
95
0
  case SSE41:
96
0
    _initInterpolationFilterX86<SSE41>(/*iBitDepthY, iBitDepthC*/);
97
0
    break;
98
0
  default:
99
0
    break;
100
0
  }
101
0
}
102
#endif
103
104
#if ENABLE_SIMD_OPT_BUFFER
105
void PelBufferOps::initPelBufOpsX86()
106
0
{
107
0
  if( isInitX86Done )
108
0
    return;
109
110
0
  isInitX86Done = true;
111
112
0
  auto vext = read_x86_extension_flags();
113
0
  switch (vext){
114
0
    case AVX512:
115
0
    case AVX2:
116
0
#if ENABLE_AVX2_IMPLEMENTATIONS
117
0
      _initPelBufOpsX86<AVX2>();
118
0
      break;
119
0
#endif
120
0
    case AVX:
121
      //_initPelBufOpsX86<AVX>();
122
      //break;
123
0
    case SSE42:
124
0
    case SSE41:
125
0
      _initPelBufOpsX86<SSE41>();
126
0
      break;
127
0
    default:
128
0
      break;
129
0
  }
130
0
}
131
#endif
132
133
134
#if ENABLE_SIMD_DBLF
135
void LoopFilter::initLoopFilterX86()
136
0
{
137
0
  auto vext = read_x86_extension_flags();
138
0
  switch (vext)
139
0
  {
140
0
  case AVX512:
141
0
  case AVX2:
142
0
#if ENABLE_AVX2_IMPLEMENTATIONS
143
0
    _initLoopFilterX86<AVX2>();
144
0
    break;
145
0
#endif
146
0
  case AVX:
147
    //_initLoopFilterX86<AVX>();
148
    //break;
149
0
  case SSE42:
150
0
  case SSE41:
151
0
    _initLoopFilterX86<SSE41>();
152
0
    break;
153
0
  default:
154
0
    break;
155
0
  }
156
0
}
157
#endif
158
159
160
#if ENABLE_SIMD_OPT_DIST
161
void RdCost::initRdCostX86()
162
0
{
163
0
  auto vext = read_x86_extension_flags();
164
0
  switch (vext){ 
165
0
    case AVX512:
166
0
    case AVX2:
167
0
#if ENABLE_AVX2_IMPLEMENTATIONS
168
#if defined( _MSC_VER ) && _MSC_VER >= 1938 && _MSC_VER < 1939
169
#else
170
0
      _initRdCostX86<AVX2>();
171
0
      break;
172
0
#endif
173
0
#endif
174
0
    case AVX:
175
      //_initRdCostX86<AVX>();
176
      //break;
177
0
    case SSE42:
178
0
    case SSE41:
179
0
      _initRdCostX86<SSE41>();
180
0
      break;
181
0
    default:
182
0
      break;
183
0
  }
184
0
}
185
#endif
186
187
#if ENABLE_SIMD_OPT_ALF
188
void AdaptiveLoopFilter::initAdaptiveLoopFilterX86()
189
0
{
190
0
  auto vext = read_x86_extension_flags();
191
0
  switch( vext )
192
0
  {
193
0
  case AVX512:
194
0
  case AVX2:
195
0
#if ENABLE_AVX2_IMPLEMENTATIONS
196
0
    _initAdaptiveLoopFilterX86<AVX2>();
197
0
    break;
198
0
#endif
199
0
  case AVX:
200
    //_initAdaptiveLoopFilterX86<AVX>();
201
    //break;
202
0
  case SSE42:
203
0
  case SSE41:
204
0
    _initAdaptiveLoopFilterX86<SSE41>();
205
0
    break;
206
0
  default:
207
0
    break;
208
0
  }
209
0
}
210
#endif
211
212
#if ENABLE_SIMD_OPT_SAO
213
void SampleAdaptiveOffset::initSampleAdaptiveOffsetX86()
214
0
{
215
0
  auto vext = read_x86_extension_flags();
216
0
  switch (vext){
217
0
    case AVX512:
218
0
    case AVX2:
219
0
#if ENABLE_AVX2_IMPLEMENTATIONS
220
0
      _initSampleAdaptiveOffsetX86<AVX2>();
221
0
      break;
222
0
#endif
223
0
    case AVX:
224
      //_initSampleAdaptiveOffsetX86<AVX>();
225
      //break;
226
0
    case SSE42:
227
0
    case SSE41:
228
0
      _initSampleAdaptiveOffsetX86<SSE41>();
229
0
      break;
230
0
    default:
231
0
      break;
232
0
  }
233
0
}
234
235
#endif
236
237
#if ENABLE_SIMD_OPT_BDOF
238
void InterPredInterpolation::initInterPredictionX86()
239
0
{
240
0
  auto vext = read_x86_extension_flags();
241
0
  switch (vext){
242
0
    case AVX512:
243
0
    case AVX2:
244
0
#if ENABLE_AVX2_IMPLEMENTATIONS
245
0
      _initInterPredictionX86<AVX2>();
246
0
      break;
247
0
#endif
248
0
    case AVX:
249
      //_initInterPredictionX86<AVX>();
250
      //break;
251
0
    case SSE42:
252
0
    case SSE41:
253
0
      _initInterPredictionX86<SSE41>();
254
0
      break;
255
0
    default:
256
0
      break;
257
0
  }
258
0
}
259
#endif
260
261
#if ENABLE_SIMD_OPT_AFFINE_ME
262
void AffineGradientSearch::initAffineGradientSearchX86()
263
0
{
264
0
  auto vext = read_x86_extension_flags();
265
0
  switch (vext) {
266
0
  case AVX512:
267
0
  case AVX2:
268
0
#if ENABLE_AVX2_IMPLEMENTATIONS
269
0
    _initAffineGradientSearchX86<AVX2>();
270
0
    break;
271
0
#endif
272
0
  case AVX:
273
    //_initAffineGradientSearchX86<AVX>();
274
    //break;
275
0
  case SSE42:
276
0
  case SSE41:
277
0
    _initAffineGradientSearchX86<SSE41>();
278
0
    break;
279
0
  default:
280
0
    break;
281
0
  }
282
0
}
283
#endif
284
285
#if ENABLE_SIMD_OPT_INTRAPRED
286
void IntraPrediction::initIntraPredictionX86()
287
0
{
288
0
  auto vext = read_x86_extension_flags();
289
0
  switch (vext){
290
0
    case AVX512:
291
0
    case AVX2:
292
0
#if ENABLE_AVX2_IMPLEMENTATIONS
293
0
      _initIntraPredictionX86<AVX2>();
294
0
      break;
295
0
#endif
296
0
    case AVX:
297
      //_initIntraPredictionX86<AVX>();
298
      //break;
299
0
    case SSE42:
300
0
    case SSE41:
301
0
      _initIntraPredictionX86<SSE41>();
302
0
      break;
303
0
    default:
304
0
      break;
305
0
  }
306
0
}
307
308
#endif
309
#if ENABLE_SIMD_OPT_MCTF
310
void MCTF::initMCTF_X86()
311
0
{
312
0
  auto vext = read_x86_extension_flags();
313
0
  switch (vext){
314
0
    case AVX512:
315
0
    case AVX2:
316
0
#if ENABLE_AVX2_IMPLEMENTATIONS
317
0
      _initMCTF_X86<AVX2 >();
318
0
      break;
319
0
#endif
320
0
    case AVX:
321
      //_initMCTF_X86<AVX  >();
322
      //break;
323
0
    case SSE42:
324
      //_initMCTF_X86<SSE42>();
325
      //break;
326
0
    case SSE41:
327
0
      _initMCTF_X86<SSE41>();
328
0
      break;
329
0
    default:
330
0
      break;
331
0
  }
332
0
}
333
334
#endif
335
#if ENABLE_SIMD_TRAFO
336
void TCoeffOps::initTCoeffOpsX86()
337
0
{
338
0
  auto vext = read_x86_extension_flags();
339
0
  switch (vext){
340
0
    case AVX512:
341
0
    case AVX2:
342
0
#if ENABLE_AVX2_IMPLEMENTATIONS
343
0
      _initTCoeffOpsX86<AVX2 >();
344
0
      break;
345
0
#endif
346
0
    case AVX:
347
      //_initTCoeffOpsX86<AVX  >();
348
      //break;
349
0
    case SSE42:
350
      //_initTCoeffOpsX86<SSE42>();
351
      //break;
352
0
    case SSE41:
353
0
      _initTCoeffOpsX86<SSE41>();
354
0
      break;
355
0
    default:
356
0
      break;
357
0
  }
358
0
}
359
360
void TrQuant::initTrQuantX86()
361
0
{
362
0
  auto vext = read_x86_extension_flags();
363
0
  switch( vext )
364
0
  {
365
0
  case AVX512:
366
0
  case AVX2:
367
0
#if ENABLE_AVX2_IMPLEMENTATIONS
368
0
    _initTrQuantX86<AVX2 >();
369
0
    break;
370
0
#endif
371
0
  case AVX:
372
    //_initTrQuantX86<AVX  >();
373
    //break;
374
0
  case SSE42:
375
    //_initTrQuantX86<SSE42>();
376
    //break;
377
0
  case SSE41:
378
0
    _initTrQuantX86<SSE41>();
379
0
    break;
380
0
  default:
381
0
  break;
382
0
  }
383
0
}
384
385
#endif
386
387
#if ENABLE_SIMD_OPT_QUANT
388
389
void Quant::initQuantX86()
390
0
{
391
0
  auto vext = read_x86_extension_flags();
392
0
  switch (vext){
393
0
    case AVX512:
394
0
    case AVX2:
395
0
#if ENABLE_AVX2_IMPLEMENTATIONS
396
0
      _initQuantX86<AVX2>();
397
0
      break;
398
0
#endif
399
0
    case AVX:
400
      //_initQuantX86<AVX>();
401
      //break;
402
0
    case SSE42:
403
0
    case SSE41:
404
0
      _initQuantX86<SSE41>();
405
0
      break;
406
0
    default:
407
0
      break;
408
0
  }
409
0
}
410
411
void DepQuant::initDepQuantX86()
412
0
{
413
0
  auto vext = read_x86_extension_flags();
414
0
  switch (vext){
415
0
  case AVX512:
416
0
  case AVX2:
417
0
#if ENABLE_AVX2_IMPLEMENTATIONS
418
0
    _initDepQuantX86<AVX2>();
419
0
    break;
420
0
#endif
421
0
  case AVX:
422
0
  case SSE42:
423
0
    _initDepQuantX86<SSE42>();
424
0
    break;
425
0
  case SSE41:
426
0
    _initDepQuantX86<SSE41>();
427
0
    break;
428
0
  default:
429
0
    break;
430
0
  }
431
0
}
432
433
#endif
434
435
#if ENABLE_SIMD_OPT_FGA
436
void Canny::initFGACannyX86()
437
0
{
438
0
  auto vext = read_x86_extension_flags();
439
0
  switch (vext){
440
0
    case AVX512:
441
0
    case AVX2:
442
0
#if ENABLE_AVX2_IMPLEMENTATIONS
443
0
      _initFGACannyX86<AVX2>();
444
0
      break;
445
0
#endif
446
0
    case SSE42:
447
0
    case SSE41:
448
0
      _initFGACannyX86<SSE41>();
449
0
      break;
450
0
    default:
451
0
      break;
452
0
  }
453
0
}
454
void Morph::initFGAMorphX86()
455
0
{
456
0
  auto vext = read_x86_extension_flags();
457
0
  switch (vext){
458
0
    case AVX512:
459
0
    case AVX2:
460
0
#if ENABLE_AVX2_IMPLEMENTATIONS
461
0
      _initFGAMorphX86<AVX2>();
462
0
      break;
463
0
#endif
464
0
    case SSE42:
465
0
    case SSE41:
466
0
      _initFGAMorphX86<SSE41>();
467
0
      break;
468
0
    default:
469
0
      break;
470
0
  }
471
0
}
472
473
void FGAnalyzer::initFGAnalyzerX86()
474
0
{
475
0
  auto vext = read_x86_extension_flags();
476
0
  switch (vext){
477
0
    case AVX512:
478
0
    case AVX2:
479
0
#if ENABLE_AVX2_IMPLEMENTATIONS
480
0
      _initFGAnalyzerX86<AVX2>();
481
0
      break;
482
0
#endif
483
0
    case SSE42:
484
0
    case SSE41:
485
0
      _initFGAnalyzerX86<SSE41>();
486
0
      break;
487
0
    default:
488
0
      break;
489
0
  }
490
0
}
491
#endif
492
493
} // namespace vvenc
494
495
//! \}
496
497
#endif // TARGET_SIMD_X86
498