/src/vvdec/source/Lib/FilmGrain/FilmGrainImplX86.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) 2018-2026, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVdeC 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 | | #pragma once |
42 | | |
43 | | #include "FilmGrainImpl.h" |
44 | | |
45 | | #include <CommonDef.h> |
46 | | #include <CommonDefX86.h> |
47 | | |
48 | | #include <memory> |
49 | | |
50 | | #if defined(TARGET_SIMD_X86) && ENABLE_SIMD_OPT |
51 | | |
52 | | namespace vvdec |
53 | | { |
54 | | template<X86_VEXT VEXT> |
55 | | class FilmGrainImplX86 : public FilmGrainImpl |
56 | | { |
57 | | public: |
58 | | static std::unique_ptr<FilmGrainImpl> makeFilmGrainImpl(); |
59 | | |
60 | | protected: |
61 | | void make_grain_pattern( const void* I, |
62 | | int c, |
63 | | int x, |
64 | | int subx, |
65 | | uint8_t oc1, |
66 | | uint8_t oc2, |
67 | | uint8_t ox, |
68 | | uint8_t ox_up, |
69 | | uint8_t oy, |
70 | | uint8_t oy_up, |
71 | | int s, |
72 | | int s_up, |
73 | | int16_t grain[3][32], |
74 | | uint8_t scale[3][32] ) const override; |
75 | | void scale_and_output( void* I, // |
76 | | int c, |
77 | | int x, |
78 | | int subx, |
79 | | int width, |
80 | | int16_t grain[3][32], |
81 | | uint8_t scale[3][32] ) const override; |
82 | | }; |
83 | | |
84 | | template<> |
85 | | inline std::unique_ptr<FilmGrainImpl> FilmGrainImplX86<UNDEFINED>::makeFilmGrainImpl() |
86 | 0 | { |
87 | 0 | switch( read_x86_extension_flags() ) |
88 | 0 | { |
89 | 0 | case AVX512: |
90 | 0 | case AVX2: |
91 | 0 | #if ENABLE_AVX2_IMPLEMENTATIONS |
92 | 0 | return std::make_unique<FilmGrainImplX86<AVX2>>(); |
93 | 0 | #endif |
94 | 0 | case AVX: |
95 | 0 | case SSE42: |
96 | 0 | case SSE41: |
97 | 0 | return std::make_unique<FilmGrainImplX86<SSE41>>(); |
98 | 0 | default: |
99 | 0 | return std::make_unique<FilmGrainImpl>(); |
100 | 0 | } |
101 | 0 | } |
102 | | |
103 | | } // namespace vvdec |
104 | | #endif |