#include "vpx/vpx_integer.h"
#include "vpx_ports/mem.h"
-#define VP9_FILTER_WEIGHT 128
-#define VP9_FILTER_SHIFT 7
-
/* Assume a bank of 16 filters to choose from. There are two implementations
* for filter wrapping behavior, since we want to be able to pick which filter
* to start with. We could either:
const int16_t *filter_x0, int x_step_q4,
const int16_t *filter_y, int y_step_q4,
int w, int h, int taps) {
- int x, y, k, sum;
+ int x, y, k;
const int16_t *filter_x_base = filter_x0;
#if ALIGN_FILTERS_256
for (x = 0; x < w; ++x) {
/* Per-pixel src offset */
int src_x = (x_q4 - x0_q4) >> 4;
+ int sum = 0;
- for (sum = 0, k = 0; k < taps; ++k) {
+ for (k = 0; k < taps; ++k)
sum += src[src_x + k] * filter_x[k];
- }
- sum += (VP9_FILTER_WEIGHT >> 1);
- dst[x] = clip_pixel(sum >> VP9_FILTER_SHIFT);
+
+ dst[x] = clip_pixel(ROUND_POWER_OF_TWO(sum, VP9_FILTER_BITS));
/* Adjust source and filter to use for the next pixel */
x_q4 += x_step_q4;
const int16_t *filter_x0, int x_step_q4,
const int16_t *filter_y, int y_step_q4,
int w, int h, int taps) {
- int x, y, k, sum;
+ int x, y, k;
const int16_t *filter_x_base = filter_x0;
#if ALIGN_FILTERS_256
for (x = 0; x < w; ++x) {
/* Per-pixel src offset */
int src_x = (x_q4 - x0_q4) >> 4;
+ int sum = 0;
- for (sum = 0, k = 0; k < taps; ++k) {
+ for (k = 0; k < taps; ++k)
sum += src[src_x + k] * filter_x[k];
- }
- sum += (VP9_FILTER_WEIGHT >> 1);
- dst[x] = (dst[x] + clip_pixel(sum >> VP9_FILTER_SHIFT) + 1) >> 1;
+
+ dst[x] = ROUND_POWER_OF_TWO(dst[x] +
+ clip_pixel(ROUND_POWER_OF_TWO(sum, VP9_FILTER_BITS)), 1);
/* Adjust source and filter to use for the next pixel */
x_q4 += x_step_q4;
const int16_t *filter_x, int x_step_q4,
const int16_t *filter_y0, int y_step_q4,
int w, int h, int taps) {
- int x, y, k, sum;
+ int x, y, k;
const int16_t *filter_y_base = filter_y0;
for (y = 0; y < h; ++y) {
/* Per-pixel src offset */
int src_y = (y_q4 - y0_q4) >> 4;
+ int sum = 0;
- for (sum = 0, k = 0; k < taps; ++k) {
+ for (k = 0; k < taps; ++k)
sum += src[(src_y + k) * src_stride] * filter_y[k];
- }
- sum += (VP9_FILTER_WEIGHT >> 1);
- dst[y * dst_stride] = clip_pixel(sum >> VP9_FILTER_SHIFT);
+
+ dst[y * dst_stride] =
+ clip_pixel(ROUND_POWER_OF_TWO(sum, VP9_FILTER_BITS));
/* Adjust source and filter to use for the next pixel */
y_q4 += y_step_q4;
const int16_t *filter_x, int x_step_q4,
const int16_t *filter_y0, int y_step_q4,
int w, int h, int taps) {
- int x, y, k, sum;
+ int x, y, k;
const int16_t *filter_y_base = filter_y0;
for (y = 0; y < h; ++y) {
/* Per-pixel src offset */
int src_y = (y_q4 - y0_q4) >> 4;
+ int sum = 0;
- for (sum = 0, k = 0; k < taps; ++k) {
+ for (k = 0; k < taps; ++k)
sum += src[(src_y + k) * src_stride] * filter_y[k];
- }
- sum += (VP9_FILTER_WEIGHT >> 1);
- dst[y * dst_stride] =
- (dst[y * dst_stride] + clip_pixel(sum >> VP9_FILTER_SHIFT) + 1) >> 1;
+
+ dst[y * dst_stride] = ROUND_POWER_OF_TWO(dst[y * dst_stride] +
+ clip_pixel(ROUND_POWER_OF_TWO(sum, VP9_FILTER_BITS)), 1);
/* Adjust source and filter to use for the next pixel */
y_q4 += y_step_q4;
#ifndef VP9_COMMON_VP9_SUBPELVAR_H_
#define VP9_COMMON_VP9_SUBPELVAR_H_
-#include "vp9/common/vp9_filter.h"
+#include "vp9/common/vp9_common.h"
+#include "vp9/common/vp9_convolve.h"
static void variance(const uint8_t *src_ptr,
int source_stride,
for (i = 0; i < output_height; i++) {
for (j = 0; j < output_width; j++) {
- // Apply bilinear filter
- output_ptr[j] = (((int)src_ptr[0] * vp9_filter[0]) +
- ((int)src_ptr[pixel_step] * vp9_filter[1]) +
- (VP9_FILTER_WEIGHT / 2)) >> VP9_FILTER_SHIFT;
+ output_ptr[j] = ROUND_POWER_OF_TWO((int)src_ptr[0] * vp9_filter[0] +
+ (int)src_ptr[pixel_step] * vp9_filter[1],
+ VP9_FILTER_BITS);
+
src_ptr++;
}
unsigned int output_width,
const int16_t *vp9_filter) {
unsigned int i, j;
- int Temp;
for (i = 0; i < output_height; i++) {
for (j = 0; j < output_width; j++) {
- // Apply filter
- Temp = ((int)src_ptr[0] * vp9_filter[0]) +
- ((int)src_ptr[pixel_step] * vp9_filter[1]) +
- (VP9_FILTER_WEIGHT / 2);
- output_ptr[j] = (unsigned int)(Temp >> VP9_FILTER_SHIFT);
+ output_ptr[j] = ROUND_POWER_OF_TWO((int)src_ptr[0] * vp9_filter[0] +
+ (int)src_ptr[pixel_step] * vp9_filter[1],
+ VP9_FILTER_BITS);
src_ptr++;
}
- // Next row...
- src_ptr += src_pixels_per_line - output_width;
+ src_ptr += src_pixels_per_line - output_width;
output_ptr += output_width;
}
}