Fix extrapolated inter SATD
#include <limits.h>
#include <stdlib.h>
+#include "strategies/strategies-ipol.h"
#include "strategies/strategies-picture.h"
#include "threads.h"
@@ -519,17 +520,36 @@ unsigned kvz_image_calc_satd(const kvz_picture *pic,
ref_data,
ref->stride) >> (KVZ_BIT_DEPTH - 8);
} else {
- // Call a routine that knows how to interpolate pixels outside the frame.
- // TODO: write interpolated SATD
- unsigned sad = image_interpolated_sad(pic,
- ref,
- pic_x,
+ // Extrapolate pixels from outside the frame.
+ kvz_extended_block block;
+ kvz_get_extended_block(pic_x,
pic_y,
- ref_x,
- ref_y,
+ ref_x - pic_x,
+ ref_y - pic_y,
+ 0,
+ 0,
+ ref->y,
+ ref->width,
+ ref->height,
+ 0,
block_width,
- block_height) >> (KVZ_BIT_DEPTH - 8);
- return 2.4 * sad;
+ block_height,
+ &block);
+
+ const kvz_pixel *pic_data = &pic->y[pic_y * pic->stride + pic_x];
+
+ unsigned satd = kvz_satd_any_size(block_width,
+ block_height,
+ pic_data,
+ pic->stride,
+ block.buffer,
+ block.stride) >> (KVZ_BIT_DEPTH - 8);
+
+ if (block.malloc_used) {
+ FREE_POINTER(block.buffer);
+ }
+
+ return satd;
}
}
