Commit 6b151d43 authored by Johann's avatar Johann
Browse files

Clarify 'max_sad' usage

Depending on implementation the optimized SAD functions may return early
when the calculated SAD exceeds max_sad.

Change-Id: I05ce5b2d34e6d45fb3ec2a450aa99c4f3343bf3a
parent 3653fb47
......@@ -13,24 +13,30 @@
#include "vpx_config.h"
#include "vpx/vpx_integer.h"
unsigned int vp8_sad16x16_c(
static __inline
unsigned int sad_mx_n_c(
const unsigned char *src_ptr,
int src_stride,
const unsigned char *ref_ptr,
int ref_stride,
int max_sad)
int max_sad,
int m,
int n)
{
int r, c;
unsigned int sad = 0;
for (r = 0; r < 16; r++)
for (r = 0; r < n; r++)
{
for (c = 0; c < 16; c++)
for (c = 0; c < m; c++)
{
sad += abs(src_ptr[c] - ref_ptr[c]);
}
if (sad > max_sad)
break;
src_ptr += src_stride;
ref_ptr += ref_stride;
}
......@@ -38,32 +44,19 @@ unsigned int vp8_sad16x16_c(
return sad;
}
/* max_sad is provided as an optional optimization point. Alternative
* implementations of these functions are not required to check it.
*/
static __inline
unsigned int sad_mx_n_c(
unsigned int vp8_sad16x16_c(
const unsigned char *src_ptr,
int src_stride,
const unsigned char *ref_ptr,
int ref_stride,
int m,
int n)
int max_sad)
{
int r, c;
unsigned int sad = 0;
for (r = 0; r < n; r++)
{
for (c = 0; c < m; c++)
{
sad += abs(src_ptr[c] - ref_ptr[c]);
}
src_ptr += src_stride;
ref_ptr += ref_stride;
}
return sad;
return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, max_sad, 16, 16);
}
......@@ -72,10 +65,10 @@ unsigned int vp8_sad8x8_c(
int src_stride,
const unsigned char *ref_ptr,
int ref_stride,
int max_sad)
int max_sad)
{
return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 8, 8);
return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, max_sad, 8, 8);
}
......@@ -84,10 +77,10 @@ unsigned int vp8_sad16x8_c(
int src_stride,
const unsigned char *ref_ptr,
int ref_stride,
int max_sad)
int max_sad)
{
return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 16, 8);
return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, max_sad, 16, 8);
}
......@@ -97,10 +90,10 @@ unsigned int vp8_sad8x16_c(
int src_stride,
const unsigned char *ref_ptr,
int ref_stride,
int max_sad)
int max_sad)
{
return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 8, 16);
return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, max_sad, 8, 16);
}
......@@ -109,10 +102,10 @@ unsigned int vp8_sad4x4_c(
int src_stride,
const unsigned char *ref_ptr,
int ref_stride,
int max_sad)
int max_sad)
{
return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 4, 4);
return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, max_sad, 4, 4);
}
void vp8_sad16x16x3_c(
......
......@@ -89,7 +89,7 @@ sym(vp8_sad16x16_wmt):
; int src_stride,
; unsigned char *ref_ptr,
; int ref_stride,
; int max_err)
; int max_sad)
global sym(vp8_sad8x16_wmt)
sym(vp8_sad8x16_wmt):
push rbp
......
......@@ -19,7 +19,7 @@
%define end_ptr rcx
%define ret_var rbx
%define result_ptr arg(4)
%define max_err arg(4)
%define max_sad arg(4)
%define height dword ptr arg(4)
push rbp
mov rbp, rsp
......@@ -42,7 +42,7 @@
%define end_ptr r10
%define ret_var r11
%define result_ptr [rsp+xmm_stack_space+8+4*8]
%define max_err [rsp+xmm_stack_space+8+4*8]
%define max_sad [rsp+xmm_stack_space+8+4*8]
%define height dword ptr [rsp+xmm_stack_space+8+4*8]
%else
%define src_ptr rdi
......@@ -52,7 +52,7 @@
%define end_ptr r9
%define ret_var r10
%define result_ptr r8
%define max_err r8
%define max_sad r8
%define height r8
%endif
%endif
......@@ -67,7 +67,7 @@
%define end_ptr
%define ret_var
%define result_ptr
%define max_err
%define max_sad
%define height
%if ABI_IS_32BIT
......@@ -587,7 +587,7 @@ sym(vp8_sad4x4x3_sse3):
; int src_stride,
; unsigned char *ref_ptr,
; int ref_stride,
; int max_err)
; int max_sad)
;%define lddqu movdqu
global sym(vp8_sad16x16_sse3)
sym(vp8_sad16x16_sse3):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment