// Copyright 2014 Google Inc. All Rights Reserved. // // Use of this source code is governed by a BSD-style license // that can be found in the COPYING file in the root of the source // tree. An additional intellectual property rights grant can be found // in the file PATENTS. All contributing project authors may // be found in the AUTHORS file in the root of the source tree. // ----------------------------------------------------------------------------- // // WebPPicture tools for measuring distortion // // Author: Skal (pascal.massimino@gmail.com)
typedefdouble (*AccumulateFunc)(const uint8_t* src, int src_stride, const uint8_t* ref, int ref_stride, int w, int h);
//------------------------------------------------------------------------------ // local-min distortion // // For every pixel in the *reference* picture, we search for the local best // match in the compressed image. This is not a symmetrical measure.
#define RADIUS 2 // search radius. Shouldn't be too large.
staticdouble AccumulateLSIM(const uint8_t* src, int src_stride, const uint8_t* ref, int ref_stride, int w, int h) { int x, y; double total_sse = 0.; for (y = 0; y < h; ++y) { constint y_0 = (y - RADIUS < 0) ? 0 : y - RADIUS; constint y_1 = (y + RADIUS + 1 >= h) ? h : y + RADIUS + 1; for (x = 0; x < w; ++x) { constint x_0 = (x - RADIUS < 0) ? 0 : x - RADIUS; constint x_1 = (x + RADIUS + 1 >= w) ? w : x + RADIUS + 1; double best_sse = 255. * 255.; constdouble value = (double)ref[y * ref_stride + x]; int i, j; for (j = y_0; j < y_1; ++j) { const uint8_t* const s = src + j * src_stride; for (i = x_0; i < x_1; ++i) { constdouble diff = s[i] - value; constdouble sse = diff * diff; if (sse < best_sse) best_sse = sse;
}
}
total_sse += best_sse;
}
} return total_sse;
} #undef RADIUS
staticdouble AccumulateSSE(const uint8_t* src, int src_stride, const uint8_t* ref, int ref_stride, int w, int h) { int y; double total_sse = 0.; for (y = 0; y < h; ++y) {
total_sse += VP8AccumulateSSE(src, ref, w);
src += src_stride;
ref += ref_stride;
} return total_sse;
}
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.