From 0df974cb0d60e1d0ad9d76871ac7818fd19d8e63 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Fri, 11 Oct 2013 12:51:53 +0300 Subject: [PATCH] Change sad functions to accept negative block widths. This makes boundary checking clearer. --- src/picture.c | 18 +++++++++--------- src/picture.h | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/picture.c b/src/picture.c index 65e777f2..03b03478 100644 --- a/src/picture.c +++ b/src/picture.c @@ -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) { diff --git a/src/picture.h b/src/picture.h index bfc6c1d1..aa9e52f2 100644 --- a/src/picture.h +++ b/src/picture.h @@ -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);