/* * Copyright (c) 2010 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE 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.
*/
uint32_t vpx_get4x4sse_cs_c(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride) { int distortion = 0; int r, c;
for (r = 0; r < 4; ++r) { for (c = 0; c < 4; ++c) { int diff = src_ptr[c] - ref_ptr[c];
distortion += diff * diff;
}
src_ptr += src_stride;
ref_ptr += ref_stride;
}
return distortion;
}
uint32_t vpx_get_mb_ss_c(const int16_t *src_ptr) { unsignedint i, sum = 0;
for (i = 0; i < 256; ++i) {
sum += src_ptr[i] * src_ptr[i];
}
return sum;
}
staticvoid variance(const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, int w, int h,
uint32_t *sse, int *sum) { int i, j;
*sum = 0;
*sse = 0;
for (i = 0; i < h; ++i) { for (j = 0; j < w; ++j) { constint diff = src_ptr[j] - ref_ptr[j];
*sum += diff;
*sse += diff * diff;
}
src_ptr += src_stride;
ref_ptr += ref_stride;
}
}
// Applies a 1-D 2-tap bilinear filter to the source block in either horizontal // or vertical direction to produce the filtered output block. Used to implement // the first-pass of 2-D separable filter. // // Produces int16_t output to retain precision for the next pass. Two filter // taps should sum to FILTER_WEIGHT. pixel_step defines whether the filter is // applied horizontally (pixel_step = 1) or vertically (pixel_step = stride). // It defines the offset required to move from one input to the next. staticvoid var_filter_block2d_bil_first_pass( const uint8_t *src_ptr, uint16_t *ref_ptr, unsignedint src_pixels_per_line, int pixel_step, unsignedint output_height, unsignedint output_width, const uint8_t *filter) { unsignedint i, j;
for (i = 0; i < output_height; ++i) { for (j = 0; j < output_width; ++j) {
ref_ptr[j] = ROUND_POWER_OF_TWO(
(int)src_ptr[0] * filter[0] + (int)src_ptr[pixel_step] * filter[1],
FILTER_BITS);
// Applies a 1-D 2-tap bilinear filter to the source block in either horizontal // or vertical direction to produce the filtered output block. Used to implement // the second-pass of 2-D separable filter. // // Requires 16-bit input as produced by filter_block2d_bil_first_pass. Two // filter taps should sum to FILTER_WEIGHT. pixel_step defines whether the // filter is applied horizontally (pixel_step = 1) or vertically // (pixel_step = stride). It defines the offset required to move from one input // to the next. Output is 8-bit. staticvoid var_filter_block2d_bil_second_pass( const uint16_t *src_ptr, uint8_t *ref_ptr, unsignedint src_pixels_per_line, unsignedint pixel_step, unsignedint output_height, unsignedint output_width, const uint8_t *filter) { unsignedint i, j;
for (i = 0; i < output_height; ++i) { for (j = 0; j < output_width; ++j) {
ref_ptr[j] = ROUND_POWER_OF_TWO(
(int)src_ptr[0] * filter[0] + (int)src_ptr[pixel_step] * filter[1],
FILTER_BITS);
++src_ptr;
}
/* Identical to the variance call except it takes an additional parameter, sum, * and returns that value using pass-by-reference instead of returning * sse - sum^2 / w*h
*/ #define GET_VAR(W, H) \ void vpx_get##W##x##H##var_c(const uint8_t *src_ptr, int src_stride, \ const uint8_t *ref_ptr, int ref_stride, \
uint32_t *sse, int *sum) { \
variance(src_ptr, src_stride, ref_ptr, ref_stride, W, H, sse, sum); \
}
/* Identical to the variance call except it does not calculate the * sse - sum^2 / w*h and returns sse in addition to modifying the passed in * variable.
*/ #define MSE(W, H) \
uint32_t vpx_mse##W##x##H##_c(const uint8_t *src_ptr, int src_stride, \ const uint8_t *ref_ptr, int ref_stride, \
uint32_t *sse) { \ int sum; \
variance(src_ptr, src_stride, ref_ptr, ref_stride, W, H, sse, &sum); \ return *sse; \
}
/* All three forms of the variance are available in the same sizes. */ #define VARIANCES(W, H) \
VAR(W, H) \
SUBPIX_VAR(W, H) \
SUBPIX_AVG_VAR(W, H)
void vpx_comp_avg_pred_c(uint8_t *comp_pred, const uint8_t *pred, int width, int height, const uint8_t *ref, int ref_stride) { int i, j;
for (i = 0; i < height; ++i) { for (j = 0; j < width; ++j) { constint tmp = pred[j] + ref[j];
comp_pred[j] = ROUND_POWER_OF_TWO(tmp, 1);
}
comp_pred += width;
pred += width;
ref += ref_stride;
}
}
#if CONFIG_VP9_HIGHBITDEPTH staticvoid highbd_variance64(const uint8_t *src8_ptr, int src_stride, const uint8_t *ref8_ptr, int ref_stride, int w, int h, uint64_t *sse, int64_t *sum) { int i, j;
/* All three forms of the variance are available in the same sizes. */ #define HIGHBD_VARIANCES(W, H) \
HIGHBD_VAR(W, H) \
HIGHBD_SUBPIX_VAR(W, H) \
HIGHBD_SUBPIX_AVG_VAR(W, H)
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.