/* * Copyright (c) 2016, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
staticint variance(int sum, int sum_squared, int size) { return sum_squared / size - (sum / size) * (sum / size);
} // Calculate a blockiness level for a vertical block edge. // This function returns a new blockiness metric that's defined as
// reconstructed_blockiness = abs(blockiness from reconstructed buffer - // blockiness from source buffer,0) // // I make the assumption that flat blocks are much more visible than high // contrast blocks. As such, I scale the result of the blockiness calc // by dividing the blockiness by the variance of the pixels on either side // of the edge as follows: // var_0 = (q0^2+q1^2+q2^2+q3^2) - ((q0 + q1 + q2 + q3) / 4 )^2 // var_1 = (r0^2+r1^2+r2^2+r3^2) - ((r0 + r1 + r2 + r3) / 4 )^2 // The returned blockiness is the scaled value // Reconstructed blockiness / ( 1 + var_0 + var_1 ) ; staticint blockiness_vertical(const uint8_t *s, int sp, const uint8_t *r, int rp, int size) { int s_blockiness = 0; int r_blockiness = 0; int sum_0 = 0; int sum_sq_0 = 0; int sum_1 = 0; int sum_sq_1 = 0; int i; int var_0; int var_1; for (i = 0; i < size; ++i, s += sp, r += rp) {
s_blockiness += horizontal_filter(s);
r_blockiness += horizontal_filter(r);
sum_0 += s[0];
sum_sq_0 += s[0] * s[0];
sum_1 += s[-1];
sum_sq_1 += s[-1] * s[-1];
}
var_0 = variance(sum_0, sum_sq_0, size);
var_1 = variance(sum_1, sum_sq_1, size);
r_blockiness = abs(r_blockiness);
s_blockiness = abs(s_blockiness);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.