Skip to content

Commit 9169430

Browse files
authored
Fix #515 (#518)
1 parent 95f7a76 commit 9169430

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

source/Lib/EncoderLib/SEIFilmGrainAnalyzer.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,13 @@ void gradient_core ( PelStorage *buff1,
107107
for (int j = 0; j < height; j++)
108108
{
109109
int acc = 0;
110+
int xOffset = i - convWidthS / 2;
111+
int yOffset = j - convHeightS / 2;
110112
for (int x = 0; x < convWidthS; x++)
111113
{
112114
for (int y = 0; y < convHeightS; y++)
113115
{
114-
acc += (buff1->get(compID).at(x - convWidthS / 2 + i, y - convHeightS / 2 + j) * m_gx[x][y]);
116+
acc += ( buff1->get(compID).at( x + xOffset, y + yOffset ) * m_gx[x][y] );
115117
}
116118
}
117119
tmpBuf1->Y().at(i, j) = acc;
@@ -526,7 +528,6 @@ int dilation_core ( PelStorage *buff,
526528
++iter,
527529
Value );
528530

529-
return iter;
530531
}
531532

532533
Morph::Morph()
@@ -1258,8 +1259,8 @@ void FGAnalyzer::estimateScalingFactors ( uint32_t bitDepth,
12581259
void FGAnalyzer::adaptiveSampling ( int bins,
12591260
double threshold,
12601261
std::vector<int>& significantIndices,
1261-
int startIdx,
1262-
bool isRow )
1262+
bool isRow,
1263+
int startIdx )
12631264
{
12641265
int binSize = DATA_BASE_SIZE / bins;
12651266
for ( int i = 0; i < bins; i++ )
@@ -1318,11 +1319,13 @@ void FGAnalyzer::estimateCutoffFreqAdaptive( ComponentID compId )
13181319
adaptiveSampling ( coarseBins,
13191320
threshold,
13201321
significantRows,
1321-
true ); // Rows
1322+
true,
1323+
0 ); // Rows
13221324
adaptiveSampling ( coarseBins,
13231325
threshold,
13241326
significantCols,
1325-
false ); // Columns
1327+
false,
1328+
0 ); // Columns
13261329

13271330
// Iterative Refinement
13281331
for ( int iter = 0; iter < maxIterations; iter++ )
@@ -1333,16 +1336,16 @@ void FGAnalyzer::estimateCutoffFreqAdaptive( ComponentID compId )
13331336
adaptiveSampling ( refineBins,
13341337
threshold,
13351338
refinedRows,
1336-
row,
1337-
true );
1339+
true,
1340+
row );
13381341
}
13391342
for ( int col : significantCols )
13401343
{
13411344
adaptiveSampling ( refineBins,
13421345
threshold,
13431346
refinedCols,
1344-
col,
1345-
false );
1347+
false,
1348+
col );
13461349
}
13471350
significantRows = refinedRows;
13481351
significantCols = refinedCols;

source/Lib/EncoderLib/SEIFilmGrainAnalyzer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ class FGAnalyzer
256256
void adaptiveSampling ( int bins,
257257
double threshold,
258258
std::vector<int>& significantIndices,
259-
int startIdx = 0,
260-
bool isRow = true );
259+
bool isRow,
260+
int startIdx );
261261

262262
void estimateCutoffFreqAdaptive ( ComponentID compID );
263263

0 commit comments

Comments
 (0)