From ce0a303f3302455d960189c2ebc2daa3b88100eb Mon Sep 17 00:00:00 2001 From: Alexander Rhatushnyak Date: Wed, 4 Jul 2018 18:06:11 -0400 Subject: [PATCH 1/2] Faster Convolution() --- butteraugli/butteraugli.cc | 200 ++++++++++++++++++++++++++++++++++--- 1 file changed, 184 insertions(+), 16 deletions(-) diff --git a/butteraugli/butteraugli.cc b/butteraugli/butteraugli.cc index a9973b1..553f34e 100755 --- a/butteraugli/butteraugli.cc +++ b/butteraugli/butteraugli.cc @@ -190,17 +190,17 @@ ImageF Convolution(const ImageF& in, PROFILER_FUNC; ImageF out(in.ysize(), in.xsize()); const int len = kernel.size(); - const int offset = kernel.size() / 2; + const int offset = len / 2; float weight_no_border = 0.0f; for (int j = 0; j < len; ++j) { weight_no_border += kernel[j]; } - float scale_no_border = 1.0f / weight_no_border; + const float scale_no_border = 1.0f / weight_no_border; const int border1 = in.xsize() <= offset ? in.xsize() : offset; const int border2 = in.xsize() - offset; - std::vector scaled_kernel = kernel; - for (int i = 0; i < scaled_kernel.size(); ++i) { - scaled_kernel[i] *= scale_no_border; + float* BUTTERAUGLI_RESTRICT scaled_kernel = (float*)malloc((len/2+1)*sizeof(float)); + for (int i = 0; i <= len/2; ++i) { + scaled_kernel[i] = kernel[i] * scale_no_border; } // left border for (int x = 0; x < border1; ++x) { @@ -208,23 +208,191 @@ ImageF Convolution(const ImageF& in, out.Row(x)); } // middle - for (size_t y = 0; y < in.ysize(); ++y) { - const float* const BUTTERAUGLI_RESTRICT row_in = in.Row(y); - for (int x = border1; x < border2; ++x) { - const int d = x - offset; - float* const BUTTERAUGLI_RESTRICT row_out = out.Row(x); - float sum = 0.0f; - for (int j = 0; j < len; ++j) { - sum += row_in[d + j] * scaled_kernel[j]; - } - row_out[y] = sum; - } + switch(len) { + #if 1 // speed-optimized version + case 5: { + const float sk0 = scaled_kernel[0]; + const float sk1 = scaled_kernel[1]; + const float sk2 = scaled_kernel[2]; + for (size_t y = 0; y < in.ysize(); ++y) { + const float* BUTTERAUGLI_RESTRICT row_in = in.Row(y) + border1 - offset; + for (int x = border1; x < border2; ++x, ++row_in) { + float sum = (row_in[ 0] + row_in[ 4]) * sk0; + sum += (row_in[ 1] + row_in[ 3]) * sk1; + sum += (row_in[ 2] ) * sk2; + float* const BUTTERAUGLI_RESTRICT row_out = out.Row(x); + row_out[y] = sum; + } + }} + break; + case 9: { + const float sk0 = scaled_kernel[0]; + const float sk1 = scaled_kernel[1]; + const float sk2 = scaled_kernel[2]; + const float sk3 = scaled_kernel[3]; + const float sk4 = scaled_kernel[4]; + for (size_t y = 0; y < in.ysize(); ++y) { + const float* BUTTERAUGLI_RESTRICT row_in = in.Row(y) + border1 - offset; + for (int x = border1; x < border2; ++x, ++row_in) { + float sum = (row_in[ 0] + row_in[ 8]) * sk0; + sum += (row_in[ 1] + row_in[ 7]) * sk1; + sum += (row_in[ 2] + row_in[ 6]) * sk2; + sum += (row_in[ 3] + row_in[ 5]) * sk3; + sum += (row_in[ 4] ) * sk4; + float* const BUTTERAUGLI_RESTRICT row_out = out.Row(x); + row_out[y] = sum; + } + }} + break; + case 17: + for (size_t y = 0; y < in.ysize(); ++y) { + const float* BUTTERAUGLI_RESTRICT row_in = in.Row(y) + border1 - offset; + for (int x = border1; x < border2; ++x, ++row_in) { + float sum = (row_in[ 0] + row_in[16]) * scaled_kernel[0]; + sum += (row_in[ 1] + row_in[15]) * scaled_kernel[1]; + sum += (row_in[ 2] + row_in[14]) * scaled_kernel[2]; + sum += (row_in[ 3] + row_in[13]) * scaled_kernel[3]; + sum += (row_in[ 4] + row_in[12]) * scaled_kernel[4]; + sum += (row_in[ 5] + row_in[11]) * scaled_kernel[5]; + sum += (row_in[ 6] + row_in[10]) * scaled_kernel[6]; + sum += (row_in[ 7] + row_in[ 9]) * scaled_kernel[7]; + sum += (row_in[ 8] ) * scaled_kernel[8]; + float* const BUTTERAUGLI_RESTRICT row_out = out.Row(x); + row_out[y] = sum; + } + } + break; + case 33: + for (size_t y = 0; y < in.ysize(); ++y) { + const float* BUTTERAUGLI_RESTRICT row_in = in.Row(y) + border1 - offset; + for (int x = border1; x < border2; ++x, ++row_in) { + float sum = (row_in[ 0] + row_in[32]) * scaled_kernel[ 0]; + sum += (row_in[ 1] + row_in[31]) * scaled_kernel[ 1]; + sum += (row_in[ 2] + row_in[30]) * scaled_kernel[ 2]; + sum += (row_in[ 3] + row_in[29]) * scaled_kernel[ 3]; + sum += (row_in[ 4] + row_in[28]) * scaled_kernel[ 4]; + sum += (row_in[ 5] + row_in[27]) * scaled_kernel[ 5]; + sum += (row_in[ 6] + row_in[26]) * scaled_kernel[ 6]; + sum += (row_in[ 7] + row_in[25]) * scaled_kernel[ 7]; + sum += (row_in[ 8] + row_in[24]) * scaled_kernel[ 8]; + sum += (row_in[ 9] + row_in[23]) * scaled_kernel[ 9]; + sum += (row_in[10] + row_in[22]) * scaled_kernel[10]; + sum += (row_in[11] + row_in[21]) * scaled_kernel[11]; + sum += (row_in[12] + row_in[20]) * scaled_kernel[12]; + sum += (row_in[13] + row_in[19]) * scaled_kernel[13]; + sum += (row_in[14] + row_in[18]) * scaled_kernel[14]; + sum += (row_in[15] + row_in[17]) * scaled_kernel[15]; + sum += (row_in[16] ) * scaled_kernel[16]; + float* const BUTTERAUGLI_RESTRICT row_out = out.Row(x); + row_out[y] = sum; + } + } + break; + case 11: + for (size_t y = 0; y < in.ysize(); ++y) { + const float* BUTTERAUGLI_RESTRICT row_in = in.Row(y) + border1 - offset; + for (int x = border1; x < border2; ++x, ++row_in) { + float sum = (row_in[ 0] + row_in[10]) * scaled_kernel[0]; + sum += (row_in[ 1] + row_in[ 9]) * scaled_kernel[1]; + sum += (row_in[ 2] + row_in[ 8]) * scaled_kernel[2]; + sum += (row_in[ 3] + row_in[ 7]) * scaled_kernel[3]; + sum += (row_in[ 4] + row_in[ 6]) * scaled_kernel[4]; + sum += (row_in[ 5] ) * scaled_kernel[5]; + float* const BUTTERAUGLI_RESTRICT row_out = out.Row(x); + row_out[y] = sum; + } + } + break; + case 41: + for (size_t y = 0; y < in.ysize(); ++y) { + const float* BUTTERAUGLI_RESTRICT row_in = in.Row(y) + border1 - offset; + for (int x = border1; x < border2; ++x, ++row_in) { + float sum = (row_in[ 0] + row_in[40]) * scaled_kernel[ 0]; + sum += (row_in[ 1] + row_in[39]) * scaled_kernel[ 1]; + sum += (row_in[ 2] + row_in[38]) * scaled_kernel[ 2]; + sum += (row_in[ 3] + row_in[37]) * scaled_kernel[ 3]; + sum += (row_in[ 4] + row_in[36]) * scaled_kernel[ 4]; + sum += (row_in[ 5] + row_in[35]) * scaled_kernel[ 5]; + sum += (row_in[ 6] + row_in[34]) * scaled_kernel[ 6]; + sum += (row_in[ 7] + row_in[33]) * scaled_kernel[ 7]; + sum += (row_in[ 8] + row_in[32]) * scaled_kernel[ 8]; + sum += (row_in[ 9] + row_in[31]) * scaled_kernel[ 9]; + sum += (row_in[10] + row_in[30]) * scaled_kernel[10]; + sum += (row_in[11] + row_in[29]) * scaled_kernel[11]; + sum += (row_in[12] + row_in[28]) * scaled_kernel[12]; + sum += (row_in[13] + row_in[27]) * scaled_kernel[13]; + sum += (row_in[14] + row_in[26]) * scaled_kernel[14]; + sum += (row_in[15] + row_in[25]) * scaled_kernel[15]; + sum += (row_in[16] + row_in[24]) * scaled_kernel[16]; + sum += (row_in[17] + row_in[23]) * scaled_kernel[17]; + sum += (row_in[18] + row_in[22]) * scaled_kernel[18]; + sum += (row_in[19] + row_in[21]) * scaled_kernel[19]; + sum += (row_in[20] ) * scaled_kernel[20]; + float* const BUTTERAUGLI_RESTRICT row_out = out.Row(x); + row_out[y] = sum; + } + } + break; + case 47: + for (size_t y = 0; y < in.ysize(); ++y) { + const float* BUTTERAUGLI_RESTRICT row_in = in.Row(y) + border1 - offset; + for (int x = border1; x < border2; ++x, ++row_in) { + float sum = (row_in[ 0] + row_in[46]) * scaled_kernel[ 0]; + sum += (row_in[ 1] + row_in[45]) * scaled_kernel[ 1]; + sum += (row_in[ 2] + row_in[44]) * scaled_kernel[ 2]; + sum += (row_in[ 3] + row_in[43]) * scaled_kernel[ 3]; + sum += (row_in[ 4] + row_in[42]) * scaled_kernel[ 4]; + sum += (row_in[ 5] + row_in[41]) * scaled_kernel[ 5]; + sum += (row_in[ 6] + row_in[40]) * scaled_kernel[ 6]; + sum += (row_in[ 7] + row_in[39]) * scaled_kernel[ 7]; + sum += (row_in[ 8] + row_in[38]) * scaled_kernel[ 8]; + sum += (row_in[ 9] + row_in[37]) * scaled_kernel[ 9]; + sum += (row_in[10] + row_in[36]) * scaled_kernel[10]; + sum += (row_in[11] + row_in[35]) * scaled_kernel[11]; + sum += (row_in[12] + row_in[34]) * scaled_kernel[12]; + sum += (row_in[13] + row_in[33]) * scaled_kernel[13]; + sum += (row_in[14] + row_in[32]) * scaled_kernel[14]; + sum += (row_in[15] + row_in[31]) * scaled_kernel[15]; + sum += (row_in[16] + row_in[30]) * scaled_kernel[16]; + sum += (row_in[17] + row_in[29]) * scaled_kernel[17]; + sum += (row_in[18] + row_in[28]) * scaled_kernel[18]; + sum += (row_in[19] + row_in[27]) * scaled_kernel[19]; + sum += (row_in[20] + row_in[26]) * scaled_kernel[20]; + sum += (row_in[21] + row_in[25]) * scaled_kernel[21]; + sum += (row_in[22] + row_in[24]) * scaled_kernel[22]; + sum += (row_in[23] ) * scaled_kernel[23]; + float* const BUTTERAUGLI_RESTRICT row_out = out.Row(x); + row_out[y] = sum; + } + } + break; + default: + printf("Warning: Unexpected kernel size! %d\n", len); + #else + default: + #endif + for (size_t y = 0; y < in.ysize(); ++y) { + const float* const BUTTERAUGLI_RESTRICT row_in = in.Row(y); + for (int j, x = border1; x < border2; ++x) { + const int d = x - offset; + float* const BUTTERAUGLI_RESTRICT row_out = out.Row(x); + float sum = 0.0f; + for (j = 0; j <= len/2; ++j) { + sum += row_in[d + j] * scaled_kernel[j]; + } + for (; j < len; ++j) { + sum += row_in[d + j] * scaled_kernel[len-1-j]; + } + row_out[y] = sum; + } + } } // right border for (int x = border2; x < in.xsize(); ++x) { ConvolveBorderColumn(in, kernel, weight_no_border, border_ratio, x, out.Row(x)); } + free(scaled_kernel); return out; } From b4a44b2bc496dc60f4ad9aeae9630f92ea4c3f57 Mon Sep 17 00:00:00 2001 From: Alexander Rhatushnyak Date: Wed, 4 Jul 2018 18:12:14 -0400 Subject: [PATCH 2/2] A few more speed improvements, is it twice faster now? --- butteraugli/butteraugli.cc | 145 ++++++++++++++++++++++--------------- 1 file changed, 86 insertions(+), 59 deletions(-) diff --git a/butteraugli/butteraugli.cc b/butteraugli/butteraugli.cc index 553f34e..6067c0f 100755 --- a/butteraugli/butteraugli.cc +++ b/butteraugli/butteraugli.cc @@ -684,8 +684,11 @@ static void SeparateFrequencies( // ... and keep everything else in mf. ps.mf[i] = ImageF(xsize, ysize); for (size_t y = 0; y < ysize; ++y) { + float* BUTTERAUGLI_RESTRICT const row_mf = ps.mf[i].Row(y); + float* BUTTERAUGLI_RESTRICT const row_lf = ps.lf[i].Row(y); + const float* BUTTERAUGLI_RESTRICT const row_xyb = xyb[i].Row(y); for (size_t x = 0; x < xsize; ++x) { - ps.mf[i].Row(y)[x] = xyb[i].Row(y)[x] - ps.lf[i].Row(y)[x]; + row_mf[x] = row_xyb[x] - row_lf[x]; } } if (i == 2) { @@ -697,9 +700,10 @@ static void SeparateFrequencies( for (size_t y = 0; y < ysize; ++y) { float* BUTTERAUGLI_RESTRICT const row_mf = ps.mf[i].Row(y); float* BUTTERAUGLI_RESTRICT const row_hf = ps.hf[i].Row(y); - for (size_t x = 0; x < xsize; ++x) { - row_hf[x] = row_mf[x]; - } + //for (size_t x = 0; x < xsize; ++x) { + // row_hf[x] = row_mf[x]; + //} + memcpy(row_hf, row_mf, xsize*sizeof(float)); } ps.mf[i] = Blur(ps.mf[i], kSigmaHf, border_mf); static const double w0 = 0.120079806822; @@ -734,9 +738,10 @@ static void SeparateFrequencies( for (size_t y = 0; y < ysize; ++y) { float* BUTTERAUGLI_RESTRICT const row_uhf = ps.uhf[i].Row(y); float* BUTTERAUGLI_RESTRICT const row_hf = ps.hf[i].Row(y); - for (size_t x = 0; x < xsize; ++x) { - row_uhf[x] = row_hf[x]; - } + //for (size_t x = 0; x < xsize; ++x) { + // row_uhf[x] = row_hf[x]; + //} + memcpy(row_uhf, row_hf, xsize*sizeof(float)); } ps.hf[i] = Blur(ps.hf[i], kSigmaUhf, border_hf); static const double kRemoveHfRange = 0.0287615200377; @@ -923,6 +928,18 @@ void MaskPsychoImage(const PsychoImage& pi0, const PsychoImage& pi1, for (int i = 0; i < 2; ++i) { double a = muls[2 * i]; double b = muls[2 * i + 1]; + if (a==0) + for (size_t y = 0; y < ysize; ++y) { + const float* const BUTTERAUGLI_RESTRICT row_hf0 = pi0.hf[i].Row(y); + const float* const BUTTERAUGLI_RESTRICT row_hf1 = pi1.hf[i].Row(y); + float* const BUTTERAUGLI_RESTRICT row0 = mask_xyb0[i].Row(y); + float* const BUTTERAUGLI_RESTRICT row1 = mask_xyb1[i].Row(y); + for (size_t x = 0; x < xsize; ++x) { + row0[x] = b * row_hf0[x]; + row1[x] = b * row_hf1[x]; + } + } + else for (size_t y = 0; y < ysize; ++y) { const float* const BUTTERAUGLI_RESTRICT row_hf0 = pi0.hf[i].Row(y); const float* const BUTTERAUGLI_RESTRICT row_hf1 = pi1.hf[i].Row(y); @@ -1632,60 +1649,41 @@ static void MaltaDiffMapImpl(const ImageF& lum0, const ImageF& lum1, const float norm2_0gt1 = w_pre0gt1 * norm1; const float norm2_0lt1 = w_pre0lt1 * norm1; - std::vector diffs(ysize_ * xsize_); + //std::vector diffs(ysize_ * xsize_); + float *diffs = (float*)malloc(ysize_ * xsize_ * sizeof(float)); for (size_t y = 0, ix = 0; y < ysize_; ++y) { const float* BUTTERAUGLI_RESTRICT const row0 = lum0.Row(y); const float* BUTTERAUGLI_RESTRICT const row1 = lum1.Row(y); for (size_t x = 0; x < xsize_; ++x, ++ix) { - const float absval = 0.5 * std::abs(row0[x]) + 0.5 * std::abs(row1[x]); - const float diff = row0[x] - row1[x]; - const float scaler = norm2_0gt1 / (static_cast(norm1) + absval); - - // Primary symmetric quadratic objective. - diffs[ix] = scaler * diff; - - const float scaler2 = norm2_0lt1 / (static_cast(norm1) + absval); const double fabs0 = fabs(row0[x]); - // Secondary half-open quadratic objectives. const double too_small = 0.55 * fabs0; const double too_big = 1.05 * fabs0; + double impact = 0; if (row0[x] < 0) { if (row1[x] > -too_small) { - double impact = scaler2 * (row1[x] + too_small); - if (diff < 0) { - diffs[ix] -= impact; - } else { - diffs[ix] += impact; - } + impact = (row1[x] + too_small) * norm2_0lt1; } else if (row1[x] < -too_big) { - double impact = scaler2 * (-row1[x] - too_big); - if (diff < 0) { - diffs[ix] -= impact; - } else { - diffs[ix] += impact; - } + impact = (-row1[x] - too_big) * norm2_0lt1; } } else { if (row1[x] < too_small) { - double impact = scaler2 * (too_small - row1[x]); - if (diff < 0) { - diffs[ix] -= impact; - } else { - diffs[ix] += impact; - } + impact = (too_small - row1[x]) * norm2_0lt1; } else if (row1[x] > too_big) { - double impact = scaler2 * (row1[x] - too_big); - if (diff < 0) { - diffs[ix] -= impact; - } else { - diffs[ix] += impact; - } + impact =(row1[x] - too_big) * norm2_0lt1; } } - } - } + const float diff = row0[x] - row1[x]; + if (diff < 0) + impact = -impact; + const float scaler = (std::abs(row0[x]) + std::abs(row1[x])) * 0.5 + + static_cast(norm1); + // Primary symmetric quadratic objective. + diffs[ix] = (norm2_0gt1 * diff + impact) / scaler; + + }//x + }//y size_t y0 = 0; // Top @@ -1709,7 +1707,6 @@ static void MaltaDiffMapImpl(const ImageF& lum0, const ImageF& lum1, row_diff[x0] += PaddedMaltaUnit(&diffs[0], x0, y0, xsize_, ysize_); } - for (; x0 < xsize_; ++x0) { row_diff[x0] += PaddedMaltaUnit(&diffs[0], x0, y0, xsize_, ysize_); @@ -1724,6 +1721,7 @@ static void MaltaDiffMapImpl(const ImageF& lum0, const ImageF& lum1, PaddedMaltaUnit(&diffs[0], x0, y0, xsize_, ysize_); } } + free(diffs); } void ButteraugliComparator::MaltaDiffMap( @@ -1762,7 +1760,20 @@ ImageF ButteraugliComparator::CombineChannels( ImageF result(xsize_, ysize_); for (size_t y = 0; y < ysize_; ++y) { float* const BUTTERAUGLI_RESTRICT row_out = result.Row(y); + const float* const BUTTERAUGLI_RESTRICT msk0 = mask_xyb[0].Row(y); + const float* const BUTTERAUGLI_RESTRICT msk1 = mask_xyb[1].Row(y); + const float* const BUTTERAUGLI_RESTRICT msk2 = mask_xyb[2].Row(y); + const float* const BUTTERAUGLI_RESTRICT dcmsk0 = mask_xyb_dc[0].Row(y); + const float* const BUTTERAUGLI_RESTRICT dcmsk1 = mask_xyb_dc[1].Row(y); + const float* const BUTTERAUGLI_RESTRICT dcmsk2 = mask_xyb_dc[2].Row(y); + const float* const BUTTERAUGLI_RESTRICT bddc0 = block_diff_dc[0].Row(y); + const float* const BUTTERAUGLI_RESTRICT bddc1 = block_diff_dc[1].Row(y); + const float* const BUTTERAUGLI_RESTRICT bddc2 = block_diff_dc[2].Row(y); + const float* const BUTTERAUGLI_RESTRICT bdac0 = block_diff_ac[0].Row(y); + const float* const BUTTERAUGLI_RESTRICT bdac1 = block_diff_ac[1].Row(y); + const float* const BUTTERAUGLI_RESTRICT bdac2 = block_diff_ac[2].Row(y); for (size_t x = 0; x < xsize_; ++x) { + /* float mask[3]; float dc_mask[3]; float diff_dc[3]; @@ -1774,6 +1785,11 @@ ImageF ButteraugliComparator::CombineChannels( diff_ac[i] = block_diff_ac[i].Row(y)[x]; } row_out[x] = (DotProduct(diff_dc, dc_mask) + DotProduct(diff_ac, mask)); + */ + row_out[x] = + bddc0[x] * dcmsk0[x] + bdac0[x] * msk0[x] + + bddc1[x] * dcmsk1[x] + bdac1[x] * msk1[x] + + bddc2[x] * dcmsk2[x] + bdac2[x] * msk2[x]; } } return result; @@ -1924,9 +1940,10 @@ void Mask(const std::vector& xyb0, ImageF blurred = Blur(diff, r2, border_ratio); (*mask)[0] = ImageF(xsize, ysize); for (size_t y = 0; y < ysize; ++y) { - for (size_t x = 0; x < xsize; ++x) { - (*mask)[0].Row(y)[x] = blurred.Row(y)[x]; - } + //for (size_t x = 0; x < xsize; ++x) { + // (*mask)[0].Row(y)[x] = blurred.Row(y)[x]; + //} + memcpy((*mask)[0].Row(y), blurred.Row(y), xsize*sizeof(float)); } } { @@ -1936,11 +1953,14 @@ void Mask(const std::vector& xyb0, ImageF blurred1 = Blur(diff, r0, border_ratio); ImageF blurred2 = Blur(diff, r1, border_ratio); for (size_t y = 0; y < ysize; ++y) { + const float* b1_row = blurred1.Row(y); + const float* b2_row = blurred2.Row(y); + float* const m_row = (*mask)[1].Row(y); for (size_t x = 0; x < xsize; ++x) { const double val = normalizer * ( - muls[0] * blurred1.Row(y)[x] + - muls[1] * blurred2.Row(y)[x]); - (*mask)[1].Row(y)[x] = val; + muls[0] * b1_row[x] + + muls[1] * b2_row[x]); + m_row[x] = val; } } } @@ -1959,18 +1979,23 @@ void Mask(const std::vector& xyb0, static const double p1_to_p0 = 0.0513061271723; for (size_t y = 0; y < ysize; ++y) { + float* const m0_row = (*mask)[0].Row(y); + float* const m1_row = (*mask)[1].Row(y); + float* const m2_row = (*mask)[2].Row(y); + float* const mdc0_row = (*mask_dc)[0].Row(y); + float* const mdc1_row = (*mask_dc)[1].Row(y); + float* const mdc2_row = (*mask_dc)[2].Row(y); for (size_t x = 0; x < xsize; ++x) { - const double s0 = (*mask)[0].Row(y)[x]; - const double s1 = (*mask)[1].Row(y)[x]; + const double s0 = m0_row[x]; + const double s1 = m1_row[x]; const double p1 = mul[1] * w11 * s1; const double p0 = mul[0] * w00 * s0 + p1_to_p0 * p1; - - (*mask)[0].Row(y)[x] = MaskX(p0); - (*mask)[1].Row(y)[x] = MaskY(p1); - (*mask)[2].Row(y)[x] = w_ytob_hf * MaskY(p1); - (*mask_dc)[0].Row(y)[x] = MaskDcX(p0); - (*mask_dc)[1].Row(y)[x] = MaskDcY(p1); - (*mask_dc)[2].Row(y)[x] = w_ytob_lf * MaskDcY(p1); + m0_row[x] = MaskX(p0); + m1_row[x] = MaskY(p1); + m2_row[x] = w_ytob_hf * MaskY(p1); + mdc0_row[x] = MaskDcX(p0); + mdc1_row[x] = MaskDcY(p1); + mdc2_row[x] = w_ytob_lf * MaskDcY(p1); } } } @@ -2039,6 +2064,7 @@ bool ButteraugliInterface(const std::vector &rgb0, return true; } +#if 1 // unused ? bool ButteraugliAdaptiveQuantization(size_t xsize, size_t ysize, const std::vector > &rgb, std::vector &quant) { if (xsize < 16 || ysize < 16) { @@ -2061,6 +2087,7 @@ bool ButteraugliAdaptiveQuantization(size_t xsize, size_t ysize, } return true; } +#endif double ButteraugliFuzzyClass(double score) { static const double fuzzy_width_up = 6.07887388532;