From 235b1ec0bc1dd1b4d315a148018a6e27d62fd185 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Fri, 11 Oct 2013 12:39:56 +0300 Subject: [PATCH] Add rest of the quadrants for sad calculation. - All tests pass. - Movement vectors that don't overlap with the frame aren't handled yet. --- src/search.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/search.c b/src/search.c index fcc86f32..5ca0a877 100644 --- a/src/search.c +++ b/src/search.c @@ -120,15 +120,52 @@ unsigned get_block_sad(picture *pic, picture *ref, &ref_data[top * width], block_width, block_height - top, width); } else if (bottom && left) { - + result += hor_sad(pic_data, + &ref_data[left], + left, block_height - bottom, width); + result += reg_sad(&pic_data[left], + &ref_data[left], + block_width - left, block_height - bottom, width); + result += cor_sad(&pic_data[(block_height - bottom) * width], + &ref_data[(block_height - bottom - 1) * width + left], + left, bottom, width); + result += ver_sad(&pic_data[(block_height - bottom) * width + left], + &ref_data[(block_height - bottom - 1) * width + left], + block_width - left, bottom, width); } else if (bottom && right) { - + result += reg_sad(pic_data, + ref_data, + block_width - right, block_height - bottom, width); + result += hor_sad(&pic_data[block_width - right], + &ref_data[block_width - right - 1], + right, block_height - bottom, width); + result += ver_sad(&pic_data[(block_height - bottom) * width], + &ref_data[(block_height - bottom - 1) * width], + block_width - right, bottom, width); + result += cor_sad(&pic_data[(block_height - bottom) * width + block_width - right], + &ref_data[(block_height - bottom - 1) * width + block_width - right - 1], + right, bottom, width); } else if (left) { - + result += hor_sad(pic_data, + &ref_data[left], + left, block_height, width); + result += reg_sad(&pic_data[left], + &ref_data[left], + block_width - left, block_height, width); } else if (right) { - + result += reg_sad(pic_data, + ref_data, + block_width - right, block_height, width); + result += hor_sad(&pic_data[block_width - right], + &ref_data[block_width - right - 1], + right, block_height, width); } else if (bottom) { - + result += reg_sad(pic_data, + ref_data, + block_width, block_height - bottom, width); + result += ver_sad(&pic_data[(block_height - bottom) * width], + &ref_data[(block_height - bottom - 1) * width], + block_width, bottom, width); } else { result += reg_sad(pic_data, ref_data, block_width, block_height, width); }