/work/vvenc/source/Lib/EncoderLib/SEIFilmGrainAnalyzer.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) 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 | | /* Film grain analysis (--fga 1, 2 and 3): a port of the film grain analysis of the VTM reference software (VTM master, |
44 | | * including JVET-AL0282 and JVET-AN0237 by InterDigital), with improvements (--fga 2) and the auto-regressive grain |
45 | | * model (--fga 3, which signals an AR filter fitted to the grain spectrum instead of cut-off frequencies). |
46 | | * |
47 | | * For every analysed picture, the grain is estimated as the difference between the original and a temporally filtered |
48 | | * (denoised) version of it, as in VTM (--fga 1). With the improvements (--fga 2) it is estimated from the temporal |
49 | | * residual instead, twice the picture minus its neighbours motion compensated with the vectors of the temporal filter |
50 | | * (MCTF::fgaTemporalResidual), which also holds the part of the grain that the filter keeps. |
51 | | * Flat blocks are found with a multi-scale Canny edge detector and morphological dilation on the denoised picture. On |
52 | | * 16x16 flat blocks the analysis collects |
53 | | * - the block mean and the grain strength (twice the standard deviation of the grain), from which a polynomial |
54 | | * scaling function is fitted and quantized with Lloyd-Max into intensity intervals and scaling factors, and |
55 | | * - the squared DCT of the grain, per block mean, from which horizontal and vertical cut-off frequencies are |
56 | | * estimated per intensity interval. |
57 | | * Both are accumulated over the analysed pictures with exponentially decreasing weights, so that the estimate follows |
58 | | * the current scene. |
59 | | */ |
60 | | |
61 | | #pragma once |
62 | | |
63 | | #include "CommonLib/CommonDef.h" |
64 | | #include "CommonLib/Unit.h" |
65 | | #include "CommonLib/SEI.h" |
66 | | |
67 | | #include <utility> |
68 | | #include <vector> |
69 | | |
70 | | namespace vvenc { |
71 | | |
72 | | // Row and block kernels of the analysis, with SIMD versions in CommonLib/x86/FGAX86.h and |
73 | | // CommonLib/arm/neon/FGA_neon.cpp. A row is processed from x = 0 to width - 1; neighbours outside the picture repeat |
74 | | // the border sample. |
75 | | struct FgaRowKernels |
76 | | { |
77 | | // Sobel gradients of the row "cur": magnitude, (|gx| + |gy|) / 2 limited to maxVal, and edge direction (0, 45, 90 |
78 | | // or 135 degrees). |
79 | | void ( *sobel ) ( const Pel* above, const Pel* cur, const Pel* below, int width, Pel maxVal, Pel* mag, Pel* dir ); |
80 | | // Non-maximum suppression: the magnitude where it is not smaller than both neighbours along the direction, else 0. |
81 | | void ( *nonMax ) ( const Pel* magAbove, const Pel* mag, const Pel* magBelow, const Pel* dir, int width, Pel* dst ); |
82 | | // 3-tap maximum (dilate) or minimum (erode) along a row, and over three rows. |
83 | | void ( *morphRow )( const Pel* src, int width, bool dilate, Pel* dst ); |
84 | | void ( *morphCol )( const Pel* above, const Pel* cur, const Pel* below, int width, bool dilate, Pel* dst ); |
85 | | // Largest of n non-negative samples. |
86 | | Pel ( *rowMax ) ( const Pel* src, int n ); |
87 | | // Double threshold: strong above high, weak above low, else 0. |
88 | | void ( *classify )( Pel* row, int n, Pel low, Pel high, Pel weak, Pel strong ); |
89 | | // Positions x of the samples equal to value, in increasing order; returns their number. |
90 | | int ( *findEqual )( const Pel* row, int n, Pel value, int* positions ); |
91 | | |
92 | | // Block kernels, on 16x16 blocks. |
93 | | bool ( *isZeroBlock ) ( const Pel* src, int stride ); |
94 | | void ( *blockSums ) ( const Pel* src, int stride, int64_t& sum, int64_t& sumSq ); |
95 | | // 16x16 DCT-II of VVC (rounding shift 8 after each stage, the second stage clipped to +-maxRange); the squared |
96 | | // coefficients are added to sum[ horizontal * 16 + vertical ]. |
97 | | void ( *squaredDct16 )( const Pel* src, int stride, int maxRange, double* sum ); |
98 | | |
99 | | // Temporal residual kernel (MCTF::fgaTemporalResidual). |
100 | | // Temporal residual of n samples: 2 cur - prev - next, or cur - prev when next is null. |
101 | | void ( *residualRow ) ( const Pel* cur, const Pel* prev, const Pel* next, int n, Pel* dst ); |
102 | | }; |
103 | | |
104 | | // Scalar row kernels for x = xStart to xEnd - 1; the SIMD kernels use them at the picture borders. |
105 | | void fgaSobelCore ( const Pel* above, const Pel* cur, const Pel* below, int width, int xStart, int xEnd, Pel maxVal, Pel* mag, Pel* dir ); |
106 | | void fgaNonMaxCore ( const Pel* magAbove, const Pel* mag, const Pel* magBelow, const Pel* dir, int width, int xStart, int xEnd, Pel* dst ); |
107 | | void fgaMorphRowCore( const Pel* src, int width, int xStart, int xEnd, bool dilate, Pel* dst ); |
108 | | void fgaMorphColCore( const Pel* above, const Pel* cur, const Pel* below, int xStart, int xEnd, bool dilate, Pel* dst ); |
109 | | Pel fgaRowMaxCore ( const Pel* src, int n ); |
110 | | int fgaFindEqualCore( const Pel* row, int n, Pel value, int* positions ); |
111 | | void fgaClassifyCore( Pel* row, int n, Pel low, Pel high, Pel weak, Pel strong ); |
112 | | bool fgaIsZeroBlockCore ( const Pel* src, int stride ); |
113 | | void fgaBlockSumsCore ( const Pel* src, int stride, int64_t& sum, int64_t& sumSq ); |
114 | | void fgaSquaredDct16Core( const Pel* src, int stride, int maxRange, double* sum ); |
115 | | void fgaResidualRowCore ( const Pel* cur, const Pel* prev, const Pel* next, int n, Pel* dst ); |
116 | | |
117 | | struct LostGrainSpectrum; // CommonLib/Picture.h |
118 | | |
119 | | class FGAnalyzer |
120 | | { |
121 | | public: |
122 | | FGAnalyzer(); |
123 | | |
124 | | // improved: the analysis with the improvements beyond VTM (--fga 2), else VTM's analysis with its bugs fixed |
125 | | // (--fga 1). arModel: the improved analysis with the auto-regressive grain model (--fga 3). See m_improved. |
126 | | void init( int width, int height, ChromaFormat chromaFormat, const int bitDepths[ MAX_NUM_CH ], const bool doAnalysis[ MAX_NUM_COMP ], bool improved, bool arModel = false ); |
127 | | |
128 | | // Analyses one picture: orig is the original, denoised its temporally filtered version (same size). residual is the |
129 | | // temporal residual of MCTF::fgaTemporalResidual, whose variance is residualWeight times the grain variance; without it |
130 | | // the grain is estimated as denoised minus orig. With sceneCut the statistics of the previous pictures are dropped |
131 | | // first, as they describe another scene. |
132 | | void estimateGrainParameters( const CPelUnitBuf& orig, const CPelUnitBuf& denoised, const CPelUnitBuf* residual = nullptr, int residualWeight = 0, |
133 | | bool sceneCut = false ); |
134 | | |
135 | | // Sets the row kernels: the scalar ones, then the SIMD ones the CPU supports. |
136 | | static void initKernels( FgaRowKernels& k ); |
137 | | |
138 | | // The parameters to signal in the FGC SEI, with the grain strength set to strength percent of the analysed grain: |
139 | | // the log2 scale factor and the component models, with scaling factors calibrated against the synthesis. |
140 | | void getSignalledParameters( double strength, int& log2ScaleFactor, SeiFgc::CompModel compModel[ MAX_NUM_COMP ] ) const; |
141 | | |
142 | | // The film grain SEI fitted to the grain the coding lost. lostGrainSpectra: for one component of a coded picture, the |
143 | | // summed 16x16 DCT power of the original's smoothest blocks (the 30 % with the least low-frequency power per band of |
144 | | // block means) and of the same blocks of the reconstruction, per 8-bit block mean, in ascending order (read by several |
145 | | // threads at once: it changes no state). |
146 | | void lostGrainSpectra( const CPelBuf& org, const CPelBuf& rec, int bitDepth, std::vector<LostGrainSpectrum>& spectra ) const; |
147 | | // An intensity interval's summed spectra reduced to the mean power per block in each u + v frequency group of the fit, |
148 | | // split by direction (once per interval: it does not depend on the cut-offs tried). |
149 | | struct LostGrainPower |
150 | | { |
151 | | static constexpr int GROUPS = 5; |
152 | | static constexpr int DIRECTIONS = 2; // 0: horizontal frequency dominates (u > v), 1: vertical (v > u) |
153 | | double orig[ GROUPS ][ DIRECTIONS ] = {}; |
154 | | double reco[ GROUPS ][ DIRECTIONS ] = {}; |
155 | | int blocks = 0; |
156 | | }; |
157 | | static LostGrainPower lostGrainPower( const double orig[ 256 ], const double reco[ 256 ], int blocks ); |
158 | | // What lostGrainFit needs of the grain synthesized at cut-offs (h, w), each clipped to 2 .. 14. It depends on nothing |
159 | | // else, so the caller computes it once per pair of cut-offs and fits every intensity interval with it. |
160 | | struct LostGrainShape |
161 | | { |
162 | | double patternStddev = 0.0; // the grain pattern's standard deviation |
163 | | double blockShare = 0.0; // the share of the grain's variance a 16x16 block keeps |
164 | | double power[ LostGrainPower::GROUPS ][ LostGrainPower::DIRECTIONS ] = {}; // per unit of grain variance |
165 | | }; |
166 | | static LostGrainShape lostGrainShape( bool chroma420, int h, int w ); |
167 | | // The scaling factor (0 .. MAX_STANDARD_DEVIATION) at the cut-offs of shape whose synthesized grain, added to the |
168 | | // reconstruction, best matches the original's power per u + v frequency group and direction (least squares of the log |
169 | | // ratio, overshoot weighted); the synthesized power is capped at LOST_GRAIN_CAP_POWER times that of the analyzer's scale s0 |
170 | | // at its cut-offs (h0, w0). Returns the cost, -1: nothing to fit (scale is then s0). |
171 | | static double lostGrainFit( const LostGrainPower& power, int bitDepth, bool chroma420, int log2ScaleFactor, int s0, int h0, |
172 | | int w0, const LostGrainShape& shape, int& scale ); |
173 | | // The scaling factor at cut-offs (h, w) whose synthesized in-block power equals that of scale s at (h0, w0). |
174 | | static int equalPowerScale( int s, bool chroma420, int h0, int w0, int h, int w ); |
175 | | // The lost-grain fit may put back up to this many times the analyzer's grain power: the coding can lose more than that |
176 | | // (the analyzer's scale falls toward bright areas while the lost grain does not). At 2x Top Gun's mid-bright band |
177 | | // (8-bit 97-128) got back 0.68-0.76 of its lost fine grain and 0.52-0.56 of its medium grain, at 4x 0.93-0.94 and |
178 | | // 0.71-0.72; the overshoot-weighted cost still holds the fit where it is not bound. |
179 | | static constexpr double LOST_GRAIN_CAP_POWER = 4.0; |
180 | | // The largest scaling factor the fit may give at cut-offs (h, w): LOST_GRAIN_CAP_POWER times the power of the analyzer's |
181 | | // scale s0 at (h0, w0), at most 127 (the largest scaling factor the analyzer signals). |
182 | | static int lostGrainCapScale( int s0, bool chroma420, int h0, int w0, int h, int w ); |
183 | | |
184 | | // The grain the synthesis makes with a filter of the auto-regressive model (--fga 3): its standard deviation per unit |
185 | | // of the scaling factor, and its power in a 16x16 block per unit of grain variance in each u + v frequency group and |
186 | | // direction of the lost-grain fit. |
187 | | struct ArGrain |
188 | | { |
189 | | double stddevPerScale = 0.0; |
190 | | double bandPower[ LostGrainPower::GROUPS ][ LostGrainPower::DIRECTIONS ] = {}; |
191 | | }; |
192 | | // modelValues: an intensity interval's signalled model values (scaling factor, a1, 0, a3, r, a5; the filter is the same |
193 | | // in all intervals of a component). |
194 | | static ArGrain arGrain( const std::vector<int>& modelValues, int log2ScaleFactor, int bitDepth, bool luma ); |
195 | | // The scaling factor (0 to twice s0, the analyzer's: LOST_GRAIN_CAP_POWER in power) whose synthesized grain, rounded |
196 | | // to whole sample values as the synthesis rounds it, added to the reconstruction, best matches the original's power |
197 | | // per frequency group and direction (the cost of lostGrainFit), among those that leave no group from u + v = 3 more |
198 | | // than 1.1 times above the original in amplitude. Returns the cost, -1: nothing to fit. |
199 | | static double lostGrainFitAr( const LostGrainPower& power, const ArGrain& grain, int s0, int& scale ); |
200 | | // The largest scaling factor that fit may give: LOST_GRAIN_CAP_POWER times the power of the analyzer's s0. |
201 | | static int lostGrainCapScaleAr( int s0 ); |
202 | | |
203 | | // A plane of samples with its own storage; the analysis works on whole planes. |
204 | | struct Plane |
205 | | { |
206 | | int width = 0; |
207 | | int height = 0; |
208 | | std::vector<Pel> samples; |
209 | | |
210 | | // Sets the size; the storage only grows, so planes reused for smaller sizes are not cleared again. |
211 | 0 | void resize( int w, int h ) { width = w; height = h; if( samples.size() < (size_t) w * h ) samples.resize( (size_t) w * h ); } |
212 | 0 | Pel* row ( int y ) { return samples.data() + (size_t) y * width; } |
213 | 0 | const Pel* row( int y ) const { return samples.data() + (size_t) y * width; } |
214 | 0 | Pel at ( int x, int y ) const { return samples[ (size_t) y * width + x ]; } |
215 | | // Sample at (x, y) with the coordinates clamped to the plane, as on a border-extended buffer. |
216 | | Pel clampedAt( int x, int y ) const; |
217 | | }; |
218 | | |
219 | | private: |
220 | | static constexpr int BLOCK_SIZE = 16; // analysis block size, for scaling function and cut-off frequencies |
221 | | // Weight of the data accumulated so far when a picture is added. VTM sums the data of all pictures without limit, |
222 | | // so a new scene hardly changes the estimate; halving the old data lets it follow the scene within a few analyses. |
223 | | static constexpr double ACCUMULATION_DECAY = 0.5; |
224 | | |
225 | | // Squared DCT coefficients of the grain, summed over the blocks with one block mean. |
226 | | typedef std::vector<double> SquaredDctSum; // BLOCK_SIZE * BLOCK_SIZE entries, [horizontal][vertical] |
227 | | |
228 | | struct CutoffPair |
229 | | { |
230 | | std::pair<int, int> p; // horizontal and vertical cut-off |
231 | | int w = 0; // weight (interval width) |
232 | | std::vector<int> idx; // intensity intervals having this pair |
233 | | }; |
234 | | |
235 | | int m_width = 0; |
236 | | int m_height = 0; |
237 | | ChromaFormat m_chromaFormat = CHROMA_420; |
238 | | int m_bitDepths[ MAX_NUM_CH ] = { 10, 10 }; |
239 | | bool m_doAnalysis[ MAX_NUM_COMP ] = { false, false, false }; |
240 | | |
241 | | // The analysed parameters: intensities at 8 bits, compModelValue[ 0 ] the grain strength (m_strengthScale times twice |
242 | | // the standard deviation of the grain on 16x16 blocks, at the component's bit depth), cut-off frequencies at the |
243 | | // component's resolution. getSignalledParameters() converts them for the synthesis. |
244 | | SeiFgc::CompModel m_compModel[ MAX_NUM_COMP ]; |
245 | | int m_cutoffPairs[ MAX_NUM_COMP ] = { 0, 0, 0 }; |
246 | | int m_failedFits [ MAX_NUM_COMP ] = { 0, 0, 0 }; // analyses in a row whose scaling function fit failed |
247 | | |
248 | | // With the improvements beyond VTM (--fga 2): the grain is measured from the temporal residual when MCTF provides |
249 | | // it, the strengths are kept in finer units, the scaling function fit works with few intensity intervals (chroma), |
250 | | // the scaling factors are calibrated against the synthesis, and the statistics follow grain that changes or |
251 | | // disappears. Without them (--fga 1) the analysis is VTM's, with its bugs fixed. |
252 | | bool m_improved = true; |
253 | | int m_strengthScale = 1; // units of the strengths: twice the standard deviation / m_strengthScale |
254 | | |
255 | | // The auto-regressive grain model (--fga 3, FGC model_id 1): instead of cut-off frequencies, every component |
256 | | // signals the filter of vvdec's SEI AR mode, x = a1 * left + a1 * r * top + a3 * r * ( top-left + top-right ) |
257 | | // + a5 * left-left + a5 * r^2 * top-top + noise, fitted to the measured grain spectrum. One filter per component, |
258 | | // the same for all intensity intervals, so that the synthesis makes one pattern per component. |
259 | | struct ArFilter |
260 | | { |
261 | | double a1 = 0.0, a3 = 0.0, a5 = 0.0, r = 1.0; |
262 | | double nonDcShare = 1.0; // share of the grain variance outside the DC coefficient of 16x16 blocks |
263 | | double powerScale = 1.0; // share of the measured grain power the synthesized grain gets (fitArFilter) |
264 | | bool valid = false; |
265 | | }; |
266 | | bool m_arModel = false; |
267 | | ArFilter m_arFilter[ MAX_NUM_COMP ]; |
268 | | |
269 | | // Data accumulated over the analysed pictures, weighted (see ACCUMULATION_DECAY). |
270 | | std::vector<SquaredDctSum> m_squaredDctSums[ MAX_NUM_COMP ]; // per block mean |
271 | | std::vector<double> m_numDctBlocks [ MAX_NUM_COMP ]; // per block mean |
272 | | std::vector<double> m_storedMeanIntensity [ MAX_NUM_COMP ]; |
273 | | std::vector<double> m_storedStrengthIntensity[ MAX_NUM_COMP ]; |
274 | | std::vector<double> m_storedElementsPerInterval[ MAX_NUM_COMP ]; |
275 | | |
276 | | // Planes of the picture being analysed. |
277 | | Plane m_denoised[ MAX_NUM_COMP ]; |
278 | | Plane m_grain [ MAX_NUM_COMP ]; // temporal residual, or denoised minus original |
279 | | int m_grainWeight = 1; // variance of m_grain relative to the grain variance |
280 | | Plane m_mask [ MAX_NUM_COMP ]; // non-zero where the picture is not flat |
281 | | std::vector<uint8_t> m_motionFailed[ MAX_NUM_COMP ]; // per 16x16 block: the temporal residual's compensation failed |
282 | | std::vector<double> m_fineEnergy[ MAX_NUM_COMP ]; // per 16x16 block: the original's energy at the finest frequencies |
283 | | std::vector<double> m_repeatedGrainRatio[ MAX_NUM_COMP ]; // per intensity bin: grain variance per variance the residual sees |
284 | | std::vector<int> m_plateaus; // luma values of the picture's grain-free plateaus (findPlateaus), most blocks first |
285 | | |
286 | | // Scratch planes and lists of the mask search, kept to avoid allocating and clearing them for every picture. |
287 | | struct Scratch |
288 | | { |
289 | | Plane magnitude, direction, morph, half, quarter, lowMask; |
290 | | Plane spatial; // denoised minus original of the component being prepared, beside a temporal residual |
291 | | std::vector<int> positions, weakX, weakY, columnStart; |
292 | | std::vector<Pel> wide, top, bottom, left, right; |
293 | | std::vector<double> repeatedGrainRatios; // per flat block, measureRepeatedGrain |
294 | | std::vector<std::vector<double>> repeatedGrainBinRatios; // the same, per intensity bin |
295 | | }; |
296 | | Scratch m_scratch; |
297 | | |
298 | | // flat area mask |
299 | | void resetStatistics ( int c ); |
300 | | void findMask ( ComponentID compId ); |
301 | | void maskForScale ( const Plane& picture, Plane& mask, int bitDepth, int numDilations ); |
302 | | bool markMotionFailures ( ComponentID compId ); |
303 | | void measureFineDetail ( ComponentID compId, const Plane& spatialGrain ); |
304 | | void measureRepeatedGrain ( ComponentID compId ); |
305 | | void addSmoothBlockPoints ( ComponentID compId, std::vector<int>& means, std::vector<int>& strengths ) const; |
306 | | |
307 | | // parameter estimation |
308 | | void estimateComponent ( ComponentID compId ); |
309 | | void estimateScalingFactors( std::vector<int>& dataX, std::vector<int>& dataY, int bitDepth, ComponentID compId ); |
310 | | bool fitFunction ( std::vector<int>& dataX, std::vector<int>& dataY, std::vector<double>& coeffs, std::vector<double>& scalingVec, |
311 | | int order, int bitDepth, bool secondPass, ComponentID compId ); |
312 | | void extendPoints ( std::vector<int>& dataX, std::vector<int>& dataY, int bitDepth ) const; |
313 | | bool lloydMax ( std::vector<double>& scalingVec, std::vector<int>& quantizedVec, int numQuantizedLevels, int bitDepth ) const; |
314 | | void setEstimatedParameters( std::vector<int>& quantizedVec, int bitDepth, ComponentID compId ); |
315 | | void holdDarkStrength ( std::vector<int>& quantizedVec, int bitDepth ) const; |
316 | | void mergeIntervals ( std::vector<std::vector<int>>& parameters, int bitDepth ) const; |
317 | | void cutPlateauHoles ( std::vector<std::vector<int>>& parameters, int bitDepth ) const; |
318 | | void scaleDown ( std::vector<std::vector<int>>& parameters, int bitDepth ) const; |
319 | | |
320 | | void getVtmParameters ( double strength, int& log2ScaleFactor, SeiFgc::CompModel compModel[ MAX_NUM_COMP ] ) const; |
321 | | void getArParameters ( double strength, int& log2ScaleFactor, SeiFgc::CompModel compModel[ MAX_NUM_COMP ] ) const; |
322 | | bool arParametersAt ( double strength, int log2ScaleFactor, SeiFgc::CompModel compModel[ MAX_NUM_COMP ], bool& usable ) const; |
323 | | void fitArFilter ( ComponentID compId ); |
324 | | |
325 | | void estimateCutoffFreq ( ComponentID compId, int bitDepth ); |
326 | | int cutoffFrequency ( const std::vector<double>& mean ) const; |
327 | | void fitCutoffPair ( const std::vector<double>& meanSq, bool chroma420, int& horizontal, int& vertical ) const; |
328 | | void replaceCutoff ( ComponentID compId, int& replacementH, int& replacementV ); |
329 | | void limitCutoff ( ComponentID compId, int avgH, int avgV ); |
330 | | void limitCutoffConsecutive( ComponentID compId ); |
331 | | int limitCutoffPairs ( std::vector<CutoffPair>& pairs, int maxUnique ) const; |
332 | | |
333 | | FgaRowKernels m_kernels; |
334 | | |
335 | | #if ENABLE_SIMD_OPT_FGA && defined( TARGET_SIMD_X86 ) |
336 | | static void initFGAnalyzerX86( FgaRowKernels& k ); |
337 | | template <x86_simd::X86_VEXT vext> |
338 | | static void _initFGAnalyzerX86( FgaRowKernels& k ); |
339 | | #endif |
340 | | #if ENABLE_SIMD_OPT_FGA && defined( TARGET_SIMD_ARM ) |
341 | | static void initFGAnalyzerARM( FgaRowKernels& k ); |
342 | | template <arm_simd::ARM_VEXT vext> |
343 | | static void _initFGAnalyzerARM( FgaRowKernels& k ); |
344 | | #endif |
345 | | }; |
346 | | |
347 | | } // namespace vvenc |