2010-05-18 11:58:33 -04:00
|
|
|
/*
|
2010-09-09 08:16:39 -04:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 11:58:33 -04:00
|
|
|
*
|
2010-06-18 12:39:21 -04:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 16:19:40 -04:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 12:39:21 -04:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 16:19:40 -04:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 11:58:33 -04:00
|
|
|
*/
|
|
|
|
|
2012-11-29 16:36:10 -08:00
|
|
|
#ifndef VP9_ENCODER_VP9_VARIANCE_H_
|
|
|
|
#define VP9_ENCODER_VP9_VARIANCE_H_
|
2010-05-18 11:58:33 -04:00
|
|
|
|
2012-12-18 15:31:19 -08:00
|
|
|
#include "vpx/vpx_integer.h"
|
2015-05-15 11:52:03 -07:00
|
|
|
#include "vpx_ports/mem.h"
|
2014-01-18 12:16:11 -08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2012-12-18 15:31:19 -08:00
|
|
|
|
2015-05-15 11:52:03 -07:00
|
|
|
// TODO(johannkoenig): All functions which depend on
|
|
|
|
// [highbd_][8|10|12_]variance should be refactored or moved to vpx_dsp.
|
|
|
|
static void variance(const uint8_t *a, int a_stride,
|
|
|
|
const uint8_t *b, int b_stride,
|
|
|
|
int w, int h, unsigned int *sse, int *sum) {
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
*sum = 0;
|
|
|
|
*sse = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < h; i++) {
|
|
|
|
for (j = 0; j < w; j++) {
|
|
|
|
const int diff = a[j] - b[j];
|
|
|
|
*sum += diff;
|
|
|
|
*sse += diff * diff;
|
|
|
|
}
|
|
|
|
|
|
|
|
a += a_stride;
|
|
|
|
b += b_stride;
|
|
|
|
}
|
|
|
|
}
|
2013-10-07 19:20:10 +01:00
|
|
|
|
2014-09-05 15:00:54 -07:00
|
|
|
#if CONFIG_VP9_HIGHBITDEPTH
|
2015-05-15 11:52:03 -07:00
|
|
|
static void highbd_variance64(const uint8_t *a8, int a_stride,
|
|
|
|
const uint8_t *b8, int b_stride,
|
|
|
|
int w, int h, uint64_t *sse, uint64_t *sum) {
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
uint16_t *a = CONVERT_TO_SHORTPTR(a8);
|
|
|
|
uint16_t *b = CONVERT_TO_SHORTPTR(b8);
|
|
|
|
*sum = 0;
|
|
|
|
*sse = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < h; i++) {
|
|
|
|
for (j = 0; j < w; j++) {
|
|
|
|
const int diff = a[j] - b[j];
|
|
|
|
*sum += diff;
|
|
|
|
*sse += diff * diff;
|
|
|
|
}
|
|
|
|
a += a_stride;
|
|
|
|
b += b_stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void highbd_8_variance(const uint8_t *a8, int a_stride,
|
|
|
|
const uint8_t *b8, int b_stride,
|
|
|
|
int w, int h, unsigned int *sse, int *sum) {
|
|
|
|
uint64_t sse_long = 0;
|
|
|
|
uint64_t sum_long = 0;
|
|
|
|
highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, &sum_long);
|
|
|
|
*sse = (unsigned int)sse_long;
|
|
|
|
*sum = (int)sum_long;
|
|
|
|
}
|
2014-09-05 15:00:54 -07:00
|
|
|
#endif
|
|
|
|
|
2012-12-18 15:31:19 -08:00
|
|
|
typedef unsigned int(*vp9_sad_fn_t)(const uint8_t *src_ptr,
|
2012-10-21 20:47:57 -07:00
|
|
|
int source_stride,
|
2012-12-18 15:31:19 -08:00
|
|
|
const uint8_t *ref_ptr,
|
2014-05-13 10:11:42 -07:00
|
|
|
int ref_stride);
|
2012-10-21 20:47:57 -07:00
|
|
|
|
2013-06-25 11:26:49 -07:00
|
|
|
typedef unsigned int(*vp9_sad_avg_fn_t)(const uint8_t *src_ptr,
|
|
|
|
int source_stride,
|
|
|
|
const uint8_t *ref_ptr,
|
|
|
|
int ref_stride,
|
2014-05-13 10:11:42 -07:00
|
|
|
const uint8_t *second_pred);
|
2013-06-25 11:26:49 -07:00
|
|
|
|
2012-12-18 15:31:19 -08:00
|
|
|
typedef void (*vp9_sad_multi_fn_t)(const uint8_t *src_ptr,
|
2012-10-21 20:47:57 -07:00
|
|
|
int source_stride,
|
2012-12-18 15:31:19 -08:00
|
|
|
const uint8_t *ref_ptr,
|
2012-10-21 20:47:57 -07:00
|
|
|
int ref_stride,
|
|
|
|
unsigned int *sad_array);
|
|
|
|
|
2012-12-18 15:31:19 -08:00
|
|
|
typedef void (*vp9_sad_multi_d_fn_t)(const uint8_t *src_ptr,
|
2012-10-21 20:47:57 -07:00
|
|
|
int source_stride,
|
2013-03-01 12:43:41 -08:00
|
|
|
const uint8_t* const ref_ptr[],
|
2012-10-21 20:47:57 -07:00
|
|
|
int ref_stride, unsigned int *sad_array);
|
|
|
|
|
2012-12-18 15:31:19 -08:00
|
|
|
typedef unsigned int (*vp9_variance_fn_t)(const uint8_t *src_ptr,
|
2012-10-21 20:47:57 -07:00
|
|
|
int source_stride,
|
2012-12-18 15:31:19 -08:00
|
|
|
const uint8_t *ref_ptr,
|
2012-10-21 20:47:57 -07:00
|
|
|
int ref_stride,
|
|
|
|
unsigned int *sse);
|
|
|
|
|
2012-12-18 15:31:19 -08:00
|
|
|
typedef unsigned int (*vp9_subpixvariance_fn_t)(const uint8_t *src_ptr,
|
2012-10-21 20:47:57 -07:00
|
|
|
int source_stride,
|
|
|
|
int xoffset,
|
|
|
|
int yoffset,
|
2012-12-18 15:31:19 -08:00
|
|
|
const uint8_t *ref_ptr,
|
2012-10-21 20:47:57 -07:00
|
|
|
int Refstride,
|
|
|
|
unsigned int *sse);
|
|
|
|
|
2013-05-07 09:45:28 -07:00
|
|
|
typedef unsigned int (*vp9_subp_avg_variance_fn_t)(const uint8_t *src_ptr,
|
|
|
|
int source_stride,
|
|
|
|
int xoffset,
|
|
|
|
int yoffset,
|
|
|
|
const uint8_t *ref_ptr,
|
|
|
|
int Refstride,
|
|
|
|
unsigned int *sse,
|
|
|
|
const uint8_t *second_pred);
|
|
|
|
|
2013-02-22 16:06:48 -08:00
|
|
|
typedef struct vp9_variance_vtable {
|
2013-06-25 11:26:49 -07:00
|
|
|
vp9_sad_fn_t sdf;
|
|
|
|
vp9_sad_avg_fn_t sdaf;
|
|
|
|
vp9_variance_fn_t vf;
|
|
|
|
vp9_subpixvariance_fn_t svf;
|
|
|
|
vp9_subp_avg_variance_fn_t svaf;
|
|
|
|
vp9_sad_multi_fn_t sdx3f;
|
2014-04-10 23:31:45 -07:00
|
|
|
vp9_sad_multi_fn_t sdx8f;
|
2013-06-25 11:26:49 -07:00
|
|
|
vp9_sad_multi_d_fn_t sdx4df;
|
2012-10-31 14:40:53 -07:00
|
|
|
} vp9_variance_fn_ptr_t;
|
2010-05-18 11:58:33 -04:00
|
|
|
|
2014-01-18 12:16:11 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2012-12-18 15:31:19 -08:00
|
|
|
#endif // VP9_ENCODER_VP9_VARIANCE_H_
|