Change sad functions to accept negative block widths.

This makes boundary checking clearer.
This commit is contained in:
Ari Koivula 2013-10-11 12:51:53 +03:00
parent 235b1ec0bc
commit 0df974cb0d
2 changed files with 17 additions and 17 deletions

View file

@ -560,10 +560,10 @@ uint32_t sad4x4(int16_t *block1, uint32_t stride1,
}
unsigned cor_sad(unsigned char* pic_data, unsigned char* ref_data,
unsigned block_width, unsigned block_height, unsigned width)
int block_width, int block_height, unsigned width)
{
unsigned char ref = *ref_data;
unsigned x, y;
int x, y;
unsigned sad = 0;
for (y = 0; y < block_height; ++y) {
@ -576,9 +576,9 @@ unsigned cor_sad(unsigned char* pic_data, unsigned char* ref_data,
}
unsigned ver_sad(unsigned char* pic_data, unsigned char* ref_data,
unsigned block_width, unsigned block_height, unsigned width)
int block_width, int block_height, unsigned width)
{
unsigned x, y;
int x, y;
unsigned sad = 0;
for (y = 0; y < block_height; ++y) {
@ -591,9 +591,9 @@ unsigned ver_sad(unsigned char* pic_data, unsigned char* ref_data,
}
unsigned hor_sad(unsigned char* pic_data, unsigned char* ref_data,
unsigned block_width, unsigned block_height, unsigned width)
int block_width, int block_height, unsigned width)
{
unsigned x, y;
int x, y;
unsigned sad = 0;
for (y = 0; y < block_height; ++y) {
@ -619,10 +619,10 @@ unsigned hor_sad(unsigned char* pic_data, unsigned char* ref_data,
*
* \returns Sum of Absolute Differences
*/
uint32_t reg_sad(uint8_t *data1, uint8_t *data2,
unsigned width, unsigned height, unsigned stride)
unsigned reg_sad(uint8_t *data1, uint8_t *data2,
int width, int height, unsigned stride)
{
unsigned y, x;
int y, x;
unsigned sad = 0;
for (y = 0; y < height; ++y) {

View file

@ -121,14 +121,14 @@ uint32_t sad8x8(int16_t *block1, uint32_t stride1,
uint32_t sad4x4(int16_t *block1, uint32_t stride1,
int16_t* block2, uint32_t stride2);
uint32_t cor_sad(uint8_t *data1, uint8_t *data2,
unsigned width, unsigned height, unsigned stride);
uint32_t ver_sad(uint8_t *data1, uint8_t *data2,
unsigned width, unsigned height, unsigned stride);
uint32_t hor_sad(uint8_t *data1, uint8_t *data2,
unsigned width, unsigned height, unsigned stride);
uint32_t reg_sad(uint8_t *data1, uint8_t *data2,
unsigned width, unsigned height, unsigned stride);
unsigned cor_sad(uint8_t *data1, uint8_t *data2,
int width, int height, unsigned stride);
unsigned ver_sad(uint8_t *data1, uint8_t *data2,
int width, int height, unsigned stride);
unsigned hor_sad(uint8_t *data1, uint8_t *data2,
int width, int height, unsigned stride);
unsigned reg_sad(uint8_t *data1, uint8_t *data2,
int width, int height, unsigned stride);
double image_psnr(uint8_t *frame1, uint8_t *frame2, int32_t x, int32_t y);